[gobject-introspection] scanner: Ensure "complete_ctype" patch doesn't throw an exception for anonymous unions



commit f77cfc4275b1fba4f9fedea6e40b00e0ebbe142c
Author: Colin Walters <walters verbum org>
Date:   Sun Jul 8 20:36:50 2012 -0400

    scanner: Ensure "complete_ctype" patch doesn't throw an exception for anonymous unions
    
    The previous patch introduced a regression where we would crash on
    encountering an anonymous union.  Work around this by just writing out
    'gpointer' in this case, and add a regression test.

 giscanner/transformer.py               |    2 ++
 tests/scanner/Regress-1.0-expected.gir |   16 +++++++++++++++-
 tests/scanner/regress.h                |   11 +++++++++++
 3 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 91d00af..d6320d8 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -449,6 +449,8 @@ raise ValueError."""
                                   CTYPE_UNION,
                                   CTYPE_ENUM]:
             value = source_type.name
+            if not value:
+                value = 'gpointer'
             if const:
                 value = 'const ' + value
             if volatile:
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 0b39bff..631dd98 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -55,6 +55,20 @@ and/or use gtk-doc annotations.  -->
               c:type="REGRESS_LONG_STRING_CONSTANT">
       <type name="utf8" c:type="gchar*"/>
     </constant>
+    <record name="LikeGnomeKeyringPasswordSchema"
+            c:type="RegressLikeGnomeKeyringPasswordSchema">
+      <field name="dummy" writable="1">
+        <type name="gint" c:type="int"/>
+      </field>
+      <field name="attributes" writable="1">
+        <array zero-terminated="0" c:type="gpointer" fixed-size="32">
+          <type name="gpointer" c:type="gpointer"/>
+        </array>
+      </field>
+      <field name="dummy2" writable="1">
+        <type name="gdouble" c:type="double"/>
+      </field>
+    </record>
     <constant name="Mixed_Case_Constant"
               value="4423"
               c:type="REGRESS_Mixed_Case_Constant">
@@ -1474,7 +1488,7 @@ Use with regress_test_obj_emit_sig_with_obj</doc>
         <type name="GType" c:type="GType"/>
       </field>
       <field name="some_union" writable="1">
-        <array zero-terminated="0" fixed-size="2">
+        <array zero-terminated="0" c:type="gpointer" fixed-size="2">
           <type name="TestStructE__some_union__union"/>
         </array>
       </field>
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 97b9135..fd937cd 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -875,4 +875,15 @@ void regress_test_struct_fixed_array_frob (RegressTestStructFixedArray *str);
 void regress_has_parameter_named_attrs (int        foo,
                                         gpointer   attributes);
 
+
+typedef struct {
+  int dummy;
+  struct {
+    const char *name;
+    guint x;
+  } attributes[32];
+
+  double dummy2;
+} RegressLikeGnomeKeyringPasswordSchema;
+
 #endif /* __GITESTTYPES_H__ */



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