[pypy-commit] pypy reflex-support: lazy setup of function returns to prevent hitting the recursion limits when class return types are created

wlav noreply at buildbot.pypy.org
Fri Mar 9 02:42:57 CET 2012


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r53276:d905100df05f
Date: 2012-03-08 10:50 -0800
http://bitbucket.org/pypy/pypy/changeset/d905100df05f/

Log:	lazy setup of function returns to prevent hitting the recursion
	limits when class return types are created

diff --git a/pypy/module/cppyy/pythonify.py b/pypy/module/cppyy/pythonify.py
--- a/pypy/module/cppyy/pythonify.py
+++ b/pypy/module/cppyy/pythonify.py
@@ -46,22 +46,22 @@
 def make_static_function(cpptype, func_name, cppol):
     rettype = cppol.get_returntype()
     if not rettype:                              # return builtin type
-        cppclass = None
+        def function(*args):
+            return cppol.call(None, None, *args)
     else:                                        # return instance
-        cppclass = get_cppclass(rettype)
-    def function(*args):
-        return cppol.call(None, cppclass, *args)
+        def function(*args):
+            return cppol.call(None, get_cppclass(rettype), *args)
     function.__name__ = func_name
     return staticmethod(function)
 
 def make_method(meth_name, cppol):
     rettype = cppol.get_returntype()
     if not rettype:                              # return builtin type
-        cppclass = None
+        def method(self, *args):
+            return cppol.call(self, None, *args)
     else:                                        # return instance
-        cppclass = get_cppclass(rettype)
-    def method(self, *args):
-        return cppol.call(self, cppclass, *args)
+        def method(self, *args):
+            return cppol.call(self, get_cppclass(rettype), *args)
     method.__name__ = meth_name
     return method
 


More information about the pypy-commit mailing list