[pypy-svn] r60092 - pypy/branch/oo-jit/pypy/rpython/lltypesystem
arigo at codespeak.net
arigo at codespeak.net
Sun Nov 23 19:39:33 CET 2008
Author: arigo
Date: Sun Nov 23 19:39:31 2008
New Revision: 60092
Modified:
pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py
Log:
Yet Another Obscure Hack to support passing around
llmemory.Address coming from ctypes.c_void_p.
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 Sun Nov 23 19:39:31 2008
@@ -602,7 +602,7 @@
if cobj is None:
llobj = llmemory.NULL
else:
- xxx
+ llobj = _lladdress(cobj)
elif T is lltype.Char:
llobj = chr(cobj)
elif T is lltype.UniChar:
@@ -850,6 +850,22 @@
resulttype = v_ptr.concretetype)
# ____________________________________________________________
+
+class _lladdress(long):
+ _TYPE = llmemory.Address
+
+ def __new__(cls, void_p):
+ self = long.__new__(cls, void_p.value)
+ self.void_p = void_p
+ return self
+
+ def __repr__(self):
+ return '<_lladdress %s>' % (self.void_p,)
+
+ def _cast_to_int(self):
+ return ctypes.cast(self.void_p, ctypes.c_long)
+
+# ____________________________________________________________
# errno
# this saves in a thread-local way the "current" value that errno
More information about the Pypy-commit
mailing list