1. Soares Chen
  2. pypy


Armin Rigo  committed ed5f7dd

First round of translation fixes.

  • Participants
  • Parent commits a1c66a2
  • Branches ffi-backend

Comments (0)

Files changed (11)

File pypy/interpreter/baseobjspace.py

View file
         w_meth = self.getattr(w_obj, self.wrap(methname))
         return self.call_function(w_meth, *arg_w)
+    def raise_key_error(self, w_key):
+        e = self.call_function(self.w_KeyError, w_key)
+        raise OperationError(self.w_KeyError, e)
     def lookup(self, w_obj, name):
         w_type = self.type(w_obj)
         w_mro = self.getattr(w_type, self.wrap("__mro__"))

File pypy/module/_cffi_backend/ccallback.py

View file
 class W_CDataCallback(W_CDataApplevelOwning):
+    _immutable_ = True
     ll_error = lltype.nullptr(rffi.CCHARP.TO)
     def __init__(self, space, ctype, w_callable, w_error):

File pypy/module/_cffi_backend/cdataobj.py

View file
     """This is the abstract base class for classes that are of the app-level
     type '_cffi_backend.CDataOwn'.  These are weakrefable."""
     _attrs_ = []
+    _immutable_ = True
     def _owning_num_bytes(self):
         return self.ctype.size
     """This is the class used for the app-level type
     '_cffi_backend.CDataOwn' created by newp()."""
     _attrs_ = []
+    _immutable_ = True
     def __init__(self, space, size, ctype):
         cdata = lltype.malloc(rffi.CCHARP.TO, size, flavor='raw', zero=True)
     """Subclass with an explicit length, for allocated instances of
     the C type 'foo[]'."""
     _attrs_ = ['length']
+    _immutable_ = True
     def __init__(self, space, size, ctype, length):
         W_CDataNewOwning.__init__(self, space, size, ctype)
     It has a strong reference to a W_CDataNewOwning that really owns the
     struct, which is the object returned by the app-level expression 'p[0]'."""
     _attrs_ = ['structobj']
+    _immutable_ = True
     def __init__(self, space, cdata, ctype, structobj):
         W_CDataApplevelOwning.__init__(self, space, cdata, ctype)
     small bits of memory (e.g. just an 'int').  Its point is to not be
     a subclass of W_CDataApplevelOwning."""
     _attrs_ = []
+    _immutable_ = True
     def __init__(self, space, size, ctype):
         cdata = lltype.malloc(rffi.CCHARP.TO, size, flavor='raw', zero=True)

File pypy/module/_cffi_backend/ctypeenum.py

View file
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.rpython.lltypesystem import rffi
-from pypy.rlib.rarithmetic import intmask
+from pypy.rlib.rarithmetic import intmask, r_ulonglong
 from pypy.rlib.objectmodel import keepalive_until_here
 from pypy.module._cffi_backend.ctypeprim import W_CTypePrimitiveSigned
         if space.isinstance_w(w_ob, space.w_str):
             value = self.convert_enum_string_to_int(space.str_w(w_ob))
+            value = r_ulonglong(value)
             misc.write_raw_integer_data(cdata, value, self.size)
             raise self._convert_error("str or int", w_ob)

File pypy/module/_cffi_backend/ctypeprim.py

View file
         if (isinstance(ob, cdataobj.W_CData) and
                isinstance(ob.ctype, ctypeptr.W_CTypePtrOrArray)):
             value = rffi.cast(lltype.Signed, ob._cdata)
+            value = r_ulonglong(value)
         elif space.isinstance_w(w_ob, space.w_str):
             value = self.cast_str(w_ob)
+            value = r_ulonglong(value)
             value = misc.as_unsigned_long_long(space, w_ob, strict=False)
         w_cdata = cdataobj.W_CDataCasted(space, self.size, self)
         if self.size < rffi.sizeof(lltype.SignedLongLong):
             if r_ulonglong(value) - self.vmin > self.vrangemax:
+        value = r_ulonglong(value)
         misc.write_raw_integer_data(cdata, value, self.size)

File pypy/module/_cffi_backend/ctypestruct.py

View file
     def _check_only_one_argument_for_union(self, w_ob):
         space = self.space
-        if space.int_w(space.len(w_ob)) > 1:
+        n = space.int_w(space.len(w_ob))
+        if n > 1:
             raise operationerrfmt(space.w_ValueError,
                                   "initializer for '%s': %d items given, but "
                                   "only one supported (use a dict if needed)",

File pypy/module/_cffi_backend/func.py

View file
         if size < 0:
             raise operationerrfmt(space.w_ValueError,
                                   "ctype '%s' is of unknown size",
-                                  w_ctype.name)
+                                  ob.name)
         raise OperationError(space.w_TypeError,
                             space.wrap("expected a 'cdata' or 'ctype' object"))

File pypy/module/_cffi_backend/newtype.py

View file
 from pypy.interpreter.gateway import unwrap_spec
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.rlib.rarithmetic import ovfcheck
+from pypy.rlib.objectmodel import specialize
 from pypy.module._cffi_backend import ctypeobj, ctypeprim, ctypeptr, ctypearray
 from pypy.module._cffi_backend import ctypestruct, ctypevoid, ctypeenum
 def alignment(TYPE):
     S = lltype.Struct('aligncheck', ('x', lltype.Char), ('y', TYPE))
     return rffi.offsetof(S, 'y')

File pypy/module/_cffi_backend/test/test_ztranslation.py

View file
+from pypy.objspace.fake.checkmodule import checkmodule
+def test_checkmodule():
+    checkmodule('_cffi_backend')

File pypy/objspace/std/objspace.py

View file
             return ObjSpace.call_method(self, w_obj, methname, *arg_w)
-    def raise_key_error(self, w_key):
-        e = self.call_function(self.w_KeyError, w_key)
-        raise OperationError(self.w_KeyError, e)
     def _type_issubtype(self, w_sub, w_type):
         if isinstance(w_sub, W_TypeObject) and isinstance(w_type, W_TypeObject):
             return self.wrap(w_sub.issubtype(w_type))

File pypy/rpython/lltypesystem/llmemory.py

View file
     return ItemOffset(TYPE)
 _sizeof_none._annspecialcase_ = 'specialize:memo'
+def _internal_array_field(TYPE):
+    return TYPE._arrayfld, TYPE._flds[TYPE._arrayfld]
+_internal_array_field._annspecialcase_ = 'specialize:memo'
 def _sizeof_int(TYPE, n):
     if isinstance(TYPE, lltype.Struct):
-        return FieldOffset(TYPE, TYPE._arrayfld) + \
-               itemoffsetof(TYPE._flds[TYPE._arrayfld], n)
+        fldname, ARRAY = _internal_array_field(TYPE)
+        return offsetof(TYPE, fldname) + sizeof(ARRAY, n)
         raise Exception("don't know how to take the size of a %r"%TYPE)