From: Colin Walters Date: Thu, 11 Feb 2010 22:18:28 +0000 (-0500) Subject: [g-ir-compiler] Slightly less lame error messages X-Git-Tag: GOBJECT_INTROSPECTION_0_6_8~12 X-Git-Url: http://git.roojs.org/?p=gnome.gobject-introspection;a=commitdiff_plain;h=a9e6ae83ffa54194adc01e84c85ac336c59fd520 [g-ir-compiler] Slightly less lame error messages To make things really better we should track the line origin of element from the .gir file (and actually we need to do better checking in the scanner), but this is slightly less lame. --- diff --git a/girepository/girmodule.c b/girepository/girmodule.c index bf1e856..b954d15 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -20,6 +20,7 @@ #include #include +#include #include "girmodule.h" #include "girnode.h" @@ -75,6 +76,39 @@ g_ir_module_free (GIrModule *module) g_free (module); } +/** + * g_ir_module_fatal: + * @module: Current module + * @line: Origin line number, or 0 if unknown + * @msg: printf-format string + * @args: Remaining arguments + * + * Report a fatal error, then exit. + */ +void +g_ir_module_fatal (GIrModule *module, + guint line, + const char *msg, + ...) +{ + char *formatted; + + va_list args; + + va_start (args, msg); + + formatted = g_strdup_vprintf (msg, args); + + if (line) + g_printerr ("%s-%s.gir:%d: error: %s\n", module->name, module->version, line, formatted); + else + g_printerr ("%s-%s.gir: error: %s\n", module->name, module->version, formatted); + + exit (1); + + va_end (args); +} + static void add_alias_foreach (gpointer key, gpointer value, diff --git a/girepository/girmodule.h b/girepository/girmodule.h index 5a558c3..da3fb35 100644 --- a/girepository/girmodule.h +++ b/girepository/girmodule.h @@ -61,6 +61,8 @@ void g_ir_module_add_include_module (GIrModule *module, GTypelib * g_ir_module_build_typelib (GIrModule *module, GList *modules); +void g_ir_module_fatal (GIrModule *module, guint line, const char *msg, ...) G_GNUC_PRINTF (3, 4) G_GNUC_NORETURN; + void _g_irnode_init_stats (void); void _g_irnode_dump_stats (void); diff --git a/girepository/girnode.c b/girepository/girnode.c index 9f62345..2523ee1 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -1090,7 +1090,7 @@ find_entry_node (GIrModule *module, goto out; } - g_warning ("Entry '%s' not found", name); + g_ir_module_fatal (module, 0, "Type reference '%s' not found", name); out: diff --git a/girepository/giroffsets.c b/girepository/giroffsets.c index 96ff576..dcfd75e 100644 --- a/girepository/giroffsets.c +++ b/girepository/giroffsets.c @@ -156,7 +156,7 @@ get_interface_size_alignment (GIrNodeType *type, if (!g_ir_find_node (module, modules, type->interface, &iface, &iface_module)) { - g_warning ("Can't resolve type '%s' for %s", type->interface, who); + g_ir_module_fatal (module, 0, "Can't resolve type '%s' for %s", type->interface, who); *size = -1; *alignment = -1; return FALSE;