[pypy-svn] r39877 - pypy/branch/pypy-2.5/pypy/objspace/cpy

xoraxax at codespeak.net xoraxax at codespeak.net
Sun Mar 4 13:53:29 CET 2007


Author: xoraxax
Date: Sun Mar  4 13:53:26 2007
New Revision: 39877

Modified:
   pypy/branch/pypy-2.5/pypy/objspace/cpy/function.py
   pypy/branch/pypy-2.5/pypy/objspace/cpy/objspace.py
Log:
Some basic __index__ support for the CPyObjSpace (well, it is equivalent to calling int() currently).

Modified: pypy/branch/pypy-2.5/pypy/objspace/cpy/function.py
==============================================================================
--- pypy/branch/pypy-2.5/pypy/objspace/cpy/function.py	(original)
+++ pypy/branch/pypy-2.5/pypy/objspace/cpy/function.py	Sun Mar  4 13:53:26 2007
@@ -52,7 +52,9 @@
     def visit__object(self, el):
         convertermap = {int: 'int_w',
                         str: 'str_w',
-                        float: 'float_w'}
+                        float: 'float_w',
+                        "index": 'getindex_w'
+                        }
         argname = self.orig_arg()
         assert not argname.startswith('w_')
         self.inputargs.append(argname)
@@ -62,6 +64,9 @@
                                 argname))
         self.passedargs.append(argname)
 
+    def visit_index(self, el):
+        self.visit__object("index")
+
     def visit_args_w(self, el):
         argname = self.orig_arg()
         assert argname.endswith('_w')

Modified: pypy/branch/pypy-2.5/pypy/objspace/cpy/objspace.py
==============================================================================
--- pypy/branch/pypy-2.5/pypy/objspace/cpy/objspace.py	(original)
+++ pypy/branch/pypy-2.5/pypy/objspace/cpy/objspace.py	Sun Mar  4 13:53:26 2007
@@ -148,6 +148,11 @@
     repr    = staticmethod(PyObject_Repr)
     id      = staticmethod(PyLong_FromVoidPtr_PYOBJ)
 
+    def index(self, w_obj):
+        # XXX we do not support 2.5 yet, so we just do some
+        # hack here to have index working
+        return self.wrap(self.int_w(w_obj))
+
     def bigint_w(self, w_obj):
         if self.is_true(self.isinstance(w_obj, self.w_long)):
             sign = _PyLong_Sign(w_obj)



More information about the Pypy-commit mailing list