From 0074db08a14250ad85345c4b44722eaff6a029ad Mon Sep 17 00:00:00 2001 From: Baidyanath Kundu Date: Sat, 8 Jul 2023 15:29:05 +0530 Subject: [PATCH] Use underlying type for execs, convs & pythonizer --- src/Converters.cxx | 24 ++++++++++++------------ src/Executors.cxx | 10 +++++----- src/Pythonize.cxx | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Converters.cxx b/src/Converters.cxx index 3f6bb9e4..603a9790 100644 --- a/src/Converters.cxx +++ b/src/Converters.cxx @@ -3308,7 +3308,7 @@ CPyCppyy::Converter* CPyCppyy::CreateConverter(Cppyy::TCppType_t type, cdims_t d // converters for known C++ classes and default (void*) Converter* result = nullptr; - Cppyy::TCppScope_t klass = Cppyy::GetScopeFromType(type); + Cppyy::TCppScope_t klass = Cppyy::GetScopeFromType(realType); if (klass || (klass = Cppyy::GetFullScope(realTypeStr))) { Cppyy::TCppType_t raw{0}; if (Cppyy::GetSmartPtrInfo(realTypeStr, &raw, nullptr)) { @@ -3584,18 +3584,18 @@ static struct InitConvFactories_t { gf["const char*[]"] = (cf_t)+[](cdims_t d) { return new CStringArrayConverter{d}; }; gf["char*[]"] = (cf_t)+[](cdims_t d) { return new NonConstCStringArrayConverter{d}; }; gf["char ptr"] = gf["char*[]"]; - gf["std::string"] = (cf_t)+[](cdims_t) { return new STLStringConverter{}; }; - gf["const std::string&"] = gf["std::string"]; - gf["std::string&&"] = (cf_t)+[](cdims_t) { return new STLStringMoveConverter{}; }; - gf["const std::string &"] = gf["std::string"]; - gf["std::string &&"] = (cf_t)+[](cdims_t) { return new STLStringMoveConverter{}; }; + gf["std::basic_string"] = (cf_t)+[](cdims_t) { return new STLStringConverter{}; }; + gf["const std::basic_string&"] = gf["std::basic_string"]; + gf["std::basic_string&&"] = (cf_t)+[](cdims_t) { return new STLStringMoveConverter{}; }; + gf["const std::basic_string &"] = gf["std::basic_string"]; + gf["std::basic_string &&"] = (cf_t)+[](cdims_t) { return new STLStringMoveConverter{}; }; #if __cplusplus > 201402L - gf["std::string_view"] = (cf_t)+[](cdims_t) { return new STLStringViewConverter{}; }; - gf[STRINGVIEW] = gf["std::string_view"]; - gf["std::string_view&"] = gf["std::string_view"]; - gf["const " STRINGVIEW "&"] = gf["std::string_view"]; - gf["std::string_view &"] = gf["std::string_view"]; - gf["const " STRINGVIEW " &"] = gf["std::string_view"]; + gf["std::basic_string_view"] = (cf_t)+[](cdims_t) { return new STLStringViewConverter{}; }; + gf[STRINGVIEW] = gf["std::basic_string_view"]; + gf["std::basic_string_view&"] = gf["std::basic_string_view"]; + gf["const " STRINGVIEW "&"] = gf["std::basic_string_view"]; + gf["std::basic_string_view &"] = gf["std::basic_string_view"]; + gf["const " STRINGVIEW " &"] = gf["std::basic_string_view"]; #endif gf["std::wstring"] = (cf_t)+[](cdims_t) { return new STLWStringConverter{}; }; gf[WSTRING1] = gf["std::wstring"]; diff --git a/src/Executors.cxx b/src/Executors.cxx index 4eda137a..531eae4b 100644 --- a/src/Executors.cxx +++ b/src/Executors.cxx @@ -1173,11 +1173,11 @@ struct InitExecFactories_t { gf["wchar_t*"] = (ef_t)+[](cdims_t) { static WCStringExecutor e{}; return &e;}; gf["char16_t*"] = (ef_t)+[](cdims_t) { static CString16Executor e{}; return &e;}; gf["char32_t*"] = (ef_t)+[](cdims_t) { static CString32Executor e{}; return &e;}; - gf["std::string"] = (ef_t)+[](cdims_t) { static STLStringExecutor e{}; return &e; }; - gf["std::string&"] = (ef_t)+[](cdims_t) { return new STLStringRefExecutor{}; }; - gf["std::wstring"] = (ef_t)+[](cdims_t) { static STLWStringExecutor e{}; return &e; }; - gf[WSTRING1] = gf["std::wstring"]; - gf[WSTRING2] = gf["std::wstring"]; + gf["std::basic_string"] = (ef_t)+[](cdims_t) { static STLStringExecutor e{}; return &e; }; + gf["std::basic_string&"] = (ef_t)+[](cdims_t) { return new STLStringRefExecutor{}; }; + gf["std::basic_string"] = (ef_t)+[](cdims_t) { static STLWStringExecutor e{}; return &e; }; + gf[WSTRING1] = gf["std::basic_string"]; + gf[WSTRING2] = gf["std::basic_string"]; gf["__init__"] = (ef_t)+[](cdims_t) { static ConstructorExecutor e{}; return &e; }; gf["PyObject*"] = (ef_t)+[](cdims_t) { static PyObjectExecutor e{}; return &e; }; gf["_object*"] = gf["PyObject*"]; diff --git a/src/Pythonize.cxx b/src/Pythonize.cxx index 4a894098..31b5e76e 100644 --- a/src/Pythonize.cxx +++ b/src/Pythonize.cxx @@ -1846,7 +1846,7 @@ bool CPyCppyy::Pythonize(PyObject* pyclass, Cppyy::TCppScope_t scope) Utility::AddToClass(pyclass, "__iter__", (PyCFunction)PyObject_SelfIter, METH_NOARGS); } - else if (name == "std::string") { // TODO: ask backend as well + else if (name == "std::basic_string") { // TODO: ask backend as well Utility::AddToClass(pyclass, "__repr__", (PyCFunction)STLStringRepr, METH_NOARGS); Utility::AddToClass(pyclass, "__str__", (PyCFunction)STLStringStr, METH_NOARGS); Utility::AddToClass(pyclass, "__bytes__", (PyCFunction)STLStringBytes, METH_NOARGS);