From e3e84400529899854fe06f7d110685f50be26a18 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 4 Feb 2009 00:48:24 +0000 Subject: Bug 555960 - Nested structs and unions (generation portion) Patch from Andreas Rottmann . * 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 --- tests/repository/Makefile.am | 3 ++- tests/scanner/utility-1.0-expected.gir | 29 +++++++++++++++++++++++++++++ tests/scanner/utility-1.0-expected.tgir | 12 ++++++++++++ tests/scanner/utility.h | 21 +++++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) (limited to 'tests') 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. --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + 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; -- cgit v1.2.1