Skip to content

Commit

Permalink
Replace interfaces in Dispatcher to use canonical type of method args
Browse files Browse the repository at this point in the history
  • Loading branch information
maximusron authored and vgvassilev committed Jun 11, 2024
1 parent ede3f04 commit 8a42159
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/Cppyy.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ namespace Cppyy {
CPPYY_IMPORT
std::string GetMethodArgTypeAsString(TCppMethod_t, TCppIndex_t iarg);
CPPYY_IMPORT
std::string GetMethodArgCanonTypeAsString(TCppMethod_t, TCppIndex_t iarg);
CPPYY_IMPORT
std::string GetMethodArgDefault(TCppMethod_t, TCppIndex_t iarg);
CPPYY_IMPORT
std::string GetMethodSignature(TCppMethod_t, bool show_formal_args, TCppIndex_t max_args = (TCppIndex_t)-1);
Expand Down
10 changes: 5 additions & 5 deletions src/Dispatcher.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static inline void InjectMethod(Cppyy::TCppMethod_t method, const std::string& m
Cppyy::TCppIndex_t nArgs = Cppyy::GetMethodNumArgs(method);
std::vector<std::string> argtypes; argtypes.reserve(nArgs);
for (Cppyy::TCppIndex_t i = 0; i < nArgs; ++i) {
argtypes.push_back(Cppyy::GetMethodArgTypeAsString(method, i));
argtypes.push_back(Cppyy::GetMethodArgCanonTypeAsString(method, i));
if (i != 0) code << ", ";
code << argtypes.back() << " arg" << i;
}
Expand Down Expand Up @@ -98,7 +98,7 @@ static void build_constructors(
size_t offset = (i != 0 ? arg_tots[i-1] : 0);
for (size_t j = 0; j < nArgs; ++j) {
if (i != 0 || j != 0) code << ", ";
code << Cppyy::GetMethodArgTypeAsString(cinfo.first, j) << " a" << (j+offset);
code << Cppyy::GetMethodArgCanonTypeAsString(cinfo.first, j) << " a" << (j+offset);
}
}
code << ") : ";
Expand All @@ -111,7 +111,7 @@ static void build_constructors(
for (size_t j = first; j < arg_tots[i]; ++j) {
if (j != first) code << ", ";
bool isRValue = CPyCppyy::TypeManip::compound(\
Cppyy::GetMethodArgTypeAsString(methods[i].first, j-first)) == "&&";
Cppyy::GetMethodArgCanonTypeAsString(methods[i].first, j-first)) == "&&";
if (isRValue) code << "std::move(";
code << "a" << j;
if (isRValue) code << ")";
Expand Down Expand Up @@ -264,7 +264,7 @@ bool CPyCppyy::InsertDispatcher(CPPScope* klass, PyObject* bases, PyObject* dct,
Cppyy::TCppIndex_t nreq = Cppyy::GetMethodReqArgs(method);
if (nreq == 0) default_found = true;
else if (!cctor_found && nreq == 1) {
const std::string& argtype = Cppyy::GetMethodArgTypeAsString(method, 0);
const std::string& argtype = Cppyy::GetMethodArgCanonTypeAsString(method, 0);
if (TypeManip::compound(argtype) == "&" && TypeManip::clean_type(argtype, false) == binfo.bname_scoped)
cctor_found = true;
}
Expand All @@ -289,7 +289,7 @@ bool CPyCppyy::InsertDispatcher(CPPScope* klass, PyObject* bases, PyObject* dct,
Cppyy::TCppIndex_t nArgs = Cppyy::GetMethodNumArgs(method);
for (Cppyy::TCppIndex_t i = 0; i < nArgs; ++i) {
if (i != 0) code << ", ";
code << Cppyy::GetMethodArgTypeAsString(method, i) << " arg" << i;
code << Cppyy::GetMethodArgCanonTypeAsString(method, i) << " arg" << i;
}
code << ") ";
if (Cppyy::IsConstMethod(method)) code << "const ";
Expand Down

0 comments on commit 8a42159

Please sign in to comment.