[pypy-commit] pypy inline-dict-ops: one more missing case for parentstructure
fijal
noreply at buildbot.pypy.org
Sun Jul 3 20:26:02 CEST 2011
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: inline-dict-ops
Changeset: r45328:e575516493ff
Date: 2011-07-03 20:33 +0200
http://bitbucket.org/pypy/pypy/changeset/e575516493ff/
Log: one more missing case for parentstructure
diff --git a/pypy/rpython/lltypesystem/ll2ctypes.py b/pypy/rpython/lltypesystem/ll2ctypes.py
--- a/pypy/rpython/lltypesystem/ll2ctypes.py
+++ b/pypy/rpython/lltypesystem/ll2ctypes.py
@@ -525,7 +525,10 @@
return 0, sys.maxint
def getitem(self, index, uninitialized_ok=False):
- return self._storage.contents._getitem(index, boundscheck=False)
+ res = self._storage.contents._getitem(index, boundscheck=False)
+ if isinstance(self._TYPE.OF, lltype.ContainerType):
+ res._obj._setparentstructure(self, index)
+ return res
def setitem(self, index, value):
self._storage.contents._setitem(index, value, boundscheck=False)
diff --git a/pypy/rpython/lltypesystem/test/test_ll2ctypes.py b/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
--- a/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
+++ b/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
@@ -1327,6 +1327,11 @@
round = ctypes2lltype(llmemory.GCREF, lltype2ctypes(opaque.hide()))
assert Opaque.show(round) is opaque
+ def test_array_of_structs(self):
+ A = lltype.GcArray(lltype.Struct('x', ('v', lltype.Signed)))
+ a = lltype.malloc(A, 5)
+ a2 = ctypes2lltype(lltype.Ptr(A), lltype2ctypes(a))
+ assert a2._obj.getitem(0)._obj._parentstructure() is a2._obj
class TestPlatform(object):
def test_lib_on_libpaths(self):
More information about the pypy-commit
mailing list