[pypy-svn] r46198 - in pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem: . test

fijal at codespeak.net fijal at codespeak.net
Thu Aug 30 16:10:36 CEST 2007


Author: fijal
Date: Thu Aug 30 16:10:36 2007
New Revision: 46198

Modified:
   pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py
   pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/test/test_ll2ctypes.py
Log:
A test and a fix for recursive types (test probably should check for sth else
as well...)


Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/ll2ctypes.py	Thu Aug 30 16:10:36 2007
@@ -43,6 +43,8 @@
         FIELDTYPE = S._flds[fieldname]
         if max_n is not None and fieldname == S._arrayfld:
             cls = build_ctypes_array(FIELDTYPE, max_n)
+        elif isinstance(FIELDTYPE, lltype.Ptr) and FIELDTYPE.TO is S:
+            cls = ctypes.POINTER(S._name)
         else:
             cls = get_ctypes_type(FIELDTYPE)
         fields.append((fieldname, cls))

Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/test/test_ll2ctypes.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/test/test_ll2ctypes.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/lltypesystem/test/test_ll2ctypes.py	Thu Aug 30 16:10:36 2007
@@ -407,9 +407,8 @@
 
     def test_recursive_struct(self):
         # XXX sucky way of creating those
-        py.test.skip("HELP! I don't know how to make this work")
-        SX = lltype.Struct('y')
+        SX = lltype.ForwardReference()
         S1 = lltype.Struct('S1', ('x', lltype.Ptr(SX)))
-        S1._flds['x'] = lltype.Ptr(S1)
+        S1._flds['x'].TO.become(S1)
         s = lltype.malloc(S1, flavor='raw')
         sc = lltype2ctypes(s)



More information about the Pypy-commit mailing list