Add prefix to enum value with reserved name. (#3020)
This commit is contained in:
parent
3c0855e94a
commit
a6189acd18
2 changed files with 5 additions and 4 deletions
|
@ -119,6 +119,7 @@ enum TestEnum {
|
|||
ZERO = 0;
|
||||
ONE = 1;
|
||||
TWO = 2;
|
||||
ECHO = 3; // Test reserved name.
|
||||
}
|
||||
|
||||
// Test prefix for reserved words.
|
||||
|
|
|
@ -49,8 +49,8 @@ const std::string kDescriptorMetadataFile =
|
|||
"GPBMetadata/Google/Protobuf/Internal/Descriptor.php";
|
||||
const std::string kDescriptorDirName = "Google/Protobuf/Internal";
|
||||
const std::string kDescriptorPackageName = "Google\\Protobuf\\Internal";
|
||||
const char* const kReservedNames[] = {"Empty"};
|
||||
const int kReservedNamesSize = 1;
|
||||
const char* const kReservedNames[] = {"Empty", "ECHO"};
|
||||
const int kReservedNamesSize = 2;
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
@ -559,7 +559,7 @@ void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) {
|
|||
const EnumValueDescriptor* value = en->value(i);
|
||||
printer->Print(
|
||||
"->value(\"^name^\", ^number^)\n",
|
||||
"name", value->name(),
|
||||
"name", ClassNamePrefix(value->name(), en) + value->name(),
|
||||
"number", IntToString(value->number()));
|
||||
}
|
||||
printer->Print("->finalizeToPool();\n\n");
|
||||
|
@ -845,7 +845,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
|
|||
const EnumValueDescriptor* value = en->value(i);
|
||||
GenerateEnumValueDocComment(&printer, value);
|
||||
printer.Print("const ^name^ = ^number^;\n",
|
||||
"name", value->name(),
|
||||
"name", ClassNamePrefix(value->name(), en) + value->name(),
|
||||
"number", IntToString(value->number()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue