Skip to content

Commit

Permalink
[slang-reflect] Provide type namespace if necessary in get_* functions
Browse files Browse the repository at this point in the history
When returning a non-primitive type from a get_* function, we were
assuming that the type was part of the current namespace, which is not
always true. This commit fixes this issue by adding the namespace
when necessary.
  • Loading branch information
Sustrak committed Nov 3, 2023
1 parent 5b206ce commit 9a4fa3e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tools/reflect/src/SvStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,15 @@ void SvStruct::toCpp(HppFile& hppFile, std::string_view _namespace, const SvAlia

//* STATIC GET FUNCTIONS *//
for (const auto& member : members) {
hppFile.addWithIndent(fmt::format("static {} get_{} (const {}& __data) {{\n",
member.second.toString(), member.first, cppTypeStr));
if (member.second.isStructOrEnum() && _namespace != member.second._namespace) {
hppFile.addWithIndent(fmt::format("static {}::{} get_{} (const {}& __data) {{\n",
member.second._namespace, member.second.toString(),
member.first, cppTypeStr));
}
else {
hppFile.addWithIndent(fmt::format("static {} get_{} (const {}& __data) {{\n",
member.second.toString(), member.first, cppTypeStr));
}
hppFile.increaseIndent();
std::string value;
if (cppType == CppType::SC_BV) {
Expand Down

0 comments on commit 9a4fa3e

Please sign in to comment.