[pypy-svn] r61064 - in pypy/branch/oo-jit/pypy/rpython/lltypesystem: . test
fijal at codespeak.net
fijal at codespeak.net
Sat Jan 17 17:44:14 CET 2009
Author: fijal
Date: Sat Jan 17 17:44:14 2009
New Revision: 61064
Modified:
pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
Log:
Move hack from codegen386 here
Besides I suppose that this test is not suppose to pass anyway
Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Sat Jan 17 17:44:14 2009
@@ -481,8 +481,12 @@
if T is base_ptr_lltype():
return new_opaque_object(llobj)
if T == llmemory.GCREF:
+ if isinstance(llobj, _llgcref):
+ return ctypes.c_void_p(llobj.intval)
container = llobj._obj.container
T = lltype.Ptr(lltype.typeOf(container))
+ # otherwise it came from integer and we want a c_void_p with
+ # the same valu
else:
container = llobj._obj
if isinstance(T.TO, lltype.FuncType):
@@ -631,7 +635,11 @@
return lltype.functionptr(T.TO, getattr(cobj, '__name__', '?'),
_callable=_callable)
elif isinstance(T.TO, lltype.OpaqueType):
- container = lltype._opaque(T.TO)
+ if T == llmemory.GCREF:
+ # XXX obscure hack
+ return _llgcref(cobj)
+ else:
+ container = lltype._opaque(T.TO)
else:
raise NotImplementedError(T)
llobj = lltype._ptr(T, container, solid=True)
@@ -899,6 +907,23 @@
def _cast_to_int(self):
return ctypes.cast(self.void_p, ctypes.c_long)
+class _llgcref(object):
+ _TYPE = llmemory.GCREF
+
+ def __init__(self, void_p):
+ self.intval = void_p.value
+
+ def __eq__(self, other):
+ if isinstance(other, _llgcref):
+ return self.intval == other.intval
+ return force_cast(lltype.Signed, other) == self.intval
+
+ def __ne__(self, other):
+ return not self == other
+
+ def __nonzero__(self):
+ return bool(self.intval)
+
def cast_adr_to_int(addr):
if isinstance(addr, llmemory.fakeaddress):
# use ll2ctypes to obtain a real ctypes-based representation of
Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original)
+++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Sat Jan 17 17:44:14 2009
@@ -933,11 +933,6 @@
back = rffi.cast(llmemory.GCREF, rffi.cast(lltype.Signed, ref))
assert lltype.cast_opaque_ptr(lltype.Ptr(NODE), ref) == node
- def test_runtimetypeinfo_change(self):
- p = lltype.opaqueptr(lltype.RuntimeTypeInfo, 'foo')
- hash1 = hash(p._obj)
- print repr(p)
- lltype2ctypes(p)
- print repr(p)
- hash2 = hash(p._obj)
- assert hash1 == hash2
+ def test_gcref_forth_and_back(self):
+ cp = ctypes.c_void_p(1234)
+ assert lltype2ctypes(ctypes2lltype(llmemory.GCREF, cp)).value == cp.value
More information about the Pypy-commit
mailing list