[pypy-commit] cffi default: Test and fix: ABI out-of-line didn't support C functions with
arigo
noreply at buildbot.pypy.org
Fri May 22 00:11:53 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r2078:9a74c1c6b5ce
Date: 2015-05-22 00:12 +0200
http://bitbucket.org/cffi/cffi/changeset/9a74c1c6b5ce/
Log: Test and fix: ABI out-of-line didn't support C functions with dot-
dot-dot (reported by lazka on irc)
diff --git a/cffi/recompiler.py b/cffi/recompiler.py
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -581,10 +581,11 @@
def _generate_cpy_function_collecttype(self, tp, name):
self._do_collect_type(tp.as_raw_function())
- if tp.ellipsis:
+ if tp.ellipsis and not self.target_is_python:
self._do_collect_type(tp)
def _generate_cpy_function_decl(self, tp, name):
+ assert not self.target_is_python
assert isinstance(tp, model.FunctionPtrType)
if tp.ellipsis:
# cannot support vararg functions better than this: check for its
@@ -702,7 +703,7 @@
prnt()
def _generate_cpy_function_ctx(self, tp, name):
- if tp.ellipsis:
+ if tp.ellipsis and not self.target_is_python:
self._generate_cpy_constant_ctx(tp, name)
return
type_index = self._typesdict[tp.as_raw_function()]
diff --git a/testing/cffi1/test_re_python.py b/testing/cffi1/test_re_python.py
--- a/testing/cffi1/test_re_python.py
+++ b/testing/cffi1/test_re_python.py
@@ -12,6 +12,7 @@
#define BIGPOS 420000000000L
#define BIGNEG -420000000000L
int add42(int x) { return x + 42; }
+ int add43(int x, ...) { return x; }
int globalvar42 = 1234;
struct foo_s;
typedef struct bar_s { int x; signed char a[]; } bar_t;
@@ -37,6 +38,7 @@
#define BIGPOS 420000000000L
#define BIGNEG -420000000000L
int add42(int);
+ int add43(int, ...);
int globalvar42;
int no_such_function(int);
int no_such_globalvar;
@@ -68,6 +70,13 @@
assert lib.add42(-10) == 32
assert type(lib.add42) is _cffi_backend.FFI.CData
+def test_function_with_varargs():
+ import _cffi_backend
+ from re_python_pysrc import ffi
+ lib = ffi.dlopen(extmod)
+ assert lib.add43(45, ffi.cast("int", -5)) == 45
+ assert type(lib.add43) is _cffi_backend.FFI.CData
+
def test_dlclose():
import _cffi_backend
from re_python_pysrc import ffi
More information about the pypy-commit
mailing list