Commit 1889d0d8 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

improve error reporting and ignore get_type functions with parameters

2007-11-22  Juerg Billeter  <j@bitron.ch>

	* gobject-introspection/clexer.l, gobject-introspection/cparser.y,
	  gobject-introspection/gen-introspect.c: improve error reporting and
	  ignore get_type functions with parameters

svn path=/trunk/; revision=695
parent 4f224ced
2007-11-22 Jürg Billeter <j@bitron.ch>
* gobject-introspection/clexer.l, gobject-introspection/cparser.y,
gobject-introspection/gen-introspect.c: improve error reporting and
ignore get_type functions with parameters
2007-11-22 Jürg Billeter <j@bitron.ch> 2007-11-22 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala: add symbol dependency for generic * vala/valasemanticanalyzer.vala: add symbol dependency for generic
......
...@@ -164,7 +164,7 @@ stringtext ([^"])|(\\.) ...@@ -164,7 +164,7 @@ stringtext ([^"])|(\\.)
"\""{stringtext}*"\"" { return STRING; } "\""{stringtext}*"\"" { return STRING; }
"L\""{stringtext}*"\"" { return STRING; } "L\""{stringtext}*"\"" { return STRING; }
. { fprintf(stderr, "%d: unexpected character `%c'\n", lineno, yytext[0]); } . { fprintf(stderr, "%s:%d: unexpected character `%c'\n", the_igenerator->current_filename, lineno, yytext[0]); }
%% %%
...@@ -208,8 +208,10 @@ static void process_directive (void) ...@@ -208,8 +208,10 @@ static void process_directive (void)
{ {
/* extract current filename from #line directives */ /* extract current filename from #line directives */
GString *filename_builder; GString *filename_builder;
gboolean in_string; gboolean in_string, found_filename;
lineno = 0;
found_filename = FALSE;
in_string = FALSE; in_string = FALSE;
filename_builder = g_string_new (""); filename_builder = g_string_new ("");
...@@ -218,6 +220,11 @@ static void process_directive (void) ...@@ -218,6 +220,11 @@ static void process_directive (void)
if (!in_string) { if (!in_string) {
if (c == '\"') { if (c == '\"') {
in_string = TRUE; in_string = TRUE;
found_filename = TRUE;
} else if (c >= '0' && c <= '9') {
if (!found_filename) {
lineno = lineno * 10 + (c - '0');
}
} }
} else { } else {
if (c == '\"') { if (c == '\"') {
...@@ -232,7 +239,6 @@ static void process_directive (void) ...@@ -232,7 +239,6 @@ static void process_directive (void)
} }
c = input (); c = input ();
} }
++lineno;
if (filename_builder->len > 0) { if (filename_builder->len > 0) {
char *filename = g_strcompress (filename_builder->str); char *filename = g_strcompress (filename_builder->str);
......
...@@ -1190,7 +1190,7 @@ yyerror(const char *s) ...@@ -1190,7 +1190,7 @@ yyerror(const char *s)
/* ignore errors while doing a macro scan as not all object macros /* ignore errors while doing a macro scan as not all object macros
* have valid expressions */ * have valid expressions */
if (!the_igenerator->macro_scan) { if (!the_igenerator->macro_scan) {
fprintf(stderr, "%d: %s\n", lineno, s); fprintf(stderr, "%s:%d: %s\n", the_igenerator->current_filename, lineno, s);
} }
} }
......
...@@ -1036,7 +1036,10 @@ void g_igenerator_generate (GIGenerator *igenerator) ...@@ -1036,7 +1036,10 @@ void g_igenerator_generate (GIGenerator *igenerator)
for (l = igenerator->symbol_list; l != NULL; l = l->next) { for (l = igenerator->symbol_list; l != NULL; l = l->next) {
CSymbol *sym = l->data; CSymbol *sym = l->data;
if (sym->type == CSYMBOL_TYPE_FUNCTION && g_str_has_suffix (sym->ident, "_get_type")) { if (sym->type == CSYMBOL_TYPE_FUNCTION && g_str_has_suffix (sym->ident, "_get_type")) {
igenerator->get_type_symbols = g_list_prepend (igenerator->get_type_symbols, sym->ident); if (sym->base_type->child_list == NULL) {
// ignore get_type functions with parameters
igenerator->get_type_symbols = g_list_prepend (igenerator->get_type_symbols, sym->ident);
}
} }
} }
g_igenerator_process_types (igenerator); g_igenerator_process_types (igenerator);
...@@ -1227,6 +1230,7 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) { ...@@ -1227,6 +1230,7 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
GList *l; GList *l;
for (l = igenerator->filenames; l != NULL; l = l->next) { for (l = igenerator->filenames; l != NULL; l = l->next) {
FILE *f = fopen (l->data, "r"); FILE *f = fopen (l->data, "r");
int line = 1;
GString *define_line; GString *define_line;
char *str; char *str;
...@@ -1236,14 +1240,22 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) { ...@@ -1236,14 +1240,22 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
if (c != '#') { if (c != '#') {
/* ignore line */ /* ignore line */
c = eat_line (f, c); c = eat_line (f, c);
line++;
continue; continue;
} }
/* print current location */
str = g_strescape (l->data, "");
fprintf (fmacros, "# %d \"%s\"\n", line, str);
g_free (str);
c = eat_hspace (f); c = eat_hspace (f);
c = read_identifier (f, c, &str); c = read_identifier (f, c, &str);
if (strcmp (str, "define") != 0 || (c != ' ' && c != '\t')) { if (strcmp (str, "define") != 0 || (c != ' ' && c != '\t')) {
g_free (str); g_free (str);
/* ignore line */ /* ignore line */
c = eat_line (f, c); c = eat_line (f, c);
line++;
continue; continue;
} }
g_free (str); g_free (str);
...@@ -1253,6 +1265,7 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) { ...@@ -1253,6 +1265,7 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
g_free (str); g_free (str);
/* ignore line */ /* ignore line */
c = eat_line (f, c); c = eat_line (f, c);
line++;
continue; continue;
} }
define_line = g_string_new ("#define "); define_line = g_string_new ("#define ");
...@@ -1271,6 +1284,7 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) { ...@@ -1271,6 +1284,7 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
g_string_free (define_line, TRUE); g_string_free (define_line, TRUE);
/* ignore line */ /* ignore line */
c = eat_line (f, c); c = eat_line (f, c);
line++;
continue; continue;
} }
...@@ -1279,18 +1293,19 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) { ...@@ -1279,18 +1293,19 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
c = fgetc (f); c = fgetc (f);
/* found function-like macro */ /* found function-like macro */
fprintf (fmacros, define_line->str); fprintf (fmacros, "%s\n", define_line->str);
fprintf (fmacros, "\n");
g_string_free (define_line, TRUE); g_string_free (define_line, TRUE);
/* ignore rest of line */ /* ignore rest of line */
c = eat_line (f, c); c = eat_line (f, c);
line++;
continue; continue;
} }
if (c != ' ' && c != '\t') { if (c != ' ' && c != '\t') {
g_string_free (define_line, TRUE); g_string_free (define_line, TRUE);
/* ignore line */ /* ignore line */
c = eat_line (f, c); c = eat_line (f, c);
line++;
continue; continue;
} }
while (c != EOF && c != '\n') { while (c != EOF && c != '\n') {
...@@ -1308,10 +1323,10 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) { ...@@ -1308,10 +1323,10 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
} }
/* found object-like macro */ /* found object-like macro */
fprintf (fmacros, define_line->str); fprintf (fmacros, "%s\n", define_line->str);
fprintf (fmacros, "\n");
c = eat_line (f, c); c = eat_line (f, c);
line++;
} }
fclose (f); fclose (f);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment