mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 02:45:22 +00:00
THRIFT-5417 Fix Lua compiler omitting default values in Lua service functions
Client: Lua Patch: Jeffrey Han This closes #2394
This commit is contained in:
parent
8101302c56
commit
c54cfcb8d2
@ -593,7 +593,21 @@ void t_lua_generator::generate_service_client(ostream& out, t_service* tservice)
|
|||||||
vector<t_field*>::const_iterator fld_iter;
|
vector<t_field*>::const_iterator fld_iter;
|
||||||
for (fld_iter = args.begin(); fld_iter != args.end(); ++fld_iter) {
|
for (fld_iter = args.begin(); fld_iter != args.end(); ++fld_iter) {
|
||||||
std::string argname = (*fld_iter)->get_name();
|
std::string argname = (*fld_iter)->get_name();
|
||||||
|
if ((*fld_iter)->get_value() != nullptr) {
|
||||||
|
// Insert default value for nil arguments
|
||||||
|
t_type* type = get_true_type((*fld_iter)->get_type());
|
||||||
|
indent(out) << "if " << argname << " ~= nil then" << endl;
|
||||||
|
indent_up();
|
||||||
indent(out) << "args." << argname << " = " << argname << endl;
|
indent(out) << "args." << argname << " = " << argname << endl;
|
||||||
|
indent_down();
|
||||||
|
indent(out) << "else" << endl;
|
||||||
|
indent_up();
|
||||||
|
indent(out) << "args." << argname << " = " << render_const_value(type, (*fld_iter)->get_value()) << endl;
|
||||||
|
indent_down();
|
||||||
|
indent(out) << "end" << endl;
|
||||||
|
} else {
|
||||||
|
indent(out) << "args." << argname << " = " << argname << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
indent(out) << "args:write(self.oprot)" << endl;
|
indent(out) << "args:write(self.oprot)" << endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user