Commits

Armin Rigo committed d307308

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:
+            if force_pointer and not isinstance(type, model.ArrayType):
                 return self._get_type_pointer(type)
             if convert_array_to_pointer:
                 xxx

testing/test_parsing.py

     def complete_struct_or_union(self, s, tp, fields):
         assert isinstance(s, FakeStruct)
         s.fields = zip(tp.fldnames, fields, tp.fldbitsize)
+    
+    def new_array_type(self, ptrtype, length):
+        return '<array %s x %s>' % (ptrtype, length)
 
 class FakeStruct(object):
     def __init__(self, name):
     assert ffi.typeof("foo_p") == '<pointer to <int>a, <int>b>'
     assert ffi.C.foo.BType == ('<func (<pointer to <pointer to '
                                '<int>a, <int>b>>), <int>, False>')
+
+def test_typedef_array():
+    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>'