Skip to content

Commit 28999b3

Browse files
fix: non-type template (enum) instantiation for templ func (#175)
1 parent a415ec5 commit 28999b3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

clingwrapper/src/clingwrapper.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,19 @@ bool split_comma_saparated_types(const std::string& name,
605605
return true;
606606
}
607607

608+
Cpp::TCppScope_t GetEnumFromCompleteName(const std::string &name) {
609+
std::string delim = "::";
610+
size_t start = 0;
611+
size_t end = name.find(delim);
612+
Cpp::TCppScope_t curr_scope = 0;
613+
while (end != std::string::npos) {
614+
curr_scope = Cpp::GetNamed(name.substr(start, end - start), curr_scope);
615+
start = end + delim.length();
616+
end = name.find(delim, start);
617+
}
618+
return Cpp::GetNamed(name.substr(start, end), curr_scope);
619+
}
620+
608621
// returns true if no new type was added.
609622
bool Cppyy::AppendTypesSlow(const std::string& name,
610623
std::vector<Cpp::TemplateArgInfo>& types, Cppyy::TCppScope_t parent) {
@@ -668,6 +681,10 @@ bool Cppyy::AppendTypesSlow(const std::string& name,
668681

669682
if (is_integral(i))
670683
integral_value = strdup(i.c_str());
684+
if (Cpp::TCppScope_t scope = GetEnumFromCompleteName(i))
685+
if (Cpp::IsEnumConstant(scope))
686+
integral_value =
687+
strdup(std::to_string(Cpp::GetEnumConstantValue(scope)).c_str());
671688
types.emplace_back(type, integral_value);
672689
}
673690
return false;

0 commit comments

Comments
 (0)