Author: Armin Rigo <[email protected]>
Branch: py3.5-newtext
Changeset: r90134:78d15c73cfad
Date: 2017-02-15 08:16 +0100
http://bitbucket.org/pypy/pypy/changeset/78d15c73cfad/
Log: hg merge 8dfca1a083c6
diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py
--- a/pypy/module/cppyy/converter.py
+++ b/pypy/module/cppyy/converter.py
@@ -225,9 +225,6 @@
class NumericTypeConverterMixin(object):
_mixin_ = True
- def _wrap_object(self, space, obj):
- return getattr(space, self.wrapper)(obj)
-
def convert_argument_libffi(self, space, w_obj, address, call_local):
x = rffi.cast(self.c_ptrtype, address)
x[0] = self._unwrap_object(space, w_obj)
diff --git a/pypy/module/cppyy/executor.py b/pypy/module/cppyy/executor.py
--- a/pypy/module/cppyy/executor.py
+++ b/pypy/module/cppyy/executor.py
@@ -80,8 +80,8 @@
class NumericExecutorMixin(object):
_mixin_ = True
- def _wrap_object(self, space, obj):
- return getattr(space, self.wrapper)(obj)
+ #def _wrap_object(self, space, obj):
+ # return getattr(space, self.wrapper)(obj)
def execute(self, space, cppmethod, cppthis, num_args, args):
result = self.c_stubcall(space, cppmethod, cppthis, num_args, args)
@@ -104,8 +104,8 @@
self.item = self._unwrap_object(space, w_item)
self.do_assign = True
- def _wrap_object(self, space, obj):
- return getattr(space, self.wrapper)(rffi.cast(self.c_type, obj))
+ #def _wrap_object(self, space, obj):
+ # return getattr(space, self.wrapper)(rffi.cast(self.c_type, obj))
def _wrap_reference(self, space, rffiptr):
if self.do_assign:
diff --git a/pypy/module/cppyy/ffitypes.py b/pypy/module/cppyy/ffitypes.py
--- a/pypy/module/cppyy/ffitypes.py
+++ b/pypy/module/cppyy/ffitypes.py
@@ -41,18 +41,6 @@
self.c_size_t = nt.new_primitive_type(space, 'size_t')
self.c_ptrdiff_t = nt.new_primitive_type(space, 'ptrdiff_t')
-class BaseIntTypeMixin(object):
- _mixin_ = True
- _immutable_fields_ = ['wrapper']
-
- wrapper = 'newint'
-
-class BaseLongTypeMixin(object):
- _mixin_ = True
- _immutable_fields_ = ['wrapper']
-
- wrapper = 'newlong'
-
class BoolTypeMixin(object):
_mixin_ = True
_immutable_fields_ = ['c_type', 'c_ptrtype']
@@ -60,6 +48,9 @@
c_type = rffi.UCHAR
c_ptrtype = rffi.UCHARP
+ def _wrap_object(self, space, obj):
+ return space.newbool(bool(ord(rffi.cast(rffi.CHAR, obj))))
+
def _unwrap_object(self, space, w_obj):
arg = space.c_int_w(w_obj)
if arg != False and arg != True:
@@ -80,7 +71,9 @@
c_type = rffi.CHAR
c_ptrtype = rffi.CCHARP # there's no such thing as rffi.CHARP
- wrapper = 'newbytes'
+
+ def _wrap_object(self, space, obj):
+ return space.newbytes(obj)
def _unwrap_object(self, space, w_value):
# allow int to pass to char and make sure that str is of length 1
@@ -151,6 +144,9 @@
c_type = rffi.UINT
c_ptrtype = rffi.UINTP
+ def _wrap_object(self, space, obj):
+ return space.newlong_from_rarith_int(obj)
+
def _unwrap_object(self, space, w_obj):
return rffi.cast(self.c_type, space.uint_w(w_obj))
@@ -165,6 +161,9 @@
c_type = rffi.LONG
c_ptrtype = rffi.LONGP
+ def _wrap_object(self, space, obj):
+ return space.newlong(obj)
+
def _unwrap_object(self, space, w_obj):
return space.int_w(w_obj)
@@ -181,6 +180,9 @@
c_type = rffi.ULONG
c_ptrtype = rffi.ULONGP
+ def _wrap_object(self, space, obj):
+ return space.newlong_from_rarith_int(obj)
+
def _unwrap_object(self, space, w_obj):
return space.uint_w(w_obj)
@@ -195,6 +197,9 @@
c_type = rffi.LONGLONG
c_ptrtype = rffi.LONGLONGP
+ def _wrap_object(self, space, obj):
+ return space.newlong_from_rarith_int(obj)
+
def _unwrap_object(self, space, w_obj):
return space.r_longlong_w(w_obj)
@@ -209,6 +214,9 @@
c_type = rffi.ULONGLONG
c_ptrtype = rffi.ULONGLONGP
+ def _wrap_object(self, space, obj):
+ return space.newlong_from_rarith_int(obj)
+
def _unwrap_object(self, space, w_obj):
return space.r_ulonglong_w(w_obj)
@@ -240,9 +248,11 @@
c_type = rffi.DOUBLE
c_ptrtype = rffi.DOUBLEP
- wrapper = 'newfloat'
typecode = 'd'
+ def _wrap_object(self, space, obj):
+ return space.newfloat(obj)
+
def _unwrap_object(self, space, w_obj):
return space.float_w(w_obj)
diff --git a/pypy/module/cppyy/test/test_zjit.py
b/pypy/module/cppyy/test/test_zjit.py
--- a/pypy/module/cppyy/test/test_zjit.py
+++ b/pypy/module/cppyy/test/test_zjit.py
@@ -1,7 +1,7 @@
import py, os, sys
from rpython.jit.metainterp.test.support import LLJitMixin
from rpython.rlib.objectmodel import specialize, instantiate
-from rpython.rlib import rarithmetic, jit
+from rpython.rlib import rarithmetic, rbigint, jit
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rtyper import llinterp
from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root
@@ -158,11 +158,20 @@
@specialize.argtype(1)
def newint(self, obj):
- return FakeInt(rarithmetic.intmask(obj))
+ if not isinstance(obj, int):
+ return FakeLong(rbigint.rbigint.fromrarith_int(obj))
+ return FakeInt(obj)
@specialize.argtype(1)
def newlong(self, obj):
- return FakeLong(rarithmetic.intmask(obj))
+ return FakeLong(rbigint.rbigint.fromint(obj))
+
+ @specialize.argtype(1)
+ def newlong_from_rarith_int(self, obj):
+ return FakeLong(rbigint.rbigint.fromrarith_int(obj))
+
+ def newlong_from_rbigint(self, val):
+ return FakeLong(obj)
@specialize.argtype(1)
def newfloat(self, obj):
@@ -202,10 +211,8 @@
return w_obj.val
def uint_w(self, w_obj):
- if isinstance(w_obj, FakeInt):
- return rarithmetic.r_uint(w_obj.val)
assert isinstance(w_obj, FakeLong)
- return rarithmetic.r_uint(w_obj.val)
+ return rarithmetic.r_uint(w_obj.val.touint())
def str_w(self, w_obj):
assert isinstance(w_obj, FakeString)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit