| 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 1a11bce8579833990570c00214ea031f35da27c1..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
|
| @@ -69,11 +69,12 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
|
|
|
| EnumGenerator::~EnumGenerator() {}
|
|
|
| -void EnumGenerator::FillForwardDeclaration(set<string>* enum_names) {
|
| +void EnumGenerator::FillForwardDeclaration(
|
| + map<string, const EnumDescriptor*>* enum_names) {
|
| if (!options_.proto_h) {
|
| return;
|
| }
|
| - enum_names->insert(classname_);
|
| + (*enum_names)[classname_] = descriptor_;
|
| }
|
|
|
| void EnumGenerator::GenerateDefinition(io::Printer* printer) {
|
| @@ -83,6 +84,7 @@ void EnumGenerator::GenerateDefinition(io::Printer* printer) {
|
| vars["enumbase"] = classname_ + (options_.proto_h ? " : int" : "");
|
|
|
| printer->Print(vars, "enum $enumbase$ {\n");
|
| + printer->Annotate("enumbase", descriptor_);
|
| printer->Indent();
|
|
|
| const EnumValueDescriptor* min_value = descriptor_->value(0);
|
| @@ -96,9 +98,11 @@ void EnumGenerator::GenerateDefinition(io::Printer* printer) {
|
| vars["number"] = Int32ToString(descriptor_->value(i)->number());
|
| vars["prefix"] = (descriptor_->containing_type() == NULL) ?
|
| "" : classname_ + "_";
|
| + vars["deprecation"] = descriptor_->value(i)->options().deprecated() ?
|
| + " PROTOBUF_DEPRECATED" : "";
|
|
|
| if (i > 0) printer->Print(",\n");
|
| - printer->Print(vars, "$prefix$$name$ = $number$");
|
| + printer->Print(vars, "$prefix$$name$$deprecation$ = $number$");
|
|
|
| if (descriptor_->value(i)->number() < min_value->number()) {
|
| min_value = descriptor_->value(i);
|
| @@ -140,15 +144,16 @@ void EnumGenerator::GenerateDefinition(io::Printer* printer) {
|
| "$prefix$$short_name$_MAX + 1;\n\n");
|
| }
|
|
|
| - if (HasDescriptorMethods(descriptor_->file())) {
|
| + if (HasDescriptorMethods(descriptor_->file(), options_)) {
|
| printer->Print(vars,
|
| "$dllexport$const ::google::protobuf::EnumDescriptor* $classname$_descriptor();\n");
|
| // The _Name and _Parse methods
|
| - printer->Print(vars,
|
| - "inline const ::std::string& $classname$_Name($classname$ value) {\n"
|
| - " return ::google::protobuf::internal::NameOfEnum(\n"
|
| - " $classname$_descriptor(), value);\n"
|
| - "}\n");
|
| + printer->Print(
|
| + vars,
|
| + "inline const ::std::string& $classname$_Name($classname$ value) {\n"
|
| + " return ::google::protobuf::internal::NameOfEnum(\n"
|
| + " $classname$_descriptor(), value);\n"
|
| + "}\n");
|
| printer->Print(vars,
|
| "inline bool $classname$_Parse(\n"
|
| " const ::std::string& name, $classname$* value) {\n"
|
| @@ -164,7 +169,7 @@ GenerateGetEnumDescriptorSpecializations(io::Printer* printer) {
|
| "template <> struct is_proto_enum< $classname$> : ::google::protobuf::internal::true_type "
|
| "{};\n",
|
| "classname", ClassName(descriptor_, true));
|
| - if (HasDescriptorMethods(descriptor_->file())) {
|
| + if (HasDescriptorMethods(descriptor_->file(), options_)) {
|
| printer->Print(
|
| "template <>\n"
|
| "inline const EnumDescriptor* GetEnumDescriptor< $classname$>() {\n"
|
| @@ -178,12 +183,16 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) {
|
| map<string, string> vars;
|
| vars["nested_name"] = descriptor_->name();
|
| vars["classname"] = classname_;
|
| + vars["constexpr"] = options_.proto_h ? "constexpr " : "";
|
| printer->Print(vars, "typedef $classname$ $nested_name$;\n");
|
|
|
| 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 " : "";
|
| printer->Print(vars,
|
| - "static const $nested_name$ $tag$ = $classname$_$tag$;\n");
|
| + "$deprecated_attr$static $constexpr$const $nested_name$ $tag$ =\n"
|
| + " $classname$_$tag$;\n");
|
| }
|
|
|
| printer->Print(vars,
|
| @@ -200,16 +209,18 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) {
|
| " $classname$_$nested_name$_ARRAYSIZE;\n");
|
| }
|
|
|
| - if (HasDescriptorMethods(descriptor_->file())) {
|
| + if (HasDescriptorMethods(descriptor_->file(), options_)) {
|
| printer->Print(vars,
|
| "static inline const ::google::protobuf::EnumDescriptor*\n"
|
| "$nested_name$_descriptor() {\n"
|
| " return $classname$_descriptor();\n"
|
| "}\n");
|
| printer->Print(vars,
|
| - "static inline const ::std::string& $nested_name$_Name($nested_name$ value) {\n"
|
| - " return $classname$_Name(value);\n"
|
| - "}\n");
|
| + "static inline const ::std::string& "
|
| + "$nested_name$_Name($nested_name$ value) {"
|
| + "\n"
|
| + " return $classname$_Name(value);\n"
|
| + "}\n");
|
| printer->Print(vars,
|
| "static inline bool $nested_name$_Parse(const ::std::string& name,\n"
|
| " $nested_name$* value) {\n"
|
| @@ -237,8 +248,9 @@ void EnumGenerator::GenerateDescriptorInitializer(
|
| void EnumGenerator::GenerateMethods(io::Printer* printer) {
|
| map<string, string> vars;
|
| vars["classname"] = classname_;
|
| + vars["constexpr"] = options_.proto_h ? "constexpr " : "";
|
|
|
| - if (HasDescriptorMethods(descriptor_->file())) {
|
| + if (HasDescriptorMethods(descriptor_->file(), options_)) {
|
| printer->Print(vars,
|
| "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n"
|
| " protobuf_AssignDescriptorsOnce();\n"
|
| @@ -287,7 +299,7 @@ void EnumGenerator::GenerateMethods(io::Printer* printer) {
|
| for (int i = 0; i < descriptor_->value_count(); i++) {
|
| vars["value"] = EnumValueName(descriptor_->value(i));
|
| printer->Print(vars,
|
| - "const $classname$ $parent$::$value$;\n");
|
| + "$constexpr$const $classname$ $parent$::$value$;\n");
|
| }
|
| printer->Print(vars,
|
| "const $classname$ $parent$::$nested_name$_MIN;\n"
|
|
|