Skip to content

Commit

Permalink
fix thrift parser when return type has space (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
kedixa committed May 22, 2024
1 parent e8c4736 commit 33dd3ea
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/generator/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -808,18 +808,21 @@ bool Parser::parse_service_thrift(const std::string& file_name_prefix,
if (left_b == std::string::npos)
continue;

auto aa = SGenUtil::split_skip_string(line.substr(0, left_b), ' ');
if (aa.size() != 2)
continue;
std::string idl_type;
std::string tmp = SGenUtil::strip(line.substr(0, left_b));
auto sp_pos = tmp.find_last_of(" \t");

rpc_desc.method_name = SGenUtil::strip(aa[1]);
if (rpc_desc.method_name.empty())
if (sp_pos != std::string::npos)
{
idl_type = SGenUtil::strip(tmp.substr(0, sp_pos));
rpc_desc.method_name = SGenUtil::strip(tmp.substr(sp_pos+1));
}
else
continue;

rpc_desc.request_name = rpc_desc.method_name + "Request";
rpc_desc.response_name = rpc_desc.method_name + "Response";

auto idl_type = SGenUtil::strip(aa[0]);
rpc_param param;

param.var_name = "result";
Expand Down

0 comments on commit 33dd3ea

Please sign in to comment.