summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--giscanner/gdumpparser.py11
-rw-r--r--giscanner/transformer.py13
-rw-r--r--tests/scanner/test_transformer.py8
3 files changed, 11 insertions, 21 deletions
diff --git a/giscanner/gdumpparser.py b/giscanner/gdumpparser.py
index e5490b1b..e1fc9358 100644
--- a/giscanner/gdumpparser.py
+++ b/giscanner/gdumpparser.py
@@ -326,17 +326,6 @@ different --identifier-prefix.""" % (xmlnode.attrib['name'], self._namespace.ide
self._introspect_signals(node, xmlnode)
self._introspect_implemented_interfaces(node, xmlnode)
self._add_record_fields(node)
-
- if node.name == 'InitiallyUnowned':
- # http://bugzilla.gnome.org/show_bug.cgi?id=569408
- # GInitiallyUnowned is actually a typedef for GObject, but
- # that's not reflected in the GIR, where it appears as a
- # subclass (as it appears in the GType hierarchy). So
- # what we do here is copy all of the GObject fields into
- # GInitiallyUnowned so that struct offset computation
- # works correctly.
- node.fields = self._namespace.get('Object').fields
-
self._namespace.append(node, replace=True)
def _introspect_interface(self, xmlnode):
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index b540a8c1..80265dd8 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -752,14 +752,15 @@ raise ValueError."""
# prior typedef struct. If we get here it means this is another
# typedef of that struct. Instead of creating an alias to the
# primary typedef that has been promoted, we create a new Record
- # which is forced as a disguised struct. This handles the case
- # where we want to give GInitiallyUnowned its own Record:
+ # with shared fields. This handles the case where we want to
+ # give structs like GInitiallyUnowned its own Record:
# typedef struct _GObject GObject;
# typedef struct _GObject GInitiallyUnowned;
- # GInitiallyUnowned is also special cased in gdumpparser.py to
- # copy fields which may eventually be avoided by doing it here
- # generically.
- compound = compound_class(name, symbol.ident, disguised=True, tag_name=tag_name)
+ # See: http://bugzilla.gnome.org/show_bug.cgi?id=569408
+ new_compound = compound_class(name, symbol.ident, tag_name=tag_name)
+ new_compound.fields = compound.fields
+ new_compound.add_symbol_reference(symbol)
+ return new_compound
else:
# If the struct does not have its name set, it exists only in
# the tag namespace. Set it here and return it which will
diff --git a/tests/scanner/test_transformer.py b/tests/scanner/test_transformer.py
index 7f4f98de..39c54a4d 100644
--- a/tests/scanner/test_transformer.py
+++ b/tests/scanner/test_transformer.py
@@ -157,8 +157,8 @@ class TestStructTypedefs(unittest.TestCase):
shared = self.namespace.get('StructAlias')
self.assertTrue(shared is not None)
self.assertTrue(isinstance(shared, ast.Record))
- self.assertTrue(shared.disguised)
- self.assertEqual(len(shared.fields), 0)
+ self.assertFalse(shared.disguised)
+ self.assertEqual(len(shared.fields), 1)
self.assertEqual(shared.ctype, 'TestStructAlias')
def test_struct_tag_aliases_after(self):
@@ -181,8 +181,8 @@ class TestStructTypedefs(unittest.TestCase):
shared = self.namespace.get('StructAlias')
self.assertTrue(shared is not None)
self.assertTrue(isinstance(shared, ast.Record))
- self.assertTrue(shared.disguised)
- self.assertEqual(len(shared.fields), 0)
+ self.assertFalse(shared.disguised)
+ self.assertEqual(len(shared.fields), 1)
self.assertEqual(shared.ctype, 'TestStructAlias')
def test_struct_pointer(self):