@@ -565,13 +565,31 @@ Cppyy::TCppScope_t Cppyy::GetUnderlyingScope(TCppScope_t scope)
565565Cppyy::TCppScope_t Cppyy::GetScope (const std::string& name,
566566 TCppScope_t parent_scope)
567567{
568- # ifndef NDEBUG
569- if (name. find ( " :: " ) != std::string::npos)
570- throw std::runtime_error ( " Calling Cppyy::GetScope with qualified name ' "
571- + name + " ' \n " );
572- # endif // NDEBUG
568+ if (Cppyy::TCppScope_t scope = Cpp::GetScope (name, parent_scope))
569+ return scope;
570+ if (!parent_scope || parent_scope == Cpp::GetGlobalScope ())
571+ if (Cppyy::TCppScope_t scope = Cpp::GetScopeFromCompleteName ( name))
572+ return scope;
573573
574- return Cpp::GetScope (name, parent_scope);
574+ if (name.find (' <' ) != std::string::npos) {
575+ // Templated Type; May need instantiation
576+ size_t start = name.find (' <' );
577+ size_t end = name.rfind (' >' );
578+ std::string params = name.substr (start + 1 , end - start - 1 );
579+
580+ std::string pure_name = name.substr (0 , start);
581+ Cppyy::TCppScope_t scope = Cpp::GetScope (pure_name, parent_scope);
582+ if (!scope && (!parent_scope || parent_scope == Cpp::GetGlobalScope ()))
583+ scope = Cpp::GetScopeFromCompleteName (pure_name);
584+
585+ if (Cppyy::IsTemplate (scope)) {
586+ std::vector<Cpp::TemplateArgInfo> templ_params;
587+ if (!Cppyy::AppendTypesSlow (params, templ_params))
588+ return Cpp::InstantiateTemplate (scope, templ_params.data (),
589+ templ_params.size ());
590+ }
591+ }
592+ return nullptr ;
575593}
576594
577595Cppyy::TCppScope_t Cppyy::GetFullScope (const std::string& name)
0 commit comments