[pypy-svn] r54586 - pypy/branch/gc-tweak/pypy/rpython/lltypesystem
arigo at codespeak.net
arigo at codespeak.net
Fri May 9 13:35:30 CEST 2008
Author: arigo
Date: Fri May 9 13:35:30 2008
New Revision: 54586
Modified:
pypy/branch/gc-tweak/pypy/rpython/lltypesystem/llmemory.py
pypy/branch/gc-tweak/pypy/rpython/lltypesystem/lltype.py
Log:
Implement cast_int_to_adr() for direct running too.
Modified: pypy/branch/gc-tweak/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/branch/gc-tweak/pypy/rpython/lltypesystem/llmemory.py (original)
+++ pypy/branch/gc-tweak/pypy/rpython/lltypesystem/llmemory.py Fri May 9 13:35:30 2008
@@ -582,8 +582,10 @@
def cast_adr_to_int(adr):
return adr._cast_to_int()
+_NONGCREF = lltype.Ptr(lltype.OpaqueType('NONGCREF'))
def cast_int_to_adr(int):
- raise NotImplementedError("cast_int_to_adr")
+ ptr = lltype.cast_int_to_ptr(_NONGCREF, int)
+ return cast_ptr_to_adr(ptr)
# ____________________________________________________________
# Weakrefs.
Modified: pypy/branch/gc-tweak/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/branch/gc-tweak/pypy/rpython/lltypesystem/lltype.py (original)
+++ pypy/branch/gc-tweak/pypy/rpython/lltypesystem/lltype.py Fri May 9 13:35:30 2008
@@ -905,6 +905,8 @@
return p # primitive
if not p:
return None # null pointer
+ if type(p._obj0) is int:
+ return p # a pointer obtained by cast_int_to_ptr
container = p._obj._normalizedcontainer()
if container is not p._obj:
p = _ptr(Ptr(typeOf(container)), container, p._solid)
@@ -985,7 +987,7 @@
_obj = property(_getobj)
def _was_freed(self):
- return (self._obj0 is not None and
+ return (type(self._obj0) not in (type(None), int) and
self._getobj(check=False)._was_freed())
def __getattr__(self, field_name): # ! can only return basic or ptr !
More information about the Pypy-commit
mailing list