diff options
Diffstat (limited to 'girepository')
-rw-r--r-- | girepository/girmodule.c | 34 | ||||
-rw-r--r-- | girepository/girmodule.h | 2 | ||||
-rw-r--r-- | girepository/girnode.c | 2 | ||||
-rw-r--r-- | girepository/giroffsets.c | 2 |
4 files changed, 38 insertions, 2 deletions
diff --git a/girepository/girmodule.c b/girepository/girmodule.c index bf1e856b..b954d15d 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <string.h> +#include <stdlib.h> #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 5a558c35..da3fb35d 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 9f623453..2523ee1f 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 96ff5764..dcfd75e5 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; |