Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r77666:1752064fc012 Date: 2015-05-28 21:03 +0200 http://bitbucket.org/pypy/pypy/changeset/1752064fc012/
Log: update to cffi/4d3306c3afcc diff --git a/lib_pypy/cffi/cffi_opcode.py b/lib_pypy/cffi/cffi_opcode.py --- a/lib_pypy/cffi/cffi_opcode.py +++ b/lib_pypy/cffi/cffi_opcode.py @@ -52,6 +52,7 @@ OP_CONSTANT_INT = 31 OP_GLOBAL_VAR = 33 OP_DLOPEN_FUNC = 35 +OP_DLOPEN_CONST = 37 PRIM_VOID = 0 PRIM_BOOL = 1 diff --git a/lib_pypy/cffi/parse_c_type.h b/lib_pypy/cffi/parse_c_type.h --- a/lib_pypy/cffi/parse_c_type.h +++ b/lib_pypy/cffi/parse_c_type.h @@ -25,6 +25,7 @@ #define _CFFI_OP_CONSTANT_INT 31 #define _CFFI_OP_GLOBAL_VAR 33 #define _CFFI_OP_DLOPEN_FUNC 35 +#define _CFFI_OP_DLOPEN_CONST 37 #define _CFFI_PRIM_VOID 0 #define _CFFI_PRIM_BOOL 1 diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py --- a/lib_pypy/cffi/recompiler.py +++ b/lib_pypy/cffi/recompiler.py @@ -982,8 +982,12 @@ raise ffiplatform.VerificationError( "constant '%s' is of type '%s', whose size is not known" % (name, tp._get_c_name())) + if self.target_is_python: + const_kind = OP_DLOPEN_CONST + else: + const_kind = OP_CONSTANT type_index = self._typesdict[tp] - type_op = CffiOp(OP_CONSTANT, type_index) + type_op = CffiOp(const_kind, type_index) self._lsts["global"].append( GlobalExpr(name, '_cffi_const_%s' % name, type_op)) diff --git a/pypy/module/_cffi_backend/cffi_opcode.py b/pypy/module/_cffi_backend/cffi_opcode.py --- a/pypy/module/_cffi_backend/cffi_opcode.py +++ b/pypy/module/_cffi_backend/cffi_opcode.py @@ -52,6 +52,7 @@ OP_CONSTANT_INT = 31 OP_GLOBAL_VAR = 33 OP_DLOPEN_FUNC = 35 +OP_DLOPEN_CONST = 37 PRIM_VOID = 0 PRIM_BOOL = 1 diff --git a/pypy/module/_cffi_backend/lib_obj.py b/pypy/module/_cffi_backend/lib_obj.py --- a/pypy/module/_cffi_backend/lib_obj.py +++ b/pypy/module/_cffi_backend/lib_obj.py @@ -122,7 +122,8 @@ w_result = realize_c_type.realize_global_int(self.ffi, g, index) # - elif op == cffi_opcode.OP_CONSTANT: + elif (op == cffi_opcode.OP_CONSTANT or + op == cffi_opcode.OP_DLOPEN_CONST): # A constant which is not of integer type w_ct = realize_c_type.realize_c_type( self.ffi, self.ctx.c_types, getarg(g.c_type_op)) @@ -133,8 +134,10 @@ raise oefmt(space.w_SystemError, "constant has no known size") if not fetch_funcptr: # for dlopen() style + assert op == cffi_opcode.OP_DLOPEN_CONST ptr = self.cdlopen_fetch(attr) else: + assert op == cffi_opcode.OP_CONSTANT ptr = lltype.malloc(rffi.CCHARP.TO, w_ct.size, flavor='raw') self.ffi._finalizer.free_mems.append(ptr) fetch_funcptr(ptr) diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_dlopen.py b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_dlopen.py --- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_dlopen.py +++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_dlopen.py @@ -31,7 +31,7 @@ ffi = _cffi_backend.FFI('test_valid_global_constant', _version = 0x2601, _types = b'\x00\x00\x0D\x01\x00\x00\x09\x01', - _globals = (b'\x00\x00\x01\x1DBB',0,b'\x00\x00\x00\x1DBF',0), + _globals = (b'\x00\x00\x01\x25BB',0,b'\x00\x00\x00\x25BF',0), ) """ diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py --- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py +++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py @@ -167,7 +167,7 @@ def test_global_const_nonint(): from re_python_pysrc import ffi lib = ffi.dlopen(extmod) - assert ffi.string(lib.globalconsthello, 8) == "hello" + assert ffi.string(lib.globalconsthello, 8) == b"hello" py.test.raises(AttributeError, ffi.addressof, lib, 'globalconsthello') def test_rtld_constants(): diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py --- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py +++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py @@ -881,7 +881,7 @@ # but we can get its address p = ffi.addressof(lib, 'globvar') assert ffi.typeof(p) == ffi.typeof('opaque_t *') - assert ffi.string(ffi.cast("char *", p), 8) == "hello" + assert ffi.string(ffi.cast("char *", p), 8) == b"hello" def test_constant_of_value_unknown_to_the_compiler(): extra_c_source = udir.join( _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit