Author: Armin Rigo <[email protected]>
Branch: static-callback
Changeset: r2383:b07d81267db0
Date: 2015-11-13 13:37 +0100
http://bitbucket.org/cffi/cffi/changeset/b07d81267db0/
Log: 'long double' is the only primitive type that doesn't necessarily
fit inside uint64_t, for now
diff --git a/cffi/recompiler.py b/cffi/recompiler.py
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -1161,9 +1161,14 @@
prnt()
#
# Write the implementation of the functions declared above
+ def may_need_128_bits(tp):
+ return tp.name == 'long double'
+ #
for j in range(len(self._callpy)):
tp, name = self._callpy[j]
size_of_a = max(len(tp.args), 1)
+ if may_need_128_bits(tp.result):
+ size_of_a = max(size_of_a, 2)
if isinstance(tp.result, model.StructOrUnion):
size_of_a = 'sizeof(%s) > %d ? (sizeof(%s) + 7) / 8 : %d' % (
tp.result.get_c_name(''), 8 * size_of_a,
@@ -1174,7 +1179,8 @@
prnt(' char *p = (char *)a;')
for i, type in enumerate(tp.args):
arg = 'a%d' % i
- if isinstance(type, model.StructOrUnion):
+ if (isinstance(type, model.StructOrUnion) or
+ may_need_128_bits(type)):
arg = '&' + arg
type = model.PointerType(type)
prnt(' *(%s)(p + %d) = %s;' % (type.get_c_name('*'), i*8,
arg))
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
--- a/testing/cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -1507,3 +1507,13 @@
lib = verify(ffi, 'test_call_python_2',
"struct foo_s { int a, b, c; };")
XXX
+
+def test_call_python_3():
+ ffi = FFI()
+ ffi.cdef("""
+ CFFI_CALL_PYTHON int bar(int, long double, int);
+ CFFI_CALL_PYTHON long double baz(int, int);
+ CFFI_CALL_PYTHON long double bok(void);
+ """)
+ lib = verify(ffi, 'test_call_python_3', "")
+ XXX
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit