wlav avatar wlav committed c907272

factor out the need of passing wrapped types into function calls (note that this also means that test_cppyy.py can no longer use the generic CPPInstance as return type, but will automatically work with the actual type as appropriate; same goes for test_zjit.py)

Comments (0)

Files changed (9)

pypy/module/cppyy/capi/__init__.py

     compilation_info=backend.eci)
 def c_final_name(cpptype):
     return charp2str_free(_c_final_name(cpptype))
+_c_scoped_final_name = rffi.llexternal(
+    "cppyy_scoped_final_name",
+    [C_TYPE], rffi.CCHARP,
+    compilation_info=backend.eci)
+def c_scoped_final_name(cpptype):
+    return charp2str_free(_c_scoped_final_name(cpptype))
 c_has_complex_hierarchy = rffi.llexternal(
     "cppyy_has_complex_hierarchy",
     [C_TYPE], rffi.INT,

pypy/module/cppyy/executor.py

     def __init__(self, space, name, cpptype):
         self.name = name
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         raise TypeError('return type not available or supported ("%s")' % self.name)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         from pypy.module.cppyy.interp_cppyy import FastCallNotPossible
         raise FastCallNotPossible
 
     _immutable_ = True
     typecode = 'P'
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         if hasattr(space, "fake"):
             raise NotImplementedError
         lresult = capi.c_call_l(cppmethod, cppthis, num_args, args)
     _immutable_ = True
     libffitype = libffi.types.void
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         capi.c_call_v(cppmethod, cppthis, num_args, args)
         return space.w_None
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         libffifunc.call(argchain, lltype.Void)
         return space.w_None
 
     _immutable_ = True
     libffitype = libffi.types.schar
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         result = capi.c_call_b(cppmethod, cppthis, num_args, args)
         return space.wrap(result)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.CHAR)
         return space.wrap(bool(ord(result)))
 
     _immutable_ = True
     libffitype = libffi.types.schar
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         result = capi.c_call_c(cppmethod, cppthis, num_args, args)
         return space.wrap(result)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.CHAR)
         return space.wrap(result)
 
     _immutable_ = True
     libffitype = libffi.types.sshort
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         result = capi.c_call_h(cppmethod, cppthis, num_args, args)
         return space.wrap(result)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.SHORT)
         return space.wrap(result)
 
     def _wrap_result(self, space, result):
         return space.wrap(result)
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         result = capi.c_call_i(cppmethod, cppthis, num_args, args)
         return self._wrap_result(space, result)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.INT)
         return space.wrap(result)
 
     def _wrap_result(self, space, result):
         return space.wrap(rffi.cast(rffi.UINT, result))
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         result = capi.c_call_l(cppmethod, cppthis, num_args, args)
         return self._wrap_result(space, result)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.UINT)
         return space.wrap(result)
 
     def _wrap_result(self, space, result):
         return space.wrap(result)
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         result = capi.c_call_l(cppmethod, cppthis, num_args, args)
         return self._wrap_result(space, result)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.LONG)
         return space.wrap(result)
 
     def _wrap_result(self, space, result):
         return space.wrap(rffi.cast(rffi.ULONG, result))
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.ULONG)
         return space.wrap(result)
 
         intptr = rffi.cast(rffi.INTP, result)
         return space.wrap(intptr[0])
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         result = capi.c_call_r(cppmethod, cppthis, num_args, args)
         return self._wrap_result(space, result)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.INTP)
         return space.wrap(result[0])
 
         longptr = rffi.cast(rffi.LONGP, result)
         return space.wrap(longptr[0])
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.LONGP)
         return space.wrap(result[0])
 
     _immutable_ = True
     libffitype = libffi.types.float
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         result = capi.c_call_f(cppmethod, cppthis, num_args, args)
         return space.wrap(float(result))
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.FLOAT)
         return space.wrap(float(result))
 
     _immutable_ = True
     libffitype = libffi.types.double
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         result = capi.c_call_d(cppmethod, cppthis, num_args, args)
         return space.wrap(result)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         result = libffifunc.call(argchain, rffi.DOUBLE)
         return space.wrap(result)
 
 class CStringExecutor(FunctionExecutor):
     _immutable_ = True
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         lresult = capi.c_call_l(cppmethod, cppthis, num_args, args)
         ccpresult = rffi.cast(rffi.CCHARP, lresult)
         result = rffi.charp2str(ccpresult)  # TODO: make it a choice to free
         FunctionExecutor.__init__(self, space, name, cpptype)
         self.cpptype = cpptype
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         from pypy.module.cppyy import interp_cppyy
         long_result = capi.c_call_l(cppmethod, cppthis, num_args, args)
         ptr_result = rffi.cast(capi.C_OBJECT, long_result)
