Skip to content

Commit fe544af

Browse files
committed
Enable GetMethodSignature for template functions(cling)
1 parent ad880c4 commit fe544af

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

clingwrapper/src/clingwrapper.cxx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ std::vector<Cppyy::TCppScope_t> Cppyy::GetUsingNamespaces(TCppScope_t scope)
11681168
std::string Cppyy::GetFinalName(TCppType_t klass)
11691169
{
11701170
return Cpp::GetCompleteName(klass);
1171-
}
1171+
}
11721172

11731173
std::string Cppyy::GetScopedFinalName(TCppType_t klass)
11741174
{
@@ -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)