[pypy-svn] r73159 - in pypy/branch/cpython-extension/pypy: annotation module/cpyext rlib rpython/lltypesystem

xoraxax at codespeak.net xoraxax at codespeak.net
Tue Mar 30 13:59:24 CEST 2010


Author: xoraxax
Date: Tue Mar 30 13:59:22 2010
New Revision: 73159

Modified:
   pypy/branch/cpython-extension/pypy/annotation/description.py
   pypy/branch/cpython-extension/pypy/module/cpyext/api.py
   pypy/branch/cpython-extension/pypy/rlib/entrypoint.py
   pypy/branch/cpython-extension/pypy/rpython/lltypesystem/rffi.py
Log:
RPythonizing fixes, introduce relax mode that returns a standard graph even if the signature doesnt match.

Modified: pypy/branch/cpython-extension/pypy/annotation/description.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/annotation/description.py	(original)
+++ pypy/branch/cpython-extension/pypy/annotation/description.py	Tue Mar 30 13:59:22 2010
@@ -209,8 +209,9 @@
         if len(self._cache) != 1:
             raise NoStandardGraph(self)
         [graph] = self._cache.values()
+        relax_sig_check = getattr(self.pyobj, "relax_sig_check", False)
         if (graph.signature != self.signature or
-            graph.defaults  != self.defaults):
+            graph.defaults  != self.defaults) and not relax_sig_check:
             raise NoStandardGraph(self)
         return graph
 

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/api.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/api.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/api.py	Tue Mar 30 13:59:22 2010
@@ -102,7 +102,7 @@
     def get_llhelper(self, space):
         llh = getattr(self, '_llhelper', None)
         if llh is None:
-            llh = llhelper(self.functype, make_wrapper(space, self.callable))
+            llh = llhelper(self.functype, self.get_wrapper(space))
             self._llhelper = llh
         return llh
 
@@ -203,8 +203,9 @@
     new_fields = []
     for name in T._names:
         new_fields.append((name, fields[name]))
-    new_fields.append(("custom_padding", lltype.Array(lltype.Char)))
-    hints["padding"] = hints["padding"] + ("custom_padding", )
+    new_fields.append(("c_custom_padding", lltype.Array(lltype.Char,
+        hints={'nolength': True})))
+    hints["padding"] = hints["padding"] + ("c_custom_padding", )
     return lltype.Struct(hints["c_name"], hints=hints, *new_fields)
 
 
@@ -452,6 +453,7 @@
         elif callable.api_func.restype is not lltype.Void:
             retval = rffi.cast(callable.api_func.restype, retval)
         return retval
+    callable._always_inline_ = True
     wrapper.__name__ = "wrapper for %r" % (callable, )
     return wrapper
 
@@ -597,7 +599,7 @@
 
 def setup_library(space):
     for name, func in FUNCTIONS.iteritems():
-        deco = entrypoint("cpyext", func.argtypes, name)
+        deco = entrypoint("cpyext", func.argtypes, name, relax=True)
         deco(func.get_wrapper(space))
 
 @unwrap_spec(ObjSpace, str, str)

Modified: pypy/branch/cpython-extension/pypy/rlib/entrypoint.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/rlib/entrypoint.py	(original)
+++ pypy/branch/cpython-extension/pypy/rlib/entrypoint.py	Tue Mar 30 13:59:22 2010
@@ -1,11 +1,13 @@
 secondary_entrypoints = {}
 
 
-def entrypoint(key, argtypes, c_name=None):
+def entrypoint(key, argtypes, c_name=None, relax=False):
     def deco(func):
         secondary_entrypoints.setdefault(key, []).append((func, argtypes))
         if c_name is not None:
             func.c_name = c_name
+        if relax:
+            func.relax_sig_check = True
         return func
     return deco
 

Modified: pypy/branch/cpython-extension/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/rpython/lltypesystem/rffi.py	(original)
+++ pypy/branch/cpython-extension/pypy/rpython/lltypesystem/rffi.py	Tue Mar 30 13:59:22 2010
@@ -381,6 +381,7 @@
 r_int_real = rarithmetic.build_int("r_int_real", r_int.SIGN, r_int.BITS, True)
 INT_real = lltype.build_number("INT", r_int_real)
 platform.numbertype_to_rclass[INT_real] = r_int_real
+NUMBER_TYPES.append(INT_real)
 
 # ^^^ this creates at least the following names:
 # --------------------------------------------------------------------



More information about the Pypy-commit mailing list