diff options
author | nechda <nechda@yandex-team.com> | 2024-08-29 23:50:27 +0300 |
---|---|---|
committer | nechda <nechda@yandex-team.com> | 2024-08-30 00:05:25 +0300 |
commit | e10d6638f07a82edae3ea8197b9f5c0affcc07ea (patch) | |
tree | 571c38cec05813766a1ad290c9d51ce7ace52919 /contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc | |
parent | e79b38f2bbbf78d295d1901d2a79f898022d5224 (diff) | |
download | ydb-e10d6638f07a82edae3ea8197b9f5c0affcc07ea.tar.gz |
Update cpp-protobuf to 22.5
Привет!\
Этот PR переключат cpp & python библиотеки protobuf на версию 22.5
Если у вас возникли проблемы после влития этого PR:
1. Если начали падать канон тесты, то проведите их переканонизацию
2. Прочитайте <https://wiki.yandex-team.ru/users/nechda/obnovlenie-cpp-protobuf-22.5/> страничку с основными изменениями
3. Если страничка в вики не помогла, то пишите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/DEVTOOLSSUPPORT)
7fecade616c20a841b9e9af7b7998bdfc8d2807d
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc')
-rw-r--r-- | contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc index 5ba5e630c0..000cd54882 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/enum.cc @@ -32,21 +32,21 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <google/protobuf/compiler/java/enum.h> +#include "google/protobuf/compiler/java/enum.h" -#include <map> #include <string> -#include <google/protobuf/io/printer.h> -#include <google/protobuf/stubs/strutil.h> -#include <google/protobuf/compiler/java/context.h> -#include <google/protobuf/compiler/java/doc_comment.h> -#include <google/protobuf/compiler/java/helpers.h> -#include <google/protobuf/compiler/java/name_resolver.h> -#include <google/protobuf/descriptor.pb.h> +#include "y_absl/container/flat_hash_map.h" +#include "y_absl/strings/str_cat.h" +#include "google/protobuf/compiler/java/context.h" +#include "google/protobuf/compiler/java/doc_comment.h" +#include "google/protobuf/compiler/java/helpers.h" +#include "google/protobuf/compiler/java/name_resolver.h" +#include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/io/printer.h" // Must be last. -#include <google/protobuf/port_def.inc> +#include "google/protobuf/port_def.inc" namespace google { namespace protobuf { @@ -80,6 +80,10 @@ EnumGenerator::~EnumGenerator() {} void EnumGenerator::Generate(io::Printer* printer) { WriteEnumDocComment(printer, descriptor_); MaybePrintGeneratedAnnotation(context_, printer, descriptor_, immutable_api_); + + if (!context_->options().opensource_runtime) { + printer->Print("@com.google.protobuf.Internal.ProtoNonnullApi\n"); + } printer->Print( "$deprecation$public enum $classname$\n" " implements com.google.protobuf.ProtocolMessageEnum {\n", @@ -99,10 +103,10 @@ void EnumGenerator::Generate(io::Printer* printer) { } for (int i = 0; i < canonical_values_.size(); i++) { - std::map<TProtoStringType, TProtoStringType> vars; + y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars; vars["name"] = canonical_values_[i]->name(); - vars["index"] = StrCat(canonical_values_[i]->index()); - vars["number"] = StrCat(canonical_values_[i]->number()); + vars["index"] = y_absl::StrCat(canonical_values_[i]->index()); + vars["number"] = y_absl::StrCat(canonical_values_[i]->number()); WriteEnumValueDocComment(printer, canonical_values_[i]); if (canonical_values_[i]->options().deprecated()) { printer->Print("@java.lang.Deprecated\n"); @@ -131,7 +135,7 @@ void EnumGenerator::Generate(io::Printer* printer) { // ----------------------------------------------------------------- for (int i = 0; i < aliases_.size(); i++) { - std::map<TProtoStringType, TProtoStringType> vars; + y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars; vars["classname"] = descriptor_->name(); vars["name"] = aliases_[i].value->name(); vars["canonical_name"] = aliases_[i].canonical_value->name(); @@ -142,9 +146,9 @@ void EnumGenerator::Generate(io::Printer* printer) { } for (int i = 0; i < descriptor_->value_count(); i++) { - std::map<TProtoStringType, TProtoStringType> vars; + y_absl::flat_hash_map<y_absl::string_view, TProtoStringType> vars; vars["name"] = descriptor_->value(i)->name(); - vars["number"] = StrCat(descriptor_->value(i)->number()); + vars["number"] = y_absl::StrCat(descriptor_->value(i)->number()); vars["{"] = ""; vars["}"] = ""; vars["deprecation"] = descriptor_->value(i)->options().deprecated() @@ -181,23 +185,32 @@ void EnumGenerator::Generate(io::Printer* printer) { printer->Print( " return value;\n" "}\n" - "\n" - "/**\n" - " * @param value The numeric wire value of the corresponding enum " - "entry.\n" - " * @return The enum associated with the given numeric wire value.\n" - " * @deprecated Use {@link #forNumber(int)} instead.\n" - " */\n" - "@java.lang.Deprecated\n" - "public static $classname$ valueOf(int value) {\n" - " return forNumber(value);\n" - "}\n" - "\n" + "\n"); + if (context_->options().opensource_runtime) { + printer->Print( + "/**\n" + " * @param value The numeric wire value of the corresponding enum " + "entry.\n" + " * @return The enum associated with the given numeric wire value.\n" + " * @deprecated Use {@link #forNumber(int)} instead.\n" + " */\n" + "@java.lang.Deprecated\n" + "public static $classname$ valueOf(int value) {\n" + " return forNumber(value);\n" + "}\n" + "\n", + "classname", descriptor_->name()); + } + printer->Print( "/**\n" " * @param value The numeric wire value of the corresponding enum " "entry.\n" " * @return The enum associated with the given numeric wire value.\n" - " */\n" + " */\n"); + if (!context_->options().opensource_runtime) { + printer->Print("@com.google.protobuf.Internal.ProtoMethodMayReturnNull\n"); + } + printer->Print( "public static $classname$ forNumber(int value) {\n" " switch (value) {\n", "classname", descriptor_->name()); @@ -207,7 +220,7 @@ void EnumGenerator::Generate(io::Printer* printer) { for (int i = 0; i < canonical_values_.size(); i++) { printer->Print("case $number$: return $name$;\n", "name", canonical_values_[i]->name(), "number", - StrCat(canonical_values_[i]->number())); + y_absl::StrCat(canonical_values_[i]->number())); } printer->Outdent(); @@ -277,7 +290,7 @@ void EnumGenerator::Generate(io::Printer* printer) { " return $file$.getDescriptor().getEnumTypes().get($index$);\n", "file", name_resolver_->GetClassName(descriptor_->file(), immutable_api_), - "index", StrCat(descriptor_->index())); + "index", y_absl::StrCat(descriptor_->index())); } else { printer->Print( " return $parent$.$descriptor$.getEnumTypes().get($index$);\n", @@ -290,7 +303,7 @@ void EnumGenerator::Generate(io::Printer* printer) { .no_standard_descriptor_accessor() ? "getDefaultInstance().getDescriptorForType()" : "getDescriptor()", - "index", StrCat(descriptor_->index())); + "index", y_absl::StrCat(descriptor_->index())); } printer->Print( @@ -394,4 +407,4 @@ bool EnumGenerator::CanUseEnumValues() { } // namespace protobuf } // namespace google -#include <google/protobuf/port_undef.inc> +#include "google/protobuf/port_undef.inc" |