-        return interp_cppyy.wrap_cppobject(space, w_returntype, self.cpptype, ptr_result, False, False)
+        return interp_cppyy.wrap_cppobject(space, None, self.cpptype, ptr_result, False, False)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         from pypy.module.cppyy import interp_cppyy
         ptr_result = rffi.cast(capi.C_OBJECT, libffifunc.call(argchain, rffi.VOIDP))
-        return interp_cppyy.wrap_cppobject(space, w_returntype, self.cpptype, ptr_result, False, False)
+        return interp_cppyy.wrap_cppobject(space, None, self.cpptype, ptr_result, False, False)
 
 class InstancePtrPtrExecutor(InstancePtrExecutor):
     _immutable_ = True
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         from pypy.module.cppyy import interp_cppyy
         voidp_result = capi.c_call_r(cppmethod, cppthis, num_args, args)
         ref_address = rffi.cast(rffi.VOIDPP, voidp_result)
         ptr_result = rffi.cast(capi.C_OBJECT, ref_address[0])
-        return interp_cppyy.wrap_cppobject(space, w_returntype, self.cpptype, ptr_result, False, False)
+        return interp_cppyy.wrap_cppobject(space, None, self.cpptype, ptr_result, False, False)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         from pypy.module.cppyy.interp_cppyy import FastCallNotPossible
         raise FastCallNotPossible
 
 class InstanceExecutor(InstancePtrExecutor):
     _immutable_ = True
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         from pypy.module.cppyy import interp_cppyy
         long_result = capi.c_call_o(cppmethod, cppthis, num_args, args, self.cpptype.handle)
         ptr_result = rffi.cast(capi.C_OBJECT, long_result)
-        return interp_cppyy.wrap_cppobject(space, w_returntype, self.cpptype, ptr_result, False, True)
+        return interp_cppyy.wrap_cppobject(space, None, self.cpptype, ptr_result, False, True)
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         from pypy.module.cppyy.interp_cppyy import FastCallNotPossible
         raise FastCallNotPossible
 
 class StdStringExecutor(InstancePtrExecutor):
     _immutable_ = True
 
-    def execute(self, space, w_returntype, cppmethod, cppthis, num_args, args):
+    def execute(self, space, cppmethod, cppthis, num_args, args):
         charp_result = capi.c_call_s(cppmethod, cppthis, num_args, args)
         return space.wrap(capi.charp2str_free(charp_result))
 
-    def execute_libffi(self, space, w_returntype, libffifunc, argchain):
+    def execute_libffi(self, space, libffifunc, argchain):
         from pypy.module.cppyy.interp_cppyy import FastCallNotPossible
         raise FastCallNotPossible
 

pypy/module/cppyy/include/capi.h

 
     /* class reflection information ------------------------------------------- */
     char* cppyy_final_name(cppyy_type_t type);
+    char* cppyy_scoped_final_name(cppyy_type_t type);
     int cppyy_has_complex_hierarchy(cppyy_type_t type);
     int cppyy_num_bases(cppyy_type_t type);
     char* cppyy_base_name(cppyy_type_t type, int base_index);

pypy/module/cppyy/interp_cppyy.py

         self._libffifunc = None
 
     @jit.unroll_safe
-    def call(self, cppthis, w_type, args_w):
+    def call(self, cppthis, args_w):
         jit.promote(self)
-        jit.promote(w_type)
         assert lltype.typeOf(cppthis) == capi.C_OBJECT
         args_expected = len(self.arg_defs)
         args_given = len(args_w)
 
         if self._libffifunc:
             try:
-                return self.do_fast_call(cppthis, w_type, args_w)
+                return self.do_fast_call(cppthis, args_w)
             except FastCallNotPossible:
                 pass          # can happen if converters or executor does not implement ffi
 
         args = self.prepare_arguments(args_w)
         try:
