[pypy-svn] r61066 - pypy/branch/oo-jit/pypy/rpython/lltypesystem

fijal at codespeak.net fijal at codespeak.net
Sat Jan 17 17:52:48 CET 2009


Author: fijal
Date: Sat Jan 17 17:52:48 2009
New Revision: 61066

Modified:
   pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py
   pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py
Log:
install a hook to cast to ptr, let's see how it'll work


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:52:48 2009
@@ -924,6 +924,9 @@
     def __nonzero__(self):
         return bool(self.intval)
 
+    def _cast_to_ptr(self, PTRTYPE):
+        return force_cast(PTRTYPE, 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/lltype.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py	(original)
+++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py	Sat Jan 17 17:52:48 2009
@@ -798,6 +798,8 @@
                         "%s to %s" % (CURTYPE, PTRTYPE))
     if (isinstance(CURTYPE.TO, OpaqueType)
         and not isinstance(PTRTYPE.TO, OpaqueType)):
+        if hasattr(ptr, '_cast_to_ptr'):
+            return ptr._cast_to_ptr(PTRTYPE)
         if not ptr:
             return nullptr(PTRTYPE.TO)
         try:



More information about the Pypy-commit mailing list