Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Unified Diff: third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 c81c598216e7ef0a9cac0ba9d47bcac720dc60b3..9493d5f805b2c371abb653fa8effc3d6dbb41e2d 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(
- map<string, const EnumDescriptor*>* enum_names) {
+ std::map<string, const EnumDescriptor*>* enum_names) {
if (!options_.proto_h) {
return;
}
@@ -78,7 +78,7 @@ void EnumGenerator::FillForwardDeclaration(
}
void EnumGenerator::GenerateDefinition(io::Printer* printer) {
- map<string, string> vars;
+ std::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) {
- map<string, string> vars;
+ std::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() ?
- "PROTOBUF_DEPRECATED_ATTR " : "";
+ "GOOGLE_PROTOBUF_DEPRECATED_ATTR " : "";
printer->Print(vars,
"$deprecated_attr$static $constexpr$const $nested_name$ $tag$ =\n"
" $classname$_$tag$;\n");
@@ -229,50 +229,53 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) {
}
}
-void EnumGenerator::GenerateDescriptorInitializer(
- io::Printer* printer, int index) {
- map<string, string> vars;
- vars["classname"] = classname_;
- vars["index"] = SimpleItoa(index);
+void EnumGenerator::GenerateDescriptorInitializer(io::Printer* printer) {
+ std::map<string, string> vars;
+ vars["index"] = SimpleItoa(descriptor_->index());
+ vars["index_in_metadata"] = SimpleItoa(index_in_metadata_);
if (descriptor_->containing_type() == NULL) {
printer->Print(vars,
- "$classname$_descriptor_ = file->enum_type($index$);\n");
+ "file_level_enum_descriptors[$index_in_metadata$] = "
+ "file->enum_type($index$);\n");
} else {
vars["parent"] = ClassName(descriptor_->containing_type(), false);
printer->Print(vars,
- "$classname$_descriptor_ = $parent$_descriptor_->enum_type($index$);\n");
+ "file_level_enum_descriptors[$index_in_metadata$] = "
+ "$parent$_descriptor->enum_type($index$);\n");
}
}
void EnumGenerator::GenerateMethods(io::Printer* printer) {
- map<string, string> vars;
+ std::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 $classname$_descriptor_;\n"
- "}\n");
+ 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,
"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.
- set<int> numbers;
+ std::set<int> numbers;
for (int j = 0; j < descriptor_->value_count(); j++) {
const EnumValueDescriptor* value = descriptor_->value(j);
numbers.insert(value->number());
}
- for (set<int>::iterator iter = numbers.begin();
+ for (std::set<int>::iterator iter = numbers.begin();
iter != numbers.end(); ++iter) {
printer->Print(
" case $number$:\n",

Powered by Google App Engine
This is Rietveld 408576698