[pypy-svn] r62822 - pypy/branch/pyjitpl5/pypy/rpython/lltypesystem
fijal at codespeak.net
fijal at codespeak.net
Tue Mar 10 17:57:21 CET 2009
Author: fijal
Date: Tue Mar 10 17:57:20 2009
New Revision: 62822
Modified:
pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/lltype.py
Log:
* Support for bool (a bit)
* Support for nested structures with parents (seems not to work perfectly though)
Modified: pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes.py Tue Mar 10 17:57:20 2009
@@ -622,7 +622,7 @@
container._ctypes_storage_was_allocated()
storage = container._storage
if lltype.parentlink(container)[0] is not None:
- _parent_cache[ctypes.addressof(storage)] = lltype.parentlink(container)
+ _parent_cache[ctypes.addressof(storage)] = parentchain(container)
p = ctypes.pointer(storage)
if index:
p = ctypes.cast(p, ctypes.c_void_p)
@@ -688,7 +688,10 @@
struct_use_ctypes_storage(container, cobj.contents)
addr = ctypes.addressof(cobj.contents)
if addr in _parent_cache:
- container._setparentstructure(*_parent_cache[addr])
+ setparentstructure(container, _parent_cache[addr])
+ else:
+ import pdb
+ pdb.set_trace()
elif isinstance(T.TO, lltype.Array):
if T.TO._hints.get('nolength', False):
container = _array_of_unknown_length(T.TO)
@@ -720,6 +723,8 @@
llobj = _lladdress(cobj)
elif T is lltype.Char:
llobj = chr(cobj)
+ elif T is lltype.Bool:
+ llobj = bool(cobj)
elif T is lltype.UniChar:
llobj = unichr(cobj)
elif T is lltype.Signed:
@@ -1059,6 +1064,24 @@
return hop.genop('cast_adr_to_int', [adr],
resulttype = lltype.Signed)
+# ------------------------------------------------------------
+
+def parentchain(container):
+ current = container
+ links = []
+ while True:
+ link = lltype.parentlink(current)
+ if link[0] is None:
+ return links
+ links.append(link)
+ current = link[0]
+
+def setparentstructure(container, chain):
+ current = container
+ for elem in chain:
+ current._setparentstructure(*elem)
+ current = elem[0]
+
# ____________________________________________________________
# errno
Modified: pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/lltype.py (original)
+++ pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/lltype.py Tue Mar 10 17:57:20 2009
@@ -1161,6 +1161,8 @@
while u:
parent = struc._parentstructure()
if parent is None:
+ import pdb
+ pdb.set_trace()
raise RuntimeError("widening to trash: %r" % self)
PARENTTYPE = struc._parent_type
if getattr(parent, PARENTTYPE._names[0]) != struc:
More information about the Pypy-commit
mailing list