[pypy-svn] r72480 - in pypy/trunk/pypy: rpython/lltypesystem translator/c translator/c/test

xoraxax at codespeak.net xoraxax at codespeak.net
Sat Mar 20 22:49:10 CET 2010


Author: xoraxax
Date: Sat Mar 20 22:49:09 2010
New Revision: 72480

Modified:
   pypy/trunk/pypy/rpython/lltypesystem/rffi.py
   pypy/trunk/pypy/translator/c/node.py
   pypy/trunk/pypy/translator/c/test/test_database.py
Log:
Add real void* type!

Modified: pypy/trunk/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/rffi.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/rffi.py	Sat Mar 20 22:49:09 2010
@@ -520,6 +520,7 @@
 
 # void *   - for now, represented as char *
 VOIDP = lltype.Ptr(lltype.Array(lltype.Char, hints={'nolength': True}))
+VOIDP_real = lltype.Ptr(lltype.Array(lltype.Char, hints={'nolength': True, 'render_as_void': True}))
 
 # void **
 VOIDPP = CArrayPtr(VOIDP)

Modified: pypy/trunk/pypy/translator/c/node.py
==============================================================================
--- pypy/trunk/pypy/translator/c/node.py	(original)
+++ pypy/trunk/pypy/translator/c/node.py	Sat Mar 20 22:49:09 2010
@@ -304,7 +304,10 @@
         self.LLTYPE = ARRAY
         self.varlength = varlength
         self.dependencies = {}
-        self.itemtypename = db.gettype(ARRAY.OF, who_asks=self)
+        contained_type = ARRAY.OF
+        if ARRAY._hints.get("render_as_void"):
+            contained_type = Void
+        self.itemtypename = db.gettype(contained_type, who_asks=self)
 
     def setup(self):
         """Array loops are forbidden by ForwardReference.become() because

Modified: pypy/trunk/pypy/translator/c/test/test_database.py
==============================================================================
--- pypy/trunk/pypy/translator/c/test/test_database.py	(original)
+++ pypy/trunk/pypy/translator/c/test/test_database.py	Sat Mar 20 22:49:09 2010
@@ -5,6 +5,7 @@
 from pypy.objspace.flow.model import Constant, Variable, SpaceOperation
 from pypy.objspace.flow.model import Block, Link, FunctionGraph
 from pypy.rpython.typesystem import getfunctionptr
+from pypy.rpython.lltypesystem.rffi import VOIDP_real
 
 
 def dump_on_stdout(database):
@@ -221,6 +222,11 @@
     db.complete()
     dump_on_stdout(db)
 
+def test_voidp():
+    A = VOIDP_real
+    db = LowLevelDatabase()
+    assert db.gettype(A) == "void *@"
+
 def test_recursive_struct():
     S = GcForwardReference()
     S.become(GcStruct('testing', ('p', Ptr(S))))



More information about the Pypy-commit mailing list