[gobject-introspection] Maintransfomer: fix again paring error domains with unregistered enums



commit b87a149dfbc5ce416e86e8f4aa9b45fc8a8cc791
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Jul 2 22:51:19 2012 +0200

    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">
+    <enumeration name="DBusError"
+                 c:type="SDBusError"
+                 glib:error-domain="s-dbus-error">
+      <member name="code1" value="1" c:identifier="S_DBUS_ERROR_CODE1"/>
+      <member name="code2" value="2" c:identifier="S_DBUS_ERROR_CODE2"/>
+      <member name="code3" value="3" c:identifier="S_DBUS_ERROR_CODE3"/>
+    </enumeration>
     <record name="Point" c:type="SPoint">
       <field name="x" writable="1">
         <type name="gdouble" c:type="double"/>
@@ -30,6 +37,11 @@ and/or use gtk-doc annotations.  -->
       <member name="code2" value="2" c:identifier="S_SPAWN_ERROR_CODE2"/>
       <member name="code3" value="3" c:identifier="S_SPAWN_ERROR_CODE3"/>
     </enumeration>
+    <function name="dbus_error_quark" c:identifier="s_dbus_error_quark">
+      <return-value transfer-ownership="none">
+        <type name="GLib.Quark" c:type="GQuark"/>
+      </return-value>
+    </function>
     <function name="hello" c:identifier="s_hello">
       <return-value transfer-ownership="none">
         <type name="none" c:type="void"/>
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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]