From b87a149dfbc5ce416e86e8f4aa9b45fc8a8cc791 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 2 Jul 2012 22:51:19 +0200 Subject: [PATCH] Maintransfomer: fix again paring error domains with unregistered enums Previous fix was wrong, as it called to_underscores_noprefix on a prefixed type name. The actual fix is to call the transformer to do the prefix / type_name split, and turn the latter to underscores. Test case included. https://bugzilla.gnome.org/show_bug.cgi?id=634202 --- giscanner/maintransformer.py | 16 +++------------- tests/scanner/SLetter-1.0-expected.gir | 12 ++++++++++++ tests/scanner/sletter.c | 6 ++++++ tests/scanner/sletter.h | 9 +++++++++ 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 850d242..8723875 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -900,19 +900,9 @@ the ones that failed to resolve removed.""" for enum in self._namespace.itervalues(): if not isinstance(enum, ast.Enum): continue - type_name = enum.ctype - uscored = to_underscores(type_name).lower() - + uscored = to_underscores_noprefix(enum.name).lower() uscore_enums[uscored] = enum - - try: - no_uscore_prefixed = self._transformer.strip_identifier(type_name) - except TransformerException, e: - message.warn(e) - no_uscore_prefixed = None - - if no_uscore_prefixed not in uscore_enums: - uscore_enums[no_uscore_prefixed] = enum + uscore_enums[enum.name] = enum for node in self._namespace.itervalues(): if not isinstance(node, ast.ErrorQuarkFunction): @@ -927,7 +917,7 @@ the ones that failed to resolve removed.""" else: enum = self._uscore_type_names.get(short) if enum is None: - enum = uscore_enums.get(full) + enum = uscore_enums.get(short) if enum is not None: enum.error_domain = node.error_domain else: diff --git a/tests/scanner/SLetter-1.0-expected.gir b/tests/scanner/SLetter-1.0-expected.gir index 9c42e4f..c6da0df 100644 --- a/tests/scanner/SLetter-1.0-expected.gir +++ b/tests/scanner/SLetter-1.0-expected.gir @@ -15,6 +15,13 @@ and/or use gtk-doc annotations. --> shared-library="libsletter.so" c:identifier-prefixes="S" c:symbol-prefixes="s"> + + + + + @@ -30,6 +37,11 @@ and/or use gtk-doc annotations. --> + + + + + diff --git a/tests/scanner/sletter.c b/tests/scanner/sletter.c index 09f3cfd..a6e7bcc 100644 --- a/tests/scanner/sletter.c +++ b/tests/scanner/sletter.c @@ -13,3 +13,9 @@ s_spawn_error_quark (void) { return g_quark_from_static_string ("s-spawn-error"); } + +GQuark +s_dbus_error_quark (void) +{ + return g_quark_from_static_string ("s-dbus-error"); +} diff --git a/tests/scanner/sletter.h b/tests/scanner/sletter.h index 24dfd68..20797f6 100644 --- a/tests/scanner/sletter.h +++ b/tests/scanner/sletter.h @@ -19,4 +19,13 @@ typedef enum } SSpawnError; GQuark s_spawn_error_quark (void); +/* Like GDBusError but not registered with GType */ +typedef enum +{ + S_DBUS_ERROR_CODE1 = 1, + S_DBUS_ERROR_CODE2 = 2, + S_DBUS_ERROR_CODE3 = 3 +} SDBusError; +GQuark s_dbus_error_quark (void); + #endif -- 2.7.4