35#if PY_VERSION_HEX < 0x03000000
36#if defined(__GNUC__) && !defined(__APPLE__)
37# if __GNUC__ > 4 && __has_include("codecvt")
60 static std::regex
s_fnptr(
"\\((\\w*:*)*\\*&*\\)");
65#if PY_VERSION_HEX < 0x030e0000
66#if PY_VERSION_HEX < 0x03000000
68#elif PY_VERSION_HEX < 0x03080000
118#define ct_c_uint32 10
121#define ct_c_longlong 13
122#define ct_c_ulonglong 14
124#define ct_c_double 16
125#define ct_c_longdouble 17
126#define ct_c_char_p 18
127#define ct_c_wchar_p 19
128#define ct_c_void_p 20
129#define ct_c_fcomplex 21
130#define ct_c_complex 22
131#define ct_c_pointer 23
132#define ct_c_funcptr 24
138 "c_bool",
"c_char",
"c_wchar",
"c_byte",
"c_ubyte",
"c_short",
"c_ushort",
"c_uint16",
139 "c_int",
"c_uint",
"c_uint32",
"c_long",
"c_ulong",
"c_longlong",
"c_ulonglong",
140 "c_float",
"c_double",
"c_longdouble",
141 "c_char_p",
"c_wchar_p",
"c_void_p",
"c_fcomplex",
"c_complex",
142 "_Pointer",
"_CFuncPtr" };
216#if PY_VERSION_HEX < 0x30d0000
276 if (!
holder)
return false;
290 if (!
holder)
return false;
381#define CPPYY_PYLONG_AS_TYPE(name, type, limit_low, limit_high) \
382static inline type CPyCppyy_PyLong_As##name(PyObject* pyobject) \
384 if (!(PyLong_Check(pyobject) || PyInt_Check(pyobject))) { \
385 if (pyobject == CPyCppyy::gDefaultObject) \
387 PyErr_SetString(PyExc_TypeError, #type" conversion expects an integer object");\
390 long l = PyLong_AsLong(pyobject); \
391 if (l < limit_low || limit_high < l) { \
392 PyErr_Format(PyExc_ValueError, "integer %ld out of range for "#type, l);\
445 para.fValue.fVoidp =
nullptr;
451 para.fValue.fVoidp =
nullptr;
454 "could not convert argument to buffer or nullptr");
459 para.fTypeCode =
'p';
512 para.fValue.fVoidp =
pytmp->GetObjectRaw();
513 para.fTypeCode =
'V';
546#define CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc)\
548 type val = (type)F2(pyobject); \
549 if (val == (type)-1 && PyErr_Occurred()) { \
550 static PyTypeObject* ctypes_type = nullptr; \
551 if (!ctypes_type) { \
552 auto error = CPyCppyy::Utility::FetchPyError(); \
553 ctypes_type = GetCTypesType(ct_##ctype); \
554 CPyCppyy::Utility::RestorePyError(error); \
556 if (Py_TYPE(pyobject) == ctypes_type) { \
558 val = *((type*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr); \
559 } else if (pyobject == CPyCppyy::gDefaultObject) { \
565 para.fValue.f##name = val; \
566 para.fTypeCode = tc; \
569#define CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2) \
570PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
572 return F1((stype)*((type*)address)); \
575bool CPyCppyy::name##Converter::ToMemory( \
576 PyObject* value, void* address, PyObject* ) \
578 type s = (type)F2(value); \
579 if (s == (type)-1 && PyErr_Occurred()) { \
580 if (value == CPyCppyy::gDefaultObject) { \
586 *((type*)address) = (type)s; \
590#define CPPYY_IMPL_BASIC_CONVERTER_NI(name, type, stype, ctype, F1, F2, tc) \
591bool CPyCppyy::name##Converter::SetArg( \
592 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
594 if (!StrictBool(pyobject, ctxt)) \
596 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
598CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
600#define CPPYY_IMPL_BASIC_CONVERTER_IB(name, type, stype, ctype, F1, F2, tc) \
601bool CPyCppyy::name##Converter::SetArg( \
602 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
604 if (!ImplicitBool(pyobject, ctxt)) \
606 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
608CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
610#define CPPYY_IMPL_BASIC_CONVERTER_NB(name, type, stype, ctype, F1, F2, tc) \
611bool CPyCppyy::name##Converter::SetArg( \
612 PyObject* pyobject, Parameter& para, CallContext* ) \
614 if (PyBool_Check(pyobject)) \
616 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
618CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
644 "integer to character: value %d not in range [%d,%d]",
lchar, low, high);
654#define CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(name, ctype) \
655PyObject* CPyCppyy::name##RefConverter::FromMemory(void* ptr) \
658 PyTypeObject* ctypes_type = GetCTypesType(ct_##ctype); \
659 if (!ctypes_type) { \
660 PyErr_SetString(PyExc_RuntimeError, "no ctypes available"); \
663 PyObject* ref = ctypes_type->tp_new(ctypes_type, nullptr, nullptr); \
664 ((CPyCppyy_tagCDataObject*)ref)->b_ptr = (char*)ptr; \
665 ((CPyCppyy_tagCDataObject*)ref)->b_needsfree = 0; \
670#define CPPYY_IMPL_BASIC_CONST_REFCONVERTER(name, type, ctype, F1) \
671bool CPyCppyy::Const##name##RefConverter::SetArg( \
672 PyObject* pyobject, Parameter& para, CallContext* ) \
674 type val = (type)F1(pyobject); \
675 if (val == (type)-1 && PyErr_Occurred()) { \
676 if (pyobject == CPyCppyy::gDefaultObject) { \
682 para.fValue.f##name = val; \
683 para.fRef = ¶.fValue.f##name; \
684 para.fTypeCode = 'r'; \
687CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(Const##name, ctype)
690#define CPPYY_IMPL_BASIC_CONST_CHAR_REFCONVERTER(name, type, ctype, low, high)\
691bool CPyCppyy::Const##name##RefConverter::SetArg( \
692 PyObject* pyobject, Parameter& para, CallContext* ) \
695 type val = (type)ExtractChar(pyobject, #type, low, high); \
696 if (val == (type)-1 && PyErr_Occurred()) \
698 para.fValue.fLong = val; \
699 para.fTypeCode = 'l'; \
702CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(Const##name, ctype)
706#define CPPYY_IMPL_BASIC_CHAR_CONVERTER(name, type, low, high) \
707bool CPyCppyy::name##Converter::SetArg( \
708 PyObject* pyobject, Parameter& para, CallContext* ) \
711 long val = ExtractChar(pyobject, #type, low, high); \
712 if (val == -1 && PyErr_Occurred()) \
714 para.fValue.fLong = val; \
715 para.fTypeCode = 'l'; \
719PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
722 return CPyCppyy_PyText_FromFormat("%c", *((type*)address)); \
725bool CPyCppyy::name##Converter::ToMemory( \
726 PyObject* value, void* address, PyObject* ) \
729 const char* cstr = nullptr; \
730 if (PyBytes_Check(value)) \
731 PyBytes_AsStringAndSize(value, (char**)&cstr, &len); \
733 cstr = CPyCppyy_PyText_AsStringAndSize(value, &len); \
736 PyErr_Format(PyExc_TypeError, #type" expected, got string of size %zd", len);\
739 *((type*)address) = (type)cstr[0]; \
742 long l = PyLong_AsLong(value); \
743 if (l == -1 && PyErr_Occurred()) { \
744 if (value == CPyCppyy::gDefaultObject) { \
750 if (!(low <= l && l <= high)) { \
751 PyErr_Format(PyExc_ValueError, \
752 "integer to character: value %ld not in range [%d,%d]", l, low, high);\
755 *((type*)address) = (type)l; \
769#if PY_VERSION_HEX < 0x03000000
772 para.fTypeCode =
'V';
779 para.fTypeCode =
'V';
784 para.fTypeCode =
'V';
813bool CPyCppyy::IntRefConverter::SetArg(
817#if PY_VERSION_HEX < 0x03000000
820 para.fTypeCode =
'V';
825#if PY_VERSION_HEX >= 0x02050000
828 para.fTypeCode =
'V';
835 if (
para.fValue.fVoidp && buflen) {
836 para.fTypeCode =
'V';
840#if PY_VERSION_HEX < 0x02050000
849#define CPPYY_IMPL_REFCONVERTER(name, ctype, type, code) \
850bool CPyCppyy::name##RefConverter::SetArg( \
851 PyObject* pyobject, Parameter& para, CallContext* ) \
854 if (Py_TYPE(pyobject) == GetCTypesType(ct_##ctype)) { \
855 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
856 para.fTypeCode = 'V'; \
859 bool res = CArraySetArg(pyobject, para, code, sizeof(type)); \
861 PyErr_SetString(PyExc_TypeError, "use ctypes."#ctype" for pass-by-ref of "#type);\
864 para.fTypeCode = 'V'; \
867CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(name, ctype)
911PyObject* CPyCppyy::UCharAsIntConverter::FromMemory(
void* address)
919bool CPyCppyy::WCharConverter::SetArg(
931 para.fValue.fLong = (long)val;
932 para.fTypeCode =
'U';
936PyObject* CPyCppyy::WCharConverter::FromMemory(
void* address)
951 *((
wchar_t*)address) = val;
956bool CPyCppyy::Char16Converter::SetArg(
966 if (!
bstr)
return false;
970 para.fValue.fLong = (long)val;
971 para.fTypeCode =
'U';
975PyObject* CPyCppyy::Char16Converter::FromMemory(
void* address)
988 if (!
bstr)
return false;
996bool CPyCppyy::Char32Converter::SetArg(
1006 if (!
bstr)
return false;
1010 para.fValue.fLong = (long)val;
1011 para.fTypeCode =
'U';
1015PyObject* CPyCppyy::Char32Converter::FromMemory(
void* address)
1028 if (!
bstr)
return false;
1056bool CPyCppyy::ULongConverter::SetArg(
1066 para.fTypeCode =
'L';
1070PyObject* CPyCppyy::ULongConverter::FromMemory(
void* address)
1083 u = (
unsigned long)0;
1087 *((
unsigned long*)address) =
u;
1092PyObject* CPyCppyy::UIntConverter::FromMemory(
void* address)
1110 *((
unsigned int*)address) = (
unsigned int)
u;
1127bool CPyCppyy::ComplexDConverter::SetArg(
1135 para.fTypeCode =
'V';
1142PyObject* CPyCppyy::ComplexDConverter::FromMemory(
void* address)
1144 std::complex<double>*
dc = (std::complex<double>*)address;
1152 std::complex<double>*
dc = (std::complex<double>*)address;
1157 return this->InstanceConverter::ToMemory(
value, address,
ctxt);
1161bool CPyCppyy::DoubleRefConverter::SetArg(
1165#if PY_VERSION_HEX < 0x03000000
1168 para.fTypeCode =
'V';
1173#if PY_VERSION_HEX >= 0x02050000
1176 para.fTypeCode =
'V';
1183 if (
para.fValue.fVoidp && buflen) {
1184 para.fTypeCode =
'V';
1188#if PY_VERSION_HEX < 0x02050000
1210bool CPyCppyy::LLongConverter::SetArg(
1220 para.fTypeCode =
'q';
1224PyObject* CPyCppyy::LLongConverter::FromMemory(
void* address)
1246bool CPyCppyy::ULLongConverter::SetArg(
1256 para.fTypeCode =
'Q';
1260PyObject* CPyCppyy::ULLongConverter::FromMemory(
void* address)
1282bool CPyCppyy::CStringConverter::SetArg(
1294 para.fTypeCode =
'V';
1305 if (!
ctxt->fPyContext) {
1316 para.fTypeCode =
'p';
1320PyObject* CPyCppyy::CStringConverter::FromMemory(
void* address)
1323 if (address && *(
void**)address) {
1327 if (*(
void**)address == (
void*)
fBuffer.data())
1344 if (!
cstr)
return false;
1353 void*
ptrval = *(
void**)address;
1356 *(
void**)address = (
void*)
fBuffer.data();
1366 *(
void**)address = (
void*)
cstr;
1381bool CPyCppyy::WCStringConverter::SetArg(
1397 para.fTypeCode =
'p';
1401PyObject* CPyCppyy::WCStringConverter::FromMemory(
void* address)
1404 if (address && *(
wchar_t**)address) {
1405 if (
fMaxSize != std::wstring::npos)
1428 if (
fMaxSize != std::wstring::npos)
1434 if (res == -1)
return false;
1439#define CPYCPPYY_WIDESTRING_CONVERTER(name, type, encode, decode, snull) \
1440bool CPyCppyy::name##Converter::SetArg( \
1441 PyObject* pyobject, Parameter& para, CallContext* ) \
1444 PyObject* bstr = encode(pyobject); \
1445 if (!bstr) return false; \
1447 Py_ssize_t len = PyBytes_GET_SIZE(bstr) - sizeof(type) ; \
1448 fBuffer = (type*)realloc(fBuffer, len + sizeof(type)); \
1449 memcpy(fBuffer, PyBytes_AS_STRING(bstr) + sizeof(type) , len); \
1452 fBuffer[len/sizeof(type)] = snull; \
1453 para.fValue.fVoidp = (void*)fBuffer; \
1454 para.fTypeCode = 'p'; \
1458PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
1461 if (address && *(type**)address) { \
1462 if (fMaxSize != std::wstring::npos) \
1463 return decode(*(const char**)address, (Py_ssize_t)fMaxSize*sizeof(type), nullptr, nullptr);\
1464 return decode(*(const char**)address, \
1465 std::char_traits<type>::length(*(type**)address)*sizeof(type), nullptr, nullptr);\
1470 return decode((const char*)&w, 0, nullptr, nullptr); \
1473bool CPyCppyy::name##Converter::ToMemory(PyObject* value, void* address, PyObject* )\
1476 PyObject* bstr = encode(value); \
1477 if (!bstr) return false; \
1479 Py_ssize_t len = PyBytes_GET_SIZE(bstr) - sizeof(type) ; \
1480 Py_ssize_t maxbytes = (Py_ssize_t)fMaxSize*sizeof(type); \
1483 if (fMaxSize != std::wstring::npos && maxbytes < len) { \
1484 PyErr_Warn(PyExc_RuntimeWarning, (char*)"string too long for "#type" array (truncated)");\
1488 memcpy(*((void**)address), PyBytes_AS_STRING(bstr) + sizeof(type) , len);\
1491 if (len/sizeof(type) < fMaxSize) (*(type**)address)[len/sizeof(type)] = snull;\
1499bool CPyCppyy::NonConstCStringConverter::SetArg(
1512PyObject* CPyCppyy::NonConstCStringConverter::FromMemory(
void* address)
1517 return this->CStringConverter::FromMemory(address);
1533 address = (
void*)val;
1561 para.fValue.fVoidp =
pyobj->GetObject();
1562 para.fTypeCode =
'p';
1567 if (GetAddressSpecialCase(
pyobject,
para.fValue.fVoidp)) {
1568 para.fTypeCode =
'p';
1576 para.fValue.fVoidp = (
void*)((CPyCppyy_tagCDataObject*)
pyobject)->b_ptr;
1577 para.fTypeCode =
'V';
1583 void** payload = (
void**)((CPyCppyy_tagCDataObject*)
pyobject)->b_ptr;
1585 para.fValue.fVoidp = *payload;
1586 para.fTypeCode =
'p';
1595 if (
para.fValue.fVoidp && buflen != 0) {
1596 para.fTypeCode =
'p';
1608 if (!address || *(
uintptr_t*)address == 0) {
1626 *(
void**)address =
pyobj->GetObject();
1631 void* ptr =
nullptr;
1632 if (GetAddressSpecialCase(
value, ptr)) {
1633 *(
void**)address = ptr;
1638 void* buf =
nullptr;
1640 if (!buf || buflen == 0)
1643 *(
void**)address = buf;
1685#define CPPYY_IMPL_ARRAY_CONVERTER(name, ctype, type, code, suffix) \
1686CPyCppyy::name##ArrayConverter::name##ArrayConverter(cdims_t dims) : \
1688 fIsFixed = dims ? fShape[0] != UNKNOWN_SIZE : false; \
1691bool CPyCppyy::name##ArrayConverter::SetArg( \
1692 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
1695 bool convOk = false; \
1698 if (fShape.ndim() == 2) { \
1699 if (Py_TYPE(pyobject) == GetCTypesPtrType(ct_##ctype)) { \
1700 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1701 para.fTypeCode = 'p'; \
1703 } else if (Py_TYPE(pyobject) == GetCTypesType(ct_c_void_p)) { \
1705 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1706 para.fTypeCode = 'p'; \
1708 } else if (LowLevelView_Check(pyobject) && \
1709 ((LowLevelView*)pyobject)->fBufInfo.ndim == 2 && \
1710 strchr(((LowLevelView*)pyobject)->fBufInfo.format, code)) { \
1711 para.fValue.fVoidp = ((LowLevelView*)pyobject)->get_buf(); \
1712 para.fTypeCode = 'p'; \
1719 PyTypeObject* ctypes_type = GetCTypesType(ct_##ctype); \
1720 if (Py_TYPE(pyobject) == ctypes_type) { \
1721 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1722 para.fTypeCode = 'p'; \
1724 } else if (Py_TYPE(pyobject) == GetCTypesPtrType(ct_##ctype)) { \
1725 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1726 para.fTypeCode = 'V'; \
1728 } else if (IsPyCArgObject(pyobject)) { \
1729 CPyCppyy_tagPyCArgObject* carg = (CPyCppyy_tagPyCArgObject*)pyobject;\
1730 if (carg->obj && Py_TYPE(carg->obj) == ctypes_type) { \
1731 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)carg->obj)->b_ptr;\
1732 para.fTypeCode = 'p'; \
1740 bool ismulti = fShape.ndim() > 1; \
1741 convOk = CArraySetArg(pyobject, para, code, ismulti ? sizeof(void*) : sizeof(type), true);\
1745 if (convOk) SetLifeLine(ctxt->fPyContext, pyobject, (intptr_t)this); \
1750PyObject* CPyCppyy::name##ArrayConverter::FromMemory(void* address) \
1753 return CreateLowLevelView##suffix((type**)address, fShape); \
1754 return CreateLowLevelView##suffix(*(type**)address, fShape); \
1757bool CPyCppyy::name##ArrayConverter::ToMemory( \
1758 PyObject* value, void* address, PyObject* ctxt) \
1760 if (fShape.ndim() <= 1 || fIsFixed) { \
1761 void* buf = nullptr; \
1762 Py_ssize_t buflen = Utility::GetBuffer(value, code, sizeof(type), buf);\
1763 return ToArrayFromBuffer<type>(value, address, ctxt, buf, buflen, fShape, fIsFixed);\
1765 void* buf = nullptr; \
1766 Py_ssize_t buflen = Utility::GetBuffer(value, code, sizeof(void*), buf);\
1767 if (buflen == 0) return false; \
1768 *(type**)address = (type*)buf; \
1769 SetLifeLine(ctxt, value, (intptr_t)address); \
1802bool CPyCppyy::CStringArrayConverter::SetArg(
1810 para.fTypeCode =
'V';
1814#if PY_VERSION_HEX >= 0x03000000
1822 if (
len == (
size_t)-1) {
1828 for (
size_t i = 0; i <
len; ++i) {
1846 para.fTypeCode =
'p';
1855PyObject* CPyCppyy::CStringArrayConverter::FromMemory(
void* address)
1873 return SCharArrayConverter::ToMemory(
value, address,
ctxt);
1877PyObject* CPyCppyy::NonConstCStringArrayConverter::FromMemory(
void* address)
1891 para.fValue.fVoidp =
nullptr;
1892 para.fTypeCode =
'p';
1907#if PY_VERSION_HEX < 0x03030000
1917 const char*
cstr =
nullptr;
1919 if (
cstr) buffer = T{
cstr, (
typename T::size_type)
len};
1927#define CPPYY_IMPL_STRING_AS_PRIMITIVE_CONVERTER(name, type, F1, F2) \
1928CPyCppyy::name##Converter::name##Converter(bool keepControl) : \
1929 InstanceConverter(Cppyy::GetScope(#type), keepControl) {} \
1931bool CPyCppyy::name##Converter::SetArg( \
1932 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
1934 if (CPyCppyy_PyUnicodeAsBytes2Buffer(pyobject, fBuffer)) { \
1935 para.fValue.fVoidp = &fBuffer; \
1936 para.fTypeCode = 'V'; \
1941 if (!(PyInt_Check(pyobject) || PyLong_Check(pyobject))) { \
1942 bool result = InstanceConverter::SetArg(pyobject, para, ctxt); \
1943 para.fTypeCode = 'V'; \
1950PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
1953 return InstanceConverter::FromMemory(address); \
1954 auto* empty = new type(); \
1955 return BindCppObjectNoCast(empty, fClass, CPPInstance::kIsOwner); \
1958bool CPyCppyy::name##Converter::ToMemory( \
1959 PyObject* value, void* address, PyObject* ctxt) \
1961 if (CPyCppyy_PyUnicodeAsBytes2Buffer(value, *((type*)address))) \
1963 return InstanceConverter::ToMemory(value, address, ctxt); \
1969CPyCppyy::STLWStringConverter::STLWStringConverter(
bool keepControl) :
1972bool CPyCppyy::STLWStringConverter::SetArg(
1980 para.fTypeCode =
'V';
1983#if PY_VERSION_HEX < 0x03000000
1986 std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>
cnv;
1990 if (!
pyu)
return false;
1996 para.fTypeCode =
'V';
2003 para.fTypeCode =
'V';
2010PyObject* CPyCppyy::STLWStringConverter::FromMemory(
void* address)
2022 wchar_t* buf =
new wchar_t[
len+1];
2024 *((std::wstring*)address) = std::wstring(buf,
len);
2028 return InstanceConverter::ToMemory(
value, address,
ctxt);
2032CPyCppyy::STLStringViewConverter::STLStringViewConverter(
bool keepControl) :
2035bool CPyCppyy::STLStringViewConverter::SetArg(
2042 para.fTypeCode =
'V';
2053 fBuffer = std::string_view(
cstr, (std::string_view::size_type)
len);
2055 para.fTypeCode =
'V';
2068 void* ptr =
pyobj->GetObject();
2074 fBuffer = *((std::string*)ptr);
2076 para.fTypeCode =
'V';
2084PyObject* CPyCppyy::STLStringViewConverter::FromMemory(
void* address)
2087 return InstanceConverter::FromMemory(address);
2088 auto* empty =
new std::string_view();
2092bool CPyCppyy::STLStringViewConverter::ToMemory(
2096 if (InstanceConverter::ToMemory(
value, address,
ctxt))
2104 *
reinterpret_cast<std::string_view*
>(address) = \
2105 std::string_view(
cstr, (std::string_view::size_type)
len);
2113bool CPyCppyy::STLStringMoveConverter::SetArg(
2142template <
bool ISCONST>
2149 if (GetAddressSpecialCase(
pyobject,
para.fValue.fVoidp)) {
2150 para.fTypeCode =
'p';
2170 para.fValue.fVoidp =
pyobj->GetObject();
2177 para.fTypeCode =
'p';
2185template <
bool ISCONST>
2195template <
bool ISCONST>
2201 void* ptr =
nullptr;
2202 if (GetAddressSpecialCase(
value, ptr)) {
2203 *(
void**)address = ptr;
2216 *(
void**)address =
pyobj->GetObject();
2226bool CPyCppyy::InstanceConverter::SetArg(
2235 para.fValue.fVoidp =
pyobj->GetObject();
2236 if (!
para.fValue.fVoidp)
2244 para.fTypeCode =
'V';
2253PyObject* CPyCppyy::InstanceConverter::FromMemory(
void* address)
2267#if PY_VERSION_HEX >= 0x03080000
2283bool CPyCppyy::InstanceRefConverter::SetArg(
2298 if (
pyobj->IsSmart()) {
2301 para.fValue.fVoidp =
pyobj->GetObjectRaw();
2309 para.fValue.fVoidp =
pyobj->GetObject();
2316 if (!
para.fValue.fVoidp) {
2327 para.fTypeCode =
'V';
2339PyObject* CPyCppyy::InstanceRefConverter::FromMemory(
void* address)
2345bool CPyCppyy::InstanceMoveConverter::SetArg(
2376template <
bool ISREFERENCE>
2377bool CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::SetArg(
2385 para.fValue.fVoidp =
nullptr;
2386 para.fTypeCode =
'p';
2399 para.fValue.fVoidp =
pyobj->GetObjectRaw();
2401 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2410template <
bool ISREFERENCE>
2411PyObject* CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::FromMemory(
void* address)
2418template <
bool ISREFERENCE>
2419bool CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::ToMemory(
2427 *(
void**)address =
nullptr;
2442 *(
void**)address =
pyobj->GetObject();
2454 template class CPyCppyy::InstancePtrPtrConverter<true>;
2455 template class CPyCppyy::InstancePtrPtrConverter<false>;
2459bool CPyCppyy::InstanceArrayConverter::SetArg(
2478 para.fTypeCode =
'p';
2486PyObject* CPyCppyy::InstanceArrayConverter::FromMemory(
void* address)
2493bool CPyCppyy::InstanceArrayConverter::ToMemory(
2500 "access to C-arrays of objects not yet implemented!");
2507bool CPyCppyy::STLIteratorConverter::SetArg(
2515 para.fValue.fVoidp =
pyobj->GetObject();
2516 para.fTypeCode =
'V';
2522bool CPyCppyy::VoidPtrRefConverter::SetArg(
2528 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2529 para.fTypeCode =
'V';
2537CPyCppyy::VoidPtrPtrConverter::VoidPtrPtrConverter(
cdims_t dims) :
2543bool CPyCppyy::VoidPtrPtrConverter::SetArg(
2550 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2551 para.fTypeCode =
'p';
2557 para.fTypeCode =
'p';
2567 if (
para.fValue.fVoidp && buflen != 0) {
2568 para.fTypeCode =
'p';
2576PyObject* CPyCppyy::VoidPtrPtrConverter::FromMemory(
void* address)
2579 if (!address || *(ptrdiff_t*)address == 0) {
2589bool CPyCppyy::PyObjectConverter::SetArg(
2594 para.fTypeCode =
'p';
2598PyObject* CPyCppyy::PyObjectConverter::FromMemory(
void* address)
2634 auto key =
ipos->second.second;
2652 const_cast<char*
>(
"internal_WrapperCacheEraser"),
2668 if (!
ol->fMethodInfo ||
ol->fMethodInfo->fMethods.empty())
2672 for (
auto&
m :
ol->fMethodInfo->fMethods) {
2677 void*
fptr = (
void*)
m->GetFunctionAddress();
2687 std::string fullname =
pytmpl->fTI->fCppName;
2688 if (
pytmpl->fTemplateArgs)
2742 std::ostringstream
wname;
2746 std::ostringstream code;
2747 code <<
"namespace __cppyy_internal {\n "
2749 for (
int i = 0; i <
nArgs; ++i) {
2750 code <<
argtypes[i] <<
" arg" << i;
2751 if (i !=
nArgs-1) code <<
", ";
2762 code <<
" PyObject** ref = (PyObject**)" << (intptr_t)
ref <<
";\n"
2763 " PyObject* pyresult = nullptr;\n"
2764 " if (*ref) pyresult = PyObject_CallFunctionObjArgs(*ref";
2765 for (
int i = 0; i <
nArgs; ++i)
2766 code <<
", pyargs[" << i <<
"]";
2767 code <<
", NULL);\n"
2768 " else PyErr_SetString(PyExc_TypeError, \"callable was deleted\");\n";
2800bool CPyCppyy::FunctionPointerConverter::SetArg(
2805 para.fValue.fVoidp =
nullptr;
2806 para.fTypeCode =
'p';
2815 para.fTypeCode =
'p';
2822PyObject* CPyCppyy::FunctionPointerConverter::FromMemory(
void* address)
2833bool CPyCppyy::FunctionPointerConverter::ToMemory(
2838 *((
void**)address) =
nullptr;
2846 *((
void**)address) =
fptr;
2855bool CPyCppyy::StdFunctionConverter::SetArg(
2869 PyObject* func = this->FunctionPointerConverter::FromMemory(&
para.fValue.fVoidp);
2882PyObject* CPyCppyy::StdFunctionConverter::FromMemory(
void* address)
2897bool CPyCppyy::SmartPtrConverter::SetArg(
2924 para.fValue.fVoidp =
pyobj->GetSmartObject();
2939 para.fValue.fVoidp =
pyobj->GetObject();
2962 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)
3141 if (
memloc) entries += 1;
3144 "default ctor needed for initializer list of objects");
3161#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3162 fake->_M_len = (faux_initlist::size_type)entries;
3163#elif defined (_MSC_VER)
3176 para.fTypeCode =
'V';
3197 if (
cpd ==
"**" ||
cpd ==
"*[]" ||
cpd ==
"&*")
3199 else if (
cpd ==
"*&")
3205 else if (
cpd ==
"&")
3207 else if (
cpd ==
"&&")
3233 return (
h->second)(
dims);
3243 return (
h->second)(
dims);
3254 return (
h->second)(
dims);
3261 return (
h->second)(
dims);
3265 if (
cpd.compare(0, 3,
"*[]") == 0) {
3279 for (
int i = 2; i < (
newdim-1); ++i)
3285 return (
h->second)(
dims);
3288 }
else if (!
cpd.empty() && (std::string::size_type)std::count(
cpd.
begin(),
cpd.
end(),
'*') ==
cpd.size()) {
3294 }
else if (2 <=
cpd.size() && (std::string::size_type)std::count(
cpd.
begin(),
cpd.
end(),
'[') ==
cpd.size() / 2) {
3298 return (
h->second)(
dims);
3302 if (
realType.compare(0, 16,
"initializer_list") == 0) {
3314 if (pos == 0 || pos == 5 ||
3315 pos == 6 || pos == 11 ) {
3325 if (
pos1 != std::string::npos &&
pos2 != std::string::npos) {
3329 return new StdFunctionConverter(
cnv,
3331 }
else if (
cnv->HasState())
3343 }
else if (
cpd ==
"&") {
3353 static STLIteratorConverter
c;
3363 auto pos1 =
sm.position(0);
3365 result =
new FunctionPointerConverter(
3374 return (
h->second)(
dims);
3376 result =
new NotImplementedConverter();
3384 if (
cpd.size() == 2 &&
cpd !=
"&&")
3385 result =
new VoidPtrPtrConverter(
dims.ndim());
3386 else if (!
cpd.empty())
3389 result =
new NotImplementedConverter();
3399 if (
p &&
p->HasState())
3457#define STRINGVIEW "basic_string_view<char,char_traits<char> >"
3458#define WSTRING1 "std::basic_string<wchar_t>"
3459#define WSTRING2 "std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>"
3463#define CCOMPLEX_D "_Complex double"
3464#define CCOMPLEX_F "_Complex float"
3466#define CCOMPLEX_D "_C_double_complex"
3467#define CCOMPLEX_F "_C_float_complex"
3470static struct InitConvFactories_t {
3472 InitConvFactories_t() {
3477 gf[
"bool"] = (
cf_t)+[](
cdims_t) {
static BoolConverter
c{};
return &
c; };
3478 gf[
"const bool&"] = (
cf_t)+[](
cdims_t) {
static ConstBoolRefConverter
c{};
return &
c; };
3479 gf[
"bool&"] = (
cf_t)+[](
cdims_t) {
static BoolRefConverter
c{};
return &
c; };
3480 gf[
"char"] = (
cf_t)+[](
cdims_t) {
static CharConverter
c{};
return &
c; };
3481 gf[
"const char&"] = (
cf_t)+[](
cdims_t) {
static ConstCharRefConverter
c{};
return &
c; };
3482 gf[
"char&"] = (
cf_t)+[](
cdims_t) {
static CharRefConverter
c{};
return &
c; };
3483 gf[
"signed char&"] = (
cf_t)+[](
cdims_t) {
static SCharRefConverter
c{};
return &
c; };
3484 gf[
"unsigned char"] = (
cf_t)+[](
cdims_t) {
static UCharConverter
c{};
return &
c; };
3485 gf[
"const unsigned char&"] = (
cf_t)+[](
cdims_t) {
static ConstUCharRefConverter
c{};
return &
c; };
3486 gf[
"unsigned char&"] = (
cf_t)+[](
cdims_t) {
static UCharRefConverter
c{};
return &
c; };
3487 gf[
"SCharAsInt"] = (
cf_t)+[](
cdims_t) {
static SCharAsIntConverter
c{};
return &
c; };
3488 gf[
"UCharAsInt"] = (
cf_t)+[](
cdims_t) {
static UCharAsIntConverter
c{};
return &
c; };
3489 gf[
"wchar_t"] = (
cf_t)+[](
cdims_t) {
static WCharConverter
c{};
return &
c; };
3490 gf[
"char16_t"] = (
cf_t)+[](
cdims_t) {
static Char16Converter
c{};
return &
c; };
3491 gf[
"char32_t"] = (
cf_t)+[](
cdims_t) {
static Char32Converter
c{};
return &
c; };
3492 gf[
"wchar_t&"] = (
cf_t)+[](
cdims_t) {
static WCharRefConverter
c{};
return &
c; };
3493 gf[
"char16_t&"] = (
cf_t)+[](
cdims_t) {
static Char16RefConverter
c{};
return &
c; };
3494 gf[
"char32_t&"] = (
cf_t)+[](
cdims_t) {
static Char32RefConverter
c{};
return &
c; };
3495 gf[
"int8_t"] = (
cf_t)+[](
cdims_t) {
static Int8Converter
c{};
return &
c; };
3496 gf[
"const int8_t&"] = (
cf_t)+[](
cdims_t) {
static ConstInt8RefConverter
c{};
return &
c; };
3497 gf[
"int8_t&"] = (
cf_t)+[](
cdims_t) {
static Int8RefConverter
c{};
return &
c; };
3498 gf[
"int16_t"] = (
cf_t)+[](
cdims_t) {
static Int16Converter
c{};
return &
c; };
3499 gf[
"const int16_t&"] = (
cf_t)+[](
cdims_t) {
static ConstInt16RefConverter
c{};
return &
c; };
3500 gf[
"int16_t&"] = (
cf_t)+[](
cdims_t) {
static Int16RefConverter
c{};
return &
c; };
3501 gf[
"int32_t"] = (
cf_t)+[](
cdims_t) {
static Int32Converter
c{};
return &
c; };
3502 gf[
"const int32_t&"] = (
cf_t)+[](
cdims_t) {
static ConstInt32RefConverter
c{};
return &
c; };
3503 gf[
"int32_t&"] = (
cf_t)+[](
cdims_t) {
static Int32RefConverter
c{};
return &
c; };
3504 gf[
"uint8_t"] = (
cf_t)+[](
cdims_t) {
static UInt8Converter
c{};
return &
c; };
3505 gf[
"const uint8_t&"] = (
cf_t)+[](
cdims_t) {
static ConstUInt8RefConverter
c{};
return &
c; };
3506 gf[
"uint8_t&"] = (
cf_t)+[](
cdims_t) {
static UInt8RefConverter
c{};
return &
c; };
3507 gf[
"uint16_t"] = (
cf_t)+[](
cdims_t) {
static UInt16Converter
c{};
return &
c; };
3508 gf[
"const uint16_t&"] = (
cf_t)+[](
cdims_t) {
static ConstUInt16RefConverter
c{};
return &
c; };
3509 gf[
"uint16_t&"] = (
cf_t)+[](
cdims_t) {
static UInt16RefConverter
c{};
return &
c; };
3510 gf[
"uint32_t"] = (
cf_t)+[](
cdims_t) {
static UInt32Converter
c{};
return &
c; };
3511 gf[
"const uint32_t&"] = (
cf_t)+[](
cdims_t) {
static ConstUInt32RefConverter
c{};
return &
c; };
3512 gf[
"uint32_t&"] = (
cf_t)+[](
cdims_t) {
static UInt32RefConverter
c{};
return &
c; };
3513 gf[
"short"] = (
cf_t)+[](
cdims_t) {
static ShortConverter
c{};
return &
c; };
3514 gf[
"const short&"] = (
cf_t)+[](
cdims_t) {
static ConstShortRefConverter
c{};
return &
c; };
3515 gf[
"short&"] = (
cf_t)+[](
cdims_t) {
static ShortRefConverter
c{};
return &
c; };
3516 gf[
"unsigned short"] = (
cf_t)+[](
cdims_t) {
static UShortConverter
c{};
return &
c; };
3517 gf[
"const unsigned short&"] = (
cf_t)+[](
cdims_t) {
static ConstUShortRefConverter
c{};
return &
c; };
3518 gf[
"unsigned short&"] = (
cf_t)+[](
cdims_t) {
static UShortRefConverter
c{};
return &
c; };
3519 gf[
"int"] = (
cf_t)+[](
cdims_t) {
static IntConverter
c{};
return &
c; };
3520 gf[
"int&"] = (
cf_t)+[](
cdims_t) {
static IntRefConverter
c{};
return &
c; };
3521 gf[
"const int&"] = (
cf_t)+[](
cdims_t) {
static ConstIntRefConverter
c{};
return &
c; };
3522 gf[
"unsigned int"] = (
cf_t)+[](
cdims_t) {
static UIntConverter
c{};
return &
c; };
3523 gf[
"const unsigned int&"] = (
cf_t)+[](
cdims_t) {
static ConstUIntRefConverter
c{};
return &
c; };
3524 gf[
"unsigned int&"] = (
cf_t)+[](
cdims_t) {
static UIntRefConverter
c{};
return &
c; };
3525 gf[
"long"] = (
cf_t)+[](
cdims_t) {
static LongConverter
c{};
return &
c; };
3526 gf[
"long&"] = (
cf_t)+[](
cdims_t) {
static LongRefConverter
c{};
return &
c; };
3527 gf[
"const long&"] = (
cf_t)+[](
cdims_t) {
static ConstLongRefConverter
c{};
return &
c; };
3528 gf[
"unsigned long"] = (
cf_t)+[](
cdims_t) {
static ULongConverter
c{};
return &
c; };
3529 gf[
"const unsigned long&"] = (
cf_t)+[](
cdims_t) {
static ConstULongRefConverter
c{};
return &
c; };
3530 gf[
"unsigned long&"] = (
cf_t)+[](
cdims_t) {
static ULongRefConverter
c{};
return &
c; };
3531 gf[
"long long"] = (
cf_t)+[](
cdims_t) {
static LLongConverter
c{};
return &
c; };
3532 gf[
"const long long&"] = (
cf_t)+[](
cdims_t) {
static ConstLLongRefConverter
c{};
return &
c; };
3533 gf[
"long long&"] = (
cf_t)+[](
cdims_t) {
static LLongRefConverter
c{};
return &
c; };
3534 gf[
"unsigned long long"] = (
cf_t)+[](
cdims_t) {
static ULLongConverter
c{};
return &
c; };
3535 gf[
"const unsigned long long&"] = (
cf_t)+[](
cdims_t) {
static ConstULLongRefConverter
c{};
return &
c; };
3536 gf[
"unsigned long long&"] = (
cf_t)+[](
cdims_t) {
static ULLongRefConverter
c{};
return &
c; };
3538 gf[
"float"] = (
cf_t)+[](
cdims_t) {
static FloatConverter
c{};
return &
c; };
3539 gf[
"const float&"] = (
cf_t)+[](
cdims_t) {
static ConstFloatRefConverter
c{};
return &
c; };
3540 gf[
"float&"] = (
cf_t)+[](
cdims_t) {
static FloatRefConverter
c{};
return &
c; };
3541 gf[
"double"] = (
cf_t)+[](
cdims_t) {
static DoubleConverter
c{};
return &
c; };
3542 gf[
"double&"] = (
cf_t)+[](
cdims_t) {
static DoubleRefConverter
c{};
return &
c; };
3543 gf[
"const double&"] = (
cf_t)+[](
cdims_t) {
static ConstDoubleRefConverter
c{};
return &
c; };
3544 gf[
"long double"] = (
cf_t)+[](
cdims_t) {
static LDoubleConverter
c{};
return &
c; };
3545 gf[
"const long double&"] = (
cf_t)+[](
cdims_t) {
static ConstLDoubleRefConverter
c{};
return &
c; };
3546 gf[
"long double&"] = (
cf_t)+[](
cdims_t) {
static LDoubleRefConverter
c{};
return &
c; };
3547 gf[
"std::complex<double>"] = (
cf_t)+[](
cdims_t) {
return new ComplexDConverter{}; };
3548 gf[
"const std::complex<double>&"] = (
cf_t)+[](
cdims_t) {
return new ComplexDConverter{}; };
3549 gf[
"void"] = (
cf_t)+[](
cdims_t) {
static VoidConverter
c{};
return &
c; };
3552 gf[
"bool ptr"] = (
cf_t)+[](
cdims_t d) {
return new BoolArrayConverter{
d}; };
3553 gf[
"signed char ptr"] = (
cf_t)+[](
cdims_t d) {
return new SCharArrayConverter{
d}; };
3555 gf[
"const unsigned char*"] = (
cf_t)+[](
cdims_t d) {
return new UCharArrayConverter{
d}; };
3556 gf[
"unsigned char ptr"] = (
cf_t)+[](
cdims_t d) {
return new UCharArrayConverter{
d}; };
3557 gf[
"SCharAsInt*"] =
gf[
"signed char ptr"];
3558 gf[
"SCharAsInt[]"] =
gf[
"signed char ptr"];
3559 gf[
"UCharAsInt*"] =
gf[
"unsigned char ptr"];
3560 gf[
"UCharAsInt[]"] =
gf[
"unsigned char ptr"];
3561 gf[
"std::byte ptr"] = (
cf_t)+[](
cdims_t d) {
return new ByteArrayConverter{
d}; };
3562 gf[
"int8_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new Int8ArrayConverter{
d}; };
3563 gf[
"int16_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new Int16ArrayConverter{
d}; };
3564 gf[
"int32_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new Int32ArrayConverter{
d}; };
3565 gf[
"uint8_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new UInt8ArrayConverter{
d}; };
3566 gf[
"uint16_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new UInt16ArrayConverter{
d}; };
3567 gf[
"uint32_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new UInt32ArrayConverter{
d}; };
3568 gf[
"short ptr"] = (
cf_t)+[](
cdims_t d) {
return new ShortArrayConverter{
d}; };
3569 gf[
"unsigned short ptr"] = (
cf_t)+[](
cdims_t d) {
return new UShortArrayConverter{
d}; };
3570 gf[
"int ptr"] = (
cf_t)+[](
cdims_t d) {
return new IntArrayConverter{
d}; };
3571 gf[
"unsigned int ptr"] = (
cf_t)+[](
cdims_t d) {
return new UIntArrayConverter{
d}; };
3572 gf[
"long ptr"] = (
cf_t)+[](
cdims_t d) {
return new LongArrayConverter{
d}; };
3573 gf[
"unsigned long ptr"] = (
cf_t)+[](
cdims_t d) {
return new ULongArrayConverter{
d}; };
3574 gf[
"long long ptr"] = (
cf_t)+[](
cdims_t d) {
return new LLongArrayConverter{
d}; };
3575 gf[
"unsigned long long ptr"] = (
cf_t)+[](
cdims_t d) {
return new ULLongArrayConverter{
d}; };
3576 gf[
"float ptr"] = (
cf_t)+[](
cdims_t d) {
return new FloatArrayConverter{
d}; };
3577 gf[
"double ptr"] = (
cf_t)+[](
cdims_t d) {
return new DoubleArrayConverter{
d}; };
3578 gf[
"long double ptr"] = (
cf_t)+[](
cdims_t d) {
return new LDoubleArrayConverter{
d}; };
3579 gf[
"std::complex<float> ptr"] = (
cf_t)+[](
cdims_t d) {
return new ComplexFArrayConverter{
d}; };
3580 gf[
"std::complex<double> ptr"] = (
cf_t)+[](
cdims_t d) {
return new ComplexDArrayConverter{
d}; };
3584 gf[
"signed char"] =
gf[
"char"];
3585 gf[
"const signed char&"] =
gf[
"const char&"];
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&"];
3592 gf[
"std::int8_t"] =
gf[
"int8_t"];
3593 gf[
"const std::int8_t&"] =
gf[
"const int8_t&"];
3594 gf[
"std::int8_t&"] =
gf[
"int8_t&"];
3595 gf[
"std::uint8_t"] =
gf[
"uint8_t"];
3596 gf[
"const std::uint8_t&"] =
gf[
"const uint8_t&"];
3597 gf[
"std::uint8_t&"] =
gf[
"uint8_t&"];
3598 gf[
"internal_enum_type_t"] =
gf[
"int"];
3599 gf[
"internal_enum_type_t&"] =
gf[
"int&"];
3600 gf[
"const internal_enum_type_t&"] =
gf[
"const int&"];
3601 gf[
"internal_enum_type_t ptr"] =
gf[
"int ptr"];
3603 gf[
"__int64"] =
gf[
"long long"];
3604 gf[
"const __int64&"] =
gf[
"const long long&"];
3605 gf[
"__int64&"] =
gf[
"long long&"];
3606 gf[
"__int64 ptr"] =
gf[
"long long ptr"];
3607 gf[
"unsigned __int64"] =
gf[
"unsigned long long"];
3608 gf[
"const unsigned __int64&"] =
gf[
"const unsigned long long&"];
3609 gf[
"unsigned __int64&"] =
gf[
"unsigned long long&"];
3610 gf[
"unsigned __int64 ptr"] =
gf[
"unsigned long long ptr"];
3618 gf[
"nullptr_t"] = (
cf_t)+[](
cdims_t) {
static NullptrConverter
c{};
return &
c;};
3619 gf[
"const char*"] = (
cf_t)+[](
cdims_t) {
return new CStringConverter{}; };
3620 gf[
"const signed char*"] =
gf[
"const char*"];
3621 gf[
"const char*&&"] =
gf[
"const char*"];
3622 gf[
"const char[]"] = (
cf_t)+[](
cdims_t) {
return new CStringConverter{}; };
3624 gf[
"char[]"] = (
cf_t)+[](
cdims_t d) {
return new NonConstCStringArrayConverter{
d,
true}; };
3625 gf[
"signed char*"] =
gf[
"char*"];
3626 gf[
"wchar_t*"] = (
cf_t)+[](
cdims_t) {
return new WCStringConverter{}; };
3627 gf[
"char16_t*"] = (
cf_t)+[](
cdims_t) {
return new CString16Converter{}; };
3629 gf[
"char32_t*"] = (
cf_t)+[](
cdims_t) {
return new CString32Converter{}; };
3632 gf[
"char16_t**"] =
gf[
"char16_t*"];
3633 gf[
"char32_t**"] =
gf[
"char32_t*"];
3635 gf[
"char**"] =
gf[
"const char**"];
3636 gf[
"const char*[]"] = (
cf_t)+[](
cdims_t d) {
return new CStringArrayConverter{
d,
false}; };
3637 gf[
"char*[]"] = (
cf_t)+[](
cdims_t d) {
return new NonConstCStringArrayConverter{
d,
false}; };
3638 gf[
"char ptr"] =
gf[
"char*[]"];
3639 gf[
"std::string"] = (
cf_t)+[](
cdims_t) {
return new STLStringConverter{}; };
3640 gf[
"const std::string&"] =
gf[
"std::string"];
3641 gf[
"string"] =
gf[
"std::string"];
3642 gf[
"const string&"] =
gf[
"std::string"];
3643 gf[
"std::string&&"] = (
cf_t)+[](
cdims_t) {
return new STLStringMoveConverter{}; };
3644 gf[
"string&&"] =
gf[
"std::string&&"];
3645 gf[
"std::string_view"] = (
cf_t)+[](
cdims_t) {
return new STLStringViewConverter{}; };
3647 gf[
"std::string_view&"] =
gf[
"std::string_view"];
3648 gf[
"const std::string_view&"] =
gf[
"std::string_view"];
3650 gf[
"std::wstring"] = (
cf_t)+[](
cdims_t) {
return new STLWStringConverter{}; };
3653 gf[
"const std::wstring&"] =
gf[
"std::wstring"];
3656 gf[
"void*&"] = (
cf_t)+[](
cdims_t) {
static VoidPtrRefConverter
c{};
return &
c; };
3657 gf[
"void**"] = (
cf_t)+[](
cdims_t d) {
return new VoidPtrPtrConverter{
d}; };
3658 gf[
"void ptr"] =
gf[
"void**"];
3659 gf[
"PyObject*"] = (
cf_t)+[](
cdims_t) {
static PyObjectConverter
c{};
return &
c; };
3660 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 unsigned short CPyCppyy_PyLong_AsUShort(PyObject *pyobject)
static int32_t CPyCppyy_PyLong_AsInt32(PyObject *pyobject)
static std::array< PyTypeObject *, 27 > gCTypesTypes
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)
static std::array< PyTypeObject *, 27 > gCTypesPtrTypes
#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 PyMethodDef gWrapperCacheEraserMethodDef
#define CPPYY_IMPL_BASIC_CONST_REFCONVERTER(name, type, ctype, F1)
static std::array< const char *, 27 > 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)
bool PyUnstable_Object_IsUniqueReferencedTemporary(PyObject *pyobject)
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)
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)
bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr) override
bool SetArg(PyObject *, Parameter &, CallContext *=nullptr) override
PyObject * FromMemory(void *address) override
static bool RegisterPyObject(CPPInstance *pyobj, void *cppobj)
PyObject * FromMemory(void *address) override
virtual bool GetAddressSpecialCase(PyObject *pyobject, void *&address)
bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr) override
bool SetArg(PyObject *, Parameter &, CallContext *=nullptr) override
Internal::TypedIter< T, decltype(std::begin(std::declval< Range_t >())), isDynamic > iterator
const_iterator begin() const
const_iterator end() const
unsigned long long PY_ULONG_LONG
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)
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)
bool UseStrictOwnership()
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)
@ kImplicitSmartPtrConversion
PyObject_HEAD char * b_ptr
PyObject_HEAD void * pffi_type
union CPyCppyy_tagPyCArgObject::@199 value