Skip to content

Commit

Permalink
Use underlying type for execs, convs & pythonizer
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-panda authored and vgvassilev committed Jul 9, 2023
1 parent 86d9f58 commit 0074db0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions src/Converters.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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<char>"] = (cf_t)+[](cdims_t) { return new STLStringConverter{}; };
gf["const std::basic_string<char>&"] = gf["std::basic_string<char>"];
gf["std::basic_string<char>&&"] = (cf_t)+[](cdims_t) { return new STLStringMoveConverter{}; };
gf["const std::basic_string<char> &"] = gf["std::basic_string<char>"];
gf["std::basic_string<char> &&"] = (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<char>"] = (cf_t)+[](cdims_t) { return new STLStringViewConverter{}; };
gf[STRINGVIEW] = gf["std::basic_string_view<char>"];
gf["std::basic_string_view<char>&"] = gf["std::basic_string_view<char>"];
gf["const " STRINGVIEW "&"] = gf["std::basic_string_view<char>"];
gf["std::basic_string_view<char> &"] = gf["std::basic_string_view<char>"];
gf["const " STRINGVIEW " &"] = gf["std::basic_string_view<char>"];
#endif
gf["std::wstring"] = (cf_t)+[](cdims_t) { return new STLWStringConverter{}; };
gf[WSTRING1] = gf["std::wstring"];
Expand Down
10 changes: 5 additions & 5 deletions src/Executors.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>"] = (ef_t)+[](cdims_t) { static STLStringExecutor e{}; return &e; };
gf["std::basic_string<char>&"] = (ef_t)+[](cdims_t) { return new STLStringRefExecutor{}; };
gf["std::basic_string<wchar_t>"] = (ef_t)+[](cdims_t) { static STLWStringExecutor e{}; return &e; };
gf[WSTRING1] = gf["std::basic_string<wchar_t>"];
gf[WSTRING2] = gf["std::basic_string<wchar_t>"];
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*"];
Expand Down
2 changes: 1 addition & 1 deletion src/Pythonize.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>") { // 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);
Expand Down

0 comments on commit 0074db0

Please sign in to comment.