[pypy-commit] cffi cffi-1.0: Process argument types

arigo noreply at buildbot.pypy.org
Tue Apr 14 18:47:59 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1706:4070e62efc66
Date: 2015-04-14 18:48 +0200
http://bitbucket.org/cffi/cffi/changeset/4070e62efc66/

Log:	Process argument types

diff --git a/new/realize_c_type.c b/new/realize_c_type.c
--- a/new/realize_c_type.c
+++ b/new/realize_c_type.c
@@ -107,11 +107,34 @@
     case _CFFI_OP_FUNCTION:
     {
         PyObject *fargs;
+        int i, base_index, num_args;
 
         y = realize_c_type(ctx, opcodes, _CFFI_GETARG(op));
         if (y == NULL)
             return NULL;
-        fargs = PyTuple_New(0);  // XXX NULL
+
+        base_index = index + 1;
+        num_args = 0;
+        while (_CFFI_GETOP(opcodes[base_index + num_args]) !=
+                   _CFFI_OP_FUNCTION_END)
+            num_args++;
+
+        fargs = PyTuple_New(num_args);
+        if (fargs == NULL) {
+            Py_DECREF(y);
+            return NULL;
+        }
+
+        for (i = 0; i < num_args; i++) {
+            z = realize_c_type(ctx, opcodes, base_index + i);
+            if (z == NULL) {
+                Py_DECREF(fargs);
+                Py_DECREF(y);
+                return NULL;
+            }
+            PyTuple_SET_ITEM(fargs, i, z);
+        }
+
         z = new_function_type(fargs, (CTypeDescrObject *)y, 0, FFI_DEFAULT_ABI);
         Py_DECREF(fargs);
         Py_DECREF(y);


More information about the pypy-commit mailing list