From 946cd7ad34b49d08f6d797ae0224a0ea29361b78 Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Wed, 30 Oct 2024 14:15:54 +0000 Subject: [PATCH] refactored --- clingwrapper/src/clingwrapper.cxx | 35 ++++++++++--------------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/clingwrapper/src/clingwrapper.cxx b/clingwrapper/src/clingwrapper.cxx index bc430091..4a880c2f 100644 --- a/clingwrapper/src/clingwrapper.cxx +++ b/clingwrapper/src/clingwrapper.cxx @@ -1412,32 +1412,19 @@ 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) { - 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(); - } - std::ostringstream sig; sig << "("; - size_t args = Cpp::GetFunctionNumArgs(method); - for (size_t i = 0; i < args; i++) { - sig << Cppyy::GetMethodArgTypeAsString(method, i); - if (i != args -1) - 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 && Cppyy::IsTemplatedMethod(method)) { + std::string argname = Cppyy::GetMethodArgName(method, iarg); + if (!argname.empty()) sig << " " << argname; + std::string defvalue = Cppyy::GetMethodArgDefault(method, iarg); + if (!defvalue.empty()) sig << " = " << defvalue; + } + if (iarg != nArgs-1) sig << (show_formal_args ? ", " : ","); } sig << ")"; return sig.str();