[pypy-commit] cffi cffi-1.0: ellipsis
arigo
noreply at buildbot.pypy.org
Sat Apr 25 11:04:19 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1810:c818c7444718
Date: 2015-04-25 11:04 +0200
http://bitbucket.org/cffi/cffi/changeset/c818c7444718/
Log: ellipsis
diff --git a/_cffi1/realize_c_type.c b/_cffi1/realize_c_type.c
--- a/_cffi1/realize_c_type.c
+++ b/_cffi1/realize_c_type.c
@@ -489,7 +489,7 @@
case _CFFI_OP_FUNCTION:
{
PyObject *fargs;
- int i, base_index, num_args;
+ int i, base_index, num_args, ellipsis;
y = (PyObject *)realize_c_type(builder, opcodes, _CFFI_GETARG(op));
if (y == NULL)
@@ -501,6 +501,8 @@
_CFFI_OP_FUNCTION_END)
num_args++;
+ ellipsis = _CFFI_GETARG(opcodes[base_index + num_args]) & 1;
+
fargs = PyTuple_New(num_args);
if (fargs == NULL) {
Py_DECREF(y);
@@ -517,7 +519,8 @@
PyTuple_SET_ITEM(fargs, i, z);
}
- z = new_function_type(fargs, (CTypeDescrObject *)y, 0, FFI_DEFAULT_ABI);
+ z = new_function_type(fargs, (CTypeDescrObject *)y, ellipsis,
+ FFI_DEFAULT_ABI);
z = get_unique_type(builder, z);
Py_DECREF(fargs);
Py_DECREF(y);
diff --git a/_cffi1/recompiler.py b/_cffi1/recompiler.py
--- a/_cffi1/recompiler.py
+++ b/_cffi1/recompiler.py
@@ -312,6 +312,8 @@
def _generate_cpy_function_collecttype(self, tp, name):
self._do_collect_type(tp.as_raw_function())
+ if tp.ellipsis:
+ self._do_collect_type(tp)
def _generate_cpy_function_decl(self, tp, name):
assert isinstance(tp, model.FunctionPtrType)
@@ -319,7 +321,7 @@
# cannot support vararg functions better than this: check for its
# exact type (including the fixed arguments), and build it as a
# constant function pointer (no CPython wrapper)
- self._generate_cpy_const(False, name, tp)
+ self._generate_cpy_constant_decl(tp, name)
return
prnt = self._prnt
numargs = len(tp.args)
@@ -388,7 +390,8 @@
def _generate_cpy_function_ctx(self, tp, name):
if tp.ellipsis:
- XXX
+ self._generate_cpy_constant_ctx(tp, name)
+ return
type_index = self._typesdict[tp.as_raw_function()]
numargs = len(tp.args)
if numargs == 0:
More information about the pypy-commit
mailing list