diff options
author | mikhnenko <[email protected]> | 2024-06-30 20:16:52 +0300 |
---|---|---|
committer | mikhnenko <[email protected]> | 2024-06-30 20:28:14 +0300 |
commit | b91a38fe11269c505fec071351a68e568768e6e8 (patch) | |
tree | 07d43bf92eee00e2fce98bdbf698f135386995c1 /contrib/libs/protoc/src/google/protobuf/compiler/csharp | |
parent | b21e05a2e32e36ae9cc9826acf98084ca4b52d7d (diff) |
Update protobuf to 3.21.2
a628f0376085fcf46dc6d24629f2a7dacb91ae79
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/csharp')
18 files changed, 30 insertions, 31 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index 186fa27e5b3..55fb60c504a 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -109,7 +109,7 @@ void EnumOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, "$oneof_name$_ = input.ReadEnum();\n" - "$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n"); + "$oneof_name$Case_ = $oneof_property_name$OneofCase.$oneof_case_name$;\n"); } void EnumOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) { diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.h index b887a287348..5d1e5f0a99a 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_enum_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__ -#include <string> - #include <google/protobuf/compiler/code_generator.h> #include <google/protobuf/compiler/csharp/csharp_primitive_field.h> diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc index ec39b108880..7b1806e1925 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -130,8 +130,9 @@ void FieldGeneratorBase::SetCommonOneofFieldVariables( } else { (*variables)["has_property_check"] = oneof_name() + "Case_ == " + oneof_property_name() + - "OneofCase." + property_name(); + "OneofCase." + oneof_case_name(); } + (*variables)["oneof_case_name"] = oneof_case_name(); (*variables)["oneof_property_name"] = oneof_property_name(); } @@ -187,6 +188,10 @@ void FieldGeneratorBase::AddPublicMemberAttributes(io::Printer* printer) { WriteGeneratedCodeAttributes(printer); } +TProtoStringType FieldGeneratorBase::oneof_case_name() { + return GetOneofCaseName(descriptor_); +} + TProtoStringType FieldGeneratorBase::oneof_property_name() { return UnderscoresToCamelCase(descriptor_->containing_oneof()->name(), true); } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.h index 154f67ae9ce..e553202792f 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -85,6 +85,7 @@ class FieldGeneratorBase : public SourceGeneratorBase { std::map<TProtoStringType, TProtoStringType>* variables); TProtoStringType oneof_property_name(); + TProtoStringType oneof_case_name(); TProtoStringType oneof_name(); TProtoStringType property_name(); TProtoStringType name(); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.cc index b80131b024d..8b5d09e5311 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -393,6 +393,13 @@ TProtoStringType GetPropertyName(const FieldDescriptor* descriptor) { return property_name; } +TProtoStringType GetOneofCaseName(const FieldDescriptor* descriptor) { + // The name in a oneof case enum is the same as for the property, but as we always have a "None" + // value as well, we need to reserve that by appending an underscore. + TProtoStringType property_name = GetPropertyName(descriptor); + return property_name == "None" ? "None_" : property_name; +} + TProtoStringType GetOutputFile(const FileDescriptor* descriptor, const TProtoStringType file_extension, const bool generate_directories, diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h index db93b6211ec..0a325464dcc 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -87,6 +87,8 @@ TProtoStringType GetFieldConstantName(const FieldDescriptor* field); TProtoStringType GetPropertyName(const FieldDescriptor* descriptor); +TProtoStringType GetOneofCaseName(const FieldDescriptor* descriptor); + int GetFixedSize(FieldDescriptor::Type type); TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input, diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.h index e8212498c95..b03f65b74a3 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_map_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__ -#include <string> - #include <google/protobuf/compiler/code_generator.h> #include <google/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc index cc966488f7c..e96b329cab0 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -238,8 +238,8 @@ void MessageGenerator::Generate(io::Printer* printer) { printer->Print("None = 0,\n"); for (int j = 0; j < oneof->field_count(); j++) { const FieldDescriptor* field = oneof->field(j); - printer->Print("$field_property_name$ = $index$,\n", - "field_property_name", GetPropertyName(field), + printer->Print("$oneof_case_name$ = $index$,\n", + "oneof_case_name", GetOneofCaseName(field), "index", StrCat(field->number())); } printer->Outdent(); @@ -403,10 +403,10 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) { for (int j = 0; j < oneof->field_count(); j++) { const FieldDescriptor* field = oneof->field(j); std::unique_ptr<FieldGeneratorBase> generator(CreateFieldGeneratorInternal(field)); - vars["field_property_name"] = GetPropertyName(field); + vars["oneof_case_name"] = GetOneofCaseName(field); printer->Print( vars, - "case $property_name$OneofCase.$field_property_name$:\n"); + "case $property_name$OneofCase.$oneof_case_name$:\n"); printer->Indent(); generator->GenerateCloningCode(printer); printer->Print("break;\n"); @@ -635,10 +635,10 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { printer->Indent(); for (int j = 0; j < oneof->field_count(); j++) { const FieldDescriptor* field = oneof->field(j); - vars["field_property_name"] = GetPropertyName(field); + vars["oneof_case_name"] = GetOneofCaseName(field); printer->Print( vars, - "case $property_name$OneofCase.$field_property_name$:\n"); + "case $property_name$OneofCase.$oneof_case_name$:\n"); printer->Indent(); std::unique_ptr<FieldGeneratorBase> generator(CreateFieldGeneratorInternal(field)); generator->GenerateMergingCode(printer); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 034fbd92427..487d01ddef3 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -225,7 +225,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n" " set {\n" " $oneof_name$_ = value;\n" - " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" + " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$oneof_case_name$;\n" " }\n" "}\n"); if (SupportsPresenceApi(descriptor_)) { @@ -236,7 +236,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { printer->Print( variables_, "$access_level$ bool Has$property_name$ {\n" - " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$property_name$; }\n" + " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$oneof_case_name$; }\n" "}\n"); printer->Print( variables_, diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.h index 1da8bea08df..2da1d71701f 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_message_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__ -#include <string> - #include <google/protobuf/compiler/code_generator.h> #include <google/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 9df1dd6abd7..e7d51168d17 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -296,7 +296,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { } printer->Print( variables_, - " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" + " $oneof_name$Case_ = $oneof_property_name$OneofCase.$oneof_case_name$;\n" " }\n" "}\n"); if (SupportsPresenceApi(descriptor_)) { @@ -307,7 +307,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { printer->Print( variables_, "$access_level$ bool Has$property_name$ {\n" - " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$property_name$; }\n" + " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$oneof_case_name$; }\n" "}\n"); printer->Print( variables_, diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.h index f0dbfad7911..e98c3698a00 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_primitive_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__ -#include <string> - #include <google/protobuf/compiler/code_generator.h> #include <google/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc index d462273c4a2..c142195cf53 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc @@ -128,7 +128,7 @@ void ReflectionClassGenerator::WriteIntroduction(io::Printer* printer) { "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" "// source: $file_name$\n" "// </auto-generated>\n" - "#pragma warning disable 1591, 0612, 3021\n" + "#pragma warning disable 1591, 0612, 3021, 8981\n" "#region Designer generated code\n" "\n" "using pb = global::Google.Protobuf;\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h index 23d3c0dabaa..6d6717cc022 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__ -#include <string> - #include <google/protobuf/compiler/code_generator.h> #include <google/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h index c584f2bd6f7..ea252ced34a 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__ -#include <string> - #include <google/protobuf/compiler/code_generator.h> #include <google/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h index 36be81d069d..2b470e12c9d 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__ -#include <string> - #include <google/protobuf/compiler/code_generator.h> #include <google/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc index 578f54ba697..e638dd862ae 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc @@ -233,7 +233,7 @@ void WrapperOneofFieldGenerator::GenerateMembers(io::Printer* printer) { " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : ($type_name$) null; }\n" " set {\n" " $oneof_name$_ = value;\n" - " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" + " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$oneof_case_name$;\n" " }\n" "}\n"); if (SupportsPresenceApi(descriptor_)) { @@ -244,7 +244,7 @@ void WrapperOneofFieldGenerator::GenerateMembers(io::Printer* printer) { printer->Print( variables_, "$access_level$ bool Has$property_name$ {\n" - " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$property_name$; }\n" + " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$oneof_case_name$; }\n" "}\n"); printer->Print( variables_, diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h index 57c4f5e76b4..cc8a3137d6e 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__ -#include <string> - #include <google/protobuf/compiler/code_generator.h> #include <google/protobuf/compiler/csharp/csharp_field_base.h> |