Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r67901:988070ca4092
Date: 2013-11-09 08:36 -0800
http://bitbucket.org/pypy/pypy/changeset/988070ca4092/
Log: Unroll ffi.new("struct s *", [a, list]) or ffi.new("struct s *", {a:
dict})
diff --git a/pypy/module/_cffi_backend/ctypestruct.py
b/pypy/module/_cffi_backend/ctypestruct.py
--- a/pypy/module/_cffi_backend/ctypestruct.py
+++ b/pypy/module/_cffi_backend/ctypestruct.py
@@ -95,6 +95,9 @@
if not self._copy_from_same(cdata, w_ob):
self.convert_struct_from_object(cdata, w_ob)
+ @jit.look_inside_iff(
+ lambda self, cdata, w_ob, optvarsize=-1: jit.isvirtual(w_ob)
+ )
def convert_struct_from_object(self, cdata, w_ob, optvarsize=-1):
self._check_only_one_argument_for_union(w_ob)
diff --git a/pypy/module/pypyjit/test_pypy_c/test_ffi.py
b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
--- a/pypy/module/pypyjit/test_pypy_c/test_ffi.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
@@ -228,7 +228,7 @@
except ImportError:
sys.stderr.write('SKIP: cannot import cffi\n')
return 0
-
+
ffi = cffi.FFI()
ffi.cdef("""
@@ -301,5 +301,30 @@
f(1)
#
libm_name = get_libm_name(sys.platform)
- log = self.run(main, [libm_name])
+ self.run(main, [libm_name])
# assert did not crash
+
+ def test_cffi_init_struct_with_list(self):
+ def main(n):
+ import sys
+ try:
+ import cffi
+ except ImportError:
+ sys.stderr.write('SKIP: cannot import cffi\n')
+ return 0
+
+ ffi = cffi.FFI()
+ ffi.cdef("""
+ struct s {
+ int x;
+ int y;
+ int z;
+ };
+ """)
+
+ for i in xrange(n):
+ ffi.new("struct s *", [i, i, i])
+
+ log = self.run(main, [300])
+ loop, = log.loops_by_filename(self.filepath)
+ assert False, "XXX: fill this in"
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit