[pypy-svn] r46749 - in pypy/dist/pypy/rpython/lltypesystem: . test
arigo at codespeak.net
arigo at codespeak.net
Wed Sep 19 22:22:31 CEST 2007
Author: arigo
Date: Wed Sep 19 22:22:29 2007
New Revision: 46749
Modified:
pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
Log:
Fix substructures.
Modified: pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py Wed Sep 19 22:22:29 2007
@@ -228,6 +228,17 @@
for i in range(container.getlength()):
container.items[i] = None
+def struct_use_ctypes_storage(container, ctypes_storage):
+ STRUCT = container._TYPE
+ assert isinstance(STRUCT, lltype.Struct)
+ add_storage(container, _struct_mixin, ctypes_storage)
+ remove_regular_struct_content(container)
+ for field_name in STRUCT._names:
+ FIELDTYPE = getattr(STRUCT, field_name)
+ if isinstance(FIELDTYPE, lltype.ContainerType):
+ struct_use_ctypes_storage(getattr(container, field_name),
+ getattr(ctypes_storage, field_name))
+
# ____________________________________________________________
# Ctypes-aware subclasses of the _parentable classes
@@ -394,10 +405,10 @@
if not cobj: # NULL pointer
return lltype.nullptr(T.TO)
if isinstance(T.TO, lltype.Struct):
- # XXX var-sized structs
+ if T.TO._arrayfld is not None:
+ raise NotImplementedError("XXX var-sized structs")
container = lltype._struct(T.TO)
- add_storage(container, _struct_mixin, cobj.contents)
- remove_regular_struct_content(container)
+ struct_use_ctypes_storage(container, cobj.contents)
elif isinstance(T.TO, lltype.Array):
if T.TO._hints.get('nolength', False):
container = _array_of_unknown_length(T.TO)
Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Wed Sep 19 22:22:29 2007
@@ -426,7 +426,6 @@
assert s1ac.contents.x == 59
assert s.s1a.x == 59
- py.test.skip("in-progress")
t = ctypes2lltype(lltype.Ptr(BIG), sc)
assert t == s
assert t.s1a == s.s1a
More information about the Pypy-commit
mailing list