[pypy-svn] r43766 - in pypy/branch/kill-ctypes/pypy/rpython/lltypesystem: . test

fijal at codespeak.net fijal at codespeak.net
Mon May 28 00:58:57 CEST 2007


Author: fijal
Date: Mon May 28 00:58:55 2007
New Revision: 43766

Modified:
   pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/rffi.py
   pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/test/test_rfficache.py
Log:
Add those type to be available


Modified: pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/rffi.py	(original)
+++ pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/rffi.py	Mon May 28 00:58:55 2007
@@ -3,6 +3,7 @@
 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.annotation.model import lltype_to_annotation
 from pypy.rlib.objectmodel import Symbolic, CDefinedIntSymbolic
+from pypy.rlib import rarithmetic
 
 class CConstant(Symbolic):
     """ A C-level constant, maybe #define, rendered directly.
@@ -23,6 +24,24 @@
                               sources=tuple(sources),
                               includes=tuple(includes))
 
+def setup():
+    """ creates necessary c-level types
+    """
+    from pypy.rpython.lltypesystem.rfficache import platform
+    for name, bits in platform.items():
+        if name.startswith('unsigned'):
+            name = 'u' + name[9:]
+            signed = False
+        else:
+            signed = True
+        name = name.replace(' ', '')
+        llname = name.upper()
+        inttype = rarithmetic.build_int('r_' + name, signed, bits)
+        globals()['r_' + name] = inttype
+        globals()[llname] = lltype.build_number(llname, inttype)
+
+setup()
+
 def CStruct(name, *fields, **kwds):
     """ A small helper to create external C structure, not the
     pypy one
@@ -72,4 +91,3 @@
         lltype.free(next[i], flavor='raw')
         i += 1
     lltype.free(ref, flavor='raw')
-

Modified: pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/test/test_rfficache.py
==============================================================================
--- pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/test/test_rfficache.py	(original)
+++ pypy/branch/kill-ctypes/pypy/rpython/lltypesystem/test/test_rfficache.py	Mon May 28 00:58:55 2007
@@ -1,5 +1,6 @@
 
 from pypy.rpython.lltypesystem.rfficache import *
+from pypy.rpython.lltypesystem import rffi
 from pypy.tool.udir import udir
 
 def test_sizeof_c_type():
@@ -19,3 +20,12 @@
     """))
     assert get_type_sizes(tmpfile)['char'] == 8
     assert get_type_sizes(tmpfile, platform_key='xxx', compiler_exe='xxx')['char'] == 4
+
+def test_types_present():
+    for name in TYPES:
+        if name.startswith('unsigned'):
+            name = 'u' + name[9:]
+        name = name.replace(' ', '')
+        assert hasattr(rffi, 'r_' + name)
+        assert hasattr(rffi, name.upper())
+



More information about the Pypy-commit mailing list