@@ -565,13 +565,32 @@ Cppyy::TCppScope_t Cppyy::GetUnderlyingScope(TCppScope_t scope)
565
565
Cppyy::TCppScope_t Cppyy::GetScope (const std::string& name,
566
566
TCppScope_t parent_scope)
567
567
{
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;
573
573
574
- return Cpp::GetScope (name, parent_scope);
574
+ // FIXME: avoid string parsing here
575
+ if (name.find (' <' ) != std::string::npos) {
576
+ // Templated Type; May need instantiation
577
+ size_t start = name.find (' <' );
578
+ size_t end = name.rfind (' >' );
579
+ std::string params = name.substr (start + 1 , end - start - 1 );
580
+
581
+ std::string pure_name = name.substr (0 , start);
582
+ Cppyy::TCppScope_t scope = Cpp::GetScope (pure_name, parent_scope);
583
+ if (!scope && (!parent_scope || parent_scope == Cpp::GetGlobalScope ()))
584
+ scope = Cpp::GetScopeFromCompleteName (pure_name);
585
+
586
+ if (Cppyy::IsTemplate (scope)) {
587
+ std::vector<Cpp::TemplateArgInfo> templ_params;
588
+ if (!Cppyy::AppendTypesSlow (params, templ_params))
589
+ return Cpp::InstantiateTemplate (scope, templ_params.data (),
590
+ templ_params.size ());
591
+ }
592
+ }
593
+ return nullptr ;
575
594
}
576
595
577
596
Cppyy::TCppScope_t Cppyy::GetFullScope (const std::string& name)
0 commit comments