[pypy-svn] r75987 - in pypy/branch/reflex-support/pypy/module/cppyy: . include src

wlav at codespeak.net wlav at codespeak.net
Wed Jul 7 18:13:33 CEST 2010


Author: wlav
Date: Wed Jul  7 18:13:31 2010
New Revision: 75987

Modified:
   pypy/branch/reflex-support/pypy/module/cppyy/capi.py
   pypy/branch/reflex-support/pypy/module/cppyy/executor.py
   pypy/branch/reflex-support/pypy/module/cppyy/include/reflexcwrapper.h
   pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx
Log:
Merge static and method call for resolution on the C++ side.


Modified: pypy/branch/reflex-support/pypy/module/cppyy/capi.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/capi.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/capi.py	Wed Jul  7 18:13:31 2010
@@ -39,8 +39,8 @@
     "construct",
     [rffi.VOIDP, rffi.INT, rffi.VOIDPP], rffi.VOIDP,
     compilation_info=eci)
-c_callmethod_l = rffi.llexternal(
-    "callmethod_l",
+c_cppyy_call_l = rffi.llexternal(
+    "cppyy_call_l",
     [rffi.VOIDP, rffi.INT, rffi.VOIDP, rffi.INT, rffi.VOIDPP], rffi.LONG,
     compilation_info=eci)
 c_destruct = rffi.llexternal(

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	Wed Jul  7 18:13:31 2010
@@ -12,10 +12,7 @@
 
 class LongExecutor(FunctionExecutor):
     def execute(self, space, func, cppthis, num_args, args):
-        if cppthis is not None:
-            result = capi.c_callmethod_l(func.cpptype.handle, func.method_index, cppthis, num_args, args)
-        else:
-            result = capi.c_callstatic_l(func.cpptype.handle, func.method_index, num_args, args)
+        result = capi.c_cppyy_call_l(func.cpptype.handle, func.method_index, cppthis, num_args, args)
         return space.wrap(result)
 
 class DoubleExecutor(FunctionExecutor):
@@ -31,7 +28,7 @@
         if cppthis is not None:
             raise NotImplementedError
         else:
-            lresult = capi.c_callstatic_l(func.cpptype.handle, func.method_index, num_args, args)
+            lresult = capi.c_cppyy_call_l(func.cpptype.handle, func.method_index, cppthis, num_args, args)
         ccpresult = rffi.cast(rffi.CCHARP, lresult)
         result = capi.charp2str_free(ccpresult)
         return space.wrap(result)

Modified: pypy/branch/reflex-support/pypy/module/cppyy/include/reflexcwrapper.h
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/include/reflexcwrapper.h	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/include/reflexcwrapper.h	Wed Jul  7 18:13:31 2010
@@ -7,9 +7,8 @@
 #endif // ifdef __cplusplus
     void* cppyy_get_typehandle(const char* class_name);
 
-    long callstatic_l(void* handle, int method_index, int numargs, void* args[]);
     double callstatic_d(void* handle, int method_index, int numargs, void* args[]);
-    long callmethod_l(void* handle, int method_index, void* self, int numargs, void* args[]);
+    long cppyy_call_l(void* handle, int method_index, void* self, int numargs, void* args[]);
     void* construct(void* handle, int numargs, void* args[]);
     void destruct(void* handle, void* self);
 

Modified: pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx	Wed Jul  7 18:13:31 2010
@@ -8,14 +8,6 @@
    return Reflex::Type::ByName(class_name).Id();
 }
 
-long callstatic_l(void* handle, int method_index, int numargs, void* args[]) {
-    long result;
-    std::vector<void*> arguments(args, args+numargs);
-    Reflex::Type t((Reflex::TypeName*)handle);
-    Reflex::Member m = t.FunctionMemberAt(method_index);
-    m.Invoke(result, arguments);
-    return result;
-}
 double callstatic_d(void* handle, int method_index, int numargs, void* args[]) {
     double result;
     std::vector<void*> arguments(args, args+numargs);
@@ -25,14 +17,18 @@
     return result;
 }
 
-long callmethod_l(void* handle, int method_index,
+long cppyy_call_l(void* handle, int method_index,
 	          void* self, int numargs, void* args[]) {
     long result;
     std::vector<void*> arguments(args, args+numargs);
     Reflex::Type t((Reflex::TypeName*)handle);
-    Reflex::Object o(t, self);
     Reflex::Member m = t.FunctionMemberAt(method_index);
-    m.Invoke(o, result, arguments);
+    if (self) {
+        Reflex::Object o(t, self);
+        m.Invoke(o, result, arguments);
+    } else {
+        m.Invoke(result, arguments);
+    }
     return result;
 }
 



More information about the Pypy-commit mailing list