Commits

Armin Rigo committed cf451d1

Test and fix.

Comments (0)

Files changed (2)

             len(typenode.type.names) == 1 and
             ('typedef ' + typenode.type.names[0]) in self._declarations):
             type = self._declarations['typedef ' + typenode.type.names[0]]
-            if force_pointer and not isinstance(type, model.ArrayType):
-                return self._get_type_pointer(type)
-            if convert_array_to_pointer:
-                xxx
+            if isinstance(type, model.ArrayType):
+                if convert_array_to_pointer:
+                    return type.item
+            else:
+                if force_pointer:
+                    return self._get_type_pointer(type)
             return type
         #
         if isinstance(typenode, pycparser.c_ast.ArrayDecl):

testing/test_parsing.py

     assert ffi.C.foo.BType == ('<func (<pointer to <pointer to '
                                '<int>a, <int>b>>), <int>, False>')
 
-def test_typedef_array():
+def test_typedef_array_force_pointer():
     ffi = FFI(backend=FakeBackend())
     ffi.cdef("""
         typedef int array_t[5];
     type = ffi._parser.parse_type("array_t", force_pointer=True)
     BType = type.get_backend_type(ffi)
     assert BType == '<array <pointer to <int>> x 5>'
+
+def test_typedef_array_convert_array_to_pointer():
+    ffi = FFI(backend=FakeBackend())
+    ffi.cdef("""
+        typedef int array_t[5];
+        """)
+    type = ffi._parser.parse_type("array_t", convert_array_to_pointer=True)
+    BType = type.get_backend_type(ffi)
+    assert BType == '<pointer to <int>>'