You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2016/06/06 21:15:10 UTC

[2/2] thrift git commit: THRIFT-3834 Erlang namespacing and exception metadata Client: Erlang Patch: Steve Cohen

THRIFT-3834 Erlang namespacing and exception metadata
Client: Erlang
Patch: Steve Cohen


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/c8deed8c
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/c8deed8c
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/c8deed8c

Branch: refs/heads/master
Commit: c8deed8cba62dce0ce816afef38f708ce49d0a61
Parents: cee82ae
Author: Steve Cohen <st...@pinterest.com>
Authored: Mon Jun 6 23:09:10 2016 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Mon Jun 6 23:10:10 2016 +0200

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_erl_generator.cc |  26 ++-
 lib/erl/test/thrift_test_test.erl            | 202 +++++++++++-----------
 test/erl/src/test_client.erl                 |  32 ++--
 test/erl/src/test_thrift_server.erl          |  58 +++----
 4 files changed, 165 insertions(+), 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/c8deed8c/compiler/cpp/src/generate/t_erl_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_erl_generator.cc b/compiler/cpp/src/generate/t_erl_generator.cc
index 0e7f7f1..9118b48 100644
--- a/compiler/cpp/src/generate/t_erl_generator.cc
+++ b/compiler/cpp/src/generate/t_erl_generator.cc
@@ -56,6 +56,8 @@ public:
     legacy_names_ = false;
     maps_ = false;
     otp16_ = false;
+    erl_namespace_ = program->get_namespace("erl");
+
     for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) {
       if( iter->first.compare("legacynames") == 0) {
         legacy_names_ = true;
@@ -64,7 +66,7 @@ public:
       } else if( iter->first.compare("otp16") == 0) {
         otp16_ = true;
       } else {
-        throw "unknown option erl:" + iter->first; 
+        throw "unknown option erl:" + iter->first;
       }
     }
 
@@ -180,6 +182,8 @@ private:
   /* if true use non-namespaced dict and set instead of dict:dict and sets:set */
   bool otp16_;
 
+  /* A namespace that gets appended to our generated structs. */
+  std::string erl_namespace_;
   /**
    * add function to export list
    */
@@ -227,6 +231,7 @@ private:
    */
   std::vector<std::string> v_struct_names_;
   std::vector<std::string> v_enum_names_;
+  std::vector<std::string> v_exception_names_;
   std::vector<t_enum*> v_enums_;
 };
 
