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
type arguments
"\""{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]); }
%%
{
/* 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 ("");
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 == '\"') {
}
c = input ();
}
- ++lineno;
if (filename_builder->len > 0) {
char *filename = g_strcompress (filename_builder->str);
/* 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);
}
}
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);
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;
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);
g_free (str);
/* ignore line */
c = eat_line (f, c);
+ line++;
continue;
}
define_line = g_string_new ("#define ");
g_string_free (define_line, TRUE);
/* ignore line */
c = eat_line (f, c);
+ line++;
continue;
}
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') {
}
/* 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);