Added backwards compatible --no-union-value-namespacing

Change-Id: Ia78dd3b0f213e9ffa49dcec699dcbb21fe6517da
Tested: on Linux.
This commit is contained in:
Wouter van Oortmerssen 2016-07-29 10:45:32 -07:00
parent c9b9fd0407
commit d70f5ac6b0
3 changed files with 10 additions and 4 deletions

View File

@ -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) {}
};

View File

@ -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") {

View File

@ -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()