[pypy-svn] pypy real-rffi.INT: Start to make all int types different from each other.
amauryfa
commits-noreply at bitbucket.org
Wed Mar 2 01:23:04 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: real-rffi.INT
Changeset: r42375:7ae5475d94a0
Date: 2011-03-02 01:20 +0100
http://bitbucket.org/pypy/pypy/changeset/7ae5475d94a0/
Log: Start to make all int types different from each other.
diff --git a/pypy/rpython/lltypesystem/test/test_rffi.py b/pypy/rpython/lltypesystem/test/test_rffi.py
--- a/pypy/rpython/lltypesystem/test/test_rffi.py
+++ b/pypy/rpython/lltypesystem/test/test_rffi.py
@@ -693,6 +693,10 @@
res = interpret(f, [])
assert res == 3
+ def test_type_identity(self):
+ assert INT != lltype.Signed
+ assert LONG != INT
+
def test_size_t_sign(self):
assert r_size_t(-1) > 0
diff --git a/pypy/rpython/lltypesystem/rffi.py b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -405,7 +405,7 @@
NUMBER_TYPES = setup()
platform.numbertype_to_rclass[lltype.Signed] = int # avoid "r_long" for common cases
-r_int_real = rarithmetic.build_int("r_int_real", r_int.SIGN, r_int.BITS, True)
+r_int_real = rarithmetic.build_int("r_int_real", r_int.SIGN, r_int.BITS)
INT_real = lltype.build_number("INT", r_int_real)
platform.numbertype_to_rclass[INT_real] = r_int_real
NUMBER_TYPES.append(INT_real)
diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -482,15 +482,8 @@
return super(unsigned_int, klass).__new__(klass, val & klass.MASK)
typemap = {}
-_inttypes = {}
-
-def build_int(name, sign, bits, force_creation=False):
+def build_int(name, sign, bits):
sign = bool(sign)
- if not force_creation:
- try:
- return _inttypes[sign, bits]
- except KeyError:
- pass
if sign:
base_int_type = signed_int
else:
@@ -501,8 +494,6 @@
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
diff --git a/pypy/rpython/tool/rffi_platform.py b/pypy/rpython/tool/rffi_platform.py
--- a/pypy/rpython/tool/rffi_platform.py
+++ b/pypy/rpython/tool/rffi_platform.py
@@ -612,8 +612,8 @@
rffi.SHORT, rffi.USHORT,
rffi.INT, rffi.UINT,
rffi.LONG, rffi.ULONG,
- rffi.LONGLONG, rffi.ULONGLONG]
-# XXX SIZE_T?
+ rffi.LONGLONG, rffi.ULONGLONG,
+ rffi.SIZE_T]
float_class = [rffi.DOUBLE]
diff --git a/pypy/rpython/tool/rfficache.py b/pypy/rpython/tool/rfficache.py
--- a/pypy/rpython/tool/rfficache.py
+++ b/pypy/rpython/tool/rfficache.py
@@ -54,7 +54,10 @@
class Platform:
def __init__(self):
self.types = {}
- self.numbertype_to_rclass = {}
+ self.numbertype_to_rclass = {
+ lltype.Signed: rarithmetic.r_int,
+ lltype.Unsigned: rarithmetic.r_uint,
+ }
def inttype(self, name, c_name, signed, **kwds):
try:
More information about the Pypy-commit
mailing list