[pypy-svn] r76289 - pypy/branch/interplevel-array/pypy/module/_demo

fijal at codespeak.net fijal at codespeak.net
Mon Jul 19 22:27:00 CEST 2010


Author: fijal
Date: Mon Jul 19 22:26:58 2010
New Revision: 76289

Modified:
   pypy/branch/interplevel-array/pypy/module/_demo/__init__.py
   pypy/branch/interplevel-array/pypy/module/_demo/interp_demo.py
Log:
Fix a couple of things - expose type


Modified: pypy/branch/interplevel-array/pypy/module/_demo/__init__.py
==============================================================================
--- pypy/branch/interplevel-array/pypy/module/_demo/__init__.py	(original)
+++ pypy/branch/interplevel-array/pypy/module/_demo/__init__.py	Mon Jul 19 22:26:58 2010
@@ -9,7 +9,8 @@
     """A demo built-in module based on ctypes."""
 
     interpleveldefs = {
-        'tp' : 'interp_demo.w_type',
+        'tp' : 'interp_demo.W_Zero', # W_One would do as well, gateway
+        # is getting type of an object anyway (which they share)
     }
 
     appleveldefs = {

Modified: pypy/branch/interplevel-array/pypy/module/_demo/interp_demo.py
==============================================================================
--- pypy/branch/interplevel-array/pypy/module/_demo/interp_demo.py	(original)
+++ pypy/branch/interplevel-array/pypy/module/_demo/interp_demo.py	Mon Jul 19 22:26:58 2010
@@ -3,18 +3,19 @@
 from pypy.objspace.std.stdtypedef import SMM, StdTypeDef
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.model import W_Object
+from pypy.interpreter.gateway import interp2app
 
-def w_type(space, arg):
+def w_type(space, w_subtype, arg):
+    # XXX handle subclasses
     if arg == 0:
         return W_Zero()
     else:
         return W_One()
-w_type.unwrap_spec = [ObjSpace, int]
+w_type.unwrap_spec = [ObjSpace, W_Root, int]
 
-#type_repr = SMM('__repr__', 1, 'a docstring')
 tp_pop    = SMM('pop',    2, defaults=(-1,))
 
-type_typedef = StdTypeDef("tp", __new__ = w_type)
+type_typedef = StdTypeDef("tp", __new__ = interp2app(w_type))
 type_typedef.registermethods(globals())
 
 class W_Zero(W_Object):



More information about the Pypy-commit mailing list