Author: Armin Rigo <ar...@tunes.org> Branch: cffi-1.0 Changeset: r77227:84657c90a123 Date: 2015-05-08 18:23 +0200 http://bitbucket.org/pypy/pypy/changeset/84657c90a123/
Log: Translation fixes (yay test_ztranslation) diff --git a/pypy/module/_cffi_backend/ffi_obj.py b/pypy/module/_cffi_backend/ffi_obj.py --- a/pypy/module/_cffi_backend/ffi_obj.py +++ b/pypy/module/_cffi_backend/ffi_obj.py @@ -2,7 +2,7 @@ from pypy.interpreter.baseobjspace import W_Root from pypy.interpreter.typedef import TypeDef, GetSetProperty, ClassAttr from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault -from rpython.rlib import jit, rgc +from rpython.rlib import jit, rgc, nonconst from rpython.rtyper.lltypesystem import rffi from pypy.module._cffi_backend import parse_c_type, realize_c_type @@ -34,7 +34,7 @@ class W_FFIObject(W_Root): - def __init__(self, space, src_ctx=parse_c_type.NULL_CTX): + def __init__(self, space, src_ctx): self.space = space self.types_dict = {} self.ctxobj = parse_c_type.allocate_ctxobj(src_ctx) @@ -339,7 +339,9 @@ def W_FFIObject___new__(space, w_subtype, __args__): r = space.allocate_instance(W_FFIObject, w_subtype) - r.__init__(space) + # get in 'src_ctx' a NULL which transaction doesn't consider a constant + src_ctx = rffi.cast(parse_c_type.PCTX, nonconst.NonConstant(0)) + r.__init__(space, src_ctx) return space.wrap(r) def make_NULL(space): diff --git a/pypy/module/_cffi_backend/realize_c_type.py b/pypy/module/_cffi_backend/realize_c_type.py --- a/pypy/module/_cffi_backend/realize_c_type.py +++ b/pypy/module/_cffi_backend/realize_c_type.py @@ -1,5 +1,6 @@ import sys from rpython.rlib.rarithmetic import intmask +from rpython.rlib.objectmodel import specialize from rpython.rtyper.lltypesystem import lltype, rffi from pypy.interpreter.error import oefmt from pypy.interpreter.baseobjspace import W_Root @@ -8,9 +9,11 @@ from pypy.module._cffi_backend import parse_c_type +@specialize.ll() def getop(op): return rffi.cast(rffi.SIGNED, op) & 0xFF +@specialize.ll() def getarg(op): return rffi.cast(rffi.SIGNED, op) >> 8 @@ -78,7 +81,7 @@ elif 0 <= num < len(RealizeCache.NAMES) and RealizeCache.NAMES[num]: w_ctype = newtype.new_primitive_type(space, RealizeCache.NAMES[num]) else: - raise oefmt(ffi.space.w_NotImplementedError, "prim=%d", case) + raise oefmt(space.w_NotImplementedError, "prim=%d", num) realize_cache.all_primitives[num] = w_ctype return w_ctype @@ -99,15 +102,16 @@ neg = rffi.cast(lltype.Signed, neg) if neg == 0: # positive - if value <= sys.maxint: + if value <= rffi.cast(rffi.ULONGLONG, sys.maxint): return ffi.space.wrap(intmask(value)) else: return ffi.space.wrap(value) elif neg == 1: # negative + value = rffi.cast(rffi.LONGLONG, value) if value >= -sys.maxint-1: return ffi.space.wrap(intmask(value)) else: - return ffi.space.wrap(rffi.cast(rffi.LONGLONG, value)) + return ffi.space.wrap(value) if neg == 2: got = "%d (0x%x)" % (value, value) @@ -240,8 +244,8 @@ name = _realize_name("enum ", e.c_name) w_ctype = newtype.new_enum_type(space, name, - space.newtuple(enumerators_w), - space.newtuple(enumvalues_w), + space.newlist(enumerators_w), + space.newlist(enumvalues_w), w_basetd) # Update the "primary" OP_ENUM slot @@ -389,7 +393,7 @@ assert w_ctype._fields_list is not None # not lazy any more w_ctype._lazy_ffi = None - w_ctype._lazy_s = lltype.nullptr(parse_c_type.FIELD_S) + w_ctype._lazy_s = lltype.nullptr(parse_c_type.STRUCT_UNION_S) def _fetch_external_struct_or_union(s, included_libs): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit