[pypy-svn] r14477 - pypy/dist/pypy/interpreter

pedronis at codespeak.net pedronis at codespeak.net
Sun Jul 10 23:57:46 CEST 2005


Author: pedronis
Date: Sun Jul 10 23:57:43 2005
New Revision: 14477

Modified:
   pypy/dist/pypy/interpreter/baseobjspace.py
   pypy/dist/pypy/interpreter/typedef.py
Log:
reorganize slot support such that slots_w does not get improperly attached to W_Root by annotation.



Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py	Sun Jul 10 23:57:43 2005
@@ -54,6 +54,12 @@
         id = r_uint(id) # XXX what about sizeof(void*) > sizeof(long) !!
         return space.wrap("<%s at 0x%x>" % (info, id))
 
+    def getslotvalue(self, index):
+        raise NotImplementedError
+
+    def setslotvalue(self, index, w_val):
+        raise NotImplementedError
+
 class BaseWrappable(W_Root):
     """A subclass of BaseWrappable is an internal, interpreter-level class
     that can nevertheless be exposed at application-level by space.wrap()."""

Modified: pypy/dist/pypy/interpreter/typedef.py
==============================================================================
--- pypy/dist/pypy/interpreter/typedef.py	(original)
+++ pypy/dist/pypy/interpreter/typedef.py	Sun Jul 10 23:57:43 2005
@@ -89,6 +89,12 @@
         if wants_slots:
             def user_setup_slots(self, nslots):
                 self.slots_w = [None] * nslots 
+
+            def setslotvalue(self, index, w_value):
+                self.slots_w[index] = w_value
+
+            def getslotvalue(self, index):
+                return self.slots_w[index]
         else:
             def user_setup_slots(self, nslots):
                 assert nslots == 0
@@ -273,7 +279,7 @@
         else:
             self = member
             self.typecheck(space, w_obj)
-            w_result = w_obj.slots_w[self.index]
+            w_result = w_obj.getslotvalue(self.index)
             if w_result is None:
                 raise OperationError(space.w_AttributeError,
                                      space.wrap(self.name)) # XXX better message
@@ -284,14 +290,14 @@
         Write into the slot 'member' of the given 'obj'."""
         self = member
         self.typecheck(space, w_obj)
-        w_obj.slots_w[self.index] = w_value
+        w_obj.setslotvalue(self.index, w_value)
 
     def descr_member_del(space, member, w_obj):
         """member.__delete__(obj)
         Delete the value of the slot 'member' from the given 'obj'."""
         self = member
         self.typecheck(space, w_obj)
-        w_obj.slots_w[self.index] = None
+        w_obj.setslotvalue(self.index, None)
 
 Member.typedef = TypeDef(
     "Member",



More information about the Pypy-commit mailing list