2626#include < regex>
2727#include < utility>
2828#include < sstream>
29- #if __cplusplus > 201402L
29+ #if ( __cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
3030#include < cstddef>
3131#include < string_view>
3232#endif
@@ -58,7 +58,7 @@ namespace CPyCppyy {
5858 extern PyObject* gDefaultObject ;
5959
6060// regular expression for matching function pointer
61- static std::regex s_fnptr (" \\ (: *\\ *&*\\ )" );
61+ static std::regex s_fnptr (" \\ (( \\ w*:*) *\\ *&*\\ )" );
6262}
6363
6464#if PY_VERSION_HEX < 0x03000000
@@ -1749,7 +1749,7 @@ bool CPyCppyy::name##ArrayConverter::ToMemory( \
17491749CPPYY_IMPL_ARRAY_CONVERTER (Bool, c_bool, bool , ' ?' , )
17501750CPPYY_IMPL_ARRAY_CONVERTER(SChar, c_char, signed char , ' b' , )
17511751CPPYY_IMPL_ARRAY_CONVERTER(UChar, c_ubyte, unsigned char , ' B' , )
1752- #if __cplusplus > 201402L
1752+ #if ( __cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
17531753CPPYY_IMPL_ARRAY_CONVERTER (Byte, c_ubyte, std::byte, ' B' , )
17541754#endif
17551755CPPYY_IMPL_ARRAY_CONVERTER (Int8, c_byte, int8_t , ' b' , _i8)
@@ -2001,7 +2001,7 @@ bool CPyCppyy::STLWStringConverter::ToMemory(PyObject* value, void* address, PyO
20012001}
20022002
20032003
2004- #if __cplusplus > 201402L
2004+ #if ( __cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
20052005CPyCppyy::STLStringViewConverter::STLStringViewConverter (bool keepControl) :
20062006 InstanceConverter(Cppyy::GetScope(" std::string_view" ), keepControl) {}
20072007
@@ -2238,7 +2238,11 @@ bool CPyCppyy::InstanceConverter::ToMemory(PyObject* value, void* address, PyObj
22382238{
22392239// assign value to C++ instance living at <address> through assignment operator
22402240 PyObject* pyobj = BindCppObjectNoCast (address, fClass );
2241+ #if PY_VERSION_HEX >= 0x03080000
2242+ PyObject* result = PyObject_CallMethodOneArg (pyobj, PyStrings::gAssign , value);
2243+ #else
22412244 PyObject* result = PyObject_CallMethod (pyobj, (char *)" __assign__" , (char *)" O" , value);
2245+ #endif
22422246 Py_DECREF (pyobj);
22432247
22442248 if (result) {
@@ -2957,6 +2961,25 @@ PyObject* CPyCppyy::SmartPtrConverter::FromMemory(void* address)
29572961 return BindCppObjectNoCast (address, fSmartPtrType );
29582962}
29592963
2964+ bool CPyCppyy::SmartPtrConverter::ToMemory (PyObject* value, void * address, PyObject*)
2965+ {
2966+ // assign value to C++ instance living at <address> through assignment operator (this
2967+ // is similar to InstanceConverter::ToMemory, but prevents wrapping the smart ptr)
2968+ PyObject* pyobj = BindCppObjectNoCast (address, fSmartPtrType , CPPInstance::kNoWrapConv );
2969+ #if PY_VERSION_HEX >= 0x03080000
2970+ PyObject* result = PyObject_CallMethodOneArg (pyobj, PyStrings::gAssign , value);
2971+ #else
2972+ PyObject* result = PyObject_CallMethod (pyobj, (char *)" __assign__" , (char *)" O" , value);
2973+ #endif
2974+ Py_DECREF (pyobj);
2975+
2976+ if (result) {
2977+ Py_DECREF (result);
2978+ return true ;
2979+ }
2980+ return false ;
2981+ }
2982+
29602983
29612984// ----------------------------------------------------------------------------
29622985namespace {
@@ -3497,7 +3520,7 @@ static struct InitConvFactories_t {
34973520 gf[" SCharAsInt[]" ] = gf[" signed char ptr" ];
34983521 gf[" UCharAsInt*" ] = gf[" unsigned char ptr" ];
34993522 gf[" UCharAsInt[]" ] = gf[" unsigned char ptr" ];
3500- #if __cplusplus > 201402L
3523+ #if ( __cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
35013524 gf[" std::byte ptr" ] = (cf_t )+[](cdims_t d) { return new ByteArrayConverter{d}; };
35023525#endif
35033526 gf[" int8_t ptr" ] = (cf_t )+[](cdims_t d) { return new Int8ArrayConverter{d}; };
@@ -3520,7 +3543,7 @@ static struct InitConvFactories_t {
35203543 // aliases
35213544 gf[" signed char" ] = gf[" char" ];
35223545 gf[" const signed char&" ] = gf[" const char&" ];
3523- #if __cplusplus > 201402L
3546+ #if ( __cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
35243547 gf[" std::byte" ] = gf[" uint8_t" ];
35253548 gf[" byte" ] = gf[" uint8_t" ];
35263549 gf[" const std::byte&" ] = gf[" const uint8_t&" ];
@@ -3584,7 +3607,7 @@ static struct InitConvFactories_t {
35843607 gf[" const string&" ] = gf[" std::string" ];
35853608 gf[" std::string&&" ] = (cf_t )+[](cdims_t ) { return new STLStringMoveConverter{}; };
35863609 gf[" string&&" ] = gf[" std::string&&" ];
3587- #if __cplusplus > 201402L
3610+ #if ( __cplusplus > 201402L) || (defined(_MSC_VER) && _MSVC_LANG > 201402L)
35883611 gf[" std::string_view" ] = (cf_t )+[](cdims_t ) { return new STLStringViewConverter{}; };
35893612 gf[STRINGVIEW] = gf[" std::string_view" ];
35903613 gf[" std::string_view&" ] = gf[" std::string_view" ];
0 commit comments