From c49f4699f15daf8279cee457c5c6c520debec5bf Mon Sep 17 00:00:00 2001 From: Aaron Jomy Date: Fri, 8 Nov 2024 13:22:55 +0100 Subject: [PATCH] Add ArgMatchScore interface for numba extension --- clingwrapper/src/clingwrapper.cxx | 29 +++++++++++++++++++++++++++++ clingwrapper/src/cpp_cppyy.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/clingwrapper/src/clingwrapper.cxx b/clingwrapper/src/clingwrapper.cxx index 7c6e682a..893f03dd 100644 --- a/clingwrapper/src/clingwrapper.cxx +++ b/clingwrapper/src/clingwrapper.cxx @@ -1461,6 +1461,35 @@ std::string Cppyy::GetMethodArgDefault(TCppMethod_t method, TCppIndex_t iarg) return Cpp::GetFunctionArgDefault(method, iarg); } +Cppyy::TCppIndex_t Cppyy::CompareMethodArgType(TCppMethod_t method, TCppIndex_t iarg, const std::string &req_type) +{ + // if (method) { + // TFunction* f = m2f(method); + // TMethodArg* arg = (TMethodArg *)f->GetListOfMethodArgs()->At((int)iarg); + // void *argqtp = gInterpreter->TypeInfo_QualTypePtr(arg->GetTypeInfo()); + + // TypeInfo_t *reqti = gInterpreter->TypeInfo_Factory(req_type.c_str()); + // void *reqqtp = gInterpreter->TypeInfo_QualTypePtr(reqti); + + // if (ArgSimilarityScore(argqtp, reqqtp) < 10) { + // return ArgSimilarityScore(argqtp, reqqtp); + // } + // else { // Match using underlying types + // if(gInterpreter->IsPointerType(argqtp)) + // argqtp = gInterpreter->TypeInfo_QualTypePtr(gInterpreter->GetPointerType(argqtp)); + + // // Handles reference types and strips qualifiers + // TypeInfo_t *arg_ul = gInterpreter->GetNonReferenceType(argqtp); + // TypeInfo_t *req_ul = gInterpreter->GetNonReferenceType(reqqtp); + // argqtp = gInterpreter->TypeInfo_QualTypePtr(gInterpreter->GetUnqualifiedType(gInterpreter->TypeInfo_QualTypePtr(arg_ul))); + // reqqtp = gInterpreter->TypeInfo_QualTypePtr(gInterpreter->GetUnqualifiedType(gInterpreter->TypeInfo_QualTypePtr(req_ul))); + + // return ArgSimilarityScore(argqtp, reqqtp); + // } + // } + return 0; // Method is not valid +} + std::string Cppyy::GetMethodSignature(TCppMethod_t method, bool show_formal_args, TCppIndex_t max_args) { std::ostringstream sig; diff --git a/clingwrapper/src/cpp_cppyy.h b/clingwrapper/src/cpp_cppyy.h index 911e6a63..1dad4cac 100644 --- a/clingwrapper/src/cpp_cppyy.h +++ b/clingwrapper/src/cpp_cppyy.h @@ -284,6 +284,8 @@ namespace Cppyy { RPY_EXPORTED TCppType_t GetMethodArgType(TCppMethod_t, TCppIndex_t iarg); RPY_EXPORTED + TCppIndex_t CompareMethodArgType(TCppMethod_t, TCppIndex_t iarg, const std::string &req_type); + RPY_EXPORTED std::string GetMethodArgTypeAsString(TCppMethod_t method, TCppIndex_t iarg); RPY_EXPORTED std::string GetMethodArgCanonTypeAsString(TCppMethod_t method, TCppIndex_t iarg);