Author: Wim Lavrijsen <wlavrij...@lbl.gov>
Branch: cppyy-packaging
Changeset: r94738:9820fab951d5
Date: 2018-06-07 15:57 -0700
http://bitbucket.org/pypy/pypy/changeset/9820fab951d5/

Log:    bring the dummy backend for testing up-to-date

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
@@ -68,9 +68,11 @@
         pass
     # array type
     try:
+        if hasattr(space, "fake"):
+            raise NotImplementedError
         arr = space.interp_w(W_ArrayInstance, w_obj, can_be_None=True)
-        #if arr:
-            #return rffi.cast(rffi.VOIDP, space.uint_w(arr.getbuffer(space)))
+        if arr:
+            return rffi.cast(rffi.VOIDP, space.uint_w(arr.getbuffer(space)))
     except Exception:
         pass
     # pre-defined nullptr
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
@@ -60,7 +60,6 @@
                            const std::string& returntype,
                            EMethodType mtype = kNormal) :
         m_name(name), m_argtypes(argtypes), m_returntype(returntype), 
m_type(mtype) {}
-
     std::string m_name;
     std::vector<std::string> m_argtypes;
     std::string m_returntype;
@@ -72,7 +71,6 @@
                             const std::string& type,
                             ptrdiff_t offset, bool isstatic) :
         m_name(name), m_type(type), m_offset(offset), m_isstatic(isstatic) {}
-
     std::string m_name;
     std::string m_type;
     ptrdiff_t m_offset;
