41using namespace cpyrt::Utility;
43struct InitOperatorMapping_t {
45 InitOperatorMapping_t() {
116} initOperatorMapping_;
118inline std::string full_scope(
const std::string& tpname) {
119 return tpname[0] ==
':' ? tpname :
"::" + tpname;
128 if (PyFloat_Check(pyobject)) {
129 PyErr_SetString(PyExc_TypeError,
"can\'t convert float to unsigned long");
130 return (
unsigned long)-1;
132 return (
unsigned long)0;
135 unsigned long ul = PyLong_AsUnsignedLong(pyobject);
136 if (ul == (
unsigned long)-1 && PyErr_Occurred() && PyLong_Check(pyobject)) {
138 long i = PyLong_AsLong(pyobject);
140 ul = (
unsigned long)i;
142 PyErr_SetString(PyExc_ValueError,
143 "can\'t convert negative value to unsigned long");
144 return (
unsigned long)-1;
154 if (PyFloat_Check(pyobject)) {
155 PyErr_SetString(PyExc_TypeError,
156 "can\'t convert float to unsigned long long");
159 return (
unsigned long)0;
163 if (PyErr_Occurred() && PyLong_Check(pyobject)) {
165 long i = PyLong_AsLong(pyobject);
169 PyErr_SetString(PyExc_ValueError,
170 "can\'t convert negative value to unsigned long long");
179 PyCFunction cfunc,
int flags) {
183 static std::list<PyMethodDef> s_pymeths;
185 s_pymeths.push_back(PyMethodDef());
186 PyMethodDef* pdef = &s_pymeths.back();
187 pdef->ml_name =
const_cast<char*
>(label);
188 pdef->ml_meth = cfunc;
189 pdef->ml_flags = flags;
190 pdef->ml_doc =
nullptr;
192 PyObject* func = PyCFunction_New(pdef,
nullptr);
193 PyObject*
name = PyUnicode_InternFromString(pdef->ml_name);
195 PyObject *pytype = 0, *pyvalue = 0, *pytrace = 0;
196 PyErr_Fetch(&pytype, &pyvalue, &pytrace);
197 bool isOk = PyType_Type.tp_setattro(pyclass,
name, method) == 0;
198 PyErr_Restore(pytype, pyvalue, pytrace);
203 if (PyErr_Occurred())
207 PyErr_Format(PyExc_TypeError,
"could not add method %s", label);
218 PyObject* pyfunc = PyObject_GetAttrString(pyclass,
const_cast<char*
>(func));
222 PyObject* pylabel = PyUnicode_InternFromString(
const_cast<char*
>(label));
223 bool isOk = PyType_Type.tp_setattro(pyclass, pylabel, pyfunc) == 0;
235 (
CPPOverload*)PyObject_GetAttrString(pyclass,
const_cast<char*
>(label));
239 if (PyErr_Occurred())
243 PyObject* pylabel = PyUnicode_InternFromString(
const_cast<char*
>(label));
245 PyType_Type.tp_setattro(pyclass, pylabel, (
PyObject*)method) == 0;
259 const std::string& rcname,
262 bool reverse =
false) {
298 bool reverse =
false;
308 const std::string& lcname =
ClassName(left);
309 const std::string& rcname =
ClassName(right);
316 const std::string& rcname,
const char* op,
322 if (rcname ==
"<unknown>" || lcname ==
"<unknown>")
330 if (lcname ==
"str" || lcname ==
"unicode" || lcname ==
"complex" ||
331 lcname.find(
"std::") == 0)
351 pyfunc =
BuildOperator(lcname, rcname, op, lcscope, reverse);
373 && lcname.find(
"__wrap_iter") ==
389 std::stringstream fname, proto;
390 if (strncmp(op,
"==", 2) == 0) {
391 fname <<
"is_equal<";
392 }
else if (strncmp(op,
"!=", 2) == 0) {
393 fname <<
"is_not_equal<";
395 fname <<
"not_implemented<";
397 fname << lcname <<
", " << rcname <<
">";
398 proto <<
"const " << lcname <<
"&, const " << rcname;
411 if (!PyUnicode_Check(pyobj)) {
415 pystr = PyObject_Str(pyobj);
418 std::string str = PyUnicode_AsUTF8(pystr);
422 return PyUnicode_AsUTF8(pyobj);
427 int* pcnt =
nullptr) {
432 using namespace cpyrt::Utility;
434 if (tn == (
PyObject*)&PyLong_Type) {
442 tmpl_name.append(
"int");
445 "unsigned long long");
448 (ll < INT_MIN || INT_MAX < ll)
449 ? ((ll < LONG_MIN || LONG_MAX < ll) ?
"long long" :
"long")
452 tmpl_name.append(
"int");
457 if (tn == (
PyObject*)&PyFloat_Type) {
459 tmpl_name.append(arg ?
"double" :
"float");
463 if (tn == (
PyObject*)&PyComplex_Type) {
464 tmpl_name.append(
"std::complex<double>");
468 if (tn == (
PyObject*)&PyUnicode_Type) {
469 tmpl_name.append(
"std::string");
474 if (arg && PySequence_Size(arg)) {
475 std::string subtype{
"std::initializer_list<"};
476 PyObject* item = PySequence_GetItem(arg, 0);
480 tmpl_name.append(subtype);
481 tmpl_name.append(
">");
494 if (CPPScope_Check(tn)) {
496 tmpl_name.append(full_scope(cpp_type));
500 if (CPPInstance_Check(pyobj)) {
501 if (pyobj->
fFlags & CPPInstance::kIsRValue)
502 tmpl_name.append(
"&&");
506 if ((pyobj->
fFlags & CPPInstance::kIsReference) || pref ==
kPointer)
507 tmpl_name.push_back(
'*');
509 tmpl_name.push_back(
'&');
517 if (tn == (
PyObject*)&CPPOverload_Type) {
518 PyObject* tpName = arg ? PyObject_GetAttr(arg, PyStrings::gCppName)
519 : PyUnicode_FromString(
"void* (*)(...)");
520 tmpl_name.append(PyUnicode_AsUTF8(tpName));
526 if (arg && PyCallable_Check(arg)) {
528 PyObject* annot = PyObject_GetAttr(arg, PyStrings::gAnnotations);
530 if (PyDict_Check(annot) && 1 < PyDict_Size(annot)) {
531 PyObject* ret = PyDict_GetItemString(annot,
"return");
534 std::ostringstream tpn;
538 PyObject* values = PyDict_Values(annot);
539 for (Py_ssize_t i = 0; i < (PyList_GET_SIZE(values) - 1); ++i) {
542 PyObject* item = PyList_GET_ITEM(values, i);
543 tpn << (CPPScope_Check(item) ? full_scope(
ClassName(item))
549 tmpl_name.append(tpn.str());
564 if ((argtypes = PyObject_GetAttrString(arg,
"argtypes")) &&
565 (ret = PyObject_GetAttrString(arg,
"restype"))) {
566 std::ostringstream tpn;
567 PyObject* pytc = PyObject_GetAttr(ret, PyStrings::gCTypesType);
571 for (Py_ssize_t i = 0; i < PySequence_Length(argtypes); ++i) {
574 PyObject* item = PySequence_GetItem(argtypes, i);
575 pytc = PyObject_GetAttr(item, PyStrings::gCTypesType);
582 tmpl_name.append(tpn.str());
592 Py_XDECREF(argtypes);
596 PyObject* tpName = PyObject_GetAttr(arg, PyStrings::gCppName);
598 const char*
cname = PyUnicode_AsUTF8(tpName);
599 tmpl_name.append(CPPScope_Check(arg) ? full_scope(
cname) :
cname);
606 for (
auto nn : {PyStrings::gCppName, PyStrings::gName}) {
607 PyObject* tpName = PyObject_GetAttr(tn, nn);
609 tmpl_name.append(PyUnicode_AsUTF8(tpName));
616 if (PyLong_Check(tn) || PyFloat_Check(tn)) {
621 tmpl_name.append(PyUnicode_AsUTF8(pystr));
630 const char* repr_cstr = repr ? PyUnicode_AsUTF8(repr) :
"<unprintable>";
632 PyErr_Format(PyExc_TypeError,
633 "could not construct C++ name from template argument %s",
644 int argoff,
int* pcnt) {
647 bool justOne = !PyTuple_CheckExact(tpArgs);
650 std::string tmpl_name;
651 tmpl_name.reserve(128);
653 tmpl_name.append(PyUnicode_AsUTF8(pyname));
654 tmpl_name.push_back(
'<');
659 Py_ssize_t nArgs = justOne ? 1 : PyTuple_GET_SIZE(tpArgs);
660 for (
int i = argoff; i < nArgs; ++i) {
662 PyObject* tn = justOne ? tpArgs : PyTuple_GET_ITEM(tpArgs, i);
663 if (PyUnicode_Check(tn)) {
664 tmpl_name.append(PyUnicode_AsUTF8(tn));
669 (args ? PyTuple_GET_ITEM(args, i) :
nullptr), pref,
673 "could not construct C++ name from provided template argument.");
681 tmpl_name.push_back(
',');
685 tmpl_name.push_back(
'>');
693 int* pcnt =
nullptr) {
698 using namespace cpyrt::Utility;
700 if (tn == (
PyObject*)&PyLong_Type) {
716 (ll < INT_MIN || INT_MAX < ll)
717 ? ((ll < LONG_MIN || LONG_MAX < ll) ?
"long long" :
"long")
727 if (tn == (
PyObject*)&PyFloat_Type) {
733 if (tn == (
PyObject*)&PyComplex_Type) {
740 if (tn == (
PyObject*)&PyUnicode_Type) {
747 if (arg && PySequence_Size(arg)) {
748 std::string subtype{
"std::initializer_list<"};
749 PyObject* item = PySequence_GetItem(arg, 0);
761 if (CPPScope_Check(tn)) {
766 if (CPPInstance_Check(pyobj)) {
767 if (pyobj->
fFlags & CPPInstance::kIsRValue)
772 if ((pyobj->
fFlags & CPPInstance::kIsReference) || pref ==
kPointer)
779 types.push_back(cpp_type.data);
783 if (tn == (
PyObject*)&CPPOverload_Type) {
784 PyObject* tpName = arg ? PyObject_GetAttr(arg, PyStrings::gCppName)
785 : PyUnicode_FromString(
"void* (*)(...)");
794 if (arg && PyCallable_Check(arg)) {
795 PyObject* annot = PyObject_GetAttr(arg, PyStrings::gAnnotations);
797 if (PyDict_Check(annot) && 1 < PyDict_Size(annot)) {
798 PyObject* ret = PyDict_GetItemString(annot,
"return");
801 std::ostringstream tpn;
802 tpn << (CPPScope_Check(ret) ?
ClassName(ret) : PyUnicode_AsUTF8(ret))
805 PyObject* values = PyDict_Values(annot);
806 for (Py_ssize_t i = 0; i < (PyList_GET_SIZE(values) - 1); ++i) {
809 PyObject* item = PyList_GET_ITEM(values, i);
810 tpn << (CPPScope_Check(item) ?
ClassName(item)
811 : PyUnicode_AsUTF8(item));
818 throw std::runtime_error(
819 "This path is not yet implemented (AddTypeName) \n");
830 PyObject* tpName = PyObject_GetAttr(arg, PyStrings::gCppName);
841 for (
auto nn : {PyStrings::gCppName, PyStrings::gName}) {
842 PyObject* tpName = PyObject_GetAttr(tn, nn);
845 PyUnicode_AsUTF8(tpName),
true);
853 PyObject* value_int = PyNumber_Index(tn);
855 types.push_back(
type.data);
859 std::string num = PyUnicode_AsUTF8(pystr);
860 types.push_back({
type.data, strdup(num.c_str())});
862 Py_DECREF(value_int);
865 types.push_back(
type.data);
873 if (PyLong_Check(tn) || PyFloat_Check(tn)) {
878 std::string num = PyUnicode_AsUTF8(pystr);
881 else if (num ==
"False")
891std::vector<Cpp::TemplateArgInfo>
894 int argoff,
int* pcnt) {
897 bool justOne = !PyTuple_CheckExact(tpArgs);
900 std::vector<Cpp::TemplateArgInfo> types;
906 Py_ssize_t nArgs = justOne ? 1 : PyTuple_GET_SIZE(tpArgs);
907 for (
int i = argoff; i < nArgs; ++i) {
909 PyObject* tn = justOne ? tpArgs : PyTuple_GET_ITEM(tpArgs, i);
910 if (PyUnicode_Check(tn)) {
911 const char* tn_string = PyUnicode_AsUTF8(tn);
914 PyErr_Format(PyExc_TypeError,
"Cannot find Templated Arg: %s",
922 if (!
AddTypeName(types, tn, (args ? PyTuple_GET_ITEM(args, i) :
nullptr),
926 "could not construct C++ name from provided template argument.");
937 const char*
name =
"";
938 if (PyUnicode_Check(pytc)) {
939 char tc = ((
char*)PyUnicode_AsUTF8(pytc))[0];
951 name =
"unsigned char";
957 name =
"unsigned short";
963 name =
"unsigned int";
969 name =
"unsigned long";
975 name =
"unsigned long long";
984 name =
"long double";
987 name =
"const char*";
1005 const std::string& retType,
const std::vector<std::string>& argtypes,
1006 std::ostringstream& code) {
1008 int nArgs = (
int)argtypes.size();
1011 bool isVoid = retType.find(
"void") == 0;
1013 code <<
" CPYRT_STATIC std::unique_ptr<cppjit::cpyrt::Converter, "
1014 "std::function<void(cppjit::cpyrt::Converter*)>> "
1015 "retconv{cppjit::cpyrt::CreateConverter(\""
1016 << retType <<
"\"), cppjit::cpyrt::DestroyConverter};\n";
1017 std::vector<bool> arg_is_ptr;
1019 arg_is_ptr.resize(nArgs);
1020 code <<
" CPYRT_STATIC "
1021 "std::vector<std::unique_ptr<cppjit::cpyrt::Converter, "
1022 "std::function<void(cppjit::cpyrt::Converter*)>>> argcvs;\n"
1023 <<
" if (argcvs.empty()) {\n"
1024 <<
" argcvs.reserve(" << nArgs <<
");\n";
1025 for (
int i = 0; i < nArgs; ++i) {
1026 arg_is_ptr[i] =
false;
1027 code <<
" argcvs.emplace_back(cppjit::cpyrt::CreateConverter(\"";
1028 const std::string& at = argtypes[i];
1030 const std::string& cpd = TypeManip::compound(res_at);
1037 arg_is_ptr[i] = cpd.back() ==
'*';
1038 if (arg_is_ptr[i] || cpd.back() ==
'&') {
1039 code << res_at.substr(0, res_at.size() - 1);
1044 code <<
"\"), cppjit::cpyrt::DestroyConverter);\n";
1051 code <<
" " << retType <<
" ret{};\n";
1055 code <<
" std::vector<PyObject*> pyargs;\n";
1056 code <<
" pyargs.reserve(" << nArgs <<
");\n"
1058 for (
int i = 0; i < nArgs; ++i) {
1059 code <<
" pyargs.emplace_back(argcvs[" << i
1060 <<
"]->FromMemory((void*)";
1063 code <<
"arg" << i <<
"));\n"
1064 <<
" if (!pyargs.back()) throw " << i <<
";\n";
1066 code <<
" } catch(int) {\n"
1067 <<
" for (auto pyarg : pyargs) Py_XDECREF(pyarg);\n"
1068 <<
" cppjit::cpyrt::PyException pyexc; throw pyexc;\n"
1075 std::ostringstream& code) {
1077 bool isVoid = retType.find(
"void") == 0;
1081 code <<
" for (auto pyarg : pyargs) Py_DECREF(pyarg);\n";
1082 code <<
" bool cOk = (bool)pyresult;\n"
1083 " if (pyresult) {\n";
1088 code <<
" if (!cppjit::cpyrt::Instance_IsLively(pyresult))\n"
1092 code << (isVoid ?
""
1093 :
" cOk = retconv->ToMemory(pyresult, (void*)&ret);\n")
1094 <<
" Py_DECREF(pyresult);\n }\n";
1097 code <<
" if (!cOk) {"
1101 " /* do nothing */ }\n"
1103 " cppjit::cpyrt::PyException pyexc; throw pyexc; }\n"
1106 code << (isVoid ?
";\n }\n" :
" ret;\n }\n");
1113 const std::string& signature,
1116 static int maker_count = 0;
1120 Py_INCREF(pf->second);
1128 std::ostringstream fname;
1129 fname <<
"ptr2func" << ++maker_count;
1131 std::ostringstream code;
1132 code <<
"namespace __cppjit_internal { std::function<" << retType
1133 << signature <<
"> " << fname.str() <<
"(intptr_t faddr) { return ("
1134 << retType <<
"(*)" << signature <<
")faddr;} }";
1137 PyErr_SetString(PyExc_TypeError,
"conversion to std::function failed");
1142 maker = PyObject_GetAttrString(pyscope, fname.str().c_str());
1153 PyTuple_SET_ITEM(args, 0, PyLong_FromLongLong((intptr_t)address));
1154 PyObject* func = PyObject_Call(maker, args, NULL);
1159 ((
CPPInstance*)func)->fFlags |= CPPInstance::kIsLValue;
1173 if (PyType_Ready(pytype) < 0)
1178 if (PyModule_AddObject(module, (
char*)
name, (
PyObject*)pytype) < 0) {
1190 static std::unordered_map<std::string, char> typecodeMap{
1191 {
"char",
'b'}, {
"unsigned char",
'B'},
1192#if PY_VERSION_HEX >= 0x030d0000
1195 {
"short",
'h'}, {
"unsigned short",
'H'},
1196 {
"int",
'i'}, {
"unsigned int",
'I'},
1197 {
"long",
'l'}, {
"unsigned long",
'L'},
1198 {
"long long",
'q'}, {
"unsigned long long",
'Q'},
1199 {
"float",
'f'}, {
"double",
'd'}};
1205 void*& buf,
bool check) {
1210 if (PyBytes_Check(pyobject) || PyUnicode_Check(pyobject))
1214 if ((!check || tc ==
'*' || tc ==
'B') && PyByteArray_CheckExact(pyobject)) {
1215 buf = PyByteArray_AS_STRING(pyobject);
1216 return PyByteArray_GET_SIZE(pyobject);
1220 if (PyObject_CheckBuffer(pyobject)) {
1221 if (PySequence_Check(pyobject) && !PySequence_Size(pyobject))
1224 if (PyErr_Occurred()) {
1231 memset(&bufinfo, 0,
sizeof(Py_buffer));
1232 if (PyObject_GetBuffer(pyobject, &bufinfo, PyBUF_FORMAT) == 0) {
1234 strchr(bufinfo.format, tc)
1238 || (
sizeof(
long int) ==
sizeof(
int) &&
1239 ((tc ==
'I' && strchr(bufinfo.format,
'L')) ||
1240 (tc ==
'i' && strchr(bufinfo.format,
'l'))))
1242 || (tc ==
'z' && strstr(bufinfo.format,
"Zf"))
1245 || (tc ==
'?' && strchr(bufinfo.format,
'b'))) {
1248 if (check && bufinfo.itemsize !=
size) {
1251 "buffer itemsize (%ld) does not match expected size (%d)",
1252 bufinfo.itemsize,
size);
1253 PyBuffer_Release(&bufinfo);
1257 Py_ssize_t buflen = 0;
1258 if (buf && bufinfo.ndim == 0)
1259 buflen = bufinfo.len / bufinfo.itemsize;
1260 else if (buf && bufinfo.ndim == 1)
1262 bufinfo.shape ? bufinfo.shape[0] : bufinfo.len / bufinfo.itemsize;
1263 PyBuffer_Release(&bufinfo);
1269 PyBuffer_Release(&bufinfo);
1272 }
else if (bufinfo.obj)
1273 PyBuffer_Release(&bufinfo);
1278 PyBufferProcs* bufprocs = Py_TYPE(pyobject)->tp_as_buffer;
1280 PySequenceMethods* seqmeths = Py_TYPE(pyobject)->tp_as_sequence;
1281 if (seqmeths != 0 && bufprocs != 0 && bufprocs->bf_getbuffer != 0) {
1285 (*(bufprocs->bf_getbuffer))(pyobject, &bufinfo, PyBUF_WRITABLE);
1286 buf = (
char*)bufinfo.buf;
1287 Py_ssize_t buflen = bufinfo.len;
1288 PyBuffer_Release(&bufinfo);
1290 if (buf && check ==
true) {
1293 ? PyObject_GetAttr(pyobject, PyStrings::gTypeCode)
1296 char cpytc = PyUnicode_AsUTF8(pytc)[0];
1297 if (!(cpytc == tc || (tc ==
'?' && cpytc ==
'b')))
1300 }
else if (seqmeths->sq_length &&
1301 (
int)(buflen / (*(seqmeths->sq_length))(pyobject)) ==
size) {
1304 }
else if (buflen ==
size) {
1313 PyObject* pyvalue2 = PyUnicode_FromFormat(
1314 (
char*)
"%s and given element size (%ld) do not match needed (%d)",
1315 PyUnicode_AsUTF8(error.fValue.get()),
1317 ? (
long)(buflen / (*(seqmeths->sq_length))(pyobject))
1320 error.fValue.reset(pyvalue2);
1335 bool bTakesParams,
bool* stubbed) {
1337 if (8 <
name.size() &&
name.substr(0, 8) ==
"operator") {
1338 std::string op =
name.substr(8, std::string::npos);
1341 std::string::size_type start = 0, end = op.size();
1342 while (start < end && isspace(op[start]))
1344 while (start < end && isspace(op[end - 1]))
1346 op = op.substr(start, end - start);
1359 }
else if (op ==
"*") {
1367 }
else if (op ==
"/") {
1369 return "__truediv__";
1371 }
else if (op ==
"+") {
1379 }
else if (op ==
"-") {
1387 }
else if (op ==
"++") {
1389 return bTakesParams ?
"__postinc__" :
"__preinc__";
1391 }
else if (op ==
"--") {
1393 return bTakesParams ?
"__postdec__" :
"__predec__";
1404 std::string clname =
"<unknown>";
1406 PyObject* pyname = PyObject_GetAttr(pyclass, PyStrings::gCppName);
1409 pyname = PyObject_GetAttr(pyclass, PyStrings::gName);
1413 clname = PyUnicode_AsUTF8(pyname);
1430 std::string
tt =
"<int>::";
1431 for (
auto c : {
"std::vector",
"std::list",
"std::deque"}) {
1432 for (
auto i : {
"iterator",
"const_iterator"}) {
1434 auto pos = itname.find(
'<');
1435 if (pos != std::string::npos)
1441 auto pos = classname.find(
'<');
1442 if (pos != std::string::npos)
1477#if PY_VERSION_HEX >= 0x030c0000
1478 error.
fValue.reset(PyErr_GetRaisedException());
1483 PyErr_Fetch(&pytype, &pyvalue, &pytrace);
1484 error.fType.reset(pytype);
1485 error.fValue.reset(pyvalue);
1486 error.fTrace.reset(pytrace);
1493#if PY_VERSION_HEX >= 0x030c0000
1494 PyErr_SetRaisedException(error.
fValue.release());
1496 PyErr_Restore(error.
fType.release(), error.
fValue.release(),
1504 if (PyErr_Occurred()) {
1506 errors.back().fIsCpp = is_cpp;
1508 return errors.size();
1515 if (errors.empty()) {
1517 PyErr_SetString(defexc, PyUnicode_AsUTF8(topmsg));
1525 for (
auto&
e : errors) {
1527 if (!unique_from_cpp)
1528 unique_from_cpp = &
e;
1531 unique_from_cpp =
nullptr;
1537 if (unique_from_cpp) {
1548 for (
auto&
e : errors) {
1549#if PY_VERSION_HEX >= 0x030c0000
1556 else if (exc_type != pytype) {
1563 PyObject* separator = PyUnicode_FromString(
"\n ");
1564 for (
auto&
e : errors) {
1566 PyUnicode_Append(&topmsg, separator);
1567 if (PyUnicode_Check(pyvalue)) {
1568 PyUnicode_Append(&topmsg, pyvalue);
1569 }
else if (pyvalue) {
1570 PyObject* excstr = PyObject_Str(pyvalue);
1573 excstr = PyObject_Str((
PyObject*)Py_TYPE(pyvalue));
1575 PyUnicode_AppendAndDel(&topmsg, excstr);
1577 PyUnicode_AppendAndDel(&topmsg,
1578 PyUnicode_FromString(
"unknown exception"));
1582 Py_DECREF(separator);
1585 PyErr_SetString(exc_type, PyUnicode_AsUTF8(topmsg));
1598 "#include \"cpyrt/API.h\"\n"
1601 "#include \"cpyrt/DispatchPtr.h\"\n"
1602 "#include \"cpyrt/PyException.h\"\n");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
static std::set< std::string > sIteratorTypes
static std::unordered_map< void *, PyObject * > sStdFuncLookup
static cpyrt::PyCallable * BuildOperator(const std::string &lcname, const std::string &rcname, const char *op, interop::TCppScope_t scope, bool reverse=false)
static std::unordered_map< std::string, PyObject * > sStdFuncMakerLookup
static TC2POperatorMapping_t gC2POperatorMapping
static bool AddTypeName(std::string &tmpl_name, PyObject *tn, PyObject *arg, cpyrt::Utility::ArgPreference pref, int *pcnt=nullptr)
static std::set< std::string > gOpRemove
std::unordered_map< std::string, std::string > TC2POperatorMapping_t
static std::set< std::string > gOpSkip
static bool check_scope(const std::string &name)
static std::string AnnotationAsText(PyObject *pyobj)
void AdoptMethod(PyCallable *pc)
interop::TCppScope_t fCppType
unsigned long long PY_ULONG_LONG
std::string clean_type(const std::string &cppname, bool template_strip=true, bool const_strip=true)
std::string ConstructTemplateArgs(PyObject *pyname, PyObject *tpArgs, PyObject *args=nullptr, ArgPreference=kNone, int argoff=0, int *pcnt=nullptr)
std::string ClassName(PyObject *pyobj)
void ConstructCallbackPreamble(const std::string &retType, const std::vector< std::string > &argtypes, std::ostringstream &code)
std::string CT2CppNameS(PyObject *pytc, bool allow_voidp)
void RestorePyError(PyError_t &error)
void ConstructCallbackReturn(const std::string &retType, int nArgs, std::ostringstream &code)
size_t FetchError(std::vector< PyError_t > &, bool is_cpp=false)
PyCallable * FindBinaryOperator(PyObject *left, PyObject *right, const char *op, interop::TCppScope_t scope=interop::TCppScope_t{})
bool IsSTLIterator(const std::string &classname)
std::vector< Cpp::TemplateArgInfo > GetTemplateArgsTypes(PyObject *scope, PyObject *tpArgs, PyObject *args=nullptr, ArgPreference=kNone, int argoff=0, int *pcnt=nullptr)
bool AddToClass(PyObject *pyclass, const char *label, PyCFunction cfunc, int flags=METH_VARARGS)
PyObject * PyErr_Occurred_WithGIL()
bool InitProxy(PyObject *module, PyTypeObject *pytype, const char *name)
void SetDetailedException(std::vector< PyError_t > &&errors, PyObject *topmsg, PyObject *defexc)
Py_ssize_t GetBuffer(PyObject *pyobject, char tc, int size, void *&buf, bool check=true)
std::unordered_map< std::string, char > const & TypecodeMap()
std::string MapOperatorName(const std::string &name, bool bTakesParames, bool *stubbed=nullptr)
PyObject * FuncPtr2StdFunction(const std::string &retType, const std::string &signature, void *address)
PyCallable * FindUnaryOperator(PyObject *pyclass, const char *op)
bool CPPOverload_Check(T *object)
PyObject * CustomInstanceMethod_New(PyObject *func, PyObject *self, PyObject *)
PyObject * gDefaultObject
PyObject * gNullPtrObject
PyObject * CreateScopeProxy(PyObject *, PyObject *args)
unsigned long PyLongOrInt_AsULong(PyObject *pyobject)
bool CPPScope_Check(T *object)
bool CPPInstance_Check(T *object)
CPPOverload * CPPOverload_New(const std::string &name, std::vector< PyCallable * > &methods)
PY_ULONG_LONG PyLongOrInt_AsULong64(PyObject *pyobject)
TCppScope_t GetFullScope(const std::string &scope_name)
TCppType_t GetTypeFromScope(TCppScope_t klass)
TCppMethod_t GetMethodTemplate(TCppScope_t scope, const std::string &name, const std::string &proto)
std::string ResolveName(const std::string &cppitem_name)
bool AppendTypesSlow(const std::string &name, std::vector< Cpp::TemplateArgInfo > &types, TCppScope_t parent=nullptr)
TCppType_t GetReferencedType(TCppType_t type, bool rvalue=false)
Cpp::FuncRef TCppMethod_t
TCppMethod_t GetGlobalOperator(TCppScope_t scope, const std::string &lc, const std::string &rc, const std::string &op)
TCppScope_t GetGlobalScope()
bool Compile(const std::string &code, bool silent=false)
TCppType_t GetPointerType(TCppType_t type)
TCppScope_t GetScope(const std::string &scope_name, TCppScope_t parent_scope=TCppScope_t{})
TCppType_t GetType(const std::string &name, bool enable_slow_lookup=false)
std::string GetScopedFinalName(TCppScope_t type)
bool IsEnumType(TCppType_t type)
std::unique_ptr< PyObject, PyObjectDeleter > fType
std::unique_ptr< PyObject, PyObjectDeleter > fValue
std::unique_ptr< PyObject, PyObjectDeleter > fTrace