[pypy-svn] r72515 - in pypy/trunk/pypy: rlib rpython/lltypesystem
xoraxax at codespeak.net
xoraxax at codespeak.net
Mon Mar 22 00:58:27 CET 2010
Author: xoraxax
Date: Mon Mar 22 00:58:25 2010
New Revision: 72515
Modified:
pypy/trunk/pypy/rlib/rarithmetic.py
pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/trunk/pypy/rpython/lltypesystem/rffi.py
Log:
Build INT_real a bit differently.
Modified: pypy/trunk/pypy/rlib/rarithmetic.py
==============================================================================
--- pypy/trunk/pypy/rlib/rarithmetic.py (original)
+++ pypy/trunk/pypy/rlib/rarithmetic.py Mon Mar 22 00:58:25 2010
@@ -321,12 +321,13 @@
_inttypes = {}
-def build_int(name, sign, bits):
+def build_int(name, sign, bits, force_creation=False):
sign = bool(sign)
- try:
- return _inttypes[sign, bits]
- except KeyError:
- pass
+ if not force_creation:
+ try:
+ return _inttypes[sign, bits]
+ except KeyError:
+ pass
if sign:
base_int_type = signed_int
else:
@@ -334,8 +335,11 @@
mask = (2 ** bits) - 1
if name is None:
raise TypeError('No predefined %sint%d'%(['u', ''][sign], bits))
- int_type = _inttypes[sign, bits] = type(name, (base_int_type,), {'MASK': mask,
- 'BITS': bits})
+ int_type = type(name, (base_int_type,), {'MASK': mask,
+ 'BITS': bits,
+ 'SIGN': sign})
+ if not force_creation:
+ _inttypes[sign, bits] = int_type
class ForValuesEntry(extregistry.ExtRegistryEntry):
_type_ = int_type
Modified: pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py Mon Mar 22 00:58:25 2010
@@ -44,6 +44,7 @@
rffi.SHORT: ctypes.c_short,
rffi.USHORT: ctypes.c_ushort,
rffi.INT: ctypes.c_int,
+ rffi.INT_real: ctypes.c_int,
rffi.UINT: ctypes.c_uint,
rffi.LONG: ctypes.c_long,
rffi.ULONG: ctypes.c_ulong,
Modified: pypy/trunk/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/rffi.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/rffi.py Mon Mar 22 00:58:25 2010
@@ -378,7 +378,9 @@
NUMBER_TYPES = setup()
platform.numbertype_to_rclass[lltype.Signed] = int # avoid "r_long" for common cases
-INT_real = lltype.Number("INT", INT._type)
+r_int_real = rarithmetic.build_int("r_int_real", r_int.SIGN, r_int.BITS, True)
+INT_real = lltype.build_number("INT", r_int_real)
+platform.numbertype_to_rclass[INT_real] = r_int_real
# ^^^ this creates at least the following names:
# --------------------------------------------------------------------
More information about the Pypy-commit
mailing list