[pypy-svn] r79659 - pypy/branch/reflex-support/pypy/module/cppyy

wlav at codespeak.net wlav at codespeak.net
Tue Nov 30 05:31:02 CET 2010


Author: wlav
Date: Tue Nov 30 05:30:58 2010
New Revision: 79659

Modified:
   pypy/branch/reflex-support/pypy/module/cppyy/executor.py
   pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py
   pypy/branch/reflex-support/pypy/module/cppyy/pythonify.py
Log:
fix segfault when using pythonify

Modified: pypy/branch/reflex-support/pypy/module/cppyy/executor.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/executor.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/executor.py	Tue Nov 30 05:30:58 2010
@@ -10,8 +10,8 @@
     _immutable_ = True
     libffitype = libffi.types.NULL
 
-    def __init__(self, space, cpptype):
-        pass
+    def __init__(self, space, name, cpptype):
+        self.name = name
 
     def execute(self, space, func, cppthis, num_args, args):
         raise NotImplementedError
@@ -93,7 +93,8 @@
 
 class InstancePtrExecutor(FunctionExecutor):
     _immutable_ = True
-    def __init__(self, space, cpptype):
+    def __init__(self, space, name, cpptype):
+        FunctionExecutor.__init__(self, space, name, cpptype)
         self.cpptype = cpptype
 
     def execute(self, space, func, cppthis, num_args, args):
@@ -107,17 +108,18 @@
     from pypy.module.cppyy import interp_cppyy
 
     try:
-        return _executors[name](space, None)
+        return _executors[name](space, "", None)
     except KeyError:
         pass
 
     compound = helper.compound(name)
-    cpptype = interp_cppyy.type_byname(space, helper.clean_type(name))
+    clean_name = helper.clean_type(name)
+    cpptype = interp_cppyy.type_byname(space, clean_name)
     if compound == "*":           
-        return InstancePtrExecutor(space, cpptype)
+        return InstancePtrExecutor(space, cpptype.name, cpptype)
 
     # currently used until proper lazy instantiation available in interp_cppyy
-    return FunctionExecutor(space, None)
+    return FunctionExecutor(space, "", None)
  
  #  raise TypeError("no clue what %s is" % name)
 

Modified: pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py	Tue Nov 30 05:30:58 2010
@@ -201,7 +201,7 @@
 
 class W_CPPOverload(Wrappable):
     _immutable_ = True
-    _immutable_fields_ = ["functions[*]"]
+    _immutable_fields_ = ["func_name", "functions[*]"]
     def __init__(self, space, func_name, functions):
         self.space = space
         self.func_name = func_name
@@ -211,10 +211,7 @@
         return self.space.wrap(isinstance(self.functions[0], CPPFunction))
 
     def get_returntype(self):
-        try:
-            return self.space.wrap(self.functions[0].executor.cpptype.name)
-        except AttributeError:
-            return None
+        return self.space.wrap(self.functions[0].executor.name)
 
     @jit.unroll_safe
     def call(self, cppthis, args_w):

Modified: pypy/branch/reflex-support/pypy/module/cppyy/pythonify.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/pythonify.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/pythonify.py	Tue Nov 30 05:30:58 2010
@@ -20,10 +20,10 @@
     return bound_obj
 
 def make_static_function(cpptype, name, rettype):
-    if rettype is None:
+    if not rettype:                              # return builtin type
         def method(*args):
             return cpptype.invoke(name, *args)
-    else:
+    else:                                        # return instance
         cppclass = get_cppclass(rettype)
         def method(*args):
             return bind_object(cpptype.invoke(name, *args), cppclass)
@@ -31,7 +31,7 @@
     return staticmethod(method)
 
 def make_method(name, rettype):
-    if rettype is None:                          # return builtin type
+    if not rettype:                              # return builtin type
         def method(self, *args):
             return self._cppinstance.invoke(name, *args)
     else:                                        # return instance



More information about the Pypy-commit mailing list