Commits

Armin Rigo committed a059934

- add missing file
- add 'bool' support

Comments (0)

Files changed (3)

cffi/commontypes.py

+from . import api, model
+
+
+COMMON_TYPES = {
+    'FILE': model.unknown_type('FILE', '_IO_FILE'),
+    'bool': model.PrimitiveType('_Bool'),
+    }
+
+for _type in model.PrimitiveType.ALL_PRIMITIVE_TYPES:
+    if _type.endswith('_t'):
+        COMMON_TYPES[_type] = model.PrimitiveType(_type)
+del _type
     tp = StructType(structname, None, None, None)
     return NamedPointerType(tp, name)
 
-file_type = unknown_type('FILE', '_IO_FILE')
-
 def global_cache(srctype, ffi, funcname, *args, **kwds):
     key = kwds.pop('key', (funcname, args))
     assert not kwds

testing/test_parsing.py

     assert repr(ffi.cast("FILE", 123)) == "<cdata 'char' '{'>"
     ffi.cdef("typedef char int32_t;")
     assert repr(ffi.cast("int32_t", 123)) == "<cdata 'char' '{'>"
+
+def test_bool():
+    ffi = FFI()
+    ffi.cdef("void f(bool);")
+    #
+    ffi = FFI()
+    ffi.cdef("typedef _Bool bool; void f(bool);")