[pypy-svn] r50247 - pypy/dist/pypy/rpython/lltypesystem

fijal at codespeak.net fijal at codespeak.net
Wed Jan 2 10:15:22 CET 2008


Author: fijal
Date: Wed Jan  2 10:15:20 2008
New Revision: 50247

Modified:
   pypy/dist/pypy/rpython/lltypesystem/rffi.py
Log:
Use llhelper instead of custom _callback. We force here the constantness of
argument though.


Modified: pypy/dist/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rffi.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rffi.py	Wed Jan  2 10:15:20 2008
@@ -12,6 +12,7 @@
 from pypy.rpython.tool.rfficache import platform
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.translator.backendopt.canraise import RaiseAnalyzer
+from pypy.rpython.annlowlevel import llhelper
 import os
 
 class UnhandledRPythonException(Exception):
@@ -104,7 +105,8 @@
                     # and was not the first in this function
                     freeme = arg
             elif isfunctype(TARGET):
-                arg = _callback(arg, TARGET)
+                # XXX pass additional arguments
+                arg = llhelper(TARGET, _make_wrapper_for(arg))
             else:
                 SOURCE = lltype.typeOf(arg)
                 if SOURCE != TARGET:
@@ -137,6 +139,15 @@
 
     return func_with_new_name(wrapper, name)
 
+def _make_wrapper_for(callable, error_code=None):
+    """ Function creating wrappers for callbacks. Note that this is
+    cheating as we assume constant callbacks and we just memoize wrappers
+    """
+    def wrapper(*args):
+        return callable(*args)
+    return wrapper
+_make_wrapper_for._annspecialcase_ = 'specialize:memo'
+
 AroundFnPtr = lltype.Ptr(lltype.FuncType([], lltype.Void))
 class AroundState:
     def _freeze_(self):



More information about the Pypy-commit mailing list