[gobject-introspection] typedefs: fix type information.



commit df019eb0c5d82d44effcf9e1b0666a7b813ef5eb
Author: Mathieu Duponchelle <mathieu duponchelle opencreed com>
Date:   Mon Mar 13 03:37:50 2017 +0100

    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

 giscanner/girwriter.py            |    2 +-
 giscanner/transformer.py          |    7 +------
 tests/scanner/test_transformer.py |    2 --
 3 files changed, 2 insertions(+), 9 deletions(-)
---
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index f637376..4bef1ea 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 a1ea343..81b4d0a 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 b45f532..175a8d3 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, """


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]