summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu.duponchelle@opencreed.com>2017-03-13 03:37:50 +0100
committerMathieu Duponchelle <mathieu.duponchelle@opencreed.com>2017-03-14 17:43:45 +0100
commitdf019eb0c5d82d44effcf9e1b0666a7b813ef5eb (patch)
treeec5af959bedae18302686d181079c6f5d8c8c669
parent0ac1f1862850ab003de70344491ed3385b610e98 (diff)
downloadgobject-introspection-df019eb0c5d82d44effcf9e1b0666a7b813ef5eb.tar.gz
typedefs: fix type information.
We now reuse _create_type_from_base instead of reimplementing it in a semi-broken way in transformer, and use complete_ctype when writing it out if available. This incidentally allows us to remove a test where the comment acknowledged the non-optimal behaviour. https://bugzilla.gnome.org/show_bug.cgi?id=779959
-rw-r--r--giscanner/girwriter.py2
-rw-r--r--giscanner/transformer.py7
-rw-r--r--tests/scanner/test_transformer.py2
3 files changed, 2 insertions, 9 deletions
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index f637376f..4bef1eaf 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -276,7 +276,7 @@ class GIRWriter(XMLWriter):
assert isinstance(ntype, ast.Type), ntype
attrs = []
if ntype.ctype:
- attrs.append(('c:type', ntype.ctype))
+ attrs.append(('c:type', ntype.complete_ctype or ntype.ctype))
if isinstance(ntype, ast.Array):
if ntype.array_type != ast.Array.C:
attrs.insert(0, ('name', ntype.array_type))
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index a1ea3433..81b4d0ae 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -613,12 +613,7 @@ raise ValueError."""
CTYPE_BASIC_TYPE,
CTYPE_VOID):
name = self.strip_identifier(symbol.ident)
- if symbol.base_type.name:
- complete_ctype = self._create_complete_source_type(symbol.base_type)
- target = self.create_type_from_ctype_string(symbol.base_type.name,
- complete_ctype=complete_ctype)
- else:
- target = ast.TYPE_ANY
+ target = self._create_type_from_base(symbol.base_type)
if name in ast.type_names:
return None
# https://bugzilla.gnome.org/show_bug.cgi?id=755882
diff --git a/tests/scanner/test_transformer.py b/tests/scanner/test_transformer.py
index b45f532e..175a8d37 100644
--- a/tests/scanner/test_transformer.py
+++ b/tests/scanner/test_transformer.py
@@ -243,8 +243,6 @@ class TestStructTypedefs(unittest.TestCase):
self.assertTrue(ptr is not None)
self.assertTrue(isinstance(ptr, ast.Alias))
self.assertEqual(ptr.ctype, 'TestStructPtr')
- # This loses type information about the struct which seems broken.
- self.assertEqual(ptr.target, ast.TYPE_ANY)
def test_struct_tag_pointer(self):
load_namespace_from_source_string(self.namespace, """