[pypy-svn] r34166 - pypy/branch/transparent-proxy/pypy/objspace/std
fijal at codespeak.net
fijal at codespeak.net
Sat Nov 4 14:33:05 CET 2006
Author: fijal
Date: Sat Nov 4 14:33:03 2006
New Revision: 34166
Added:
pypy/branch/transparent-proxy/pypy/objspace/std/proxyobject.py (contents, props changed)
Removed:
pypy/branch/transparent-proxy/pypy/objspace/std/tlistobject.py
Modified:
pypy/branch/transparent-proxy/pypy/objspace/std/model.py
pypy/branch/transparent-proxy/pypy/objspace/std/transparent.py
Log:
(pedronis, fijal) - Refactoring of names.
Modified: pypy/branch/transparent-proxy/pypy/objspace/std/model.py
==============================================================================
--- pypy/branch/transparent-proxy/pypy/objspace/std/model.py (original)
+++ pypy/branch/transparent-proxy/pypy/objspace/std/model.py Sat Nov 4 14:33:03 2006
@@ -66,7 +66,7 @@
from pypy.objspace.std import stringobject
from pypy.objspace.std import strsliceobject
from pypy.objspace.std import strjoinobject
- from pypy.objspace.std import tlistobject
+ from pypy.objspace.std import proxyobject
from pypy.objspace.std import typeobject
from pypy.objspace.std import sliceobject
from pypy.objspace.std import longobject
@@ -121,8 +121,8 @@
imported_but_not_registered[implcls] = True
# xxx config
- self.typeorder[tlistobject.W_TransparentList] = []
- self.typeorder[tlistobject.W_TransparentDict] = []
+ self.typeorder[proxyobject.W_TransparentList] = []
+ self.typeorder[proxyobject.W_TransparentDict] = []
if config.objspace.std.withstrdict:
del self.typeorder[dictobject.W_DictObject]
Added: pypy/branch/transparent-proxy/pypy/objspace/std/proxyobject.py
==============================================================================
--- (empty file)
+++ pypy/branch/transparent-proxy/pypy/objspace/std/proxyobject.py Sat Nov 4 14:33:03 2006
@@ -0,0 +1,87 @@
+
+""" transparent list implementation
+"""
+
+from pypy.objspace.std.objspace import *
+from pypy.objspace.std.proxy_helpers import register_type
+from pypy.interpreter.error import OperationError
+from pypy.interpreter import baseobjspace
+
+#class W_Transparent(W_Object):
+# def __init__(self, w_controller):
+# self.controller = w_controller
+
+class W_Transparent(W_Object):
+ def __init__(self, space, w_type, w_controller):
+ self.w_type = w_type
+ self.w_controller = w_controller
+ self.space = space
+
+ def getclass(self, space):
+ return self.w_type
+
+ def setclass(self, space, w_subtype):
+ raise OperationError(space.w_TypeError,
+ space.wrap("You cannot override __class__ for transparent proxies"))
+
+ def getdictvalue(self, space, w_attr):
+ try:
+ return space.call_function(self.w_controller, space.wrap('__getattribute__'),
+ w_attr)
+ except OperationError, e:
+ if not e.match(space, space.w_AttributeError):
+ raise
+ return None
+
+ def setdictvalue(self, space, w_attr, w_value):
+ try:
+ space.call_function(self.w_controller, space.wrap('__setattr__'),
+ w_attr, w_value)
+ return True
+ except OperationError, e:
+ if not e.match(space, space.w_AttributeError):
+ raise
+ return False
+
+ def deldictvalue(self, space, w_attr):
+ try:
+ space.call_function(self.w_controller, space.wrap('__delattr__'),
+ w_attr)
+ return True
+ except OperationError, e:
+ if not e.match(space, space.w_AttributeError):
+ raise
+ return False
+
+ def getdict(self):
+ return self.getdictvalue(self.space, self.space.wrap('__dict__'))
+
+ def setdict(self, space, w_dict):
+ if not self.setdictvalue(space, space.wrap('__dict__'), w_dict):
+ baseobjspace.W_Root.setdict(self, space, w_dict)
+
+ from pypy.objspace.std.objecttype import object_typedef as typedef
+
+class W_TransparentFunction(W_Transparent):
+ from pypy.interpreter.function import Function
+ typedef = Function.typedef
+
+ def descr_call_mismatch(self, space, name, reqcls, args):
+ _, args = args.popfirst()
+ args = args.prepend(space.wrap(name))
+ return space.call_args(self.w_controller, args)
+
+class W_TransparentList(W_Transparent):
+ from pypy.objspace.std.listobject import W_ListObject as original
+ from pypy.objspace.std.listtype import list_typedef as typedef
+
+class W_TransparentDict(W_Transparent):
+ from pypy.objspace.std.dictobject import W_DictObject as original
+ from pypy.objspace.std.dicttype import dict_typedef as typedef
+
+registerimplementation(W_TransparentList)
+registerimplementation(W_TransparentDict)
+
+
+register_type(W_TransparentList)
+register_type(W_TransparentDict)
Modified: pypy/branch/transparent-proxy/pypy/objspace/std/transparent.py
==============================================================================
--- pypy/branch/transparent-proxy/pypy/objspace/std/transparent.py (original)
+++ pypy/branch/transparent-proxy/pypy/objspace/std/transparent.py Sat Nov 4 14:33:03 2006
@@ -5,7 +5,7 @@
from pypy.interpreter import gateway
from pypy.interpreter.function import Function
from pypy.interpreter.error import OperationError
-from pypy.objspace.std.tlistobject import W_TransparentList, W_TransparentDict,\
+from pypy.objspace.std.proxyobject import W_TransparentList, W_TransparentDict,\
W_Transparent, W_TransparentFunction
from pypy.objspace.std.typeobject import W_TypeObject
More information about the Pypy-commit
mailing list