Skip to content

Commit 44426de

Browse files
committed
Enable GetMethodSignature for template functions(cling)
1 parent 821d088 commit 44426de

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

clingwrapper/src/clingwrapper.cxx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,8 +1412,26 @@ 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-
// FIXME : Doesn't work for template functions as it does in cling
1416-
return Cpp::GetFunctionSignature(method);
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 ? ", " : ",");
1429+
}
1430+
sig << ")";
1431+
return sig.str();
1432+
}
1433+
1434+
else return Cpp::GetFunctionSignature(method);
14171435
}
14181436

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

0 commit comments

Comments
 (0)