[pypy-commit] cffi auto-types: - add missing file

arigo noreply at buildbot.pypy.org
Sun Feb 10 20:12:15 CET 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: auto-types
Changeset: r1143:a059934a26e2
Date: 2013-02-10 19:12 +0100
http://bitbucket.org/cffi/cffi/changeset/a059934a26e2/

Log:	- add missing file
	- add 'bool' support

diff --git a/cffi/commontypes.py b/cffi/commontypes.py
new file mode 100644
--- /dev/null
+++ b/cffi/commontypes.py
@@ -0,0 +1,12 @@
+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
diff --git a/cffi/model.py b/cffi/model.py
--- a/cffi/model.py
+++ b/cffi/model.py
@@ -383,8 +383,6 @@
     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
diff --git a/testing/test_parsing.py b/testing/test_parsing.py
--- a/testing/test_parsing.py
+++ b/testing/test_parsing.py
@@ -215,3 +215,10 @@
     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);")


More information about the pypy-commit mailing list