@@ -81,20 +79,20 @@
 
 struct Cppyy_PseudoClassInfo {
     Cppyy_PseudoClassInfo() {}
-    Cppyy_PseudoClassInfo(const std::vector<Cppyy_PseudoMethodInfo>& methods,
-                          long method_offset,
+    Cppyy_PseudoClassInfo(const std::vector<Cppyy_PseudoMethodInfo*>& methods,
                           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;
+        m_methods(methods), m_datambrs(data) {}
+    std::vector<Cppyy_PseudoMethodInfo*> m_methods;
     std::vector<Cppyy_PseudoDatambrInfo> m_datambrs;
 };
 
 typedef std::map<cppyy_scope_t, Cppyy_PseudoClassInfo> Scopes_t;
 static Scopes_t s_scopes;
 
-static std::map<std::string, long> s_methods;
+static std::map<std::string, Cppyy_PseudoMethodInfo*> s_methods;
+struct CleanPseudoMethods {
+    ~CleanPseudoMethods() { for (auto& x : s_methods) delete x.second; }
+} _clean;
 
 int Pseudo_kNothing   = 6;
 int Pseudo_kSomething = 111;
@@ -105,28 +103,28 @@
         offsetof(dummy::CppyyTestData, m_##dmname), false));                  \
     /* <type> get_<type>() */                                                 \
     argtypes.clear();                                                         \
-    methods.push_back(Cppyy_PseudoMethodInfo(                                 \
+    methods.push_back(new Cppyy_PseudoMethodInfo(                             \
                          "get_"#dmname, argtypes, #dmtype));                  \
-    s_methods["CppyyTestData::get_"#dmname] = s_method_id++;                  \
+    s_methods["CppyyTestData::get_"#dmname] = methods.back();                 \
     /* <type>& get_<type>_r() */                                              \
-    methods.push_back(Cppyy_PseudoMethodInfo(                                 \
+    methods.push_back(new Cppyy_PseudoMethodInfo(                             \
                          "get_"#dmname"_r", argtypes, #dmtype"&"));           \
-    s_methods["CppyyTestData::get_"#dmname"_r"] = s_method_id++;              \
+    s_methods["CppyyTestData::get_"#dmname"_r"] = methods.back();             \
     /* const <type>& get_<type>_cr() */                                       \
-    methods.push_back(Cppyy_PseudoMethodInfo(                                 \
+    methods.push_back(new Cppyy_PseudoMethodInfo(                             \
                          "get_"#dmname"_cr", argtypes, "const "#dmtype"&"));  \
-    s_methods["CppyyTestData::get_"#dmname"_cr"] = s_method_id++;             \
+    s_methods["CppyyTestData::get_"#dmname"_cr"] = methods.back();            \
     /* void set_<type>(<type>) */                                             \
     argtypes.push_back(#dmtype);                                              \
-    methods.push_back(Cppyy_PseudoMethodInfo(                                 \
+    methods.push_back(new Cppyy_PseudoMethodInfo(                             \
                          "set_"#dmname, argtypes, "void"));                   \
-    s_methods["CppyyTestData::set_"#dmname] = s_method_id++;                  \
+    s_methods["CppyyTestData::set_"#dmname] = methods.back();                 \
     argtypes.clear();                                                         \
     /* void set_<type>(const <type>&) */                                      \
     argtypes.push_back("const "#dmtype"&");                                   \
-    methods.push_back(Cppyy_PseudoMethodInfo(                                 \
+    methods.push_back(new Cppyy_PseudoMethodInfo(                             \
                          "set_"#dmname"_cr", argtypes, "void"));              \
-    s_methods["CppyyTestData::set_"#dmname"_cr"] = s_method_id++
+    s_methods["CppyyTestData::set_"#dmname"_cr"] = methods.back()
 
 #define PUBLIC_CPPYY_DATA2(dmname, dmtype)                                    \
     PUBLIC_CPPYY_DATA(dmname, dmtype);                                        \
@@ -135,23 +133,23 @@
     data.push_back(Cppyy_PseudoDatambrInfo("m_"#dmname"_array2", #dmtype"*",  \
         offsetof(dummy::CppyyTestData, m_##dmname##_array2), false));         \
     argtypes.clear();                                                         \
-    methods.push_back(Cppyy_PseudoMethodInfo(                                 \
+    methods.push_back(new Cppyy_PseudoMethodInfo(                             \
                          "get_"#dmname"_array", argtypes, #dmtype"*"));       \
-    s_methods["CppyyTestData::get_"#dmname"_array"] = s_method_id++;          \
-    methods.push_back(Cppyy_PseudoMethodInfo(                                 \
+    s_methods["CppyyTestData::get_"#dmname"_array"] = methods.back();         \
+    methods.push_back(new Cppyy_PseudoMethodInfo(                             \
                          "get_"#dmname"_array2", argtypes, #dmtype"*"));      \
-    s_methods["CppyyTestData::get_"#dmname"_array2"] = s_method_id++
+    s_methods["CppyyTestData::get_"#dmname"_array2"] = methods.back()
 
 #define PUBLIC_CPPYY_DATA3(dmname, dmtype, key)                               \
     PUBLIC_CPPYY_DATA2(dmname, dmtype);                                       \
     argtypes.push_back(#dmtype"*");                                           \
-    methods.push_back(Cppyy_PseudoMethodInfo(                                 \
+    methods.push_back(new Cppyy_PseudoMethodInfo(                             \
                          "pass_array", argtypes, #dmtype"*"));                \
-    s_methods["CppyyTestData::pass_array_"#dmname] = s_method_id++;           \
+    s_methods["CppyyTestData::pass_array_"#dmname] = methods.back();          \
     argtypes.clear(); argtypes.push_back("void*");                            \
-    methods.push_back(Cppyy_PseudoMethodInfo(                                 \
+    methods.push_back(new Cppyy_PseudoMethodInfo(                             \
                          "pass_void_array_"#key, argtypes, #dmtype"*"));      \
-    s_methods["CppyyTestData::pass_void_array_"#key] = s_method_id++
+    s_methods["CppyyTestData::pass_void_array_"#key] = methods.back()
 
 #define PUBLIC_CPPYY_STATIC_DATA(dmname, dmtype)                              \
     data.push_back(Cppyy_PseudoDatambrInfo("s_"#dmname, #dmtype,              \
@@ -162,7 +160,6 @@
     Cppyy_InitPseudoReflectionInfo() {
         // class example01 --
         static long s_scope_id  = 0;
-        static long s_method_id = 0;
 
         { // namespace ''
         s_handles[""] = (cppyy_scope_t)++s_scope_id;
@@ -175,33 +172,33 @@
         { // class example01 --
         s_handles["example01"] = (cppyy_scope_t)++s_scope_id;
 
-        std::vector<Cppyy_PseudoMethodInfo> methods;
+        std::vector<Cppyy_PseudoMethodInfo*> methods;
 
         // static double staticAddToDouble(double a)
         std::vector<std::string> argtypes;
         argtypes.push_back("double");
-        methods.push_back(Cppyy_PseudoMethodInfo("staticAddToDouble", 
argtypes, "double", kStatic));
-        s_methods["static_example01::staticAddToDouble_double"] = 
s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("staticAddToDouble", 
argtypes, "double", kStatic));
+        s_methods["static_example01::staticAddToDouble_double"] = 
methods.back();
 
         // static int staticAddOneToInt(int a)
         // static int staticAddOneToInt(int a, int b)
         argtypes.clear();
         argtypes.push_back("int");
-        methods.push_back(Cppyy_PseudoMethodInfo("staticAddOneToInt", 
argtypes, "int", kStatic));
-        s_methods["static_example01::staticAddOneToInt_int"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("staticAddOneToInt", 
argtypes, "int", kStatic));
+        s_methods["static_example01::staticAddOneToInt_int"] = methods.back();
         argtypes.push_back("int");
-        methods.push_back(Cppyy_PseudoMethodInfo("staticAddOneToInt", 
argtypes, "int", kStatic));
-        s_methods["static_example01::staticAddOneToInt_int_int"] = 
s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("staticAddOneToInt", 
argtypes, "int", kStatic));
+        s_methods["static_example01::staticAddOneToInt_int_int"] = 
methods.back();
 
         // static int staticAtoi(const char* str)
         argtypes.clear();
         argtypes.push_back("const char*");
-        methods.push_back(Cppyy_PseudoMethodInfo("staticAtoi", argtypes, 
"int", kStatic));
-        s_methods["static_example01::staticAtoi_cchar*"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("staticAtoi", argtypes, 
"int", kStatic));
+        s_methods["static_example01::staticAtoi_cchar*"] = methods.back();
 
         // static char* staticStrcpy(const char* strin)
-        methods.push_back(Cppyy_PseudoMethodInfo("staticStrcpy", argtypes, 
"char*", kStatic));
-        s_methods["static_example01::staticStrcpy_cchar*"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("staticStrcpy", argtypes, 
"char*", kStatic));
+        s_methods["static_example01::staticStrcpy_cchar*"] = methods.back();
 
         // static void staticSetPayload(payload* p, double d)
         // static payload* staticCyclePayload(payload* p, double d)
@@ -209,90 +206,89 @@
         argtypes.clear();
         argtypes.push_back("payload*");
         argtypes.push_back("double");
-        methods.push_back(Cppyy_PseudoMethodInfo("staticSetPayload", argtypes, 
"void", kStatic));
-        s_methods["static_example01::staticSetPayload_payload*_double"] = 
s_method_id++;
-        methods.push_back(Cppyy_PseudoMethodInfo("staticCyclePayload", 
argtypes, "payload*", kStatic));
-        s_methods["static_example01::staticCyclePayload_payload*_double"] = 
s_method_id++;
-        methods.push_back(Cppyy_PseudoMethodInfo("staticCopyCyclePayload", 
argtypes, "payload", kStatic));
-        s_methods["static_example01::staticCopyCyclePayload_payload*_double"] 
= s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("staticSetPayload", 
argtypes, "void", kStatic));
+        s_methods["static_example01::staticSetPayload_payload*_double"] = 
methods.back();
+        methods.push_back(new Cppyy_PseudoMethodInfo("staticCyclePayload", 
argtypes, "payload*", kStatic));
+        s_methods["static_example01::staticCyclePayload_payload*_double"] = 
methods.back();
+        methods.push_back(new Cppyy_PseudoMethodInfo("staticCopyCyclePayload", 
argtypes, "payload", kStatic));
+        s_methods["static_example01::staticCopyCyclePayload_payload*_double"] 
= methods.back();
 
         // static int getCount()
         // static void setCount(int)
         argtypes.clear();
-        methods.push_back(Cppyy_PseudoMethodInfo("getCount", argtypes, "int", 
kStatic));
-        s_methods["static_example01::getCount"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("getCount", argtypes, 
"int", kStatic));
+        s_methods["static_example01::getCount"] = methods.back();
         argtypes.push_back("int");
-        methods.push_back(Cppyy_PseudoMethodInfo("setCount", argtypes, "void", 
kStatic));
-        s_methods["static_example01::setCount_int"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("setCount", argtypes, 
"void", kStatic));
+        s_methods["static_example01::setCount_int"] = methods.back();
 
         // example01()
         // example01(int a)
         argtypes.clear();
-        methods.push_back(Cppyy_PseudoMethodInfo("example01", argtypes, 
"constructor", kConstructor));
-        s_methods["example01::example01"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("example01", argtypes, 
"constructor", kConstructor));
+        s_methods["example01::example01"] = methods.back();
         argtypes.push_back("int");
-        methods.push_back(Cppyy_PseudoMethodInfo("example01", argtypes, 
"constructor", kConstructor));
-        s_methods["example01::example01_int"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("example01", argtypes, 
"constructor", kConstructor));
+        s_methods["example01::example01_int"] = methods.back();
 
         // int addDataToInt(int a)
         argtypes.clear();
         argtypes.push_back("int");
-        methods.push_back(Cppyy_PseudoMethodInfo("addDataToInt", argtypes, 
"int"));
-        s_methods["example01::addDataToInt_int"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("addDataToInt", argtypes, 
"int"));
+        s_methods["example01::addDataToInt_int"] = methods.back();
 
         // int addDataToIntConstRef(const int& a)
         argtypes.clear();
         argtypes.push_back("const int&");
-        methods.push_back(Cppyy_PseudoMethodInfo("addDataToIntConstRef", 
argtypes, "int"));
-        s_methods["example01::addDataToIntConstRef_cint&"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("addDataToIntConstRef", 
argtypes, "int"));
+        s_methods["example01::addDataToIntConstRef_cint&"] = methods.back();
 
         // int overloadedAddDataToInt(int a, int b)
         argtypes.clear();
         argtypes.push_back("int");
         argtypes.push_back("int");
-        methods.push_back(Cppyy_PseudoMethodInfo("overloadedAddDataToInt", 
argtypes, "int"));
-        s_methods["example01::overloadedAddDataToInt_int_int"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("overloadedAddDataToInt", 
argtypes, "int"));
+        s_methods["example01::overloadedAddDataToInt_int_int"] = 
methods.back();
 
         // int overloadedAddDataToInt(int a)
         // int overloadedAddDataToInt(int a, int b, int c)
         argtypes.clear();
         argtypes.push_back("int");
-        methods.push_back(Cppyy_PseudoMethodInfo("overloadedAddDataToInt", 
argtypes, "int"));
-        s_methods["example01::overloadedAddDataToInt_int"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("overloadedAddDataToInt", 
argtypes, "int"));
+        s_methods["example01::overloadedAddDataToInt_int"] = methods.back();
         argtypes.push_back("int");
         argtypes.push_back("int");
-        methods.push_back(Cppyy_PseudoMethodInfo("overloadedAddDataToInt", 
argtypes, "int"));
-        s_methods["example01::overloadedAddDataToInt_int_int_int"] = 
s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("overloadedAddDataToInt", 
argtypes, "int"));
+        s_methods["example01::overloadedAddDataToInt_int_int_int"] = 
methods.back();
 
         // double addDataToDouble(double a)
         argtypes.clear();
         argtypes.push_back("double");
-        methods.push_back(Cppyy_PseudoMethodInfo("addDataToDouble", argtypes, 
"double"));
-        s_methods["example01::addDataToDouble_double"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("addDataToDouble", 
argtypes, "double"));
+        s_methods["example01::addDataToDouble_double"] = methods.back();
 
         // int addDataToAtoi(const char* str)
         // char* addToStringValue(const char* str)
         argtypes.clear();
         argtypes.push_back("const char*");
-        methods.push_back(Cppyy_PseudoMethodInfo("addDataToAtoi", argtypes, 
"int"));
-        s_methods["example01::addDataToAtoi_cchar*"] = s_method_id++;
-        methods.push_back(Cppyy_PseudoMethodInfo("addToStringValue", argtypes, 
"char*"));
-        s_methods["example01::addToStringValue_cchar*"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("addDataToAtoi", 
argtypes, "int"));
+        s_methods["example01::addDataToAtoi_cchar*"] = methods.back();
+        methods.push_back(new Cppyy_PseudoMethodInfo("addToStringValue", 
argtypes, "char*"));
+        s_methods["example01::addToStringValue_cchar*"] = methods.back();
 
         // void setPayload(payload* p)
         // payload* cyclePayload(payload* p)
         // payload copyCyclePayload(payload* p)
         argtypes.clear();
         argtypes.push_back("payload*");
-        methods.push_back(Cppyy_PseudoMethodInfo("setPayload", argtypes, 
"void"));
-        s_methods["example01::setPayload_payload*"] = s_method_id++;
-        methods.push_back(Cppyy_PseudoMethodInfo("cyclePayload", argtypes, 
"payload*"));
-        s_methods["example01::cyclePayload_payload*"] = s_method_id++;
-        methods.push_back(Cppyy_PseudoMethodInfo("copyCyclePayload", argtypes, 
"payload"));
-        s_methods["example01::copyCyclePayload_payload*"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("setPayload", argtypes, 
"void"));
+        s_methods["example01::setPayload_payload*"] = methods.back();
+        methods.push_back(new Cppyy_PseudoMethodInfo("cyclePayload", argtypes, 
"payload*"));
+        s_methods["example01::cyclePayload_payload*"] = methods.back();
+        methods.push_back(new Cppyy_PseudoMethodInfo("copyCyclePayload", 
argtypes, "payload"));
+        s_methods["example01::copyCyclePayload_payload*"] = methods.back();
 
-        Cppyy_PseudoClassInfo info(
-            methods, s_method_id - methods.size(), 
std::vector<Cppyy_PseudoDatambrInfo>());
+        Cppyy_PseudoClassInfo info(methods, 
std::vector<Cppyy_PseudoDatambrInfo>());
         s_scopes[(cppyy_scope_t)s_scope_id] = info;
         } // -- class example01
 
@@ -301,27 +297,26 @@
         { // class payload --
         s_handles["payload"] = (cppyy_scope_t)++s_scope_id;
 
-        std::vector<Cppyy_PseudoMethodInfo> methods;
+        std::vector<Cppyy_PseudoMethodInfo*> methods;
 
         // payload(double d = 0.)
         std::vector<std::string> argtypes;
         argtypes.push_back("double");
-        methods.push_back(Cppyy_PseudoMethodInfo("payload", argtypes, 
"constructor", kConstructor));
-        s_methods["payload::payload_double"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("payload", argtypes, 
"constructor", kConstructor));
+        s_methods["payload::payload_double"] = methods.back();
 
         // double getData()
         argtypes.clear();
-        methods.push_back(Cppyy_PseudoMethodInfo("getData", argtypes, 
"double"));
-        s_methods["payload::getData"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("getData", argtypes, 
"double"));
+        s_methods["payload::getData"] = methods.back();
 
         // void setData(double d)
         argtypes.clear();
         argtypes.push_back("double");
-        methods.push_back(Cppyy_PseudoMethodInfo("setData", argtypes, "void"));
-        s_methods["payload::setData_double"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("setData", argtypes, 
"void"));
+        s_methods["payload::setData_double"] = methods.back();
 
-        Cppyy_PseudoClassInfo info(
-            methods, s_method_id - methods.size(), 
std::vector<Cppyy_PseudoDatambrInfo>());
+        Cppyy_PseudoClassInfo info(methods, 
std::vector<Cppyy_PseudoDatambrInfo>());
         s_scopes[(cppyy_scope_t)s_scope_id] = info;
         } // -- class payload
 
@@ -330,21 +325,21 @@
         { // class CppyyTestData --
         s_handles["CppyyTestData"] = (cppyy_scope_t)++s_scope_id;
 
-        std::vector<Cppyy_PseudoMethodInfo> methods;
+        std::vector<Cppyy_PseudoMethodInfo*> methods;
 
         // CppyyTestData()
         std::vector<std::string> argtypes;
-        methods.push_back(Cppyy_PseudoMethodInfo("CppyyTestData", argtypes, 
"constructor", kConstructor));
-        s_methods["CppyyTestData::CppyyTestData"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("CppyyTestData", 
argtypes, "constructor", kConstructor));
+        s_methods["CppyyTestData::CppyyTestData"] = methods.back();
 
-        methods.push_back(Cppyy_PseudoMethodInfo("destroy_arrays", argtypes, 
"void"));
-        s_methods["CppyyTestData::destroy_arrays"] = s_method_id++;
+        methods.push_back(new Cppyy_PseudoMethodInfo("destroy_arrays", 
argtypes, "void"));
+        s_methods["CppyyTestData::destroy_arrays"] = methods.back();
 
         std::vector<Cppyy_PseudoDatambrInfo> data;
         PUBLIC_CPPYY_DATA2(bool,    bool);
         PUBLIC_CPPYY_DATA (char,    char);
         PUBLIC_CPPYY_DATA (schar,   signed char);
-        PUBLIC_CPPYY_DATA (uchar,   unsigned char);
+        PUBLIC_CPPYY_DATA2(uchar,   unsigned char);
         PUBLIC_CPPYY_DATA3(short,   short,              h);
         PUBLIC_CPPYY_DATA3(ushort,  unsigned short,     H);
         PUBLIC_CPPYY_DATA3(int,     int,                i);
@@ -389,7 +384,7 @@
         data.push_back(Cppyy_PseudoDatambrInfo(
             "kLots", "CppyyTestData::EWhat", (ptrdiff_t)&Pseudo_kLots, true));
 
-        Cppyy_PseudoClassInfo info(methods, s_method_id - methods.size(), 
data);
+        Cppyy_PseudoClassInfo info(methods, data);
         s_scopes[(cppyy_scope_t)s_scope_id] = info;
         } // -- class CppyyTest_data
 
@@ -432,7 +427,7 @@
 
 /* method/function dispatching -------------------------------------------- */
 void cppyy_call_v(cppyy_method_t method, cppyy_object_t self, int nargs, void* 
args) {
-    long idx = (long)method;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)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]),
@@ -522,7 +517,7 @@
 
 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;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (idx == s_methods["CppyyTestData::get_bool"]) {
         assert(self && nargs == 0);
         result = (unsigned char)((dummy::CppyyTestData*)self)->get_bool();
@@ -534,7 +529,7 @@
 
 char cppyy_call_c(cppyy_method_t method, cppyy_object_t self, int nargs, void* 
args) {
     char result = 0;
-    const long idx = (long)method;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (idx == s_methods["CppyyTestData::get_char"]) {
         assert(self && nargs == 0);
         result = ((dummy::CppyyTestData*)self)->get_char();
@@ -549,7 +544,7 @@
 
 short cppyy_call_h(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args) {
     short result = 0;
-    const long idx = (long)method; 
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (idx == s_methods["CppyyTestData::get_short"]) {
         assert(self && nargs == 0);
         result = ((dummy::CppyyTestData*)self)->get_short();
@@ -564,7 +559,7 @@
 
 int cppyy_call_i(cppyy_method_t method, cppyy_object_t self, int nargs, void* 
args) {
     int result = 0;
-    const long idx = (long)method;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (idx == s_methods["static_example01::staticAddOneToInt_int"]) {
         assert(!self && nargs == 1);
         result = 
dummy::example01::staticAddOneToInt(((CPPYY_G__value*)args)[0].obj.in);
@@ -596,7 +591,7 @@
 
 long cppyy_call_l(cppyy_method_t method, cppyy_object_t self, int nargs, void* 
args) {
     long result = 0;
-    const long idx = (long)method;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (idx == s_methods["static_example01::staticStrcpy_cchar*"]) {
         assert(!self && nargs == 1);
         result = (long)dummy::example01::staticStrcpy(
@@ -629,6 +624,12 @@
     } else if (idx == s_methods["CppyyTestData::get_bool_array2"]) {
         assert(self && nargs == 0);
         result = (long)((dummy::CppyyTestData*)self)->get_bool_array2();
+    } else if (idx == s_methods["CppyyTestData::get_uchar_array"]) {
+        assert(self && nargs == 0);
+        result = (long)((dummy::CppyyTestData*)self)->get_uchar_array();
+    } else if (idx == s_methods["CppyyTestData::get_uchar_array2"]) {
+        assert(self && nargs == 0);
+        result = (long)((dummy::CppyyTestData*)self)->get_uchar_array2();
     } else if (idx == s_methods["CppyyTestData::get_short_array"]) {
         assert(self && nargs == 0);
         result = (long)((dummy::CppyyTestData*)self)->get_short_array();
@@ -737,7 +738,7 @@
 
 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;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (idx == s_methods["CppyyTestData::get_llong"]) {
         assert(self && nargs == 0);
         result = ((dummy::CppyyTestData*)self)->get_llong();
@@ -752,7 +753,7 @@
 
 float cppyy_call_f(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args) {
     float result = 0;
-    const long idx = (long)method;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (idx == s_methods["CppyyTestData::get_float"]) {
         assert(self && nargs == 0);
         result = ((dummy::CppyyTestData*)self)->get_float();
@@ -764,7 +765,7 @@
 
 double cppyy_call_d(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args) {
     double result = 0.;
-    const long idx = (long)method;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (idx == s_methods["static_example01::staticAddToDouble_double"]) {
         assert(!self && nargs == 1);
         result = 
dummy::example01::staticAddToDouble(((CPPYY_G__value*)args)[0].obj.d);
@@ -794,7 +795,7 @@
 
 void* cppyy_call_r(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args) {
     void* result = nullptr;
-    const long idx = (long)method;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (0) {}
     DISPATCH_CALL_R_GET(bool)
     DISPATCH_CALL_R_GET(short)
@@ -818,7 +819,7 @@
 
 char* cppyy_call_s(cppyy_method_t method, cppyy_object_t self, int nargs, 
void* args, size_t* /* length */) {
     char* result = 0;
-    const long idx = (long)method;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (idx == s_methods["static_example01::staticStrcpy_cchar*"]) {
         assert(!self && nargs == 1);
         result = dummy::example01::staticStrcpy((const 
char*)(*(long*)&((CPPYY_G__value*)args)[0]));
@@ -830,7 +831,7 @@
 
 cppyy_object_t cppyy_constructor(cppyy_method_t method, cppyy_type_t handle, 
int nargs, void* args) {
     void* result = 0;
-    const long idx = (long)method;
+    Cppyy_PseudoMethodInfo* idx = (Cppyy_PseudoMethodInfo*)method;
     if (idx == s_methods["example01::example01"]) {
         assert(nargs == 0);
         result = new dummy::example01;
@@ -850,11 +851,7 @@
     return (cppyy_object_t)result;
 }
 
-cppyy_funcaddr_t cppyy_function_address_from_index(cppyy_scope_t /* scope */, 
cppyy_index_t /* idx */) {
-    return (cppyy_funcaddr_t)0;
-}
-
-cppyy_funcaddr_t cppyy_function_address_from_method(cppyy_method_t /* method 
*/) {
+cppyy_funcaddr_t cppyy_function_address(cppyy_method_t /* method */) {
     return (cppyy_funcaddr_t)0;
 }
 
@@ -922,12 +919,15 @@
    return 0;
 }
 
+int cppyy_smartptr_info(const char* name, cppyy_type_t* raw, cppyy_method_t* 
deref) {
+   return 0;
+}
+
 
 /* method/function reflection information --------------------------------- */
-cppyy_method_t cppyy_get_method(cppyy_scope_t handle, cppyy_index_t 
method_index) {
+cppyy_method_t cppyy_get_method(cppyy_scope_t handle, cppyy_index_t idx) {
     if (s_scopes.find(handle) != s_scopes.end()) {
-        long id = s_scopes[handle].m_method_offset + (long)method_index;
-        return (cppyy_method_t)id;
+        return (cppyy_method_t)s_scopes[handle].m_methods[idx];
     }
     assert(!"unknown class in cppyy_get_method");
     return (cppyy_method_t)0;
@@ -937,24 +937,24 @@
     return s_scopes[handle].m_methods.size();
 }
 
-char* cppyy_method_name(cppyy_scope_t handle, cppyy_index_t method_index) {
-    return 
cppstring_to_cstring(s_scopes[handle].m_methods[(int)method_index].m_name);
+char* cppyy_method_name(cppyy_method_t method) {
+    return cppstring_to_cstring(((Cppyy_PseudoMethodInfo*)method)->m_name);
 }
 
-char* cppyy_method_result_type(cppyy_scope_t handle, cppyy_index_t 
method_index) {
-    return 
cppstring_to_cstring(s_scopes[handle].m_methods[method_index].m_returntype);
+char* cppyy_method_result_type(cppyy_method_t method) {
+    return 
cppstring_to_cstring(((Cppyy_PseudoMethodInfo*)method)->m_returntype);
 }
     
-int cppyy_method_num_args(cppyy_scope_t handle, cppyy_index_t method_index) {
-    return s_scopes[handle].m_methods[method_index].m_argtypes.size();
+int cppyy_method_num_args(cppyy_method_t method) {
+    return ((Cppyy_PseudoMethodInfo*)method)->m_argtypes.size();
 }
 
-int cppyy_method_req_args(cppyy_scope_t handle, cppyy_index_t method_index) {
-    return cppyy_method_num_args(handle, method_index);
+int cppyy_method_req_args(cppyy_method_t method) {
+    return cppyy_method_num_args(method);
 }
 
-char* cppyy_method_arg_type(cppyy_scope_t handle, cppyy_index_t method_index, 
int arg_index) {
-    return 
cppstring_to_cstring(s_scopes[handle].m_methods[method_index].m_argtypes[arg_index]);
+char* cppyy_method_arg_type(cppyy_method_t method, int idx) {
+    return 
cppstring_to_cstring(((Cppyy_PseudoMethodInfo*)method)->m_argtypes[idx]);
 }
 
 char* cppyy_method_arg_default(cppyy_method_t, int /* arg_index */) {
@@ -969,6 +969,10 @@
     return cppstring_to_cstring("");
 }
 
+int cppyy_exists_method_template(cppyy_scope_t scope, const char* name) {
+    return 0;
+}
+
 int cppyy_method_is_template(cppyy_scope_t /* handle */, cppyy_index_t /* 
method_index */) {
     return 0;
 }
@@ -980,24 +984,24 @@
 
 
 /* method properties -----------------------------------------------------  */
-int cppyy_is_publicmethod(cppyy_type_t /* handle */, cppyy_index_t /* 
method_index */) {
+int cppyy_is_publicmethod(cppyy_method_t) {
     return 1;
 }
 
-int cppyy_is_constructor(cppyy_type_t handle, cppyy_index_t method_index) {
-    if (s_scopes.find(handle) != s_scopes.end())
-        return s_scopes[handle].m_methods[method_index].m_type == kConstructor;
+int cppyy_is_constructor(cppyy_method_t method) {
+    if (method)
+        return ((Cppyy_PseudoMethodInfo*)method)->m_type == kConstructor;
     assert(!"unknown class in cppyy_is_constructor");
     return 0;
 }
 
-int cppyy_is_destructor(cppyy_type_t /* handle */, cppyy_index_t /* 
method_index */) {
+int cppyy_is_destructor(cppyy_method_t) {
     return 0;
 }
 
-int cppyy_is_staticmethod(cppyy_type_t handle, cppyy_index_t method_index) {
-    if (s_scopes.find(handle) != s_scopes.end())
-        return s_scopes[handle].m_methods[method_index].m_type == kStatic;
+int cppyy_is_staticmethod(cppyy_method_t method) {
+    if (method)
+        return ((Cppyy_PseudoMethodInfo*)method)->m_type == kStatic;
     assert(!"unknown class in cppyy_is_staticmethod");
     return 0;
 }
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to