[pypy-svn] rev 601 - pypy/trunk/src/pypy/objspace/std

arigo at codespeak.net arigo at codespeak.net
Tue May 27 18:15:51 CEST 2003


Author: arigo
Date: Tue May 27 18:15:50 2003
New Revision: 601

Modified:
   pypy/trunk/src/pypy/objspace/std/boolobject.py
   pypy/trunk/src/pypy/objspace/std/cpythonobject.py
   pypy/trunk/src/pypy/objspace/std/dictobject.py
   pypy/trunk/src/pypy/objspace/std/floatobject.py
   pypy/trunk/src/pypy/objspace/std/funcobject.py
   pypy/trunk/src/pypy/objspace/std/instmethobject.py
   pypy/trunk/src/pypy/objspace/std/intobject.py
   pypy/trunk/src/pypy/objspace/std/iterobject.py
   pypy/trunk/src/pypy/objspace/std/listobject.py
   pypy/trunk/src/pypy/objspace/std/longobject.py
   pypy/trunk/src/pypy/objspace/std/moduleobject.py
   pypy/trunk/src/pypy/objspace/std/noneobject.py
   pypy/trunk/src/pypy/objspace/std/objspace.py
   pypy/trunk/src/pypy/objspace/std/sliceobject.py
   pypy/trunk/src/pypy/objspace/std/stringobject.py
   pypy/trunk/src/pypy/objspace/std/tupleobject.py
Log:
BROKEN, we are changing a hell lot of things

Modified: pypy/trunk/src/pypy/objspace/std/boolobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/boolobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/boolobject.py	Tue May 27 18:15:50 2003
@@ -1,10 +1,11 @@
 from pypy.objspace.std.objspace import *
 
 
-class W_BoolObject:
+class W_BoolObject(W_Object):
     delegate_once = {}
 
-    def __init__(w_self, boolval):  # please pass in a real bool, not an int
+    def __init__(w_self, space, boolval):# please pass in a real bool, not an int
+        W_Object.__init__(w_self, space)
         w_self.boolval = boolval
 
     def __eq__(w_self, w_other):

Modified: pypy/trunk/src/pypy/objspace/std/cpythonobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/cpythonobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/cpythonobject.py	Tue May 27 18:15:50 2003
@@ -2,12 +2,13 @@
 from stringobject import W_StringObject
 import sys, operator, types
 
-class W_CPythonObject:
+class W_CPythonObject(W_Object):
     "This class wraps an arbitrary CPython object."
 
     delegate_once = {}
     
-    def __init__(w_self, cpyobj):
+    def __init__(w_self, space, cpyobj):
+        W_Object.__init__(w_self, space)
         w_self.cpyobj = cpyobj
 
     def __repr__(w_self):

Modified: pypy/trunk/src/pypy/objspace/std/dictobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/dictobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/dictobject.py	Tue May 27 18:15:50 2003
@@ -25,11 +25,12 @@
         return self.w_value is _NoValueInCell
     
 
-class W_DictObject:
+class W_DictObject(W_Object):
     delegate_once = {}
 
-    def __init__(self, list_pairs_w):
-        self.data = [ (w_key,Cell(w_value)) for w_key,w_value in list_pairs_w ]
+    def __init__(w_self, space, list_pairs_w):
+        W_Object.__init__(w_self, space)
+        w_self.data = [ (w_key,Cell(w_value)) for w_key,w_value in list_pairs_w ]
 
     def non_empties(self):
         return [ (w_key,cell) for w_key,cell in self.data if not cell.is_empty()]

Modified: pypy/trunk/src/pypy/objspace/std/floatobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/floatobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/floatobject.py	Tue May 27 18:15:50 2003
@@ -10,12 +10,13 @@
 
 applicationfile = StdObjSpace.AppFile(__name__)
 
-class W_FloatObject:
+class W_FloatObject(W_Object):
     """This is a reimplementation of the CPython "PyFloatObject" 
        it is assumed that the constructor takes a real Python float as
        an argument""" 
     
-    def __init__(w_self, floatval):
+    def __init__(w_self, space, floatval):
+        W_Object.__init__(w_self, space)
         w_self.floatval = floatval
 
 def float_float(space,w_value):

Modified: pypy/trunk/src/pypy/objspace/std/funcobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/funcobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/funcobject.py	Tue May 27 18:15:50 2003
@@ -3,8 +3,9 @@
 import pypy.interpreter.pyframe
 
 
-class W_FuncObject(object):
-    def __init__(w_self, code, w_globals, w_defaultarguments, w_closure):
+class W_FuncObject(W_Object):
+    def __init__(w_self, space, code, w_globals, w_defaultarguments, w_closure):
+        W_Object.__init__(w_self, space)
         w_self.code = code
         w_self.w_globals = w_globals
         w_self.w_defaultarguments = w_defaultarguments

Modified: pypy/trunk/src/pypy/objspace/std/instmethobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/instmethobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/instmethobject.py	Tue May 27 18:15:50 2003
@@ -2,8 +2,9 @@
 from pypy.objspace.std.objspace import *
 
 
-class W_InstMethObject(object):
-    def __init__(w_self, w_im_self,w_im_func):
+class W_InstMethObject(W_Object):
+    def __init__(w_self, space, w_im_self, w_im_func):
+        W_Object.__init__(w_self, space)
         w_self.w_im_self = w_im_self
         w_self.w_im_func = w_im_func
 
@@ -22,9 +23,9 @@
 
 
 def instmeth_call(space, w_instmeth, w_arguments, w_keywords):
-    w_args = space.add(space.newtuple([self.w_im_self]),
+    w_args = space.add(space.newtuple([w_instmeth.w_im_self]),
                        w_arguments)
-    w_ret = space.call(self.w_im_func, w_args, w_keywords)
+    w_ret = space.call(w_instmeth.w_im_func, w_args, w_keywords)
     return w_ret
 
 StdObjSpace.call.register(instmeth_call, W_InstMethObject, W_ANY, W_ANY)

Modified: pypy/trunk/src/pypy/objspace/std/intobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/intobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/intobject.py	Tue May 27 18:15:50 2003
@@ -20,11 +20,12 @@
 RPython, just for test purposes.
 """
 
-class W_IntObject:
+class W_IntObject(W_Object):
 
     delegate_once = {}
     
-    def __init__(w_self, intval):
+    def __init__(w_self, space, intval):
+        W_Object.__init__(w_self, space)
         w_self.intval = r_int(intval)
 
     def __repr__(w_self):

Modified: pypy/trunk/src/pypy/objspace/std/iterobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/iterobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/iterobject.py	Tue May 27 18:15:50 2003
@@ -1,12 +1,13 @@
 from objspace import *
 
 
-class W_SeqIterObject:
+class W_SeqIterObject(W_Object):
     delegate_once = {}
 
-    def __init__(self, w_seq, index=0):
-        self.w_seq = w_seq
-        self.index = index
+    def __init__(w_self, space, w_seq, index=0):
+        W_Object.__init__(w_self, space)
+        w_self.w_seq = w_seq
+        w_self.index = index
 
 
 def iter_seqiter(space, w_seqiter):

Modified: pypy/trunk/src/pypy/objspace/std/listobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/listobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/listobject.py	Tue May 27 18:15:50 2003
@@ -2,20 +2,23 @@
 from intobject import W_IntObject
 from sliceobject import W_SliceObject
 from instmethobject import W_InstMethObject
+from pypy.interpreter.extmodule import make_builtin_func
 
 
-class W_ListObject(object):
+class W_ListObject(W_Object):
 
-    def __init__(self, wrappeditems):
-        self.wrappeditems = wrappeditems   # a list of wrapped values
+    def __init__(w_self, space, wrappeditems):
+        W_Object.__init__(w_self, space)
+        w_self.wrappeditems = wrappeditems   # a list of wrapped values
 
     def __repr__(w_self):
         """ representation for debugging purposes """
         reprlist = [repr(w_item) for w_item in w_self.wrappeditems]
         return "%s(%s)" % (w_self.__class__.__name__, ', '.join(reprlist))
 
-###    def append(w_self):
-###        .:.
+    def append(w_self, w_obj):
+        w_self.wrappeditems.append(w_obj)
+        return w_self.space
 
 
 def list_unwrap(space, w_list):
@@ -97,6 +100,15 @@
 # upto here, lists are nearly identical to tuples.
 # XXX have to add over-allocation!
 
+def getattr_list(space, w_list, w_attr):
+    if space.is_true(space.eq(w_attr, space.wrap('append'))):
+        w_builtinfn = make_builtin_func(space, W_ListObject.append)
+        return W_InstMethObject(w_list, w_builtinfn)
+    raise FailedToImplement(space.w_AttributeError)
+
+StdObjSpace.getattr.register(getattr_list, W_ListObject, W_ANY)
+
+
 """
 static PyMethodDef list_methods[] = {
 	{"append",	(PyCFunction)listappend,  METH_O, append_doc},

Modified: pypy/trunk/src/pypy/objspace/std/longobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/longobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/longobject.py	Tue May 27 18:15:50 2003
@@ -1,10 +1,11 @@
-from objspace import *
+from pypy.objspace.std.objspace import *
 
 
 
-class W_LongObject:
+class W_LongObject(W_Object):
     
-    def __init__(w_self, longval):
+    def __init__(w_self, space, longval):
+        W_Object.__init__(w_self, space)
         w_self.longval = longval
 
     def getattr(w_self, space, w_attrname):

Modified: pypy/trunk/src/pypy/objspace/std/moduleobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/moduleobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/moduleobject.py	Tue May 27 18:15:50 2003
@@ -1,11 +1,12 @@
-from objspace import *
+from pypy.objspace.std.objspace import *
 from dictobject import W_DictObject
 
 
-class W_ModuleObject:
+class W_ModuleObject(W_Object):
     delegate_once = {}
 
-    def __init__(self, space, w_name):
+    def __init__(w_self, space, w_name):
+        W_Object.__init__(w_self, space)
         w_key_name = space.wrap('__name__')
         w_key_doc  = space.wrap('__doc__')
         items = [(w_key_name, w_name),

Modified: pypy/trunk/src/pypy/objspace/std/noneobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/noneobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/noneobject.py	Tue May 27 18:15:50 2003
@@ -1,7 +1,7 @@
 from pypy.objspace.std.objspace import *
 
 
-class W_NoneObject:
+class W_NoneObject(W_Object):
     delegate_once = {}
 
 

Modified: pypy/trunk/src/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/objspace.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/objspace.py	Tue May 27 18:15:50 2003
@@ -8,6 +8,12 @@
     booltype = bool
 
 
+class W_Object:
+    "Parent base class for wrapped objects."
+    def __init__(w_self, space):
+        w_self.space = space
+
+
 ##################################################################
 
 class StdObjSpace(ObjSpace):

Modified: pypy/trunk/src/pypy/objspace/std/sliceobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/sliceobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/sliceobject.py	Tue May 27 18:15:50 2003
@@ -5,8 +5,9 @@
 appfile = AppFile(__name__, ["objspace.std"])
 
 
-class W_SliceObject:
-    def __init__(w_self, w_start, w_stop, w_step):
+class W_SliceObject(W_Object):
+    def __init__(w_self, space, w_start, w_stop, w_step):
+        W_Object.__init__(w_self, space)
         w_self.w_start = w_start
         w_self.w_stop = w_stop
         w_self.w_step = w_step

Modified: pypy/trunk/src/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/stringobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/stringobject.py	Tue May 27 18:15:50 2003
@@ -1,11 +1,12 @@
-from objspace import *
+from pypy.objspace.std.objspace import *
 from intobject   import W_IntObject
 from sliceobject import W_SliceObject
 
 applicationfile = StdObjSpace.AppFile(__name__)
 
-class W_StringObject:
-    def __init__(w_self, str):
+class W_StringObject(W_Object):
+    def __init__(w_self, space, str):
+        W_Object.__init__(w_self, space)
         w_self.value = str
     def __repr__(w_self):
         """ representation for debugging purposes """

Modified: pypy/trunk/src/pypy/objspace/std/tupleobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/tupleobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/tupleobject.py	Tue May 27 18:15:50 2003
@@ -3,10 +3,11 @@
 from sliceobject import W_SliceObject
 
 
-class W_TupleObject(object):
+class W_TupleObject(W_Object):
 
-    def __init__(self, wrappeditems):
-        self.wrappeditems = wrappeditems   # a list of wrapped values
+    def __init__(w_self, space, wrappeditems):
+        W_Object.__init__(w_self, space)
+        w_self.wrappeditems = wrappeditems   # a list of wrapped values
 
     def __repr__(w_self):
         """ representation for debugging purposes """


More information about the Pypy-commit mailing list