scanner: Ensure "complete_ctype" patch doesn't throw an exception for anonymous unions
authorColin Walters <walters@verbum.org>
Mon, 9 Jul 2012 00:36:50 +0000 (20:36 -0400)
committerColin Walters <walters@verbum.org>
Mon, 9 Jul 2012 00:36:50 +0000 (20:36 -0400)
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
tests/scanner/Regress-1.0-expected.gir
tests/scanner/regress.h

index 91d00af..d6320d8 100644 (file)
@@ -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:
index 0b39bff..631dd98 100644 (file)
@@ -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>
index 97b9135..fd937cd 100644 (file)
@@ -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__ */