[pypy-commit] cffi default: Test and fix

arigo noreply at buildbot.pypy.org
Thu Jun 28 11:49:04 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r550:045f5bfdd5ea
Date: 2012-06-28 00:49 +0200
http://bitbucket.org/cffi/cffi/changeset/045f5bfdd5ea/

Log:	Test and fix

diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -144,7 +144,8 @@
         self._declarations[name] = obj
 
     def _get_type_pointer(self, type, const=False):
-        if isinstance(type, model.RawFunctionType):
+        if (isinstance(type, model.RawFunctionType) and
+                not isinstance(type, model.FunctionPtrType)):
             return model.FunctionPtrType(type.args, type.result, type.ellipsis)
         if const:
             return model.ConstPointerType(type)
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -558,3 +558,21 @@
     """)
     s = ffi.new("struct foo_s", ['B', 1])
     assert lib.foo(s[0]) == ord('A')
+
+def test_autofilled_struct_as_argument_dynamic():
+    ffi = FFI()
+    ffi.cdef("struct foo_s { char a; int b; ...; };\n"
+             "int (**foo)(struct foo_s);")
+    lib = ffi.verify("""
+        struct foo_s {
+            int pad1, b, pad2, pad3;
+            char a;
+        };
+        int foo1(struct foo_s s) {
+            return s.a - s.b;
+        }
+        int (*foo2)(struct foo_s s) = &foo1;
+        int (**foo)(struct foo_s s) = &foo2;
+    """)
+    s = ffi.new("struct foo_s", ['B', 1])
+    assert lib.foo[0](s[0]) == ord('A')


More information about the pypy-commit mailing list