[pypy-commit] pypy reflex-support: restructure reflex calling for integration with cint
wlav
noreply at buildbot.pypy.org
Thu Jul 14 18:01:07 CEST 2011
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r45598:c0410ece8035
Date: 2011-07-14 08:59 -0700
http://bitbucket.org/pypy/pypy/changeset/c0410ece8035/
Log: restructure reflex calling for integration with cint
diff --git a/pypy/module/cppyy/capi/reflex_capi.py b/pypy/module/cppyy/capi/reflex_capi.py
--- a/pypy/module/cppyy/capi/reflex_capi.py
+++ b/pypy/module/cppyy/capi/reflex_capi.py
@@ -19,7 +19,7 @@
include_dirs=[incpath] + rootincpath,
includes=["reflexcwrapper.h"],
library_dirs=rootlibpath,
- libraries=["Reflex"],
+ link_extra=["-lReflex"],
use_cpp_linker=True,
)
@@ -89,39 +89,39 @@
c_call_v = rffi.llexternal(
"cppyy_call_v",
- [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], lltype.Void,
+ [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], lltype.Void,
compilation_info=eci)
c_call_o = rffi.llexternal(
"cppyy_call_o",
- [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP, C_TYPEHANDLE], rffi.LONG,
+ [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP, C_TYPEHANDLE], rffi.LONG,
compilation_info=eci)
c_call_b = rffi.llexternal(
"cppyy_call_b",
- [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], rffi.INT,
+ [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.INT,
compilation_info=eci)
c_call_c = rffi.llexternal(
"cppyy_call_c",
- [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], rffi.CHAR,
+ [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.CHAR,
compilation_info=eci)
c_call_h = rffi.llexternal(
"cppyy_call_h",
- [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], rffi.SHORT,
+ [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.SHORT,
compilation_info=eci)
c_call_i = rffi.llexternal(
"cppyy_call_i",
- [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], rffi.INT,
+ [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.INT,
compilation_info=eci)
c_call_l = rffi.llexternal(
"cppyy_call_l",
- [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], rffi.LONG,
+ [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.LONG,
compilation_info=eci)
c_call_f = rffi.llexternal(
"cppyy_call_f",
- [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], rffi.DOUBLE,
+ [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.DOUBLE,
compilation_info=eci)
c_call_d = rffi.llexternal(
"cppyy_call_d",
- [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], rffi.DOUBLE,
+ [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.DOUBLE,
compilation_info=eci)
@@ -131,6 +131,29 @@
compilation_info=eci)
+c_allocate_function_args = rffi.llexternal(
+ "cppyy_allocate_function_args",
+ [rffi.SIZE_T], rffi.VOIDP,
+ compilation_info=eci)
+
+c_deallocate_function_args = rffi.llexternal(
+ "cppyy_deallocate_function_args",
+ [rffi.VOIDP], lltype.Void,
+ compilation_info=eci)
+
+c_function_arg_sizeof = rffi.llexternal(
+ "cppyy_function_arg_sizeof",
+ [], rffi.SIZE_T,
+ compilation_info=eci,
+ elidable_function=True)
+
+c_function_arg_typeoffset = rffi.llexternal(
+ "cppyy_function_arg_typeoffset",
+ [], rffi.SIZE_T,
+ compilation_info=eci,
+ elidable_function=True)
+
+
c_num_methods = rffi.llexternal(
"cppyy_num_methods",
[C_TYPEHANDLE], rffi.INT,
diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py
--- a/pypy/module/cppyy/converter.py
+++ b/pypy/module/cppyy/converter.py
@@ -47,7 +47,7 @@
raise NotImplementedError(
"abstract base class" ) # more detailed part is not rpython: (actual: %s)" % type(self).__name__)
- def convert_argument(self, space, w_obj):
+ def convert_argument(self, space, w_obj, address):
self._is_abstract()
def convert_argument_libffi(self, space, w_obj, argchain):
@@ -61,7 +61,7 @@
self._is_abstract()
def free_argument(self, arg):
- lltype.free(arg, flavor='raw')
+ pass
class ArrayCache(object):
@@ -141,7 +141,7 @@
def __init__(self, space, name):
self.name = name
- def convert_argument(self, space, w_obj):
+ def convert_argument(self, space, w_obj, address):
raise OperationError(space.w_TypeError,
space.wrap('no converter available for type "%s"' % self.name))
@@ -157,11 +157,9 @@
space.wrap("boolean value should be bool, or integer 1 or 0"))
return arg
- def convert_argument(self, space, w_obj):
- arg = self._unwrap_object(space, w_obj)
- x = lltype.malloc(rffi.LONGP.TO, 1, flavor='raw')
- x[0] = arg
- return rffi.cast(rffi.VOIDP, x)
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.LONGP, address)
+ x[0] = self._unwrap_object(space, w_obj)
def convert_argument_libffi(self, space, w_obj, argchain):
argchain.arg(self._unwrap_object(space, w_obj))
@@ -201,10 +199,9 @@
space.wrap("char expected, got string of size %d" % len(value)))
return value[0] # turn it into a "char" to the annotator
- def convert_argument(self, space, w_obj):
- arg = self._unwrap_object(space, w_obj)
- x = rffi.str2charp(arg)
- return rffi.cast(rffi.VOIDP, x)
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.CCHARP, address)
+ x[0] = self._unwrap_object(space, w_obj)
def convert_argument_libffi(self, space, w_obj, argchain):
argchain.arg(self._unwrap_object(space, w_obj))
@@ -224,11 +221,9 @@
def _unwrap_object(self, space, w_obj):
return rffi.cast(rffi.INT, space.c_int_w(w_obj))
- def convert_argument(self, space, w_obj):
- arg = self._unwrap_object(space, w_obj)
- x = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
- x[0] = arg
- return rffi.cast(rffi.VOIDP, x)
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.INTP, address)
+ x[0] = self._unwrap_object(space, w_obj)
def convert_argument_libffi(self, space, w_obj, argchain):
argchain.arg(self._unwrap_object(space, w_obj))
@@ -250,11 +245,9 @@
def _unwrap_object(self, space, w_obj):
return rffi.cast(rffi.UINT, space.uint_w(w_obj))
- def convert_argument(self, space, w_obj):
- arg = self._unwrap_object(space, w_obj)
- x = lltype.malloc(rffi.UINTP.TO, 1, flavor='raw')
- x[0] = arg
- return rffi.cast(rffi.VOIDP, x)
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.UINTP, address)
+ x[0] = self._unwrap_object(space, w_obj)
def convert_argument_libffi(self, space, w_obj, argchain):
argchain.arg(self._unwrap_object(space, w_obj))
@@ -276,11 +269,9 @@
def _unwrap_object(self, space, w_obj):
return space.int_w(w_obj)
- def convert_argument(self, space, w_obj):
- arg = self._unwrap_object(space, w_obj)
- x = lltype.malloc(rffi.LONGP.TO, 1, flavor='raw')
- x[0] = arg
- return rffi.cast(rffi.VOIDP, x)
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.LONGP, address)
+ x[0] = self._unwrap_object(space, w_obj)
def convert_argument_libffi(self, space, w_obj, argchain):
argchain.arg(self._unwrap_object(space, w_obj))
@@ -302,11 +293,9 @@
def _unwrap_object(self, space, w_obj):
return space.uint_w(w_obj)
- def convert_argument(self, space, w_obj):
- arg = self._unwrap_object(space, w_obj)
- x = lltype.malloc(rffi.ULONGP.TO, 1, flavor='raw')
- x[0] = arg
- return rffi.cast(rffi.VOIDP, x)
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.ULONGP, address)
+ x[0] = self._unwrap_object(space, w_obj)
def convert_argument_libffi(self, space, w_obj, argchain):
argchain.arg(self._unwrap_object(space, w_obj))
@@ -328,11 +317,9 @@
def _unwrap_object(self, space, w_obj):
return rffi.cast(rffi.SHORT, space.int_w(w_obj))
- def convert_argument(self, space, w_obj):
- arg = self._unwrap_object(space, w_obj)
- x = lltype.malloc(rffi.SHORTP.TO, 1, flavor='raw')
- x[0] = arg
- return rffi.cast(rffi.VOIDP, x)
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.SHORTP, address)
+ x[0] = self._unwrap_object(space, w_obj)
def convert_argument_libffi(self, space, w_obj, argchain):
argchain.arg(self._unwrap_object(space, w_obj))
@@ -354,10 +341,9 @@
def _unwrap_object(self, space, w_obj):
return r_singlefloat(space.float_w(w_obj))
- def convert_argument(self, space, w_obj):
- x = lltype.malloc(rffi.FLOATP.TO, 1, flavor='raw')
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.FLOATP, address)
x[0] = self._unwrap_object(space, w_obj)
- return rffi.cast(rffi.VOIDP, x)
def convert_argument_libffi(self, space, w_obj, argchain):
# it's required to sent an rffi.DOUBLE not r_singlefloat
@@ -380,10 +366,9 @@
def _unwrap_object(self, space, w_obj):
return space.float_w(w_obj)
- def convert_argument(self, space, w_obj):
- x = lltype.malloc(rffi.DOUBLEP.TO, 1, flavor='raw')
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.DOUBLEP, address)
x[0] = self._unwrap_object(space, w_obj)
- return rffi.cast(rffi.VOIDP, x)
def convert_argument_libffi(self, space, w_obj, argchain):
argchain.arg(self._unwrap_object(space, w_obj))
@@ -402,16 +387,21 @@
class CStringConverter(TypeConverter):
_immutable = True
- def convert_argument(self, space, w_obj):
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.LONGP, address)
arg = space.str_w(w_obj)
- x = rffi.str2charp(arg)
- return rffi.cast(rffi.VOIDP, x)
+ x[0] = rffi.cast(rffi.LONG, rffi.str2charp(arg))
+ typecode = _direct_ptradd(address, capi.c_function_arg_typeoffset())
+ typecode[0] = 'a'
def from_memory(self, space, w_obj, offset):
address = self._get_raw_address(space, w_obj, offset)
charpptr = rffi.cast(rffi.CCHARPP, address)
return space.wrap(rffi.charp2str(charpptr[0]))
+ def free_argument(self, arg):
+ lltype.free(rffi.cast(rffi.CCHARPP, arg)[0], flavor='raw')
+
class ShortArrayConverter(ArrayTypeConverterMixin, TypeConverter):
_immutable_=True
@@ -498,14 +488,15 @@
space.type(w_obj).getname(space, "?"),
self.cpptype.name)))
- def convert_argument(self, space, w_obj):
- return self._unwrap_object(space, w_obj)
+ def convert_argument(self, space, w_obj, address):
+ x = rffi.cast(rffi.VOIDPP, address)
+ x[0] = self._unwrap_object(space, w_obj)
+ typecode = _direct_ptradd(address, capi.c_function_arg_typeoffset())
+ typecode[0] = 'a'
def convert_argument_libffi(self, space, w_obj, argchain):
argchain.arg(self._unwrap_object(space, w_obj))
- def free_argument(self, arg):
- pass
class InstanceConverter(InstancePtrConverter):
_immutable_ = True
@@ -515,9 +506,6 @@
from pypy.module.cppyy import interp_cppyy
return interp_cppyy.W_CPPInstance(space, self.cpptype, address, False)
- def free_argument(self, arg):
- pass
-
_converters = {}
def get_converter(space, name):
diff --git a/pypy/module/cppyy/include/capi.h b/pypy/module/cppyy/include/capi.h
--- a/pypy/module/cppyy/include/capi.h
+++ b/pypy/module/cppyy/include/capi.h
@@ -20,18 +20,24 @@
void cppyy_destruct(cppyy_typehandle_t handle, cppyy_object_t self);
/* method/function dispatching */
- void cppyy_call_v(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
- long cppyy_call_o(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[], cppyy_typehandle_t rettype);
- int cppyy_call_b(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
- char cppyy_call_c(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
- short cppyy_call_h(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
- int cppyy_call_i(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
- long cppyy_call_l(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
- double cppyy_call_f(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
- double cppyy_call_d(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
+ void cppyy_call_v(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args);
+ long cppyy_call_o(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args, cppyy_typehandle_t rettype);
+ int cppyy_call_b(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args);
+ char cppyy_call_c(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args);
+ short cppyy_call_h(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args);
+ int cppyy_call_i(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args);
+ long cppyy_call_l(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args);
+ double cppyy_call_f(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args);
+ double cppyy_call_d(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args);
cppyy_methptrgetter_t cppyy_get_methptr_getter(cppyy_typehandle_t handle, int method_index);
+ /* handling of function argument buffer */
+ void* cppyy_allocate_function_args(size_t nargs);
+ void cppyy_deallocate_function_args(void* args);
+ size_t cppyy_function_arg_sizeof();
+ size_t cppyy_function_arg_typeoffset();
+
/* scope reflection information ------------------------------------------- */
int cppyy_is_namespace(cppyy_typehandle_t handle);
diff --git a/pypy/module/cppyy/include/cppyy.h b/pypy/module/cppyy/include/cppyy.h
--- a/pypy/module/cppyy/include/cppyy.h
+++ b/pypy/module/cppyy/include/cppyy.h
@@ -1,6 +1,81 @@
#ifndef CPPYY_CPPYY
#define CPPYY_CPPYY
-// for now, just a conventional placeholder
+#define CPPYY_G__MAXFUNCPARA 40
+
+#ifdef __cplusplus
+struct CPPYY_G__DUMMY_FOR_CINT7 {
+#else
+typedef struct
+#endif
+ void* fTypeName;
+ unsigned int fModifiers;
+#ifdef __cplusplus
+};
+#else
+} CPPYY_G__DUMMY_FOR_CINT7;
+#endif
+
+#ifdef __cplusplus
+struct CPPYY_G__p2p {
+#else
+#typedef struct
+#endif
+ long i;
+ int reftype;
+#ifdef __cplusplus
+};
+#else
+} CPPYY_G__p2p;
+#endif
+
+
+#ifdef __cplusplus
+struct CPPYY_G__value {
+#else
+typedef struct {
+#endif
+ union {
+ double d;
+ long i; /* used to be int */
+ struct CPPYY_G__p2p reftype;
+ char ch;
+ short sh;
+ int in;
+ float fl;
+ unsigned char uch;
+ unsigned short ush;
+ unsigned int uin;
+ unsigned long ulo;
+ long long ll;
+ unsigned long long ull;
+ long double ld;
+ } obj;
+ long ref;
+ int type;
+ int tagnum;
+ int typenum;
+ char isconst;
+ struct CPPYY_G__DUMMY_FOR_CINT7 dummyForCint7;
+#ifdef __cplusplus
+};
+#else
+} CPPYY_G__value;
+#endif
+
+
+#ifdef __cplusplus
+struct CPPYY_G__param {
+#else
+typedef struct
+#endif
+ int paran;
+ long para; /* place-holder */
+ /* dropped parameter as it appears unused in stub functions */
+#ifdef __cplusplus
+};
+#else
+} CPPYY_G__param;
+#endif
#endif // CPPYY_CPPYY
diff --git a/pypy/module/cppyy/interp_cppyy.py b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -171,28 +171,32 @@
raise OperationError(space.w_TypeError, space.wrap("wrong number of args"))
if self.arg_converters is None:
self._build_converters()
- args = lltype.malloc(rffi.CArray(rffi.VOIDP), len(args_w), flavor='raw')
+ args = capi.c_allocate_function_args(len(args_w))
+ stride = capi.c_function_arg_sizeof()
for i in range(len(args_w)):
conv = self.arg_converters[i]
w_arg = args_w[i]
try:
- arg = conv.convert_argument(space, w_arg)
+ arg_i = lltype.direct_ptradd(rffi.cast(rffi.CCHARP, args), i*stride)
+ conv.convert_argument(space, w_arg, rffi.cast(rffi.VOIDP, arg_i))
except:
# fun :-(
for j in range(i):
conv = self.arg_converters[j]
- conv.free_argument(args[j])
- lltype.free(args, flavor='raw')
+ arg_j = lltype.direct_ptradd(rffi.cast(rffi.CCHARP, args), j*stride)
+ conv.free_argument(rffi.cast(rffi.VOIDP, arg_j))
+ capi.c_deallocate_function_args(args)
raise
- args[i] = arg
return args
@jit.unroll_safe
def free_arguments(self, args, nargs):
+ stride = capi.c_function_arg_sizeof()
for i in range(nargs):
conv = self.arg_converters[i]
- conv.free_argument(args[i])
- lltype.free(args, flavor='raw')
+ arg_i = lltype.direct_ptradd(rffi.cast(rffi.CCHARP, args), i*stride)
+ conv.free_argument(rffi.cast(rffi.VOIDP, arg_i))
+ capi.c_deallocate_function_args(args)
def __repr__(self):
return "CPPFunction(%s, %s, %r, %s)" % (
diff --git a/pypy/module/cppyy/src/reflexcwrapper.cxx b/pypy/module/cppyy/src/reflexcwrapper.cxx
--- a/pypy/module/cppyy/src/reflexcwrapper.cxx
+++ b/pypy/module/cppyy/src/reflexcwrapper.cxx
@@ -30,6 +30,18 @@
return Reflex::Scope((Reflex::ScopeName*)handle);
}
+static inline std::vector<void*> build_args(int numargs, void* args) {
+ std::vector<void*> arguments;
+ arguments.reserve(numargs);
+ for (int i=0; i < numargs; ++i) {
+ if (((CPPYY_G__value*)args)[i].type == 'l')
+ arguments.push_back(&((CPPYY_G__value*)args)[i]);
+ else
+ arguments.push_back((void*)(*(long*)&((CPPYY_G__value*)args)[i]));
+ }
+ return arguments;
+}
+
static inline size_t base_offset(const Reflex::Type& td, const Reflex::Type& tb) {
// when dealing with virtual inheritance the only (reasonably) well-defined info is
// in a Reflex internal base table, that contains all offsets within the hierarchy
@@ -92,8 +104,8 @@
/* method/function dispatching -------------------------------------------- */
void cppyy_call_v(cppyy_typehandle_t handle, int method_index,
- cppyy_object_t self, int numargs, void* args[]) {
- std::vector<void*> arguments(args, args+numargs);
+ cppyy_object_t self, int numargs, void* args) {
+ std::vector<void*> arguments = build_args(numargs, args);
Reflex::Scope s = scope_from_handle(handle);
Reflex::Member m = s.FunctionMemberAt(method_index);
if (self) {
@@ -105,10 +117,10 @@
}
long cppyy_call_o(cppyy_typehandle_t handle, int method_index,
- cppyy_object_t self, int numargs, void* args[],
+ cppyy_object_t self, int numargs, void* args,
cppyy_typehandle_t rettype) {
void* result = cppyy_allocate(rettype);
- std::vector<void*> arguments(args, args+numargs);
+ std::vector<void*> arguments = build_args(numargs, args);
Reflex::Scope s = scope_from_handle(handle);
Reflex::Member m = s.FunctionMemberAt(method_index);
if (self) {
@@ -122,9 +134,9 @@
template<typename T>
static inline T cppyy_call_T(cppyy_typehandle_t handle, int method_index,
- cppyy_object_t self, int numargs, void* args[]) {
+ cppyy_object_t self, int numargs, void* args) {
T result;
- std::vector<void*> arguments(args, args+numargs);
+ std::vector<void*> arguments = build_args(numargs, args);
Reflex::Scope s = scope_from_handle(handle);
Reflex::Member m = s.FunctionMemberAt(method_index);
if (self) {
@@ -137,37 +149,37 @@
}
int cppyy_call_b(cppyy_typehandle_t handle, int method_index,
- cppyy_object_t self, int numargs, void* args[]) {
+ cppyy_object_t self, int numargs, void* args) {
return (int)cppyy_call_T<bool>(handle, method_index, self, numargs, args);
}
char cppyy_call_c(cppyy_typehandle_t handle, int method_index,
- cppyy_object_t self, int numargs, void* args[]) {
+ cppyy_object_t self, int numargs, void* args) {
return cppyy_call_T<char>(handle, method_index, self, numargs, args);
}
short cppyy_call_h(cppyy_typehandle_t handle, int method_index,
- cppyy_object_t self, int numargs, void* args[]) {
+ cppyy_object_t self, int numargs, void* args) {
return cppyy_call_T<short>(handle, method_index, self, numargs, args);
}
int cppyy_call_i(cppyy_typehandle_t handle, int method_index,
- cppyy_object_t self, int numargs, void* args[]) {
+ cppyy_object_t self, int numargs, void* args) {
return cppyy_call_T<int>(handle, method_index, self, numargs, args);
}
long cppyy_call_l(cppyy_typehandle_t handle, int method_index,
- cppyy_object_t self, int numargs, void* args[]) {
+ cppyy_object_t self, int numargs, void* args) {
return cppyy_call_T<long>(handle, method_index, self, numargs, args);
}
double cppyy_call_f(cppyy_typehandle_t handle, int method_index,
- cppyy_object_t self, int numargs, void* args[]) {
+ cppyy_object_t self, int numargs, void* args) {
return cppyy_call_T<float>(handle, method_index, self, numargs, args);
}
double cppyy_call_d(cppyy_typehandle_t handle, int method_index,
- cppyy_object_t self, int numargs, void* args[]) {
+ cppyy_object_t self, int numargs, void* args) {
return cppyy_call_T<double>(handle, method_index, self, numargs, args);
}
@@ -188,6 +200,29 @@
}
+/* handling of function argument buffer */
+void* cppyy_allocate_function_args(size_t nargs) {
+ CPPYY_G__param* libp = (CPPYY_G__param*)malloc(
+ sizeof(int/*CPPYY_G__param.paran*/) + nargs*sizeof(CPPYY_G__value));
+ libp->paran = (int)nargs;
+ for (int i = 0; i < nargs; ++i)
+ ((CPPYY_G__value*)&libp->para)[i].type = 'l';
+ return (void*)&libp->para;
+}
+
+void cppyy_deallocate_function_args(void* args) {
+ free((char*)args - offsetof(CPPYY_G__param, para));
+}
+
+size_t cppyy_function_arg_sizeof() {
+ return sizeof(CPPYY_G__value);
+}
+
+size_t cppyy_function_arg_typeoffset() {
+ return offsetof(CPPYY_G__value, type);
+}
+
+
/* scope reflection information ------------------------------------------- */
int cppyy_is_namespace(cppyy_typehandle_t handle) {
Reflex::Scope s = scope_from_handle(handle);
diff --git a/pypy/module/cppyy/test/example01.cxx b/pypy/module/cppyy/test/example01.cxx
--- a/pypy/module/cppyy/test/example01.cxx
+++ b/pypy/module/cppyy/test/example01.cxx
@@ -83,7 +83,6 @@
}
int example01::getCount() {
- std::cout << "getcount called" << std::endl;
return count;
}
diff --git a/pypy/module/cppyy/test/test_cppyy.py b/pypy/module/cppyy/test/test_cppyy.py
--- a/pypy/module/cppyy/test/test_cppyy.py
+++ b/pypy/module/cppyy/test/test_cppyy.py
@@ -61,7 +61,6 @@
raises(TypeError, 't.invoke(t.get_overload("staticAddOneToInt"), 1.)')
raises(OverflowError, 't.invoke(t.get_overload("staticAddOneToInt"), maxint32+1)')
-
def test_example01static_double(self):
"""Test passing of a double and returning of a double on a static function."""
More information about the pypy-commit
mailing list