| Index: third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc b/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc
|
| index 9493d5f805b2c371abb653fa8effc3d6dbb41e2d..c81c598216e7ef0a9cac0ba9d47bcac720dc60b3 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc
|
| @@ -70,7 +70,7 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
|
| EnumGenerator::~EnumGenerator() {}
|
|
|
| void EnumGenerator::FillForwardDeclaration(
|
| - std::map<string, const EnumDescriptor*>* enum_names) {
|
| + map<string, const EnumDescriptor*>* enum_names) {
|
| if (!options_.proto_h) {
|
| return;
|
| }
|
| @@ -78,7 +78,7 @@ void EnumGenerator::FillForwardDeclaration(
|
| }
|
|
|
| void EnumGenerator::GenerateDefinition(io::Printer* printer) {
|
| - std::map<string, string> vars;
|
| + map<string, string> vars;
|
| vars["classname"] = classname_;
|
| vars["short_name"] = descriptor_->name();
|
| vars["enumbase"] = classname_ + (options_.proto_h ? " : int" : "");
|
| @@ -180,7 +180,7 @@ GenerateGetEnumDescriptorSpecializations(io::Printer* printer) {
|
| }
|
|
|
| void EnumGenerator::GenerateSymbolImports(io::Printer* printer) {
|
| - std::map<string, string> vars;
|
| + map<string, string> vars;
|
| vars["nested_name"] = descriptor_->name();
|
| vars["classname"] = classname_;
|
| vars["constexpr"] = options_.proto_h ? "constexpr " : "";
|
| @@ -189,7 +189,7 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) {
|
| for (int j = 0; j < descriptor_->value_count(); j++) {
|
| vars["tag"] = EnumValueName(descriptor_->value(j));
|
| vars["deprecated_attr"] = descriptor_->value(j)->options().deprecated() ?
|
| - "GOOGLE_PROTOBUF_DEPRECATED_ATTR " : "";
|
| + "PROTOBUF_DEPRECATED_ATTR " : "";
|
| printer->Print(vars,
|
| "$deprecated_attr$static $constexpr$const $nested_name$ $tag$ =\n"
|
| " $classname$_$tag$;\n");
|
| @@ -229,53 +229,50 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) {
|
| }
|
| }
|
|
|
| -void EnumGenerator::GenerateDescriptorInitializer(io::Printer* printer) {
|
| - std::map<string, string> vars;
|
| - vars["index"] = SimpleItoa(descriptor_->index());
|
| - vars["index_in_metadata"] = SimpleItoa(index_in_metadata_);
|
| +void EnumGenerator::GenerateDescriptorInitializer(
|
| + io::Printer* printer, int index) {
|
| + map<string, string> vars;
|
| + vars["classname"] = classname_;
|
| + vars["index"] = SimpleItoa(index);
|
|
|
| if (descriptor_->containing_type() == NULL) {
|
| printer->Print(vars,
|
| - "file_level_enum_descriptors[$index_in_metadata$] = "
|
| - "file->enum_type($index$);\n");
|
| + "$classname$_descriptor_ = file->enum_type($index$);\n");
|
| } else {
|
| vars["parent"] = ClassName(descriptor_->containing_type(), false);
|
| printer->Print(vars,
|
| - "file_level_enum_descriptors[$index_in_metadata$] = "
|
| - "$parent$_descriptor->enum_type($index$);\n");
|
| + "$classname$_descriptor_ = $parent$_descriptor_->enum_type($index$);\n");
|
| }
|
| }
|
|
|
| void EnumGenerator::GenerateMethods(io::Printer* printer) {
|
| - std::map<string, string> vars;
|
| + map<string, string> vars;
|
| vars["classname"] = classname_;
|
| - vars["index_in_metadata"] = SimpleItoa(index_in_metadata_);
|
| vars["constexpr"] = options_.proto_h ? "constexpr " : "";
|
|
|
| if (HasDescriptorMethods(descriptor_->file(), options_)) {
|
| - printer->Print(
|
| - vars,
|
| - "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n"
|
| - " protobuf_AssignDescriptorsOnce();\n"
|
| - " return file_level_enum_descriptors[$index_in_metadata$];\n"
|
| - "}\n");
|
| + printer->Print(vars,
|
| + "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n"
|
| + " protobuf_AssignDescriptorsOnce();\n"
|
| + " return $classname$_descriptor_;\n"
|
| + "}\n");
|
| }
|
|
|
| printer->Print(vars,
|
| "bool $classname$_IsValid(int value) {\n"
|
| - " switch (value) {\n");
|
| + " switch(value) {\n");
|
|
|
| // Multiple values may have the same number. Make sure we only cover
|
| // each number once by first constructing a set containing all valid
|
| // numbers, then printing a case statement for each element.
|
|
|
| - std::set<int> numbers;
|
| + set<int> numbers;
|
| for (int j = 0; j < descriptor_->value_count(); j++) {
|
| const EnumValueDescriptor* value = descriptor_->value(j);
|
| numbers.insert(value->number());
|
| }
|
|
|
| - for (std::set<int>::iterator iter = numbers.begin();
|
| + for (set<int>::iterator iter = numbers.begin();
|
| iter != numbers.end(); ++iter) {
|
| printer->Print(
|
| " case $number$:\n",
|
|
|