From 7c676fbe051710cbb269ddf4f8a37c9ad87b344c Mon Sep 17 00:00:00 2001 From: maximusron Date: Fri, 12 Jul 2024 14:36:15 +0200 Subject: [PATCH] Enable GetMethodSignature for template functions(cling) --- clingwrapper/src/clingwrapper.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/clingwrapper/src/clingwrapper.cxx b/clingwrapper/src/clingwrapper.cxx index 8c22066c..fa4c6238 100644 --- a/clingwrapper/src/clingwrapper.cxx +++ b/clingwrapper/src/clingwrapper.cxx @@ -1412,8 +1412,26 @@ std::string Cppyy::GetMethodArgDefault(TCppMethod_t method, TCppIndex_t iarg) std::string Cppyy::GetMethodSignature(TCppMethod_t method, bool show_formal_args, TCppIndex_t max_args) { - // FIXME : Doesn't work for template functions as it does in cling - return Cpp::GetFunctionSignature(method); + if (Cppyy::IsTemplatedMethod(method)) { + std::ostringstream sig; + sig << "("; + int nArgs = GetMethodNumArgs(method); + if (max_args != (TCppIndex_t)-1) nArgs = std::min(nArgs, (int)max_args); + for (int iarg = 0; iarg < nArgs; ++iarg) { + sig << Cppyy::GetMethodArgTypeAsString(method, iarg); + if (show_formal_args) { + const char* argname = Cppyy::GetMethodArgName(method, iarg).c_str(); + if (argname && argname[0] != '\0') sig << " " << argname; + const char* defvalue = Cppyy::GetMethodArgDefault(method, iarg).c_str(); + if (defvalue && defvalue[0] != '\0') sig << " = " << defvalue; + } + if (iarg != nArgs-1) sig << (show_formal_args ? ", " : ","); + } + sig << ")"; + return sig.str(); + } + + else return Cpp::GetFunctionSignature(method); } std::string Cppyy::GetMethodPrototype(TCppMethod_t method, bool show_formal_args)