Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Enum siblings value names #56

Merged
merged 2 commits into from Nov 18, 2012
Jump to file or symbol
Failed to load files and symbols.
+143 −143
Split
@@ -615,17 +615,17 @@ void t_go_generator::generate_enum(t_enum* tenum)
string iter_std_name(escape_string((*c_iter)->get_name()));
string iter_name((*c_iter)->get_name());
f_types_ <<
- indent() << " " << iter_name << ' ' << tenum_name << " = " << value << endl;
+ indent() << " " << tenum_name << "_" << iter_name << ' ' << tenum_name << " = " << value << endl;
// Dictionaries to/from string names of enums
to_string_mapping <<
- indent() << " case " << iter_name << ": return \"" << iter_std_name << "\"" << endl;
+ indent() << " case " << tenum_name << "_" << iter_name << ": return \"" << tenum_name << "_" << iter_std_name << "\"" << endl;
if (iter_std_name != escape_string(iter_name)) {
from_string_mapping <<
- indent() << " case \"" << iter_std_name << "\", \"" << escape_string(iter_name) << "\": return " << iter_name << endl;
+ indent() << " case \"" << tenum_name << "_" << iter_std_name << "\", \"" << escape_string(iter_name) << "\": return " << tenum_name << "_" << iter_name << endl;
} else {
from_string_mapping <<
- indent() << " case \"" << iter_std_name << "\": return " << iter_name << endl;
+ indent() << " case \"" << tenum_name << "_" << iter_std_name << "\": return " << tenum_name << "_" << iter_name << endl;
}
}
@@ -654,7 +654,7 @@ void t_go_generator::generate_enum(t_enum* tenum)
void t_go_generator::generate_const(t_const* tconst)
{
t_type* type = tconst->get_type();
- string name = publicize(tconst->get_name());
+ string name = publicize(type->get_name()) + "_" + publicize(tconst->get_name());
t_const_value* value = tconst->get_value();
if (type->is_base_type() || type->is_enum()) {

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1,22 +1,22 @@
namespace java thrift4go.generated
enum UndefinedValues {
- UndefinedOne,
- UndefinedTwo,
- UndefinedThree,
+ One,
+ Two,
+ Three,
}
enum DefinedValues {
- DefinedOne = 1,
- DefinedTwo = 2,
- DefinedThree = 3,
+ One = 1,
+ Two = 2,
+ Three = 3,
}
enum HeterogeneousValues {
- HeterogeneousOne,
- HeterogeneousTwo = 2,
- HeterogeneousThree,
- HeterogeneousFour = 4,
+ One,
+ Two = 2,
+ Three,
+ Four = 4,
}
struct ContainerOfEnums {
@@ -26,9 +26,9 @@ struct ContainerOfEnums {
4: optional UndefinedValues optional_fourth,
5: optional DefinedValues optional_fifth,
6: optional HeterogeneousValues optional_sixth,
- 7: optional UndefinedValues default_seventh = UndefinedValues.UndefinedOne,
- 8: optional DefinedValues default_eighth = DefinedValues.DefinedOne,
- 9: optional HeterogeneousValues default_nineth = HeterogeneousValues.HeterogeneousOne,
+ 7: optional UndefinedValues default_seventh = UndefinedValues.One,
+ 8: optional DefinedValues default_eighth = DefinedValues.One,
+ 9: optional HeterogeneousValues default_nineth = HeterogeneousValues.One,
}
service ContainerOfEnumsTestService {
Oops, something went wrong.