summaryrefslogtreecommitdiff
path: root/tests/scanner
diff options
context:
space:
mode:
authorTorsten Schönfeld <kaffeetisch@gmx.de>2011-09-10 16:52:51 +0200
committerTorsten Schönfeld <kaffeetisch@gmx.de>2011-09-11 00:34:28 +0200
commitea68ec234ad31b0a1d92adbf0c911a5dd541b647 (patch)
tree125930f400320b4bddfa7948396a10915f83c1b5 /tests/scanner
parentc3da3d46ffa9c3b53e7f7132eaa9c9c722ebc859 (diff)
downloadgobject-introspection-ea68ec234ad31b0a1d92adbf0c911a5dd541b647.tar.gz
scanner: correctly handle structs with arrays of anon unions
This applies mainly to GValue, which is defined as: struct _GValue { /*< private >*/ GType g_type; /* public for GTypeValueTable methods */ union { gint v_int; guint v_uint; glong v_long; gulong v_ulong; gint64 v_int64; guint64 v_uint64; gfloat v_float; gdouble v_double; gpointer v_pointer; } data[2]; }; Previously, the scanner did not understand the array of unions. This resulted in g_struct_info_get_size returning an incorrect size for GValue (at least on 32bit systems). Fix this by making up a separate union declaration for the GIR that can be referenced by the array. https://bugzilla.gnome.org/show_bug.cgi?id=657040
Diffstat (limited to 'tests/scanner')
-rw-r--r--tests/scanner/Regress-1.0-expected.gir39
-rw-r--r--tests/scanner/regress.h17
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 2f4b5c21..79ca1d31 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -1162,6 +1162,45 @@ TpAccount::status-changed</doc>
</array>
</field>
</record>
+ <record name="TestStructE" c:type="RegressTestStructE">
+ <field name="some_type" writable="1">
+ <type name="GType" c:type="GType"/>
+ </field>
+ <field name="some_union" writable="1">
+ <array zero-terminated="0" fixed-size="2">
+ <type name="TestStructE__some_union__union"/>
+ </array>
+ </field>
+ </record>
+ <union name="TestStructE__some_union__union">
+ <field name="v_int" writable="1">
+ <type name="gint" c:type="gint"/>
+ </field>
+ <field name="v_uint" writable="1">
+ <type name="guint" c:type="guint"/>
+ </field>
+ <field name="v_long" writable="1">
+ <type name="glong" c:type="glong"/>
+ </field>
+ <field name="v_ulong" writable="1">
+ <type name="gulong" c:type="gulong"/>
+ </field>
+ <field name="v_int64" writable="1">
+ <type name="gint64" c:type="gint64"/>
+ </field>
+ <field name="v_uint64" writable="1">
+ <type name="guint64" c:type="guint64"/>
+ </field>
+ <field name="v_float" writable="1">
+ <type name="gfloat" c:type="gfloat"/>
+ </field>
+ <field name="v_double" writable="1">
+ <type name="gdouble" c:type="gdouble"/>
+ </field>
+ <field name="v_pointer" writable="1">
+ <type name="gpointer" c:type="gpointer"/>
+ </field>
+ </union>
<record name="TestStructFixedArray" c:type="RegressTestStructFixedArray">
<field name="just_int" writable="1">
<type name="gint" c:type="gint"/>
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index f30fcd78..4afb9b06 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -243,6 +243,23 @@ struct _RegressTestStructD
GPtrArray *garray;
};
+/* This one has an array of anonymous unions, inspired by GValue */
+struct RegressTestStructE
+{
+ GType some_type;
+ union {
+ gint v_int;
+ guint v_uint;
+ glong v_long;
+ gulong v_ulong;
+ gint64 v_int64;
+ guint64 v_uint64;
+ gfloat v_float;
+ gdouble v_double;
+ gpointer v_pointer;
+ } some_union[2];
+};
+
/* plain-old-data boxed types */
typedef struct _RegressTestSimpleBoxedA RegressTestSimpleBoxedA;
typedef struct _RegressTestSimpleBoxedB RegressTestSimpleBoxedB;