29#if __cplusplus > 201402L
36#if PY_VERSION_HEX < 0x03000000
37#if defined(__GNUC__) && !defined(__APPLE__)
38# if __GNUC__ > 4 && __has_include("codecvt")
61 static std::regex
s_fnptr(
"\\(:*\\*&*\\)");
64#if PY_VERSION_HEX < 0x03000000
66#elif PY_VERSION_HEX < 0x03080000
112#define ct_c_uint32 10
115#define ct_c_longlong 13
116#define ct_c_ulonglong 14
118#define ct_c_double 16
119#define ct_c_longdouble 17
120#define ct_c_char_p 18
121#define ct_c_wchar_p 19
122#define ct_c_void_p 20
123#define ct_c_fcomplex 21
124#define ct_c_complex 22
125#define ct_c_pointer 23
129 "c_bool",
"c_char",
"c_wchar",
"c_byte",
"c_ubyte",
"c_short",
"c_ushort",
"c_uint16",
130 "c_int",
"c_uint",
"c_uint32",
"c_long",
"c_ulong",
"c_longlong",
"c_ulonglong",
131 "c_float",
"c_double",
"c_longdouble",
132 "c_char_p",
"c_wchar_p",
"c_void_p",
"c_fcomplex",
"c_complex",
"_Pointer" };
206#if PY_VERSION_HEX < 0x30d0000
266 if (!
holder)
return false;
280 if (!
holder)
return false;
371#define CPPYY_PYLONG_AS_TYPE(name, type, limit_low, limit_high) \
372static inline type CPyCppyy_PyLong_As##name(PyObject* pyobject) \
374 if (!(PyLong_Check(pyobject) || PyInt_Check(pyobject))) { \
375 if (pyobject == CPyCppyy::gDefaultObject) \
377 PyErr_SetString(PyExc_TypeError, #type" conversion expects an integer object");\
380 long l = PyLong_AsLong(pyobject); \
381 if (l < limit_low || limit_high < l) { \
382 PyErr_Format(PyExc_ValueError, "integer %ld out of range for "#type, l);\
431 para.fValue.fVoidp =
nullptr;
437 para.fValue.fVoidp =
nullptr;
440 "could not convert argument to buffer or nullptr");
445 para.fTypeCode =
'p';
498 para.fValue.fVoidp =
pytmp->GetObjectRaw();
499 para.fTypeCode =
'V';
532#define CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc)\
534 type val = (type)F2(pyobject); \
535 if (val == (type)-1 && PyErr_Occurred()) { \
536 static PyTypeObject* ctypes_type = nullptr; \
537 if (!ctypes_type) { \
538 PyObject* pytype = 0, *pyvalue = 0, *pytrace = 0; \
539 PyErr_Fetch(&pytype, &pyvalue, &pytrace); \
540 ctypes_type = GetCTypesType(ct_##ctype); \
541 PyErr_Restore(pytype, pyvalue, pytrace); \
543 if (Py_TYPE(pyobject) == ctypes_type) { \
545 val = *((type*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr); \
546 } else if (pyobject == CPyCppyy::gDefaultObject) { \
552 para.fValue.f##name = val; \
553 para.fTypeCode = tc; \
556#define CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2) \
557PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
559 return F1((stype)*((type*)address)); \
562bool CPyCppyy::name##Converter::ToMemory( \
563 PyObject* value, void* address, PyObject* ) \
565 type s = (type)F2(value); \
566 if (s == (type)-1 && PyErr_Occurred()) { \
567 if (value == CPyCppyy::gDefaultObject) { \
573 *((type*)address) = (type)s; \
577#define CPPYY_IMPL_BASIC_CONVERTER_NI(name, type, stype, ctype, F1, F2, tc) \
578bool CPyCppyy::name##Converter::SetArg( \
579 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
581 if (!StrictBool(pyobject, ctxt)) \
583 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
585CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
587#define CPPYY_IMPL_BASIC_CONVERTER_IB(name, type, stype, ctype, F1, F2, tc) \
588bool CPyCppyy::name##Converter::SetArg( \
589 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
591 if (!ImplicitBool(pyobject, ctxt)) \
593 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
595CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
597#define CPPYY_IMPL_BASIC_CONVERTER_NB(name, type, stype, ctype, F1, F2, tc) \
598bool CPyCppyy::name##Converter::SetArg( \
599 PyObject* pyobject, Parameter& para, CallContext* ) \
601 if (PyBool_Check(pyobject)) \
603 CPPYY_IMPL_BASIC_CONVERTER_BODY(name, type, stype, ctype, F1, F2, tc) \
605CPPYY_IMPL_BASIC_CONVERTER_METHODS(name, type, stype, ctype, F1, F2)
631 "integer to character: value %d not in range [%d,%d]",
lchar, low, high);
641#define CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(name, ctype) \
642PyObject* CPyCppyy::name##RefConverter::FromMemory(void* ptr) \
645 PyTypeObject* ctypes_type = GetCTypesType(ct_##ctype); \
646 if (!ctypes_type) { \
647 PyErr_SetString(PyExc_RuntimeError, "no ctypes available"); \
650 PyObject* ref = ctypes_type->tp_new(ctypes_type, nullptr, nullptr); \
651 ((CPyCppyy_tagCDataObject*)ref)->b_ptr = (char*)ptr; \
652 ((CPyCppyy_tagCDataObject*)ref)->b_needsfree = 0; \
657#define CPPYY_IMPL_BASIC_CONST_REFCONVERTER(name, type, ctype, F1) \
658bool CPyCppyy::Const##name##RefConverter::SetArg( \
659 PyObject* pyobject, Parameter& para, CallContext* ) \
661 type val = (type)F1(pyobject); \
662 if (val == (type)-1 && PyErr_Occurred()) { \
663 if (pyobject == CPyCppyy::gDefaultObject) { \
669 para.fValue.f##name = val; \
670 para.fRef = ¶.fValue.f##name; \
671 para.fTypeCode = 'r'; \
674CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(Const##name, ctype)
677#define CPPYY_IMPL_BASIC_CONST_CHAR_REFCONVERTER(name, type, ctype, low, high)\
678bool CPyCppyy::Const##name##RefConverter::SetArg( \
679 PyObject* pyobject, Parameter& para, CallContext* ) \
682 type val = (type)ExtractChar(pyobject, #type, low, high); \
683 if (val == (type)-1 && PyErr_Occurred()) \
685 para.fValue.fLong = val; \
686 para.fTypeCode = 'l'; \
689CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(Const##name, ctype)
693#define CPPYY_IMPL_BASIC_CHAR_CONVERTER(name, type, low, high) \
694bool CPyCppyy::name##Converter::SetArg( \
695 PyObject* pyobject, Parameter& para, CallContext* ) \
698 long val = ExtractChar(pyobject, #type, low, high); \
699 if (val == -1 && PyErr_Occurred()) \
701 para.fValue.fLong = val; \
702 para.fTypeCode = 'l'; \
706PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
709 return CPyCppyy_PyText_FromFormat("%c", *((type*)address)); \
712bool CPyCppyy::name##Converter::ToMemory( \
713 PyObject* value, void* address, PyObject* ) \
716 const char* cstr = nullptr; \
717 if (PyBytes_Check(value)) \
718 PyBytes_AsStringAndSize(value, (char**)&cstr, &len); \
720 cstr = CPyCppyy_PyText_AsStringAndSize(value, &len); \
723 PyErr_Format(PyExc_TypeError, #type" expected, got string of size %zd", len);\
726 *((type*)address) = (type)cstr[0]; \
729 long l = PyLong_AsLong(value); \
730 if (l == -1 && PyErr_Occurred()) { \
731 if (value == CPyCppyy::gDefaultObject) { \
737 if (!(low <= l && l <= high)) { \
738 PyErr_Format(PyExc_ValueError, \
739 "integer to character: value %ld not in range [%d,%d]", l, low, high);\
742 *((type*)address) = (type)l; \
756#if PY_VERSION_HEX < 0x03000000
759 para.fTypeCode =
'V';
766 para.fTypeCode =
'V';
771 para.fTypeCode =
'V';
796bool CPyCppyy::IntRefConverter::SetArg(
800#if PY_VERSION_HEX < 0x03000000
803 para.fTypeCode =
'V';
808#if PY_VERSION_HEX >= 0x02050000
811 para.fTypeCode =
'V';
818 if (
para.fValue.fVoidp && buflen) {
819 para.fTypeCode =
'V';
823#if PY_VERSION_HEX < 0x02050000
832#define CPPYY_IMPL_REFCONVERTER(name, ctype, type, code) \
833bool CPyCppyy::name##RefConverter::SetArg( \
834 PyObject* pyobject, Parameter& para, CallContext* ) \
837 if (Py_TYPE(pyobject) == GetCTypesType(ct_##ctype)) { \
838 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
839 para.fTypeCode = 'V'; \
842 bool res = CArraySetArg(pyobject, para, code, sizeof(type)); \
844 PyErr_SetString(PyExc_TypeError, "use ctypes."#ctype" for pass-by-ref of "#type);\
847 para.fTypeCode = 'V'; \
850CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(name, ctype)
890PyObject* CPyCppyy::UCharAsIntConverter::FromMemory(
void* address)
898bool CPyCppyy::WCharConverter::SetArg(
910 para.fValue.fLong = (long)val;
911 para.fTypeCode =
'U';
915PyObject* CPyCppyy::WCharConverter::FromMemory(
void* address)
930 *((
wchar_t*)address) = val;
935bool CPyCppyy::Char16Converter::SetArg(
945 if (!
bstr)
return false;
949 para.fValue.fLong = (long)val;
950 para.fTypeCode =
'U';
954PyObject* CPyCppyy::Char16Converter::FromMemory(
void* address)
967 if (!
bstr)
return false;
975bool CPyCppyy::Char32Converter::SetArg(
985 if (!
bstr)
return false;
989 para.fValue.fLong = (long)val;
990 para.fTypeCode =
'U';
994PyObject* CPyCppyy::Char32Converter::FromMemory(
void* address)
1007 if (!
bstr)
return false;
1027bool CPyCppyy::ULongConverter::SetArg(
1037 para.fTypeCode =
'L';
1041PyObject* CPyCppyy::ULongConverter::FromMemory(
void* address)
1054 u = (
unsigned long)0;
1058 *((
unsigned long*)address) =
u;
1063PyObject* CPyCppyy::UIntConverter::FromMemory(
void* address)
1081 *((
unsigned int*)address) = (
unsigned int)
u;
1098bool CPyCppyy::ComplexDConverter::SetArg(
1106 para.fTypeCode =
'V';
1113PyObject* CPyCppyy::ComplexDConverter::FromMemory(
void* address)
1115 std::complex<double>*
dc = (std::complex<double>*)address;
1123 std::complex<double>*
dc = (std::complex<double>*)address;
1128 return this->InstanceConverter::ToMemory(
value, address,
ctxt);
1132bool CPyCppyy::DoubleRefConverter::SetArg(
1136#if PY_VERSION_HEX < 0x03000000
1139 para.fTypeCode =
'V';
1144#if PY_VERSION_HEX >= 0x02050000
1147 para.fTypeCode =
'V';
1154 if (
para.fValue.fVoidp && buflen) {
1155 para.fTypeCode =
'V';
1159#if PY_VERSION_HEX < 0x02050000
1181bool CPyCppyy::LLongConverter::SetArg(
1191 para.fTypeCode =
'q';
1195PyObject* CPyCppyy::LLongConverter::FromMemory(
void* address)
1217bool CPyCppyy::ULLongConverter::SetArg(
1227 para.fTypeCode =
'Q';
1231PyObject* CPyCppyy::ULLongConverter::FromMemory(
void* address)
1253bool CPyCppyy::CStringConverter::SetArg(
1266 para.fTypeCode =
'V';
1278 if (!
ctxt->fPyContext) {
1289 para.fTypeCode =
'p';
1293PyObject* CPyCppyy::CStringConverter::FromMemory(
void* address)
1296 if (address && *(
void**)address) {
1300 if (*(
void**)address == (
void*)
fBuffer.data())
1317 if (!
cstr)
return false;
1326 void*
ptrval = *(
void**)address;
1329 *(
void**)address = (
void*)
fBuffer.data();
1339 *(
void**)address = (
void*)
cstr;
1354bool CPyCppyy::WCStringConverter::SetArg(
1370 para.fTypeCode =
'p';
1374PyObject* CPyCppyy::WCStringConverter::FromMemory(
void* address)
1377 if (address && *(
wchar_t**)address) {
1378 if (
fMaxSize != std::wstring::npos)
1401 if (
fMaxSize != std::wstring::npos)
1407 if (res == -1)
return false;
1412#define CPYCPPYY_WIDESTRING_CONVERTER(name, type, encode, decode, snull) \
1413bool CPyCppyy::name##Converter::SetArg( \
1414 PyObject* pyobject, Parameter& para, CallContext* ) \
1417 PyObject* bstr = encode(pyobject); \
1418 if (!bstr) return false; \
1420 Py_ssize_t len = PyBytes_GET_SIZE(bstr) - sizeof(type) ; \
1421 fBuffer = (type*)realloc(fBuffer, len + sizeof(type)); \
1422 memcpy(fBuffer, PyBytes_AS_STRING(bstr) + sizeof(type) , len); \
1425 fBuffer[len/sizeof(type)] = snull; \
1426 para.fValue.fVoidp = (void*)fBuffer; \
1427 para.fTypeCode = 'p'; \
1431PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
1434 if (address && *(type**)address) { \
1435 if (fMaxSize != std::wstring::npos) \
1436 return decode(*(const char**)address, (Py_ssize_t)fMaxSize*sizeof(type), nullptr, nullptr);\
1437 return decode(*(const char**)address, \
1438 std::char_traits<type>::length(*(type**)address)*sizeof(type), nullptr, nullptr);\
1443 return decode((const char*)&w, 0, nullptr, nullptr); \
1446bool CPyCppyy::name##Converter::ToMemory(PyObject* value, void* address, PyObject* )\
1449 PyObject* bstr = encode(value); \
1450 if (!bstr) return false; \
1452 Py_ssize_t len = PyBytes_GET_SIZE(bstr) - sizeof(type) ; \
1453 Py_ssize_t maxbytes = (Py_ssize_t)fMaxSize*sizeof(type); \
1456 if (fMaxSize != std::wstring::npos && maxbytes < len) { \
1457 PyErr_Warn(PyExc_RuntimeWarning, (char*)"string too long for "#type" array (truncated)");\
1461 memcpy(*((void**)address), PyBytes_AS_STRING(bstr) + sizeof(type) , len);\
1464 if (len/sizeof(type) < fMaxSize) (*(type**)address)[len/sizeof(type)] = snull;\
1472bool CPyCppyy::NonConstCStringConverter::SetArg(
1485PyObject* CPyCppyy::NonConstCStringConverter::FromMemory(
void* address)
1490 return this->CStringConverter::FromMemory(address);
1506 address = (
void*)val;
1534 para.fValue.fVoidp =
pyobj->GetObject();
1535 para.fTypeCode =
'p';
1540 if (GetAddressSpecialCase(
pyobject,
para.fValue.fVoidp)) {
1541 para.fTypeCode =
'p';
1549 para.fValue.fVoidp = (
void*)((CPyCppyy_tagCDataObject*)
pyobject)->b_ptr;
1550 para.fTypeCode =
'V';
1556 void** payload = (
void**)((CPyCppyy_tagCDataObject*)
pyobject)->b_ptr;
1558 para.fValue.fVoidp = *payload;
1559 para.fTypeCode =
'p';
1568 if (
para.fValue.fVoidp && buflen != 0) {
1569 para.fTypeCode =
'p';
1581 if (!address || *(
uintptr_t*)address == 0) {
1599 *(
void**)address =
pyobj->GetObject();
1604 void* ptr =
nullptr;
1605 if (GetAddressSpecialCase(
value, ptr)) {
1606 *(
void**)address = ptr;
1611 void* buf =
nullptr;
1613 if (!buf || buflen == 0)
1616 *(
void**)address = buf;
1658#define CPPYY_IMPL_ARRAY_CONVERTER(name, ctype, type, code, suffix) \
1659CPyCppyy::name##ArrayConverter::name##ArrayConverter(cdims_t dims) : \
1661 fIsFixed = dims ? fShape[0] != UNKNOWN_SIZE : false; \
1664bool CPyCppyy::name##ArrayConverter::SetArg( \
1665 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
1668 bool convOk = false; \
1671 if (fShape.ndim() == 2) { \
1672 if (Py_TYPE(pyobject) == GetCTypesPtrType(ct_##ctype)) { \
1673 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1674 para.fTypeCode = 'p'; \
1676 } else if (Py_TYPE(pyobject) == GetCTypesType(ct_c_void_p)) { \
1678 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1679 para.fTypeCode = 'p'; \
1681 } else if (LowLevelView_Check(pyobject) && \
1682 ((LowLevelView*)pyobject)->fBufInfo.ndim == 2 && \
1683 strchr(((LowLevelView*)pyobject)->fBufInfo.format, code)) { \
1684 para.fValue.fVoidp = ((LowLevelView*)pyobject)->get_buf(); \
1685 para.fTypeCode = 'p'; \
1692 PyTypeObject* ctypes_type = GetCTypesType(ct_##ctype); \
1693 if (Py_TYPE(pyobject) == ctypes_type) { \
1694 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1695 para.fTypeCode = 'p'; \
1697 } else if (Py_TYPE(pyobject) == GetCTypesPtrType(ct_##ctype)) { \
1698 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)pyobject)->b_ptr;\
1699 para.fTypeCode = 'V'; \
1701 } else if (IsPyCArgObject(pyobject)) { \
1702 CPyCppyy_tagPyCArgObject* carg = (CPyCppyy_tagPyCArgObject*)pyobject;\
1703 if (carg->obj && Py_TYPE(carg->obj) == ctypes_type) { \
1704 para.fValue.fVoidp = (void*)((CPyCppyy_tagCDataObject*)carg->obj)->b_ptr;\
1705 para.fTypeCode = 'p'; \
1713 bool ismulti = fShape.ndim() > 1; \
1714 convOk = CArraySetArg(pyobject, para, code, ismulti ? sizeof(void*) : sizeof(type), true);\
1718 if (convOk) SetLifeLine(ctxt->fPyContext, pyobject, (intptr_t)this); \
1723PyObject* CPyCppyy::name##ArrayConverter::FromMemory(void* address) \
1726 return CreateLowLevelView##suffix((type**)address, fShape); \
1727 return CreateLowLevelView##suffix(*(type**)address, fShape); \
1730bool CPyCppyy::name##ArrayConverter::ToMemory( \
1731 PyObject* value, void* address, PyObject* ctxt) \
1733 if (fShape.ndim() <= 1 || fIsFixed) { \
1734 void* buf = nullptr; \
1735 Py_ssize_t buflen = Utility::GetBuffer(value, code, sizeof(type), buf);\
1736 return ToArrayFromBuffer<type>(value, address, ctxt, buf, buflen, fShape, fIsFixed);\
1738 void* buf = nullptr; \
1739 Py_ssize_t buflen = Utility::GetBuffer(value, code, sizeof(void*), buf);\
1740 if (buflen == 0) return false; \
1741 *(type**)address = (type*)buf; \
1742 SetLifeLine(ctxt, value, (intptr_t)address); \
1752#if __cplusplus > 201402L
1773bool CPyCppyy::CStringArrayConverter::SetArg(
1781 para.fTypeCode =
'V';
1785#if PY_VERSION_HEX >= 0x03000000
1793 if (
len == (
size_t)-1) {
1799 for (
size_t i = 0; i <
len; ++i) {
1817 para.fTypeCode =
'p';
1826PyObject* CPyCppyy::CStringArrayConverter::FromMemory(
void* address)
1844 return SCharArrayConverter::ToMemory(
value, address,
ctxt);
1848PyObject* CPyCppyy::NonConstCStringArrayConverter::FromMemory(
void* address)
1862 para.fValue.fVoidp =
nullptr;
1863 para.fTypeCode =
'p';
1878#if PY_VERSION_HEX < 0x03030000
1888 const char*
cstr =
nullptr;
1890 if (
cstr) buffer = T{
cstr, (
typename T::size_type)
len};
1898#define CPPYY_IMPL_STRING_AS_PRIMITIVE_CONVERTER(name, type, F1, F2) \
1899CPyCppyy::name##Converter::name##Converter(bool keepControl) : \
1900 InstanceConverter(Cppyy::GetScope(#type), keepControl) {} \
1902bool CPyCppyy::name##Converter::SetArg( \
1903 PyObject* pyobject, Parameter& para, CallContext* ctxt) \
1905 if (CPyCppyy_PyUnicodeAsBytes2Buffer(pyobject, fBuffer)) { \
1906 para.fValue.fVoidp = &fBuffer; \
1907 para.fTypeCode = 'V'; \
1912 if (!(PyInt_Check(pyobject) || PyLong_Check(pyobject))) { \
1913 bool result = InstanceConverter::SetArg(pyobject, para, ctxt); \
1914 para.fTypeCode = 'V'; \
1921PyObject* CPyCppyy::name##Converter::FromMemory(void* address) \
1924 return InstanceConverter::FromMemory(address); \
1925 auto* empty = new type(); \
1926 return BindCppObjectNoCast(empty, fClass, CPPInstance::kIsOwner); \
1929bool CPyCppyy::name##Converter::ToMemory( \
1930 PyObject* value, void* address, PyObject* ctxt) \
1932 if (CPyCppyy_PyUnicodeAsBytes2Buffer(value, *((type*)address))) \
1934 return InstanceConverter::ToMemory(value, address, ctxt); \
1941CPyCppyy::STLWStringConverter::STLWStringConverter(
bool keepControl) :
1944bool CPyCppyy::STLWStringConverter::SetArg(
1952 para.fTypeCode =
'V';
1955#if PY_VERSION_HEX < 0x03000000
1958 std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>
cnv;
1962 if (!
pyu)
return false;
1968 para.fTypeCode =
'V';
1975 para.fTypeCode =
'V';
1982PyObject* CPyCppyy::STLWStringConverter::FromMemory(
void* address)
1994 wchar_t* buf =
new wchar_t[
len+1];
1996 *((std::wstring*)address) = std::wstring(buf,
len);
2000 return InstanceConverter::ToMemory(
value, address,
ctxt);
2004#if __cplusplus > 201402L
2005CPyCppyy::STLStringViewConverter::STLStringViewConverter(
bool keepControl) :
2008bool CPyCppyy::STLStringViewConverter::SetArg(
2015 para.fTypeCode =
'V';
2026 fBuffer = std::string_view(
cstr, (std::string_view::size_type)
len);
2028 para.fTypeCode =
'V';
2041 void* ptr =
pyobj->GetObject();
2047 fBuffer = *((std::string*)ptr);
2049 para.fTypeCode =
'V';
2057PyObject* CPyCppyy::STLStringViewConverter::FromMemory(
void* address)
2060 return InstanceConverter::FromMemory(address);
2061 auto* empty =
new std::string_view();
2065bool CPyCppyy::STLStringViewConverter::ToMemory(
2069 if (InstanceConverter::ToMemory(
value, address,
ctxt))
2077 *
reinterpret_cast<std::string_view*
>(address) = \
2078 std::string_view(
cstr, (std::string_view::size_type)
len);
2087bool CPyCppyy::STLStringMoveConverter::SetArg(
2116template <
bool ISCONST>
2123 if (GetAddressSpecialCase(
pyobject,
para.fValue.fVoidp)) {
2124 para.fTypeCode =
'p';
2144 para.fValue.fVoidp =
pyobj->GetObject();
2151 para.fTypeCode =
'p';
2159template <
bool ISCONST>
2169template <
bool ISCONST>
2175 void* ptr =
nullptr;
2176 if (GetAddressSpecialCase(
value, ptr)) {
2177 *(
void**)address = ptr;
2190 *(
void**)address =
pyobj->GetObject();
2200bool CPyCppyy::InstanceConverter::SetArg(
2209 para.fValue.fVoidp =
pyobj->GetObject();
2210 if (!
para.fValue.fVoidp)
2218 para.fTypeCode =
'V';
2227PyObject* CPyCppyy::InstanceConverter::FromMemory(
void* address)
2253bool CPyCppyy::InstanceRefConverter::SetArg(
2268 if (
pyobj->IsSmart()) {
2271 para.fValue.fVoidp =
pyobj->GetObjectRaw();
2279 para.fValue.fVoidp =
pyobj->GetObject();
2286 if (!
para.fValue.fVoidp) {
2297 para.fTypeCode =
'V';
2309PyObject* CPyCppyy::InstanceRefConverter::FromMemory(
void* address)
2315bool CPyCppyy::InstanceMoveConverter::SetArg(
2346template <
bool ISREFERENCE>
2347bool CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::SetArg(
2355 para.fValue.fVoidp =
nullptr;
2356 para.fTypeCode =
'p';
2369 para.fValue.fVoidp =
pyobj->GetObjectRaw();
2371 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2380template <
bool ISREFERENCE>
2381PyObject* CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::FromMemory(
void* address)
2388template <
bool ISREFERENCE>
2389bool CPyCppyy::InstancePtrPtrConverter<ISREFERENCE>::ToMemory(
2397 *(
void**)address =
nullptr;
2412 *(
void**)address =
pyobj->GetObject();
2424 template class CPyCppyy::InstancePtrPtrConverter<true>;
2425 template class CPyCppyy::InstancePtrPtrConverter<false>;
2429bool CPyCppyy::InstanceArrayConverter::SetArg(
2448 para.fTypeCode =
'p';
2456PyObject* CPyCppyy::InstanceArrayConverter::FromMemory(
void* address)
2463bool CPyCppyy::InstanceArrayConverter::ToMemory(
2470 "access to C-arrays of objects not yet implemented!");
2477bool CPyCppyy::STLIteratorConverter::SetArg(
2485 para.fValue.fVoidp =
pyobj->GetObject();
2486 para.fTypeCode =
'V';
2492bool CPyCppyy::VoidPtrRefConverter::SetArg(
2498 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2499 para.fTypeCode =
'V';
2507CPyCppyy::VoidPtrPtrConverter::VoidPtrPtrConverter(
cdims_t dims) :
2513bool CPyCppyy::VoidPtrPtrConverter::SetArg(
2520 para.fValue.fVoidp = &
pyobj->GetObjectRaw();
2521 para.fTypeCode =
'p';
2527 para.fTypeCode =
'p';
2537 if (
para.fValue.fVoidp && buflen != 0) {
2538 para.fTypeCode =
'p';
2546PyObject* CPyCppyy::VoidPtrPtrConverter::FromMemory(
void* address)
2549 if (!address || *(ptrdiff_t*)address == 0) {
2559bool CPyCppyy::PyObjectConverter::SetArg(
2564 para.fTypeCode =
'p';
2568PyObject* CPyCppyy::PyObjectConverter::FromMemory(
void* address)
2604 auto key =
ipos->second.second;
2622 const_cast<char*
>(
"internal_WrapperCacheEraser"),
2638 if (!
ol->fMethodInfo ||
ol->fMethodInfo->fMethods.empty())
2642 for (
auto&
m :
ol->fMethodInfo->fMethods) {
2647 void*
fptr = (
void*)
m->GetFunctionAddress();
2657 std::string fullname =
pytmpl->fTI->fCppName;
2658 if (
pytmpl->fTemplateArgs)
2706 std::ostringstream
wname;
2710 std::ostringstream code;
2711 code <<
"namespace __cppyy_internal {\n "
2713 for (
int i = 0; i <
nArgs; ++i) {
2714 code <<
argtypes[i] <<
" arg" << i;
2715 if (i !=
nArgs-1) code <<
", ";
2726 code <<
" PyObject** ref = (PyObject**)" << (intptr_t)ref <<
";\n"
2727 " PyObject* pyresult = nullptr;\n"
2728 " if (*ref) pyresult = PyObject_CallFunctionObjArgs(*ref";
2729 for (
int i = 0; i <
nArgs; ++i)
2730 code <<
", pyargs[" << i <<
"]";
2731 code <<
", NULL);\n"
2732 " else PyErr_SetString(PyExc_TypeError, \"callable was deleted\");\n";
2764bool CPyCppyy::FunctionPointerConverter::SetArg(
2769 para.fValue.fVoidp =
nullptr;
2770 para.fTypeCode =
'p';
2779 para.fTypeCode =
'p';
2786PyObject* CPyCppyy::FunctionPointerConverter::FromMemory(
void* address)
2797bool CPyCppyy::FunctionPointerConverter::ToMemory(
2802 *((
void**)address) =
nullptr;
2810 *((
void**)address) =
fptr;
2819bool CPyCppyy::StdFunctionConverter::SetArg(
2833 PyObject* func = this->FunctionPointerConverter::FromMemory(&
para.fValue.fVoidp);
2846PyObject* CPyCppyy::StdFunctionConverter::FromMemory(
void* address)
2861bool CPyCppyy::SmartPtrConverter::SetArg(
2888 para.fValue.fVoidp =
pyobj->GetSmartObject();
2903 para.fValue.fVoidp =
pyobj->GetObject();
2934 pyobj->PythonOwns();
2945 para.fTypeCode =
'V';
2952PyObject* CPyCppyy::SmartPtrConverter::FromMemory(
void* address)
2965#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
2968 typedef size_t size_type;
2969 typedef void* iterator;
2973#elif defined (_MSC_VER)
2976 typedef char* iterator;
2981#define NO_KNOWN_INITIALIZER_LIST 1
2986CPyCppyy::InitializerListConverter::InitializerListConverter(
Cppyy::TCppType_t klass, std::string
const &value_type)
2988 : InstanceConverter{
klass},
2995CPyCppyy::InitializerListConverter::~InitializerListConverter()
3003void CPyCppyy::InitializerListConverter::Clear() {
3006#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3007 for (faux_initlist::size_type i = 0; i <
fake->_M_len; ++i) {
3008#elif defined (_MSC_VER)
3020bool CPyCppyy::InitializerListConverter::SetArg(
3023#ifdef NO_KNOWN_INITIALIZER_LIST
3043 void* buf =
nullptr;
3047 if (buf && buflen) {
3052#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3053 fake->_M_len = (faux_initlist::size_type)buflen;
3054#elif defined (_MSC_VER)
3069#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3070 fake->_M_len = (faux_initlist::size_type)
len;
3071 for (faux_initlist::size_type i = 0; i <
fake->_M_len; ++i) {
3072#elif defined (_MSC_VER)
3094 if (
memloc) entries += 1;
3097 "default ctor needed for initializer list of objects");
3112#if defined (_LIBCPP_INITIALIZER_LIST) || defined(__GNUC__)
3113 fake->_M_len = (faux_initlist::size_type)entries;
3114#elif defined (_MSC_VER)
3127 para.fTypeCode =
'V';
3148 if (
cpd ==
"**" ||
cpd ==
"*[]" ||
cpd ==
"&*")
3150 else if (
cpd ==
"*&")
3156 else if (
cpd ==
"&")
3158 else if (
cpd ==
"&&")
3184 return (
h->second)(
dims);
3194 return (
h->second)(
dims);
3205 return (
h->second)(
dims);
3212 return (
h->second)(
dims);
3216 if (
cpd.compare(0, 3,
"*[]") == 0) {
3230 for (
int i = 2; i < (
newdim-1); ++i)
3236 return (
h->second)(
dims);
3239 }
else if (!
cpd.empty() && (std::string::size_type)std::count(
cpd.
begin(),
cpd.
end(),
'*') ==
cpd.size()) {
3245 }
else if (2 <=
cpd.size() && (std::string::size_type)std::count(
cpd.
begin(),
cpd.
end(),
'[') ==
cpd.size() / 2) {
3249 return (
h->second)(
dims);
3253 if (
realType.compare(0, 16,
"initializer_list") == 0) {
3265 if (pos == 0 || pos == 5 ||
3266 pos == 6 || pos == 11 ) {
3276 if (
pos1 != std::string::npos &&
pos2 != std::string::npos) {
3280 return new StdFunctionConverter(
cnv,
3282 }
else if (
cnv->HasState())
3294 }
else if (
cpd ==
"&") {
3304 static STLIteratorConverter
c;
3314 auto pos1 =
sm.position(0);
3316 result =
new FunctionPointerConverter(
3325 return (
h->second)(
dims);
3327 result =
new NotImplementedConverter();
3335 if (
cpd.size() == 2 &&
cpd !=
"&&")
3336 result =
new VoidPtrPtrConverter(
dims.ndim());
3337 else if (!
cpd.empty())
3340 result =
new NotImplementedConverter();
3350 if (
p &&
p->HasState())
3408#define STRINGVIEW "basic_string_view<char,char_traits<char> >"
3409#define WSTRING1 "std::basic_string<wchar_t>"
3410#define WSTRING2 "std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>"
3414#define CCOMPLEX_D "_Complex double"
3415#define CCOMPLEX_F "_Complex float"
3417#define CCOMPLEX_D "_C_double_complex"
3418#define CCOMPLEX_F "_C_float_complex"
3421static struct InitConvFactories_t {
3423 InitConvFactories_t() {
3428 gf[
"bool"] = (
cf_t)+[](
cdims_t) {
static BoolConverter
c{};
return &
c; };
3429 gf[
"const bool&"] = (
cf_t)+[](
cdims_t) {
static ConstBoolRefConverter
c{};
return &
c; };
3430 gf[
"bool&"] = (
cf_t)+[](
cdims_t) {
static BoolRefConverter
c{};
return &
c; };
3431 gf[
"char"] = (
cf_t)+[](
cdims_t) {
static CharConverter
c{};
return &
c; };
3432 gf[
"const char&"] = (
cf_t)+[](
cdims_t) {
static ConstCharRefConverter
c{};
return &
c; };
3433 gf[
"char&"] = (
cf_t)+[](
cdims_t) {
static CharRefConverter
c{};
return &
c; };
3434 gf[
"signed char&"] = (
cf_t)+[](
cdims_t) {
static SCharRefConverter
c{};
return &
c; };
3435 gf[
"unsigned char"] = (
cf_t)+[](
cdims_t) {
static UCharConverter
c{};
return &
c; };
3436 gf[
"const unsigned char&"] = (
cf_t)+[](
cdims_t) {
static ConstUCharRefConverter
c{};
return &
c; };
3437 gf[
"unsigned char&"] = (
cf_t)+[](
cdims_t) {
static UCharRefConverter
c{};
return &
c; };
3438 gf[
"SCharAsInt"] = (
cf_t)+[](
cdims_t) {
static SCharAsIntConverter
c{};
return &
c; };
3439 gf[
"UCharAsInt"] = (
cf_t)+[](
cdims_t) {
static UCharAsIntConverter
c{};
return &
c; };
3440 gf[
"wchar_t"] = (
cf_t)+[](
cdims_t) {
static WCharConverter
c{};
return &
c; };
3441 gf[
"char16_t"] = (
cf_t)+[](
cdims_t) {
static Char16Converter
c{};
return &
c; };
3442 gf[
"char32_t"] = (
cf_t)+[](
cdims_t) {
static Char32Converter
c{};
return &
c; };
3443 gf[
"wchar_t&"] = (
cf_t)+[](
cdims_t) {
static WCharRefConverter
c{};
return &
c; };
3444 gf[
"char16_t&"] = (
cf_t)+[](
cdims_t) {
static Char16RefConverter
c{};
return &
c; };
3445 gf[
"char32_t&"] = (
cf_t)+[](
cdims_t) {
static Char32RefConverter
c{};
return &
c; };
3446 gf[
"int8_t"] = (
cf_t)+[](
cdims_t) {
static Int8Converter
c{};
return &
c; };
3447 gf[
"const int8_t&"] = (
cf_t)+[](
cdims_t) {
static ConstInt8RefConverter
c{};
return &
c; };
3448 gf[
"int8_t&"] = (
cf_t)+[](
cdims_t) {
static Int8RefConverter
c{};
return &
c; };
3449 gf[
"uint8_t"] = (
cf_t)+[](
cdims_t) {
static UInt8Converter
c{};
return &
c; };
3450 gf[
"const uint8_t&"] = (
cf_t)+[](
cdims_t) {
static ConstUInt8RefConverter
c{};
return &
c; };
3451 gf[
"uint8_t&"] = (
cf_t)+[](
cdims_t) {
static UInt8RefConverter
c{};
return &
c; };
3452 gf[
"short"] = (
cf_t)+[](
cdims_t) {
static ShortConverter
c{};
return &
c; };
3453 gf[
"const short&"] = (
cf_t)+[](
cdims_t) {
static ConstShortRefConverter
c{};
return &
c; };
3454 gf[
"short&"] = (
cf_t)+[](
cdims_t) {
static ShortRefConverter
c{};
return &
c; };
3455 gf[
"unsigned short"] = (
cf_t)+[](
cdims_t) {
static UShortConverter
c{};
return &
c; };
3456 gf[
"const unsigned short&"] = (
cf_t)+[](
cdims_t) {
static ConstUShortRefConverter
c{};
return &
c; };
3457 gf[
"unsigned short&"] = (
cf_t)+[](
cdims_t) {
static UShortRefConverter
c{};
return &
c; };
3458 gf[
"int"] = (
cf_t)+[](
cdims_t) {
static IntConverter
c{};
return &
c; };
3459 gf[
"int&"] = (
cf_t)+[](
cdims_t) {
static IntRefConverter
c{};
return &
c; };
3460 gf[
"const int&"] = (
cf_t)+[](
cdims_t) {
static ConstIntRefConverter
c{};
return &
c; };
3461 gf[
"unsigned int"] = (
cf_t)+[](
cdims_t) {
static UIntConverter
c{};
return &
c; };
3462 gf[
"const unsigned int&"] = (
cf_t)+[](
cdims_t) {
static ConstUIntRefConverter
c{};
return &
c; };
3463 gf[
"unsigned int&"] = (
cf_t)+[](
cdims_t) {
static UIntRefConverter
c{};
return &
c; };
3464 gf[
"long"] = (
cf_t)+[](
cdims_t) {
static LongConverter
c{};
return &
c; };
3465 gf[
"long&"] = (
cf_t)+[](
cdims_t) {
static LongRefConverter
c{};
return &
c; };
3466 gf[
"const long&"] = (
cf_t)+[](
cdims_t) {
static ConstLongRefConverter
c{};
return &
c; };
3467 gf[
"unsigned long"] = (
cf_t)+[](
cdims_t) {
static ULongConverter
c{};
return &
c; };
3468 gf[
"const unsigned long&"] = (
cf_t)+[](
cdims_t) {
static ConstULongRefConverter
c{};
return &
c; };
3469 gf[
"unsigned long&"] = (
cf_t)+[](
cdims_t) {
static ULongRefConverter
c{};
return &
c; };
3470 gf[
"long long"] = (
cf_t)+[](
cdims_t) {
static LLongConverter
c{};
return &
c; };
3471 gf[
"const long long&"] = (
cf_t)+[](
cdims_t) {
static ConstLLongRefConverter
c{};
return &
c; };
3472 gf[
"long long&"] = (
cf_t)+[](
cdims_t) {
static LLongRefConverter
c{};
return &
c; };
3473 gf[
"unsigned long long"] = (
cf_t)+[](
cdims_t) {
static ULLongConverter
c{};
return &
c; };
3474 gf[
"const unsigned long long&"] = (
cf_t)+[](
cdims_t) {
static ConstULLongRefConverter
c{};
return &
c; };
3475 gf[
"unsigned long long&"] = (
cf_t)+[](
cdims_t) {
static ULLongRefConverter
c{};
return &
c; };
3477 gf[
"float"] = (
cf_t)+[](
cdims_t) {
static FloatConverter
c{};
return &
c; };
3478 gf[
"const float&"] = (
cf_t)+[](
cdims_t) {
static ConstFloatRefConverter
c{};
return &
c; };
3479 gf[
"float&"] = (
cf_t)+[](
cdims_t) {
static FloatRefConverter
c{};
return &
c; };
3480 gf[
"double"] = (
cf_t)+[](
cdims_t) {
static DoubleConverter
c{};
return &
c; };
3481 gf[
"double&"] = (
cf_t)+[](
cdims_t) {
static DoubleRefConverter
c{};
return &
c; };
3482 gf[
"const double&"] = (
cf_t)+[](
cdims_t) {
static ConstDoubleRefConverter
c{};
return &
c; };
3483 gf[
"long double"] = (
cf_t)+[](
cdims_t) {
static LDoubleConverter
c{};
return &
c; };
3484 gf[
"const long double&"] = (
cf_t)+[](
cdims_t) {
static ConstLDoubleRefConverter
c{};
return &
c; };
3485 gf[
"long double&"] = (
cf_t)+[](
cdims_t) {
static LDoubleRefConverter
c{};
return &
c; };
3486 gf[
"std::complex<double>"] = (
cf_t)+[](
cdims_t) {
return new ComplexDConverter{}; };
3487 gf[
"const std::complex<double>&"] = (
cf_t)+[](
cdims_t) {
return new ComplexDConverter{}; };
3488 gf[
"void"] = (
cf_t)+[](
cdims_t) {
static VoidConverter
c{};
return &
c; };
3491 gf[
"bool ptr"] = (
cf_t)+[](
cdims_t d) {
return new BoolArrayConverter{
d}; };
3492 gf[
"signed char ptr"] = (
cf_t)+[](
cdims_t d) {
return new SCharArrayConverter{
d}; };
3494 gf[
"const unsigned char*"] = (
cf_t)+[](
cdims_t d) {
return new UCharArrayConverter{
d}; };
3495 gf[
"unsigned char ptr"] = (
cf_t)+[](
cdims_t d) {
return new UCharArrayConverter{
d}; };
3496 gf[
"SCharAsInt*"] =
gf[
"signed char ptr"];
3497 gf[
"SCharAsInt[]"] =
gf[
"signed char ptr"];
3498 gf[
"UCharAsInt*"] =
gf[
"unsigned char ptr"];
3499 gf[
"UCharAsInt[]"] =
gf[
"unsigned char ptr"];
3500#if __cplusplus > 201402L
3503 gf[
"int8_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new Int8ArrayConverter{
d}; };
3504 gf[
"uint8_t ptr"] = (
cf_t)+[](
cdims_t d) {
return new UInt8ArrayConverter{
d}; };
3505 gf[
"short ptr"] = (
cf_t)+[](
cdims_t d) {
return new ShortArrayConverter{
d}; };
3506 gf[
"unsigned short ptr"] = (
cf_t)+[](
cdims_t d) {
return new UShortArrayConverter{
d}; };
3507 gf[
"int ptr"] = (
cf_t)+[](
cdims_t d) {
return new IntArrayConverter{
d}; };
3508 gf[
"unsigned int ptr"] = (
cf_t)+[](
cdims_t d) {
return new UIntArrayConverter{
d}; };
3509 gf[
"long ptr"] = (
cf_t)+[](
cdims_t d) {
return new LongArrayConverter{
d}; };
3510 gf[
"unsigned long ptr"] = (
cf_t)+[](
cdims_t d) {
return new ULongArrayConverter{
d}; };
3511 gf[
"long long ptr"] = (
cf_t)+[](
cdims_t d) {
return new LLongArrayConverter{
d}; };
3512 gf[
"unsigned long long ptr"] = (
cf_t)+[](
cdims_t d) {
return new ULLongArrayConverter{
d}; };
3513 gf[
"float ptr"] = (
cf_t)+[](
cdims_t d) {
return new FloatArrayConverter{
d}; };
3514 gf[
"double ptr"] = (
cf_t)+[](
cdims_t d) {
return new DoubleArrayConverter{
d}; };
3515 gf[
"long double ptr"] = (
cf_t)+[](
cdims_t d) {
return new LDoubleArrayConverter{
d}; };
3516 gf[
"std::complex<float> ptr"] = (
cf_t)+[](
cdims_t d) {
return new ComplexFArrayConverter{
d}; };
3517 gf[
"std::complex<double> ptr"] = (
cf_t)+[](
cdims_t d) {
return new ComplexDArrayConverter{
d}; };
3521 gf[
"signed char"] =
gf[
"char"];
3522 gf[
"const signed char&"] =
gf[
"const char&"];
3523#if __cplusplus > 201402L
3524 gf[
"std::byte"] =
gf[
"uint8_t"];
3525 gf[
"byte"] =
gf[
"uint8_t"];
3526 gf[
"const std::byte&"] =
gf[
"const uint8_t&"];
3527 gf[
"const byte&"] =
gf[
"const uint8_t&"];
3528 gf[
"std::byte&"] =
gf[
"uint8_t&"];
3529 gf[
"byte&"] =
gf[
"uint8_t&"];
3531 gf[
"std::int8_t"] =
gf[
"int8_t"];
3532 gf[
"const std::int8_t&"] =
gf[
"const int8_t&"];
3533 gf[
"std::int8_t&"] =
gf[
"int8_t&"];
3534 gf[
"std::uint8_t"] =
gf[
"uint8_t"];
3535 gf[
"const std::uint8_t&"] =
gf[
"const uint8_t&"];
3536 gf[
"std::uint8_t&"] =
gf[
"uint8_t&"];
3537 gf[
"internal_enum_type_t"] =
gf[
"int"];
3538 gf[
"internal_enum_type_t&"] =
gf[
"int&"];
3539 gf[
"const internal_enum_type_t&"] =
gf[
"const int&"];
3540 gf[
"internal_enum_type_t ptr"] =
gf[
"int ptr"];
3542 gf[
"__int64"] =
gf[
"long long"];
3543 gf[
"const __int64&"] =
gf[
"const long long&"];
3544 gf[
"__int64&"] =
gf[
"long long&"];
3545 gf[
"__int64 ptr"] =
gf[
"long long ptr"];
3546 gf[
"unsigned __int64"] =
gf[
"unsigned long long"];
3547 gf[
"const unsigned __int64&"] =
gf[
"const unsigned long long&"];
3548 gf[
"unsigned __int64&"] =
gf[
"unsigned long long&"];
3549 gf[
"unsigned __int64 ptr"] =
gf[
"unsigned long long ptr"];
3557 gf[
"TString"] = (
cf_t)+[](
cdims_t) {
return new TStringConverter{}; };
3558 gf[
"TString&"] =
gf[
"TString"];
3559 gf[
"const TString&"] =
gf[
"TString"];
3560 gf[
"nullptr_t"] = (
cf_t)+[](
cdims_t) {
static NullptrConverter
c{};
return &
c;};
3561 gf[
"const char*"] = (
cf_t)+[](
cdims_t) {
return new CStringConverter{}; };
3562 gf[
"const signed char*"] =
gf[
"const char*"];
3563 gf[
"const char*&&"] =
gf[
"const char*"];
3564 gf[
"const char[]"] = (
cf_t)+[](
cdims_t) {
return new CStringConverter{}; };
3566 gf[
"char[]"] = (
cf_t)+[](
cdims_t d) {
return new NonConstCStringArrayConverter{
d,
true}; };
3567 gf[
"signed char*"] =
gf[
"char*"];
3568 gf[
"wchar_t*"] = (
cf_t)+[](
cdims_t) {
return new WCStringConverter{}; };
3569 gf[
"char16_t*"] = (
cf_t)+[](
cdims_t) {
return new CString16Converter{}; };
3571 gf[
"char32_t*"] = (
cf_t)+[](
cdims_t) {
return new CString32Converter{}; };
3574 gf[
"char16_t**"] =
gf[
"char16_t*"];
3575 gf[
"char32_t**"] =
gf[
"char32_t*"];
3577 gf[
"char**"] =
gf[
"const char**"];
3578 gf[
"const char*[]"] = (
cf_t)+[](
cdims_t d) {
return new CStringArrayConverter{
d,
false}; };
3579 gf[
"char*[]"] = (
cf_t)+[](
cdims_t d) {
return new NonConstCStringArrayConverter{
d,
false}; };
3580 gf[
"char ptr"] =
gf[
"char*[]"];
3581 gf[
"std::string"] = (
cf_t)+[](
cdims_t) {
return new STLStringConverter{}; };
3582 gf[
"const std::string&"] =
gf[
"std::string"];
3583 gf[
"string"] =
gf[
"std::string"];
3584 gf[
"const string&"] =
gf[
"std::string"];
3585 gf[
"std::string&&"] = (
cf_t)+[](
cdims_t) {
return new STLStringMoveConverter{}; };
3586 gf[
"string&&"] =
gf[
"std::string&&"];
3587#if __cplusplus > 201402L
3590 gf[
"std::string_view&"] =
gf[
"std::string_view"];
3591 gf[
"const std::string_view&"] =
gf[
"std::string_view"];
3594 gf[
"std::wstring"] = (
cf_t)+[](
cdims_t) {
return new STLWStringConverter{}; };
3597 gf[
"const std::wstring&"] =
gf[
"std::wstring"];
3600 gf[
"void*&"] = (
cf_t)+[](
cdims_t) {
static VoidPtrRefConverter
c{};
return &
c; };
3601 gf[
"void**"] = (
cf_t)+[](
cdims_t d) {
return new VoidPtrPtrConverter{
d}; };
3602 gf[
"void ptr"] =
gf[
"void**"];
3603 gf[
"PyObject*"] = (
cf_t)+[](
cdims_t) {
static PyObjectConverter
c{};
return &
c; };
3604 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 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 std::map< void *, PyObject ** > sWrapperReference
static bool CPyCppyy_PyLong_AsBool(PyObject *pyobject)
static bool IsPyCArgObject(PyObject *pyobject)
static std::array< PyTypeObject *, 24 > gCTypesTypes
static PyObject * WrapperCacheEraser(PyObject *, PyObject *pyref)
static bool CPyCppyy_PyUnicodeAsBytes2Buffer(PyObject *pyobject, T &buffer)
#define CPPYY_IMPL_STRING_AS_PRIMITIVE_CONVERTER(name, type, F1, F2)
#define CPPYY_IMPL_BASIC_CHAR_CONVERTER(name, type, low, high)
#define CPPYY_IMPL_BASIC_CONST_CHAR_REFCONVERTER(name, type, ctype, low, high)
static bool SetLifeLine(PyObject *holder, PyObject *target, intptr_t ref)
static std::array< PyTypeObject *, 24 > gCTypesPtrTypes
static PY_LONG_LONG CPyCppyy_PyLong_AsStrictLongLong(PyObject *pyobject)
static std::array< const char *, 24 > gCTypesNames
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)
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 uint8_t CPyCppyy_PyLong_AsUInt8(PyObject *pyobject)
static short CPyCppyy_PyLong_AsShort(PyObject *pyobject)
static long CPyCppyy_PyLong_AsStrictLong(PyObject *pyobject)
#define CPPYY_IMPL_ARRAY_CONVERTER(name, ctype, type, code, suffix)
#define CPPYY_IMPL_BASIC_CONVERTER_NB(name, type, stype, ctype, F1, F2, tc)
#define CPPYY_IMPL_REFCONVERTER(name, ctype, type, code)
#define CPPYY_IMPL_BASIC_CONVERTER_NI(name, type, stype, ctype, F1, F2, tc)
static PyTypeObject * GetCTypesType(int nidx)
static CPyCppyy::CPPInstance * ConvertImplicit(Cppyy::TCppType_t klass, PyObject *pyobject, CPyCppyy::Parameter ¶, CPyCppyy::CallContext *ctxt, bool manage=true)
static int CPyCppyy_PyLong_AsStrictInt(PyObject *pyobject)
static std::map< RetSigKey_t, std::vector< void * > > sWrapperFree
static bool IsCTypesArrayOrPointer(PyObject *pyobject)
static unsigned int sWrapperCounter
#define CPPYY_PYLONG_AS_TYPE(name, type, limit_low, limit_high)
static void * PyFunction_AsCPointer(PyObject *pyobject, const std::string &rettype, const std::string &signature)
#define CPPYY_IMPL_REFCONVERTER_FROM_MEMORY(name, ctype)
unsigned long long PY_ULONG_LONG
std::string fValueTypeName
Cppyy::TCppType_t fValueType
Cppyy::TCppType_t fSmartPtrType
Cppyy::TCppType_t fUnderlyingType
std::string::size_type fMaxSize
std::vector< Converter * > fConverters
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)=0
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual PyObject * FromMemory(void *address)
virtual PyObject * FromMemory(void *address)
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
static bool RegisterPyObject(CPPInstance *pyobj, void *cppobj)
virtual bool GetAddressSpecialCase(PyObject *pyobject, void *&address)
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual PyObject * FromMemory(void *address)
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)
Internal::TypedIter< T, decltype(std::begin(std::declval< Range_t >())), isDynamic > iterator
const_iterator begin() const
const_iterator end() const
std::string clean_type(const std::string &cppname, bool template_strip=true, bool const_strip=true)
std::string compound(const std::string &name)
std::vector< std::string > extract_arg_types(const std::string &sig)
void ConstructCallbackPreamble(const std::string &retType, const std::vector< std::string > &argtypes, std::ostringstream &code)
void ConstructCallbackReturn(const std::string &retType, int nArgs, std::ostringstream &code)
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 AllowImplicit(CallContext *ctxt)
bool UseStrictOwnership(CallContext *ctxt)
PY_ULONG_LONG PyLongOrInt_AsULong64(PyObject *pyobject)
bool CPPInstance_Check(T *object)
PyObject * BindCppObjectArray(Cppyy::TCppObject_t address, Cppyy::TCppType_t klass, cdims_t dims)
PyObject * CreatePointerView(void *ptr, cdims_t shape=0)
PyObject * gNullPtrObject
bool IsConstructor(uint64_t flags)
CPYCPPYY_EXTERN bool RegisterConverterAlias(const std::string &name, const std::string &target)
CPYCPPYY_EXTERN Converter * CreateConverter(const std::string &name, cdims_t=0)
PyObject * BindCppObject(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, const unsigned flags=0)
static std::regex s_fnptr("\\(:*\\*&*\\)")
CPYCPPYY_EXTERN void DestroyConverter(Converter *p)
bool TemplateProxy_Check(T *object)
std::map< std::string, cf_t > ConvFactories_t
CPYCPPYY_EXTERN bool UnregisterConverter(const std::string &name)
RPY_EXPORTED ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
RPY_EXPORTED size_t SizeOf(TCppType_t klass)
RPY_EXPORTED std::vector< TCppIndex_t > GetMethodIndicesFromName(TCppScope_t scope, const std::string &name)
RPY_EXPORTED bool Compile(const std::string &code, bool silent=false)
RPY_EXPORTED void CallDestructor(TCppType_t type, TCppObject_t self)
RPY_EXPORTED bool IsSubtype(TCppType_t derived, TCppType_t base)
RPY_EXPORTED TCppMethod_t GetMethodTemplate(TCppScope_t scope, const std::string &name, const std::string &proto)
RPY_EXPORTED TCppObject_t Construct(TCppType_t type, void *arena=nullptr)
RPY_EXPORTED bool GetSmartPtrInfo(const std::string &, TCppType_t *raw, TCppMethod_t *deref)
RPY_EXPORTED std::string ResolveName(const std::string &cppitem_name)
RPY_EXPORTED TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
RPY_EXPORTED bool IsSmartPtr(TCppType_t type)
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
RPY_EXPORTED TCppFuncAddr_t GetFunctionAddress(TCppMethod_t method, bool check_enabled=true)
RooArgList L(Args_t &&... args)
static ECallFlags sMemoryPolicy
PyObject_HEAD char * b_ptr
PyObject_HEAD void * pffi_type
union CPyCppyy_tagPyCArgObject::@202 value