Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[slang-reflect] Fix more namespace issues and header prints #848

Merged
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
2 changes: 1 addition & 1 deletion tools/reflect/include/CppEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class HppFile {
auto headersTransform = std::views::transform(headers, [](const auto& h) {
return fmt::format("#include \"{}.h\"", h);
});
return fmt::format("// {}\n#pragma once\n\n{}{}\n\n{}", fileName,
return fmt::format("// {}\n#pragma once\n\n{}\n{}\n\n{}", fileName,
fmt::join(includesTransform, "\n"), fmt::join(headersTransform, "\n"),
hpp.str());
}
Expand Down
25 changes: 20 additions & 5 deletions tools/reflect/src/SvStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ void SvStruct::toCpp(HppFile& hppFile, std::string_view _namespace, const SvAlia
const auto& value = values[i];

if (member.second.isStructOrEnum())
hppFile.addWithIndent(
fmt::format("{} = {}({});\n", member.first, member.second.toString(), value));
if (_namespace != member.second._namespace)
hppFile.addWithIndent(fmt::format("{} = {}::{}({});\n", member.first,
member.second._namespace,
member.second.toString(), value));
else
hppFile.addWithIndent(fmt::format("{} = {}({});\n", member.first,
member.second.toString(), value));
else
hppFile.addWithIndent(fmt::format("{} = {};\n", member.first, value));
}
Expand All @@ -132,8 +137,13 @@ void SvStruct::toCpp(HppFile& hppFile, std::string_view _namespace, const SvAlia
member.first);

if (member.second.isStructOrEnum())
hppFile.addWithIndent(
fmt::format("{} = {}({});\n", member.first, member.second.toString(), value));
if (_namespace != member.second._namespace)
hppFile.addWithIndent(fmt::format("{} = {}::{}({});\n", member.first,
member.second._namespace,
member.second.toString(), value));
else
hppFile.addWithIndent(fmt::format("{} = {}({});\n", member.first,
member.second.toString(), value));
else
hppFile.addWithIndent(fmt::format("{} = {};\n", member.first, value));
}
Expand Down Expand Up @@ -257,7 +267,12 @@ void SvStruct::toCpp(HppFile& hppFile, std::string_view _namespace, const SvAlia
}

if (member.second.isStructOrEnum())
hppFile.addWithIndent(fmt::format("return {}({});\n", member.second.toString(), value));
if (_namespace != member.second._namespace)
hppFile.addWithIndent(fmt::format("return {}::{}({});\n", member.second._namespace,
member.second.toString(), value));
else
hppFile.addWithIndent(
fmt::format("return {}({});\n", member.second.toString(), value));
else
hppFile.addWithIndent(fmt::format("return {};\n", value));

Expand Down