From: Wouter van Oortmerssen Date: Fri, 29 Jul 2016 17:45:32 +0000 (-0700) Subject: Added backwards compatible --no-union-value-namespacing X-Git-Tag: v1.4.0~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d70f5ac6b02f250dca8e2c6e8f59a4223d1f66f6;p=platform%2Fupstream%2Fflatbuffers.git Added backwards compatible --no-union-value-namespacing Change-Id: Ia78dd3b0f213e9ffa49dcec699dcbb21fe6517da Tested: on Linux. --- diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h index 1f45016..25706e8 100644 --- a/include/flatbuffers/idl.h +++ b/include/flatbuffers/idl.h @@ -347,6 +347,7 @@ struct IDLOptions { bool generate_name_strings; bool escape_proto_identifiers; bool generate_object_based_api; + bool union_value_namespacing; // Possible options for the more general generator below. enum Language { kJava, kCSharp, kGo, kMAX }; @@ -368,6 +369,7 @@ struct IDLOptions { generate_name_strings(false), escape_proto_identifiers(false), generate_object_based_api(false), + union_value_namespacing(true), lang(IDLOptions::kJava) {} }; diff --git a/src/flatc.cpp b/src/flatc.cpp index a568bbb..b174cbd 100644 --- a/src/flatc.cpp +++ b/src/flatc.cpp @@ -195,6 +195,8 @@ int main(int argc, const char *argv[]) { } else if(arg == "--scoped-enums") { opts.prefixed_enums = false; opts.scoped_enums = true; + } else if (arg == "--no-union-value-namespacing") { + opts.union_value_namespacing = false; } else if(arg == "--gen-mutable") { opts.mutable_buffer = true; } else if(arg == "--gen-name-strings") { diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index fc21367..b03655c 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -1216,10 +1216,12 @@ CheckedError Parser::ParseEnum(bool is_union, EnumDef **dest) { EXPECT(kTokenIdentifier); if (is_union) { ECHECK(ParseNamespacing(&full_name, &value_name)); - // Since we can't namespace the actual enum identifiers, turn - // namespace parts into part of the identifier. - value_name = full_name; - std::replace(value_name.begin(), value_name.end(), '.', '_'); + if (opts.union_value_namespacing) { + // Since we can't namespace the actual enum identifiers, turn + // namespace parts into part of the identifier. + value_name = full_name; + std::replace(value_name.begin(), value_name.end(), '.', '_'); + } } auto prevsize = enum_def.vals.vec.size(); auto value = enum_def.vals.vec.size()