Author: Wim Lavrijsen <[email protected]>
Branch: reflex-support
Changeset: r71123:49432e9dce27
Date: 2014-04-30 23:45 -0700
http://bitbucket.org/pypy/pypy/changeset/49432e9dce27/
Log: open up more tests (from test_datatypes.py) for use with dummy
backend
diff --git a/pypy/module/cppyy/src/dummy_backend.cxx
b/pypy/module/cppyy/src/dummy_backend.cxx
--- a/pypy/module/cppyy/src/dummy_backend.cxx
+++ b/pypy/module/cppyy/src/dummy_backend.cxx
@@ -8,15 +8,18 @@
#include <vector>
#include <assert.h>
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
+#pragma GCC diagnostic ignored "-Winvalid-offsetof"
// add example01.cxx code
int globalAddOneToInt(int a);
namespace dummy {
#include "example01.cxx"
+#include "datatypes.cxx"
}
int globalAddOneToInt(int a) {
@@ -36,7 +39,7 @@
const std::vector<std::string>& argtypes,
const std::string& returntype,
EMethodType mtype = kNormal) :
- m_name(name), m_argtypes(argtypes), m_returntype(returntype),
m_type(mtype) {}
+ m_name(name), m_argtypes(argtypes), m_returntype(returntype),
m_type(mtype) {}
std::string m_name;
std::vector<std::string> m_argtypes;
@@ -44,14 +47,28 @@
EMethodType m_type;
};
+struct Cppyy_PseudoDatambrInfo {
+ Cppyy_PseudoDatambrInfo(const std::string& name,
+ const std::string& type,
+ size_t offset, bool isstatic) :
+ m_name(name), m_type(type), m_offset(offset), m_isstatic(isstatic) {}
+
+ std::string m_name;
+ std::string m_type;
+ size_t m_offset;
+ bool m_isstatic;
+};
+
struct Cppyy_PseudoClassInfo {
Cppyy_PseudoClassInfo() {}
Cppyy_PseudoClassInfo(const std::vector<Cppyy_PseudoMethodInfo>& methods,
- long method_offset) :
- m_methods(methods), m_method_offset(method_offset) {}
+ long method_offset,
+ const std::vector<Cppyy_PseudoDatambrInfo>& data) :
+ m_methods(methods), m_method_offset(method_offset), m_datambrs(data) {}
std::vector<Cppyy_PseudoMethodInfo> m_methods;
long m_method_offset;
+ std::vector<Cppyy_PseudoDatambrInfo> m_datambrs;
};
typedef std::map<cppyy_scope_t, Cppyy_PseudoClassInfo> Scopes_t;
@@ -59,10 +76,57 @@
static std::map<std::string, long> s_methods;
+#define PUBLIC_CPPYY_DATA(dmname, dmtype) \
+ data.push_back(Cppyy_PseudoDatambrInfo("m_"#dmname, #dmtype, \
+ offsetof(dummy::cppyy_test_data, m_##dmname), false)); \
+ argtypes.clear(); \
+ methods.push_back(Cppyy_PseudoMethodInfo( \
+ "get_"#dmname, argtypes, #dmtype)); \
+ s_methods["cppyy_test_data::get_"#dmname] = s_method_id++; \
+ argtypes.push_back(#dmtype); \
+ methods.push_back(Cppyy_PseudoMethodInfo( \
+ "set_"#dmname, argtypes, "void")); \
+ s_methods["cppyy_test_data::set_"#dmname] = s_method_id++; \
+ argtypes.clear(); \
+ argtypes.push_back("const "#dmtype"&"); \
+ methods.push_back(Cppyy_PseudoMethodInfo( \
+ "set_"#dmname"_c", argtypes, "void")); \
+ s_methods["cppyy_test_data::set_"#dmname"_c"] = s_method_id++
+
+#define PUBLIC_CPPYY_DATA2(dmname, dmtype) \
+ PUBLIC_CPPYY_DATA(dmname, dmtype); \
+ data.push_back(Cppyy_PseudoDatambrInfo("m_"#dmname"_array", #dmtype"[5]", \
+ offsetof(dummy::cppyy_test_data, m_##dmname##_array), false)); \
+ data.push_back(Cppyy_PseudoDatambrInfo("m_"#dmname"_array2", #dmtype"*", \
+ offsetof(dummy::cppyy_test_data, m_##dmname##_array2), false)); \
+ argtypes.clear(); \
+ methods.push_back(Cppyy_PseudoMethodInfo( \
+ "get_"#dmname"_array", argtypes, #dmtype"*")); \
+ s_methods["cppyy_test_data::get_"#dmname"_array"] = s_method_id++; \
+ methods.push_back(Cppyy_PseudoMethodInfo( \
+ "get_"#dmname"_array2", argtypes, #dmtype"*")); \
+ s_methods["cppyy_test_data::get_"#dmname"_array2"] = s_method_id++
+
+#define PUBLIC_CPPYY_DATA3(dmname, dmtype, key) \
+ PUBLIC_CPPYY_DATA2(dmname, dmtype); \
+ argtypes.push_back(#dmtype"*"); \
+ methods.push_back(Cppyy_PseudoMethodInfo( \
+ "pass_array", argtypes, #dmtype"*")); \
+ s_methods["cppyy_test_data::pass_array_"#dmname] = s_method_id++; \
+ argtypes.clear(); argtypes.push_back("void*"); \
+ methods.push_back(Cppyy_PseudoMethodInfo( \
+ "pass_void_array_"#key, argtypes, #dmtype"*")); \
+ s_methods["cppyy_test_data::pass_void_array_"#key] = s_method_id++
+
+#define PUBLIC_CPPYY_STATIC_DATA(dmname, dmtype) \
+ data.push_back(Cppyy_PseudoDatambrInfo("s_"#dmname, #dmtype, \
+ (size_t)&dummy::cppyy_test_data::s_##dmname, true))
+
+
struct Cppyy_InitPseudoReflectionInfo {
Cppyy_InitPseudoReflectionInfo() {
// class example01 --
- static long s_scope_id = 0;
+ static long s_scope_id = 0;
static long s_method_id = 0;
{ // class example01 --
@@ -184,10 +248,13 @@
methods.push_back(Cppyy_PseudoMethodInfo("copyCyclePayload", argtypes,
"payload"));
s_methods["example01::copyCyclePayload_payload*"] = s_method_id++;
- Cppyy_PseudoClassInfo info(methods, s_method_id - methods.size());
+ Cppyy_PseudoClassInfo info(
+ methods, s_method_id - methods.size(),
std::vector<Cppyy_PseudoDatambrInfo>());
s_scopes[(cppyy_scope_t)s_scope_id] = info;
} // -- class example01
+ //====================================================================
+
{ // class payload --
s_handles["payload"] = (cppyy_scope_t)++s_scope_id;
@@ -210,9 +277,62 @@
methods.push_back(Cppyy_PseudoMethodInfo("setData", argtypes, "void"));
s_methods["payload::setData_double"] = s_method_id++;
- Cppyy_PseudoClassInfo info(methods, s_method_id - methods.size());
+ Cppyy_PseudoClassInfo info(
+ methods, s_method_id - methods.size(),
std::vector<Cppyy_PseudoDatambrInfo>());
s_scopes[(cppyy_scope_t)s_scope_id] = info;
} // -- class payload
+
+ //====================================================================
+
+ { // class cppyy_test_data --
+ s_handles["cppyy_test_data"] = (cppyy_scope_t)++s_scope_id;
+
+ std::vector<Cppyy_PseudoMethodInfo> methods;
+
+ // cppyy_test_data()
+ std::vector<std::string> argtypes;
+ methods.push_back(Cppyy_PseudoMethodInfo("cppyy_test_data", argtypes,
"constructor", kConstructor));
+ s_methods["cppyy_test_data::cppyy_test_data"] = s_method_id++;
+
+ methods.push_back(Cppyy_PseudoMethodInfo("destroy_arrays", argtypes,
"void"));
+ s_methods["cppyy_test_data::destroy_arrays"] = s_method_id++;
+
+ std::vector<Cppyy_PseudoDatambrInfo> data;
+ PUBLIC_CPPYY_DATA2(bool, bool);
+ PUBLIC_CPPYY_DATA (char, char);
+ PUBLIC_CPPYY_DATA (uchar, unsigned char);
+ PUBLIC_CPPYY_DATA3(short, short, h);
+ PUBLIC_CPPYY_DATA3(ushort, unsigned short, H);
+ PUBLIC_CPPYY_DATA3(int, int, i);
+ PUBLIC_CPPYY_DATA3(uint, unsigned int, I);
+ PUBLIC_CPPYY_DATA3(long, long, l);
+ PUBLIC_CPPYY_DATA3(ulong, unsigned long, L);
+ PUBLIC_CPPYY_DATA (llong, long long);
+ PUBLIC_CPPYY_DATA (ullong, unsigned long long);
+ PUBLIC_CPPYY_DATA3(float, float, f);
+ PUBLIC_CPPYY_DATA3(double, double, d);
+ PUBLIC_CPPYY_DATA (enum, cppyy_test_data::what);
+ PUBLIC_CPPYY_DATA (voidp, void*);
+
+ PUBLIC_CPPYY_STATIC_DATA(char, char);
+ PUBLIC_CPPYY_STATIC_DATA(uchar, unsigned char);
+ PUBLIC_CPPYY_STATIC_DATA(short, short);
+ PUBLIC_CPPYY_STATIC_DATA(ushort, unsigned short);
+ PUBLIC_CPPYY_STATIC_DATA(int, int);
+ PUBLIC_CPPYY_STATIC_DATA(uint, unsigned int);
+ PUBLIC_CPPYY_STATIC_DATA(long, long);
+ PUBLIC_CPPYY_STATIC_DATA(ulong, unsigned long);
+ PUBLIC_CPPYY_STATIC_DATA(llong, long long);
+ PUBLIC_CPPYY_STATIC_DATA(ullong, unsigned long long);
+ PUBLIC_CPPYY_STATIC_DATA(float, float);
+ PUBLIC_CPPYY_STATIC_DATA(double, double);
+ PUBLIC_CPPYY_STATIC_DATA(enum, cppyy_test_data::what);
+ PUBLIC_CPPYY_STATIC_DATA(voidp, void*);
+
+ Cppyy_PseudoClassInfo info(methods, s_method_id - methods.size(),
data);
+ s_scopes[(cppyy_scope_t)s_scope_id] = info;
+ } // -- class cppyy_test_data
+
}
} _init;
@@ -254,26 +374,136 @@
/* method/function dispatching -------------------------------------------- */
void cppyy_call_v(cppyy_method_t method, cppyy_object_t self, int nargs, void*
args) {
- switch ((long)method) {
- case 5: // static void example01:;staticSetPayload(payload*
p, double d)
+ long idx = (long)method;
+ if (idx ==
s_methods["static_example01::staticSetPayload_payload*_double"]) {
assert(!self && nargs == 2);
dummy::example01::staticSetPayload((dummy::payload*)(*(long*)&((CPPYY_G__value*)args)[0]),
((CPPYY_G__value*)args)[1].obj.d);
- break;
- case 9: // static void example01::setCount(int)
+ } else if (idx == s_methods["static_example01::setCount_int"]) {
assert(!self && nargs == 1);
dummy::example01::setCount(((CPPYY_G__value*)args)[0].obj.in);
- break;
- case 20: // void example01::setPayload(payload* p);
+ } else if (idx == s_methods["example01::setPayload_payload*"]) {
assert(self && nargs == 1);
((dummy::example01*)self)->setPayload((dummy::payload*)(*(long*)&((CPPYY_G__value*)args)[0]));
- break;
- default:
+ } else if (idx == s_methods["cppyy_test_data::destroy_arrays"]) {
+ assert(self && nargs == 0);
+ ((dummy::cppyy_test_data*)self)->destroy_arrays();
+ } else if (idx == s_methods["cppyy_test_data::set_bool"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_bool((bool)((CPPYY_G__value*)args)[0].obj.in);
+ } else if (idx == s_methods["cppyy_test_data::set_char"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_char(((CPPYY_G__value*)args)[0].obj.ch);
+ } else if (idx == s_methods["cppyy_test_data::set_uchar"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_uchar(((CPPYY_G__value*)args)[0].obj.uch);
+ } else if (idx == s_methods["cppyy_test_data::set_short"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_short(((CPPYY_G__value*)args)[0].obj.sh);
+ } else if (idx == s_methods["cppyy_test_data::set_short_c"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_short_c(*(short*)&((CPPYY_G__value*)args)[0]);
+ } else if (idx == s_methods["cppyy_test_data::set_ushort"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_ushort(((CPPYY_G__value*)args)[0].obj.ush);
+ } else if (idx == s_methods["cppyy_test_data::set_ushort_c"]) {
+ assert(self && nargs == 1);
+ ((dummy::cppyy_test_data*)self)->set_ushort_c(*(unsigned
short*)&((CPPYY_G__value*)args)[0]);
+ } else if (idx == s_methods["cppyy_test_data::set_int"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_int(((CPPYY_G__value*)args)[0].obj.in);
+ } else if (idx == s_methods["cppyy_test_data::set_int_c"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_int_c(*(int*)&((CPPYY_G__value*)args)[0]);
+ } else if (idx == s_methods["cppyy_test_data::set_uint"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_uint(((CPPYY_G__value*)args)[0].obj.uin);
+ } else if (idx == s_methods["cppyy_test_data::set_uint_c"]) {
+ assert(self && nargs == 1);
+ ((dummy::cppyy_test_data*)self)->set_uint_c(*(unsigned
int*)&((CPPYY_G__value*)args)[0]);
+ } else if (idx == s_methods["cppyy_test_data::set_long"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_long(((CPPYY_G__value*)args)[0].obj.i);
+ } else if (idx == s_methods["cppyy_test_data::set_long_c"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_long_c(*(long*)&((CPPYY_G__value*)args)[0]);
+ } else if (idx == s_methods["cppyy_test_data::set_ulong"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_ulong(((CPPYY_G__value*)args)[0].obj.ulo);
+ } else if (idx == s_methods["cppyy_test_data::set_ulong_c"]) {
+ assert(self && nargs == 1);
+ ((dummy::cppyy_test_data*)self)->set_ulong_c(*(unsigned
long*)&((CPPYY_G__value*)args)[0]);
+ } else if (idx == s_methods["cppyy_test_data::set_llong"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_llong(((CPPYY_G__value*)args)[0].obj.ll);
+ } else if (idx == s_methods["cppyy_test_data::set_llong_c"]) {
+ assert(self && nargs == 1);
+ ((dummy::cppyy_test_data*)self)->set_llong_c(*(long
long*)&((CPPYY_G__value*)args)[0]);
+ } else if (idx == s_methods["cppyy_test_data::set_ullong"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_ullong(((CPPYY_G__value*)args)[0].obj.ull);
+ } else if (idx == s_methods["cppyy_test_data::set_ullong_c"]) {
+ assert(self && nargs == 1);
+ ((dummy::cppyy_test_data*)self)->set_ullong_c(*(unsigned
long*)&((CPPYY_G__value*)args)[0]);
+ } else if (idx == s_methods["cppyy_test_data::set_float"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_float(((CPPYY_G__value*)args)[0].obj.fl);
+ } else if (idx == s_methods["cppyy_test_data::set_float_c"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_float_c(*(float*)&((CPPYY_G__value*)args)[0]);
+ } else if (idx == s_methods["cppyy_test_data::set_double"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_double(((CPPYY_G__value*)args)[0].obj.d);
+ } else if (idx == s_methods["cppyy_test_data::set_double_c"]) {
+ assert(self && nargs == 1);
+
((dummy::cppyy_test_data*)self)->set_double_c(*(double*)&((CPPYY_G__value*)args)[0]);
+ } else {
assert(!"method unknown in cppyy_call_v");
- break;
}
}
+unsigned char cppyy_call_b(cppyy_method_t method, cppyy_object_t self, int
nargs, void* args) {
+ unsigned char result = 0;
+ const long idx = (long)method;
+ if (idx == s_methods["cppyy_test_data::get_bool"]) {
+ assert(self && nargs == 0);
+ result = (unsigned char)((dummy::cppyy_test_data*)self)->get_bool();
+ } else {
+ assert(!"method unknown in cppyy_call_b");
+ }
+ return result;
+}
+
+char cppyy_call_c(cppyy_method_t method, cppyy_object_t self, int nargs, void*
args) {
+ char result = 0;
+ const long idx = (long)method;
+ if (idx == s_methods["cppyy_test_data::get_char"]) {
+ assert(self && nargs == 0);
+ result = ((dummy::cppyy_test_data*)self)->get_char();
+ } else if (idx == s_methods["cppyy_test_data::get_uchar"]) {
+ assert(self && nargs == 0);
+ result = (char)((dummy::cppyy_test_data*)self)->get_uchar();
+ } else {
+ assert(!"method unknown in cppyy_call_c");
+ }
+ return result;
+}
+
+short cppyy_call_h(cppyy_method_t method, cppyy_object_t self, int nargs,
void* args) {
+ short result = 0;
+ const long idx = (long)method;
+ if (idx == s_methods["cppyy_test_data::get_short"]) {
+ assert(self && nargs == 0);
+ result = ((dummy::cppyy_test_data*)self)->get_short();
+ } else if (idx == s_methods["cppyy_test_data::get_ushort"]) {
+ assert(self && nargs == 0);
+ result = (short)((dummy::cppyy_test_data*)self)->get_ushort();
+ } else {
+ assert(!"method unknown in cppyy_call_h");
+ }
+ return result;
+}
+
int cppyy_call_i(cppyy_method_t method, cppyy_object_t self, int nargs, void*
args) {
int result = 0;
const long idx = (long)method;
@@ -297,6 +527,9 @@
assert(self && nargs == 1);
result = ((dummy::example01*)self)->addDataToAtoi(
(const char*)(*(long*)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::get_int"]) {
+ assert(self && nargs == 0);
+ result = ((dummy::cppyy_test_data*)self)->get_int();
} else {
assert(!"method unknown in cppyy_call_i");
}
@@ -323,12 +556,154 @@
assert(self && nargs == 1);
result = (long)((dummy::example01*)self)->cyclePayload(
(dummy::payload*)(*(long*)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::get_uint"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_uint();
+ } else if (idx == s_methods["cppyy_test_data::get_long"]) {
+ assert(self && nargs == 0);
+ result = ((dummy::cppyy_test_data*)self)->get_long();
+ } else if (idx == s_methods["cppyy_test_data::get_ulong"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_ulong();
+ } else if (idx == s_methods["cppyy_test_data::get_bool_array"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_bool_array();
+ } else if (idx == s_methods["cppyy_test_data::get_bool_array2"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_bool_array2();
+ } else if (idx == s_methods["cppyy_test_data::get_short_array"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_short_array();
+ } else if (idx == s_methods["cppyy_test_data::get_short_array2"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_short_array2();
+ } else if (idx == s_methods["cppyy_test_data::get_ushort_array"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_ushort_array();
+ } else if (idx == s_methods["cppyy_test_data::get_ushort_array2"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_ushort_array2();
+ } else if (idx == s_methods["cppyy_test_data::get_int_array"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_int_array();
+ } else if (idx == s_methods["cppyy_test_data::get_int_array2"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_int_array2();
+ } else if (idx == s_methods["cppyy_test_data::get_uint_array"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_uint_array();
+ } else if (idx == s_methods["cppyy_test_data::get_uint_array2"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_uint_array2();
+ } else if (idx == s_methods["cppyy_test_data::get_long_array"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_long_array();
+ } else if (idx == s_methods["cppyy_test_data::get_long_array2"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_long_array2();
+ } else if (idx == s_methods["cppyy_test_data::get_ulong_array"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_ulong_array();
+ } else if (idx == s_methods["cppyy_test_data::get_ulong_array2"]) {
+ assert(self && nargs == 0);
+ result = (long)((dummy::cppyy_test_data*)self)->get_ulong_array2();
+ } else if (idx == s_methods["cppyy_test_data::pass_array_short"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_array(
+ (*(short**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_void_array_h"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_void_array_h(
+ (*(short**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_array_ushort"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_array(
+ (*(unsigned short**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_void_array_H"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_void_array_H(
+ (*(unsigned short**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_array_int"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_array(
+ (*(int**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_void_array_i"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_void_array_i(
+ (*(int**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_array_uint"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_array(
+ (*(unsigned int**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_void_array_I"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_void_array_I(
+ (*(unsigned int**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_array_long"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_array(
+ (*(long**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_void_array_l"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_void_array_l(
+ (*(long**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_array_ulong"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_array(
+ (*(unsigned long**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_void_array_L"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_void_array_L(
+ (*(unsigned long**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_array_float"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_array(
+ (*(float**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_void_array_f"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_void_array_f(
+ (*(float**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_array_double"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_array(
+ (*(double**)&((CPPYY_G__value*)args)[0]));
+ } else if (idx == s_methods["cppyy_test_data::pass_void_array_d"]) {
+ assert(self && nargs == 1);
+ result = (long)((dummy::cppyy_test_data*)self)->pass_void_array_d(
+ (*(double**)&((CPPYY_G__value*)args)[0]));
} else {
assert(!"method unknown in cppyy_call_l");
}
return result;
}
+long long cppyy_call_ll(cppyy_method_t method, cppyy_object_t self, int nargs,
void* args) {
+ long long result = 0;
+ const long idx = (long)method;
+ if (idx == s_methods["cppyy_test_data::get_llong"]) {
+ assert(self && nargs == 0);
+ result = ((dummy::cppyy_test_data*)self)->get_llong();
+ } else if (idx == s_methods["cppyy_test_data::get_ullong"]) {
+ assert(self && nargs == 0);
+ result = (long long)((dummy::cppyy_test_data*)self)->get_ullong();
+ } else {
+ assert(!"method unknown in cppyy_call_ll");
+ }
+ return result;
+}
+
+float cppyy_call_f(cppyy_method_t method, cppyy_object_t self, int nargs,
void* args) {
+ float result = 0;
+ const long idx = (long)method;
+ if (idx == s_methods["cppyy_test_data::get_float"]) {
+ assert(self && nargs == 0);
+ result = ((dummy::cppyy_test_data*)self)->get_float();
+ } else {
+ assert(!"method unknown in cppyy_call_f");
+ }
+ return result;
+}
+
double cppyy_call_d(cppyy_method_t method, cppyy_object_t self, int nargs,
void* args) {
double result = 0.;
const long idx = (long)method;
@@ -341,6 +716,9 @@
} else if (idx == s_methods["payload::getData"]) {
assert(self && nargs == 0);
result = ((dummy::payload*)self)->getData();
+ } else if (idx == s_methods["cppyy_test_data::get_double"]) {
+ assert(self && nargs == 0);
+ result = ((dummy::cppyy_test_data*)self)->get_double();
} else {
assert(!"method unknown in cppyy_call_d");
}
@@ -369,8 +747,12 @@
assert(nargs == 1);
result = new dummy::example01(((CPPYY_G__value*)args)[0].obj.in);
} else if (idx == s_methods["payload::payload_double"]) {
+ assert(nargs == 0 || nargs == 1);
if (nargs == 0) result = new dummy::payload;
else if (nargs == 1) result = new
dummy::payload(((CPPYY_G__value*)args)[0].obj.d);
+ } else if (idx == s_methods["cppyy_test_data::cppyy_test_data"]) {
+ assert(nargs == 0);
+ result = new dummy::cppyy_test_data;
} else {
assert(!"method unknown in cppyy_constructor");
}
@@ -506,8 +888,30 @@
/* data member reflection information ------------------------------------- */
-int cppyy_num_datamembers(cppyy_scope_t /* handle */) {
- return 0;
+int cppyy_num_datamembers(cppyy_scope_t handle) {
+ return s_scopes[handle].m_datambrs.size();
+}
+
+char* cppyy_datamember_name(cppyy_scope_t handle, int idatambr) {
+ return cppstring_to_cstring(s_scopes[handle].m_datambrs[idatambr].m_name);
+}
+
+char* cppyy_datamember_type(cppyy_scope_t handle, int idatambr) {
+ return cppstring_to_cstring(s_scopes[handle].m_datambrs[idatambr].m_type);
+}
+
+size_t cppyy_datamember_offset(cppyy_scope_t handle, int idatambr) {
+ return s_scopes[handle].m_datambrs[idatambr].m_offset;
+}
+
+
+/* data member properties ------------------------------------------------ */
+int cppyy_is_publicdata(cppyy_scope_t handle, int idatambr) {
+ return 1;
+}
+
+int cppyy_is_staticdata(cppyy_scope_t handle, int idatambr) {
+ return s_scopes[handle].m_datambrs[idatambr].m_isstatic;
}
diff --git a/pypy/module/cppyy/test/conftest.py
b/pypy/module/cppyy/test/conftest.py
--- a/pypy/module/cppyy/test/conftest.py
+++ b/pypy/module/cppyy/test/conftest.py
@@ -7,14 +7,18 @@
if 'dummy' in lcapi.reflection_library:
# run only tests that are covered by the dummy backend and tests
# that do not rely on reflex
- if not ('test_helper.py' in item.location[0] or \
- 'test_cppyy.py' in item.location[0] or \
- 'test_pythonify.py' in item.location[0]):
+ import os
+ tst = os.path.basename(item.location[0])
+ if not tst in ('test_helper.py', 'test_cppyy.py',
'test_pythonify.py',
+ 'test_datatypes.py'):
py.test.skip("genreflex is not installed")
import re
- if 'test_pythonify.py' in item.location[0] and \
+ if tst == 'test_pythonify.py' and \
not re.search("AppTestPYTHONIFY.test0[1-6]", item.location[2]):
py.test.skip("genreflex is not installed")
+ elif tst == 'test_datatypes.py' and \
+ not re.search("AppTestDATATYPES.test0[1-8]", item.location[2]):
+ py.test.skip("genreflex is not installed")
def pytest_ignore_collect(path, config):
if py.path.local.sysfind('genreflex') is None and
config.option.runappdirect:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit