[pypy-svn] r76058 - in pypy/branch/reflex-support/pypy/module/cppyy: . include src
antocuni at codespeak.net
antocuni at codespeak.net
Fri Jul 9 10:44:17 CEST 2010
Author: antocuni
Date: Fri Jul 9 10:44:15 2010
New Revision: 76058
Modified:
pypy/branch/reflex-support/pypy/module/cppyy/capi.py
pypy/branch/reflex-support/pypy/module/cppyy/include/reflexcwrapper.h
pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py
pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx
Log:
(arigo, antocuni): revert r76042 as it makes things slower. Moreover, turn
get_methptr_getter into a pure function, to help the jit
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 Fri Jul 9 10:44:15 2010
@@ -96,10 +96,6 @@
"cppyy_is_subtype",
[C_TYPEHANDLE, C_TYPEHANDLE], rffi.INT,
compilation_info=eci)
-c_dynamic_type = rffi.llexternal(
- "cppyy_dynamic_type",
- [C_TYPEHANDLE, C_OBJECT], C_TYPEHANDLE,
- compilation_info=eci)
c_free = rffi.llexternal(
"cppyy_free",
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 Fri Jul 9 10:44:15 2010
@@ -30,8 +30,6 @@
int cppyy_is_static(cppyy_typehandle_t handle, int method_index);
int cppyy_is_subtype(cppyy_typehandle_t h1, cppyy_typehandle_t h2);
- cppyy_typehandle_t cppyy_dynamic_type(cppyy_typehandle_t handle, cppyy_object_t self);
-
void cppyy_free(void* ptr);
#ifdef __cplusplus
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 Fri Jul 9 10:44:15 2010
@@ -51,6 +51,11 @@
'CPPLibrary',
)
+ at jit.purefunction
+def get_methptr_getter(handle, method_index):
+ return capi.c_get_methptr_getter(handle, method_index)
+
+
class CPPMethod(object):
""" A concrete function after overloading has been resolved """
_immutable_ = True
@@ -91,11 +96,11 @@
if len(args_w) != 1:
raise OperationError(space.w_TypeError, space.wrap("wrong number of args"))
arg = space.c_int_w(args_w[0])
-
- cpptype = jit.hint(self.cpptype, promote=True)
- cpp_dynamic_type = capi.c_dynamic_type(cpptype.handle, cppthis)
- cppthis_holder.cppthis = cppthis
- funcptr = cpptype.get_methptr(cpp_dynamic_type, self.method_index)
+ methgetter = get_methptr_getter(self.cpptype.handle,
+ self.method_index)
+ if not methgetter:
+ raise NotImplementedError
+ funcptr = methgetter(cppthis)
funcptr = rffi.cast(self.INT_2_INT_FNPTR, funcptr)
result = funcptr(cppthis, arg)
return space.wrap(rffi.cast(lltype.Signed, result))
@@ -197,10 +202,6 @@
is_static = interp2app(W_CPPOverload.is_static, unwrap_spec=['self']),
)
-# hack hack hack (see get_methptr)
-class _CppthisHolder(object):
- pass
-cppthis_holder = _CppthisHolder()
class W_CPPType(Wrappable):
_immutable_fields_ = ["name","handle"]
@@ -246,18 +247,6 @@
def get_overload(self, name):
return self.function_members[name]
- @jit.purefunction
- def get_methptr(self, cpp_dynamic_type, method_index):
- # hack hack hack: we can't really pass cppthis as an argument as it's
- # not constant, but as long as it corresponds to cpp_dynamic_type, the
- # function is still pure
- cppthis = cppthis_holder.cppthis
- methgetter = capi.c_get_methptr_getter(self.handle, method_index)
- if not methgetter:
- raise NotImplementedError
- return methgetter(cppthis)
-
-
def invoke(self, name, args_w):
overload = self.get_overload(name)
return overload.call(NULL_VOIDP, args_w)
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 Fri Jul 9 10:44:15 2010
@@ -156,13 +156,6 @@
return (int)t2.HasBase(t1);
}
-cppyy_typehandle_t cppyy_dynamic_type(cppyy_typehandle_t handle, cppyy_object_t self) {
- Reflex::Type t((Reflex::TypeName*)handle);
- const Reflex::Object* obj = (const Reflex::Object*)self;
- return t.DynamicType((*obj)).Id();
-}
-
-
void cppyy_free(void* ptr) {
free(ptr);
}
More information about the Pypy-commit
mailing list