-            return self.executor.execute(self.space, w_type, self.cppmethod, cppthis, len(args_w), args)
+            return self.executor.execute(self.space, self.cppmethod, cppthis, len(args_w), args)
         finally:
             self.free_arguments(args, len(args_w))
 
     @jit.unroll_safe
-    def do_fast_call(self, cppthis, w_type, args_w):
+    def do_fast_call(self, cppthis, args_w):
         jit.promote(self)
         argchain = libffi.ArgChain()
         argchain.arg(cppthis)
         for j in range(i+1, len(self.arg_defs)):
             conv = self.arg_converters[j]
             conv.default_argument_libffi(self.space, argchain)
-        return self.executor.execute_libffi(self.space, w_type, self._libffifunc, argchain)
+        return self.executor.execute_libffi(self.space, self._libffifunc, argchain)
 
     def _setup(self, cppthis):
         self.arg_converters = [converter.get_converter(self.space, arg_type, arg_dflt)
 class CPPConstructor(CPPMethod):
     _immutable_ = True
 
-    def call(self, cppthis, w_type, args_w):
+    def call(self, cppthis, args_w):
         newthis = capi.c_allocate(self.cpptype.handle)
         assert lltype.typeOf(newthis) == capi.C_OBJECT
         try:
-            CPPMethod.call(self, newthis, None, args_w)
+            CPPMethod.call(self, newthis, args_w)
         except Exception:
             capi.c_deallocate(self.cpptype.handle, newthis)
             raise
-        return wrap_new_cppobject_nocast(self.space, w_type, self.cpptype, newthis, False, True)
+        return wrap_new_cppobject_nocast(self.space, None, self.cpptype, newthis, False, True)
 
 
 class W_CPPOverload(Wrappable):
         return self.space.wrap(self.functions[0].executor.name)
 
     @jit.unroll_safe
-    def call(self, w_cppinstance, w_type, args_w):
+    def call(self, w_cppinstance, args_w):
         cppinstance = self.space.interp_w(W_CPPInstance, w_cppinstance, can_be_None=True)
         if cppinstance is not None:
             cppinstance._nullcheck()
         for i in range(len(self.functions)):
             cppyyfunc = self.functions[i]
             try:
-                return cppyyfunc.call(cppthis, w_type, args_w)
+                return cppyyfunc.call(cppthis, args_w)
             except Exception, e:
                 errmsg += '\n\t'+str(e)
 
     'CPPOverload',
     is_static = interp2app(W_CPPOverload.is_static, unwrap_spec=['self']),
     get_returntype = interp2app(W_CPPOverload.get_returntype, unwrap_spec=['self']),
-    call = interp2app(W_CPPOverload.call, unwrap_spec=['self', W_Root, W_Root, 'args_w']),
+    call = interp2app(W_CPPOverload.call, unwrap_spec=['self', W_Root, 'args_w']),
 )
 
 
             self.space.wrap("%s '%s' has no attribute %s" % (self.kind, self.name, name)))
 
 
-
 # For now, keep namespaces and classes separate as namespaces are extensible
 # with info from multiple dictionaries and do not need to bother with meta
 # classes for inheritance. Both are python classes, though, and refactoring
 memory_regulator = MemoryRegulator()
 
 
+def get_wrapped_type(space, handle):
+    state = space.fromcache(State)
+    try:
+        w_type = state.type_registry[handle]
+    except KeyError:
+        final_name = capi.c_scoped_final_name(handle)
+        w_type = space.call_function(state.w_clgen_callback, space.wrap(final_name))
+    return w_type
+
 def wrap_new_cppobject_nocast(space, w_type, cpptype, rawobject, isref, python_owns):
+    if w_type is None:
+        w_type = get_wrapped_type(space, cpptype.handle)
     w_cppinstance = space.allocate_instance(W_CPPInstance, w_type)
     cppinstance = space.interp_w(W_CPPInstance, w_cppinstance, can_be_None=False)
     W_CPPInstance.__init__(cppinstance, space, cpptype, rawobject, isref, python_owns)
         if actual != cpptype.handle:
             offset = capi.c_base_offset(actual, cpptype.handle, rawobject)
             rawobject = capi.direct_ptradd(rawobject, offset)
