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

Fix thrift 'typedef' nested namespace bug. #393

Merged
merged 1 commit into from
Jun 25, 2024
Merged
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
13 changes: 9 additions & 4 deletions src/generator/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ bool Parser::parse_thrift_typedef(const std::string& line,
std::string& new_type_name,
idl_info&info)
{
std::vector<std::string> elems = SGenUtil::split_by_space(line);
std::string str = line.substr(0, line.find_first_of(';'));
std::vector<std::string> elems = SGenUtil::split_by_space(str);

if (elems.size() >= 3 && elems[0] == "typedef")
{
Expand Down Expand Up @@ -1278,10 +1279,14 @@ std::string type_prefix_to_namespace(const std::string& type_name,
return type_name;
}

if (include->package_name.size() > 0)
return include->package_name[0]+"::"+real_type;
std::string namespc;
for (const auto& name : include->package_name)
namespc += name+"::";

return "::"+real_type;
if (namespc.empty())
namespc = "::";

return namespc+real_type;
}

Descriptor *search_cur_file_descriptor(idl_info& info,
Expand Down