THRIFT-2102 constants are not referencing to correct type when included from another...
authorJens Geyer <jensg@apache.org>
Thu, 25 Jul 2013 22:23:00 +0000 (00:23 +0200)
committerJens Geyer <jensg@apache.org>
Thu, 25 Jul 2013 22:23:00 +0000 (00:23 +0200)
Patch: Remo Hertig

compiler/cpp/src/generate/t_go_generator.cc
lib/go/test/IncludesTest.thrift
test/ThriftTest.thrift

index 0f4951b..4a38885 100644 (file)
@@ -509,6 +509,7 @@ void t_go_generator::init_generator()
 
     f_consts_ <<
               go_package() <<
+              render_includes() <<              
               go_autogen_comment();
 
     f_const_values_ << endl << "func init() {" << endl;
@@ -767,7 +768,7 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co
         indent(out) << value->get_integer();
     } else if (type->is_struct() || type->is_xception()) {
         out <<
-            "&" << publicize(type->get_name()) << "{";
+            "&" << publicize(type_name(type)) << "{";
         indent_up();
         const vector<t_field*>& fields = ((t_struct*)type)->get_members();
         vector<t_field*>::const_iterator f_iter;
index 4416c09..6b68806 100644 (file)
@@ -19,6 +19,9 @@
 
 include "ThriftTest.thrift"
 
+const ThriftTest.UserId USERID = 42
+const ThriftTest.MapType MAPCONSTANT = {'hello':{}, 'goodnight':{}}
+
 struct testStruct {
   1: list<ThriftTest.Numberz> listNumbers
 }
index be000b6..500f0ea 100644 (file)
@@ -68,6 +68,8 @@ struct Bonk
   2: i32 type
 }
 
+typedef map<string,Bonk> MapType
+
 struct Bools {
   1: bool im_true,
   2: bool im_false,