Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/cpyrt/CPPMethod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,21 @@ int cpyrt::CPPMethod::GetPriority() {

// prefer more derived classes
const std::string& clean_name = TypeManip::clean_type(aname, false);
interop::TCppScope_t scope = interop::GetScope(clean_name);
interop::TCppScope_t scope = nullptr;
if (clean_name.find('<') != std::string::npos &&
clean_name.find("initializer_list") == std::string::npos) {
// Resolving a template name from its spelling declares new code in
// the interpreter on every call, so take the class from the argument
// type instead, and force its definition like GetScope() does.
// GetScope() deliberately resolves std::initializer_list<T> as
// std::vector<T>, which the ranking relies on, so those still go
// through GetScope().
scope = interop::GetScopeFromType(interop::GetUnderlyingType(
interop::GetMethodArgType(fMethod, iarg)));
if (scope)
interop::IsComplete(scope);
} else
scope = interop::GetScope(clean_name);
if (scope)
priority += static_cast<int>(interop::GetNumBasesLongestBranch(scope));

Expand Down
2 changes: 2 additions & 0 deletions src/interop/cppjit_interop.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ std::string ResolveName(const std::string& cppitem_name);
RPY_EXPORTED
TCppType_t ResolveType(TCppType_t cppitem_name);
RPY_EXPORTED
TCppType_t GetUnderlyingType(TCppType_t type);
RPY_EXPORTED
TCppType_t ResolveEnumReferenceType(TCppType_t type);
RPY_EXPORTED
TCppType_t ResolveEnumPointerType(TCppType_t type);
Expand Down
5 changes: 5 additions & 0 deletions src/interop/interop_wrapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,11 @@ interop::TCppScope_t interop::GetScopeFromType(TCppType_t type) {
return Cpp::GetScopeFromType(type);
}

interop::TCppType_t interop::GetUnderlyingType(TCppType_t type) {
std::lock_guard<std::recursive_mutex> Lock(InterOpMutex);
return Cpp::GetUnderlyingType(type);
}

interop::TCppType_t interop::GetTypeFromScope(TCppScope_t klass) {
std::lock_guard<std::recursive_mutex> Lock(InterOpMutex);
return Cpp::GetTypeFromScope(klass);
Expand Down
Loading