@@ -339,6 +344,7 @@ void t_erl_generator::close_generator() {
   export_types_string("enum_info", 1);
   export_types_string("enum_names", 0);
   export_types_string("struct_names", 0);
+  export_types_string("exception_names", 0);
 
   f_types_file_ << "-export([" << export_types_lines_.str() << "])." << endl << endl;
 
@@ -351,6 +357,7 @@ void t_erl_generator::close_generator() {
   generate_type_metadata("struct_names", v_struct_names_);
   generate_enum_metadata();
   generate_type_metadata("enum_names", v_enum_names_);
+  generate_type_metadata("exception_names", v_exception_names_);
 
   hrl_footer(f_types_hrl_file_, string("BOGUS"));
 
@@ -369,7 +376,7 @@ void t_erl_generator::generate_type_metadata(std::string function_name, vector<s
 
 
   for(size_t i=0; i < num_structs; i++) {
-    f_types_file_ << atomify(names.at(i));
+    f_types_file_ << names.at(i);
 
     if (i < num_structs - 1) {
       f_types_file_ << ", ";
@@ -400,7 +407,7 @@ void t_erl_generator::generate_enum(t_enum* tenum) {
   vector<t_enum_value*>::iterator c_iter;
 
   v_enums_.push_back(tenum);
-  v_enum_names_.push_back(tenum->get_name());
+  v_enum_names_.push_back(atomify(tenum->get_name()));
 
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
@@ -497,7 +504,7 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
     indent(out) << value->get_integer();
 
   } else if (type->is_struct() || type->is_xception()) {
-    out << "#" << atomify(type->get_name()) << "{";
+    out << "#" << type_name(type) << "{";
     const vector<t_field*>& fields = ((t_struct*)type)->get_members();
     vector<t_field*>::const_iterator f_iter;
     const map<t_const_value*, t_const_value*>& val = value->get_map();
@@ -582,7 +589,7 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
 string t_erl_generator::render_default_value(t_field* field) {
   t_type* type = field->get_type();
   if (type->is_struct() || type->is_xception()) {
-    return "#" + atomify(type->get_name()) + "{}";
+    return "#" + type_name(type) + "{}";
   } else if (type->is_map()) {
     if (maps_) {
       return "#{}";
@@ -620,7 +627,7 @@ string t_erl_generator::render_member_type(t_field* field) {
   } else if (type->is_enum()) {
     return "integer()";
   } else if (type->is_struct() || type->is_xception()) {
-    return atomify(type->get_name()) + "()";
+    return type_name(type) + "()";
   } else if (type->is_map()) {
     if (maps_) {
       return "#{}";
@@ -657,7 +664,7 @@ string t_erl_generator::render_member_requiredness(t_field* field) {
  * Generates a struct
  */
 void t_erl_generator::generate_struct(t_struct* tstruct) {
-  v_struct_names_.push_back(tstruct->get_name());
+  v_struct_names_.push_back(type_name(tstruct));
   generate_erl_struct(tstruct, false);
 }
 
@@ -668,6 +675,7 @@ void t_erl_generator::generate_struct(t_struct* tstruct) {
  * @param txception The struct definition
  */
 void t_erl_generator::generate_xception(t_struct* txception) {
+  v_exception_names_.push_back(type_name(txception));
   generate_erl_struct(txception, true);
 }
 
@@ -1009,6 +1017,10 @@ string t_erl_generator::argument_list(t_struct* tstruct) {
 
 string t_erl_generator::type_name(t_type* ttype) {
   string prefix = "";
+  if (erl_namespace_.length() > 0) {
+    prefix = erl_namespace_ + ".";
+  }
+
   string name = ttype->get_name();
 
   if (ttype->is_struct() || ttype->is_xception() || ttype->is_service()) {

http://git-wip-us.apache.org/repos/asf/thrift/blob/c8deed8c/lib/erl/test/thrift_test_test.erl
----------------------------------------------------------------------
diff --git a/lib/erl/test/thrift_test_test.erl b/lib/erl/test/thrift_test_test.erl
index e506437..ae20f31 100644
--- a/lib/erl/test/thrift_test_test.erl
+++ b/lib/erl/test/thrift_test_test.erl
@@ -33,32 +33,32 @@ constant_test_() ->
 record_generation_test_() ->
   [
     {"Bonk record", ?_assertMatch(
-      {'Bonk', _, _},
-      #'Bonk'{message=null,type=null}
+      {'thrift.test.Bonk', _, _},
+      #'thrift.test.Bonk'{message=null,type=null}
     )},
     {"Bools record", ?_assertMatch(
-      {'Bools', _, _},
-      #'Bools'{im_true=null,im_false=null}
+      {'thrift.test.Bools', _, _},
+      #'thrift.test.Bools'{im_true=null,im_false=null}
     )},
     {"Xtruct record", ?_assertMatch(
-      {'Xtruct', _, _, _, _},
-      #'Xtruct'{string_thing=null,byte_thing=null,i32_thing=null,i64_thing=null}
+      {'thrift.test.Xtruct', _, _, _, _},
+      #'thrift.test.Xtruct'{string_thing=null,byte_thing=null,i32_thing=null,i64_thing=null}
     )},
     {"Xtruct2 record", ?_assertMatch(
-      {'Xtruct2', _, _, _},
-      #'Xtruct2'{byte_thing=null,struct_thing=null,i32_thing=null}
+      {'thrift.test.Xtruct2', _, _, _},
+      #'thrift.test.Xtruct2'{byte_thing=null,struct_thing=null,i32_thing=null}
     )},
     {"Xtruct3 record", ?_assertMatch(
-      {'Xtruct3', _, _, _, _},
-      #'Xtruct3'{string_thing=null,changed=null,i32_thing=null,i64_thing=null}
+      {'thrift.test.Xtruct3', _, _, _, _},
+      #'thrift.test.Xtruct3'{string_thing=null,changed=null,i32_thing=null,i64_thing=null}
     )},
     {"Insanity record", ?_assertMatch(
-      {'Insanity', _, _},
-      #'Insanity'{userMap=null,xtructs=null}
+      {'thrift.test.Insanity', _, _},
+      #'thrift.test.Insanity'{userMap=null,xtructs=null}
     )},
     {"CrazyNesting record", ?_assertMatch(
-      {'CrazyNesting', _, _, _, _},
-      #'CrazyNesting'{
+      {'thrift.test.CrazyNesting', _, _, _, _},
+      #'thrift.test.CrazyNesting'{
         string_field=null,
         set_field=null,
         list_field=null,
@@ -66,22 +66,22 @@ record_generation_test_() ->
       }
     )},
     {"Xception record", ?_assertMatch(
-      {'Xception', _, _},
-      #'Xception'{errorCode=null,message=null}
+      {'thrift.test.Xception', _, _},
+      #'thrift.test.Xception'{errorCode=null,message=null}
     )},
     {"Xception2 record", ?_assertMatch(
-      {'Xception2', _, _},
-      #'Xception2'{errorCode=null,struct_thing=null}
+      {'thrift.test.Xception2', _, _},
+      #'thrift.test.Xception2'{errorCode=null,struct_thing=null}
     )},
-    {"EmptyStruct record", ?_assertMatch({'EmptyStruct'}, #'EmptyStruct'{})},
-    {"OneField record", ?_assertMatch({'OneField', _}, #'OneField'{field=null})},
+    {"EmptyStruct record", ?_assertMatch({'thrift.test.EmptyStruct'}, #'thrift.test.EmptyStruct'{})},
+    {"OneField record", ?_assertMatch({'thrift.test.OneField', _}, #'thrift.test.OneField'{field=null})},
     {"VersioningTestV1 record", ?_assertMatch(
-      {'VersioningTestV1', _, _, _},
-      #'VersioningTestV1'{begin_in_both=null,old_string=null,end_in_both=null}
+      {'thrift.test.VersioningTestV1', _, _, _},
+      #'thrift.test.VersioningTestV1'{begin_in_both=null,old_string=null,end_in_both=null}
     )},
     {"VersioningTestV2 record", ?_assertMatch(
-      {'VersioningTestV2', _, _, _, _, _, _, _, _, _, _, _, _},
-      #'VersioningTestV2'{
+      {'thrift.test.VersioningTestV2', _, _, _, _, _, _, _, _, _, _, _, _},
+      #'thrift.test.VersioningTestV2'{
         begin_in_both=null,
         newint=null,
         newbyte=null,
@@ -97,20 +97,20 @@ record_generation_test_() ->
       }
     )},
     {"ListTypeVersioningV1 record", ?_assertMatch(
-      {'ListTypeVersioningV1', _, _},
-      #'ListTypeVersioningV1'{myints=null,hello=null}
+      {'thrift.test.ListTypeVersioningV1', _, _},
+      #'thrift.test.ListTypeVersioningV1'{myints=null,hello=null}
     )},
     {"ListTypeVersioningV2 record", ?_assertMatch(
-      {'ListTypeVersioningV2', _, _},
-      #'ListTypeVersioningV2'{strings=null,hello=null}
+      {'thrift.test.ListTypeVersioningV2', _, _},
+      #'thrift.test.ListTypeVersioningV2'{strings=null,hello=null}
     )},
     {"GuessProtocolStruct record", ?_assertMatch(
-      {'GuessProtocolStruct', _},
-      #'GuessProtocolStruct'{map_field=null}
+      {'thrift.test.GuessProtocolStruct', _},
+      #'thrift.test.GuessProtocolStruct'{map_field=null}
     )},
     {"LargeDeltas record", ?_assertMatch(
-      {'LargeDeltas', _, _, _, _, _, _, _, _, _, _},
-      #'LargeDeltas'{
+      {'thrift.test.LargeDeltas', _, _, _, _, _, _, _, _, _, _},
+      #'thrift.test.LargeDeltas'{
         b1=null,
         b10=null,
         b100=null,
@@ -124,34 +124,34 @@ record_generation_test_() ->
       }
     )},
     {"NestedListsI32x2 record", ?_assertMatch(
-      {'NestedListsI32x2', _},
-      #'NestedListsI32x2'{integerlist=null}
+      {'thrift.test.NestedListsI32x2', _},
+      #'thrift.test.NestedListsI32x2'{integerlist=null}
     )},
     {"NestedListsI32x3 record", ?_assertMatch(
-      {'NestedListsI32x3', _},
-      #'NestedListsI32x3'{integerlist=null}
+      {'thrift.test.NestedListsI32x3', _},
+      #'thrift.test.NestedListsI32x3'{integerlist=null}
     )},
     {"NestedMixedx2 record", ?_assertMatch(
-      {'NestedMixedx2', _, _, _},
-      #'NestedMixedx2'{
+      {'thrift.test.NestedMixedx2', _, _, _},
+      #'thrift.test.NestedMixedx2'{
         int_set_list=null,
         map_int_strset=null,
         map_int_strset_list=null
       }
     )},
-    {"ListBonks record", ?_assertMatch({'ListBonks', _}, #'ListBonks'{bonk=null})},
+    {"ListBonks record", ?_assertMatch({'thrift.test.ListBonks', _}, #'thrift.test.ListBonks'{bonk=null})},
     {"NestedListsBonk record", ?_assertMatch(
-      {'NestedListsBonk', _},
-      #'NestedListsBonk'{bonk=null}
+      {'thrift.test.NestedListsBonk', _},
+      #'thrift.test.NestedListsBonk'{bonk=null}
     )},
     {"BoolTest record", ?_assertMatch(
-      {'BoolTest', _, _},
-      #'BoolTest'{b=null,s=null}
+      {'thrift.test.BoolTest', _, _},
+      #'thrift.test.BoolTest'{b=null,s=null}
     )},
-    {"StructA record", ?_assertMatch({'StructA', _}, #'StructA'{s=null})},
+    {"StructA record", ?_assertMatch({'thrift.test.StructA', _}, #'thrift.test.StructA'{s=null})},
     {"StructB record", ?_assertMatch(
-      {'StructB', _, _},
-      #'StructB'{aa=null,ab=null}
+      {'thrift.test.StructB', _, _},
+      #'thrift.test.StructB'{aa=null,ab=null}
     )}
   ].
 
@@ -159,21 +159,21 @@ struct_info_test_() ->
   [
     {"Bonk definition (short version)", ?_assertEqual(
       {struct, [{1, string}, {2, i32}]},
-      thrift_test_types:struct_info('Bonk')
+      thrift_test_types:struct_info('thrift.test.Bonk')
     )},
     {"Bonk definition", ?_assertEqual(
       {struct, [
         {1, undefined, string, message, undefined},
         {2, undefined, i32, type, undefined}
       ]},
-      thrift_test_types:struct_info_ext('Bonk')
+      thrift_test_types:struct_info_ext('thrift.test.Bonk')
     )},
     {"Bools definition", ?_assertEqual(
       {struct, [
         {1, undefined, bool, im_true, undefined},
         {2, undefined, bool, im_false, undefined}
       ]},
-      thrift_test_types:struct_info_ext('Bools')
+      thrift_test_types:struct_info_ext('thrift.test.Bools')
     )},
     {"Xtruct definition", ?_assertEqual(
       {struct, [
@@ -182,15 +182,15 @@ struct_info_test_() ->
         {9, undefined, i32, i32_thing, undefined},
         {11, undefined, i64, i64_thing, undefined}
       ]},
-      thrift_test_types:struct_info_ext('Xtruct')
+      thrift_test_types:struct_info_ext('thrift.test.Xtruct')
     )},
     {"Xtruct2 definition", ?_assertEqual(
       {struct, [
         {1, undefined, byte, byte_thing, undefined},
-        {2, undefined, {struct, {'thrift_test_types', 'Xtruct'}}, struct_thing, #'Xtruct'{}},
+        {2, undefined, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}, struct_thing, #'thrift.test.Xtruct'{}},
         {3, undefined, i32, i32_thing, undefined}
       ]},
-      thrift_test_types:struct_info_ext('Xtruct2')
+      thrift_test_types:struct_info_ext('thrift.test.Xtruct2')
     )},
     {"Xtruct3 definition", ?_assertEqual(
       {struct, [
@@ -199,50 +199,50 @@ struct_info_test_() ->
         {9, undefined, i32, i32_thing, undefined},
         {11, undefined, i64, i64_thing, undefined}
       ]},
-      thrift_test_types:struct_info_ext('Xtruct3')
+      thrift_test_types:struct_info_ext('thrift.test.Xtruct3')
     )},
     {"Insanity definition", ?_assertEqual(
       {struct, [
         {1, undefined, {map, i32, i64}, userMap, dict:new()},
-        {2, undefined, {list, {struct, {'thrift_test_types', 'Xtruct'}}}, xtructs, []}
+        {2, undefined, {list, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}}, xtructs, []}
       ]},
-      thrift_test_types:struct_info_ext('Insanity')
+      thrift_test_types:struct_info_ext('thrift.test.Insanity')
     )},
     {"CrazyNesting definition", ?_assertEqual(
       {struct, [
         {1, undefined, string, string_field, undefined},
-        {2, optional, {set, {struct, {'thrift_test_types', 'Insanity'}}}, set_field, sets:new()},
-        {3, required, {list, {map, 
+        {2, optional, {set, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}}, set_field, sets:new()},
+        {3, required, {list, {map,
           {set, i32},
-          {map, i32, {set, {list, {map, {struct, {'thrift_test_types', 'Insanity'}}, string}}}}
+          {map, i32, {set, {list, {map, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}, string}}}}
         }}, list_field, []},
         {4, undefined, string, binary_field, undefined}
       ]},
-      thrift_test_types:struct_info_ext('CrazyNesting')
+      thrift_test_types:struct_info_ext('thrift.test.CrazyNesting')
     )},
     {"Xception definition", ?_assertEqual(
       {struct, [
         {1, undefined, i32, errorCode, undefined},
         {2, undefined, string, message, undefined}
       ]},
-      thrift_test_types:struct_info_ext('Xception')
+      thrift_test_types:struct_info_ext('thrift.test.Xception')
     )},
     {"Xception2 definition", ?_assertEqual(
       {struct, [
         {1, undefined, i32, errorCode, undefined},
-        {2, undefined, {struct, {'thrift_test_types', 'Xtruct'}}, struct_thing, #'Xtruct'{}}
+        {2, undefined, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}, struct_thing, #'thrift.test.Xtruct'{}}
       ]},
-      thrift_test_types:struct_info_ext('Xception2')
+      thrift_test_types:struct_info_ext('thrift.test.Xception2')
     )},
     {"EmptyStruct definition", ?_assertEqual(
       {struct, []},
-      thrift_test_types:struct_info_ext('EmptyStruct')
+      thrift_test_types:struct_info_ext('thrift.test.EmptyStruct')
     )},
     {"OneField definition", ?_assertEqual(
       {struct, [
-        {1, undefined, {struct, {'thrift_test_types', 'EmptyStruct'}}, field, #'EmptyStruct'{}}
+        {1, undefined, {struct, {'thrift_test_types', 'thrift.test.EmptyStruct'}}, field, #'thrift.test.EmptyStruct'{}}
       ]},
-      thrift_test_types:struct_info_ext('OneField')
+      thrift_test_types:struct_info_ext('thrift.test.OneField')
     )},
     {"VersioningTestV1 definition", ?_assertEqual(
       {struct, [
@@ -250,7 +250,7 @@ struct_info_test_() ->
         {3, undefined, string, old_string, undefined},
         {12, undefined, i32, end_in_both, undefined}
       ]},
-      thrift_test_types:struct_info_ext('VersioningTestV1')
+      thrift_test_types:struct_info_ext('thrift.test.VersioningTestV1')
     )},
     {"VersioningTestV2 definition", ?_assertEqual(
       {struct, [
@@ -260,61 +260,61 @@ struct_info_test_() ->
         {4, undefined, i16, newshort, undefined},
         {5, undefined, i64, newlong, undefined},
         {6, undefined, double, newdouble, undefined},
-        {7, undefined, {struct, {thrift_test_types, 'Bonk'}}, newstruct, #'Bonk'{}},
+        {7, undefined, {struct, {thrift_test_types, 'thrift.test.Bonk'}}, newstruct, #'thrift.test.Bonk'{}},
         {8, undefined, {list, i32}, newlist, []},
         {9, undefined, {set, i32}, newset, sets:new()},
         {10, undefined, {map, i32, i32}, newmap, dict:new()},
         {11, undefined, string, newstring, undefined},
         {12, undefined, i32, end_in_both, undefined}
       ]},
-      thrift_test_types:struct_info_ext('VersioningTestV2')
+      thrift_test_types:struct_info_ext('thrift.test.VersioningTestV2')
     )},
     {"ListTypeVersioningV1 definition", ?_assertEqual(
       {struct, [
         {1, undefined, {list, i32}, myints, []},
         {2, undefined, string, hello, undefined}
       ]},
-      thrift_test_types:struct_info_ext('ListTypeVersioningV1')
+      thrift_test_types:struct_info_ext('thrift.test.ListTypeVersioningV1')
     )},
     {"ListTypeVersioningV2 definition", ?_assertEqual(
       {struct, [
         {1, undefined, {list, string}, strings, []},
         {2, undefined, string, hello, undefined}
       ]},
-      thrift_test_types:struct_info_ext('ListTypeVersioningV2')
+      thrift_test_types:struct_info_ext('thrift.test.ListTypeVersioningV2')
     )},
     {"GuessProtocolStruct definition", ?_assertEqual(
       {struct, [
         {7, undefined, {map, string, string}, map_field, dict:new()}
       ]},
-      thrift_test_types:struct_info_ext('GuessProtocolStruct')
+      thrift_test_types:struct_info_ext('thrift.test.GuessProtocolStruct')
     )},
     {"LargeDeltas definition", ?_assertEqual(
       {struct, [
-        {1, undefined, {struct, {thrift_test_types, 'Bools'}}, b1, #'Bools'{}},
-        {10, undefined, {struct, {thrift_test_types, 'Bools'}}, b10, #'Bools'{}},
-        {100, undefined, {struct, {thrift_test_types, 'Bools'}}, b100, #'Bools'{}},
+        {1, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b1, #'thrift.test.Bools'{}},
+        {10, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b10, #'thrift.test.Bools'{}},
+        {100, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b100, #'thrift.test.Bools'{}},
         {500, undefined, bool, check_true, undefined},
-        {1000, undefined, {struct, {thrift_test_types, 'Bools'}}, b1000, #'Bools'{}},
+        {1000, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b1000, #'thrift.test.Bools'{}},
         {1500, undefined, bool, check_false, undefined},
-        {2000, undefined, {struct, {thrift_test_types, 'VersioningTestV2'}}, vertwo2000, #'VersioningTestV2'{}},
+        {2000, undefined, {struct, {thrift_test_types, 'thrift.test.VersioningTestV2'}}, vertwo2000, #'thrift.test.VersioningTestV2'{}},
         {2500, undefined, {set, string}, a_set2500, sets:new()},
-        {3000, undefined, {struct, {thrift_test_types, 'VersioningTestV2'}}, vertwo3000, #'VersioningTestV2'{}},
+        {3000, undefined, {struct, {thrift_test_types, 'thrift.test.VersioningTestV2'}}, vertwo3000, #'thrift.test.VersioningTestV2'{}},
         {4000, undefined, {list, i32}, big_numbers, []}
       ]},
-      thrift_test_types:struct_info_ext('LargeDeltas')
+      thrift_test_types:struct_info_ext('thrift.test.LargeDeltas')
     )},
     {"NestedListsI32x2 definition", ?_assertEqual(
       {struct, [
         {1, undefined, {list, {list, i32}}, integerlist, []}
       ]},
-      thrift_test_types:struct_info_ext('NestedListsI32x2')
+      thrift_test_types:struct_info_ext('thrift.test.NestedListsI32x2')
     )},
     {"NestedListsI32x3 definition", ?_assertEqual(
       {struct, [
         {1, undefined, {list, {list, {list, i32}}}, integerlist, []}
       ]},
-      thrift_test_types:struct_info_ext('NestedListsI32x3')
+      thrift_test_types:struct_info_ext('thrift.test.NestedListsI32x3')
     )},
     {"NestedMixedx2 definition", ?_assertEqual(
       {struct, [
@@ -322,37 +322,37 @@ struct_info_test_() ->
         {2, undefined, {map, i32, {set, string}}, map_int_strset, dict:new()},
         {3, undefined, {list, {map, i32, {set, string}}}, map_int_strset_list, []}
       ]},
-      thrift_test_types:struct_info_ext('NestedMixedx2')
+      thrift_test_types:struct_info_ext('thrift.test.NestedMixedx2')
     )},
     {"ListBonks definition", ?_assertEqual(
       {struct, [
-        {1, undefined, {list, {struct, {thrift_test_types, 'Bonk'}}}, bonk, []}
+        {1, undefined, {list, {struct, {thrift_test_types, 'thrift.test.Bonk'}}}, bonk, []}
       ]},
-      thrift_test_types:struct_info_ext('ListBonks')
+      thrift_test_types:struct_info_ext('thrift.test.ListBonks')
     )},
     {"NestedListsBonk definition", ?_assertEqual(
       {struct, [
-        {1, undefined, {list, {list, {list, {struct, {thrift_test_types, 'Bonk'}}}}}, bonk, []}
+        {1, undefined, {list, {list, {list, {struct, {thrift_test_types, 'thrift.test.Bonk'}}}}}, bonk, []}
       ]},
-      thrift_test_types:struct_info_ext('NestedListsBonk')
+      thrift_test_types:struct_info_ext('thrift.test.NestedListsBonk')
     )},
     {"BoolTest definition", ?_assertEqual(
       {struct, [
         {1, optional, bool, b, true},
         {2, optional, string, s, "true"}
       ]},
-      thrift_test_types:struct_info_ext('BoolTest')
+      thrift_test_types:struct_info_ext('thrift.test.BoolTest')
     )},
     {"StructA definition", ?_assertEqual(
       {struct, [{1, required, string, s, undefined}]},
-      thrift_test_types:struct_info_ext('StructA')
+      thrift_test_types:struct_info_ext('thrift.test.StructA')
     )},
     {"StructB definition", ?_assertEqual(
       {struct, [
-        {1, optional, {struct, {thrift_test_types, 'StructA'}}, aa, #'StructA'{}},
-        {2, required, {struct, {thrift_test_types, 'StructA'}}, ab, #'StructA'{}}
+        {1, optional, {struct, {thrift_test_types, 'thrift.test.StructA'}}, aa, #'thrift.test.StructA'{}},
+        {2, required, {struct, {thrift_test_types, 'thrift.test.StructA'}}, ab, #'thrift.test.StructA'{}}
       ]},
-      thrift_test_types:struct_info_ext('StructB')
+      thrift_test_types:struct_info_ext('thrift.test.StructB')
     )}
   ].
 
@@ -432,12 +432,12 @@ service_info_test_() ->
     )},
     {"testStruct params", ?_assertEqual(
       {struct, [
-        {1, {struct, {thrift_test_types, 'Xtruct'}}}
+        {1, {struct, {thrift_test_types, 'thrift.test.Xtruct'}}}
       ]},
       thrift_test_thrift:function_info(testStruct, params_type)
     )},
     {"testStruct reply", ?_assertEqual(
-      {struct, {thrift_test_types, 'Xtruct'}},
+      {struct, {thrift_test_types, 'thrift.test.Xtruct'}},
       thrift_test_thrift:function_info(testStruct, reply_type)
     )},
     {"testStruct exceptions", ?_assertEqual(
@@ -446,12 +446,12 @@ service_info_test_() ->
     )},
     {"testNest params", ?_assertEqual(
       {struct, [
-        {1, {struct, {thrift_test_types, 'Xtruct2'}}}
+        {1, {struct, {thrift_test_types, 'thrift.test.Xtruct2'}}}
       ]},
       thrift_test_thrift:function_info(testNest, params_type)
     )},
     {"testNest reply", ?_assertEqual(
-      {struct, {thrift_test_types, 'Xtruct2'}},
+      {struct, {thrift_test_types, 'thrift.test.Xtruct2'}},
       thrift_test_thrift:function_info(testNest, reply_type)
     )},
     {"testNest exceptions", ?_assertEqual(
@@ -556,12 +556,12 @@ service_info_test_() ->
     )},
     {"testInsanity params", ?_assertEqual(
       {struct, [
-        {1, {struct, {thrift_test_types, 'Insanity'}}}
+        {1, {struct, {thrift_test_types, 'thrift.test.Insanity'}}}
       ]},
       thrift_test_thrift:function_info(testInsanity, params_type)
     )},
     {"testInsanity reply", ?_assertEqual(
-      {map, i64, {map, i32, {struct, {'thrift_test_types', 'Insanity'}}}},
+      {map, i64, {map, i32, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}}},
       thrift_test_thrift:function_info(testInsanity, reply_type)
     )},
     {"testInsanity exceptions", ?_assertEqual(
@@ -580,7 +580,7 @@ service_info_test_() ->
       thrift_test_thrift:function_info(testMulti, params_type)
     )},
     {"testMulti reply", ?_assertEqual(
-      {struct, {thrift_test_types, 'Xtruct'}},
+      {struct, {thrift_test_types, 'thrift.test.Xtruct'}},
       thrift_test_thrift:function_info(testMulti, reply_type)
     )},
     {"testMulti exceptions", ?_assertEqual(
@@ -597,7 +597,7 @@ service_info_test_() ->
     )},
     {"testException exceptions", ?_assertEqual(
       {struct, [
-        {1, {struct, {thrift_test_types, 'Xception'}}}
+        {1, {struct, {thrift_test_types, 'thrift.test.Xception'}}}
       ]},
       thrift_test_thrift:function_info(testException, exceptions)
     )},
@@ -606,13 +606,13 @@ service_info_test_() ->
       thrift_test_thrift:function_info(testMultiException, params_type)
     )},
     {"testMultiException reply", ?_assertEqual(
-      {struct, {thrift_test_types, 'Xtruct'}},
+      {struct, {thrift_test_types, 'thrift.test.Xtruct'}},
       thrift_test_thrift:function_info(testMultiException, reply_type)
     )},
     {"testMultiException exceptions", ?_assertEqual(
       {struct, [
-        {1, {struct, {thrift_test_types, 'Xception'}}},
-        {2, {struct, {thrift_test_types, 'Xception2'}}}
+        {1, {struct, {thrift_test_types, 'thrift.test.Xception'}}},
+        {2, {struct, {thrift_test_types, 'thrift.test.Xception2'}}}
       ]},
       thrift_test_thrift:function_info(testMultiException, exceptions)
     )},

http://git-wip-us.apache.org/repos/asf/thrift/blob/c8deed8c/test/erl/src/test_client.erl
----------------------------------------------------------------------
diff --git a/test/erl/src/test_client.erl b/test/erl/src/test_client.erl
index f97bc8a..50ffc64 100644
--- a/test/erl/src/test_client.erl
+++ b/test/erl/src/test_client.erl
@@ -68,13 +68,13 @@ start(Args) ->
   {ok, Client0} = thrift_client_util:new(
     "127.0.0.1", Port, thrift_test_thrift, ClientOpts),
 
-  DemoXtruct = #'Xtruct'{
-    string_thing = <<"Zero">>,
-    byte_thing = 1,
-    i32_thing = 9128361,
-    i64_thing = 9223372036854775807},
+  DemoXtruct = #'thrift.test.Xtruct'{
+                  string_thing = <<"Zero">>,
+                  byte_thing = 1,
+                  i32_thing = 9128361,
+                  i64_thing = 9223372036854775807},
 
-  DemoNest = #'Xtruct2'{
+  DemoNest = #'thrift.test.Xtruct2'{
     byte_thing = 7,
     struct_thing = DemoXtruct,
     % Note that we don't set i32_thing, it will come back as undefined
@@ -86,9 +86,9 @@ start(Args) ->
   DemoDict = dict:from_list([ {Key, Key-10} || Key <- lists:seq(0,10) ]),
   DemoSet = sets:from_list([ Key || Key <- lists:seq(-3,3) ]),
 
-  DemoInsane = #'Insanity'{
+  DemoInsane = #'thrift.test.Insanity'{
     userMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_FIVE, 5000}]),
-    xtructs = [#'Xtruct'{ string_thing = <<"Truck">>, byte_thing = 8, i32_thing = 8, i64_thing = 8}]},
+    xtructs = [#'thrift.test.Xtruct'{ string_thing = <<"Truck">>, byte_thing = 8, i32_thing = 8, i64_thing = 8}]},
 
   error_logger:info_msg("testVoid"),
   {Client01, {ok, ok}} = thrift_client:call(Client0, testVoid, []),
@@ -126,7 +126,7 @@ start(Args) ->
   {Client16, {ok, InsaneResult}}    = thrift_client:call(Client15, testInsanity, [DemoInsane]),
   io:format("~p~n", [InsaneResult]),
 
-  {Client17, {ok, #'Xtruct'{string_thing = <<"Message">>}}} =
+  {Client17, {ok, #'thrift.test.Xtruct'{string_thing = <<"Message">>}}} =
     thrift_client:call(Client16, testMultiException, ["Safe", "Message"]),
 
   Client18 =
@@ -135,10 +135,10 @@ start(Args) ->
       io:format("Unexpected return! ~p~n", [Result1]),
       ClientS1
     catch
-      throw:{ClientS2, {exception, ExnS1 = #'Xception'{}}} ->
-        #'Xception'{errorCode = 1001, message = <<"This is an Xception">>} = ExnS1,
+      throw:{ClientS2, {exception, ExnS1 = #'thrift.test.Xception'{}}} ->
+        #'thrift.test.Xception'{errorCode = 1001, message = <<"This is an Xception">>} = ExnS1,
         ClientS2;
-      throw:{ClientS2, {exception, _ExnS1 = #'Xception2'{}}} ->
+      throw:{ClientS2, {exception, _ExnS1 = #'thrift.test.Xception2'{}}} ->
         io:format("Wrong exception type!~n", []),
         ClientS2
     end,
@@ -149,12 +149,12 @@ start(Args) ->
       io:format("Unexpected return! ~p~n", [Result2]),
       ClientS3
     catch
-      throw:{ClientS4, {exception, _ExnS2 = #'Xception'{}}} ->
+      throw:{ClientS4, {exception, _ExnS2 = #'thrift.test.Xception'{}}} ->
         io:format("Wrong exception type!~n", []),
         ClientS4;
-      throw:{ClientS4, {exception, ExnS2 = #'Xception2'{}}} ->
-        #'Xception2'{errorCode = 2002,
-                   struct_thing = #'Xtruct'{
+      throw:{ClientS4, {exception, ExnS2 = #'thrift.test.Xception2'{}}} ->
+        #'thrift.test.Xception2'{errorCode = 2002,
+                   struct_thing = #'thrift.test.Xtruct'{
                      string_thing = <<"This is an Xception2">>}} = ExnS2,
         ClientS4
     end,

http://git-wip-us.apache.org/repos/asf/thrift/blob/c8deed8c/test/erl/src/test_thrift_server.erl
----------------------------------------------------------------------
diff --git a/test/erl/src/test_thrift_server.erl b/test/erl/src/test_thrift_server.erl
index f504c73..f3ed2f7 100644
--- a/test/erl/src/test_thrift_server.erl
+++ b/test/erl/src/test_thrift_server.erl
@@ -107,10 +107,10 @@ handle_function(testBinary, {S}) when is_binary(S) ->
     {reply, S};
 
 handle_function(testStruct,
-                {Struct = #'Xtruct'{string_thing = String,
-                                 byte_thing = Byte,
-                                 i32_thing = I32,
-                                 i64_thing = I64}})
+                {Struct = #'thrift.test.Xtruct'{string_thing = String,
+                                                byte_thing = Byte,
+                                                i32_thing = I32,
+                                                i64_thing = I64}})
 when is_binary(String),
      is_integer(Byte),
      is_integer(I32),
@@ -119,8 +119,8 @@ when is_binary(String),
     {reply, Struct};
 
 handle_function(testNest,
-                {Nest}) when is_record(Nest, 'Xtruct2'),
-                             is_record(Nest#'Xtruct2'.struct_thing, 'Xtruct') ->
+                {Nest}) when is_record(Nest, 'thrift.test.Xtruct2'),
+                             is_record(Nest#'thrift.test.Xtruct2'.struct_thing, 'thrift.test.Xtruct') ->
     io:format("testNest: ~p~n", [Nest]),
     {reply, Nest};
 
@@ -159,22 +159,22 @@ handle_function(testMapMap, {Hello}) ->
                              {-4, dict:from_list(NegList)}]),
     {reply, MapMap};
 
-handle_function(testInsanity, {Insanity}) when is_record(Insanity, 'Insanity') ->
-    Hello = #'Xtruct'{string_thing = <<"Hello2">>,
-                    byte_thing = 2,
-                    i32_thing = 2,
-                    i64_thing = 2},
+handle_function(testInsanity, {Insanity}) when is_record(Insanity, 'thrift.test.Insanity') ->
+    Hello = #'thrift.test.Xtruct'{string_thing = <<"Hello2">>,
+                                  byte_thing = 2,
+                                  i32_thing = 2,
+                                  i64_thing = 2},
 
-    Goodbye = #'Xtruct'{string_thing = <<"Goodbye4">>,
-                      byte_thing = 4,
-                      i32_thing = 4,
-                      i64_thing = 4},
-    Crazy = #'Insanity'{
-      userMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_EIGHT, 8}]),
-      xtructs = [Goodbye]
-      },
+    Goodbye = #'thrift.test.Xtruct'{string_thing = <<"Goodbye4">>,
+                                   byte_thing = 4,
+                                    i32_thing = 4,
+                                    i64_thing = 4},
+    Crazy = #'thrift.test.Insanity'{
+               userMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_EIGHT, 8}]),
+               xtructs = [Goodbye]
+              },
 
-    Looney = #'Insanity'{},
+    Looney = #'thrift.test.Insanity'{},
 
     FirstMap = dict:from_list([{?THRIFT_TEST_NUMBERZ_TWO, Insanity},
                                {?THRIFT_TEST_NUMBERZ_THREE, Insanity}]),
@@ -196,16 +196,16 @@ handle_function(testMulti, Args = {Arg0, Arg1, Arg2, _Arg3, Arg4, Arg5})
        is_integer(Arg5) ->
 
     io:format("testMulti(~p)~n", [Args]),
-    {reply, #'Xtruct'{string_thing = <<"Hello2">>,
-                    byte_thing = Arg0,
-                    i32_thing = Arg1,
-                    i64_thing = Arg2}};
+    {reply, #'thrift.test.Xtruct'{string_thing = <<"Hello2">>,
+                                  byte_thing = Arg0,
+                                  i32_thing = Arg1,
+                                  i64_thing = Arg2}};
 
 handle_function(testException, {String}) when is_binary(String) ->
     io:format("testException(~p)~n", [String]),
     case String of
         <<"Xception">> ->
-            throw(#'Xception'{errorCode = 1001,
+            throw(#'thrift.test.Xception'{errorCode = 1001,
                             message = String});
         <<"TException">> ->
             throw({?TApplicationException_Structure});
@@ -217,14 +217,14 @@ handle_function(testMultiException, {Arg0, Arg1}) ->
     io:format("testMultiException(~p, ~p)~n", [Arg0, Arg1]),
     case Arg0 of
         <<"Xception">> ->
-            throw(#'Xception'{errorCode = 1001,
+            throw(#'thrift.test.Xception'{errorCode = 1001,
                                    message = <<"This is an Xception">>});
         <<"Xception2">> ->
-            throw(#'Xception2'{errorCode = 2002,
+            throw(#'thrift.test.Xception2'{errorCode = 2002,
                                     struct_thing =
-                                    #'Xtruct'{string_thing = <<"This is an Xception2">>}});
+                                    #'thrift.test.Xtruct'{string_thing = <<"This is an Xception2">>}});
         _ ->
-            {reply, #'Xtruct'{string_thing = Arg1}}
+            {reply, #'thrift.test.Xtruct'{string_thing = Arg1}}
     end;
 
 handle_function(testOneway, {Seconds}) ->