[pypy-svn] r10284 - in pypy/dist/pypy: interpreter objspace/std

tismer at codespeak.net tismer at codespeak.net
Mon Apr 4 15:39:15 CEST 2005


Author: tismer
Date: Mon Apr  4 15:39:14 2005
New Revision: 10284

Modified:
   pypy/dist/pypy/interpreter/gateway.py
   pypy/dist/pypy/objspace/std/dictobject.py
   pypy/dist/pypy/objspace/std/sliceobject.py
   pypy/dist/pypy/objspace/std/typeobject.py
Log:
more occurances of appdef replaced by applevel (tested, works fine)

Modified: pypy/dist/pypy/interpreter/gateway.py
==============================================================================
--- pypy/dist/pypy/interpreter/gateway.py	(original)
+++ pypy/dist/pypy/interpreter/gateway.py	Mon Apr  4 15:39:14 2005
@@ -536,10 +536,8 @@
     def _freeze_(self):
         return True  # hint for the annotator: applevel instances are constants
 
-## XXX experimental code using geninterplevel
-
 class applevelinterp(applevel):
-    """ same as applevel, but using translation to interp-level.
+    """ similar to applevel, but using translation to interp-level.
     """
     NOT_RPYTHON_ATTRIBUTES = []
 
@@ -565,9 +563,6 @@
 # comment this out to check against applevel without translation
 ##applevelinterp = applevel
 
-## XXX there is a problem with the naming convention of app_xxx not allowed
-## for interp2app! What shall we do?
-
 def appdef(source, applevel=applevel):
     """ NOT_RPYTHON: build an app-level helper function, like for example:
     myfunc = appdef('''myfunc(x, y):

Modified: pypy/dist/pypy/objspace/std/dictobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictobject.py	(original)
+++ pypy/dist/pypy/objspace/std/dictobject.py	Mon Apr  4 15:39:14 2005
@@ -242,8 +242,8 @@
     else:
         return w_default
 
-dictstr = gateway.appdef('''
-    dictstr(currently_in_repr, d):
+app = gateway.applevelinterp('''
+    def dictstr(currently_in_repr, d):
         # Now we only handle one implementation of dicts, this one.
         # The fix is to move this to dicttype.py, and do a
         # multimethod lookup mapping str to StdObjSpace.str
@@ -264,6 +264,8 @@
                     pass
 ''')
 
+dictstr = app.interphook("dictstr")
+
 def str__Dict(space, w_dict):
     if w_dict.used == 0:
         return space.wrap('{}')

Modified: pypy/dist/pypy/objspace/std/sliceobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/sliceobject.py	(original)
+++ pypy/dist/pypy/objspace/std/sliceobject.py	Mon Apr  4 15:39:14 2005
@@ -24,10 +24,10 @@
 
 registerimplementation(W_SliceObject)
 
-repr__Slice = gateway.appdef("""
-    repr__Slice(aslice):
+repr__Slice = gateway.applevelinterp("""
+    def repr__Slice(aslice):
         return 'slice(%r, %r, %r)' % (aslice.start, aslice.stop, aslice.step)
-""") 
+""").interphook("repr__Slice")
 
 def eq__Slice_Slice(space, w_slice1, w_slice2):
     # We need this because CPython considers that slice1 == slice1

Modified: pypy/dist/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/typeobject.py	Mon Apr  4 15:39:14 2005
@@ -277,8 +277,8 @@
 # ____________________________________________________________
 
 
-abstract_mro = gateway.appdef("""
-    abstract_mro(klass):
+abstract_mro = gateway.applevelinterp("""
+    def abstract_mro(klass):
         # abstract/classic mro
         mro = []
         def fill_mro(klass):
@@ -289,7 +289,7 @@
                 fill_mro(base)
         fill_mro(klass)
         return mro
-""") 
+""").interphook("abstract_mro")
 
 def get_mro(space, klass):
     if isinstance(klass, W_TypeObject):



More information about the pypy-svn mailing list