[pypy-svn] r36147 - pypy/dist/pypy/rlib/rctypes
arigo at codespeak.net
arigo at codespeak.net
Thu Jan 4 14:29:00 CET 2007
Author: arigo
Date: Thu Jan 4 14:28:58 2007
New Revision: 36147
Modified:
pypy/dist/pypy/rlib/rctypes/implementation.py
pypy/dist/pypy/rlib/rctypes/rctypesobject.py
pypy/dist/pypy/rlib/rctypes/rpointer.py
Log:
Fixes to the forward pointer code.
Modified: pypy/dist/pypy/rlib/rctypes/implementation.py
==============================================================================
--- pypy/dist/pypy/rlib/rctypes/implementation.py (original)
+++ pypy/dist/pypy/rlib/rctypes/implementation.py Thu Jan 4 14:28:58 2007
@@ -132,12 +132,14 @@
else:
# non-recursive case
TLS.pending = []
- controller = cls(ctype)
- pending = TLS.pending
- del TLS.pending
- pending.append(controller)
- for c1 in pending:
- c1.setup()
+ try:
+ controller = cls(ctype)
+ TLS.pending.append(controller)
+ finally:
+ pending = TLS.pending
+ del TLS.pending
+ for c1 in pending:
+ c1.setup()
return controller
def getcontroller(ctype):
Modified: pypy/dist/pypy/rlib/rctypes/rctypesobject.py
==============================================================================
--- pypy/dist/pypy/rlib/rctypes/rctypesobject.py (original)
+++ pypy/dist/pypy/rlib/rctypes/rctypesobject.py Thu Jan 4 14:28:58 2007
@@ -294,7 +294,7 @@
return RCTypesPtr
RPointer._annspecialcase_ = 'specialize:memo'
-def _rpointer_set_pointer_type(RCTypesPtr, contentscls):
+def _rpointer_set_pointer_type(RCTypesPtr, contentscls, force=False):
assert issubclass(contentscls, RCTypesObject)
if contentscls in _abstract_classes:
raise Exception("cannot call RPointer(%s) or "
@@ -306,9 +306,10 @@
RCTypesPtr.LLTYPE.TO.become(RCTypesPtr.CONTENTS)
RCTypesPtr._OFS_ITEM = llmemory.sizeof(contentscls.LLTYPE)
RCTypesPtr.__name__ = 'RCTypes_%s' % (RCTypesPtr.LLTYPE,)
- assert not hasattr(contentscls, '_ptrcls'), (
- "the RPointer class corresponding to %r exists already" %
- (contentscls,))
+ if not force:
+ assert not hasattr(contentscls, '_ptrcls'), (
+ "the RPointer class corresponding to %r exists already" %
+ (contentscls,))
contentscls._ptrcls = RCTypesPtr
def pointer(x):
Modified: pypy/dist/pypy/rlib/rctypes/rpointer.py
==============================================================================
--- pypy/dist/pypy/rlib/rctypes/rpointer.py (original)
+++ pypy/dist/pypy/rlib/rctypes/rpointer.py Thu Jan 4 14:28:58 2007
@@ -10,15 +10,19 @@
class PointerCTypeController(CTypeController):
+ ready = 0
def __init__(self, ctype):
CTypeController.__init__(self, ctype)
self.knowntype = rctypesobject.RPointer(None)
def setup(self):
- if not hasattr(self, 'contentscontroller'):
+ if self.ready == 0:
+ self.ready = 1
self.contentscontroller = getcontroller(self.ctype._type_)
- self.knowntype.setpointertype(self.contentscontroller.knowntype)
+ self.knowntype.setpointertype(self.contentscontroller.knowntype,
+ force=True)
+ self.ready = 2
def new(self, ptrto=None):
obj = self.knowntype.allocate()
More information about the Pypy-commit
mailing list