-            state = space.fromcache(State)
-            try:
-                w_type = state.type_registry[actual]
-            except KeyError:
-                final_name = capi.c_final_name(actual)
-                w_type = space.call_function(state.w_clgen_callback, space.wrap(final_name))
+            w_type = get_wrapped_type(space, actual)
             w_cpptype = space.findattr(w_type, space.wrap("_cpp_proxy"))
             cpptype = space.interp_w(W_CPPType, w_cpptype, can_be_None=False)
     return wrap_cppobject_nocast(space, w_type, cpptype, rawobject, isref, python_owns)

pypy/module/cppyy/pythonify.py

 cppyy._set_class_generator(clgen_callback)
 
 def make_static_function(cpptype, func_name, cppol):
-    rettype = cppol.get_returntype()
-    if not rettype:                              # return builtin type
-        def function(*args):
-            return cppol.call(None, None, *args)
-    else:                                        # return instance
-        def function(*args):
-            return cppol.call(None, get_cppclass(rettype), *args)
+    def function(*args):
+        return cppol.call(None, *args)
     function.__name__ = func_name
     return staticmethod(function)
 
 def make_method(meth_name, cppol):
-    rettype = cppol.get_returntype()
-    if not rettype:                              # return builtin type
-        def method(self, *args):
-            return cppol.call(self, None, *args)
-    else:                                        # return instance
-        def method(self, *args):
-            return cppol.call(self, get_cppclass(rettype), *args)
+    def method(self, *args):
+        return cppol.call(self, *args)
     method.__name__ = meth_name
     return method
 
             raise TypeError(msg)
     else:
         def __new__(cls, *args):
-            return constructor_overload.call(None, cls, *args)
+            return constructor_overload.call(None, *args)
     return __new__
 
 def make_cppclass(scope, class_name, final_class_name, cpptype):

pypy/module/cppyy/src/cintcwrapper.cxx

     return cppstring_to_cstring(cr.GetClassName());
 }
 
+char* cppyy_scoped_final_name(cppyy_type_t handle) {
+    TClassRef cr = type_from_handle(handle);
+    if (cr.GetClass() && cr->GetClassInfo()) {
+        std::string true_name = G__TypeInfo(cr->GetName()).TrueName();
+        return cppstring_to_cstring(true_name);
+    }
+    return cppstring_to_cstring(cr.GetClassName());
+}
+
 int cppyy_has_complex_hierarchy(cppyy_type_t handle) {
 // as long as no fast path is supported for CINT, calculating offsets (which
 // are cached by the JIT) is not going to hurt 

pypy/module/cppyy/src/reflexcwrapper.cxx

     return cppstring_to_cstring(name);
 }
 
