[pypy-svn] r36074 - in pypy/dist/pypy/rlib/rctypes: . test
arigo at codespeak.net
arigo at codespeak.net
Sun Dec 31 14:46:11 CET 2006
Author: arigo
Date: Sun Dec 31 14:45:54 2006
New Revision: 36074
Modified:
pypy/dist/pypy/rlib/rctypes/rctypesobject.py
pypy/dist/pypy/rlib/rctypes/test/test_rctypesobject.py
Log:
Rename the pointers' get_contents_at_index() to ref() to be the same
method name as arrays.
Modified: pypy/dist/pypy/rlib/rctypes/rctypesobject.py
==============================================================================
--- pypy/dist/pypy/rlib/rctypes/rctypesobject.py (original)
+++ pypy/dist/pypy/rlib/rctypes/rctypesobject.py Sun Dec 31 14:45:54 2006
@@ -249,10 +249,11 @@
targetmemblock = self._getmemblock(0, targetkeepalives)
return contentscls(targetaddr, targetmemblock)
- def get_contents_at_index(self, index):
+ def ref(self, index):
ptr = self.ll_ref(RCTypesPtr.CDATATYPE)
targetaddr = llmemory.cast_ptr_to_adr(ptr[0])
- targetaddr += ofs_item * index
+ if index:
+ targetaddr += ofs_item * index
keepalive_until_here(self)
targetkeepalives = contentscls.num_keepalives
targetmemblock = self._getmemblock(0, targetkeepalives)
Modified: pypy/dist/pypy/rlib/rctypes/test/test_rctypesobject.py
==============================================================================
--- pypy/dist/pypy/rlib/rctypes/test/test_rctypesobject.py (original)
+++ pypy/dist/pypy/rlib/rctypes/test/test_rctypesobject.py Sun Dec 31 14:45:54 2006
@@ -221,7 +221,7 @@
a.ref(i).set_value(100 + 5 * i)
p = pointer(a.ref(0))
del a
- return p.get_contents_at_index(7).get_value()
+ return p.ref(7).get_value()
res = self.do(func)
assert res == 135
@@ -235,7 +235,7 @@
a.ref(i).ref_y().set_value(200 + 2 * i)
p = pointer(a.ref(0))
del a
- s1 = p.get_contents_at_index(3)
+ s1 = p.ref(3)
return s1.ref_x().get_value() + s1.ref_y().get_value()
res = self.do(func)
assert res == 115 + 206
More information about the Pypy-commit
mailing list