Skip to content

Commit

Permalink
Update ArgSimilarityScore to static
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronj0 committed Aug 29, 2023
1 parent 4efb802 commit d274ee3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
7 changes: 4 additions & 3 deletions cling/src/core/metacling/src/TCling.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,13 @@ class TCling final : public TInterpreter {
virtual bool IsFloatingType(const void * QualTypePtr) const;
virtual bool IsPointerType(const void * QualTypePtr) const;
virtual bool IsVoidPointerType(const void * QualTypePtr) const;

// FunctionDecl interface
bool FunctionDeclId_IsMethod(DeclId_t fdeclid) const;

virtual TypeInfo_t* GetNonReferenceType(const void * QualTypePtr) const;
virtual TypeInfo_t* GetUnqualifiedType(const void * QualTypePtr) const;
virtual TypeInfo_t* GetPointerType(const void * QualTypePtr) const;

// FunctionDecl interface
bool FunctionDeclId_IsMethod(DeclId_t fdeclid) const;
};

} // namespace CppyyLegacy
Expand Down
44 changes: 22 additions & 22 deletions clingwrapper/src/clingwrapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,28 @@ std::string Cppyy::ResolveEnum(const std::string& enum_type)
return restype; // should default to some int variant
}

static Cppyy::TCppIndex_t ArgSimilarityScore(void *argqtp, void *reqqtp)
{
// This scoring is not based on any particular rules
if (gInterpreter->IsSameType(argqtp, reqqtp))
return 0; // Best match
else if ((gInterpreter->IsSignedIntegerType(argqtp) && gInterpreter->IsSignedIntegerType(reqqtp)) ||
(gInterpreter->IsUnsignedIntegerType(argqtp) && gInterpreter->IsUnsignedIntegerType(reqqtp)) ||
(gInterpreter->IsFloatingType(argqtp) && gInterpreter->IsFloatingType(reqqtp)))
return 1;
else if ((gInterpreter->IsSignedIntegerType(argqtp) && gInterpreter->IsUnsignedIntegerType(reqqtp)) ||
(gInterpreter->IsFloatingType(argqtp) && gInterpreter->IsUnsignedIntegerType(reqqtp)))
return 2;
else if ((gInterpreter->IsIntegerType(argqtp) && gInterpreter->IsIntegerType(reqqtp)))
return 3;
else if ((gInterpreter->IsIntegralType(argqtp) && gInterpreter->IsIntegralType(reqqtp)))
return 4;
else if ((gInterpreter->IsVoidPointerType(argqtp) && gInterpreter->IsPointerType(reqqtp)))
return 5;
else
return 10; // Penalize heavily for no possible match
}

Cppyy::TCppScope_t Cppyy::GetScope(const std::string& sname)
{
// First, try cache
Expand Down Expand Up @@ -1742,28 +1764,6 @@ Cppyy::TCppIndex_t Cppyy::CompareMethodArgType(TCppMethod_t method, TCppIndex_t
return INT_MAX; // Method is not valid
}

Cppyy::TCppIndex_t Cppyy::ArgSimilarityScore(void *argqtp, void *reqqtp)
{
// This scoring is not based on any particular rules
if (gInterpreter->IsSameType(argqtp, reqqtp))
return 0; // Best match
else if ((gInterpreter->IsSignedIntegerType(argqtp) && gInterpreter->IsSignedIntegerType(reqqtp)) ||
(gInterpreter->IsUnsignedIntegerType(argqtp) && gInterpreter->IsUnsignedIntegerType(reqqtp)) ||
(gInterpreter->IsFloatingType(argqtp) && gInterpreter->IsFloatingType(reqqtp)))
return 1;
else if ((gInterpreter->IsSignedIntegerType(argqtp) && gInterpreter->IsUnsignedIntegerType(reqqtp)) ||
(gInterpreter->IsFloatingType(argqtp) && gInterpreter->IsUnsignedIntegerType(reqqtp)))
return 2;
else if ((gInterpreter->IsIntegerType(argqtp) && gInterpreter->IsIntegerType(reqqtp)))
return 3;
else if ((gInterpreter->IsIntegralType(argqtp) && gInterpreter->IsIntegralType(reqqtp)))
return 4;
else if ((gInterpreter->IsVoidPointerType(argqtp) && gInterpreter->IsPointerType(reqqtp)))
return 5;
else
return 10; // Penalize heavily for no possible match
}

std::string Cppyy::GetMethodArgDefault(TCppMethod_t method, TCppIndex_t iarg)
{
if (method) {
Expand Down
2 changes: 0 additions & 2 deletions clingwrapper/src/cpp_cppyy.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ namespace Cppyy {
RPY_EXPORTED
TCppIndex_t CompareMethodArgType(TCppMethod_t, TCppIndex_t iarg, const std::string &req_type);
RPY_EXPORTED
TCppIndex_t ArgSimilarityScore(void *argqtp, void *reqqtp);
RPY_EXPORTED
std::string GetMethodArgDefault(TCppMethod_t, TCppIndex_t iarg);
RPY_EXPORTED
std::string GetMethodSignature(TCppMethod_t, bool show_formalargs, TCppIndex_t maxargs = (TCppIndex_t)-1);
Expand Down

0 comments on commit d274ee3

Please sign in to comment.