+char* cppyy_scoped_final_name(cppyy_type_t handle) {
+    Reflex::Scope s = scope_from_handle(handle);
+    if (s.IsEnum())
+        return cppstring_to_cstring("unsigned int");
+    std::string name = s.Name(Reflex::SCOPED | Reflex::FINAL);
+    return cppstring_to_cstring(name);
+}   
+
 static int cppyy_has_complex_hierarchy(const Reflex::Type& t) {
     int is_complex = 1;
     

pypy/module/cppyy/test/test_cppyy.py

         import sys, math
         t = self.example01
 
-        res = t.get_overload("staticAddOneToInt").call(None, None, 1)
+        res = t.get_overload("staticAddOneToInt").call(None, 1)
         assert res == 2
-        res = t.get_overload("staticAddOneToInt").call(None, None, 1L)
+        res = t.get_overload("staticAddOneToInt").call(None, 1L)
         assert res == 2
-        res = t.get_overload("staticAddOneToInt").call(None, None, 1, 2)
+        res = t.get_overload("staticAddOneToInt").call(None, 1, 2)
         assert res == 4
-        res = t.get_overload("staticAddOneToInt").call(None, None, -1)
+        res = t.get_overload("staticAddOneToInt").call(None, -1)
         assert res == 0
         maxint32 = int(2 ** 31 - 1)
-        res = t.get_overload("staticAddOneToInt").call(None, None, maxint32-1)
+        res = t.get_overload("staticAddOneToInt").call(None, maxint32-1)
         assert res == maxint32
-        res = t.get_overload("staticAddOneToInt").call(None, None, maxint32)
+        res = t.get_overload("staticAddOneToInt").call(None, maxint32)
         assert res == -maxint32-1
 
-        raises(TypeError, 't.get_overload("staticAddOneToInt").call(None, None, 1, [])')
-        raises(TypeError, 't.get_overload("staticAddOneToInt").call(None, None, 1.)')
-        raises(TypeError, 't.get_overload("staticAddOneToInt").call(None, None, maxint32+1)')
+        raises(TypeError, 't.get_overload("staticAddOneToInt").call(None, 1, [])')
+        raises(TypeError, 't.get_overload("staticAddOneToInt").call(None, 1.)')
+        raises(TypeError, 't.get_overload("staticAddOneToInt").call(None, maxint32+1)')
 
     def test02_static_double(self):
         """Test passing of a double and returning of a double on a static function."""
 
         t = self.example01
 
-        res = t.get_overload("staticAddToDouble").call(None, None, 0.09)
+        res = t.get_overload("staticAddToDouble").call(None, 0.09)
         assert res == 0.09 + 0.01
 
     def test03_static_constcharp(self):
 
         t = self.example01
 
-        res = t.get_overload("staticAtoi").call(None, None, "1")
+        res = t.get_overload("staticAtoi").call(None, "1")
         assert res == 1
-        res = t.get_overload("staticStrcpy").call(None, None, "aap")   # TODO: this leaks
+        res = t.get_overload("staticStrcpy").call(None, "aap")       # TODO: this leaks
         assert res == "aap"
-        res = t.get_overload("staticStrcpy").call(None, None, u"aap")  # TODO: this leaks
+        res = t.get_overload("staticStrcpy").call(None, u"aap")      # TODO: this leaks
         assert res == "aap"
 
-        raises(TypeError, 't.get_overload("staticStrcpy").call(None, None, 1.)') # TODO: this leaks
+        raises(TypeError, 't.get_overload("staticStrcpy").call(None, 1.)')     # TODO: this leaks
 
     def test04_method_int(self):
         """Test passing of a int, returning of a int, and memory cleanup, on
 
         t = self.example01
 
-        assert t.get_overload("getCount").call(None, None) == 0
+        assert t.get_overload("getCount").call(None) == 0
 
-        e1 = t.get_overload(t.type_name).call(None, cppyy.CPPInstance, 7)
-        assert t.get_overload("getCount").call(None, None) == 1
-        res = t.get_overload("addDataToInt").call(e1, None, 4)
+        e1 = t.get_overload(t.type_name).call(None, 7)
+        assert t.get_overload("getCount").call(None) == 1
+        res = t.get_overload("addDataToInt").call(e1, 4)
         assert res == 11
-        res = t.get_overload("addDataToInt").call(e1, None, -4)
+        res = t.get_overload("addDataToInt").call(e1, -4)
         assert res == 3
         e1.destruct()
-        assert t.get_overload("getCount").call(None, None) == 0
-        raises(ReferenceError, 't.get_overload("addDataToInt").call(e1, None, 4)')
+        assert t.get_overload("getCount").call(None) == 0
+        raises(ReferenceError, 't.get_overload("addDataToInt").call(e1, 4)')
 
-        e1 = t.get_overload(t.type_name).call(None, cppyy.CPPInstance, 7)
-        e2 = t.get_overload(t.type_name).call(None, cppyy.CPPInstance, 8)
-        assert t.get_overload("getCount").call(None, None) == 2
+        e1 = t.get_overload(t.type_name).call(None, 7)
+        e2 = t.get_overload(t.type_name).call(None, 8)
+        assert t.get_overload("getCount").call(None) == 2
         e1.destruct()
-        assert t.get_overload("getCount").call(None, None) == 1
+        assert t.get_overload("getCount").call(None) == 1
         e2.destruct()
-        assert t.get_overload("getCount").call(None, None) == 0
+        assert t.get_overload("getCount").call(None) == 0
 
         e2.destruct()
-        assert t.get_overload("getCount").call(None, None) == 0
+        assert t.get_overload("getCount").call(None) == 0
 
-        raises(TypeError, t.get_overload("addDataToInt").call, 41, None, 4)
+        raises(TypeError, t.get_overload("addDataToInt").call, 41, 4)
 
     def test05_memory(self):
         """Test memory destruction and integrity."""
 
         t = self.example01
 
-        assert t.get_overload("getCount").call(None, None) == 0
+        assert t.get_overload("getCount").call(None) == 0
 
-        e1 = t.get_overload(t.type_name).call(None, cppyy.CPPInstance, 7)
-        assert t.get_overload("getCount").call(None, None) == 1
-        res = t.get_overload("addDataToInt").call(e1, None, 4)
+        e1 = t.get_overload(t.type_name).call(None, 7)
+        assert t.get_overload("getCount").call(None) == 1
+        res = t.get_overload("addDataToInt").call(e1, 4)
         assert res == 11
-        res = t.get_overload("addDataToInt").call(e1, None, -4)
+        res = t.get_overload("addDataToInt").call(e1, -4)
         assert res == 3
         e1 = None
         gc.collect()
-        assert t.get_overload("getCount").call(None, None) == 0
+        assert t.get_overload("getCount").call(None) == 0
 
-        e1 = t.get_overload(t.type_name).call(None, cppyy.CPPInstance, 7)
-        e2 = t.get_overload(t.type_name).call(None, cppyy.CPPInstance, 8)
-        assert t.get_overload("getCount").call(None, None) == 2
+        e1 = t.get_overload(t.type_name).call(None, 7)
+        e2 = t.get_overload(t.type_name).call(None, 8)
+        assert t.get_overload("getCount").call(None) == 2
         e1 = None
         gc.collect()
-        assert t.get_overload("getCount").call(None, None) == 1
+        assert t.get_overload("getCount").call(None) == 1
 	e2.destruct()
-        assert t.get_overload("getCount").call(None, None) == 0
+        assert t.get_overload("getCount").call(None) == 0
         e2 = None
         gc.collect()
-        assert t.get_overload("getCount").call(None, None) == 0
+        assert t.get_overload("getCount").call(None) == 0
 
     def test06_method_double(self):
         """Test passing of a double and returning of double on a method"""
 
         t = self.example01
 
-        e = t.get_overload(t.type_name).call(None, cppyy.CPPInstance, 13)
-        res = t.get_overload("addDataToDouble").call(e, None, 16)
+        e = t.get_overload(t.type_name).call(None, 13)
+        res = t.get_overload("addDataToDouble").call(e, 16)
         assert round(res-29, 8) == 0.
         e.destruct()
 
-        e = t.get_overload(t.type_name).call(None, cppyy.CPPInstance, -13)
-        res = t.get_overload("addDataToDouble").call(e, None, 16)
+        e = t.get_overload(t.type_name).call(None, -13)
+        res = t.get_overload("addDataToDouble").call(e, 16)
         assert round(res-3, 8) == 0.
         e.destruct()
-        assert t.get_overload("getCount").call(None, None) == 0
+        assert t.get_overload("getCount").call(None) == 0
 
     def test07_method_constcharp(self):
         """Test passing of a C string and returning of a C string on a
 
         t = self.example01
 
-        e = t.get_overload(t.type_name).call(None, cppyy.CPPInstance, 42)
-        res = t.get_overload("addDataToAtoi").call(e, None, "13")
+        e = t.get_overload(t.type_name).call(None, 42)
+        res = t.get_overload("addDataToAtoi").call(e, "13")
         assert res == 55
-        res = t.get_overload("addToStringValue").call(e, None, "12")     # TODO: this leaks
+        res = t.get_overload("addToStringValue").call(e, "12")       # TODO: this leaks
         assert res == "54"
-        res = t.get_overload("addToStringValue").call(e, None, "-12")    # TODO: this leaks
+        res = t.get_overload("addToStringValue").call(e, "-12")      # TODO: this leaks
         assert res == "30"
         e.destruct()
-        assert t.get_overload("getCount").call(None, None) == 0
+        assert t.get_overload("getCount").call(None) == 0
 
     def test08_pass_object_by_pointer(self):
         """Test passing of an instance as an argument."""
         t1 = self.example01
         t2 = self.payload
 
-        pl = t2.get_overload(t2.type_name).call(None, cppyy.CPPInstance, 3.14)
-        assert round(t2.get_overload("getData").call(pl, None)-3.14, 8) == 0
-        t1.get_overload("staticSetPayload").call(None, None, pl, 41.)  # now pl is a CPPInstance
-        assert t2.get_overload("getData").call(pl, None) == 41.
+        pl = t2.get_overload(t2.type_name).call(None, 3.14)
+        assert round(t2.get_overload("getData").call(pl)-3.14, 8) == 0
+        t1.get_overload("staticSetPayload").call(None, pl, 41.)      # now pl is a CPPInstance
+        assert t2.get_overload("getData").call(pl) == 41.
 
-        e = t1.get_overload(t1.type_name).call(None, cppyy.CPPInstance, 50)
-        t1.get_overload("setPayload").call(e, None, pl);
-        assert round(t2.get_overload("getData").call(pl, None)-50., 8) == 0
+        e = t1.get_overload(t1.type_name).call(None, 50)
+        t1.get_overload("setPayload").call(e, pl);
+        assert round(t2.get_overload("getData").call(pl)-50., 8) == 0
 
         e.destruct()
         pl.destruct() 
-        assert t1.get_overload("getCount").call(None, None) == 0
+        assert t1.get_overload("getCount").call(None) == 0
 
     def test09_return_object_by_pointer(self):
         """Test returning of an instance as an argument."""
         t1 = self.example01
         t2 = self.payload
 
-        pl1 = t2.get_overload(t2.type_name).call(None, cppyy.CPPInstance, 3.14)
-        assert round(t2.get_overload("getData").call(pl1, None)-3.14, 8) == 0
-        pl2 = t1.get_overload("staticCyclePayload").call(None, cppyy.CPPInstance, pl1, 38.)
-        assert t2.get_overload("getData").call(pl2, None) == 38.
+        pl1 = t2.get_overload(t2.type_name).call(None, 3.14)
+        assert round(t2.get_overload("getData").call(pl1)-3.14, 8) == 0
+        pl2 = t1.get_overload("staticCyclePayload").call(None, pl1, 38.)
+        assert t2.get_overload("getData").call(pl2) == 38.
 
-        e = t1.get_overload(t1.type_name).call(None, cppyy.CPPInstance, 50)
-        pl2 = t1.get_overload("cyclePayload").call(e, cppyy.CPPInstance, pl1);
-        assert round(t2.get_overload("getData").call(pl2, None)-50., 8) == 0
+        e = t1.get_overload(t1.type_name).call(None, 50)
+        pl2 = t1.get_overload("cyclePayload").call(e, pl1);
+        assert round(t2.get_overload("getData").call(pl2)-50., 8) == 0
 
         e.destruct()
         pl1.destruct() 
-        assert t1.get_overload("getCount").call(None, None) == 0
+        assert t1.get_overload("getCount").call(None) == 0

pypy/module/cppyy/test/test_zjit.py

     def perform(self, executioncontext, frame):
         pass
 
-class FakeReturnType(object):
-    pass
-
 class FakeSpace(object):
     fake = True
 
         return None
 
     def allocate_instance(self, cls, w_type):
-        assert isinstance(w_type, FakeReturnType)
         return instantiate(cls)
 
     def call_function(self, w_func, *args_w):
         def f():
             lib = interp_cppyy.load_dictionary(space, "./example01Dict.so")
             cls  = interp_cppyy.type_byname(space, "example01")
-            inst = cls.get_overload("example01").call(None, FakeReturnType(), [FakeInt(0)])
+            inst = cls.get_overload("example01").call(None, [FakeInt(0)])
             addDataToInt = cls.get_overload("addDataToInt")
             assert isinstance(inst, interp_cppyy.W_CPPInstance)
             i = 10
             while i > 0:
                 drv.jit_merge_point(inst=inst, addDataToInt=addDataToInt, i=i)
-                addDataToInt.call(inst, None, [FakeInt(i)])
+                addDataToInt.call(inst, [FakeInt(i)])
                 i -= 1
             return 7
         f()
         def f():
             lib = interp_cppyy.load_dictionary(space, "./example01Dict.so")
             cls  = interp_cppyy.type_byname(space, "example01")
-            inst = cls.get_overload("example01").call(None, FakeReturnType(), [FakeInt(0)])
+            inst = cls.get_overload("example01").call(None, [FakeInt(0)])
             addDataToInt = cls.get_overload("overloadedAddDataToInt")
             assert isinstance(inst, interp_cppyy.W_CPPInstance)
             i = 10
             while i > 0:
                 drv.jit_merge_point(inst=inst, addDataToInt=addDataToInt, i=i)
-                addDataToInt.call(inst, None, [FakeInt(i)])
+                addDataToInt.call(inst, [FakeInt(i)])
                 i -= 1
             return 7
         f()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.