1616
1717namespace CPyCppyy {
1818
19- // - helper for ctypes conversions --------------------------------------------
20- static PyObject* TC2CppName (PyObject* pytc, const char * cpd, bool allow_voidp)
21- {
22- const char * name = nullptr ;
23- if (CPyCppyy_PyText_Check (pytc)) {
24- char tc = ((char *)CPyCppyy_PyText_AsString (pytc))[0 ];
25- switch (tc) {
26- case ' ?' : name = " bool" ; break ;
27- case ' c' : name = " char" ; break ;
28- case ' b' : name = " char" ; break ;
29- case ' B' : name = " unsigned char" ; break ;
30- case ' h' : name = " short" ; break ;
31- case ' H' : name = " unsigned short" ; break ;
32- case ' i' : name = " int" ; break ;
33- case ' I' : name = " unsigned int" ; break ;
34- case ' l' : name = " long" ; break ;
35- case ' L' : name = " unsigned long" ; break ;
36- case ' q' : name = " long long" ; break ;
37- case ' Q' : name = " unsigned long long" ; break ;
38- case ' f' : name = " float" ; break ;
39- case ' d' : name = " double" ; break ;
40- case ' g' : name = " long double" ; break ;
41- case ' z' : // special case for C strings, ignore cpd
42- return CPyCppyy_PyText_FromString (std::string{" const char*" }.c_str ());
43- default : name = (allow_voidp ? " void*" : nullptr ); break ;
44- }
45- }
46-
47- if (name)
48- return CPyCppyy_PyText_FromString ((std::string{name}+cpd).c_str ());
49- return nullptr ;
50- }
51-
5219// ----------------------------------------------------------------------------
5320TemplateInfo::TemplateInfo () : fPyClass (nullptr ), fNonTemplated (nullptr ),
5421 fTemplated (nullptr ), fLowPriority(nullptr ), fDoc(nullptr )
@@ -109,6 +76,7 @@ PyObject* TemplateProxy::Instantiate(const std::string& fname,
10976 std::string proto = " " ;
11077
11178#if PY_VERSION_HEX >= 0x03080000
79+ // adjust arguments for self if this is a rebound global function
11280 bool isNS = (((CPPScope*)fTI ->fPyClass )->fFlags & CPPScope::kIsNamespace );
11381 if (!isNS && !fSelf && CPyCppyy_PyArgs_GET_SIZE (args, nargsf)) {
11482 args += 1 ;
@@ -138,7 +106,7 @@ PyObject* TemplateProxy::Instantiate(const std::string& fname,
138106 PyErr_Clear ();
139107 }
140108
141- PyObject* pyptrname = TC2CppName (pytc, ptrdef.c_str (), true );
109+ PyObject* pyptrname = Utility::CT2CppName (pytc, ptrdef.c_str (), true );
142110 if (pyptrname) {
143111 PyTuple_SET_ITEM (tpArgs, i, pyptrname);
144112 bArgSet = true ;
@@ -152,14 +120,14 @@ PyObject* TemplateProxy::Instantiate(const std::string& fname,
152120 if (!bArgSet) pytc = PyObject_GetAttr (itemi, PyStrings::gCTypesType );
153121
154122 if (!bArgSet && pytc) {
155- PyObject* pyactname = TC2CppName (pytc, " &" , false );
123+ PyObject* pyactname = Utility::CT2CppName (pytc, " &" , false );
156124 if (!pyactname) {
157125 // _type_ of a pointer to c_type is that type, which will have a type
158126 PyObject* newpytc = PyObject_GetAttr (pytc, PyStrings::gCTypesType );
159127 Py_DECREF (pytc);
160128 pytc = newpytc;
161129 if (pytc) {
162- pyactname = TC2CppName (pytc, " *" , false );
130+ pyactname = Utility::CT2CppName (pytc, " *" , false );
163131 } else
164132 PyErr_Clear ();
165133 }
0 commit comments