THRIFT-4031: Fix invalid code generation for list of typedef'ed built-in types

Client: Go
Patch: D. Can Celasun <can@dcc.im>

This closes #1207

This commit reverts 12d430e723 which
caused invalid code to be generated for certain types.
This commit is contained in:
D. Can Celasun 2017-03-03 12:03:24 +01:00 committed by Jens Geyer
parent c89e172289
commit 431732d39e

View File

@ -178,8 +178,7 @@ public:
bool inclass = false,
bool coerceData = false,
bool inkey = false,
bool in_container = false,
bool use_true_type = false);
bool in_container = false);
void generate_deserialize_struct(std::ofstream& out,
t_struct* tstruct,
@ -2830,8 +2829,7 @@ void t_go_generator::generate_deserialize_field(ofstream& out,
bool inclass,
bool coerceData,
bool inkey,
bool in_container_value,
bool use_true_type) {
bool in_container_value) {
(void)inclass;
(void)coerceData;
t_type* orig_type = tfield->get_type();
@ -2853,10 +2851,8 @@ void t_go_generator::generate_deserialize_field(ofstream& out,
} else if (type->is_base_type() || type->is_enum()) {
if (declare) {
t_type* actual_type = use_true_type ? tfield->get_type()->get_true_type()
: tfield->get_type();
string type_name = inkey ? type_to_go_key_type(actual_type) : type_to_go_type(actual_type);
string type_name = inkey ? type_to_go_key_type(tfield->get_type())
: type_to_go_type(tfield->get_type());
out << "var " << tfield->get_name() << " " << type_name << endl;
}
@ -2918,7 +2914,7 @@ void t_go_generator::generate_deserialize_field(ofstream& out,
out << "} else {" << endl;
string wrap;
if (type->is_enum() || (orig_type->is_typedef() && !use_true_type)) {
if (type->is_enum() || orig_type->is_typedef()) {
wrap = publicize(type_name(orig_type));
} else if (((t_base_type*)type)->get_base() == t_base_type::TYPE_I8) {
wrap = "int8";
@ -3064,7 +3060,7 @@ void t_go_generator::generate_deserialize_set_element(ofstream& out,
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
felem.set_req(t_field::T_OPT_IN_REQ_OUT);
generate_deserialize_field(out, &felem, true, "", false, false, false, true, true);
generate_deserialize_field(out, &felem, true, "", false, false, false, true);
indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << endl;
}
@ -3079,7 +3075,7 @@ void t_go_generator::generate_deserialize_list_element(ofstream& out,
string elem = tmp("_elem");
t_field felem(((t_list*)tlist)->get_elem_type(), elem);
felem.set_req(t_field::T_OPT_IN_REQ_OUT);
generate_deserialize_field(out, &felem, true, "", false, false, false, true, true);
generate_deserialize_field(out, &felem, true, "", false, false, false, true);
indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << endl;
}