29#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
36#if PY_VERSION_HEX < 0x03000000
37#if defined(__GNUC__) && !defined(__APPLE__)
38# if __GNUC__ > 4 && __has_include("codecvt")
61 static std::regex
s_fnptr(
"\\((\\w*:*)*\\*&*\\)");
64#if PY_VERSION_HEX < 0x03000000
66#elif PY_VERSION_HEX < 0x03080000
112#define ct_c_uint32 10
115#define ct_c_longlong 13
116#define ct_c_ulonglong 14
118#define ct_c_double 16
119#define ct_c_longdouble 17
120#define ct_c_char_p 18
121#define ct_c_wchar_p 19
122#define ct_c_void_p 20
123#define ct_c_fcomplex 21
124#define ct_c_complex 22
125#define ct_c_pointer 23
131 "c_bool",
"c_char",
"c_wchar",
"c_byte",
"c_ubyte",
"c_short",
"c_ushort",
"c_uint16",
132 "c_int",
"c_uint",
"c_uint32",
"c_long",
"c_ulong",
"c_longlong",
"c_ulonglong",
133 "c_float",
"c_double",
"c_longdouble",
134 "c_char_p",
"c_wchar_p",
"c_void_p",
"c_fcomplex",
"c_complex",
"_Pointer" };
208#if PY_VERSION_HEX < 0x30d0000
268 if (!
holder)
return false;
282 if (!
holder)
return false;
373#define CPPYY_PYLONG_AS_TYPE(name, type, limit_low, limit_high) \
374static inline type CPyCppyy_PyLong_As##name(PyObject* pyobject) \
376 if (!(PyLong_Check(pyobject) || PyInt_Check(pyobject))) { \
377 if (pyobject == CPyCppyy::gDefaultObject) \
379 PyErr_SetString(PyExc_TypeError, #type" conversion expects an integer object");\
382 long l = PyLong_AsLong(pyobject); \
383 if (l < limit_low || limit_high < l) { \
384 PyErr_Format(PyExc_ValueError, "integer %ld out of range for "#type, l);\
437 para.fValue.fVoidp =
nullptr;
443 para.fValue.fVoidp =
nullptr;
446 "could not convert argument to buffer or nullptr");
451 para.fTypeCode =
'p';
504 para.fValue.fVoidp =
pytmp->GetObjectRaw();
505 para.fTypeCode =
'V';
538#define CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc)\
540 type val = (type)F2(pyobject); \
541 if (val == (type)-1 && PyErr_Occurred()) { \
542 static PyTypeObject* ctypes_type = nullptr; \
543 if (!ctypes_type) { \
544 auto error = CPyCppyy::Utility::FetchPyError(); \
545 ctypes_type = GetCTypesType(ct_##ctype); \
546 CPyCppyy::Utility::RestorePyError(error); \
548 if (Py_TYPE(pyobject) == ctypes_type) { \
550 val = *((type*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr); \
551 } else if (pyobject == CPyCppyy::gDefaultObject) { \
557 para.fValue.f##name = val; \
558 para.fTypeCode = tc; \
561#define CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2) \
562PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
564 return F1((stype)*((type*)address)); \
567bool CPyCppyy::name##Converter::ToMemory( \
568 PyObject* value, void* address, PyObject* ) \
570 type s = (type)F2(value); \
571 if (s == (type)-1 && PyErr_Occurred()) { \
572 if (value == CPyCppyy::gDefaultObject) { \
578 *((type*)address) = (type)s; \
582#define CPPYY_IMPL_BASIC_CONVERTER_NI(name, type, stype, ctype, F1, F2, tc) \
583bool CPyCppyy::name##Converter::SetArg( \
584 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
586 if (!StrictBool(pyobject, ctxt)) \
588 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
590CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
592#define CPPYY_IMPL_BASIC_CONVERTER_IB(name, type, stype, ctype, F1, F2, tc) \
593bool CPyCppyy::name##Converter::SetArg( \
594 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
596 if (!ImplicitBool(pyobject, ctxt)) \
598 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
600CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
602#define CPPYY_IMPL_BASIC_CONVERTER_NB(name, type, stype, ctype, F1, F2, tc) \
603bool CPyCppyy::name##Converter::SetArg( \
604 PyObject* pyobject, Parameter& para, CallContext* ) \
606 if (PyBool_Check(pyobject)) \
608 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
610CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
636 "integer to character: value %d not in range [%d,%d]",
lchar, low, high);
646#define CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(name, ctype) \
647PyObject* CPyCppyy::name##RefConverter::FromMemory(void* ptr) \
650 PyTypeObject* ctypes_type = GetCTypesType(ct_##ctype); \
651 if (!ctypes_type) { \
652 PyErr_SetString(PyExc_RuntimeError, "no ctypes available"); \
655 PyObject* ref = ctypes_type->tp_new(ctypes_type, nullptr, nullptr); \
656 ((CPyCppyy_tagCDataObject*)ref)->b_ptr = (char*)ptr; \
657 ((CPyCppyy_tagCDataObject*)ref)->b_needsfree = 0; \
662#define CPPYY_IMPL_BASIC_CONST_REFCONVERTER(name, type, ctype, F1) \
663bool CPyCppyy::Const##name##RefConverter::SetArg( \
664 PyObject* pyobject, Parameter& para, CallContext* ) \
666 type val = (type)F1(pyobject); \
667 if (val == (type)-1 && PyErr_Occurred()) { \
668 if (pyobject == CPyCppyy::gDefaultObject) { \
674 para.fValue.f##name = val; \
675 para.fRef = ¶.fValue.f##name; \
676 para.fTypeCode = 'r'; \
679CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(Const##name, ctype)
682#define CPPYY_IMPL_BASIC_CONST_CHAR_REFCONVERTER(name, type, ctype, low, high)\
683bool CPyCppyy::Const##name##RefConverter::SetArg( \
684 PyObject* pyobject, Parameter& para, CallContext* ) \
687 type val = (type)ExtractChar(pyobject, #type, low, high); \
688 if (val == (type)-1 && PyErr_Occurred()) \
690 para.fValue.fLong = val; \
691 para.fTypeCode = 'l'; \
694CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(Const##name, ctype)
698#define CPPYY_IMPL_BASIC_CHAR_CONVERTER(name, type, low, high) \
699bool CPyCppyy::name##Converter::SetArg( \
700 PyObject* pyobject, Parameter& para, CallContext* ) \
703 long val = ExtractChar(pyobject, #type, low, high); \
704 if (val == -1 && PyErr_Occurred()) \
706 para.fValue.fLong = val; \
707 para.fTypeCode = 'l'; \
711PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
714 return CPyCppyy_PyText_FromFormat("%c", *((type*)address)); \
717bool CPyCppyy::name##Converter::ToMemory( \
718 PyObject* value, void* address, PyObject* ) \
721 const char* cstr = nullptr; \
722 if (PyBytes_Check(value)) \
723 PyBytes_AsStringAndSize(value, (char**)&cstr, &len); \
725 cstr = CPyCppyy_PyText_AsStringAndSize(value, &len); \
728 PyErr_Format(PyExc_TypeError, #type" expected, got string of size %zd", len);\
731 *((type*)address) = (type)cstr[0]; \
734 long l = PyLong_AsLong(value); \
735 if (l == -1 && PyErr_Occurred()) { \
736 if (value == CPyCppyy::gDefaultObject) { \
742 if (!(low <= l && l <= high)) { \
743 PyErr_Format(PyExc_ValueError, \
744 "integer to character: value %ld not in range [%d,%d]", l, low, high);\
747 *((type*)address) = (type)l; \
761#if PY_VERSION_HEX < 0x03000000
764 para.fTypeCode =
'V';
771 para.fTypeCode =
'V';
776 para.fTypeCode =
'V';
805bool CPyCppyy::IntRefConverter::SetArg(
809#if PY_VERSION_HEX < 0x03000000
812 para.fTypeCode =
'V';
817#if PY_VERSION_HEX >= 0x02050000
820 para.fTypeCode =
'V';
827 if (
para.fValue.fVoidp && buflen) {
828 para.fTypeCode =
'V';
832#if PY_VERSION_HEX < 0x02050000
841#define CPPYY_IMPL_REFCONVERTER(name, ctype, type, code) \
842bool CPyCppyy::name##RefConverter::SetArg( \
843 PyObject* pyobject, Parameter& para, CallContext* ) \
846 if (Py_TYPE(pyobject) == GetCTypesType(ct_##ctype)) { \
847 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
848 para.fTypeCode = 'V'; \
851 bool res = CArraySetArg(pyobject, para, code, sizeof(type)); \
853 PyErr_SetString(PyExc_TypeError, "use ctypes."#ctype" for pass-by-ref of "#type);\
856 para.fTypeCode = 'V'; \
859CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(name, ctype)
903PyObject* CPyCppyy::UCharAsIntConverter::FromMemory(
void* address)
911bool CPyCppyy::WCharConverter::SetArg(
923 para.fValue.fLong = (long)val;
924 para.fTypeCode =
'U';
928PyObject* CPyCppyy::WCharConverter::FromMemory(
void* address)
943 *((
wchar_t*)address) = val;
948bool CPyCppyy::Char16Converter::SetArg(
958 if (!
bstr)
return false;
962 para.fValue.fLong = (long)val;
963 para.fTypeCode =
'U';
967PyObject* CPyCppyy::Char16Converter::FromMemory(
void* address)
980 if (!
bstr)
return false;
988bool CPyCppyy::Char32Converter::SetArg(
998 if (!
bstr)
return false;
1002 para.fValue.fLong = (long)val;
1003 para.fTypeCode =
'U';
1007PyObject* CPyCppyy::Char32Converter::FromMemory(
void* address)
1020 if (!
bstr)
return false;
1048bool CPyCppyy::ULongConverter::SetArg(
1058 para.fTypeCode =
'L';
1062PyObject* CPyCppyy::ULongConverter::FromMemory(
void* address)
1075 u = (
unsigned long)0;
1079 *((
unsigned long*)address) =
u;
1084PyObject* CPyCppyy::UIntConverter::FromMemory(
void* address)
1102 *((
unsigned int*)address) = (
unsigned int)
u;
1119bool CPyCppyy::ComplexDConverter::SetArg(
1127 para.fTypeCode =
'V';
1134PyObject* CPyCppyy::ComplexDConverter::FromMemory(
void* address)
1136 std::complex<double>*
dc = (std::complex<double>*)address;
1144 std::complex<double>*
dc = (std::complex<double>*)address;
1149 return this->InstanceConverter::ToMemory(
value, address,
ctxt);
1153bool CPyCppyy::DoubleRefConverter::SetArg(
1157#if PY_VERSION_HEX < 0x03000000
1160 para.fTypeCode =
'V';
1165#if PY_VERSION_HEX >= 0x02050000
1168 para.fTypeCode =
'V';
1175 if (
para.fValue.fVoidp && buflen) {
1176 para.fTypeCode =
'V';
1180#if PY_VERSION_HEX < 0x02050000
1202bool CPyCppyy::LLongConverter::SetArg(
1212 para.fTypeCode =
'q';
1216PyObject* CPyCppyy::LLongConverter::FromMemory(
void* address)
1238bool CPyCppyy::ULLongConverter::SetArg(
1248 para.fTypeCode =
'Q';
1252PyObject* CPyCppyy::ULLongConverter::FromMemory(
void* address)
1274bool CPyCppyy::CStringConverter::SetArg(
1286 para.fTypeCode =
'V';
1297 if (!
ctxt->fPyContext) {
1308 para.fTypeCode =
'p';
1312PyObject* CPyCppyy::CStringConverter::FromMemory(
void* address)
1315 if (address && *(
void**)address) {
1319 if (*(
void**)address == (
void*)
fBuffer.data())
1336 if (!
cstr)
return false;
1345 void*
ptrval = *(
void**)address;
1348 *(
void**)address = (
void*)
fBuffer.data();
1358 *(
void**)address = (
void*)
cstr;
1373bool CPyCppyy::WCStringConverter::SetArg(
1389 para.fTypeCode =
'p';
1393PyObject* CPyCppyy::WCStringConverter::FromMemory(
void* address)
1396 if (address && *(
wchar_t**)address) {
1397 if (
fMaxSize != std::wstring::npos)
1420 if (
fMaxSize != std::wstring::npos)
1426 if (res == -1)
return false;
1431#define CPYCPPYY_WIDESTRING_CONVERTER(name, type, encode, decode, snull) \
1432bool CPyCppyy::name##Converter::SetArg( \
1433 PyObject* pyobject, Parameter& para, CallContext* ) \
1436 PyObject* bstr = encode(pyobject); \
1437 if (!bstr) return false; \
1439 Py_ssize_t len = PyBytes_GET_SIZE(bstr) - sizeof(type) ; \
1440 fBuffer = (type*)realloc(fBuffer, len + sizeof(type)); \
1441 memcpy(fBuffer, PyBytes_AS_STRING(bstr) + sizeof(type) , len); \
1444 fBuffer[len/sizeof(type)] = snull; \
1445 para.fValue.fVoidp = (void*)fBuffer; \
1446 para.fTypeCode = 'p'; \
1450PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
1453 if (address && *(type**)address) { \
1454 if (fMaxSize != std::wstring::npos) \
1455 return decode(*(const char**)address, (Py_ssize_t)fMaxSize*sizeof(type), nullptr, nullptr);\
1456 return decode(*(const char**)address, \
1457 std::char_traits<type>::length(*(type**)address)*sizeof(type), nullptr, nullptr);\
1462 return decode((const char*)&w, 0, nullptr, nullptr); \
1465bool CPyCppyy::name##Converter::ToMemory(PyObject* value, void* address, PyObject* )\
1468 PyObject* bstr = encode(value); \
1469 if (!bstr) return false; \
1471 Py_ssize_t len = PyBytes_GET_SIZE(bstr) - sizeof(type) ; \
1472 Py_ssize_t maxbytes = (Py_ssize_t)fMaxSize*sizeof(type); \
1475 if (fMaxSize != std::wstring::npos && maxbytes < len) { \
1476 PyErr_Warn(PyExc_RuntimeWarning, (char*)"string too long for "#type" array (truncated)");\
1480 memcpy(*((void**)address), PyBytes_AS_STRING(bstr) + sizeof(type) , len);\
1483 if (len/sizeof(type) < fMaxSize) (*(type**)address)[len/sizeof(type)] = snull;\
1491bool CPyCppyy::NonConstCStringConverter::SetArg(
1504PyObject* CPyCppyy::NonConstCStringConverter::FromMemory(
void* address)
1509 return this->CStringConverter::FromMemory(address);
1525 address = (
void*)val;
1553 para.fValue.fVoidp =
pyobj->GetObject();
1554 para.fTypeCode =
'p';
1559 if (GetAddressSpecialCase(
pyobject,
para.fValue.fVoidp)) {
1560 para.fTypeCode =
'p';
1568 para.fValue.fVoidp = (
void*)((CPyCppyy_tagCDataObject*)
pyobject)->b_ptr;
1569 para.fTypeCode =
'V';
1575 void** payload = (
void**)((CPyCppyy_tagCDataObject*)
pyobject)->b_ptr;
1577 para.fValue.fVoidp = *payload;
1578 para.fTypeCode =
'p';
1587 if (
para.fValue.fVoidp && buflen != 0) {
1588 para.fTypeCode =
'p';
1600 if (!address || *(
uintptr_t*)address == 0) {
1618 *(
void**)address =
pyobj->GetObject();
1623 void* ptr =
nullptr;
1624 if (GetAddressSpecialCase(
value, ptr)) {
1625 *(
void**)address = ptr;
1630 void* buf =
nullptr;
1632 if (!buf || buflen == 0)
1635 *(
void**)address = buf;
1677#define CPPYY_IMPL_ARRAY_CONVERTER(name, ctype, type, code, suffix) \
1678CPyCppyy::name##ArrayConverter::name##ArrayConverter(cdims_t dims) : \
1680 fIsFixed = dims ? fShape[0] != UNKNOWN_SIZE : false; \
1683bool CPyCppyy::name##ArrayConverter::SetArg( \
1684 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
1687 bool convOk = false; \
1690 if (fShape.ndim() == 2) { \
1691 if (Py_TYPE(pyobject) == GetCTypesPtrType(ct_##ctype)) { \
1692 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1693 para.fTypeCode = 'p'; \
1695 } else if (Py_TYPE(pyobject) == GetCTypesType(ct_c_void_p)) { \
1697 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1698 para.fTypeCode = 'p'; \
1700 } else if (LowLevelView_Check(pyobject) && \
1701 ((LowLevelView*)pyobject)->fBufInfo.ndim == 2 && \
1702 strchr(((LowLevelView*)pyobject)->fBufInfo.format, code)) { \
1703 para.fValue.fVoidp = ((LowLevelView*)pyobject)->get_buf(); \
1704 para.fTypeCode = 'p'; \
1711 PyTypeObject* ctypes_type = GetCTypesType(ct_##ctype); \
1712 if (Py_TYPE(pyobject) == ctypes_type) { \
1713 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1714 para.fTypeCode = 'p'; \
1716 } else if (Py_TYPE(pyobject) == GetCTypesPtrType(ct_##ctype)) { \
1717 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1718 para.fTypeCode = 'V'; \
1720 } else if (IsPyCArgObject(pyobject)) { \
1721 CPyCppyy_tagPyCArgObject* carg = (CPyCppyy_tagPyCArgObject*)pyobject;\
1722 if (carg->obj && Py_TYPE(carg->obj) == ctypes_type) { \
1723 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)carg->obj)->b_ptr;\
1724 para.fTypeCode = 'p'; \
1732 bool ismulti = fShape.ndim() > 1; \
1733 convOk = CArraySetArg(pyobject, para, code, ismulti ? sizeof(void*) : sizeof(type), true);\
1737 if (convOk) SetLifeLine(ctxt->fPyContext, pyobject, (intptr_t)this); \
1742PyObject* CPyCppyy::name##ArrayConverter::FromMemory(void* address) \
1745 return CreateLowLevelView##suffix((type**)address, fShape); \
1746 return CreateLowLevelView##suffix(*(type**)address, fShape); \
1749bool CPyCppyy::name##ArrayConverter::ToMemory( \
1750 PyObject* value, void* address, PyObject* ctxt) \
1752 if (fShape.ndim() <= 1 || fIsFixed) { \
1753 void* buf = nullptr; \
1754 Py_ssize_t buflen = Utility::GetBuffer(value, code, sizeof(type), buf);\
1755 return ToArrayFromBuffer<type>(value, address, ctxt, buf, buflen, fShape, fIsFixed);\
1757 void* buf = nullptr; \
1758 Py_ssize_t buflen = Utility::GetBuffer(value, code, sizeof(void*), buf);\
1759 if (buflen == 0) return false; \
1760 *(type**)address = (type*)buf; \
1761 SetLifeLine(ctxt, value, (intptr_t)address); \
1771#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
1796bool CPyCppyy::CStringArrayConverter::SetArg(
1804 para.fTypeCode =
'V';
1808#if PY_VERSION_HEX >= 0x03000000
1816 if (
len == (
size_t)-1) {
1822 for (
size_t i = 0; i <
len; ++i) {
1840 para.fTypeCode =
'p';
1849PyObject* CPyCppyy::CStringArrayConverter::FromMemory(
void* address)
1867 return SCharArrayConverter::ToMemory(
value, address,
ctxt);
1871PyObject* CPyCppyy::NonConstCStringArrayConverter::FromMemory(
void* address)
1885 para.fValue.fVoidp =
nullptr;
1886 para.fTypeCode =
'p';
1901#if PY_VERSION_HEX < 0x03030000
1911 const char*
cstr =
nullptr;
1913 if (
cstr) buffer = T{
cstr, (
typename T::size_type)
len};
1921#define CPPYY_IMPL_STRING_AS_PRIMITIVE_CONVERTER(name, type, F1, F2) \
1922CPyCppyy::name##Converter::name##Converter(bool keepControl) : \
1923 InstanceConverter(Cppyy::GetScope(#type), keepControl) {} \
1925bool CPyCppyy::name##Converter::SetArg( \
1926 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
1928 if (CPyCppyy_PyUnicodeAsBytes2Buffer(pyobject, fBuffer)) { \
1929 para.fValue.fVoidp = &fBuffer; \
1930 para.fTypeCode = 'V'; \
1935 if (!(PyInt_Check(pyobject) || PyLong_Check(pyobject))) { \
1936 bool result = InstanceConverter::SetArg(pyobject, para, ctxt); \
1937 para.fTypeCode = 'V'; \
1944PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
1947 return InstanceConverter::FromMemory(address); \
1948 auto* empty = new type(); \
1949 return BindCppObjectNoCast(empty, fClass, CPPInstance::kIsOwner); \
1952bool CPyCppyy::name##Converter::ToMemory( \
1953 PyObject* value, void* address, PyObject* ctxt) \
1955 if (CPyCppyy_PyUnicodeAsBytes2Buffer(value, *((type*)address))) \
1957 return InstanceConverter::ToMemory(value, address, ctxt); \
1964CPyCppyy::STLWStringConverter::STLWStringConverter(
bool keepControl) :
1967bool CPyCppyy::STLWStringConverter::SetArg(
1975 para.fTypeCode =
'V';
1978#if PY_VERSION_HEX < 0x03000000
1981 std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>
cnv;
1985 if (!
pyu)
return false;
1991 para.fTypeCode =
'V';
1998 para.fTypeCode =
'V';
2005PyObject* CPyCppyy::STLWStringConverter::FromMemory(
void* address)
2017 wchar_t* buf =
new wchar_t[
len+1];
2019 *((std::wstring*)address) = std::wstring(buf,
len);
2023 return InstanceConverter::ToMemory(
value, address,
ctxt);
2027#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
2028CPyCppyy::STLStringViewConverter::STLStringViewConverter(
bool keepControl) :
2031bool CPyCppyy::STLStringViewConverter::SetArg(
2038 para.fTypeCode =
'V';
2049 fBuffer = std::string_view(
cstr, (std::string_view::size_type)
len);
2051 para.fTypeCode =
'V';
2064 void* ptr =
pyobj->GetObject();
2070 fBuffer = *((std::string*)ptr);
2072 para.fTypeCode =
'V';
2080PyObject* CPyCppyy::STLStringViewConverter::FromMemory(
void* address)
2083 return InstanceConverter::FromMemory(address);
2084 auto* empty =
new std::string_view();
2088bool CPyCppyy::STLStringViewConverter::ToMemory(
2092 if (InstanceConverter::ToMemory(
value, address,
ctxt))
2100 *
reinterpret_cast<std::string_view*
>(address) = \
2101 std::string_view(
cstr, (std::string_view::size_type)
len);
2110bool CPyCppyy::STLStringMoveConverter::SetArg(
2139template <
bool ISCONST>
2146 if (GetAddressSpecialCase(
pyobject,
para.fValue.fVoidp)) {
2147 para.fTypeCode =
'p';
2167 para.fValue.fVoidp =
pyobj->GetObject();
2174 para.fTypeCode =
'p';
2182template <
bool ISCONST>
2192template <
bool ISCONST>
2198 void* ptr =
nullptr;
2199 if (GetAddressSpecialCase(
value, ptr)) {
2200 *(
void**)address = ptr;
2213 *(
void**)address =
pyobj->GetObject();
2223bool CPyCppyy::InstanceConverter::SetArg(
2232 para.fValue.fVoidp =
pyobj->GetObject();
2233 if (!
para.fValue.fVoidp)
2241 para.fTypeCode =
'V';
2250PyObject* CPyCppyy::InstanceConverter::FromMemory(
void* address)
2264#if PY_VERSION_HEX >= 0x03080000
2280bool CPyCppyy::InstanceRefConverter::SetArg(
2295 if (
pyobj->IsSmart()) {
2298 para.fValue.fVoidp =
pyobj->GetObjectRaw();
2306 para.fValue.fVoidp =
pyobj->GetObject();
2313 if (!
para.fValue.fVoidp) {
2324 para.fTypeCode =
'V';
2336PyObject* CPyCppyy::InstanceRefConverter::FromMemory(
void* address)
2342bool CPyCppyy::InstanceMoveConverter::SetArg(
2373template <
bool ISREFERENCE>
2374bool CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::SetArg(
2382 para.fValue.fVoidp =
nullptr;
2383 para.fTypeCode =
'p';
2396 para.fValue.fVoidp =
pyobj->GetObjectRaw();
2398 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2407template <
bool ISREFERENCE>
2408PyObject* CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::FromMemory(
void* address)
2415template <
bool ISREFERENCE>
2416bool CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::ToMemory(
2424 *(
void**)address =
nullptr;
2439 *(
void**)address =
pyobj->GetObject();
2451 template class CPyCppyy::InstancePtrPtrConverter<true>;
2452 template class CPyCppyy::InstancePtrPtrConverter<false>;
2456bool CPyCppyy::InstanceArrayConverter::SetArg(
2475 para.fTypeCode =
'p';
2483PyObject* CPyCppyy::InstanceArrayConverter::FromMemory(
void* address)
2490bool CPyCppyy::InstanceArrayConverter::ToMemory(
2497 "access to C-arrays of objects not yet implemented!");
2504bool CPyCppyy::STLIteratorConverter::SetArg(
2512 para.fValue.fVoidp =
pyobj->GetObject();
2513 para.fTypeCode =
'V';
2519bool CPyCppyy::VoidPtrRefConverter::SetArg(
2525 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2526 para.fTypeCode =
'V';
2534CPyCppyy::VoidPtrPtrConverter::VoidPtrPtrConverter(
cdims_t dims) :
2540bool CPyCppyy::VoidPtrPtrConverter::SetArg(
2547 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2548 para.fTypeCode =
'p';
2554 para.fTypeCode =
'p';
2564 if (
para.fValue.fVoidp && buflen != 0) {
2565 para.fTypeCode =
'p';
2573PyObject* CPyCppyy::VoidPtrPtrConverter::FromMemory(
void* address)
2576 if (!address || *(ptrdiff_t*)address == 0) {
2586bool CPyCppyy::PyObjectConverter::SetArg(
2591 para.fTypeCode =
'p';
2595PyObject* CPyCppyy::PyObjectConverter::FromMemory(
void* address)
2631 auto key =
ipos->second.second;
2649 const_cast<char*
>(
"internal_WrapperCacheEraser"),
2665 if (!
ol->fMethodInfo ||
ol->fMethodInfo->fMethods.empty())
2669 for (
auto&
m :
ol->fMethodInfo->fMethods) {
2674 void*
fptr = (
void*)
m->GetFunctionAddress();
2684 std::string fullname =
pytmpl->fTI->fCppName;
2685 if (
pytmpl->fTemplateArgs)
2733 std::ostringstream
wname;
2737 std::ostringstream code;
2738 code <<
"namespace __cppyy_internal {\n "
2740 for (
int i = 0; i <
nArgs; ++i) {
2741 code <<
argtypes[i] <<
" arg" << i;
2742 if (i !=
nArgs-1) code <<
", ";
2753 code <<
" PyObject** ref = (PyObject**)" << (intptr_t)ref <<
";\n"
2754 " PyObject* pyresult = nullptr;\n"
2755 " if (*ref) pyresult = PyObject_CallFunctionObjArgs(*ref";
2756 for (
int i = 0; i <
nArgs; ++i)
2757 code <<
", pyargs[" << i <<
"]";
2758 code <<
", NULL);\n"
2759 " else PyErr_SetString(PyExc_TypeError, \"callable was deleted\");\n";
2791bool CPyCppyy::FunctionPointerConverter::SetArg(
2796 para.fValue.fVoidp =
nullptr;
2797 para.fTypeCode =
'p';
2806 para.fTypeCode =
'p';
2813PyObject* CPyCppyy::FunctionPointerConverter::FromMemory(
void* address)
2824bool CPyCppyy::FunctionPointerConverter::ToMemory(
2829 *((
void**)address) =
nullptr;
2837 *((
void**)address) =
fptr;
2846bool CPyCppyy::StdFunctionConverter::SetArg(
2860 PyObject* func = this->FunctionPointerConverter::FromMemory(&
para.fValue.fVoidp);
2873PyObject* CPyCppyy::StdFunctionConverter::FromMemory(
void* address)
2888bool CPyCppyy::SmartPtrConverter::SetArg(
2915 para.fValue.fVoidp =
pyobj->GetSmartObject();
2930 para.fValue.fVoidp =
pyobj->GetObject();
2961 pyobj->PythonOwns();
2972 para.fTypeCode =
'V';
2979PyObject* CPyCppyy::SmartPtrConverter::FromMemory(
void* address)
2992#if PY_VERSION_HEX >= 0x03080000
3011#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3014 typedef size_t size_type;
3015 typedef void* iterator;
3019#elif defined (_MSC_VER)
3022 typedef char* iterator;
3027#define NO_KNOWN_INITIALIZER_LIST 1
3032CPyCppyy::InitializerListConverter::InitializerListConverter(
Cppyy::TCppType_t klass, std::string
const &value_type)
3034 : InstanceConverter{
klass},
3041CPyCppyy::InitializerListConverter::~InitializerListConverter()
3049void CPyCppyy::InitializerListConverter::Clear() {
3052#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3053 for (faux_initlist::size_type i = 0; i <
fake->_M_len; ++i) {
3054#elif defined (_MSC_VER)
3066bool CPyCppyy::InitializerListConverter::SetArg(
3069#ifdef NO_KNOWN_INITIALIZER_LIST
3089 void* buf =
nullptr;
3093 if (buf && buflen) {
3098#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3099 fake->_M_len = (faux_initlist::size_type)buflen;
3100#elif defined (_MSC_VER)
3115#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3116 fake->_M_len = (faux_initlist::size_type)
len;
3117 for (faux_initlist::size_type i = 0; i <
fake->_M_len; ++i) {
3118#elif defined (_MSC_VER)
3140 if (
memloc) entries += 1;
3143 "default ctor needed for initializer list of objects");
3158#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3159 fake->_M_len = (faux_initlist::size_type)entries;
3160#elif defined (_MSC_VER)
3173 para.fTypeCode =
'V';
3194 if (
cpd ==
"**" ||
cpd ==
"*[]" ||
cpd ==
"&*")
3196 else if (
cpd ==
"*&")
3202 else if (
cpd ==
"&")
3204 else if (
cpd ==
"&&")
3230 return (
h->second)(
dims);
3240 return (
h->second)(
dims);
3251 return (
h->second)(
dims);
3258 return (
h->second)(
dims);
3262 if (
cpd.compare(0, 3,
"*[]") == 0) {
3276 for (
int i = 2; i < (
newdim-1); ++i)
3282 return (
h->second)(
dims);
3285 }
else if (!
cpd.empty() && (std::string::size_type)std::count(
cpd.
begin(),
cpd.
end(),
'*') ==
cpd.size()) {
3291 }
else if (2 <=
cpd.size() && (std::string::size_type)std::count(
cpd.
begin(),
cpd.
end(),
'[') ==
cpd.size() / 2) {
3295 return (
h->second)(
dims);
3299 if (
realType.compare(0, 16,
"initializer_list") == 0) {
3311 if (pos == 0 || pos == 5 ||
3312 pos == 6 || pos == 11 ) {
3322 if (
pos1 != std::string::npos &&
pos2 != std::string::npos) {
3326 return new StdFunctionConverter(
cnv,
3328 }
else if (
cnv->HasState())
3340 }
else if (
cpd ==
"&") {
3350 static STLIteratorConverter
c;
3360 auto pos1 =
sm.position(0);
3362 result =
new FunctionPointerConverter(
3371 return (
h->second)(
dims);
3373 result =
new NotImplementedConverter();
3381 if (
cpd.size() == 2 &&
cpd !=
"&&")
3382 result =
new VoidPtrPtrConverter(
dims.ndim());
3383 else if (!
cpd.empty())
3386 result =
new NotImplementedConverter();
3396 if (
p &&
p->HasState())
3454#define STRINGVIEW "basic_string_view<char,char_traits<char> >"
3455#define WSTRING1 "std::basic_string<wchar_t>"
3456#define WSTRING2 "std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>"
3460#define CCOMPLEX_D "_Complex double"
3461#define CCOMPLEX_F "_Complex float"
3463#define CCOMPLEX_D "_C_double_complex"
3464#define CCOMPLEX_F "_C_float_complex"
3467static struct InitConvFactories_t {
3469 InitConvFactories_t() {
3474 gf[
"bool"] = (
cf_t)+[](
cdims_t) {
static BoolConverter
c{};
return &
c; };
3475 gf[
"const bool&"] = (
cf_t)+[](
cdims_t) {
static ConstBoolRefConverter
c{};
return &
c; };
3476 gf[
"bool&"] = (
cf_t)+[](
cdims_t) {
static BoolRefConverter
c{};
return &
c; };
3477 gf[
"char"] = (
cf_t)+[](
cdims_t) {
static CharConverter
c{};
return &
c; };
3478 gf[
"const char&"] = (
cf_t)+[](
cdims_t) {
static ConstCharRefConverter
c{};
return &
c; };
3479 gf[
"char&"] = (
cf_t)+[](
cdims_t) {
static CharRefConverter
c{};
return &
c; };
3480 gf[
"signed char&"] = (
cf_t)+[](
cdims_t) {
static SCharRefConverter
c{};
return &
c; };
3481 gf[
"unsigned char"] = (
cf_t)+[](
cdims_t) {
static UCharConverter
c{};
return &
c; };
3482 gf[
"const unsigned char&"] = (
cf_t)+[](
cdims_t) {
static ConstUCharRefConverter
c{};
return &
c; };
3483 gf[
"unsigned char&"] = (
cf_t)+[](
cdims_t) {
static UCharRefConverter
c{};
return &
c; };
3484 gf[
"SCharAsInt"] = (
cf_t)+[](
cdims_t) {
static SCharAsIntConverter
c{};
return &
c; };
3485 gf[
"UCharAsInt"] = (
cf_t)+[](
cdims_t) {
static UCharAsIntConverter
c{};
return &
c; };
3486 gf[
"wchar_t"] = (
cf_t)+[](
cdims_t) {
static WCharConverter
c{};
return &
c; };
3487 gf[
"char16_t"] = (
cf_t)+[](
cdims_t) {
static Char16Converter
c{};
return &
c; };
3488 gf[
"char32_t"] = (
cf_t)+[](
cdims_t) {
static Char32Converter
c{};
return &
c; };
3489 gf[
"wchar_t&"] = (
cf_t)+[](
cdims_t) {
static WCharRefConverter
c{};
return &
c; };
3490 gf[
"char16_t&"] = (
cf_t)+[](
cdims_t) {
static Char16RefConverter
c{};
return &
c; };
3491 gf[
"char32_t&"] = (
cf_t)+[](
cdims_t) {
static Char32RefConverter
c{};
return &
c; };
3492 gf[
"int8_t"] = (
cf_t)+[](
cdims_t) {
static Int8Converter
c{};
return &
c; };
3493 gf[
"const int8_t&"] = (
cf_t)+[](
cdims_t) {
static ConstInt8RefConverter
c{};
return &
c; };
3494 gf[
"int8_t&"] = (
cf_t)+[](
cdims_t) {
static Int8RefConverter
c{};
return &
c; };
3495 gf[
"int16_t"] = (
cf_t)+[](
cdims_t) {
static Int16Converter
c{};
return &
c; };
3496 gf[
"const int16_t&"] = (
cf_t)+[](
cdims_t) {
static ConstInt16RefConverter
c{};
return &
c; };
3497 gf[
"int16_t&"] = (
cf_t)+[](
cdims_t) {
static Int16RefConverter
c{};
return &
c; };
3498 gf[
"int32_t"] = (
cf_t)+[](
cdims_t) {
static Int32Converter
c{};
return &
c; };
3499 gf[
"const int32_t&"] = (
cf_t)+[](
cdims_t) {
static ConstInt32RefConverter
c{};
return &
c; };
3500 gf[
"int32_t&"] = (
cf_t)+[](
cdims_t) {
static Int32RefConverter
c{};
return &
c; };
3501 gf[
"uint8_t"] = (
cf_t)+[](
cdims_t) {
static UInt8Converter
c{};
return &
c; };
3502 gf[
"const uint8_t&"] = (
cf_t)+[](
cdims_t) {
static ConstUInt8RefConverter
c{};
return &
c; };
3503 gf[
"uint8_t&"] = (
cf_t)+[](
cdims_t) {
static UInt8RefConverter
c{};
return &
c; };
3504 gf[
"uint16_t"] = (
cf_t)+[](
cdims_t) {
static UInt16Converter
c{};
return &
c; };
3505 gf[
"const uint16_t&"] = (
cf_t)+[](
cdims_t) {
static ConstUInt16RefConverter
c{};
return &
c; };
3506 gf[
"uint16_t&"] = (
cf_t)+[](
cdims_t) {
static UInt16RefConverter
c{};
return &
c; };
3507 gf[
"uint32_t"] = (
cf_t)+[](
cdims_t) {
static UInt32Converter
c{};
return &
c; };
3508 gf[
"const uint32_t&"] = (
cf_t)+[](
cdims_t) {
static ConstUInt32RefConverter
c{};
return &
c; };
3509 gf[
"uint32_t&"] = (
cf_t)+[](
cdims_t) {
static UInt32RefConverter
c{};
return &
c; };
3510 gf[
"short"] = (
cf_t)+[](
cdims_t) {
static ShortConverter
c{};
return &
c; };
3511 gf[
"const short&"] = (
cf_t)+[](
cdims_t) {
static ConstShortRefConverter
c{};
return &
c; };
3512 gf[
"short&"] = (
cf_t)+[](
cdims_t) {
static ShortRefConverter
c{};
return &
c; };
3513 gf[
"unsigned short"] = (
cf_t)+[](
cdims_t) {
static UShortConverter
c{};
return &
c; };
3514 gf[
"const unsigned short&"] = (
cf_t)+[](
cdims_t) {
static ConstUShortRefConverter
c{};
return &
c; };
3515 gf[
"unsigned short&"] = (
cf_t)+[](
cdims_t) {
static UShortRefConverter
c{};
return &
c; };
3516 gf[
"int"] = (
cf_t)+[](
cdims_t) {
static IntConverter
c{};
return &
c; };
3517 gf[
"int&"] = (
cf_t)+[](
cdims_t) {
static IntRefConverter
c{};
return &
c; };
3518 gf[
"const int&"] = (
cf_t)+[](
cdims_t) {
static ConstIntRefConverter
c{};
return &
c; };
3519 gf[
"unsigned int"] = (
cf_t)+[](
cdims_t) {
static UIntConverter
c{};
return &
c; };
3520 gf[
"const unsigned int&"] = (
cf_t)+[](
cdims_t) {
static ConstUIntRefConverter
c{};
return &
c; };
3521 gf[
"unsigned int&"] = (
cf_t)+[](
cdims_t) {
static UIntRefConverter
c{};
return &
c; };
3522 gf[
"long"] = (
cf_t)+[](
cdims_t) {
static LongConverter
c{};
return &
c; };
3523 gf[
"long&"] = (
cf_t)+[](
cdims_t) {
static LongRefConverter
c{};
return &
c; };
3524 gf[
"const long&"] = (
cf_t)+[](
cdims_t) {
static ConstLongRefConverter
c{};
return &
c; };
3525 gf[
"unsigned long"] = (
cf_t)+[](
cdims_t) {
static ULongConverter
c{};
return &
c; };
3526 gf[
"const unsigned long&"] = (
cf_t)+[](
cdims_t) {
static ConstULongRefConverter
c{};
return &
c; };
3527 gf[
"unsigned long&"] = (
cf_t)+[](
cdims_t) {
static ULongRefConverter
c{};
return &
c; };
3528 gf[
"long long"] = (
cf_t)+[](
cdims_t) {
static LLongConverter
c{};
return &
c; };
3529 gf[
"const long long&"] = (
cf_t)+[](
cdims_t) {
static ConstLLongRefConverter
c{};
return &
c; };
3530 gf[
"long long&"] = (
cf_t)+[](
cdims_t) {
static LLongRefConverter
c{};
return &
c; };
3531 gf[
"unsigned long long"] = (
cf_t)+[](
cdims_t) {
static ULLongConverter
c{};
return &
c; };
3532 gf[
"const unsigned long long&"] = (
cf_t)+[](
cdims_t) {
static ConstULLongRefConverter
c{};
return &
c; };
3533 gf[
"unsigned long long&"] = (
cf_t)+[](
cdims_t) {
static ULLongRefConverter
c{};
return &
c; };
3535 gf[
"float"] = (
cf_t)+[](
cdims_t) {
static FloatConverter
c{};
return &
c; };
3536 gf[
"const float&"] = (
cf_t)+[](
cdims_t) {
static ConstFloatRefConverter
c{};
return &
c; };
3537 gf[
"float&"] = (
cf_t)+[](
cdims_t) {
static FloatRefConverter
c{};
return &
c; };
3538 gf[
"double"] = (
cf_t)+[](
cdims_t) {
static DoubleConverter
c{};
return &
c; };
3539 gf[
"double&"] = (
cf_t)+[](
cdims_t) {
static DoubleRefConverter
c{};
return &
c; };
3540 gf[
"const double&"] = (
cf_t)+[](
cdims_t) {
static ConstDoubleRefConverter
c{};
return &
c; };
3541 gf[
"long double"] = (
cf_t)+[](
cdims_t) {
static LDoubleConverter
c{};
return &
c; };
3542 gf[
"const long double&"] = (
cf_t)+[](
cdims_t) {
static ConstLDoubleRefConverter
c{};
return &
c; };
3543 gf[
"long double&"] = (
cf_t)+[](
cdims_t) {
static LDoubleRefConverter
c{};
return &
c; };
3544 gf[
"std::complex<double>"] = (
cf_t)+[](
cdims_t) {
return new ComplexDConverter{}; };
3545 gf[
"const std::complex<double>&"] = (
cf_t)+[](
cdims_t) {
return new ComplexDConverter{}; };
3546 gf[
"void"] = (
cf_t)+[](
cdims_t) {
static VoidConverter
c{};
return &
c; };
3549 gf[
"bool ptr"] = (
cf_t)+[](
cdims_t d) {
return new BoolArrayConverter{
d}; };
3550 gf[
"signed char ptr"] = (
cf_t)+[](
cdims_t d) {
return new SCharArrayConverter{
d}; };
3552 gf[
"const unsigned char*"] = (
cf_t)+[](
cdims_t d) {
return new UCharArrayConverter{
d}; };
3553 gf[
"unsigned char ptr"] = (
cf_t)+[](
cdims_t d) {
return new UCharArrayConverter{
d}; };
3554 gf[
"SCharAsInt*"] =
gf[
"signed char ptr"];
3555 gf[
"SCharAsInt[]"] =
gf[
"signed char ptr"];
3556 gf[
"UCharAsInt*"] =
gf[
"unsigned char ptr"];
3557 gf[
"UCharAsInt[]"] =
gf[
"unsigned char ptr"];
3558#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
3561 gf[
"int8_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new Int8ArrayConverter{
d}; };
3562 gf[
"int16_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new Int16ArrayConverter{
d}; };
3563 gf[
"int32_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new Int32ArrayConverter{
d}; };
3564 gf[
"uint8_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new UInt8ArrayConverter{
d}; };
3565 gf[
"uint16_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new UInt16ArrayConverter{
d}; };
3566 gf[
"uint32_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new UInt32ArrayConverter{
d}; };
3567 gf[
"short ptr"] = (
cf_t)+[](
cdims_t d) {
return new ShortArrayConverter{
d}; };
3568 gf[
"unsigned short ptr"] = (
cf_t)+[](
cdims_t d) {
return new UShortArrayConverter{
d}; };
3569 gf[
"int ptr"] = (
cf_t)+[](
cdims_t d) {
return new IntArrayConverter{
d}; };
3570 gf[
"unsigned int ptr"] = (
cf_t)+[](
cdims_t d) {
return new UIntArrayConverter{
d}; };
3571 gf[
"long ptr"] = (
cf_t)+[](
cdims_t d) {
return new LongArrayConverter{
d}; };
3572 gf[
"unsigned long ptr"] = (
cf_t)+[](
cdims_t d) {
return new ULongArrayConverter{
d}; };
3573 gf[
"long long ptr"] = (
cf_t)+[](
cdims_t d) {
return new LLongArrayConverter{
d}; };
3574 gf[
"unsigned long long ptr"] = (
cf_t)+[](
cdims_t d) {
return new ULLongArrayConverter{
d}; };
3575 gf[
"float ptr"] = (
cf_t)+[](
cdims_t d) {
return new FloatArrayConverter{
d}; };
3576 gf[
"double ptr"] = (
cf_t)+[](
cdims_t d) {
return new DoubleArrayConverter{
d}; };
3577 gf[
"long double ptr"] = (
cf_t)+[](
cdims_t d) {
return new LDoubleArrayConverter{
d}; };
3578 gf[
"std::complex<float> ptr"] = (
cf_t)+[](
cdims_t d) {
return new ComplexFArrayConverter{
d}; };
3579 gf[
"std::complex<double> ptr"] = (
cf_t)+[](
cdims_t d) {
return new ComplexDArrayConverter{
d}; };
3583 gf[
"signed char"] =
gf[
"char"];
3584 gf[
"const signed char&"] =
gf[
"const char&"];
3585#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
3586 gf[
"std::byte"] =
gf[
"uint8_t"];
3587 gf[
"byte"] =
gf[
"uint8_t"];
3588 gf[
"const std::byte&"] =
gf[
"const uint8_t&"];
3589 gf[
"const byte&"] =
gf[
"const uint8_t&"];
3590 gf[
"std::byte&"] =
gf[
"uint8_t&"];
3591 gf[
"byte&"] =
gf[
"uint8_t&"];
3593 gf[
"std::int8_t"] =
gf[
"int8_t"];
3594 gf[
"const std::int8_t&"] =
gf[
"const int8_t&"];
3595 gf[
"std::int8_t&"] =
gf[
"int8_t&"];
3596 gf[
"std::uint8_t"] =
gf[
"uint8_t"];
3597 gf[
"const std::uint8_t&"] =
gf[
"const uint8_t&"];
3598 gf[
"std::uint8_t&"] =
gf[
"uint8_t&"];
3599 gf[
"internal_enum_type_t"] =
gf[
"int"];
3600 gf[
"internal_enum_type_t&"] =
gf[
"int&"];
3601 gf[
"const internal_enum_type_t&"] =
gf[
"const int&"];
3602 gf[
"internal_enum_type_t ptr"] =
gf[
"int ptr"];
3604 gf[
"__int64"] =
gf[
"long long"];
3605 gf[
"const __int64&"] =
gf[
"const long long&"];
3606 gf[
"__int64&"] =
gf[
"long long&"];
3607 gf[
"__int64 ptr"] =
gf[
"long long ptr"];
3608 gf[
"unsigned __int64"] =
gf[
"unsigned long long"];
3609 gf[
"const unsigned __int64&"] =
gf[
"const unsigned long long&"];
3610 gf[
"unsigned __int64&"] =
gf[
"unsigned long long&"];
3611 gf[
"unsigned __int64 ptr"] =
gf[
"unsigned long long ptr"];
3619 gf[
"TString"] = (
cf_t)+[](
cdims_t) {
return new TStringConverter{}; };
3620 gf[
"TString&"] =
gf[
"TString"];
3621 gf[
"const TString&"] =
gf[
"TString"];
3622 gf[
"nullptr_t"] = (
cf_t)+[](
cdims_t) {
static NullptrConverter
c{};
return &
c;};
3623 gf[
"const char*"] = (
cf_t)+[](
cdims_t) {
return new CStringConverter{}; };
3624 gf[
"const signed char*"] =
gf[
"const char*"];
3625 gf[
"const char*&&"] =
gf[
"const char*"];
3626 gf[
"const char[]"] = (
cf_t)+[](
cdims_t) {
return new CStringConverter{}; };
3628 gf[
"char[]"] = (
cf_t)+[](
cdims_t d) {
return new NonConstCStringArrayConverter{
d,
true}; };
3629 gf[
"signed char*"] =
gf[
"char*"];
3630 gf[
"wchar_t*"] = (
cf_t)+[](
cdims_t) {
return new WCStringConverter{}; };
3631 gf[
"char16_t*"] = (
cf_t)+[](
cdims_t) {
return new CString16Converter{}; };
3633 gf[
"char32_t*"] = (
cf_t)+[](
cdims_t) {
return new CString32Converter{}; };
3636 gf[
"char16_t**"] =
gf[
"char16_t*"];
3637 gf[
"char32_t**"] =
gf[
"char32_t*"];
3639 gf[
"char**"] =
gf[
"const char**"];
3640 gf[
"const char*[]"] = (
cf_t)+[](
cdims_t d) {
return new CStringArrayConverter{
d,
false}; };
3641 gf[
"char*[]"] = (
cf_t)+[](
cdims_t d) {
return new NonConstCStringArrayConverter{
d,
false}; };
3642 gf[
"char ptr"] =
gf[
"char*[]"];
3643 gf[
"std::string"] = (
cf_t)+[](
cdims_t) {
return new STLStringConverter{}; };
3644 gf[
"const std::string&"] =
gf[
"std::string"];
3645 gf[
"string"] =
gf[
"std::string"];
3646 gf[
"const string&"] =
gf[
"std::string"];
3647 gf[
"std::string&&"] = (
cf_t)+[](
cdims_t) {
return new STLStringMoveConverter{}; };
3648 gf[
"string&&"] =
gf[
"std::string&&"];
3649#if (__cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
3652 gf[
"std::string_view&"] =
gf[
"std::string_view"];
3653 gf[
"const std::string_view&"] =
gf[
"std::string_view"];
3656 gf[
"std::wstring"] = (
cf_t)+[](
cdims_t) {
return new STLWStringConverter{}; };
3659 gf[
"const std::wstring&"] =
gf[
"std::wstring"];
3662 gf[
"void*&"] = (
cf_t)+[](
cdims_t) {
static VoidPtrRefConverter
c{};
return &
c; };
3663 gf[
"void**"] = (
cf_t)+[](
cdims_t d) {
return new VoidPtrPtrConverter{
d}; };
3664 gf[
"void ptr"] =
gf[
"void**"];
3665 gf[
"PyObject*"] = (
cf_t)+[](
cdims_t) {
static PyObjectConverter
c{};
return &
c; };
3666 gf[
"_object*"] =
gf[
"PyObject*"];
static Py_ssize_t CPyCppyy_PyUnicode_AsWideChar(PyObject *pyobj, wchar_t *w, Py_ssize_t size)
#define PyBytes_AS_STRING
#define PyBytes_AsStringAndSize
#define CPyCppyy_PyText_FromStringAndSize
#define CPyCppyy_PyUnicode_GET_SIZE
#define PY_SSIZE_T_FORMAT
static void * CPyCppyy_PyCapsule_GetPointer(PyObject *capsule, const char *)
#define CPyCppyy_PyText_AsString
#define CPyCppyy_PyText_GET_SIZE
#define CPyCppyy_PyCapsule_CheckExact
static PyObject * PyObject_CallMethodOneArg(PyObject *obj, PyObject *name, PyObject *arg)
static const char * CPyCppyy_PyText_AsStringAndSize(PyObject *pystr, Py_ssize_t *size)
static PyObject * PyObject_CallMethodNoArgs(PyObject *obj, PyObject *name)
#define CPyCppyy_PyText_FromString
#define CPyCppyy_PyText_Check
static bool StrictBool(PyObject *pyobject, CPyCppyy::CallContext *ctxt)
static std::array< PyTypeObject *, 26 > gCTypesTypes
static unsigned short CPyCppyy_PyLong_AsUShort(PyObject *pyobject)
static int32_t CPyCppyy_PyLong_AsInt32(PyObject *pyobject)
static std::map< void *, PyObject ** > sWrapperReference
static bool CPyCppyy_PyLong_AsBool(PyObject *pyobject)
static bool IsPyCArgObject(PyObject *pyobject)
static PyObject * WrapperCacheEraser(PyObject *, PyObject *pyref)
static bool CPyCppyy_PyUnicodeAsBytes2Buffer(PyObject *pyobject, T &buffer)
#define CPPYY_IMPL_STRING_AS_PRIMITIVE_CONVERTER(name, type, F1, F2)
#define CPPYY_IMPL_BASIC_CHAR_CONVERTER(name, type, low, high)
#define CPPYY_IMPL_BASIC_CONST_CHAR_REFCONVERTER(name, type, ctype, low, high)
static bool SetLifeLine(PyObject *holder, PyObject *target, intptr_t ref)
static PY_LONG_LONG CPyCppyy_PyLong_AsStrictLongLong(PyObject *pyobject)
static std::map< RetSigKey_t, std::map< PyObject *, void * > > sWrapperLookup
static bool ImplicitBool(PyObject *pyobject, CPyCppyy::CallContext *ctxt)
static bool CArraySetArg(PyObject *pyobject, CPyCppyy::Parameter ¶, char tc, int size, bool check=true)
static int ExtractChar(PyObject *pyobject, const char *tname, int low, int high)
static bool HasLifeLine(PyObject *holder, intptr_t ref)
static uint32_t CPyCppyy_PyLong_AsUInt32(PyObject *pyobject)
const Py_ssize_t MOVE_REFCOUNT_CUTOFF
static PyTypeObject * GetCTypesPtrType(int nidx)
static std::map< PyObject *, std::pair< void *, RetSigKey_t > > sWrapperWeakRefs
#define CPYCPPYY_WIDESTRING_CONVERTER(name, type, encode, decode, snull)
static int8_t CPyCppyy_PyLong_AsInt8(PyObject *pyobject)
#define CPPYY_IMPL_BASIC_CONVERTER_IB(name, type, stype, ctype, F1, F2, tc)
static CPyCppyy::Converter * selectInstanceCnv(Cppyy::TCppScope_t klass, const std::string &cpd, CPyCppyy::cdims_t dims, bool isConst, bool control)
static CPyCppyy::CPPInstance * GetCppInstance(PyObject *pyobject, Cppyy::TCppType_t klass=(Cppyy::TCppType_t) 0, bool accept_rvalue=false)
static std::array< PyTypeObject *, 26 > gCTypesPtrTypes
static PyMethodDef gWrapperCacheEraserMethodDef
#define CPPYY_IMPL_BASIC_CONST_REFCONVERTER(name, type, ctype, F1)
static std::array< const char *, 26 > gCTypesNames
static uint8_t CPyCppyy_PyLong_AsUInt8(PyObject *pyobject)
static short CPyCppyy_PyLong_AsShort(PyObject *pyobject)
static long CPyCppyy_PyLong_AsStrictLong(PyObject *pyobject)
#define CPPYY_IMPL_ARRAY_CONVERTER(name, ctype, type, code, suffix)
#define CPPYY_IMPL_BASIC_CONVERTER_NB(name, type, stype, ctype, F1, F2, tc)
#define CPPYY_IMPL_REFCONVERTER(name, ctype, type, code)
#define CPPYY_IMPL_BASIC_CONVERTER_NI(name, type, stype, ctype, F1, F2, tc)
static PyTypeObject * GetCTypesType(int nidx)
static CPyCppyy::CPPInstance * ConvertImplicit(Cppyy::TCppType_t klass, PyObject *pyobject, CPyCppyy::Parameter ¶, CPyCppyy::CallContext *ctxt, bool manage=true)
static int CPyCppyy_PyLong_AsStrictInt(PyObject *pyobject)
static int16_t CPyCppyy_PyLong_AsInt16(PyObject *pyobject)
static std::map< RetSigKey_t, std::vector< void * > > sWrapperFree
static bool IsCTypesArrayOrPointer(PyObject *pyobject)
static unsigned int sWrapperCounter
static uint16_t CPyCppyy_PyLong_AsUInt16(PyObject *pyobject)
#define CPPYY_PYLONG_AS_TYPE(name, type, limit_low, limit_high)
static void * PyFunction_AsCPointer(PyObject *pyobject, const std::string &rettype, const std::string &signature)
#define CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(name, ctype)
unsigned long long PY_ULONG_LONG
std::string fValueTypeName
Cppyy::TCppType_t fValueType
Cppyy::TCppType_t fSmartPtrType
Cppyy::TCppType_t fUnderlyingType
std::string::size_type fMaxSize
std::vector< Converter * > fConverters
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
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 target
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 result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 UChar_t len
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
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)=0
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual PyObject * FromMemory(void *address)
virtual PyObject * FromMemory(void *address)
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
static bool RegisterPyObject(CPPInstance *pyobj, void *cppobj)
virtual bool GetAddressSpecialCase(PyObject *pyobject, void *&address)
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual PyObject * FromMemory(void *address)
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)
Internal::TypedIter< T, decltype(std::begin(std::declval< Range_t >())), isDynamic > iterator
const_iterator begin() const
const_iterator end() const
std::string clean_type(const std::string &cppname, bool template_strip=true, bool const_strip=true)
std::string compound(const std::string &name)
std::vector< std::string > extract_arg_types(const std::string &sig)
void ConstructCallbackPreamble(const std::string &retType, const std::vector< std::string > &argtypes, std::ostringstream &code)
void ConstructCallbackReturn(const std::string &retType, int nArgs, std::ostringstream &code)
void RestorePyError(PyError_t &error)
Py_ssize_t GetBuffer(PyObject *pyobject, char tc, int size, void *&buf, bool check=true)
PyObject * FuncPtr2StdFunction(const std::string &retType, const std::string &signature, void *address)
bool IsSTLIterator(const std::string &classname)
unsigned long PyLongOrInt_AsULong(PyObject *pyobject)
Converter *(* cf_t)(cdims_t d)
PyObject * gDefaultObject
PyObject * GetScopeProxy(Cppyy::TCppScope_t)
bool TupleOfInstances_CheckExact(T *object)
PyObject * CreateScopeProxy(Cppyy::TCppScope_t, const unsigned flags=0)
bool RefFloat_CheckExact(T *object)
bool CPPExcInstance_Check(T *object)
bool NoImplicit(CallContext *ctxt)
static ConvFactories_t gConvFactories
PyObject * CreateLowLevelView(bool *, cdims_t shape)
PyObject * BindCppObjectNoCast(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, const unsigned flags=0)
bool CPPOverload_Check(T *object)
bool RefInt_CheckExact(T *object)
PyObject * CreateLowLevelViewString(char **, cdims_t shape)
bool CPPScope_Check(T *object)
CPYCPPYY_EXTERN bool RegisterConverter(const std::string &name, ConverterFactory_t)
static const dim_t UNKNOWN_SIZE
static std::regex s_fnptr("\\((\\w*:*)*\\*&*\\)")
bool AllowImplicit(CallContext *ctxt)
bool UseStrictOwnership(CallContext *ctxt)
PY_ULONG_LONG PyLongOrInt_AsULong64(PyObject *pyobject)
bool CPPInstance_Check(T *object)
PyObject * BindCppObjectArray(Cppyy::TCppObject_t address, Cppyy::TCppType_t klass, cdims_t dims)
PyObject * CreatePointerView(void *ptr, cdims_t shape=0)
PyObject * gNullPtrObject
bool IsConstructor(uint64_t flags)
CPYCPPYY_EXTERN bool RegisterConverterAlias(const std::string &name, const std::string &target)
CPYCPPYY_EXTERN Converter * CreateConverter(const std::string &name, cdims_t=0)
PyObject * BindCppObject(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, const unsigned flags=0)
CPYCPPYY_EXTERN void DestroyConverter(Converter *p)
bool TemplateProxy_Check(T *object)
std::map< std::string, cf_t > ConvFactories_t
CPYCPPYY_EXTERN bool UnregisterConverter(const std::string &name)
RPY_EXPORTED ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
RPY_EXPORTED size_t SizeOf(TCppType_t klass)
RPY_EXPORTED std::vector< TCppIndex_t > GetMethodIndicesFromName(TCppScope_t scope, const std::string &name)
RPY_EXPORTED bool Compile(const std::string &code, bool silent=false)
RPY_EXPORTED void CallDestructor(TCppType_t type, TCppObject_t self)
RPY_EXPORTED bool IsSubtype(TCppType_t derived, TCppType_t base)
RPY_EXPORTED TCppMethod_t GetMethodTemplate(TCppScope_t scope, const std::string &name, const std::string &proto)
RPY_EXPORTED TCppObject_t Construct(TCppType_t type, void *arena=nullptr)
RPY_EXPORTED bool GetSmartPtrInfo(const std::string &, TCppType_t *raw, TCppMethod_t *deref)
RPY_EXPORTED std::string ResolveName(const std::string &cppitem_name)
RPY_EXPORTED TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
RPY_EXPORTED bool IsSmartPtr(TCppType_t type)
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
RPY_EXPORTED TCppFuncAddr_t GetFunctionAddress(TCppMethod_t method, bool check_enabled=true)
RooArgList L(Args_t &&... args)
static ECallFlags sMemoryPolicy
PyObject_HEAD char * b_ptr
union CPyCppyy_tagPyCArgObject::@200 value
PyObject_HEAD void * pffi_type