Skip to content

Commit 99f22de

Browse files
Vipul-Cariappavgvassilev
authored andcommitted
refactored Cppyy::GetMethodSignature
1 parent 44426de commit 99f22de

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

clingwrapper/src/clingwrapper.cxx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,26 +1412,22 @@ std::string Cppyy::GetMethodArgDefault(TCppMethod_t method, TCppIndex_t iarg)
14121412

14131413
std::string Cppyy::GetMethodSignature(TCppMethod_t method, bool show_formal_args, TCppIndex_t max_args)
14141414
{
1415-
if (Cppyy::IsTemplatedMethod(method)) {
1416-
std::ostringstream sig;
1417-
sig << "(";
1418-
int nArgs = GetMethodNumArgs(method);
1419-
if (max_args != (TCppIndex_t)-1) nArgs = std::min(nArgs, (int)max_args);
1420-
for (int iarg = 0; iarg < nArgs; ++iarg) {
1421-
sig << Cppyy::GetMethodArgTypeAsString(method, iarg);
1422-
if (show_formal_args) {
1423-
const char* argname = Cppyy::GetMethodArgName(method, iarg).c_str();
1424-
if (argname && argname[0] != '\0') sig << " " << argname;
1425-
const char* defvalue = Cppyy::GetMethodArgDefault(method, iarg).c_str();
1426-
if (defvalue && defvalue[0] != '\0') sig << " = " << defvalue;
1427-
}
1428-
if (iarg != nArgs-1) sig << (show_formal_args ? ", " : ",");
1415+
std::ostringstream sig;
1416+
sig << "(";
1417+
int nArgs = GetMethodNumArgs(method);
1418+
if (max_args != (TCppIndex_t)-1) nArgs = std::min(nArgs, (int)max_args);
1419+
for (int iarg = 0; iarg < nArgs; ++iarg) {
1420+
sig << Cppyy::GetMethodArgTypeAsString(method, iarg);
1421+
if (show_formal_args && Cppyy::IsTemplatedMethod(method)) {
1422+
std::string argname = Cppyy::GetMethodArgName(method, iarg);
1423+
if (!argname.empty()) sig << " " << argname;
1424+
std::string defvalue = Cppyy::GetMethodArgDefault(method, iarg);
1425+
if (!defvalue.empty()) sig << " = " << defvalue;
14291426
}
1430-
sig << ")";
1431-
return sig.str();
1427+
if (iarg != nArgs-1) sig << (show_formal_args ? ", " : ",");
14321428
}
1433-
1434-
else return Cpp::GetFunctionSignature(method);
1429+
sig << ")";
1430+
return sig.str();
14351431
}
14361432

14371433
std::string Cppyy::GetMethodPrototype(TCppMethod_t method, bool show_formal_args)

0 commit comments

Comments
 (0)