[pypy-commit] pypy default: More long long removal.
arigo
noreply at buildbot.pypy.org
Sat Oct 6 12:44:56 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r57803:a3bed57683e8
Date: 2012-10-06 12:01 +0200
http://bitbucket.org/pypy/pypy/changeset/a3bed57683e8/
Log: More long long removal.
diff --git a/pypy/module/_cffi_backend/ctypeprim.py b/pypy/module/_cffi_backend/ctypeprim.py
--- a/pypy/module/_cffi_backend/ctypeprim.py
+++ b/pypy/module/_cffi_backend/ctypeprim.py
@@ -223,7 +223,7 @@
def convert_to_object(self, cdata):
if self.value_fits_long:
- value = misc.read_raw_ulong_data(cdata, self.size)
+ value = misc.read_raw_uint_data(cdata, self.size)
return self.space.wrap(value)
else:
value = misc.read_raw_unsigned_data(cdata, self.size)
diff --git a/pypy/module/_cffi_backend/ctypestruct.py b/pypy/module/_cffi_backend/ctypestruct.py
--- a/pypy/module/_cffi_backend/ctypestruct.py
+++ b/pypy/module/_cffi_backend/ctypestruct.py
@@ -7,7 +7,7 @@
from pypy.interpreter.baseobjspace import Wrappable
from pypy.interpreter.typedef import TypeDef, interp_attrproperty
from pypy.rlib.objectmodel import keepalive_until_here
-from pypy.rlib.rarithmetic import r_ulonglong, r_longlong, intmask
+from pypy.rlib.rarithmetic import r_uint, r_ulonglong, r_longlong, intmask
from pypy.rlib import jit
from pypy.module._cffi_backend.ctypeobj import W_CType
@@ -195,14 +195,19 @@
space = ctype.space
#
if isinstance(ctype, ctypeprim.W_CTypePrimitiveSigned):
- value = r_ulonglong(misc.read_raw_signed_data(cdata, ctype.size))
- valuemask = (r_ulonglong(1) << self.bitsize) - 1
- shiftforsign = r_ulonglong(1) << (self.bitsize - 1)
- value = ((value >> self.bitshift) + shiftforsign) & valuemask
- result = r_longlong(value) - r_longlong(shiftforsign)
if ctype.value_fits_long:
- return space.wrap(intmask(result))
+ value = r_uint(misc.read_raw_long_data(cdata, ctype.size))
+ valuemask = (r_uint(1) << self.bitsize) - 1
+ shiftforsign = r_uint(1) << (self.bitsize - 1)
+ value = ((value >> self.bitshift) + shiftforsign) & valuemask
+ result = intmask(value) - intmask(shiftforsign)
+ return space.wrap(result)
else:
+ value = misc.read_raw_unsigned_data(cdata, ctype.size)
+ valuemask = (r_ulonglong(1) << self.bitsize) - 1
+ shiftforsign = r_ulonglong(1) << (self.bitsize - 1)
+ value = ((value >> self.bitshift) + shiftforsign) & valuemask
+ result = r_longlong(value) - r_longlong(shiftforsign)
return space.wrap(result)
#
if isinstance(ctype, ctypeprim.W_CTypePrimitiveUnsigned):
@@ -212,12 +217,15 @@
else:
raise NotImplementedError
#
- value = misc.read_raw_unsigned_data(cdata, ctype.size)
- valuemask = (r_ulonglong(1) << self.bitsize) - 1
- value = (value >> self.bitshift) & valuemask
if value_fits_long:
+ value = r_uint(misc.read_raw_uint_data(cdata, ctype.size))
+ valuemask = (r_uint(1) << self.bitsize) - 1
+ value = (value >> self.bitshift) & valuemask
return space.wrap(intmask(value))
else:
+ value = misc.read_raw_unsigned_data(cdata, ctype.size)
+ valuemask = (r_ulonglong(1) << self.bitsize) - 1
+ value = (value >> self.bitshift) & valuemask
return space.wrap(value)
def convert_bitfield_from_object(self, cdata, w_ob):
diff --git a/pypy/module/_cffi_backend/misc.py b/pypy/module/_cffi_backend/misc.py
--- a/pypy/module/_cffi_backend/misc.py
+++ b/pypy/module/_cffi_backend/misc.py
@@ -46,7 +46,7 @@
return rffi.cast(lltype.UnsignedLongLong, rffi.cast(TPP,target)[0])
raise NotImplementedError("bad integer size")
-def read_raw_ulong_data(target, size):
+def read_raw_uint_data(target, size):
# only for types smaller than Unsigned
for TP, TPP in _prim_unsigned_types:
if size == rffi.sizeof(TP):
More information about the pypy-commit
mailing list