32#if __cplusplus >= 202002L
39#if PY_VERSION_HEX < 0x03000000
40#if defined(__GNUC__) && !defined(__APPLE__)
41# if __GNUC__ > 4 && __has_include("codecvt")
64 static std::regex
s_fnptr(
"\\((\\w*:*)*\\*&*\\)");
69#if PY_VERSION_HEX < 0x030e0000
70#if PY_VERSION_HEX < 0x03000000
72#elif PY_VERSION_HEX < 0x03080000
122#define ct_c_uint32 10
125#define ct_c_longlong 13
126#define ct_c_ulonglong 14
128#define ct_c_double 16
129#define ct_c_longdouble 17
130#define ct_c_char_p 18
131#define ct_c_wchar_p 19
132#define ct_c_void_p 20
133#define ct_c_fcomplex 21
134#define ct_c_complex 22
135#define ct_c_pointer 23
136#define ct_c_funcptr 24
142 "c_bool",
"c_char",
"c_wchar",
"c_byte",
"c_ubyte",
"c_short",
"c_ushort",
"c_uint16",
143 "c_int",
"c_uint",
"c_uint32",
"c_long",
"c_ulong",
"c_longlong",
"c_ulonglong",
144 "c_float",
"c_double",
"c_longdouble",
145 "c_char_p",
"c_wchar_p",
"c_void_p",
"c_fcomplex",
"c_complex",
146 "_Pointer",
"_CFuncPtr" };
220#if PY_VERSION_HEX < 0x30d0000
280 if (!
holder)
return false;
294 if (!
holder)
return false;
385#define CPPYY_PYLONG_AS_TYPE(name, type, limit_low, limit_high) \
386static inline type CPyCppyy_PyLong_As##name(PyObject* pyobject) \
388 if (!(PyLong_Check(pyobject) || PyInt_Check(pyobject))) { \
389 if (pyobject == CPyCppyy::gDefaultObject) \
391 PyErr_SetString(PyExc_TypeError, #type" conversion expects an integer object");\
394 long l = PyLong_AsLong(pyobject); \
395 if (l < limit_low || limit_high < l) { \
396 PyErr_Format(PyExc_ValueError, "integer %ld out of range for "#type, l);\
454 "could not convert argument to buffer or nullptr");
462 para.fValue.fVoidp =
nullptr;
468 para.fValue.fVoidp =
nullptr;
471 "could not convert argument to buffer or nullptr");
476 para.fTypeCode =
'p';
529 para.fValue.fVoidp =
pytmp->GetObjectRaw();
530 para.fTypeCode =
'V';
563#define CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc)\
565 type val = (type)F2(pyobject); \
566 if (val == (type)-1 && PyErr_Occurred()) { \
567 static PyTypeObject* ctypes_type = nullptr; \
568 if (!ctypes_type) { \
569 auto error = CPyCppyy::Utility::FetchPyError(); \
570 ctypes_type = GetCTypesType(ct_##ctype); \
571 CPyCppyy::Utility::RestorePyError(error); \
573 if (Py_TYPE(pyobject) == ctypes_type) { \
575 val = *((type*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr); \
576 } else if (pyobject == CPyCppyy::gDefaultObject) { \
582 para.fValue.f##name = val; \
583 para.fTypeCode = tc; \
586#define CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2) \
587PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
589 return F1((stype)*((type*)address)); \
592bool CPyCppyy::name##Converter::ToMemory( \
593 PyObject* value, void* address, PyObject* ) \
595 type s = (type)F2(value); \
596 if (s == (type)-1 && PyErr_Occurred()) { \
597 if (value == CPyCppyy::gDefaultObject) { \
603 *((type*)address) = (type)s; \
607#define CPPYY_IMPL_BASIC_CONVERTER_NI(name, type, stype, ctype, F1, F2, tc) \
608bool CPyCppyy::name##Converter::SetArg( \
609 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
611 if (!StrictBool(pyobject, ctxt)) \
613 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
615CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
617#define CPPYY_IMPL_BASIC_CONVERTER_IB(name, type, stype, ctype, F1, F2, tc) \
618bool CPyCppyy::name##Converter::SetArg( \
619 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
621 if (!ImplicitBool(pyobject, ctxt)) \
623 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
625CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
627#define CPPYY_IMPL_BASIC_CONVERTER_NB(name, type, stype, ctype, F1, F2, tc) \
628bool CPyCppyy::name##Converter::SetArg( \
629 PyObject* pyobject, Parameter& para, CallContext* ) \
631 if (PyBool_Check(pyobject)) \
633 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
635CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
661 "integer to character: value %d not in range [%d,%d]",
lchar, low, high);
671#define CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(name, ctype) \
672PyObject* CPyCppyy::name##RefConverter::FromMemory(void* ptr) \
675 PyTypeObject* ctypes_type = GetCTypesType(ct_##ctype); \
676 if (!ctypes_type) { \
677 PyErr_SetString(PyExc_RuntimeError, "no ctypes available"); \
680 PyObject* ref = ctypes_type->tp_new(ctypes_type, nullptr, nullptr); \
681 ((CPyCppyy_tagCDataObject*)ref)->b_ptr = (char*)ptr; \
682 ((CPyCppyy_tagCDataObject*)ref)->b_needsfree = 0; \
687#define CPPYY_IMPL_BASIC_CONST_REFCONVERTER(name, type, ctype, F1) \
688bool CPyCppyy::Const##name##RefConverter::SetArg( \
689 PyObject* pyobject, Parameter& para, CallContext* ) \
691 type val = (type)F1(pyobject); \
692 if (val == (type)-1 && PyErr_Occurred()) { \
693 if (pyobject == CPyCppyy::gDefaultObject) { \
699 para.fValue.f##name = val; \
700 para.fRef = ¶.fValue.f##name; \
701 para.fTypeCode = 'r'; \
704CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(Const##name, ctype)
707#define CPPYY_IMPL_BASIC_CONST_CHAR_REFCONVERTER(name, type, ctype, low, high)\
708bool CPyCppyy::Const##name##RefConverter::SetArg( \
709 PyObject* pyobject, Parameter& para, CallContext* ) \
712 type val = (type)ExtractChar(pyobject, #type, low, high); \
713 if (val == (type)-1 && PyErr_Occurred()) \
715 para.fValue.fLong = val; \
716 para.fTypeCode = 'l'; \
719CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(Const##name, ctype)
723#define CPPYY_IMPL_BASIC_CHAR_CONVERTER(name, type, low, high) \
724bool CPyCppyy::name##Converter::SetArg( \
725 PyObject* pyobject, Parameter& para, CallContext* ) \
728 long val = ExtractChar(pyobject, #type, low, high); \
729 if (val == -1 && PyErr_Occurred()) \
731 para.fValue.fLong = val; \
732 para.fTypeCode = 'l'; \
736PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
739 return CPyCppyy_PyText_FromFormat("%c", *((type*)address)); \
742bool CPyCppyy::name##Converter::ToMemory( \
743 PyObject* value, void* address, PyObject* ) \
746 const char* cstr = nullptr; \
747 if (PyBytes_Check(value)) \
748 PyBytes_AsStringAndSize(value, (char**)&cstr, &len); \
750 cstr = CPyCppyy_PyText_AsStringAndSize(value, &len); \
753 PyErr_Format(PyExc_TypeError, #type" expected, got string of size %zd", len);\
756 *((type*)address) = (type)cstr[0]; \
759 long l = PyLong_AsLong(value); \
760 if (l == -1 && PyErr_Occurred()) { \
761 if (value == CPyCppyy::gDefaultObject) { \
767 if (!(low <= l && l <= high)) { \
768 PyErr_Format(PyExc_ValueError, \
769 "integer to character: value %ld not in range [%d,%d]", l, low, high);\
772 *((type*)address) = (type)l; \
786#if PY_VERSION_HEX < 0x03000000
789 para.fTypeCode =
'V';
796 para.fTypeCode =
'V';
801 para.fTypeCode =
'V';
830bool CPyCppyy::IntRefConverter::SetArg(
834#if PY_VERSION_HEX < 0x03000000
837 para.fTypeCode =
'V';
842#if PY_VERSION_HEX >= 0x02050000
845 para.fTypeCode =
'V';
852 if (
para.fValue.fVoidp && buflen) {
853 para.fTypeCode =
'V';
857#if PY_VERSION_HEX < 0x02050000
866#define CPPYY_IMPL_REFCONVERTER(name, ctype, type, code) \
867bool CPyCppyy::name##RefConverter::SetArg( \
868 PyObject* pyobject, Parameter& para, CallContext* ) \
871 if (Py_TYPE(pyobject) == GetCTypesType(ct_##ctype)) { \
872 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
873 para.fTypeCode = 'V'; \
876 bool res = CArraySetArg(pyobject, para, code, sizeof(type)); \
878 PyErr_SetString(PyExc_TypeError, "use ctypes."#ctype" for pass-by-ref of "#type);\
881 para.fTypeCode = 'V'; \
884CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(name, ctype)
928PyObject* CPyCppyy::UCharAsIntConverter::FromMemory(
void* address)
936bool CPyCppyy::WCharConverter::SetArg(
948 para.fValue.fLong = (long)val;
949 para.fTypeCode =
'U';
953PyObject* CPyCppyy::WCharConverter::FromMemory(
void* address)
968 *((
wchar_t*)address) = val;
973bool CPyCppyy::Char16Converter::SetArg(
983 if (!
bstr)
return false;
987 para.fValue.fLong = (long)val;
988 para.fTypeCode =
'U';
992PyObject* CPyCppyy::Char16Converter::FromMemory(
void* address)
1005 if (!
bstr)
return false;
1013bool CPyCppyy::Char32Converter::SetArg(
1023 if (!
bstr)
return false;
1027 para.fValue.fLong = (long)val;
1028 para.fTypeCode =
'U';
1032PyObject* CPyCppyy::Char32Converter::FromMemory(
void* address)
1045 if (!
bstr)
return false;
1073bool CPyCppyy::ULongConverter::SetArg(
1083 para.fTypeCode =
'L';
1087PyObject* CPyCppyy::ULongConverter::FromMemory(
void* address)
1100 u = (
unsigned long)0;
1104 *((
unsigned long*)address) =
u;
1109PyObject* CPyCppyy::UIntConverter::FromMemory(
void* address)
1127 *((
unsigned int*)address) = (
unsigned int)
u;
1144bool CPyCppyy::ComplexDConverter::SetArg(
1152 para.fTypeCode =
'V';
1159PyObject* CPyCppyy::ComplexDConverter::FromMemory(
void* address)
1161 std::complex<double>*
dc = (std::complex<double>*)address;
1169 std::complex<double>*
dc = (std::complex<double>*)address;
1174 return this->InstanceConverter::ToMemory(
value, address,
ctxt);
1178bool CPyCppyy::DoubleRefConverter::SetArg(
1182#if PY_VERSION_HEX < 0x03000000
1185 para.fTypeCode =
'V';
1190#if PY_VERSION_HEX >= 0x02050000
1193 para.fTypeCode =
'V';
1200 if (
para.fValue.fVoidp && buflen) {
1201 para.fTypeCode =
'V';
1205#if PY_VERSION_HEX < 0x02050000
1227bool CPyCppyy::LLongConverter::SetArg(
1237 para.fTypeCode =
'q';
1241PyObject* CPyCppyy::LLongConverter::FromMemory(
void* address)
1263bool CPyCppyy::ULLongConverter::SetArg(
1273 para.fTypeCode =
'Q';
1277PyObject* CPyCppyy::ULLongConverter::FromMemory(
void* address)
1299bool CPyCppyy::CStringConverter::SetArg(
1311 para.fTypeCode =
'V';
1323 if (!
ctxt->fPyContext) {
1334 para.fTypeCode =
'p';
1338PyObject* CPyCppyy::CStringConverter::FromMemory(
void* address)
1341 if (address && *(
void**)address) {
1345 if (*(
void**)address == (
void*)
fBuffer.data())
1362 if (!
cstr)
return false;
1372 void*
ptrval = *(
void**)address;
1375 *(
void**)address = (
void*)
fBuffer.data();
1385 *(
void**)address = (
void*)
cstr;
1400bool CPyCppyy::WCStringConverter::SetArg(
1416 para.fTypeCode =
'p';
1420PyObject* CPyCppyy::WCStringConverter::FromMemory(
void* address)
1423 if (address && *(
wchar_t**)address) {
1424 if (
fMaxSize != std::wstring::npos)
1448 if (
fMaxSize != std::wstring::npos)
1454 if (res == -1)
return false;
1459#define CPYCPPYY_WIDESTRING_CONVERTER(name, type, encode, decode, snull) \
1460bool CPyCppyy::name##Converter::SetArg( \
1461 PyObject* pyobject, Parameter& para, CallContext* ) \
1464 PyObject* bstr = encode(pyobject); \
1465 if (!bstr) return false; \
1467 Py_ssize_t len = PyBytes_GET_SIZE(bstr) - sizeof(type) ; \
1468 fBuffer = (type*)realloc(fBuffer, len + sizeof(type)); \
1469 memcpy(fBuffer, PyBytes_AS_STRING(bstr) + sizeof(type) , len); \
1472 fBuffer[len/sizeof(type)] = snull; \
1473 para.fValue.fVoidp = (void*)fBuffer; \
1474 para.fTypeCode = 'p'; \
1478PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
1481 if (address && *(type**)address) { \
1482 if (fMaxSize != std::wstring::npos) \
1483 return decode(*(const char**)address, (Py_ssize_t)fMaxSize*sizeof(type), nullptr, nullptr);\
1484 return decode(*(const char**)address, \
1485 std::char_traits<type>::length(*(type**)address)*sizeof(type), nullptr, nullptr);\
1490 return decode((const char*)&w, 0, nullptr, nullptr); \
1493bool CPyCppyy::name##Converter::ToMemory(PyObject* value, void* address, PyObject* )\
1496 PyObject* bstr = encode(value); \
1497 if (!bstr) return false; \
1499 Py_ssize_t len = PyBytes_GET_SIZE(bstr) - sizeof(type) ; \
1500 Py_ssize_t maxbytes = (Py_ssize_t)fMaxSize*sizeof(type); \
1503 if (fMaxSize != std::wstring::npos && maxbytes < len) { \
1504 if (PyErr_WarnEx(PyExc_RuntimeWarning, (char*)"string too long for "#type" array (truncated)", 1) < 0) { \
1511 memcpy(*((void**)address), PyBytes_AS_STRING(bstr) + sizeof(type) , len);\
1514 if (len/sizeof(type) < fMaxSize) (*(type**)address)[len/sizeof(type)] = snull;\
1522bool CPyCppyy::NonConstCStringConverter::SetArg(
1535PyObject* CPyCppyy::NonConstCStringConverter::FromMemory(
void* address)
1540 return this->CStringConverter::FromMemory(address);
1556 address = (
void*)val;
1584 para.fValue.fVoidp =
pyobj->GetObject();
1585 para.fTypeCode =
'p';
1590 if (GetAddressSpecialCase(
pyobject,
para.fValue.fVoidp)) {
1591 para.fTypeCode =
'p';
1599 para.fValue.fVoidp = (
void*)((CPyCppyy_tagCDataObject*)
pyobject)->b_ptr;
1600 para.fTypeCode =
'V';
1606 void** payload = (
void**)((CPyCppyy_tagCDataObject*)
pyobject)->b_ptr;
1608 para.fValue.fVoidp = *payload;
1609 para.fTypeCode =
'p';
1618 if (
para.fValue.fVoidp && buflen != 0) {
1619 para.fTypeCode =
'p';
1631 if (!address || *(
uintptr_t*)address == 0) {
1649 *(
void**)address =
pyobj->GetObject();
1654 void* ptr =
nullptr;
1655 if (GetAddressSpecialCase(
value, ptr)) {
1656 *(
void**)address = ptr;
1661 void* buf =
nullptr;
1663 if (!buf || buflen == 0)
1666 *(
void**)address = buf;
1670#if __cplusplus >= 202002L
1689 bool HasState()
override {
return true; }
1692 std::string fTypeName;
1693 std::span<std::size_t>
fBuffer;
1718 "buffer has incompatible type: expected '%c' for C++ type '%s', but got format '%s'",
typecode,
1727 if (
para.fValue.fVoidp && buflen != 0) {
1730 fBuffer = std::span<std::size_t>{(std::size_t *)
para.fValue.fVoidp,
static_cast<std::size_t
>(buflen)};
1733 para.fTypeCode =
'V';
1780#define CPPYY_IMPL_ARRAY_CONVERTER(name, ctype, type, code, suffix) \
1781CPyCppyy::name##ArrayConverter::name##ArrayConverter(cdims_t dims) : \
1783 fIsFixed = dims ? fShape[0] != UNKNOWN_SIZE : false; \
1786bool CPyCppyy::name##ArrayConverter::SetArg( \
1787 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
1790 bool convOk = false; \
1793 if (fShape.ndim() == 2) { \
1794 if (Py_TYPE(pyobject) == GetCTypesPtrType(ct_##ctype)) { \
1795 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1796 para.fTypeCode = 'p'; \
1798 } else if (Py_TYPE(pyobject) == GetCTypesType(ct_c_void_p)) { \
1800 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1801 para.fTypeCode = 'p'; \
1803 } else if (LowLevelView_Check(pyobject) && \
1804 ((LowLevelView*)pyobject)->fBufInfo.ndim == 2 && \
1805 strchr(((LowLevelView*)pyobject)->fBufInfo.format, code)) { \
1806 para.fValue.fVoidp = ((LowLevelView*)pyobject)->get_buf(); \
1807 para.fTypeCode = 'p'; \
1814 PyTypeObject* ctypes_type = GetCTypesType(ct_##ctype); \
1815 if (Py_TYPE(pyobject) == ctypes_type) { \
1816 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1817 para.fTypeCode = 'p'; \
1819 } else if (Py_TYPE(pyobject) == GetCTypesPtrType(ct_##ctype)) { \
1820 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1821 para.fTypeCode = 'V'; \
1823 } else if (IsPyCArgObject(pyobject)) { \
1824 CPyCppyy_tagPyCArgObject* carg = (CPyCppyy_tagPyCArgObject*)pyobject;\
1825 if (carg->obj && Py_TYPE(carg->obj) == ctypes_type) { \
1826 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)carg->obj)->b_ptr;\
1827 para.fTypeCode = 'p'; \
1835 bool ismulti = fShape.ndim() > 1; \
1836 convOk = CArraySetArg(pyobject, para, code, ismulti ? sizeof(void*) : sizeof(type), true);\
1840 if (convOk) SetLifeLine(ctxt->fPyContext, pyobject, (intptr_t)this); \
1845PyObject* CPyCppyy::name##ArrayConverter::FromMemory(void* address) \
1848 return CreateLowLevelView##suffix((type**)address, fShape); \
1849 return CreateLowLevelView##suffix(*(type**)address, fShape); \
1852bool CPyCppyy::name##ArrayConverter::ToMemory( \
1853 PyObject* value, void* address, PyObject* ctxt) \
1855 if (fShape.ndim() <= 1 || fIsFixed) { \
1856 void* buf = nullptr; \
1857 Py_ssize_t buflen = Utility::GetBuffer(value, code, sizeof(type), buf);\
1858 return ToArrayFromBuffer<type>(value, address, ctxt, buf, buflen, fShape, fIsFixed);\
1860 void* buf = nullptr; \
1861 Py_ssize_t buflen = Utility::GetBuffer(value, code, sizeof(void*), buf);\
1862 if (buflen == 0) return false; \
1863 *(type**)address = (type*)buf; \
1864 SetLifeLine(ctxt, value, (intptr_t)address); \
1897bool CPyCppyy::CStringArrayConverter::SetArg(
1905 para.fTypeCode =
'V';
1909#if PY_VERSION_HEX >= 0x03000000
1917 if (
len == (
size_t)-1) {
1923 for (
size_t i = 0; i <
len; ++i) {
1941 para.fTypeCode =
'p';
1950PyObject* CPyCppyy::CStringArrayConverter::FromMemory(
void* address)
1968 return SCharArrayConverter::ToMemory(
value, address,
ctxt);
1972PyObject* CPyCppyy::NonConstCStringArrayConverter::FromMemory(
void* address)
1986 para.fValue.fVoidp =
nullptr;
1987 para.fTypeCode =
'p';
2002#if PY_VERSION_HEX < 0x03030000
2012 const char*
cstr =
nullptr;
2014 if (
cstr) buffer = T{
cstr, (
typename T::size_type)
len};
2022#define CPPYY_IMPL_STRING_AS_PRIMITIVE_CONVERTER(name, type, F1, F2) \
2023CPyCppyy::name##Converter::name##Converter(bool keepControl) : \
2024 InstanceConverter(Cppyy::GetScope(#type), keepControl) {} \
2026bool CPyCppyy::name##Converter::SetArg( \
2027 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
2029 if (CPyCppyy_PyUnicodeAsBytes2Buffer(pyobject, fBuffer)) { \
2030 para.fValue.fVoidp = &fBuffer; \
2031 para.fTypeCode = 'V'; \
2036 if (!(PyInt_Check(pyobject) || PyLong_Check(pyobject))) { \
2037 bool result = InstanceConverter::SetArg(pyobject, para, ctxt); \
2038 para.fTypeCode = 'V'; \
2045PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
2048 return InstanceConverter::FromMemory(address); \
2049 auto* empty = new type(); \
2050 return BindCppObjectNoCast(empty, fClass, CPPInstance::kIsOwner); \
2053bool CPyCppyy::name##Converter::ToMemory( \
2054 PyObject* value, void* address, PyObject* ctxt) \
2056 if (CPyCppyy_PyUnicodeAsBytes2Buffer(value, *((type*)address))) \
2058 return InstanceConverter::ToMemory(value, address, ctxt); \
2064CPyCppyy::STLWStringConverter::STLWStringConverter(
bool keepControl) :
2067bool CPyCppyy::STLWStringConverter::SetArg(
2075 para.fTypeCode =
'V';
2078#if PY_VERSION_HEX < 0x03000000
2081 std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>
cnv;
2085 if (!
pyu)
return false;
2091 para.fTypeCode =
'V';
2098 para.fTypeCode =
'V';
2105PyObject* CPyCppyy::STLWStringConverter::FromMemory(
void* address)
2117 wchar_t* buf =
new wchar_t[
len+1];
2119 *((std::wstring*)address) = std::wstring(buf,
len);
2123 return InstanceConverter::ToMemory(
value, address,
ctxt);
2127CPyCppyy::STLStringViewConverter::STLStringViewConverter(
bool keepControl) :
2130bool CPyCppyy::STLStringViewConverter::SetArg(
2137 para.fTypeCode =
'V';
2148 fBuffer = std::string_view(
cstr, (std::string_view::size_type)
len);
2150 para.fTypeCode =
'V';
2163 void* ptr =
pyobj->GetObject();
2169 fBuffer = *((std::string*)ptr);
2171 para.fTypeCode =
'V';
2179PyObject* CPyCppyy::STLStringViewConverter::FromMemory(
void* address)
2182 return InstanceConverter::FromMemory(address);
2183 auto* empty =
new std::string_view();
2187bool CPyCppyy::STLStringViewConverter::ToMemory(
2191 if (InstanceConverter::ToMemory(
value, address,
ctxt))
2199 *
reinterpret_cast<std::string_view*
>(address) = \
2200 std::string_view(
cstr, (std::string_view::size_type)
len);
2208bool CPyCppyy::STLStringMoveConverter::SetArg(
2237template <
bool ISCONST>
2244 if (GetAddressSpecialCase(
pyobject,
para.fValue.fVoidp)) {
2245 para.fTypeCode =
'p';
2265 para.fValue.fVoidp =
pyobj->GetObject();
2272 para.fTypeCode =
'p';
2280template <
bool ISCONST>
2290template <
bool ISCONST>
2296 void* ptr =
nullptr;
2297 if (GetAddressSpecialCase(
value, ptr)) {
2298 *(
void**)address = ptr;
2311 *(
void**)address =
pyobj->GetObject();
2321bool CPyCppyy::InstanceConverter::SetArg(
2330 para.fValue.fVoidp =
pyobj->GetObject();
2331 if (!
para.fValue.fVoidp)
2339 para.fTypeCode =
'V';
2348PyObject* CPyCppyy::InstanceConverter::FromMemory(
void* address)
2362#if PY_VERSION_HEX >= 0x03080000
2378bool CPyCppyy::InstanceRefConverter::SetArg(
2393 if (
pyobj->IsSmart()) {
2396 para.fValue.fVoidp =
pyobj->GetObjectRaw();
2404 para.fValue.fVoidp =
pyobj->GetObject();
2411 if (!
para.fValue.fVoidp) {
2422 para.fTypeCode =
'V';
2434PyObject* CPyCppyy::InstanceRefConverter::FromMemory(
void* address)
2440bool CPyCppyy::InstanceMoveConverter::SetArg(
2471template <
bool ISREFERENCE>
2472bool CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::SetArg(
2480 para.fValue.fVoidp =
nullptr;
2481 para.fTypeCode =
'p';
2494 para.fValue.fVoidp =
pyobj->GetObjectRaw();
2496 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2505template <
bool ISREFERENCE>
2506PyObject* CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::FromMemory(
void* address)
2513template <
bool ISREFERENCE>
2514bool CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::ToMemory(
2522 *(
void**)address =
nullptr;
2537 *(
void**)address =
pyobj->GetObject();
2549 template class CPyCppyy::InstancePtrPtrConverter<true>;
2550 template class CPyCppyy::InstancePtrPtrConverter<false>;
2554bool CPyCppyy::InstanceArrayConverter::SetArg(
2573 para.fTypeCode =
'p';
2581PyObject* CPyCppyy::InstanceArrayConverter::FromMemory(
void* address)
2588bool CPyCppyy::InstanceArrayConverter::ToMemory(
2595 "access to C-arrays of objects not yet implemented!");
2602bool CPyCppyy::STLIteratorConverter::SetArg(
2610 para.fValue.fVoidp =
pyobj->GetObject();
2611 para.fTypeCode =
'V';
2617bool CPyCppyy::VoidPtrRefConverter::SetArg(
2623 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2624 para.fTypeCode =
'V';
2632CPyCppyy::VoidPtrPtrConverter::VoidPtrPtrConverter(
cdims_t dims) :
2638bool CPyCppyy::VoidPtrPtrConverter::SetArg(
2645 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2646 para.fTypeCode =
'p';
2652 para.fTypeCode =
'p';
2662 if (
para.fValue.fVoidp && buflen != 0) {
2663 para.fTypeCode =
'p';
2671PyObject* CPyCppyy::VoidPtrPtrConverter::FromMemory(
void* address)
2674 if (!address || *(ptrdiff_t*)address == 0) {
2684bool CPyCppyy::PyObjectConverter::SetArg(
2689 para.fTypeCode =
'p';
2693PyObject* CPyCppyy::PyObjectConverter::FromMemory(
void* address)
2729 auto key =
ipos->second.second;
2747 const_cast<char*
>(
"internal_WrapperCacheEraser"),
2763 if (!
ol->fMethodInfo ||
ol->fMethodInfo->fMethods.empty())
2767 for (
auto&
m :
ol->fMethodInfo->fMethods) {
2772 void*
fptr = (
void*)
m->GetFunctionAddress();
2782 std::string fullname =
pytmpl->fTI->fCppName;
2783 if (
pytmpl->fTemplateArgs)
2841 std::ostringstream
wname;
2845 std::ostringstream code;
2846 code <<
"namespace __cppyy_internal {\n "
2848 for (
int i = 0; i <
nArgs; ++i) {
2849 code <<
argtypes[i] <<
" arg" << i;
2850 if (i !=
nArgs-1) code <<
", ";
2861 code <<
" PyObject** ref = (PyObject**)" << (intptr_t)
ref <<
";\n"
2862 " PyObject* pyresult = nullptr;\n"
2863 " if (*ref) pyresult = PyObject_CallFunctionObjArgs(*ref";
2864 for (
int i = 0; i <
nArgs; ++i)
2865 code <<
", pyargs[" << i <<
"]";
2866 code <<
", NULL);\n"
2867 " else PyErr_SetString(PyExc_TypeError, \"callable was deleted\");\n";
2899bool CPyCppyy::FunctionPointerConverter::SetArg(
2904 para.fValue.fVoidp =
nullptr;
2905 para.fTypeCode =
'p';
2914 para.fTypeCode =
'p';
2921PyObject* CPyCppyy::FunctionPointerConverter::FromMemory(
void* address)
2932bool CPyCppyy::FunctionPointerConverter::ToMemory(
2937 *((
void**)address) =
nullptr;
2945 *((
void**)address) =
fptr;
2954bool CPyCppyy::StdFunctionConverter::SetArg(
2968 PyObject* func = this->FunctionPointerConverter::FromMemory(&
para.fValue.fVoidp);
2981PyObject* CPyCppyy::StdFunctionConverter::FromMemory(
void* address)
2996bool CPyCppyy::SmartPtrConverter::SetArg(
3023 para.fValue.fVoidp =
pyobj->GetSmartObject();
3038 para.fValue.fVoidp =
pyobj->GetObject();
3061 pyobj->PythonOwns();
3071 para.fTypeCode =
'V';
3078PyObject* CPyCppyy::SmartPtrConverter::FromMemory(
void* address)
3091#if PY_VERSION_HEX >= 0x03080000
3110#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3113 typedef size_t size_type;
3114 typedef void* iterator;
3118#elif defined (_MSC_VER)
3121 typedef char* iterator;
3126#define NO_KNOWN_INITIALIZER_LIST 1
3131CPyCppyy::InitializerListConverter::InitializerListConverter(
Cppyy::TCppType_t klass, std::string
const &value_type)
3133 : InstanceConverter{
klass},
3140CPyCppyy::InitializerListConverter::~InitializerListConverter()
3148void CPyCppyy::InitializerListConverter::Clear() {
3151#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3152 for (faux_initlist::size_type i = 0; i <
fake->_M_len; ++i) {
3153#elif defined (_MSC_VER)
3165bool CPyCppyy::InitializerListConverter::SetArg(
3168#ifdef NO_KNOWN_INITIALIZER_LIST
3188 void* buf =
nullptr;
3192 if (buf && buflen) {
3197#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3198 fake->_M_len = (faux_initlist::size_type)buflen;
3199#elif defined (_MSC_VER)
3220#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3221 fake->_M_len = (faux_initlist::size_type)
len;
3222 for (faux_initlist::size_type i = 0; i <
fake->_M_len; ++i) {
3223#elif defined (_MSC_VER)
3264#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3265 fake->_M_len = (faux_initlist::size_type)entries;
3266#elif defined (_MSC_VER)
3279 para.fTypeCode =
'V';
3314 if (
cpd ==
"**" ||
cpd ==
"*[]" ||
cpd ==
"&*")
3316 else if (
cpd ==
"*&")
3322 else if (
cpd ==
"&")
3324 else if (
cpd ==
"&&")
3350 return (
h->second)(
dims);
3360 return (
h->second)(
dims);
3371 "argument type '" +
resolvedType +
"' is not supported: non-const references to pointers (T*&) allow a"
3372 " function to replace the pointer itself. Python cannot represent this safely. Consider changing the"
3373 " C++ API to return the new pointer or use a wrapper"};
3379 return (
h->second)(
dims);
3386 return (
h->second)(
dims);
3390 if (
cpd.compare(0, 3,
"*[]") == 0) {
3404 for (
int i = 2; i < (
newdim-1); ++i)
3410 return (
h->second)(
dims);
3413 }
else if (!
cpd.empty() && (std::string::size_type)std::count(
cpd.
begin(),
cpd.
end(),
'*') ==
cpd.size()) {
3419 }
else if (2 <=
cpd.size() && (std::string::size_type)std::count(
cpd.
begin(),
cpd.
end(),
'[') ==
cpd.size() / 2) {
3423 return (
h->second)(
dims);
3427 if (
realType.compare(0, 16,
"initializer_list") == 0) {
3439 if (pos == 0 || pos == 5 ||
3440 pos == 6 || pos == 11 ) {
3450 if (
pos1 != std::string::npos &&
pos2 != std::string::npos) {
3454 return new StdFunctionConverter(
cnv,
3456 }
else if (
cnv->HasState())
3461#if __cplusplus >= 202002L
3464 if (pos == 0 || pos == 5 ||
3465 pos == 6 || pos == 11 ) {
3474 const std::string
cprefix =
"const ";
3476 value_type = value_type.substr(
cprefix.size());
3479 std::string
span_type =
"std::span<" + value_type +
">";
3492 }
else if (
cpd ==
"&") {
3502 static STLIteratorConverter
c;
3512 auto pos1 =
sm.position(0);
3514 result =
new FunctionPointerConverter(
3523 return (
h->second)(
dims);
3533 if (
cpd.size() == 2 &&
cpd !=
"&&")
3534 result =
new VoidPtrPtrConverter(
dims.ndim());
3535 else if (!
cpd.empty())
3549 if (
p &&
p->HasState())
3607#define STRINGVIEW "basic_string_view<char,char_traits<char> >"
3608#define WSTRING1 "std::basic_string<wchar_t>"
3609#define WSTRING2 "std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>"
3613#define CCOMPLEX_D "_Complex double"
3614#define CCOMPLEX_F "_Complex float"
3616#define CCOMPLEX_D "_C_double_complex"
3617#define CCOMPLEX_F "_C_float_complex"
3620static struct InitConvFactories_t {
3622 InitConvFactories_t() {
3627 gf[
"bool"] = (
cf_t)+[](
cdims_t) {
static BoolConverter
c{};
return &
c; };
3628 gf[
"const bool&"] = (
cf_t)+[](
cdims_t) {
static ConstBoolRefConverter
c{};
return &
c; };
3629 gf[
"bool&"] = (
cf_t)+[](
cdims_t) {
static BoolRefConverter
c{};
return &
c; };
3630 gf[
"char"] = (
cf_t)+[](
cdims_t) {
static CharConverter
c{};
return &
c; };
3631 gf[
"const char&"] = (
cf_t)+[](
cdims_t) {
static ConstCharRefConverter
c{};
return &
c; };
3632 gf[
"char&"] = (
cf_t)+[](
cdims_t) {
static CharRefConverter
c{};
return &
c; };
3633 gf[
"signed char&"] = (
cf_t)+[](
cdims_t) {
static SCharRefConverter
c{};
return &
c; };
3634 gf[
"unsigned char"] = (
cf_t)+[](
cdims_t) {
static UCharConverter
c{};
return &
c; };
3635 gf[
"const unsigned char&"] = (
cf_t)+[](
cdims_t) {
static ConstUCharRefConverter
c{};
return &
c; };
3636 gf[
"unsigned char&"] = (
cf_t)+[](
cdims_t) {
static UCharRefConverter
c{};
return &
c; };
3637 gf[
"SCharAsInt"] = (
cf_t)+[](
cdims_t) {
static SCharAsIntConverter
c{};
return &
c; };
3638 gf[
"UCharAsInt"] = (
cf_t)+[](
cdims_t) {
static UCharAsIntConverter
c{};
return &
c; };
3639 gf[
"wchar_t"] = (
cf_t)+[](
cdims_t) {
static WCharConverter
c{};
return &
c; };
3640 gf[
"char16_t"] = (
cf_t)+[](
cdims_t) {
static Char16Converter
c{};
return &
c; };
3641 gf[
"char32_t"] = (
cf_t)+[](
cdims_t) {
static Char32Converter
c{};
return &
c; };
3642 gf[
"wchar_t&"] = (
cf_t)+[](
cdims_t) {
static WCharRefConverter
c{};
return &
c; };
3643 gf[
"char16_t&"] = (
cf_t)+[](
cdims_t) {
static Char16RefConverter
c{};
return &
c; };
3644 gf[
"char32_t&"] = (
cf_t)+[](
cdims_t) {
static Char32RefConverter
c{};
return &
c; };
3645 gf[
"int8_t"] = (
cf_t)+[](
cdims_t) {
static Int8Converter
c{};
return &
c; };
3646 gf[
"const int8_t&"] = (
cf_t)+[](
cdims_t) {
static ConstInt8RefConverter
c{};
return &
c; };
3647 gf[
"int8_t&"] = (
cf_t)+[](
cdims_t) {
static Int8RefConverter
c{};
return &
c; };
3648 gf[
"int16_t"] = (
cf_t)+[](
cdims_t) {
static Int16Converter
c{};
return &
c; };
3649 gf[
"const int16_t&"] = (
cf_t)+[](
cdims_t) {
static ConstInt16RefConverter
c{};
return &
c; };
3650 gf[
"int16_t&"] = (
cf_t)+[](
cdims_t) {
static Int16RefConverter
c{};
return &
c; };
3651 gf[
"int32_t"] = (
cf_t)+[](
cdims_t) {
static Int32Converter
c{};
return &
c; };
3652 gf[
"const int32_t&"] = (
cf_t)+[](
cdims_t) {
static ConstInt32RefConverter
c{};
return &
c; };
3653 gf[
"int32_t&"] = (
cf_t)+[](
cdims_t) {
static Int32RefConverter
c{};
return &
c; };
3654 gf[
"uint8_t"] = (
cf_t)+[](
cdims_t) {
static UInt8Converter
c{};
return &
c; };
3655 gf[
"const uint8_t&"] = (
cf_t)+[](
cdims_t) {
static ConstUInt8RefConverter
c{};
return &
c; };
3656 gf[
"uint8_t&"] = (
cf_t)+[](
cdims_t) {
static UInt8RefConverter
c{};
return &
c; };
3657 gf[
"uint16_t"] = (
cf_t)+[](
cdims_t) {
static UInt16Converter
c{};
return &
c; };
3658 gf[
"const uint16_t&"] = (
cf_t)+[](
cdims_t) {
static ConstUInt16RefConverter
c{};
return &
c; };
3659 gf[
"uint16_t&"] = (
cf_t)+[](
cdims_t) {
static UInt16RefConverter
c{};
return &
c; };
3660 gf[
"uint32_t"] = (
cf_t)+[](
cdims_t) {
static UInt32Converter
c{};
return &
c; };
3661 gf[
"const uint32_t&"] = (
cf_t)+[](
cdims_t) {
static ConstUInt32RefConverter
c{};
return &
c; };
3662 gf[
"uint32_t&"] = (
cf_t)+[](
cdims_t) {
static UInt32RefConverter
c{};
return &
c; };
3663 gf[
"short"] = (
cf_t)+[](
cdims_t) {
static ShortConverter
c{};
return &
c; };
3664 gf[
"const short&"] = (
cf_t)+[](
cdims_t) {
static ConstShortRefConverter
c{};
return &
c; };
3665 gf[
"short&"] = (
cf_t)+[](
cdims_t) {
static ShortRefConverter
c{};
return &
c; };
3666 gf[
"unsigned short"] = (
cf_t)+[](
cdims_t) {
static UShortConverter
c{};
return &
c; };
3667 gf[
"const unsigned short&"] = (
cf_t)+[](
cdims_t) {
static ConstUShortRefConverter
c{};
return &
c; };
3668 gf[
"unsigned short&"] = (
cf_t)+[](
cdims_t) {
static UShortRefConverter
c{};
return &
c; };
3669 gf[
"int"] = (
cf_t)+[](
cdims_t) {
static IntConverter
c{};
return &
c; };
3670 gf[
"int&"] = (
cf_t)+[](
cdims_t) {
static IntRefConverter
c{};
return &
c; };
3671 gf[
"const int&"] = (
cf_t)+[](
cdims_t) {
static ConstIntRefConverter
c{};
return &
c; };
3672 gf[
"unsigned int"] = (
cf_t)+[](
cdims_t) {
static UIntConverter
c{};
return &
c; };
3673 gf[
"const unsigned int&"] = (
cf_t)+[](
cdims_t) {
static ConstUIntRefConverter
c{};
return &
c; };
3674 gf[
"unsigned int&"] = (
cf_t)+[](
cdims_t) {
static UIntRefConverter
c{};
return &
c; };
3675 gf[
"long"] = (
cf_t)+[](
cdims_t) {
static LongConverter
c{};
return &
c; };
3676 gf[
"long&"] = (
cf_t)+[](
cdims_t) {
static LongRefConverter
c{};
return &
c; };
3677 gf[
"const long&"] = (
cf_t)+[](
cdims_t) {
static ConstLongRefConverter
c{};
return &
c; };
3678 gf[
"unsigned long"] = (
cf_t)+[](
cdims_t) {
static ULongConverter
c{};
return &
c; };
3679 gf[
"const unsigned long&"] = (
cf_t)+[](
cdims_t) {
static ConstULongRefConverter
c{};
return &
c; };
3680 gf[
"unsigned long&"] = (
cf_t)+[](
cdims_t) {
static ULongRefConverter
c{};
return &
c; };
3681 gf[
"long long"] = (
cf_t)+[](
cdims_t) {
static LLongConverter
c{};
return &
c; };
3682 gf[
"const long long&"] = (
cf_t)+[](
cdims_t) {
static ConstLLongRefConverter
c{};
return &
c; };
3683 gf[
"long long&"] = (
cf_t)+[](
cdims_t) {
static LLongRefConverter
c{};
return &
c; };
3684 gf[
"unsigned long long"] = (
cf_t)+[](
cdims_t) {
static ULLongConverter
c{};
return &
c; };
3685 gf[
"const unsigned long long&"] = (
cf_t)+[](
cdims_t) {
static ConstULLongRefConverter
c{};
return &
c; };
3686 gf[
"unsigned long long&"] = (
cf_t)+[](
cdims_t) {
static ULLongRefConverter
c{};
return &
c; };
3688 gf[
"float"] = (
cf_t)+[](
cdims_t) {
static FloatConverter
c{};
return &
c; };
3689 gf[
"const float&"] = (
cf_t)+[](
cdims_t) {
static ConstFloatRefConverter
c{};
return &
c; };
3690 gf[
"float&"] = (
cf_t)+[](
cdims_t) {
static FloatRefConverter
c{};
return &
c; };
3691 gf[
"double"] = (
cf_t)+[](
cdims_t) {
static DoubleConverter
c{};
return &
c; };
3692 gf[
"double&"] = (
cf_t)+[](
cdims_t) {
static DoubleRefConverter
c{};
return &
c; };
3693 gf[
"const double&"] = (
cf_t)+[](
cdims_t) {
static ConstDoubleRefConverter
c{};
return &
c; };
3694 gf[
"long double"] = (
cf_t)+[](
cdims_t) {
static LDoubleConverter
c{};
return &
c; };
3695 gf[
"const long double&"] = (
cf_t)+[](
cdims_t) {
static ConstLDoubleRefConverter
c{};
return &
c; };
3696 gf[
"long double&"] = (
cf_t)+[](
cdims_t) {
static LDoubleRefConverter
c{};
return &
c; };
3697 gf[
"std::complex<double>"] = (
cf_t)+[](
cdims_t) {
return new ComplexDConverter{}; };
3698 gf[
"const std::complex<double>&"] = (
cf_t)+[](
cdims_t) {
return new ComplexDConverter{}; };
3699 gf[
"void"] = (
cf_t)+[](
cdims_t) {
static VoidConverter
c{};
return &
c; };
3702 gf[
"bool ptr"] = (
cf_t)+[](
cdims_t d) {
return new BoolArrayConverter{
d}; };
3703 gf[
"signed char ptr"] = (
cf_t)+[](
cdims_t d) {
return new SCharArrayConverter{
d}; };
3705 gf[
"const unsigned char*"] = (
cf_t)+[](
cdims_t d) {
return new UCharArrayConverter{
d}; };
3706 gf[
"unsigned char ptr"] = (
cf_t)+[](
cdims_t d) {
return new UCharArrayConverter{
d}; };
3707 gf[
"SCharAsInt*"] =
gf[
"signed char ptr"];
3708 gf[
"SCharAsInt[]"] =
gf[
"signed char ptr"];
3709 gf[
"UCharAsInt*"] =
gf[
"unsigned char ptr"];
3710 gf[
"UCharAsInt[]"] =
gf[
"unsigned char ptr"];
3711 gf[
"std::byte ptr"] = (
cf_t)+[](
cdims_t d) {
return new ByteArrayConverter{
d}; };
3712 gf[
"int8_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new Int8ArrayConverter{
d}; };
3713 gf[
"int16_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new Int16ArrayConverter{
d}; };
3714 gf[
"int32_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new Int32ArrayConverter{
d}; };
3715 gf[
"uint8_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new UInt8ArrayConverter{
d}; };
3716 gf[
"uint16_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new UInt16ArrayConverter{
d}; };
3717 gf[
"uint32_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new UInt32ArrayConverter{
d}; };
3718 gf[
"short ptr"] = (
cf_t)+[](
cdims_t d) {
return new ShortArrayConverter{
d}; };
3719 gf[
"unsigned short ptr"] = (
cf_t)+[](
cdims_t d) {
return new UShortArrayConverter{
d}; };
3720 gf[
"int ptr"] = (
cf_t)+[](
cdims_t d) {
return new IntArrayConverter{
d}; };
3721 gf[
"unsigned int ptr"] = (
cf_t)+[](
cdims_t d) {
return new UIntArrayConverter{
d}; };
3722 gf[
"long ptr"] = (
cf_t)+[](
cdims_t d) {
return new LongArrayConverter{
d}; };
3723 gf[
"unsigned long ptr"] = (
cf_t)+[](
cdims_t d) {
return new ULongArrayConverter{
d}; };
3724 gf[
"long long ptr"] = (
cf_t)+[](
cdims_t d) {
return new LLongArrayConverter{
d}; };
3725 gf[
"unsigned long long ptr"] = (
cf_t)+[](
cdims_t d) {
return new ULLongArrayConverter{
d}; };
3726 gf[
"float ptr"] = (
cf_t)+[](
cdims_t d) {
return new FloatArrayConverter{
d}; };
3727 gf[
"double ptr"] = (
cf_t)+[](
cdims_t d) {
return new DoubleArrayConverter{
d}; };
3728 gf[
"long double ptr"] = (
cf_t)+[](
cdims_t d) {
return new LDoubleArrayConverter{
d}; };
3729 gf[
"std::complex<float> ptr"] = (
cf_t)+[](
cdims_t d) {
return new ComplexFArrayConverter{
d}; };
3730 gf[
"std::complex<double> ptr"] = (
cf_t)+[](
cdims_t d) {
return new ComplexDArrayConverter{
d}; };
3734 gf[
"signed char"] =
gf[
"char"];
3735 gf[
"const signed char&"] =
gf[
"const char&"];
3736 gf[
"std::byte"] =
gf[
"uint8_t"];
3737 gf[
"byte"] =
gf[
"uint8_t"];
3738 gf[
"const std::byte&"] =
gf[
"const uint8_t&"];
3739 gf[
"const byte&"] =
gf[
"const uint8_t&"];
3740 gf[
"std::byte&"] =
gf[
"uint8_t&"];
3741 gf[
"byte&"] =
gf[
"uint8_t&"];
3742 gf[
"std::int8_t"] =
gf[
"int8_t"];
3743 gf[
"const std::int8_t&"] =
gf[
"const int8_t&"];
3744 gf[
"std::int8_t&"] =
gf[
"int8_t&"];
3745 gf[
"std::uint8_t"] =
gf[
"uint8_t"];
3746 gf[
"const std::uint8_t&"] =
gf[
"const uint8_t&"];
3747 gf[
"std::uint8_t&"] =
gf[
"uint8_t&"];
3748 gf[
"internal_enum_type_t"] =
gf[
"int"];
3749 gf[
"internal_enum_type_t&"] =
gf[
"int&"];
3750 gf[
"const internal_enum_type_t&"] =
gf[
"const int&"];
3751 gf[
"internal_enum_type_t ptr"] =
gf[
"int ptr"];
3753 gf[
"__int64"] =
gf[
"long long"];
3754 gf[
"const __int64&"] =
gf[
"const long long&"];
3755 gf[
"__int64&"] =
gf[
"long long&"];
3756 gf[
"__int64 ptr"] =
gf[
"long long ptr"];
3757 gf[
"unsigned __int64"] =
gf[
"unsigned long long"];
3758 gf[
"const unsigned __int64&"] =
gf[
"const unsigned long long&"];
3759 gf[
"unsigned __int64&"] =
gf[
"unsigned long long&"];
3760 gf[
"unsigned __int64 ptr"] =
gf[
"unsigned long long ptr"];
3771 gf[
"Long64_t"] =
gf[
"long long"];
3772 gf[
"Long64_t ptr"] =
gf[
"long long ptr"];
3773 gf[
"Long64_t&"] =
gf[
"long long&"];
3774 gf[
"const Long64_t&"] =
gf[
"const long long&"];
3775 gf[
"ULong64_t"] =
gf[
"unsigned long long"];
3776 gf[
"ULong64_t ptr"] =
gf[
"unsigned long long ptr"];
3777 gf[
"ULong64_t&"] =
gf[
"unsigned long long&"];
3778 gf[
"const ULong64_t&"] =
gf[
"const unsigned long long&"];
3781 gf[
"nullptr_t"] = (
cf_t)+[](
cdims_t) {
static NullptrConverter
c{};
return &
c;};
3782 gf[
"const char*"] = (
cf_t)+[](
cdims_t) {
return new CStringConverter{}; };
3783 gf[
"const signed char*"] =
gf[
"const char*"];
3784 gf[
"const char*&&"] =
gf[
"const char*"];
3785 gf[
"const char[]"] = (
cf_t)+[](
cdims_t) {
return new CStringConverter{}; };
3787 gf[
"char[]"] = (
cf_t)+[](
cdims_t d) {
return new NonConstCStringArrayConverter{
d,
true}; };
3788 gf[
"signed char*"] =
gf[
"char*"];
3789 gf[
"wchar_t*"] = (
cf_t)+[](
cdims_t) {
return new WCStringConverter{}; };
3800 gf[
"wchar_t*_Nonnull"] = (
cf_t)+[](
cdims_t) {
return new WCStringConverter{}; };
3801 gf[
"char16_t*"] = (
cf_t)+[](
cdims_t) {
return new CString16Converter{}; };
3803 gf[
"char32_t*"] = (
cf_t)+[](
cdims_t) {
return new CString32Converter{}; };
3806 gf[
"char16_t**"] =
gf[
"char16_t*"];
3807 gf[
"char32_t**"] =
gf[
"char32_t*"];
3809 gf[
"char**"] =
gf[
"const char**"];
3810 gf[
"const char*[]"] = (
cf_t)+[](
cdims_t d) {
return new CStringArrayConverter{
d,
false}; };
3811 gf[
"char*[]"] = (
cf_t)+[](
cdims_t d) {
return new NonConstCStringArrayConverter{
d,
false}; };
3812 gf[
"char ptr"] =
gf[
"char*[]"];
3813 gf[
"std::string"] = (
cf_t)+[](
cdims_t) {
return new STLStringConverter{}; };
3814 gf[
"const std::string&"] =
gf[
"std::string"];
3815 gf[
"string"] =
gf[
"std::string"];
3816 gf[
"const string&"] =
gf[
"std::string"];
3817 gf[
"std::string&&"] = (
cf_t)+[](
cdims_t) {
return new STLStringMoveConverter{}; };
3818 gf[
"string&&"] =
gf[
"std::string&&"];
3819 gf[
"std::string_view"] = (
cf_t)+[](
cdims_t) {
return new STLStringViewConverter{}; };
3821 gf[
"std::string_view&"] =
gf[
"std::string_view"];
3822 gf[
"const std::string_view&"] =
gf[
"std::string_view"];
3824 gf[
"std::wstring"] = (
cf_t)+[](
cdims_t) {
return new STLWStringConverter{}; };
3827 gf[
"const std::wstring&"] =
gf[
"std::wstring"];
3830 gf[
"void*&"] = (
cf_t)+[](
cdims_t) {
static VoidPtrRefConverter
c{};
return &
c; };
3831 gf[
"void**"] = (
cf_t)+[](
cdims_t d) {
return new VoidPtrPtrConverter{
d}; };
3832 gf[
"void ptr"] =
gf[
"void**"];
3833 gf[
"PyObject*"] = (
cf_t)+[](
cdims_t) {
static PyObjectConverter
c{};
return &
c; };
3834 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 void * PyFunction_AsCPointer(PyObject *pyobject, const std::string &rettype, const std::string &signature, bool allowCppInstance)
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)
#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)
bool SetArg(PyObject *, Parameter &, CallContext *=nullptr) override
NotImplementedConverter(PyObject *errorType, std::string const &message)
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)
std::map< std::string, char > const & TypecodeMap()
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
bool LowLevelView_Check(T *object)
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 bool IsDefaultConstructable(TCppType_t type)
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::@198 value