summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-07-26 16:26:46 -0400
committerColin Walters <walters@verbum.org>2010-08-17 13:14:51 -0400
commit8942500c99de223eff6f91677a5dff206e09b3a7 (patch)
tree67b89e622e14874635a7fa9268ac12e16d363f31 /tools
parent616a918019f730184bc7aee0f4570a67db8850b9 (diff)
downloadgobject-introspection-8942500c99de223eff6f91677a5dff206e09b3a7.tar.gz
[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...
Diffstat (limited to 'tools')
-rw-r--r--tools/compiler.c50
1 files changed, 10 insertions, 40 deletions
diff --git a/tools/compiler.c b/tools/compiler.c
index 62c0d345..1c68b0ac 100644
--- a/tools/compiler.c
+++ b/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");