summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorColin Walters <walters@src.gnome.org>2009-02-04 00:48:24 +0000
committerColin Walters <walters@src.gnome.org>2009-02-04 00:48:24 +0000
commite3e84400529899854fe06f7d110685f50be26a18 (patch)
tree6d7ab0ca6fb6b44969063070024628cddc2cfb6e /tests
parentab991adecd8659a8b2843f4191ca4aa16aa4e121 (diff)
downloadgobject-introspection-e3e84400529899854fe06f7d110685f50be26a18.tar.gz
Bug 555960 - Nested structs and unions (generation portion)
Patch from Andreas Rottmann <a.rottmann@gmx.at>. * tests/scanner/utility.h (UtilityTaggedValue): Make the union member anonymous. (UtilityByte): New union typedef with an unnamed struct in it. * giscanner/transformer.py (Transformer._create_struct): Create unnamed structs for symbols with a None ident. (Transformer._create_union): Likewise. * giscanner/girwriter.py (GIRWriter._write_record): Allow name being None. (GIRWriter._write_union): Likewise. * girepository/girparser.c (start_struct): Allow a NULL name for non-toplevel structs. (start_union): Likewise. * tests/scanner/utility.h (UtilityTaggedValue): New struct typedef, which has a nested union member. * tests/scanner/utility-expected.gir: Adapted. * giscanner/transformer.py (Transformer._create_member): Create struct/union members if appropriate. (Transformer._create_struct, Transformer._create_union): Allow for structs/unions without a C type. * giscanner/glibtransformer.py (GLibTransformer._resolve_field): We don't need to resolve non-typef'd (GLibTransformer._resolve_field): Add cases for non-typedef'd struct/union "fields". * giscanner/girwriter.py (GIRWriter._write_record): Allow for records without a C type. (GIRWriter._write_field): structs and unions may appear in places where fields do. svn path=/trunk/; revision=1082
Diffstat (limited to 'tests')
-rw-r--r--tests/repository/Makefile.am3
-rw-r--r--tests/scanner/utility-1.0-expected.gir29
-rw-r--r--tests/scanner/utility-1.0-expected.tgir12
-rw-r--r--tests/scanner/utility.h21
4 files changed, 64 insertions, 1 deletions
diff --git a/tests/repository/Makefile.am b/tests/repository/Makefile.am
index 1dd5c4c7..e21cff43 100644
--- a/tests/repository/Makefile.am
+++ b/tests/repository/Makefile.am
@@ -13,4 +13,5 @@ gitestthrows_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository
gitestthrows_LDADD = $(top_builddir)/girepository/libgirepository-1.0.la $(GIREPO_LIBS)
TESTS = gitestrepo gitestthrows
-TESTS_ENVIRONMENT=env top_builddir="$(top_builddir)" $(DEBUG)
+TESTS_ENVIRONMENT=env top_builddir="$(top_builddir)" $(DEBUG) \
+ XDG_DATA_DIRS="$(top_srcdir)/gir:$(XDG_DATA_DIRS)"
diff --git a/tests/scanner/utility-1.0-expected.gir b/tests/scanner/utility-1.0-expected.gir
index 81c1a6b8..bb5a5e46 100644
--- a/tests/scanner/utility-1.0-expected.gir
+++ b/tests/scanner/utility-1.0-expected.gir
@@ -46,6 +46,35 @@ and/or use gtk-doc annotations. -->
<type name="GObject.ObjectClass" c:type="GObjectClass"/>
</field>
</record>
+ <record name="TaggedValue" c:type="UtilityTaggedValue">
+ <field name="tag" writable="1">
+ <type name="int" c:type="int"/>
+ </field>
+ <union>
+ <field name="v_pointer" writable="1">
+ <type name="any" c:type="gpointer"/>
+ </field>
+ <field name="v_real" writable="1">
+ <type name="double" c:type="double"/>
+ </field>
+ <field name="v_integer" writable="1">
+ <type name="long" c:type="long"/>
+ </field>
+ </union>
+ </record>
+ <union name="Byte" c:type="UtilityByte">
+ <field name="value" writable="1">
+ <type name="uint8" c:type="guint8"/>
+ </field>
+ <record>
+ <field name="first_nibble" writable="1" bits="4">
+ <type name="uint8" c:type="guint8"/>
+ </field>
+ <field name="second_nibble" writable="1" bits="4">
+ <type name="uint8" c:type="guint8"/>
+ </field>
+ </record>
+ </union>
<callback name="FileFunc" c:type="UtilityFileFunc">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
diff --git a/tests/scanner/utility-1.0-expected.tgir b/tests/scanner/utility-1.0-expected.tgir
index 26e6d196..7a2364ea 100644
--- a/tests/scanner/utility-1.0-expected.tgir
+++ b/tests/scanner/utility-1.0-expected.tgir
@@ -35,6 +35,18 @@
<type name="GObject.ObjectClass"/>
</field>
</record>
+ <record name="TaggedValue">
+ <field name="tag" writable="1">
+ <type name="int"/>
+ </field>
+ <!-- FIXME: anonymous union member missing -->
+ </record>
+ <union name="Byte">
+ <field name="value" writable="1">
+ <type name="uint8"/>
+ </field>
+ <!-- FIXME: anonymous struct member missing -->
+ </union>
<callback name="FileFunc">
<return-value transfer-ownership="none">
<type name="none"/>
diff --git a/tests/scanner/utility.h b/tests/scanner/utility.h
index a744f037..b493a677 100644
--- a/tests/scanner/utility.h
+++ b/tests/scanner/utility.h
@@ -23,6 +23,27 @@ struct _UtilityObjectClass
/* This one is similar to Pango.Glyph */
typedef guint32 UtilityGlyph;
+typedef struct
+{
+ int tag;
+ union
+ {
+ gpointer v_pointer;
+ double v_real;
+ long v_integer;
+ };
+} UtilityTaggedValue;
+
+typedef union
+{
+ guint8 value;
+ struct
+ {
+ guint8 first_nibble : 4;
+ guint8 second_nibble : 4;
+ };
+} UtilityByte;
+
typedef void (*UtilityFileFunc)(const char *path, gpointer user_data);
GType utility_object_get_type (void) G_GNUC_CONST;