From 45a04358b6f765e8dba2ad5a735ef3c31323cfdf Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 26 Jul 2010 16:26:46 -0400 Subject: [PATCH] [gircompiler] Clean up parsing We never actually include multiple modules in the compiler, so just nuke that. Also rather than passing around GIrModule consistently pass around a GIrTypelibBuild structure which has various things. This lets us maintain a stack there which we can walk for better error messages. Also, fix up the node lookup in giroffsets.c; previously it didn't really handle includes correctly. We really need to switch to always using Foo.Bar (i.e. GIName) names internally... --- girepository/tools/compiler.c | 50 +++++++---------------------------- 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/girepository/tools/compiler.c b/girepository/tools/compiler.c index 62c0d345c..1c68b0ac2 100644 --- a/girepository/tools/compiler.c +++ b/girepository/tools/compiler.c @@ -140,7 +140,7 @@ main (int argc, char ** argv) GOptionContext *context; GError *error = NULL; GIrParser *parser; - GList *m, *modules; + GIrModule *module; gint i; g_typelib_check_sanity (); @@ -178,35 +178,22 @@ main (int argc, char ** argv) g_ir_parser_set_includes (parser, (const char*const*) includedirs); - modules = NULL; - for (i = 0; input[i]; i++) + module = g_ir_parser_parse_file (parser, input[0], &error); + if (module == NULL) { - GList *mods; - mods = g_ir_parser_parse_file (parser, input[i], &error); + g_fprintf (stderr, "error parsing file %s: %s\n", + input[0], error->message); - if (mods == NULL) - { - g_fprintf (stderr, "error parsing file %s: %s\n", - input[i], error->message); - - return 1; - } - - modules = g_list_concat (modules, mods); + return 1; } g_debug ("[parsing] done"); g_debug ("[building] start"); - for (m = modules; m; m = m->next) - { - GIrModule *module = m->data; - gchar *prefix; + { GTypelib *typelib; - if (mname && strcmp (mname, module->name) != 0) - continue; if (shlib) { if (module->shared_library) @@ -216,33 +203,16 @@ main (int argc, char ** argv) g_debug ("[building] module %s", module->name); - typelib = g_ir_module_build_typelib (module, modules); + typelib = g_ir_module_build_typelib (module); if (typelib == NULL) - { - g_error ("Failed to build typelib for module '%s'\n", module->name); - - continue; - } + g_error ("Failed to build typelib for module '%s'\n", module->name); if (!g_typelib_validate (typelib, &error)) g_error ("Invalid typelib for module '%s': %s", module->name, error->message); - if (!mname && (m->next || m->prev) && output) - prefix = module->name; - else - prefix = NULL; - - write_out_typelib (prefix, typelib); + write_out_typelib (NULL, typelib); g_typelib_free (typelib); typelib = NULL; - - /* when writing to stdout, stop after the first module */ - if (m->next && !output && !mname) - { - g_warning ("%d modules omitted\n", g_list_length (modules) - 1); - - break; - } } g_debug ("[building] done");