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>
* vala/valasemanticanalyzer.vala: add symbol dependency for generic
......
......@@ -164,7 +164,7 @@ stringtext ([^"])|(\\.)
"\""{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)
{
/* extract current filename from #line directives */
GString *filename_builder;
gboolean in_string;
gboolean in_string, found_filename;
lineno = 0;
found_filename = FALSE;
in_string = FALSE;
filename_builder = g_string_new ("");
......@@ -218,6 +220,11 @@ static void process_directive (void)
if (!in_string) {
if (c == '\"') {
in_string = TRUE;
found_filename = TRUE;
} else if (c >= '0' && c <= '9') {
if (!found_filename) {
lineno = lineno * 10 + (c - '0');
}
}
} else {
if (c == '\"') {
......@@ -232,7 +239,6 @@ static void process_directive (void)
}
c = input ();
}
++lineno;
if (filename_builder->len > 0) {
char *filename = g_strcompress (filename_builder->str);
......
......@@ -1190,7 +1190,7 @@ yyerror(const char *s)
/* ignore errors while doing a macro scan as not all object macros
* have valid expressions */
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)
for (l = igenerator->symbol_list; l != NULL; l = l->next) {
CSymbol *sym = l->data;
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);
......@@ -1227,6 +1230,7 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
GList *l;
for (l = igenerator->filenames; l != NULL; l = l->next) {
FILE *f = fopen (l->data, "r");
int line = 1;
GString *define_line;
char *str;
......@@ -1236,14 +1240,22 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
if (c != '#') {
/* ignore line */
c = eat_line (f, c);
line++;
continue;
}
/* print current location */
str = g_strescape (l->data, "");
fprintf (fmacros, "# %d \"%s\"\n", line, str);
g_free (str);
c = eat_hspace (f);
c = read_identifier (f, c, &str);
if (strcmp (str, "define") != 0 || (c != ' ' && c != '\t')) {
g_free (str);
/* ignore line */
c = eat_line (f, c);
line++;
continue;
}
g_free (str);
......@@ -1253,6 +1265,7 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
g_free (str);
/* ignore line */
c = eat_line (f, c);
line++;
continue;
}
define_line = g_string_new ("#define ");
......@@ -1271,6 +1284,7 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
g_string_free (define_line, TRUE);
/* ignore line */
c = eat_line (f, c);
line++;
continue;
}
......@@ -1279,18 +1293,19 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
c = fgetc (f);
/* found function-like macro */
fprintf (fmacros, define_line->str);
fprintf (fmacros, "\n");
fprintf (fmacros, "%s\n", define_line->str);
g_string_free (define_line, TRUE);
/* ignore rest of line */
c = eat_line (f, c);
line++;
continue;
}
if (c != ' ' && c != '\t') {
g_string_free (define_line, TRUE);
/* ignore line */
c = eat_line (f, c);
line++;
continue;
}
while (c != EOF && c != '\n') {
......@@ -1308,10 +1323,10 @@ static void g_igenerator_parse_macros (GIGenerator *igenerator) {
}
/* found object-like macro */
fprintf (fmacros, define_line->str);
fprintf (fmacros, "\n");
fprintf (fmacros, "%s\n", define_line->str);
c = eat_line (f, c);
line++;
}
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