Author: Armin Rigo <ar...@tunes.org> Branch: cffi-1.0 Changeset: r1697:acc5959cd6a8 Date: 2015-04-11 20:39 +0200 http://bitbucket.org/cffi/cffi/changeset/acc5959cd6a8/
Log: fix test diff --git a/new/parse_c_type.h b/new/parse_c_type.h --- a/new/parse_c_type.h +++ b/new/parse_c_type.h @@ -1,4 +1,4 @@ -#include <stddef.h> +#include <stdint.h> typedef void *_cffi_opcode_t; 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 @@ -34,6 +34,11 @@ { PyObject *x, *y; _cffi_opcode_t op = opcodes[index]; + if ((((uintptr_t)op) & 1) == 0) { + x = (PyObject *)op; + Py_INCREF(x); + return x; + } switch (_CFFI_GETOP(op)) { @@ -42,7 +47,7 @@ if (x == NULL) x = build_primitive_type(_CFFI_GETARG(op)); Py_XINCREF(x); - return x; + break; case _CFFI_OP_POINTER: y = realize_c_type(ctx, opcodes, _CFFI_GETARG(op)); @@ -50,16 +55,18 @@ return NULL; x = Py_BuildValue("sO", "pointer", y); Py_DECREF(y); - return x; + break; default: PyErr_Format(PyExc_NotImplementedError, "op=%d", (int)_CFFI_GETOP(op)); return NULL; } -} - -struct _cffi_type_context_s global_ctx = { + if (opcodes == ctx->types) { + Py_INCREF(x); + opcodes[index] = x; + } + return x; }; @@ -70,6 +77,7 @@ return NULL; _cffi_opcode_t opcodes[100]; + struct _cffi_type_context_s global_ctx = { NULL }; struct _cffi_parse_info_s parse_info = { .ctx = &global_ctx, .output = opcodes, diff --git a/new/test_realize_c_type.py b/new/test_realize_c_type.py --- a/new/test_realize_c_type.py +++ b/new/test_realize_c_type.py @@ -1,7 +1,9 @@ import os def setup_module(): - os.system("python setup.py build_ext -i") + err = os.system("python setup.py build_ext -i") + if err != 0: + raise Exception(err) global realize_c_type import realize_c_type _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit