THRIFT-2702 empty enums lead to invalid code

Client: Delphi
Patch: Jens Geyer
This commit is contained in:
Jens Geyer 2014-09-12 00:18:31 +02:00
parent 86b309cde0
commit 2de7e19899

View File

@ -836,15 +836,19 @@ void t_delphi_generator::generate_enum(t_enum* tenum) {
type_name(tenum,true,true) << " = " << "(" << endl; type_name(tenum,true,true) << " = " << "(" << endl;
indent_up(); indent_up();
vector<t_enum_value*> constants = tenum->get_constants(); vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter; if (constants.empty()) {
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { indent(s_enum) << "dummy = 0 // empty enums are not allowed";
int value = (*c_iter)->get_value(); } else {
if (c_iter != constants.begin()) { vector<t_enum_value*>::iterator c_iter;
s_enum << ","; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
s_enum << endl; int value = (*c_iter)->get_value();
if (c_iter != constants.begin()) {
s_enum << ",";
s_enum << endl;
}
generate_delphi_doc(s_enum, *c_iter);
indent(s_enum) << normalize_name((*c_iter)->get_name()) << " = " << value;
} }
generate_delphi_doc(s_enum, *c_iter);
indent(s_enum) << normalize_name((*c_iter)->get_name()) << " = " << value;
} }
s_enum << endl; s_enum << endl;
indent_down(); indent_down();