Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added test and fix for enum siblings.

  • Loading branch information...
commit 98bc14693076b3d57d1270a6583ad1512f5e20e5 1 parent daf05cf
@GeertJohan GeertJohan authored
View
10 compiler/cpp/src/generate/t_go_generator.cc
@@ -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()) {
View
2  tests/generation/Makefile
@@ -24,6 +24,7 @@ test-exercise-stamp: test-compile-stamp simple_test.go
test-compile-stamp: test-validate-stamp
cd gen-go/simple && go build -v -x .
+ cd gen-go/enumsiblings && go build -v -x .
touch $@
test-validate-stamp: test-generation-stamp
@@ -32,6 +33,7 @@ test-validate-stamp: test-generation-stamp
test-generation-stamp:
$(THRIFT) --gen go simple.thrift
+ $(THRIFT) --gen go enumsiblings.thrift
touch $@
clean:
View
12 tests/generation/enumsiblings.thrift
@@ -0,0 +1,12 @@
+namespace java thrift4go.generated.enumSiblings
+
+enum AB {
+ A,
+ B,
+}
+
+enum ABC {
+ A,
+ B,
+ C,
+}
Please sign in to comment.
Something went wrong with that request. Please try again.