diff options
author | pg <pg@yandex-team.com> | 2023-02-08 14:47:59 +0300 |
---|---|---|
committer | pg <pg@yandex-team.com> | 2023-02-08 14:47:59 +0300 |
commit | 2999295666a93b51c9226cee88ea70b996d43727 (patch) | |
tree | 6cd1a5290a2653689a33c6269c0eebb7dd05729d /contrib/libs/protoc | |
parent | e615f3f87f0fc3dcc0d45c304883339ab1eab8c1 (diff) | |
download | ydb-2999295666a93b51c9226cee88ea70b996d43727.tar.gz |
3.19.0
Diffstat (limited to 'contrib/libs/protoc')
59 files changed, 1354 insertions, 955 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc index 7f065c8bbd..7731c611d1 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc @@ -402,8 +402,8 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { // implements GeneratorContext -------------------------------------- io::ZeroCopyOutputStream* Open(const TProtoStringType& filename) override; io::ZeroCopyOutputStream* OpenForAppend(const TProtoStringType& filename) override; - io::ZeroCopyOutputStream* OpenForInsert(const TProtoStringType& filename, - const TProtoStringType& insertion_point) override; + io::ZeroCopyOutputStream* OpenForInsert( + const TProtoStringType& filename, const TProtoStringType& insertion_point) override; io::ZeroCopyOutputStream* OpenForInsertWithGeneratedCodeInfo( const TProtoStringType& filename, const TProtoStringType& insertion_point, const google::protobuf::GeneratedCodeInfo& info) override; @@ -2487,8 +2487,8 @@ bool CommandLineInterface::WriteDescriptorSet( to_output.insert(parsed_files.begin(), parsed_files.end()); for (int i = 0; i < parsed_files.size(); i++) { const FileDescriptor* file = parsed_files[i]; - for (int i = 0; i < file->dependency_count(); i++) { - const FileDescriptor* dependency = file->dependency(i); + for (int j = 0; j < file->dependency_count(); j++) { + const FileDescriptor* dependency = file->dependency(j); // if the dependency isn't in parsed files, mark it as already seen if (to_output.find(dependency) == to_output.end()) { already_seen.insert(dependency); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc index 263dff4079..4ecd6a9cf7 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc @@ -409,10 +409,10 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) { TProtoStringType parent = ClassName(descriptor_->containing_type(), false); // Before C++17, we must define the static constants which were // declared in the header, to give the linker a place to put them. - // But pre-2015 MSVC++ insists that we not. + // But MSVC++ pre-2015 and post-2017 (version 15.5+) insists that we not. format( "#if (__cplusplus < 201703) && " - "(!defined(_MSC_VER) || _MSC_VER >= 1900)\n"); + "(!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))\n"); for (int i = 0; i < descriptor_->value_count(); i++) { format("constexpr $classname$ $1$::$2$;\n", parent, @@ -428,7 +428,7 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) { format( "#endif // (__cplusplus < 201703) && " - "(!defined(_MSC_VER) || _MSC_VER >= 1900)\n"); + "(!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))\n"); } } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index ce2a0e4591..79fa488b5f 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -334,106 +334,6 @@ void RepeatedEnumFieldGenerator::GenerateConstructorCode( // Not needed for repeated fields. } -void RepeatedEnumFieldGenerator::GenerateMergeFromCodedStream( - io::Printer* printer) const { - Formatter format(printer, variables_); - // Don't use ReadRepeatedPrimitive here so that the enum can be validated. - format( - "int value = 0;\n" - "DO_((::$proto_ns$::internal::WireFormatLite::ReadPrimitive<\n" - " int, ::$proto_ns$::internal::WireFormatLite::TYPE_ENUM>(\n" - " input, &value)));\n"); - if (HasPreservingUnknownEnumSemantics(descriptor_)) { - format("add_$name$(static_cast< $type$ >(value));\n"); - } else { - format( - "if ($type$_IsValid(value)) {\n" - " add_$name$(static_cast< $type$ >(value));\n"); - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - format( - "} else {\n" - " mutable_unknown_fields()->AddVarint(\n" - " $number$, static_cast<$uint64$>(value));\n"); - } else { - format( - "} else {\n" - " unknown_fields_stream.WriteVarint32(tag);\n" - " unknown_fields_stream.WriteVarint32(\n" - " static_cast<$uint32$>(value));\n"); - } - format("}\n"); - } -} - -void RepeatedEnumFieldGenerator::GenerateMergeFromCodedStreamWithPacking( - io::Printer* printer) const { - Formatter format(printer, variables_); - if (!descriptor_->is_packed()) { - // This path is rarely executed, so we use a non-inlined implementation. - if (HasPreservingUnknownEnumSemantics(descriptor_)) { - format( - "DO_((::$proto_ns$::internal::" - "WireFormatLite::ReadPackedEnumPreserveUnknowns(\n" - " input,\n" - " $number$,\n" - " nullptr,\n" - " nullptr,\n" - " this->_internal_mutable_$name$())));\n"); - } else if (UseUnknownFieldSet(descriptor_->file(), options_)) { - format( - "DO_((::$proto_ns$::internal::WireFormat::" - "ReadPackedEnumPreserveUnknowns(\n" - " input,\n" - " $number$,\n" - " $type$_IsValid,\n" - " mutable_unknown_fields(),\n" - " this->_internal_mutable_$name$())));\n"); - } else { - format( - "DO_((::$proto_ns$::internal::" - "WireFormatLite::ReadPackedEnumPreserveUnknowns(\n" - " input,\n" - " $number$,\n" - " $type$_IsValid,\n" - " &unknown_fields_stream,\n" - " this->_internal_mutable_$name$())));\n"); - } - } else { - format( - "$uint32$ length;\n" - "DO_(input->ReadVarint32(&length));\n" - "::$proto_ns$::io::CodedInputStream::Limit limit = " - "input->PushLimit(static_cast<int>(length));\n" - "while (input->BytesUntilLimit() > 0) {\n" - " int value = 0;\n" - " DO_((::$proto_ns$::internal::WireFormatLite::ReadPrimitive<\n" - " int, ::$proto_ns$::internal::WireFormatLite::TYPE_ENUM>(\n" - " input, &value)));\n"); - if (HasPreservingUnknownEnumSemantics(descriptor_)) { - format(" add_$name$(static_cast< $type$ >(value));\n"); - } else { - format( - " if ($type$_IsValid(value)) {\n" - " _internal_add_$name$(static_cast< $type$ >(value));\n" - " } else {\n"); - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - format( - " mutable_unknown_fields()->AddVarint(\n" - " $number$, static_cast<$uint64$>(value));\n"); - } else { - format( - " unknown_fields_stream.WriteVarint32(tag);\n" - " unknown_fields_stream.WriteVarint32(\n" - " static_cast<$uint32$>(value));\n"); - } - format(" }\n"); - } - format( - "}\n" - "input->PopLimit(limit);\n"); - } -} - void RepeatedEnumFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { Formatter format(printer, variables_); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h index 793ab2d793..e65ec0f5c0 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h @@ -98,8 +98,6 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { void GenerateSwappingCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* printer) const override {} - void GenerateMergeFromCodedStream(io::Printer* printer) const; - void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc index 23ab1bc0bb..72893b81c9 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc @@ -44,18 +44,6 @@ namespace protobuf { namespace compiler { namespace cpp { -namespace { - -// Returns the fully-qualified class name of the message that this field -// extends. This function is used in the Google-internal code to handle some -// legacy cases. -TProtoStringType ExtendeeClassName(const FieldDescriptor* descriptor) { - const Descriptor* extendee = descriptor->containing_type(); - return ClassName(extendee, true); -} - -} // anonymous namespace - ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor, const Options& options, MessageSCCAnalyzer* scc_analyzer) @@ -88,7 +76,8 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor, break; } SetCommonVars(options, &variables_); - variables_["extendee"] = ExtendeeClassName(descriptor_); + variables_["extendee"] = + QualifiedClassName(descriptor_->containing_type(), options_); variables_["type_traits"] = type_traits_; TProtoStringType name = descriptor_->name(); variables_["name"] = ResolveKeyword(name); @@ -169,7 +158,7 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) { // Likewise, class members need to declare the field constant variable. if (IsScoped()) { format( - "#if !defined(_MSC_VER) || _MSC_VER >= 1900\n" + "#if !defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)\n" "const int $scope$$constant_name$;\n" "#endif\n"); } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc index 0a5d2cd772..5f167a4d01 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc @@ -340,7 +340,7 @@ FieldGenerator* FieldGeneratorMap::MakeGenerator( switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_MESSAGE: if (field->is_map()) { - return new MapFieldGenerator(field, options); + return new MapFieldGenerator(field, options, scc_analyzer); } else { return new RepeatedMessageFieldGenerator(field, options, scc_analyzer); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h index 8d50f88f12..e3386f446a 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h @@ -181,6 +181,10 @@ class FieldGenerator { // are placed in the message's ByteSize() method. virtual void GenerateByteSize(io::Printer* printer) const = 0; + // Generates lines to call IsInitialized() for eligible message fields. Non + // message fields won't need to override this function. + virtual void GenerateIsInitialized(io::Printer* printer) const {} + virtual bool IsInlined() const { return false; } void SetHasBitIndex(arc_i32 has_bit_index); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc index 6e3f174c5b..681e16a947 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -155,8 +155,8 @@ void FileGenerator::GenerateMacroUndefs(io::Printer* printer) { for (int i = 0; i < fields.size(); i++) { const TProtoStringType& name = fields[i]->name(); static const char* kMacroNames[] = {"major", "minor"}; - for (int i = 0; i < GOOGLE_ARRAYSIZE(kMacroNames); ++i) { - if (name == kMacroNames[i]) { + for (int j = 0; j < GOOGLE_ARRAYSIZE(kMacroNames); ++j) { + if (name == kMacroNames[j]) { names_to_undef.push_back(name); break; } @@ -1211,7 +1211,8 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { IncludeFile("net/proto2/io/public/coded_stream.h", printer); IncludeFile("net/proto2/public/arena.h", printer); IncludeFile("net/proto2/public/arenastring.h", printer); - if (options_.force_inline_string || options_.profile_driven_inline_string) { + if ((options_.force_inline_string || options_.profile_driven_inline_string) && + !options_.opensource_runtime) { IncludeFile("net/proto2/public/inlined_string_field.h", printer); } if (HasSimpleBaseClasses(file_, options_)) { diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc index c5aa700c24..5191a7e730 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -58,6 +58,7 @@ #include <google/protobuf/stubs/substitute.h> #include <google/protobuf/stubs/hash.h> +// Must be last. #include <google/protobuf/port_def.inc> namespace google { @@ -174,11 +175,7 @@ static std::unordered_set<TProtoStringType>* MakeKeywordsMap() { static std::unordered_set<TProtoStringType>& kKeywords = *MakeKeywordsMap(); TProtoStringType IntTypeName(const Options& options, const TProtoStringType& type) { - if (options.opensource_runtime) { - return "::PROTOBUF_NAMESPACE_ID::" + type; - } else { - return "::" + type; - } + return "::NProtoBuf::" + type; } void SetIntVar(const Options& options, const TProtoStringType& type, @@ -460,6 +457,19 @@ TProtoStringType FieldName(const FieldDescriptor* field) { return result; } +TProtoStringType OneofCaseConstantName(const FieldDescriptor* field) { + GOOGLE_DCHECK(field->containing_oneof()); + TProtoStringType field_name = UnderscoresToCamelCase(field->name(), true); + return "k" + field_name; +} + +TProtoStringType QualifiedOneofCaseConstantName(const FieldDescriptor* field) { + GOOGLE_DCHECK(field->containing_oneof()); + const TProtoStringType qualification = + QualifiedClassName(field->containing_type()); + return StrCat(qualification, "::", OneofCaseConstantName(field)); +} + TProtoStringType EnumValueName(const EnumValueDescriptor* enum_value) { TProtoStringType result = enum_value->name(); if (kKeywords.count(result) > 0) { @@ -526,13 +536,13 @@ TProtoStringType StripProto(const TProtoStringType& filename) { const char* PrimitiveTypeName(FieldDescriptor::CppType type) { switch (type) { case FieldDescriptor::CPPTYPE_INT32: - return "::google::protobuf::int32"; + return "arc_i32"; case FieldDescriptor::CPPTYPE_INT64: - return "::google::protobuf::int64"; + return "arc_i64"; case FieldDescriptor::CPPTYPE_UINT32: - return "::google::protobuf::uint32"; + return "arc_ui32"; case FieldDescriptor::CPPTYPE_UINT64: - return "::google::protobuf::uint64"; + return "arc_ui64"; case FieldDescriptor::CPPTYPE_DOUBLE: return "double"; case FieldDescriptor::CPPTYPE_FLOAT: @@ -781,8 +791,10 @@ TProtoStringType SafeFunctionName(const Descriptor* descriptor, return function_name; } -bool IsStringInlined(const FieldDescriptor* /* descriptor */, - const Options& /* options */) { +bool IsStringInlined(const FieldDescriptor* descriptor, + const Options& options) { + (void)descriptor; + (void)options; return false; } @@ -943,15 +955,19 @@ bool HasEnumDefinitions(const FileDescriptor* file) { return false; } -bool ShouldVerify(const Descriptor* /* descriptor */, - const Options& /* options */, - MessageSCCAnalyzer* /* scc_analyzer */) { +bool ShouldVerify(const Descriptor* descriptor, const Options& options, + MessageSCCAnalyzer* scc_analyzer) { + (void)descriptor; + (void)options; + (void)scc_analyzer; return false; } -bool ShouldVerify(const FileDescriptor* /* file */, - const Options& /* options */, - MessageSCCAnalyzer* /* scc_analyzer */) { +bool ShouldVerify(const FileDescriptor* file, const Options& options, + MessageSCCAnalyzer* scc_analyzer) { + (void)file; + (void)options; + (void)scc_analyzer; return false; } @@ -1156,8 +1172,8 @@ MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) { if (descriptor->extension_range_count() > 0) { result.contains_extension = true; } - for (int i = 0; i < descriptor->field_count(); i++) { - const FieldDescriptor* field = descriptor->field(i); + for (int j = 0; j < descriptor->field_count(); j++) { + const FieldDescriptor* field = descriptor->field(j); if (field->is_required()) { result.contains_required = true; } @@ -1474,7 +1490,8 @@ FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, return FileOptions::SPEED; } -bool EnableMessageOwnedArena(const Descriptor* /* desc */) { +bool EnableMessageOwnedArena(const Descriptor* desc) { + (void)desc; return false; } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h index 8923903452..12c8cdbde1 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -63,8 +63,8 @@ inline TProtoStringType ProtobufNamespace(const Options& /* options */) { return "PROTOBUF_NAMESPACE_ID"; } -inline TProtoStringType MacroPrefix(const Options& options) { - return options.opensource_runtime ? "GOOGLE_PROTOBUF" : "GOOGLE_PROTOBUF"; +inline TProtoStringType MacroPrefix(const Options& /* options */) { + return "GOOGLE_PROTOBUF"; } inline TProtoStringType DeprecatedAttribute(const Options& /* options */, @@ -743,6 +743,27 @@ class PROTOC_EXPORT Formatter { void Outdent() const { printer_->Outdent(); } io::Printer* printer() const { return printer_; } + class PROTOC_EXPORT ScopedIndenter { + public: + explicit ScopedIndenter(Formatter* format) : format_(format) { + format_->Indent(); + } + ~ScopedIndenter() { format_->Outdent(); } + + private: + Formatter* format_; + }; + + PROTOBUF_NODISCARD ScopedIndenter ScopedIndent() { + return ScopedIndenter(this); + } + template <typename... Args> + PROTOBUF_NODISCARD ScopedIndenter ScopedIndent(const char* format, + const Args&&... args) { + (*this)(format, static_cast<Args&&>(args)...); + return ScopedIndenter(this); + } + class PROTOC_EXPORT SaveState { public: explicit SaveState(Formatter* format) diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc index f8e1c380cc..c5028fdb1d 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -84,8 +84,11 @@ void SetMessageVariables(const FieldDescriptor* descriptor, } MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : FieldGenerator(descriptor, options) { + const Options& options, + MessageSCCAnalyzer* scc_analyzer) + : FieldGenerator(descriptor, options), + has_required_fields_( + scc_analyzer->HasRequiredFields(descriptor->message_type())) { SetMessageVariables(descriptor, &variables_, options); } @@ -293,6 +296,15 @@ void MapFieldGenerator::GenerateByteSize(io::Printer* printer) const { "}\n"); } +void MapFieldGenerator::GenerateIsInitialized(io::Printer* printer) const { + if (!has_required_fields_) return; + + Formatter format(printer, variables_); + format( + "if (!::$proto_ns$::internal::AllAreInitialized($name$_)) return " + "false;\n"); +} + void MapFieldGenerator::GenerateConstinitInitializer( io::Printer* printer) const { Formatter format(printer, variables_); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h index 5ea04290e6..c01ae498b1 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h @@ -34,6 +34,7 @@ #include <map> #include <string> +#include <google/protobuf/compiler/cpp/cpp_helpers.h> #include <google/protobuf/compiler/cpp/cpp_message_field.h> namespace google { @@ -43,8 +44,9 @@ namespace cpp { class MapFieldGenerator : public FieldGenerator { public: - MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options); - ~MapFieldGenerator(); + MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options, + MessageSCCAnalyzer* scc_analyzer); + ~MapFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const override; @@ -58,10 +60,13 @@ class MapFieldGenerator : public FieldGenerator { void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; + void GenerateIsInitialized(io::Printer* printer) const override; void GenerateConstinitInitializer(io::Printer* printer) const override; bool GenerateArenaDestructorCode(io::Printer* printer) const override; private: + const bool has_required_fields_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator); }; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc index 062b2bb754..4b5e0f2e95 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -230,12 +230,22 @@ bool EmitFieldNonDefaultCondition(io::Printer* printer, } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // Message fields still have has_$name$() methods. format("if ($prefix$_internal_has_$name$()) {\n"); - } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE || - field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT) { - // Handle float comparison to prevent -Wfloat-equal warnings + } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT) { format( - "if (!($prefix$_internal_$name$() <= 0 && $prefix$_internal_$name$() " - ">= 0)) {\n"); + "static_assert(sizeof(arc_ui32) == sizeof(float), \"Code assumes " + "arc_ui32 and float are the same size.\");\n" + "float tmp_$name$ = $prefix$_internal_$name$();\n" + "arc_ui32 raw_$name$;\n" + "memcpy(&raw_$name$, &tmp_$name$, sizeof(tmp_$name$));\n" + "if (raw_$name$ != 0) {\n"); + } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE) { + format( + "static_assert(sizeof(arc_ui64) == sizeof(double), \"Code assumes " + "arc_ui64 and double are the same size.\");\n" + "double tmp_$name$ = $prefix$_internal_$name$();\n" + "arc_ui64 raw_$name$;\n" + "memcpy(&raw_$name$, &tmp_$name$, sizeof(tmp_$name$));\n" + "if (raw_$name$ != 0) {\n"); } else { format("if ($prefix$_internal_$name$() != 0) {\n"); } @@ -974,7 +984,7 @@ $annotate_extension_set$ template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, bool _is_packed> -inline PROTOBUF_MUST_USE_RESULT +PROTOBUF_NODISCARD inline typename _proto_TypeTraits::Singular::MutableType ReleaseExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< @@ -1437,7 +1447,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { if (EnableMessageOwnedArena(descriptor_)) { format( "inline $classname$() : $classname$(" - "new ::$proto_ns$::Arena(), true) {}\n"); + "::$proto_ns$::Arena::InternalHelper<$classname$>::\n" + " CreateMessageOwnedArena(), true) {}\n"); } else { format("inline $classname$() : $classname$(nullptr) {}\n"); } @@ -1530,10 +1541,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format("enum $1$Case {\n", UnderscoresToCamelCase(oneof->name(), true)); format.Indent(); for (auto field : FieldRange(oneof)) { - TProtoStringType oneof_enum_case_field_name = - UnderscoresToCamelCase(field->name(), true); - format("k$1$ = $2$,\n", oneof_enum_case_field_name, // 1 - field->number()); // 2 + format("$1$ = $2$,\n", OneofCaseConstantName(field), // 1 + field->number()); // 2 } format("$1$_NOT_SET = 0,\n", ToUpper(oneof->name())); format.Outdent(); @@ -1565,7 +1574,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "bool PackFrom(const ::$proto_ns$::Message& message,\n" " ::PROTOBUF_NAMESPACE_ID::ConstStringParam " "type_url_prefix) {\n" - " return _any_metadata_.PackFrom(GetArena(), message, type_url_prefix);\n" + " return _any_metadata_.PackFrom(GetArena(), message, " + "type_url_prefix);\n" "}\n" "bool UnpackTo(::$proto_ns$::Message* message) const {\n" " return _any_metadata_.UnpackTo(message);\n" @@ -1586,7 +1596,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "bool PackFrom(const T& message,\n" " ::PROTOBUF_NAMESPACE_ID::ConstStringParam " "type_url_prefix) {\n" - " return _any_metadata_.PackFrom<T>(GetArena(), message, type_url_prefix);" + " return _any_metadata_.PackFrom<T>(GetArena(), message, " + "type_url_prefix);" "}\n" "template <typename T, class = typename std::enable_if<" "!std::is_convertible<T, const ::$proto_ns$::Message&>" @@ -1598,13 +1609,14 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format( "template <typename T>\n" "bool PackFrom(const T& message) {\n" - " return _any_metadata_.PackFrom(message);\n" + " return _any_metadata_.PackFrom(GetArena(), message);\n" "}\n" "template <typename T>\n" "bool PackFrom(const T& message,\n" " ::PROTOBUF_NAMESPACE_ID::ConstStringParam " "type_url_prefix) {\n" - " return _any_metadata_.PackFrom(message, type_url_prefix);\n" + " return _any_metadata_.PackFrom(GetArena(), message, " + "type_url_prefix);\n" "}\n" "template <typename T>\n" "bool UnpackTo(T* message) const {\n" @@ -1626,12 +1638,12 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "}\n" "inline void Swap($classname$* other) {\n" " if (other == this) return;\n" -#ifdef PROTOBUF_FORCE_COPY_IN_SWAP + "#ifdef PROTOBUF_FORCE_COPY_IN_SWAP\n" " if (GetOwningArena() != nullptr &&\n" - " GetOwningArena() == other->GetOwningArena()) {\n" -#else // PROTOBUF_FORCE_COPY_IN_SWAP + " GetOwningArena() == other->GetOwningArena()) {\n " + "#else // PROTOBUF_FORCE_COPY_IN_SWAP\n" " if (GetOwningArena() == other->GetOwningArena()) {\n" -#endif // !PROTOBUF_FORCE_COPY_IN_SWAP + "#endif // !PROTOBUF_FORCE_COPY_IN_SWAP\n" " InternalSwap(other);\n" " } else {\n" " ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);\n" @@ -1647,11 +1659,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "\n" "// implements Message ----------------------------------------------\n" "\n" - "inline $classname$* New() const final {\n" - " return new $classname$();\n" - "}\n" - "\n" - "$classname$* New(::$proto_ns$::Arena* arena) const final {\n" + "$classname$* New(::$proto_ns$::Arena* arena = nullptr) const final {\n" " return CreateMaybeMessage<$classname$>(arena);\n" "}\n"); @@ -1714,12 +1722,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "$uint8$* _InternalSerialize(\n" " $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) " "const final;\n"); - - // DiscardUnknownFields() is implemented in message.cc using reflections. - // We need to implement this function in generated code for messages. - if (!UseUnknownFieldSet(descriptor_->file(), options_)) { - format("void DiscardUnknownFields()$ full_final$;\n"); - } } } @@ -1740,6 +1742,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format( // Friend AnyMetadata so that it can call this FullMessageName() method. + "\nprivate:\n" "friend class ::$proto_ns$::internal::AnyMetadata;\n" "static $1$ FullMessageName() {\n" " return \"$full_name$\";\n" @@ -2744,19 +2747,22 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( // Some information about a field is in the pdproto profile. The profile is // only available at compile time. So we embed such information in the - // offset of the field, so that the information is available when reflective - // accessing the field at run time. + // offset of the field, so that the information is available when + // reflectively accessing the field at run time. // // Embed whether the field is used to the MSB of the offset. if (!IsFieldUsed(field, options_)) { - format(" | 0x80000000u, // unused\n"); - } else if (IsEagerlyVerifiedLazy(field, options_, scc_analyzer_)) { - format(" | 0x1u, // eagerly verified lazy\n"); + format(" | 0x80000000u // unused\n"); + } + + // Embed whether the field is eagerly verified lazy or inlined string to the + // LSB of the offset. + if (IsEagerlyVerifiedLazy(field, options_, scc_analyzer_)) { + format(" | 0x1u // eagerly verified lazy\n"); } else if (IsStringInlined(field, options_)) { - format(" | 0x1u, // inlined\n"); - } else { - format(",\n"); + format(" | 0x1u // inlined\n"); } + format(",\n"); } int count = 0; @@ -2796,7 +2802,7 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) { if (HasSimpleBaseClass(descriptor_, options_)) return; Formatter format(printer, variables_); - format("void $classname$::SharedCtor() {\n"); + format("inline void $classname$::SharedCtor() {\n"); std::vector<bool> processed(optimized_order_.size(), false); GenerateConstructorBody(printer, processed, false); @@ -3119,7 +3125,9 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { "metadata_);\n"); if (descriptor_->extension_range_count() > 0) { - format("_extensions_.MergeFrom(from._extensions_);\n"); + format( + "_extensions_.MergeFrom(internal_default_instance(), " + "from._extensions_);\n"); } GenerateConstructorBody(printer, processed, true); @@ -3714,7 +3722,9 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { // Merging of extensions and unknown fields is done last, to maximize // the opportunity for tail calls. if (descriptor_->extension_range_count() > 0) { - format("_extensions_.MergeFrom(from._extensions_);\n"); + format( + "_extensions_.MergeFrom(internal_default_instance(), " + "from._extensions_);\n"); } format( @@ -4516,42 +4526,7 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { // Now check that all non-oneof embedded messages are initialized. for (auto field : optimized_order_) { - // TODO(ckennelly): Push this down into a generator? - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !ShouldIgnoreRequiredFieldCheck(field, options_) && - scc_analyzer_->HasRequiredFields(field->message_type())) { - if (field->is_repeated()) { - if (IsImplicitWeakField(field, options_, scc_analyzer_)) { - format( - "if " - "(!::$proto_ns$::internal::AllAreInitializedWeak($1$_.weak)" - ")" - " return false;\n", - FieldName(field)); - } else { - format( - "if (!::$proto_ns$::internal::AllAreInitialized($1$_))" - " return false;\n", - FieldName(field)); - } - } else if (field->options().weak()) { - continue; - } else if (IsEagerlyVerifiedLazy(field, options_, scc_analyzer_)) { - GOOGLE_CHECK(!field->real_containing_oneof()); - format( - "if (_internal_has_$1$()) {\n" - " if (!$1$().IsInitialized()) return false;\n" - "}\n", - FieldName(field)); - } else { - GOOGLE_CHECK(!field->real_containing_oneof()); - format( - "if (_internal_has_$1$()) {\n" - " if (!$1$_->IsInitialized()) return false;\n" - "}\n", - FieldName(field)); - } - } + field_generators_.get(field).GenerateIsInitialized(printer); } if (num_weak_fields_) { // For Weak fields. @@ -4579,23 +4554,9 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { for (auto field : FieldRange(oneof)) { format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format.Indent(); - - if (!IsFieldStripped(field, options_) && - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !ShouldIgnoreRequiredFieldCheck(field, options_) && - scc_analyzer_->HasRequiredFields(field->message_type())) { - GOOGLE_CHECK(!(field->options().weak() || !field->real_containing_oneof())); - if (field->options().weak()) { - // Just skip. - } else { - format( - "if (has_$1$()) {\n" - " if (!this->$1$().IsInitialized()) return false;\n" - "}\n", - FieldName(field)); - } + if (!IsFieldStripped(field, options_)) { + field_generators_.get(field).GenerateIsInitialized(printer); } - format("break;\n"); format.Outdent(); format("}\n"); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc index 720ce273bd..04f45492c3 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -87,7 +87,9 @@ MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor, MessageSCCAnalyzer* scc_analyzer) : FieldGenerator(descriptor, options), implicit_weak_field_( - IsImplicitWeakField(descriptor, options, scc_analyzer)) { + IsImplicitWeakField(descriptor, options, scc_analyzer)), + has_required_fields_( + scc_analyzer->HasRequiredFields(descriptor->message_type())) { SetMessageVariables(descriptor, options, implicit_weak_field_, &variables_); } @@ -109,7 +111,7 @@ void MessageFieldGenerator::GenerateAccessorDeclarations( format( "$deprecated_attr$const $type$& ${1$$name$$}$() const { " "__builtin_trap(); }\n" - "PROTOBUF_MUST_USE_RESULT $deprecated_attr$$type$* " + "PROTOBUF_NODISCARD $deprecated_attr$$type$* " "${1$$release_name$$}$() { " "__builtin_trap(); }\n" "$deprecated_attr$$type$* ${1$mutable_$name$$}$() { " @@ -126,7 +128,7 @@ void MessageFieldGenerator::GenerateAccessorDeclarations( } format( "$deprecated_attr$const $type$& ${1$$name$$}$() const;\n" - "PROTOBUF_MUST_USE_RESULT $deprecated_attr$$type$* " + "PROTOBUF_NODISCARD $deprecated_attr$$type$* " "${1$$release_name$$}$();\n" "$deprecated_attr$$type$* ${1$mutable_$name$$}$();\n" "$deprecated_attr$void ${1$set_allocated_$name$$}$" @@ -480,6 +482,18 @@ void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const { " *$field_member$);\n"); } +void MessageFieldGenerator::GenerateIsInitialized(io::Printer* printer) const { + GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); + + if (!has_required_fields_) return; + + Formatter format(printer, variables_); + format( + "if (_internal_has_$name$()) {\n" + " if (!$name$_->IsInitialized()) return false;\n" + "}\n"); +} + void MessageFieldGenerator::GenerateConstinitInitializer( io::Printer* printer) const { Formatter format(printer, variables_); @@ -641,6 +655,17 @@ void MessageOneofFieldGenerator::GenerateConstructorCode( // space only when this field is used. } +void MessageOneofFieldGenerator::GenerateIsInitialized( + io::Printer* printer) const { + if (!has_required_fields_) return; + + Formatter format(printer, variables_); + format( + "if (_internal_has_$name$()) {\n" + " if (!$field_member$->IsInitialized()) return false;\n" + "}\n"); +} + // =================================================================== RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator( @@ -648,7 +673,9 @@ RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator( MessageSCCAnalyzer* scc_analyzer) : FieldGenerator(descriptor, options), implicit_weak_field_( - IsImplicitWeakField(descriptor, options, scc_analyzer)) { + IsImplicitWeakField(descriptor, options, scc_analyzer)), + has_required_fields_( + scc_analyzer->HasRequiredFields(descriptor->message_type())) { SetMessageVariables(descriptor, options, implicit_weak_field_, &variables_); } @@ -835,6 +862,24 @@ void RepeatedMessageFieldGenerator::GenerateByteSize( "}\n"); } +void RepeatedMessageFieldGenerator::GenerateIsInitialized( + io::Printer* printer) const { + GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); + + if (!has_required_fields_) return; + + Formatter format(printer, variables_); + if (implicit_weak_field_) { + format( + "if (!::$proto_ns$::internal::AllAreInitializedWeak($name$_.weak))\n" + " return false;\n"); + } else { + format( + "if (!::$proto_ns$::internal::AllAreInitialized($name$_))\n" + " return false;\n"); + } +} + void RepeatedMessageFieldGenerator::GenerateConstinitInitializer( io::Printer* printer) const { Formatter format(printer, variables_); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h index 712ddbfea1..2beac6253b 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h @@ -50,7 +50,7 @@ class MessageFieldGenerator : public FieldGenerator { MessageFieldGenerator(const FieldDescriptor* descriptor, const Options& options, MessageSCCAnalyzer* scc_analyzer); - ~MessageFieldGenerator(); + ~MessageFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const override; @@ -71,10 +71,12 @@ class MessageFieldGenerator : public FieldGenerator { void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; + void GenerateIsInitialized(io::Printer* printer) const override; void GenerateConstinitInitializer(io::Printer* printer) const override; protected: const bool implicit_weak_field_; + const bool has_required_fields_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); @@ -85,7 +87,7 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { MessageOneofFieldGenerator(const FieldDescriptor* descriptor, const Options& options, MessageSCCAnalyzer* scc_analyzer); - ~MessageOneofFieldGenerator(); + ~MessageOneofFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override; @@ -99,6 +101,7 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { void GenerateSwappingCode(io::Printer* printer) const override; void GenerateDestructorCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override; + void GenerateIsInitialized(io::Printer* printer) const override; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator); @@ -109,7 +112,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, const Options& options, MessageSCCAnalyzer* scc_analyzer); - ~RepeatedMessageFieldGenerator(); + ~RepeatedMessageFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const override; @@ -123,10 +126,12 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; + void GenerateIsInitialized(io::Printer* printer) const override; void GenerateConstinitInitializer(io::Printer* printer) const override; private: const bool implicit_weak_field_; + const bool has_required_fields_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); }; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h index 877908f7ad..8b745ff21c 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_names.h @@ -73,6 +73,12 @@ TProtoStringType QualifiedExtensionName(const FieldDescriptor* d); // anyway, so normally this just returns field->name(). TProtoStringType FieldName(const FieldDescriptor* field); +// Requires that this field is in a oneof. Returns the (unqualified) case +// constant for this field. +TProtoStringType OneofCaseConstantName(const FieldDescriptor* field); +// Returns the quafilied case constant for this field. +TProtoStringType QualifiedOneofCaseConstantName(const FieldDescriptor* field); + // Get the (unqualified) name that should be used for this enum value in C++ // code. TProtoStringType EnumValueName(const EnumValueDescriptor* enum_value); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h index bc174c3d6e..23adb91430 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h @@ -71,7 +71,7 @@ struct Options { bool opensource_runtime = false; bool annotate_accessor = false; bool unused_field_stripping = false; - bool profile_driven_inline_string = false; + bool profile_driven_inline_string = true; bool force_inline_string = false; TProtoStringType runtime_include_base; int num_cc_files = 0; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc index ac3e57cda8..282d70e391 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc @@ -81,9 +81,9 @@ const char* TagType(const FieldDescriptor* field) { return CodedTagType(TagSize(field->number())); } -TProtoStringType TcParserBaseName(const Options& options) { +TProtoStringType TcParserName(const Options& options) { return StrCat("::", ProtobufNamespace(options), - "::internal::TcParserBase::"); + "::internal::TcParser::"); } TProtoStringType MessageTcParseFunctionName(const FieldDescriptor* field, @@ -93,8 +93,8 @@ TProtoStringType MessageTcParseFunctionName(const FieldDescriptor* field, // For files with `option optimize_for = CODE_SIZE`, or which derive from // `ZeroFieldsBase`, we need to call the `_InternalParse` function, because // there is no generated tailcall function. For tailcall parsing, this is - // done by helpers in TcParserBase. - return StrCat(TcParserBaseName(options), + // done by helpers in TcParser. + return StrCat(TcParserName(options), (field->is_repeated() ? "Repeated" : "Singular"), "ParseMessage<", QualifiedClassName(field->message_type()), // @@ -108,8 +108,7 @@ TProtoStringType MessageTcParseFunctionName(const FieldDescriptor* field, } TProtoStringType FieldParseFunctionName(const FieldDescriptor* field, - const Options& options, - arc_ui32 table_size_log2); + const Options& options); } // namespace @@ -209,14 +208,14 @@ TailCallTableInfo::TailCallTableInfo(const Descriptor* descriptor, case FieldDescriptor::TYPE_SINT64: case FieldDescriptor::TYPE_SINT32: case FieldDescriptor::TYPE_BOOL: - name = FieldParseFunctionName(field, options, table_size_log2); + name = FieldParseFunctionName(field, options); break; case FieldDescriptor::TYPE_BYTES: if (field->options().ctype() == FieldOptions::STRING && field->default_value_string().empty() && !IsStringInlined(field, options)) { - name = FieldParseFunctionName(field, options, table_size_log2); + name = FieldParseFunctionName(field, options); } break; @@ -365,9 +364,8 @@ void ParseFunctionGenerator::GenerateTailcallParseFunction(Formatter& format) { "const char* $classname$::_InternalParse(\n" " const char* ptr, ::$proto_ns$::internal::ParseContext* ctx) {\n" "$annotate_deserialize$" - " ptr = ::$proto_ns$::internal::TcParser<$1$>::ParseLoop(\n" - " this, ptr, ctx, &_table_.header);\n", - tc_table_info_->table_size_log2); + " ptr = ::$proto_ns$::internal::TcParser::ParseLoop(\n" + " this, ptr, ctx, &_table_.header);\n"); format( " return ptr;\n" "}\n\n"); @@ -426,9 +424,9 @@ void ParseFunctionGenerator::GenerateTailcallFieldParseFunctions( "return table->fallback(PROTOBUF_TC_PARAM_PASS);\n" " ptr += $1$;\n" " hasbits |= (arc_ui64{1} << data.hasbit_idx());\n" - " ::$proto_ns$::internal::TcParserBase::SyncHasbits" + " ::$proto_ns$::internal::TcParser::SyncHasbits" "(msg, hasbits, table);\n" - " auto& field = ::$proto_ns$::internal::TcParserBase::" + " auto& field = ::$proto_ns$::internal::TcParser::" "RefAt<$classtype$*>(msg, data.offset());\n" " if (field == nullptr)\n" " field = CreateMaybeMessage<$classtype$>(ctx->data().arena);\n" @@ -448,9 +446,9 @@ void ParseFunctionGenerator::GenerateTailcallFieldParseFunctions( "return table->fallback(PROTOBUF_TC_PARAM_PASS);\n" " }\n" " ptr += $1$;\n" - " auto& field = ::$proto_ns$::internal::TcParserBase::RefAt<" + " auto& field = ::$proto_ns$::internal::TcParser::RefAt<" "::$proto_ns$::RepeatedPtrField<$classname$>>(msg, data.offset());\n" - " ::$proto_ns$::internal::TcParserBase::SyncHasbits" + " ::$proto_ns$::internal::TcParser::SyncHasbits" "(msg, hasbits, table);\n" " ptr = ctx->ParseMessage(field.Add(), ptr);\n" " return ptr;\n" @@ -471,7 +469,7 @@ void ParseFunctionGenerator::GenerateDataDecls(io::Printer* printer) { format.Indent(); } format( - "static const ::$proto_ns$::internal::TailCallParseTable<$1$>\n" + "static const ::$proto_ns$::internal::TcParseTable<$1$>\n" " _table_;\n", tc_table_info_->table_size_log2); if (should_generate_guarded_tctable()) { @@ -546,7 +544,7 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) { if (tc_table_info_->use_generated_fallback) { fallback = ClassName(descriptor_) + "::Tct_ParseFallback"; } else { - fallback = TcParserBaseName(options_) + "GenericFallback"; + fallback = TcParserName(options_) + "GenericFallback"; if (GetOptimizeFor(descriptor_->file(), options_) == FileOptions::LITE_RUNTIME) { fallback += "Lite"; @@ -561,33 +559,48 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) { // the table is sufficient we can use a generic routine, that just handles // unknown fields and potentially an extension range. format( - "const ::$proto_ns$::internal::TailCallParseTable<$1$>\n" + "const ::$proto_ns$::internal::TcParseTable<$1$>\n" " $classname$::_table_ = {\n", tc_table_info_->table_size_log2); - format.Indent(); - format("{\n"); - format.Indent(); - if (num_hasbits_ > 0 || IsMapEntryMessage(descriptor_)) { - format("PROTOBUF_FIELD_OFFSET($classname$, _has_bits_),\n"); - } else { - format("0, // no _has_bits_\n"); - } - if (descriptor_->extension_range_count() == 1) { - format( - "PROTOBUF_FIELD_OFFSET($classname$, _extensions_),\n" - "$1$, $2$, // extension_range_{low,high}\n", - descriptor_->extension_range(0)->start, - descriptor_->extension_range(0)->end); - } else { - format("0, 0, 0, // no _extensions_\n"); + { + auto table_scope = format.ScopedIndent(); + format("{\n"); + { + auto header_scope = format.ScopedIndent(); + if (num_hasbits_ > 0 || IsMapEntryMessage(descriptor_)) { + format("PROTOBUF_FIELD_OFFSET($classname$, _has_bits_),\n"); + } else { + format("0, // no _has_bits_\n"); + } + if (descriptor_->extension_range_count() == 1) { + format( + "PROTOBUF_FIELD_OFFSET($classname$, _extensions_),\n" + "$1$, $2$, // extension_range_{low,high}\n", + descriptor_->extension_range(0)->start, + descriptor_->extension_range(0)->end); + } else { + format("0, 0, 0, // no _extensions_\n"); + } + format( + "$1$, 0, $2$, // fast_idx_mask, reserved, num_fields\n" + "&$3$._instance,\n" + "$4$ // fallback\n", + (((1 << tc_table_info_->table_size_log2) - 1) << 3), + descriptor_->field_count(), + DefaultInstanceName(descriptor_, options_), fallback); + } + format("}, {\n"); + { + auto fast_scope = format.ScopedIndent(); + GenerateFastFieldEntries(format, fallback); + } + format("},\n"); // entries[] } - format( - "&$1$._instance,\n" - "$2$ // fallback\n", - DefaultInstanceName(descriptor_, options_), fallback); - format.Outdent(); - format("}, {\n"); - format.Indent(); + format("};\n\n"); // _table_ +} + +void ParseFunctionGenerator::GenerateFastFieldEntries( + Formatter& format, const TProtoStringType& fallback) { for (const auto& info : tc_table_info_->fast_path_fields) { if (info.field != nullptr) { PrintFieldComment(format, info.field); @@ -604,10 +617,6 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) { } format("},\n"); } - format.Outdent(); - format("},\n"); // entries[] - format.Outdent(); - format("};\n\n"); // _table_ } void ParseFunctionGenerator::GenerateArenaString(Formatter& format, @@ -634,6 +643,8 @@ void ParseFunctionGenerator::GenerateArenaString(Formatter& format, ", ~0x$2$u", inlined_string_index / 32, strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8)); + } else { + GOOGLE_DCHECK(field->default_value_string().empty()); } format( ");\n" @@ -766,15 +777,22 @@ void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format, "$msg$GetArenaForAllocation());\n" " $msg$set_has_$name$();\n" "}\n" - "ptr = ctx->ParseMessage($msg$$1$_.$name$_, ptr);\n", + "auto* lazy_field = $msg$$1$_.$name$_;\n", field->containing_oneof()->name()); } else if (HasHasbit(field)) { format( "_Internal::set_has_$name$(&$has_bits$);\n" - "ptr = ctx->ParseMessage(&$msg$$name$_, ptr);\n"); + "auto* lazy_field = &$msg$$name$_;\n"); } else { - format("ptr = ctx->ParseMessage(&$msg$$name$_, ptr);\n"); + format("auto* lazy_field = &$msg$$name$_;\n"); } + format( + "::$proto_ns$::internal::LazyFieldParseHelper<\n" + " ::$proto_ns$::internal::LazyField> parse_helper(\n" + " $1$::default_instance(),\n" + " $msg$GetArenaForAllocation(), lazy_field);\n" + "ptr = ctx->ParseMessage(&parse_helper, ptr);\n", + FieldMessageTypeName(field, options_)); } else if (IsImplicitWeakField(field, options_, scc_analyzer_)) { if (!field->is_repeated()) { format( @@ -859,7 +877,8 @@ void ParseFunctionGenerator::GenerateFieldBody( field->number()); } } else { - TProtoStringType size = (field->type() == FieldDescriptor::TYPE_SINT32 || + TProtoStringType size = (field->type() == FieldDescriptor::TYPE_INT32 || + field->type() == FieldDescriptor::TYPE_SINT32 || field->type() == FieldDescriptor::TYPE_UINT32) ? "32" : "64"; @@ -1086,8 +1105,7 @@ void ParseFunctionGenerator::GenerateFieldSwitch( namespace { TProtoStringType FieldParseFunctionName(const FieldDescriptor* field, - const Options& options, - arc_ui32 table_size_log2) { + const Options& options) { ParseCardinality card = // field->is_packed() ? ParseCardinality::kPacked : field->is_repeated() ? ParseCardinality::kRepeated @@ -1146,9 +1164,8 @@ TProtoStringType FieldParseFunctionName(const FieldDescriptor* field, type_format = TypeFormat::kStringValidateOnly; break; default: - GOOGLE_LOG(DFATAL) - << "Mode not handled: " - << static_cast<int>(GetUtf8CheckMode(field, options)); + GOOGLE_LOG(DFATAL) << "Mode not handled: " + << static_cast<int>(GetUtf8CheckMode(field, options)); return ""; } break; @@ -1158,8 +1175,8 @@ TProtoStringType FieldParseFunctionName(const FieldDescriptor* field, return ""; } - return "::" + ProtobufNamespace(options) + "::internal::" + - GetTailCallFieldHandlerName(card, type_format, table_size_log2, + return "::" + ProtobufNamespace(options) + "::internal::TcParser::" + + GetTailCallFieldHandlerName(card, type_format, TagSize(field->number()), options); } @@ -1167,32 +1184,10 @@ TProtoStringType FieldParseFunctionName(const FieldDescriptor* field, TProtoStringType GetTailCallFieldHandlerName(ParseCardinality card, TypeFormat type_format, - int table_size_log2, int tag_length_bytes, const Options& options) { TProtoStringType name; - switch (card) { - case ParseCardinality::kPacked: - case ParseCardinality::kRepeated: - name = "TcParserBase::"; - break; - - case ParseCardinality::kSingular: - case ParseCardinality::kOneof: - switch (type_format) { - case TypeFormat::kBytes: - case TypeFormat::kString: - case TypeFormat::kStringValidateOnly: - name = "TcParserBase::"; - break; - - default: - name = StrCat("TcParser<", table_size_log2, ">::"); - break; - } - } - // The field implementation functions are prefixed by cardinality: // `Singular` for optional or implicit fields. // `Repeated` for non-packed repeated. @@ -1274,26 +1269,24 @@ TProtoStringType GetTailCallFieldHandlerName(ParseCardinality card, case TypeFormat::kVar64: case TypeFormat::kVar32: case TypeFormat::kBool: - name.append( - StrCat(", ", TcParserBaseName(options), "kNoConversion")); + StrAppend(&name, ", ", TcParserName(options), "kNoConversion"); break; case TypeFormat::kSInt64: case TypeFormat::kSInt32: - name.append(StrCat(", ", TcParserBaseName(options), "kZigZag")); + StrAppend(&name, ", ", TcParserName(options), "kZigZag"); break; case TypeFormat::kBytes: - name.append(StrCat(", ", TcParserBaseName(options), "kNoUtf8")); + StrAppend(&name, ", ", TcParserName(options), "kNoUtf8"); break; case TypeFormat::kString: - name.append(StrCat(", ", TcParserBaseName(options), "kUtf8")); + StrAppend(&name, ", ", TcParserName(options), "kUtf8"); break; case TypeFormat::kStringValidateOnly: - name.append( - StrCat(", ", TcParserBaseName(options), "kUtf8ValidateOnly")); + StrAppend(&name, ", ", TcParserName(options), "kUtf8ValidateOnly"); break; default: diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h index 820f7b3089..0246079146 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h @@ -118,6 +118,7 @@ class ParseFunctionGenerator { // Generates the tail-call table definition. void GenerateTailCallTable(Formatter& format); + void GenerateFastFieldEntries(Formatter& format, const TProtoStringType& fallback); // Generates parsing code for an `ArenaString` field. void GenerateArenaString(Formatter& format, const FieldDescriptor* field); @@ -187,7 +188,6 @@ enum class TypeFormat { // parse_function_inc_generator_main. TProtoStringType GetTailCallFieldHandlerName(ParseCardinality card, TypeFormat type_format, - int table_size_log2, int tag_length_bytes, const Options& options); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h index ce0f97d930..ff7c208ff2 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h @@ -59,7 +59,8 @@ class PrimitiveFieldGenerator : public FieldGenerator { void GenerateSwappingCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* printer) const override; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const override; + void GenerateSerializeWithCachedSizesToArray( + io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; void GenerateConstinitInitializer(io::Printer* printer) const override; @@ -98,7 +99,8 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { void GenerateSwappingCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* printer) const override; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const override; + void GenerateSerializeWithCachedSizesToArray( + io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; void GenerateConstinitInitializer(io::Printer* printer) const override; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc index 0a30646fd0..944b41ba90 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc @@ -241,12 +241,12 @@ void ServiceGenerator::GenerateCallMethod(io::Printer* printer) { for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - Formatter format(printer, vars_); - InitMethodVariables(method, options_, &format); + Formatter format_method(printer, vars_); + InitMethodVariables(method, options_, &format_method); // Note: down_cast does not work here because it only works on pointers, // not references. - format( + format_method( " case $1$:\n" " $name$(controller,\n" " ::$proto_ns$::internal::DownCast<const $input_type$*>(\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc index 0adde4e777..c736ce9527 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -170,7 +170,7 @@ void StringFieldGenerator::GenerateAccessorDeclarations( descriptor_); format( "$deprecated_attr$TProtoStringType* ${1$mutable_$name$$}$();\n" - "PROTOBUF_MUST_USE_RESULT $deprecated_attr$TProtoStringType* " + "PROTOBUF_NODISCARD $deprecated_attr$TProtoStringType* " "${1$$release_name$$}$();\n" "$deprecated_attr$void ${1$set_allocated_$name$$}$(TProtoStringType* " "$name$);\n", @@ -290,8 +290,17 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " $clear_hasbit$\n"); if (!inlined_) { format( - " return $name$_.ReleaseNonDefault($init_value$, " + " auto* p = $name$_.ReleaseNonDefault($init_value$, " "GetArenaForAllocation());\n"); + if (descriptor_->default_value_string().empty()) { + format( + "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" + " if ($name$_.IsDefault($init_value$)) {\n" + " $name$_.Set($init_value$, \"\", GetArenaForAllocation());\n" + " }\n" + "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); + } + format(" return p;\n"); } else { format( " return $name$_.Release(nullptr, GetArenaForAllocation(), " @@ -314,6 +323,14 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( format( " $name$_.SetAllocated($init_value$, $name$,\n" " GetArenaForAllocation());\n"); + if (descriptor_->default_value_string().empty()) { + format( + "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" + " if ($name$_.IsDefault($init_value$)) {\n" + " $name$_.Set($init_value$, \"\", GetArenaForAllocation());\n" + " }\n" + "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); + } } else { // Currently, string fields with default value can't be inlined. format( @@ -422,6 +439,13 @@ void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { } GOOGLE_DCHECK(!inlined_); format("$name$_.UnsafeSetDefault($init_value$);\n"); + if (IsString(descriptor_, options_) && + descriptor_->default_value_string().empty()) { + format( + "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" + " $name$_.Set($init_value$, \"\", GetArenaForAllocation());\n" + "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); + } } void StringFieldGenerator::GenerateCopyConstructorCode( diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h index 85689bbec8..3f05443f58 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h @@ -55,7 +55,8 @@ class StringFieldGenerator : public FieldGenerator { void GenerateStaticMembers(io::Printer* printer) const override; void GenerateAccessorDeclarations(io::Printer* printer) const override; void GenerateInlineAccessorDefinitions(io::Printer* printer) const override; - void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const override; + void GenerateNonInlineAccessorDefinitions( + io::Printer* printer) const override; void GenerateClearingCode(io::Printer* printer) const override; void GenerateMessageClearingCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; @@ -63,7 +64,8 @@ class StringFieldGenerator : public FieldGenerator { void GenerateConstructorCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* printer) const override; void GenerateDestructorCode(io::Printer* printer) const override; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const override; + void GenerateSerializeWithCachedSizesToArray( + io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; void GenerateConstinitInitializer(io::Printer* printer) const override; bool IsInlined() const override { return inlined_; } @@ -108,7 +110,8 @@ class RepeatedStringFieldGenerator : public FieldGenerator { void GenerateSwappingCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* printer) const override; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const override; + void GenerateSerializeWithCachedSizesToArray( + io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; void GenerateConstinitInitializer(io::Printer* printer) const override; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc index fd6d5eb766..7032f2a747 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc @@ -467,7 +467,7 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile( for (const auto& mapping : mappings_) { TProtoStringType temp_disk_file; if (ApplyMapping(virtual_file, mapping.virtual_path, mapping.disk_path, - &temp_disk_file)) { + &temp_disk_file)) { io::ZeroCopyInputStream* stream = OpenDiskFile(temp_disk_file); if (stream != NULL) { if (disk_file != NULL) { diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc index 51a85cdc7c..2d30eabce9 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc @@ -36,6 +36,7 @@ #include <vector> +#include <google/protobuf/descriptor.pb.h> #include <google/protobuf/io/printer.h> #include <google/protobuf/stubs/strutil.h> @@ -186,6 +187,21 @@ void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field) { printer->Print(" */\n"); } +void WriteDeprecatedJavadoc(io::Printer* printer, const FieldDescriptor* field, + const FieldAccessorType type) { + if (!field->options().deprecated()) { + return; + } + + // Lite codegen does not annotate set & clear methods with @Deprecated. + if (field->file()->options().optimize_for() == FileOptions::LITE_RUNTIME && + (type == SETTER || type == CLEARER)) { + return; + } + + printer->Print(" * @deprecated\n"); +} + void WriteFieldAccessorDocComment(io::Printer* printer, const FieldDescriptor* field, const FieldAccessorType type, @@ -194,6 +210,7 @@ void WriteFieldAccessorDocComment(io::Printer* printer, WriteDocCommentBody(printer, field); printer->Print(" * <code>$def$</code>\n", "def", EscapeJavadoc(FirstLineOf(field->DebugString()))); + WriteDeprecatedJavadoc(printer, field, type); switch (type) { case HAZZER: printer->Print(" * @return Whether the $name$ field is set.\n", "name", @@ -252,6 +269,7 @@ void WriteFieldEnumValueAccessorDocComment(io::Printer* printer, WriteDocCommentBody(printer, field); printer->Print(" * <code>$def$</code>\n", "def", EscapeJavadoc(FirstLineOf(field->DebugString()))); + WriteDeprecatedJavadoc(printer, field, type); switch (type) { case HAZZER: // Should never happen @@ -321,6 +339,7 @@ void WriteFieldStringBytesAccessorDocComment(io::Printer* printer, WriteDocCommentBody(printer, field); printer->Print(" * <code>$def$</code>\n", "def", EscapeJavadoc(FirstLineOf(field->DebugString()))); + WriteDeprecatedJavadoc(printer, field, type); switch (type) { case HAZZER: // Should never happen diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc index a037f6289c..8c658eef9b 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc @@ -280,7 +280,7 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers( io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$var $kt_name$: $kt_type$\n" + "$kt_deprecation$public var $kt_name$: $kt_type$\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" @@ -291,16 +291,17 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers( WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ false); printer->Print(variables_, - "fun ${$clear$kt_capitalized_name$$}$() {\n" + "public fun ${$clear$kt_capitalized_name$$}$() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" "}\n"); if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print(variables_, - "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" - " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" - "}\n"); + printer->Print( + variables_, + "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" + " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" + "}\n"); } } @@ -1081,12 +1082,12 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers( " */\n" "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - "class ${$$kt_capitalized_name$Proxy$}$ private constructor()" + "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()" " : com.google.protobuf.kotlin.DslProxy()\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$ val $kt_name$: " + "$kt_deprecation$ public val $kt_name$: " "com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" @@ -1099,7 +1100,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "add(value: $kt_type$) {\n" " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" @@ -1110,7 +1111,8 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(value: $kt_type$) {\n" " add(value)\n" @@ -1121,7 +1123,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n" " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" @@ -1133,7 +1135,8 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n" " addAll(values)\n" @@ -1145,7 +1148,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n" - "operator fun com.google.protobuf.kotlin.DslList" + "public operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "set(index: kotlin.Int, value: $kt_type$) {\n" " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n" @@ -1156,7 +1159,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc index 300da77b9c..f7e7b2dab7 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc @@ -285,7 +285,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$var $kt_name$: $kt_type$\n" + "$kt_deprecation$public var $kt_name$: $kt_type$\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" @@ -296,16 +296,17 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ false); printer->Print(variables_, - "fun ${$clear$kt_capitalized_name$$}$() {\n" + "public fun ${$clear$kt_capitalized_name$$}$() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" "}\n"); if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print(variables_, - "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" - " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" - "}\n"); + printer->Print( + variables_, + "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" + " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" + "}\n"); } } @@ -823,12 +824,12 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( " */\n" "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - "class ${$$kt_capitalized_name$Proxy$}$ private constructor()" + "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()" " : com.google.protobuf.kotlin.DslProxy()\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$ val $kt_name$: " + "$kt_deprecation$ public val $kt_name$: " "com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" @@ -841,7 +842,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "add(value: $kt_type$) {\n" " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" @@ -852,7 +853,8 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(value: $kt_type$) {\n" " add(value)\n" @@ -863,7 +865,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n" " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" @@ -875,7 +877,8 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n" " addAll(values)\n" @@ -887,7 +890,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n" - "operator fun com.google.protobuf.kotlin.DslList" + "public operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "set(index: kotlin.Int, value: $kt_type$) {\n" " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n" @@ -898,7 +901,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h index c08f12f75c..d796c56c76 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h @@ -94,9 +94,9 @@ class ImmutableExtensionGenerator : public ExtensionGenerator { Context* context); virtual ~ImmutableExtensionGenerator(); - virtual void Generate(io::Printer* printer) override; - virtual int GenerateNonNestedInitializationCode(io::Printer* printer) override; - virtual int GenerateRegistrationCode(io::Printer* printer) override; + void Generate(io::Printer* printer) override; + int GenerateNonNestedInitializationCode(io::Printer* printer) override; + int GenerateRegistrationCode(io::Printer* printer) override; protected: const FieldDescriptor* descriptor_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h index af835946b9..117b87f7a8 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h @@ -51,14 +51,13 @@ class ImmutableExtensionLiteGenerator : public ExtensionGenerator { Context* context); virtual ~ImmutableExtensionLiteGenerator(); - virtual void Generate(io::Printer* printer) override; + void Generate(io::Printer* printer) override; // Returns an estimate of the number of bytes the printed code will compile to - virtual int GenerateNonNestedInitializationCode( - io::Printer* printer) override; + int GenerateNonNestedInitializationCode(io::Printer* printer) override; // Returns an estimate of the number of bytes the printed code will compile to - virtual int GenerateRegistrationCode(io::Printer* printer) override; + int GenerateRegistrationCode(io::Printer* printer) override; private: const FieldDescriptor* descriptor_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h index e64a45dd49..831d9dd857 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h @@ -80,13 +80,13 @@ class ImmutableGeneratorFactory : public GeneratorFactory { ImmutableGeneratorFactory(Context* context); virtual ~ImmutableGeneratorFactory(); - virtual MessageGenerator* NewMessageGenerator( + MessageGenerator* NewMessageGenerator( const Descriptor* descriptor) const override; - virtual ExtensionGenerator* NewExtensionGenerator( + ExtensionGenerator* NewExtensionGenerator( const FieldDescriptor* descriptor) const override; - virtual ServiceGenerator* NewServiceGenerator( + ServiceGenerator* NewServiceGenerator( const ServiceDescriptor* descriptor) const override; private: diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h index dd80e23d3f..b0cce4949b 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h @@ -155,7 +155,7 @@ TProtoStringType GetOneofStoredType(const FieldDescriptor* field); // Whether we should generate multiple java files for messages. inline bool MultipleJavaFiles(const FileDescriptor* descriptor, bool immutable) { - (void) immutable; + (void)immutable; return descriptor->options().java_multiple_files(); } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc index 353bff46db..a35bd42ebe 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc @@ -111,11 +111,13 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, (*variables)["key_default_value"] = DefaultValue(key, true, name_resolver); (*variables)["key_null_check"] = IsReferenceType(keyJavaType) - ? "if (key == null) { throw new java.lang.NullPointerException(); }" + ? "if (key == null) { throw new NullPointerException(\"map key\"); }" : ""; (*variables)["value_null_check"] = - IsReferenceType(valueJavaType) - ? "if (value == null) { throw new java.lang.NullPointerException(); }" + valueJavaType != JAVATYPE_ENUM && IsReferenceType(valueJavaType) + ? "if (value == null) {\n" + " throw new NullPointerException(\"map value\");\n" + "}\n" : ""; if (valueJavaType == JAVATYPE_ENUM) { // We store enums as Integers internally. @@ -435,6 +437,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " $key_type$ key,\n" " $value_type$ value) {\n" " $key_null_check$\n" + " $value_null_check$\n" " internalGetMutable$capitalized_name$().getMutableMap()\n" " .put(key, value);\n" " return this;\n" @@ -679,13 +682,13 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers( " */\n" "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - "class ${$$kt_capitalized_name$Proxy$}$ private constructor()" + "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()" " : com.google.protobuf.kotlin.DslProxy()\n"); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$kt_deprecation$ val $kt_name$: " + "$kt_deprecation$ public val $kt_name$: " "com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" @@ -698,7 +701,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers( printer->Print( variables_, "@JvmName(\"put$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslMap" + "public fun com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " .put(key: $kt_key_type$, value: $kt_value_type$) {\n" " $kt_dsl_builder$.${$put$capitalized_name$$}$(key, value)\n" @@ -709,7 +712,8 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@JvmName(\"set$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslMap" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " .set(key: $kt_key_type$, value: $kt_value_type$) {\n" " put(key, value)\n" @@ -720,7 +724,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@JvmName(\"remove$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslMap" + "public fun com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " .remove(key: $kt_key_type$) {\n" " $kt_dsl_builder$.${$remove$capitalized_name$$}$(key)\n" @@ -731,7 +735,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@JvmName(\"putAll$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslMap" + "public fun com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " .putAll(map: kotlin.collections.Map<$kt_key_type$, $kt_value_type$>) " "{\n" @@ -743,7 +747,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@JvmName(\"clear$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslMap" + "public fun com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " .clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc index 79bd924701..2c52ccaea7 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc @@ -822,13 +822,13 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers( " */\n" "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - "class ${$$kt_capitalized_name$Proxy$}$ private constructor()" + "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()" " : com.google.protobuf.kotlin.DslProxy()\n"); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$kt_deprecation$ val $kt_name$: " + "$kt_deprecation$ public val $kt_name$: " "com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" @@ -841,7 +841,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print( variables_, "@JvmName(\"put$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslMap" + "public fun com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " .put(key: $kt_key_type$, value: $kt_value_type$) {\n" " $kt_dsl_builder$.${$put$capitalized_name$$}$(key, value)\n" @@ -852,7 +852,8 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@JvmName(\"set$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslMap" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " .set(key: $kt_key_type$, value: $kt_value_type$) {\n" " put(key, value)\n" @@ -863,7 +864,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@JvmName(\"remove$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslMap" + "public fun com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " .remove(key: $kt_key_type$) {\n" " $kt_dsl_builder$.${$remove$capitalized_name$$}$(key)\n" @@ -874,7 +875,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@JvmName(\"putAll$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslMap" + "public fun com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " .putAll(map: kotlin.collections.Map<$kt_key_type$, $kt_value_type$>) " "{\n" @@ -886,7 +887,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@JvmName(\"clear$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslMap" + "public fun com.google.protobuf.kotlin.DslMap" "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " .clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc index 83c5fb5dd6..e5343d6762 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc @@ -1407,10 +1407,10 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const { "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" "@com.google.protobuf.kotlin.ProtoDslMarker\n"); printer->Print( - "class Dsl private constructor(\n" + "public class Dsl private constructor(\n" " private val _builder: $message$.Builder\n" ") {\n" - " companion object {\n" + " public companion object {\n" " @kotlin.jvm.JvmSynthetic\n" " @kotlin.PublishedApi\n" " internal fun _create(builder: $message$.Builder): Dsl = " @@ -1432,10 +1432,10 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const { for (auto oneof : oneofs_) { printer->Print( - "val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n" + "public val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n" " @JvmName(\"get$oneof_capitalized_name$Case\")\n" " get() = _builder.get$oneof_capitalized_name$Case()\n\n" - "fun clear$oneof_capitalized_name$() {\n" + "public fun clear$oneof_capitalized_name$() {\n" " _builder.clear$oneof_capitalized_name$()\n" "}\n", "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name, @@ -1456,7 +1456,8 @@ void ImmutableMessageGenerator::GenerateKotlinMembers( io::Printer* printer) const { printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> kotlin.Unit): " + "public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> " + "kotlin.Unit): " "$message$ " "=\n" " $message_kt$.Dsl._create($message$.newBuilder()).apply { block() " @@ -1465,7 +1466,7 @@ void ImmutableMessageGenerator::GenerateKotlinMembers( "message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_), "message", name_resolver_->GetClassName(descriptor_, true)); - printer->Print("object $name$Kt {\n", "name", descriptor_->name()); + printer->Print("public object $name$Kt {\n", "name", descriptor_->name()); printer->Indent(); GenerateKotlinDsl(printer); for (int i = 0; i < descriptor_->nested_type_count(); i++) { @@ -1481,7 +1482,8 @@ void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers( io::Printer* printer) const { printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline fun $message$.copy(block: $message_kt$.Dsl.() -> kotlin.Unit): " + "public inline fun $message$.copy(block: $message_kt$.Dsl.() -> " + "kotlin.Unit): " "$message$ =\n" " $message_kt$.Dsl._create(this.toBuilder()).apply { block() " "}._build()\n", @@ -1502,7 +1504,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@Suppress(\"UNCHECKED_CAST\")\n" "@kotlin.jvm.JvmSynthetic\n" - "operator fun <T> get(extension: " + "public operator fun <T> get(extension: " "com.google.protobuf.ExtensionLite<$message$, T>): T {\n" " return if (extension.isRepeated) {\n" " get(extension as com.google.protobuf.ExtensionLite<$message$, " @@ -1518,7 +1520,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" "@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n" - "operator fun <E> get(\n" + "public operator fun <E> get(\n" " extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n" "): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n" " return com.google.protobuf.kotlin.ExtensionList(extension, " @@ -1528,7 +1530,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "operator fun contains(extension: " + "public operator fun contains(extension: " "com.google.protobuf.ExtensionLite<$message$, *>): " "Boolean {\n" " return _builder.hasExtension(extension)\n" @@ -1537,7 +1539,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "fun clear(extension: com.google.protobuf.ExtensionLite<$message$, *>) " + "public fun clear(extension: " + "com.google.protobuf.ExtensionLite<$message$, *>) " "{\n" " _builder.clearExtension(extension)\n" "}\n\n", @@ -1555,7 +1558,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline operator fun <T : Comparable<T>> set(\n" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun <T : Comparable<T>> set(\n" " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n" " value: T\n" ") {\n" @@ -1565,7 +1569,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline operator fun set(\n" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun set(\n" " extension: com.google.protobuf.ExtensionLite<$message$, " "com.google.protobuf.ByteString>,\n" " value: com.google.protobuf.ByteString\n" @@ -1576,7 +1581,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline operator fun <T : com.google.protobuf.MessageLite> set(\n" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun <T : com.google.protobuf.MessageLite> set(\n" " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n" " value: T\n" ") {\n" @@ -1586,7 +1592,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "public fun <E> com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.add(value: E) {\n" " _builder.addExtension(this.extension, value)\n" "}\n\n", @@ -1594,7 +1600,9 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun <E> " + "com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.plusAssign" "(value: E) {\n" " add(value)\n" @@ -1603,7 +1611,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "public fun <E> com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.addAll(values: Iterable<E>) {\n" " for (value in values) {\n" " add(value)\n" @@ -1613,7 +1621,9 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun <E> " + "com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.plusAssign(values: " "Iterable<E>) {\n" " addAll(values)\n" @@ -1622,7 +1632,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "public operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.set(index: Int, value: " "E) {\n" " _builder.setExtension(this.extension, index, value)\n" @@ -1631,7 +1641,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline fun com.google.protobuf.kotlin.ExtensionList<*, " + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline fun com.google.protobuf.kotlin.ExtensionList<*, " "$message$>.clear() {\n" " clear(extension)\n" "}\n\n", diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc index 6e2f181387..bdd80a811f 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc @@ -417,7 +417,7 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers( io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$var $kt_name$: $kt_type$\n" + "$kt_deprecation$public var $kt_name$: $kt_type$\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" @@ -428,15 +428,16 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers( WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ false); printer->Print(variables_, - "fun ${$clear$kt_capitalized_name$$}$() {\n" + "public fun ${$clear$kt_capitalized_name$$}$() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print(variables_, - "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" - " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" - "}\n"); + printer->Print( + variables_, + "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" + " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" + "}\n"); } void ImmutableMessageFieldGenerator::GenerateFieldBuilderInitializationCode( @@ -1403,12 +1404,12 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( " */\n" "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - "class ${$$kt_capitalized_name$Proxy$}$ private constructor()" + "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()" " : com.google.protobuf.kotlin.DslProxy()\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$ val $kt_name$: " + "$kt_deprecation$ public val $kt_name$: " "com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" @@ -1421,7 +1422,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "add(value: $kt_type$) {\n" " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" @@ -1432,7 +1433,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(value: $kt_type$) {\n" " add(value)\n" @@ -1443,7 +1445,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n" " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" @@ -1455,7 +1457,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n" " addAll(values)\n" @@ -1467,7 +1470,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n" - "operator fun com.google.protobuf.kotlin.DslList" + "public operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "set(index: kotlin.Int, value: $kt_type$) {\n" " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n" @@ -1478,7 +1481,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h index 9674ab425e..a0c24ae7b7 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h @@ -78,7 +78,8 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator { void GenerateParsingDoneCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; - void GenerateFieldBuilderInitializationCode(io::Printer* printer) const override; + void GenerateFieldBuilderInitializationCode( + io::Printer* printer) const override; void GenerateEqualsCode(io::Printer* printer) const override; void GenerateHashCode(io::Printer* printer) const override; void GenerateKotlinDslMembers(io::Printer* printer) const override; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc index f36555f00c..100726856c 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc @@ -287,7 +287,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$var $kt_name$: $kt_type$\n" + "$kt_deprecation$public var $kt_name$: $kt_type$\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" @@ -298,15 +298,16 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ false); printer->Print(variables_, - "fun ${$clear$kt_capitalized_name$$}$() {\n" + "public fun ${$clear$kt_capitalized_name$$}$() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print(variables_, - "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" - " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" - "}\n"); + printer->Print( + variables_, + "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" + " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" + "}\n"); } void ImmutableMessageFieldLiteGenerator::GenerateFieldInfo( @@ -793,12 +794,12 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( " */\n" "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - "class ${$$kt_capitalized_name$Proxy$}$ private constructor()" + "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()" " : com.google.protobuf.kotlin.DslProxy()\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$ val $kt_name$: " + "$kt_deprecation$ public val $kt_name$: " "com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" @@ -811,7 +812,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "add(value: $kt_type$) {\n" " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" @@ -822,7 +823,8 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(value: $kt_type$) {\n" " add(value)\n" @@ -833,7 +835,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n" " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" @@ -845,7 +847,8 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n" " addAll(values)\n" @@ -857,7 +860,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n" - "operator fun com.google.protobuf.kotlin.DslList" + "public operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "set(index: kotlin.Int, value: $kt_type$) {\n" " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n" @@ -868,7 +871,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc index bb8bcf7a95..f5d7c9362a 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc @@ -731,10 +731,10 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl( "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" "@com.google.protobuf.kotlin.ProtoDslMarker\n"); printer->Print( - "class Dsl private constructor(\n" + "public class Dsl private constructor(\n" " private val _builder: $message$.Builder\n" ") {\n" - " companion object {\n" + " public companion object {\n" " @kotlin.jvm.JvmSynthetic\n" " @kotlin.PublishedApi\n" " internal fun _create(builder: $message$.Builder): Dsl = " @@ -756,10 +756,10 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl( for (auto oneof : oneofs_) { printer->Print( - "val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n" + "public val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n" " @JvmName(\"get$oneof_capitalized_name$Case\")\n" " get() = _builder.get$oneof_capitalized_name$Case()\n\n" - "fun clear$oneof_capitalized_name$() {\n" + "public fun clear$oneof_capitalized_name$() {\n" " _builder.clear$oneof_capitalized_name$()\n" "}\n", "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name, @@ -780,7 +780,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers( io::Printer* printer) const { printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> kotlin.Unit): " + "public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> " + "kotlin.Unit): " "$message$ =\n" " $message_kt$.Dsl._create($message$.newBuilder()).apply { block() " "}._build()\n", @@ -788,7 +789,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers( "message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_), "message", name_resolver_->GetClassName(descriptor_, true)); - printer->Print("object $name$Kt {\n", "name", descriptor_->name()); + printer->Print("public object $name$Kt {\n", "name", descriptor_->name()); printer->Indent(); GenerateKotlinDsl(printer); for (int i = 0; i < descriptor_->nested_type_count(); i++) { @@ -803,7 +804,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers( void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers( io::Printer* printer) const { printer->Print( - "inline fun $message$.copy(block: $message_kt$.Dsl.() -> kotlin.Unit): " + "public inline fun $message$.copy(block: $message_kt$.Dsl.() -> " + "kotlin.Unit): " "$message$ =\n" " $message_kt$.Dsl._create(this.toBuilder()).apply { block() " "}._build()\n", @@ -824,7 +826,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@Suppress(\"UNCHECKED_CAST\")\n" "@kotlin.jvm.JvmSynthetic\n" - "operator fun <T> get(extension: " + "public operator fun <T> get(extension: " "com.google.protobuf.ExtensionLite<$message$, T>): T {\n" " return if (extension.isRepeated) {\n" " get(extension as com.google.protobuf.ExtensionLite<$message$, " @@ -840,7 +842,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" "@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n" - "operator fun <E> get(\n" + "public operator fun <E> get(\n" " extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n" "): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n" " return com.google.protobuf.kotlin.ExtensionList(extension, " @@ -850,7 +852,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "operator fun contains(extension: " + "public operator fun contains(extension: " "com.google.protobuf.ExtensionLite<$message$, *>): " "Boolean {\n" " return _builder.hasExtension(extension)\n" @@ -859,7 +861,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "fun clear(extension: com.google.protobuf.ExtensionLite<$message$, *>) " + "public fun clear(extension: " + "com.google.protobuf.ExtensionLite<$message$, *>) " "{\n" " _builder.clearExtension(extension)\n" "}\n\n", @@ -877,7 +880,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline operator fun <T : Comparable<T>> set(\n" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun <T : Comparable<T>> set(\n" " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n" " value: T\n" ") {\n" @@ -887,7 +891,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline operator fun set(\n" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun set(\n" " extension: com.google.protobuf.ExtensionLite<$message$, " "com.google.protobuf.ByteString>,\n" " value: com.google.protobuf.ByteString\n" @@ -898,7 +903,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline operator fun <T : com.google.protobuf.MessageLite> set(\n" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun <T : com.google.protobuf.MessageLite> set(\n" " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n" " value: T\n" ") {\n" @@ -908,7 +914,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "public fun<E> com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.add(value: E) {\n" " _builder.addExtension(this.extension, value)\n" "}\n\n", @@ -916,7 +922,9 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun <E> " + "com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.plusAssign" "(value: E) {\n" " add(value)\n" @@ -925,7 +933,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "public fun<E> com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.addAll(values: Iterable<E>) {\n" " for (value in values) {\n" " add(value)\n" @@ -935,7 +943,9 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun <E> " + "com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.plusAssign(values: " "Iterable<E>) {\n" " addAll(values)\n" @@ -944,7 +954,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "public operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.set(index: Int, value: " "E) {\n" " _builder.setExtension(this.extension, index, value)\n" @@ -953,7 +963,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "inline fun com.google.protobuf.kotlin.ExtensionList<*, " + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline fun com.google.protobuf.kotlin.ExtensionList<*, " "$message$>.clear() {\n" " clear(extension)\n" "}\n\n", diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h index 0af0cb8ad2..adb0df7cc7 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h @@ -50,12 +50,12 @@ class ImmutableMessageLiteGenerator : public MessageGenerator { ImmutableMessageLiteGenerator(const Descriptor* descriptor, Context* context); virtual ~ImmutableMessageLiteGenerator(); - virtual void Generate(io::Printer* printer) override; - virtual void GenerateInterface(io::Printer* printer) override; - virtual void GenerateExtensionRegistrationCode(io::Printer* printer) override; - virtual void GenerateStaticVariables(io::Printer* printer, - int* bytecode_estimate) override; - virtual int GenerateStaticVariableInitializers(io::Printer* printer) override; + void Generate(io::Printer* printer) override; + void GenerateInterface(io::Printer* printer) override; + void GenerateExtensionRegistrationCode(io::Printer* printer) override; + void GenerateStaticVariables(io::Printer* printer, + int* bytecode_estimate) override; + int GenerateStaticVariableInitializers(io::Printer* printer) override; void GenerateKotlinDsl(io::Printer* printer) const override; void GenerateKotlinMembers(io::Printer* printer) const override; void GenerateTopLevelKotlinMembers(io::Printer* printer) const override; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc index 51e91affd8..8b3d234469 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc @@ -159,12 +159,25 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["set_has_field_bit_builder"] = ""; (*variables)["clear_has_field_bit_builder"] = ""; - if (descriptor->type() == FieldDescriptor::TYPE_BYTES) { - (*variables)["is_field_present_message"] = - "!" + (*variables)["name"] + "_.isEmpty()"; - } else { - (*variables)["is_field_present_message"] = - (*variables)["name"] + "_ != " + (*variables)["default"]; + switch (descriptor->type()) { + case FieldDescriptor::TYPE_BYTES: + (*variables)["is_field_present_message"] = + "!" + (*variables)["name"] + "_.isEmpty()"; + break; + case FieldDescriptor::TYPE_FLOAT: + (*variables)["is_field_present_message"] = + "java.lang.Float.floatToRawIntBits(" + (*variables)["name"] + + "_) != 0"; + break; + case FieldDescriptor::TYPE_DOUBLE: + (*variables)["is_field_present_message"] = + "java.lang.Double.doubleToRawLongBits(" + (*variables)["name"] + + "_) != 0"; + break; + default: + (*variables)["is_field_present_message"] = + (*variables)["name"] + "_ != " + (*variables)["default"]; + break; } } @@ -307,7 +320,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$var $kt_name$: $kt_type$\n" + "$kt_deprecation$public var $kt_name$: $kt_type$\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" @@ -318,16 +331,17 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ false); printer->Print(variables_, - "fun ${$clear$kt_capitalized_name$$}$() {\n" + "public fun ${$clear$kt_capitalized_name$$}$() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" "}\n"); if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print(variables_, - "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" - " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" - "}\n"); + printer->Print( + variables_, + "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" + " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" + "}\n"); } } @@ -617,8 +631,8 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMergingCode( void ImmutablePrimitiveOneofFieldGenerator::GenerateParsingCode( io::Printer* printer) const { printer->Print(variables_, - "$set_oneof_case_message$;\n" - "$oneof_name$_ = input.read$capitalized_type$();\n"); + "$oneof_name$_ = input.read$capitalized_type$();\n" + "$set_oneof_case_message$;\n"); } void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializationCode( @@ -835,12 +849,12 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( " */\n" "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - "class ${$$kt_capitalized_name$Proxy$}$ private constructor()" + "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()" " : com.google.protobuf.kotlin.DslProxy()\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$ val $kt_name$: " + "$kt_deprecation$ public val $kt_name$: " "com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" @@ -853,7 +867,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "add(value: $kt_type$) {\n" " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" @@ -864,7 +878,8 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(value: $kt_type$) {\n" " add(value)\n" @@ -875,7 +890,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n" " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" @@ -887,7 +902,8 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n" " addAll(values)\n" @@ -899,7 +915,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n" - "operator fun com.google.protobuf.kotlin.DslList" + "public operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "set(index: kotlin.Int, value: $kt_type$) {\n" " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n" @@ -910,7 +926,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc index 24fef33624..6ab207e7af 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc @@ -164,12 +164,25 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["set_has_field_bit_message"] = ""; (*variables)["clear_has_field_bit_message"] = ""; - if (descriptor->type() == FieldDescriptor::TYPE_BYTES) { - (*variables)["is_field_present_message"] = - "!" + (*variables)["name"] + "_.isEmpty()"; - } else { - (*variables)["is_field_present_message"] = - (*variables)["name"] + "_ != " + (*variables)["default"]; + switch (descriptor->type()) { + case FieldDescriptor::TYPE_BYTES: + (*variables)["is_field_present_message"] = + "!" + (*variables)["name"] + "_.isEmpty()"; + break; + case FieldDescriptor::TYPE_FLOAT: + (*variables)["is_field_present_message"] = + "java.lang.Float.floatToRawIntBits(" + (*variables)["name"] + + "_) != 0"; + break; + case FieldDescriptor::TYPE_DOUBLE: + (*variables)["is_field_present_message"] = + "java.lang.Double.doubleToRawLongBits(" + (*variables)["name"] + + "_) != 0"; + break; + default: + (*variables)["is_field_present_message"] = + (*variables)["name"] + "_ != " + (*variables)["default"]; + break; } } @@ -313,7 +326,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$var $kt_name$: $kt_type$\n" + "$kt_deprecation$public var $kt_name$: $kt_type$\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" @@ -324,16 +337,17 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ false); printer->Print(variables_, - "fun ${$clear$kt_capitalized_name$$}$() {\n" + "public fun ${$clear$kt_capitalized_name$$}$() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" "}\n"); if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print(variables_, - "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" - " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" - "}\n"); + printer->Print( + variables_, + "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" + " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" + "}\n"); } } @@ -658,12 +672,12 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( " */\n" "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - "class ${$$kt_capitalized_name$Proxy$}$ private constructor()" + "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()" " : com.google.protobuf.kotlin.DslProxy()\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$ val $kt_name$: " + "$kt_deprecation$ public val $kt_name$: " "com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" @@ -676,7 +690,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "add(value: $kt_type$) {\n" " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" @@ -687,7 +701,8 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(value: $kt_type$) {\n" " add(value)\n" @@ -698,7 +713,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n" " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" @@ -710,7 +725,8 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n" " addAll(values)\n" @@ -722,7 +738,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n" - "operator fun com.google.protobuf.kotlin.DslList" + "public operator fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "set(index: kotlin.Int, value: $kt_type$) {\n" " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n" @@ -733,7 +749,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h index 7314f340d9..58d2c8d750 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h @@ -80,7 +80,7 @@ class ImmutableServiceGenerator : public ServiceGenerator { Context* context); virtual ~ImmutableServiceGenerator(); - virtual void Generate(io::Printer* printer) override; + void Generate(io::Printer* printer) override; private: // Generate the getDescriptorForType() method. diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc index 2d0eb752a8..0c9ba04e56 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc @@ -81,7 +81,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, " throw new NullPointerException();\n" " }\n"; (*variables)["isStringEmpty"] = "com.google.protobuf.GeneratedMessage" + - GeneratedCodeVersionSuffix() + ".isStringEmpty"; + GeneratedCodeVersionSuffix() + + ".isStringEmpty"; (*variables)["writeString"] = "com.google.protobuf.GeneratedMessage" + GeneratedCodeVersionSuffix() + ".writeString"; (*variables)["computeStringSize"] = "com.google.protobuf.GeneratedMessage" + @@ -119,7 +120,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["clear_has_field_bit_builder"] = ""; (*variables)["is_field_present_message"] = - "!" + (*variables)["isStringEmpty"] + "(" + (*variables)["name"] + "_)"; + "!" + (*variables)["isStringEmpty"] + "(" + (*variables)["name"] + "_)"; } // For repeated builders, one bit is used for whether the array is immutable. @@ -378,7 +379,7 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers( io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$var $kt_name$: kotlin.String\n" + "$kt_deprecation$public var $kt_name$: kotlin.String\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" @@ -389,16 +390,17 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers( WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ false); printer->Print(variables_, - "fun ${$clear$kt_capitalized_name$$}$() {\n" + "public fun ${$clear$kt_capitalized_name$$}$() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" "}\n"); if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print(variables_, - "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" - " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" - "}\n"); + printer->Print( + variables_, + "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" + " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" + "}\n"); } } @@ -961,21 +963,19 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers( " */\n" "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - "class ${$$kt_capitalized_name$Proxy$}$ private constructor()" + "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()" " : com.google.protobuf.kotlin.DslProxy()\n"); // property for List<String> WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER); - printer->Print( - variables_, - "val $kt_name$: " - "com.google.protobuf.kotlin.DslList" - "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n" - " @kotlin.OptIn" - "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - " get() = com.google.protobuf.kotlin.DslList(\n" - " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" - " )\n"); + printer->Print(variables_, + "$kt_deprecation$public val $kt_name$: " + "com.google.protobuf.kotlin.DslList" + "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n" + " @kotlin.jvm.JvmSynthetic\n" + " get() = com.google.protobuf.kotlin.DslList(\n" + " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" + " )\n"); // List<String>.add(String) WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, @@ -983,7 +983,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "add(value: kotlin.String) {\n" " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" @@ -992,13 +992,14 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers( // List<String> += String WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ false); - printer->Print(variables_, + printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n" - "operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(value: kotlin.String) {\n" - " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" + " add(value)\n" "}\n"); // List<String>.addAll(Iterable<String>) @@ -1008,7 +1009,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "addAll(values: kotlin.collections.Iterable<kotlin.String>) {\n" " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" @@ -1021,10 +1022,11 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n" - "operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n" - " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" + " addAll(values)\n" "}\n"); // List<String>[Int] = String @@ -1034,7 +1036,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n" - "operator fun com.google.protobuf.kotlin.DslList" + "public operator fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "set(index: kotlin.Int, value: kotlin.String) {\n" " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n" @@ -1045,7 +1047,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h index 680e77252c..02f0734aea 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h @@ -78,7 +78,8 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator { void GenerateParsingDoneCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; - void GenerateFieldBuilderInitializationCode(io::Printer* printer) const override; + void GenerateFieldBuilderInitializationCode( + io::Printer* printer) const override; void GenerateEqualsCode(io::Printer* printer) const override; void GenerateHashCode(io::Printer* printer) const override; void GenerateKotlinDslMembers(io::Printer* printer) const override; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc index 42198cc266..3150c766ce 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc @@ -313,7 +313,7 @@ void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$var $kt_name$: kotlin.String\n" + "$kt_deprecation$public var $kt_name$: kotlin.String\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" @@ -324,16 +324,17 @@ void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ false); printer->Print(variables_, - "fun ${$clear$kt_capitalized_name$$}$() {\n" + "public fun ${$clear$kt_capitalized_name$$}$() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" "}\n"); if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print(variables_, - "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" - " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" - "}\n"); + printer->Print( + variables_, + "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" + " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" + "}\n"); } } @@ -747,14 +748,14 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( " */\n" "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" - "class ${$$kt_capitalized_name$Proxy$}$ private constructor()" + "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()" " : com.google.protobuf.kotlin.DslProxy()\n"); // property for List<String> WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER); printer->Print( variables_, - "val $kt_name$: " + "$kt_deprecation$public val $kt_name$: " "com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.OptIn" @@ -769,7 +770,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "add(value: kotlin.String) {\n" " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" @@ -781,7 +782,8 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(value: kotlin.String) {\n" " add(value)\n" @@ -794,7 +796,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "addAll(values: kotlin.collections.Iterable<kotlin.String>) {\n" " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" @@ -807,7 +809,8 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n" - "inline operator fun com.google.protobuf.kotlin.DslList" + "@Suppress(\"NOTHING_TO_INLINE\")\n" + "public inline operator fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n" " addAll(values)\n" @@ -820,7 +823,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n" - "operator fun com.google.protobuf.kotlin.DslList" + "public operator fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "set(index: kotlin.Int, value: kotlin.String) {\n" " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n" @@ -831,7 +834,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n" - "fun com.google.protobuf.kotlin.DslList" + "public fun com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>." "clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc index ac334018df..019ef3a5b5 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/js/js_generator.cc @@ -3625,7 +3625,16 @@ void Generator::GenerateFile(const GeneratorOptions& options, if (options.import_style == GeneratorOptions::kImportCommonJsStrict) { printer->Print("var proto = {};\n\n"); } else { - printer->Print("var global = Function('return this')();\n\n"); + // To get the global object we call a function with .call(null), this will set "this" inside the + // function to the global object. + // This does not work if we are running in strict mode ("use strict"), + // so we fallback to the following things (in order from first to last): + // - window: defined in browsers + // - global: defined in most server side environments like NodeJS + // - self: defined inside Web Workers (WorkerGlobalScope) + // - Function('return this')(): this will work on most platforms, but it may be blocked by things like CSP. + // Function('') is almost the same as eval('') + printer->Print("var global = (function() { return this || window || global || self || Function('return this')(); }).call(null);\n\n"); } for (int i = 0; i < file->dependency_count(); i++) { diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum.cc index c3836faa2a..39c7829576 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_enum.cc @@ -127,7 +127,6 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) { if (alias_values_to_skip_.find(all_values_[i]) != alias_values_to_skip_.end()) { continue; } - SourceLocation location; if (all_values_[i]->GetSourceLocation(&location)) { TProtoStringType comments = BuildCommentsString(location, true).c_str(); if (comments.length() > 0) { diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc index 63b543bfb4..abb8bb7811 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_file.cc @@ -52,7 +52,7 @@ namespace objectivec { namespace { // This is also found in GPBBootstrap.h, and needs to be kept in sync. -const int32 GOOGLE_PROTOBUF_OBJC_VERSION = 30004; +const arc_i32 GOOGLE_PROTOBUF_OBJC_VERSION = 30004; const char* kHeaderExtension = ".pbobjc.h"; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc index 371234aafe..160af71080 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_generator.cc @@ -44,6 +44,28 @@ namespace protobuf { namespace compiler { namespace objectivec { +namespace { + +// Convert a string with "yes"/"no" (case insensitive) to a boolean, returning +// true/false for if the input string was a valid value. If the input string is +// invalid, `result` is unchanged. +bool StringToBool(const TProtoStringType& value, bool* result) { + TProtoStringType upper_value(value); + UpperString(&upper_value); + if (upper_value == "NO") { + *result = false; + return true; + } + if (upper_value == "YES") { + *result = true; + return true; + } + + return false; +} + +} // namespace + ObjectiveCGenerator::ObjectiveCGenerator() {} ObjectiveCGenerator::~ObjectiveCGenerator() {} @@ -101,6 +123,31 @@ bool ObjectiveCGenerator::GenerateAll( generation_options.expected_prefixes_suppressions.push_back( TProtoStringType(split_piece)); } + } else if (options[i].first == "prefixes_must_be_registered") { + // If objc prefix file option value must be registered to be used. This + // option has no meaning if an "expected_prefixes_path" isn't set. The + // available options are: + // "no": They don't have to be registered. + // "yes": They must be registered and an error will be raised if a files + // tried to use a prefix that isn't registered. + // Default is "no". + if (!StringToBool(options[i].second, + &generation_options.prefixes_must_be_registered)) { + *error = "error: Unknown value for prefixes_must_be_registered: " + options[i].second; + return false; + } + } else if (options[i].first == "require_prefixes") { + // If every file must have an objc prefix file option to be used. The + // available options are: + // "no": Files can be generated without the prefix option. + // "yes": Files must have the objc prefix option, and an error will be + // raised if a files doesn't have one. + // Default is "no". + if (!StringToBool(options[i].second, + &generation_options.require_prefixes)) { + *error = "error: Unknown value for require_prefixes: " + options[i].second; + return false; + } } else if (options[i].first == "generate_for_named_framework") { // The name of the framework that protos are being generated for. This // will cause the #import statements to be framework based using this @@ -146,12 +193,9 @@ bool ObjectiveCGenerator::GenerateAll( // is just what to do if that isn't set. The available options are: // "no": Not prefixed (the existing mode). // "yes": Make a prefix out of the proto package. - TProtoStringType upper_value(options[i].second); - UpperString(&upper_value); - if (upper_value == "NO") { - SetUseProtoPackageAsDefaultPrefix(false); - } else if (upper_value == "YES") { - SetUseProtoPackageAsDefaultPrefix(true); + bool value = false; + if (StringToBool(options[i].second, &value)) { + SetUseProtoPackageAsDefaultPrefix(value); } else { *error = "error: Unknown use_package_as_prefix: " + options[i].second; return false; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index bbcfbdd2bc..cbe70bac36 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -179,6 +179,8 @@ Options::Options() { expected_prefixes_suppressions = Split(suppressions, ";", true); } + prefixes_must_be_registered = false; + require_prefixes = false; } namespace { @@ -993,7 +995,7 @@ TProtoStringType DefaultValue(const FieldDescriptor* field) { // Must convert to a standard byte order for packing length into // a cstring. - uint32 length = ghtonl(default_string.length()); + arc_ui32 length = ghtonl(default_string.length()); TProtoStringType bytes((const char*)&length, sizeof(length)); bytes.append(default_string); return "(NSData*)\"" + EscapeTrigraphs(CEscape(bytes)) + "\""; @@ -1228,6 +1230,7 @@ bool LoadExpectedPackagePrefixes(const Options& generation_options, bool ValidateObjCClassPrefix( const FileDescriptor* file, const TProtoStringType& expected_prefixes_path, const std::map<TProtoStringType, TProtoStringType>& expected_package_prefixes, + bool prefixes_must_be_registered, bool require_prefixes, TProtoStringType* out_error) { // Reminder: An explicit prefix option of "" is valid in case the default // prefixing is set to use the proto package and a file needs to be generated @@ -1266,6 +1269,12 @@ bool ValidateObjCClassPrefix( // If there was no prefix option, we're done at this point. if (!has_prefix) { + if (require_prefixes) { + *out_error = + "error: '" + file->name() + "' does not have a required 'option" + + " objc_class_prefix'."; + return false; + } return true; } @@ -1345,9 +1354,18 @@ bool ValidateObjCClassPrefix( std::cerr.flush(); } - // Check: Warning - If the given package/prefix pair wasn't expected, issue a - // warning suggesting it gets added to the file. + // Check: Error/Warning - If the given package/prefix pair wasn't expected, + // issue a error/warning to added to the file. if (have_expected_prefix_file) { + if (prefixes_must_be_registered) { + *out_error = + "error: '" + file->name() + "' has 'option objc_class_prefix = \"" + + prefix + "\";', but it is not registered; add it to the expected " + + "prefixes file (" + expected_prefixes_path + ") for the package '" + + package + "'."; + return false; + } + std::cerr << "protoc:0: warning: Found unexpected 'option objc_class_prefix = \"" << prefix << "\";' in '" << file->name() << "';" @@ -1392,6 +1410,8 @@ bool ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files, ValidateObjCClassPrefix(files[i], generation_options.expected_prefixes_path, expected_package_prefixes, + generation_options.prefixes_must_be_registered, + generation_options.require_prefixes, out_error); if (!is_valid) { return false; @@ -1404,7 +1424,7 @@ TextFormatDecodeData::TextFormatDecodeData() { } TextFormatDecodeData::~TextFormatDecodeData() { } -void TextFormatDecodeData::AddString(int32 key, +void TextFormatDecodeData::AddString(arc_i32 key, const TProtoStringType& input_for_decode, const TProtoStringType& desired_output) { for (std::vector<DataEntry>::const_iterator i = entries_.begin(); @@ -1460,12 +1480,12 @@ class DecodeDataBuilder { } private: - static constexpr uint8 kAddUnderscore = 0x80; + static constexpr uint8_t kAddUnderscore = 0x80; - static constexpr uint8 kOpAsIs = 0x00; - static constexpr uint8 kOpFirstUpper = 0x40; - static constexpr uint8 kOpFirstLower = 0x20; - static constexpr uint8 kOpAllUpper = 0x60; + static constexpr uint8_t kOpAsIs = 0x00; + static constexpr uint8_t kOpFirstUpper = 0x40; + static constexpr uint8_t kOpFirstLower = 0x20; + static constexpr uint8_t kOpAllUpper = 0x60; static constexpr int kMaxSegmentLen = 0x1f; @@ -1475,7 +1495,7 @@ class DecodeDataBuilder { } void Push() { - uint8 op = (op_ | segment_len_); + uint8_t op = (op_ | segment_len_); if (need_underscore_) op |= kAddUnderscore; if (op != 0) { decode_data_ += (char)op; @@ -1507,7 +1527,7 @@ class DecodeDataBuilder { bool need_underscore_; bool is_all_upper_; - uint8 op_; + uint8_t op_; int segment_len_; TProtoStringType decode_data_; @@ -1619,69 +1639,69 @@ class Parser { Parser(LineConsumer* line_consumer) : line_consumer_(line_consumer), line_(0) {} - // Parses a check of input, returning success/failure. - bool ParseChunk(StringPiece chunk); + // Feeds in some input, parse what it can, returning success/failure. Calling + // again after an error is undefined. + bool ParseChunk(StringPiece chunk, TProtoStringType* out_error); // Should be called to finish parsing (after all input has been provided via - // ParseChunk()). Returns success/failure. - bool Finish(); + // successful calls to ParseChunk(), calling after a ParseChunk() failure is + // undefined). Returns success/failure. + bool Finish(TProtoStringType* out_error); int last_line() const { return line_; } - TProtoStringType error_str() const { return error_str_; } private: - bool ParseLoop(); - LineConsumer* line_consumer_; int line_; - TProtoStringType error_str_; - StringPiece p_; TProtoStringType leftover_; }; -bool Parser::ParseChunk(StringPiece chunk) { +bool Parser::ParseChunk(StringPiece chunk, TProtoStringType* out_error) { + StringPiece full_chunk; if (!leftover_.empty()) { leftover_ += TProtoStringType(chunk); - p_ = StringPiece(leftover_); + full_chunk = StringPiece(leftover_); } else { - p_ = chunk; + full_chunk = chunk; + } + + StringPiece line; + while (ReadLine(&full_chunk, &line)) { + ++line_; + RemoveComment(&line); + TrimWhitespace(&line); + if (!line.empty() && !line_consumer_->ConsumeLine(line, out_error)) { + if (out_error->empty()) { + *out_error = "ConsumeLine failed without setting an error."; + } + leftover_.clear(); + return false; + } } - bool result = ParseLoop(); - if (p_.empty()) { + + if (full_chunk.empty()) { leftover_.clear(); } else { - leftover_ = TProtoStringType(p_); + leftover_ = TProtoStringType(full_chunk); } - return result; + return true; } -bool Parser::Finish() { - if (leftover_.empty()) { - return true; +bool Parser::Finish(TProtoStringType* out_error) { + // If there is still something to go, flush it with a newline. + if (!leftover_.empty() && !ParseChunk("\n", out_error)) { + return false; } - // Force a newline onto the end to finish parsing. - leftover_ += "\n"; - p_ = StringPiece(leftover_); - if (!ParseLoop()) { + // This really should never fail if ParseChunk succeeded, but check to be sure. + if (!leftover_.empty()) { + *out_error = "ParseSimple Internal error: finished with pending data."; return false; } - return p_.empty(); // Everything used? + return true; } -bool Parser::ParseLoop() { - StringPiece line; - while (ReadLine(&p_, &line)) { - ++line_; - RemoveComment(&line); - TrimWhitespace(&line); - if (line.empty()) { - continue; // Blank line. - } - if (!line_consumer_->ConsumeLine(line, &error_str_)) { - return false; - } - } - return true; +TProtoStringType FullErrorString(const TProtoStringType& name, int line_num, const TProtoStringType& msg) { + return TProtoStringType("error: ") + name + " Line " + StrCat(line_num) + ", " + msg; } } // namespace @@ -1704,22 +1724,33 @@ bool ParseSimpleFile(const TProtoStringType& path, LineConsumer* line_consumer, io::FileInputStream file_stream(fd); file_stream.SetCloseOnDelete(true); + return ParseSimpleStream(file_stream, path, line_consumer, out_error); +} + +bool ParseSimpleStream(io::ZeroCopyInputStream& input_stream, + const TProtoStringType& stream_name, + LineConsumer* line_consumer, + TProtoStringType* out_error) { + TProtoStringType local_error; Parser parser(line_consumer); const void* buf; int buf_len; - while (file_stream.Next(&buf, &buf_len)) { + while (input_stream.Next(&buf, &buf_len)) { if (buf_len == 0) { continue; } - if (!parser.ParseChunk(StringPiece(static_cast<const char*>(buf), buf_len))) { - *out_error = - TProtoStringType("error: ") + path + - " Line " + StrCat(parser.last_line()) + ", " + parser.error_str(); + if (!parser.ParseChunk(StringPiece(static_cast<const char*>(buf), buf_len), + &local_error)) { + *out_error = FullErrorString(stream_name, parser.last_line(), local_error); return false; } } - return parser.Finish(); + if (!parser.Finish(&local_error)) { + *out_error = FullErrorString(stream_name, parser.last_line(), local_error); + return false; + } + return true; } ImportWriter::ImportWriter( diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.h index 2e291dbd6b..28acf4affd 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/objectivec/objectivec_helpers.h @@ -38,6 +38,7 @@ #include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.pb.h> +#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/port_def.inc> @@ -67,6 +68,8 @@ struct Options { TProtoStringType generate_for_named_framework; TProtoStringType named_framework_to_proto_path_mappings_path; TProtoStringType runtime_import_prefix; + bool prefixes_must_be_registered; + bool require_prefixes; }; // Escape C++ trigraphs by escaping question marks to "\?". @@ -260,7 +263,7 @@ class PROTOC_EXPORT TextFormatDecodeData { TextFormatDecodeData(const TextFormatDecodeData&) = delete; TextFormatDecodeData& operator=(const TextFormatDecodeData&) = delete; - void AddString(int32 key, const TProtoStringType& input_for_decode, + void AddString(arc_i32 key, const TProtoStringType& input_for_decode, const TProtoStringType& desired_output); size_t num_entries() const { return entries_.size(); } TProtoStringType Data() const; @@ -269,7 +272,7 @@ class PROTOC_EXPORT TextFormatDecodeData { const TProtoStringType& desired_output); private: - typedef std::pair<int32, TProtoStringType> DataEntry; + typedef std::pair<arc_i32, TProtoStringType> DataEntry; std::vector<DataEntry> entries_; }; @@ -285,6 +288,11 @@ bool PROTOC_EXPORT ParseSimpleFile(const TProtoStringType& path, LineConsumer* line_consumer, TProtoStringType* out_error); +bool PROTOC_EXPORT ParseSimpleStream(io::ZeroCopyInputStream& input_stream, + const TProtoStringType& stream_name, + LineConsumer* line_consumer, + TProtoStringType* out_error); + // Helper class for parsing framework import mappings and generating // import statements. class PROTOC_EXPORT ImportWriter { diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc index 03b00dd0e8..335edcf30c 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc @@ -1514,6 +1514,13 @@ bool Parser::ParseOption(Message* options, AddError("Unexpected end of stream while parsing option value."); return false; + case io::Tokenizer::TYPE_WHITESPACE: + case io::Tokenizer::TYPE_NEWLINE: + GOOGLE_CHECK(!input_->report_whitespace() && !input_->report_newlines()) + << "Whitespace tokens were not requested."; + GOOGLE_LOG(FATAL) << "Tokenizer reported whitespace."; + return false; + case io::Tokenizer::TYPE_IDENTIFIER: { value_location.AddPath( UninterpretedOption::kIdentifierValueFieldNumber); @@ -1538,7 +1545,7 @@ bool Parser::ParseOption(Message* options, value_location.AddPath( UninterpretedOption::kNegativeIntValueFieldNumber); uninterpreted_option->set_negative_int_value( - static_cast<arc_i64>(-value)); + static_cast<arc_i64>(0 - value)); } else { value_location.AddPath( UninterpretedOption::kPositiveIntValueFieldNumber); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc index 56c7d10338..03aca43b04 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/php/php_generator.cc @@ -1121,9 +1121,9 @@ void GenerateAddFilesToPool(const FileDescriptor* file, const Options& options, file, &nodes_without_dependency, &deps, &dependency_count); while (!nodes_without_dependency.empty()) { - auto file = *nodes_without_dependency.begin(); - nodes_without_dependency.erase(file); - for (auto dependent : deps[file]) { + auto file_node = *nodes_without_dependency.begin(); + nodes_without_dependency.erase(file_node); + for (auto dependent : deps[file_node]) { if (dependency_count[dependent] == 1) { dependency_count.erase(dependent); nodes_without_dependency.insert(dependent); @@ -1132,11 +1132,11 @@ void GenerateAddFilesToPool(const FileDescriptor* file, const Options& options, } } - bool needs_aggregate = NeedsUnwrapping(file, options); + bool needs_aggregate = NeedsUnwrapping(file_node, options); if (needs_aggregate) { auto file_proto = sorted_file_set.add_file(); - file->CopyTo(file_proto); + file_node->CopyTo(file_proto); // Filter out descriptor.proto as it cannot be depended on for now. RepeatedPtrField<TProtoStringType>* dependency = @@ -1158,7 +1158,7 @@ void GenerateAddFilesToPool(const FileDescriptor* file, const Options& options, it->clear_extension(); } } else { - TProtoStringType dependency_filename = GeneratedMetadataFileName(file, false); + TProtoStringType dependency_filename = GeneratedMetadataFileName(file_node, false); printer->Print( "\\^name^::initOnce();\n", "name", FilenameToClassname(dependency_filename)); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc index 6ddcb86202..3d51e1e1cd 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc @@ -72,21 +72,22 @@ class GeneratorResponseContext : public GeneratorContext { // implements GeneratorContext -------------------------------------- - virtual io::ZeroCopyOutputStream* Open(const TProtoStringType& filename) override { + io::ZeroCopyOutputStream* Open(const TProtoStringType& filename) override { CodeGeneratorResponse::File* file = response_->add_file(); file->set_name(filename); return new io::StringOutputStream(file->mutable_content()); } - virtual io::ZeroCopyOutputStream* OpenForInsert( - const TProtoStringType& filename, const TProtoStringType& insertion_point) override { + io::ZeroCopyOutputStream* OpenForInsert( + const TProtoStringType& filename, + const TProtoStringType& insertion_point) override { CodeGeneratorResponse::File* file = response_->add_file(); file->set_name(filename); file->set_insertion_point(insertion_point); return new io::StringOutputStream(file->mutable_content()); } - virtual io::ZeroCopyOutputStream* OpenForInsertWithGeneratedCodeInfo( + io::ZeroCopyOutputStream* OpenForInsertWithGeneratedCodeInfo( const TProtoStringType& filename, const TProtoStringType& insertion_point, const google::protobuf::GeneratedCodeInfo& info) override { CodeGeneratorResponse::File* file = response_->add_file(); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc index 092d2ba17f..6370bf1fb1 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc @@ -83,7 +83,7 @@ static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2 static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; -const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +const arc_ui32 TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _internal_metadata_), ~0u, // no _extensions_ @@ -207,13 +207,13 @@ bool CodeGeneratorResponse_Feature_IsValid(int value) { } } -#if (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) +#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::FEATURE_NONE; constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::FEATURE_PROTO3_OPTIONAL; constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MIN; constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MAX; constexpr int CodeGeneratorResponse::Feature_ARRAYSIZE; -#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) +#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) // =================================================================== @@ -248,6 +248,9 @@ Version::Version(const Version& from) _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_suffix()) { suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_suffix(), GetArenaForAllocation()); @@ -258,8 +261,11 @@ Version::Version(const Version& from) // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.Version) } -void Version::SharedCtor() { +inline void Version::SharedCtor() { suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( reinterpret_cast<char*>(&major_) - reinterpret_cast<char*>(this)), 0, static_cast<size_t>(reinterpret_cast<char*>(&patch_) - @@ -290,7 +296,7 @@ void Version::SetCachedSize(int size) const { void Version::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.Version) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; @@ -311,39 +317,39 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; + arc_ui32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); switch (tag >> 3) { // optional int32 major = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_major(&has_bits); - major_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + major_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // optional int32 minor = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_minor(&has_bits); - minor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + minor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // optional int32 patch = 3; case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { _Internal::set_has_patch(&has_bits); - patch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + patch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // optional string suffix = 4; case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { auto str = _internal_mutable_suffix(); ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); #ifndef NDEBUG @@ -377,10 +383,10 @@ failure: #undef CHK_ } -::PROTOBUF_NAMESPACE_ID::uint8* Version::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { +uint8_t* Version::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _has_bits_[0]; @@ -424,7 +430,7 @@ size_t Version::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.Version) size_t total_size = 0; - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; @@ -472,7 +478,7 @@ void Version::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, void Version::MergeFrom(const Version& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version) GOOGLE_DCHECK_NE(&from, this); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._has_bits_[0]; @@ -569,6 +575,9 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) proto_file_(from.proto_file_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_parameter()) { parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_parameter(), GetArenaForAllocation()); @@ -581,8 +590,11 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest) } -void CodeGeneratorRequest::SharedCtor() { +inline void CodeGeneratorRequest::SharedCtor() { parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING compiler_version_ = nullptr; } @@ -611,7 +623,7 @@ void CodeGeneratorRequest::SetCachedSize(int size) const { void CodeGeneratorRequest::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; @@ -635,12 +647,12 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; + arc_ui32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated string file_to_generate = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { ptr -= 1; do { ptr += 1; @@ -657,7 +669,7 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM continue; // optional string parameter = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_parameter(); ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); #ifndef NDEBUG @@ -669,7 +681,7 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM continue; // optional .google.protobuf.compiler.Version compiler_version = 3; case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) { ptr = ctx->ParseMessage(_internal_mutable_compiler_version(), ptr); CHK_(ptr); } else @@ -677,7 +689,7 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM continue; // repeated .google.protobuf.FileDescriptorProto proto_file = 15; case 15: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 122)) { ptr -= 1; do { ptr += 1; @@ -712,10 +724,10 @@ failure: #undef CHK_ } -::PROTOBUF_NAMESPACE_ID::uint8* CodeGeneratorRequest::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { +uint8_t* CodeGeneratorRequest::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; (void) cached_has_bits; // repeated string file_to_generate = 1; @@ -767,7 +779,7 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest) size_t total_size = 0; - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; @@ -822,7 +834,7 @@ void CodeGeneratorRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) GOOGLE_DCHECK_NE(&from, this); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; (void) cached_has_bits; file_to_generate_.MergeFrom(from.file_to_generate_); @@ -847,7 +859,8 @@ void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) { } bool CodeGeneratorRequest::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(proto_file_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(proto_file_)) + return false; return true; } @@ -915,16 +928,25 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), GetArenaForAllocation()); } insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_insertion_point()) { insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_insertion_point(), GetArenaForAllocation()); } content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_content()) { content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_content(), GetArenaForAllocation()); @@ -937,10 +959,19 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } -void CodeGeneratorResponse_File::SharedCtor() { +inline void CodeGeneratorResponse_File::SharedCtor() { name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING generated_code_info_ = nullptr; } @@ -971,7 +1002,7 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const { void CodeGeneratorResponse_File::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; @@ -999,12 +1030,12 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; + arc_ui32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string name = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); #ifndef NDEBUG @@ -1016,7 +1047,7 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB continue; // optional string insertion_point = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_insertion_point(); ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); #ifndef NDEBUG @@ -1028,7 +1059,7 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB continue; // optional string content = 15; case 15: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 122)) { auto str = _internal_mutable_content(); ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); #ifndef NDEBUG @@ -1040,7 +1071,7 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB continue; // optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16; case 16: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 130)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 130)) { ptr = ctx->ParseMessage(_internal_mutable_generated_code_info(), ptr); CHK_(ptr); } else @@ -1070,10 +1101,10 @@ failure: #undef CHK_ } -::PROTOBUF_NAMESPACE_ID::uint8* CodeGeneratorResponse_File::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { +uint8_t* CodeGeneratorResponse_File::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _has_bits_[0]; @@ -1127,7 +1158,7 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File) size_t total_size = 0; - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; @@ -1181,7 +1212,7 @@ void CodeGeneratorResponse_File::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) GOOGLE_DCHECK_NE(&from, this); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._has_bits_[0]; @@ -1272,6 +1303,9 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) file_(from.file_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_error()) { error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_error(), GetArenaForAllocation()); @@ -1280,8 +1314,11 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) } -void CodeGeneratorResponse::SharedCtor() { +inline void CodeGeneratorResponse::SharedCtor() { error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING supported_features_ = arc_ui64{0u}; } @@ -1309,7 +1346,7 @@ void CodeGeneratorResponse::SetCachedSize(int size) const { void CodeGeneratorResponse::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; @@ -1327,12 +1364,12 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; + arc_ui32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string error = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_error(); ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); #ifndef NDEBUG @@ -1344,7 +1381,7 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA continue; // optional uint64 supported_features = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_supported_features(&has_bits); supported_features_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); @@ -1353,7 +1390,7 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA continue; // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; case 15: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122)) { + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 122)) { ptr -= 1; do { ptr += 1; @@ -1388,10 +1425,10 @@ failure: #undef CHK_ } -::PROTOBUF_NAMESPACE_ID::uint8* CodeGeneratorResponse::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { +uint8_t* CodeGeneratorResponse::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _has_bits_[0]; @@ -1431,7 +1468,7 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse) size_t total_size = 0; - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; @@ -1476,7 +1513,7 @@ void CodeGeneratorResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) GOOGLE_DCHECK_NE(&from, this); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + arc_ui32 cached_has_bits = 0; (void) cached_has_bits; file_.MergeFrom(from.file_); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h index 1b75172781..2edc4f2ce4 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h @@ -8,12 +8,12 @@ #include <string> #include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3018000 +#if PROTOBUF_VERSION < 3019000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3018003 < PROTOBUF_MIN_PROTOC_VERSION +#if 3019000 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -58,7 +58,7 @@ struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto { PROTOBUF_SECTION_VARIABLE(protodesc_cold); static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; - static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; + static const arc_ui32 offsets[]; }; PROTOC_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; PROTOBUF_NAMESPACE_OPEN @@ -173,7 +173,12 @@ class PROTOC_EXPORT Version final : } inline void Swap(Version* other) { if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -187,11 +192,7 @@ class PROTOC_EXPORT Version final : // implements Message ---------------------------------------------- - inline Version* New() const final { - return new Version(); - } - - Version* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + Version* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage<Version>(arena); } using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; @@ -206,8 +207,8 @@ class PROTOC_EXPORT Version final : size_t ByteSizeLong() const final; const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; int GetCachedSize() const final { return _cached_size_.Get(); } private: @@ -215,6 +216,8 @@ class PROTOC_EXPORT Version final : void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Version* other); + + private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.compiler.Version"; @@ -252,7 +255,7 @@ class PROTOC_EXPORT Version final : template <typename ArgT0 = const TProtoStringType&, typename... ArgT> void set_suffix(ArgT0&& arg0, ArgT... args); TProtoStringType* mutable_suffix(); - PROTOBUF_MUST_USE_RESULT TProtoStringType* release_suffix(); + PROTOBUF_NODISCARD TProtoStringType* release_suffix(); void set_allocated_suffix(TProtoStringType* suffix); private: const TProtoStringType& _internal_suffix() const; @@ -266,11 +269,11 @@ class PROTOC_EXPORT Version final : bool _internal_has_major() const; public: void clear_major(); - ::PROTOBUF_NAMESPACE_ID::int32 major() const; - void set_major(::PROTOBUF_NAMESPACE_ID::int32 value); + arc_i32 major() const; + void set_major(arc_i32 value); private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_major() const; - void _internal_set_major(::PROTOBUF_NAMESPACE_ID::int32 value); + arc_i32 _internal_major() const; + void _internal_set_major(arc_i32 value); public: // optional int32 minor = 2; @@ -279,11 +282,11 @@ class PROTOC_EXPORT Version final : bool _internal_has_minor() const; public: void clear_minor(); - ::PROTOBUF_NAMESPACE_ID::int32 minor() const; - void set_minor(::PROTOBUF_NAMESPACE_ID::int32 value); + arc_i32 minor() const; + void set_minor(arc_i32 value); private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_minor() const; - void _internal_set_minor(::PROTOBUF_NAMESPACE_ID::int32 value); + arc_i32 _internal_minor() const; + void _internal_set_minor(arc_i32 value); public: // optional int32 patch = 3; @@ -292,11 +295,11 @@ class PROTOC_EXPORT Version final : bool _internal_has_patch() const; public: void clear_patch(); - ::PROTOBUF_NAMESPACE_ID::int32 patch() const; - void set_patch(::PROTOBUF_NAMESPACE_ID::int32 value); + arc_i32 patch() const; + void set_patch(arc_i32 value); private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_patch() const; - void _internal_set_patch(::PROTOBUF_NAMESPACE_ID::int32 value); + arc_i32 _internal_patch() const; + void _internal_set_patch(arc_i32 value); public: // @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version) @@ -309,9 +312,9 @@ class PROTOC_EXPORT Version final : ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr suffix_; - ::PROTOBUF_NAMESPACE_ID::int32 major_; - ::PROTOBUF_NAMESPACE_ID::int32 minor_; - ::PROTOBUF_NAMESPACE_ID::int32 patch_; + arc_i32 major_; + arc_i32 minor_; + arc_i32 patch_; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; }; // ------------------------------------------------------------------- @@ -378,7 +381,12 @@ class PROTOC_EXPORT CodeGeneratorRequest final : } inline void Swap(CodeGeneratorRequest* other) { if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -392,11 +400,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final : // implements Message ---------------------------------------------- - inline CodeGeneratorRequest* New() const final { - return new CodeGeneratorRequest(); - } - - CodeGeneratorRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + CodeGeneratorRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage<CodeGeneratorRequest>(arena); } using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; @@ -411,8 +415,8 @@ class PROTOC_EXPORT CodeGeneratorRequest final : size_t ByteSizeLong() const final; const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; int GetCachedSize() const final { return _cached_size_.Get(); } private: @@ -420,6 +424,8 @@ class PROTOC_EXPORT CodeGeneratorRequest final : void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(CodeGeneratorRequest* other); + + private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.compiler.CodeGeneratorRequest"; @@ -499,7 +505,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final : template <typename ArgT0 = const TProtoStringType&, typename... ArgT> void set_parameter(ArgT0&& arg0, ArgT... args); TProtoStringType* mutable_parameter(); - PROTOBUF_MUST_USE_RESULT TProtoStringType* release_parameter(); + PROTOBUF_NODISCARD TProtoStringType* release_parameter(); void set_allocated_parameter(TProtoStringType* parameter); private: const TProtoStringType& _internal_parameter() const; @@ -514,7 +520,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final : public: void clear_compiler_version(); const ::PROTOBUF_NAMESPACE_ID::compiler::Version& compiler_version() const; - PROTOBUF_MUST_USE_RESULT ::PROTOBUF_NAMESPACE_ID::compiler::Version* release_compiler_version(); + PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::compiler::Version* release_compiler_version(); ::PROTOBUF_NAMESPACE_ID::compiler::Version* mutable_compiler_version(); void set_allocated_compiler_version(::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version); private: @@ -604,7 +610,12 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : } inline void Swap(CodeGeneratorResponse_File* other) { if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -618,11 +629,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : // implements Message ---------------------------------------------- - inline CodeGeneratorResponse_File* New() const final { - return new CodeGeneratorResponse_File(); - } - - CodeGeneratorResponse_File* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + CodeGeneratorResponse_File* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage<CodeGeneratorResponse_File>(arena); } using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; @@ -637,8 +644,8 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : size_t ByteSizeLong() const final; const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; int GetCachedSize() const final { return _cached_size_.Get(); } private: @@ -646,6 +653,8 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(CodeGeneratorResponse_File* other); + + private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.compiler.CodeGeneratorResponse.File"; @@ -683,7 +692,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : template <typename ArgT0 = const TProtoStringType&, typename... ArgT> void set_name(ArgT0&& arg0, ArgT... args); TProtoStringType* mutable_name(); - PROTOBUF_MUST_USE_RESULT TProtoStringType* release_name(); + PROTOBUF_NODISCARD TProtoStringType* release_name(); void set_allocated_name(TProtoStringType* name); private: const TProtoStringType& _internal_name() const; @@ -701,7 +710,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : template <typename ArgT0 = const TProtoStringType&, typename... ArgT> void set_insertion_point(ArgT0&& arg0, ArgT... args); TProtoStringType* mutable_insertion_point(); - PROTOBUF_MUST_USE_RESULT TProtoStringType* release_insertion_point(); + PROTOBUF_NODISCARD TProtoStringType* release_insertion_point(); void set_allocated_insertion_point(TProtoStringType* insertion_point); private: const TProtoStringType& _internal_insertion_point() const; @@ -719,7 +728,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : template <typename ArgT0 = const TProtoStringType&, typename... ArgT> void set_content(ArgT0&& arg0, ArgT... args); TProtoStringType* mutable_content(); - PROTOBUF_MUST_USE_RESULT TProtoStringType* release_content(); + PROTOBUF_NODISCARD TProtoStringType* release_content(); void set_allocated_content(TProtoStringType* content); private: const TProtoStringType& _internal_content() const; @@ -734,7 +743,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : public: void clear_generated_code_info(); const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& generated_code_info() const; - PROTOBUF_MUST_USE_RESULT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* release_generated_code_info(); + PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* release_generated_code_info(); ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* mutable_generated_code_info(); void set_allocated_generated_code_info(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info); private: @@ -824,7 +833,12 @@ class PROTOC_EXPORT CodeGeneratorResponse final : } inline void Swap(CodeGeneratorResponse* other) { if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); @@ -838,11 +852,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final : // implements Message ---------------------------------------------- - inline CodeGeneratorResponse* New() const final { - return new CodeGeneratorResponse(); - } - - CodeGeneratorResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + CodeGeneratorResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { return CreateMaybeMessage<CodeGeneratorResponse>(arena); } using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; @@ -857,8 +867,8 @@ class PROTOC_EXPORT CodeGeneratorResponse final : size_t ByteSizeLong() const final; const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; int GetCachedSize() const final { return _cached_size_.Get(); } private: @@ -866,6 +876,8 @@ class PROTOC_EXPORT CodeGeneratorResponse final : void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(CodeGeneratorResponse* other); + + private: friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.compiler.CodeGeneratorResponse"; @@ -952,7 +964,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final : template <typename ArgT0 = const TProtoStringType&, typename... ArgT> void set_error(ArgT0&& arg0, ArgT... args); TProtoStringType* mutable_error(); - PROTOBUF_MUST_USE_RESULT TProtoStringType* release_error(); + PROTOBUF_NODISCARD TProtoStringType* release_error(); void set_allocated_error(TProtoStringType* error); private: const TProtoStringType& _internal_error() const; @@ -966,11 +978,11 @@ class PROTOC_EXPORT CodeGeneratorResponse final : bool _internal_has_supported_features() const; public: void clear_supported_features(); - ::PROTOBUF_NAMESPACE_ID::uint64 supported_features() const; - void set_supported_features(::PROTOBUF_NAMESPACE_ID::uint64 value); + arc_ui64 supported_features() const; + void set_supported_features(arc_ui64 value); private: - ::PROTOBUF_NAMESPACE_ID::uint64 _internal_supported_features() const; - void _internal_set_supported_features(::PROTOBUF_NAMESPACE_ID::uint64 value); + arc_ui64 _internal_supported_features() const; + void _internal_set_supported_features(arc_ui64 value); public: // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse) @@ -984,7 +996,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final : mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File > file_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr error_; - ::PROTOBUF_NAMESPACE_ID::uint64 supported_features_; + arc_ui64 supported_features_; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; }; // =================================================================== @@ -1010,18 +1022,18 @@ inline void Version::clear_major() { major_ = 0; _has_bits_[0] &= ~0x00000002u; } -inline ::PROTOBUF_NAMESPACE_ID::int32 Version::_internal_major() const { +inline arc_i32 Version::_internal_major() const { return major_; } -inline ::PROTOBUF_NAMESPACE_ID::int32 Version::major() const { +inline arc_i32 Version::major() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major) return _internal_major(); } -inline void Version::_internal_set_major(::PROTOBUF_NAMESPACE_ID::int32 value) { +inline void Version::_internal_set_major(arc_i32 value) { _has_bits_[0] |= 0x00000002u; major_ = value; } -inline void Version::set_major(::PROTOBUF_NAMESPACE_ID::int32 value) { +inline void Version::set_major(arc_i32 value) { _internal_set_major(value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major) } @@ -1038,18 +1050,18 @@ inline void Version::clear_minor() { minor_ = 0; _has_bits_[0] &= ~0x00000004u; } -inline ::PROTOBUF_NAMESPACE_ID::int32 Version::_internal_minor() const { +inline arc_i32 Version::_internal_minor() const { return minor_; } -inline ::PROTOBUF_NAMESPACE_ID::int32 Version::minor() const { +inline arc_i32 Version::minor() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor) return _internal_minor(); } -inline void Version::_internal_set_minor(::PROTOBUF_NAMESPACE_ID::int32 value) { +inline void Version::_internal_set_minor(arc_i32 value) { _has_bits_[0] |= 0x00000004u; minor_ = value; } -inline void Version::set_minor(::PROTOBUF_NAMESPACE_ID::int32 value) { +inline void Version::set_minor(arc_i32 value) { _internal_set_minor(value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor) } @@ -1066,18 +1078,18 @@ inline void Version::clear_patch() { patch_ = 0; _has_bits_[0] &= ~0x00000008u; } -inline ::PROTOBUF_NAMESPACE_ID::int32 Version::_internal_patch() const { +inline arc_i32 Version::_internal_patch() const { return patch_; } -inline ::PROTOBUF_NAMESPACE_ID::int32 Version::patch() const { +inline arc_i32 Version::patch() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch) return _internal_patch(); } -inline void Version::_internal_set_patch(::PROTOBUF_NAMESPACE_ID::int32 value) { +inline void Version::_internal_set_patch(arc_i32 value) { _has_bits_[0] |= 0x00000008u; patch_ = value; } -inline void Version::set_patch(::PROTOBUF_NAMESPACE_ID::int32 value) { +inline void Version::set_patch(arc_i32 value) { _internal_set_patch(value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch) } @@ -1127,7 +1139,13 @@ inline TProtoStringType* Version::release_suffix() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return suffix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + auto* p = suffix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (suffix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; } inline void Version::set_allocated_suffix(TProtoStringType* suffix) { if (suffix != nullptr) { @@ -1137,6 +1155,11 @@ inline void Version::set_allocated_suffix(TProtoStringType* suffix) { } suffix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), suffix, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (suffix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) } @@ -1264,7 +1287,13 @@ inline TProtoStringType* CodeGeneratorRequest::release_parameter() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + auto* p = parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (parameter_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; } inline void CodeGeneratorRequest::set_allocated_parameter(TProtoStringType* parameter) { if (parameter != nullptr) { @@ -1274,6 +1303,11 @@ inline void CodeGeneratorRequest::set_allocated_parameter(TProtoStringType* para } parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (parameter_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter) } @@ -1453,7 +1487,13 @@ inline TProtoStringType* CodeGeneratorResponse_File::release_name() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; } inline void CodeGeneratorResponse_File::set_allocated_name(TProtoStringType* name) { if (name != nullptr) { @@ -1463,6 +1503,11 @@ inline void CodeGeneratorResponse_File::set_allocated_name(TProtoStringType* nam } name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) } @@ -1511,7 +1556,13 @@ inline TProtoStringType* CodeGeneratorResponse_File::release_insertion_point() { return nullptr; } _has_bits_[0] &= ~0x00000002u; - return insertion_point_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + auto* p = insertion_point_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (insertion_point_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; } inline void CodeGeneratorResponse_File::set_allocated_insertion_point(TProtoStringType* insertion_point) { if (insertion_point != nullptr) { @@ -1521,6 +1572,11 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(TProtoStri } insertion_point_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), insertion_point, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (insertion_point_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } @@ -1569,7 +1625,13 @@ inline TProtoStringType* CodeGeneratorResponse_File::release_content() { return nullptr; } _has_bits_[0] &= ~0x00000004u; - return content_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + auto* p = content_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (content_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; } inline void CodeGeneratorResponse_File::set_allocated_content(TProtoStringType* content) { if (content != nullptr) { @@ -1579,6 +1641,11 @@ inline void CodeGeneratorResponse_File::set_allocated_content(TProtoStringType* } content_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), content, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (content_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) } @@ -1719,7 +1786,13 @@ inline TProtoStringType* CodeGeneratorResponse::release_error() { return nullptr; } _has_bits_[0] &= ~0x00000001u; - return error_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + auto* p = error_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (error_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; } inline void CodeGeneratorResponse::set_allocated_error(TProtoStringType* error) { if (error != nullptr) { @@ -1729,6 +1802,11 @@ inline void CodeGeneratorResponse::set_allocated_error(TProtoStringType* error) } error_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (error_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { + error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error) } @@ -1744,18 +1822,18 @@ inline void CodeGeneratorResponse::clear_supported_features() { supported_features_ = arc_ui64{0u}; _has_bits_[0] &= ~0x00000002u; } -inline ::PROTOBUF_NAMESPACE_ID::uint64 CodeGeneratorResponse::_internal_supported_features() const { +inline arc_ui64 CodeGeneratorResponse::_internal_supported_features() const { return supported_features_; } -inline ::PROTOBUF_NAMESPACE_ID::uint64 CodeGeneratorResponse::supported_features() const { +inline arc_ui64 CodeGeneratorResponse::supported_features() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.supported_features) return _internal_supported_features(); } -inline void CodeGeneratorResponse::_internal_set_supported_features(::PROTOBUF_NAMESPACE_ID::uint64 value) { +inline void CodeGeneratorResponse::_internal_set_supported_features(arc_ui64 value) { _has_bits_[0] |= 0x00000002u; supported_features_ = value; } -inline void CodeGeneratorResponse::set_supported_features(::PROTOBUF_NAMESPACE_ID::uint64 value) { +inline void CodeGeneratorResponse::set_supported_features(arc_ui64 value) { _internal_set_supported_features(value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.supported_features) } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc index 471cc46ef6..ba79c25908 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc @@ -186,6 +186,8 @@ void PrintTopBoilerplate(io::Printer* printer, const FileDescriptor* file, } printer->Print( "from google.protobuf import descriptor as _descriptor\n" + "from google.protobuf import descriptor_pool as " + "_descriptor_pool\n" "from google.protobuf import message as _message\n" "from google.protobuf import reflection as _reflection\n" "from google.protobuf import symbol_database as " @@ -356,12 +358,32 @@ bool Generator::Generate(const FileDescriptor* file, PrintTopLevelEnums(); PrintTopLevelExtensions(); if (pure_python_workable_) { - PrintAllNestedEnumsInFile(); - PrintMessageDescriptors(); - FixForeignFieldsInDescriptors(); + if (GeneratingDescriptorProto()) { + printer_->Print("if _descriptor._USE_C_DESCRIPTORS == False:\n"); + printer_->Indent(); + // Create enums before message descriptors + PrintAllNestedEnumsInFile(StripPrintDescriptor::kCreate); + PrintMessageDescriptors(StripPrintDescriptor::kCreate); + FixForeignFieldsInDescriptors(); + printer_->Outdent(); + printer_->Print("else:\n"); + printer_->Indent(); + } + // Find the message descriptors first and then use the message + // descriptor to find enums. + PrintMessageDescriptors(StripPrintDescriptor::kFind); + PrintAllNestedEnumsInFile(StripPrintDescriptor::kFind); + if (GeneratingDescriptorProto()) { + printer_->Outdent(); + } } PrintMessages(); if (pure_python_workable_) { + PrintServiceDescriptors(); + + printer.Print("if _descriptor._USE_C_DESCRIPTORS == False:\n"); + printer_->Indent(); + // We have to fix up the extensions after the message classes themselves, // since they need to call static RegisterExtension() methods on these // classes. @@ -372,7 +394,11 @@ bool Generator::Generate(const FileDescriptor* file, // custom options that may be unknown when we define the descriptors. // This does not apply to services because they are not used by extensions. FixAllDescriptorOptions(); - PrintServiceDescriptors(); + + // Set serialized_start and serialized_end. + SetSerializedPbInterval(); + + printer_->Outdent(); } if (HasGenericServices(file)) { PrintServices(); @@ -434,46 +460,65 @@ void Generator::PrintFileDescriptor() const { m["package"] = file_->package(); m["syntax"] = StringifySyntax(file_->syntax()); m["options"] = OptionsValue(file_->options().SerializeAsString()); - const char file_descriptor_template[] = - "$descriptor_name$ = _descriptor.FileDescriptor(\n" - " name='$name$',\n" - " package='$package$',\n" - " syntax='$syntax$',\n" - " serialized_options=$options$,\n" - " create_key=_descriptor._internal_create_key,\n"; - printer_->Print(m, file_descriptor_template); - printer_->Indent(); - if (pure_python_workable_) { - printer_->Print("serialized_pb=b'$value$'\n", "value", - strings::CHexEscape(file_descriptor_serialized_)); - if (file_->dependency_count() != 0) { - printer_->Print(",\ndependencies=["); - for (int i = 0; i < file_->dependency_count(); ++i) { - TProtoStringType module_alias = ModuleAlias(file_->dependency(i)->name()); - printer_->Print("$module_alias$.DESCRIPTOR,", "module_alias", - module_alias); + m["serialized_descriptor"] = strings::CHexEscape(file_descriptor_serialized_); + if (GeneratingDescriptorProto()) { + printer_->Print("if _descriptor._USE_C_DESCRIPTORS == False:\n"); + printer_->Indent(); + // Pure python's AddSerializedFile() depend on the generated + // descriptor_pb2.py thus we can not use AddSerializedFile() when + // generated descriptor.proto for pure python. + const char file_descriptor_template[] = + "$descriptor_name$ = _descriptor.FileDescriptor(\n" + " name='$name$',\n" + " package='$package$',\n" + " syntax='$syntax$',\n" + " serialized_options=$options$,\n" + " create_key=_descriptor._internal_create_key,\n"; + printer_->Print(m, file_descriptor_template); + printer_->Indent(); + if (pure_python_workable_) { + printer_->Print("serialized_pb=b'$value$'\n", "value", + strings::CHexEscape(file_descriptor_serialized_)); + if (file_->dependency_count() != 0) { + printer_->Print(",\ndependencies=["); + for (int i = 0; i < file_->dependency_count(); ++i) { + TProtoStringType module_alias = ModuleAlias(file_->dependency(i)->name()); + printer_->Print("$module_alias$.DESCRIPTOR,", "module_alias", + module_alias); + } + printer_->Print("]"); } - printer_->Print("]"); - } - if (file_->public_dependency_count() > 0) { - printer_->Print(",\npublic_dependencies=["); - for (int i = 0; i < file_->public_dependency_count(); ++i) { - TProtoStringType module_alias = - ModuleAlias(file_->public_dependency(i)->name()); - printer_->Print("$module_alias$.DESCRIPTOR,", "module_alias", - module_alias); + if (file_->public_dependency_count() > 0) { + printer_->Print(",\npublic_dependencies=["); + for (int i = 0; i < file_->public_dependency_count(); ++i) { + TProtoStringType module_alias = + ModuleAlias(file_->public_dependency(i)->name()); + printer_->Print("$module_alias$.DESCRIPTOR,", "module_alias", + module_alias); + } + printer_->Print("]"); } - printer_->Print("]"); + } else { + printer_->Print("serialized_pb=''\n"); } - } else { - printer_->Print("serialized_pb=''\n"); - } - // TODO(falk): Also print options and fix the message_type, enum_type, - // service and extension later in the generation. + // TODO(falk): Also print options and fix the message_type, enum_type, + // service and extension later in the generation. - printer_->Outdent(); - printer_->Print(")\n"); + printer_->Outdent(); + printer_->Print(")\n"); + + printer_->Outdent(); + printer_->Print("else:\n"); + printer_->Indent(); + } + printer_->Print(m, + "$descriptor_name$ = " + "_descriptor_pool.Default().AddSerializedFile(b'$serialized_" + "descriptor$')\n"); + if (GeneratingDescriptorProto()) { + printer_->Outdent(); + } printer_->Print("\n"); } @@ -483,7 +528,7 @@ void Generator::PrintTopLevelEnums() const { std::vector<std::pair<TProtoStringType, int> > top_level_enum_values; for (int i = 0; i < file_->enum_type_count(); ++i) { const EnumDescriptor& enum_descriptor = *file_->enum_type(i); - PrintEnum(enum_descriptor); + PrintFindEnum(enum_descriptor); printer_->Print( "$name$ = " "enum_type_wrapper.EnumTypeWrapper($descriptor_name$)", @@ -507,16 +552,17 @@ void Generator::PrintTopLevelEnums() const { } // Prints all enums contained in all message types in |file|. -void Generator::PrintAllNestedEnumsInFile() const { +void Generator::PrintAllNestedEnumsInFile( + StripPrintDescriptor print_mode) const { for (int i = 0; i < file_->message_type_count(); ++i) { - PrintNestedEnums(*file_->message_type(i)); + PrintNestedEnums(*file_->message_type(i), print_mode); } } // Prints a Python statement assigning the appropriate module-level // enum name to a Python EnumDescriptor object equivalent to // enum_descriptor. -void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const { +void Generator::PrintCreateEnum(const EnumDescriptor& enum_descriptor) const { std::map<TProtoStringType, TProtoStringType> m; TProtoStringType module_level_descriptor_name = ModuleLevelDescriptorName(enum_descriptor); @@ -551,7 +597,6 @@ void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const { printer_->Print("serialized_options=$options_value$,\n", "options_value", OptionsValue(options_string)); EnumDescriptorProto edp; - PrintSerializedPbInterval(enum_descriptor, edp); printer_->Outdent(); printer_->Print(")\n"); if (pure_python_workable_) { @@ -561,20 +606,41 @@ void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const { printer_->Print("\n"); } +void Generator::PrintFindEnum(const EnumDescriptor& enum_descriptor) const { + std::map<TProtoStringType, TProtoStringType> m; + m["descriptor_name"] = ModuleLevelDescriptorName(enum_descriptor); + m["name"] = enum_descriptor.name(); + m["file"] = kDescriptorKey; + if (enum_descriptor.containing_type()) { + m["containing_type"] = + ModuleLevelDescriptorName(*enum_descriptor.containing_type()); + printer_->Print(m, + "$descriptor_name$ = " + "$containing_type$.enum_types_by_name['$name$']\n"); + } else { + printer_->Print( + m, "$descriptor_name$ = $file$.enum_types_by_name['$name$']\n"); + } +} + // Recursively prints enums in nested types within descriptor, then // prints enums contained at the top level in descriptor. -void Generator::PrintNestedEnums(const Descriptor& descriptor) const { +void Generator::PrintNestedEnums(const Descriptor& descriptor, + StripPrintDescriptor print_mode) const { for (int i = 0; i < descriptor.nested_type_count(); ++i) { - PrintNestedEnums(*descriptor.nested_type(i)); + PrintNestedEnums(*descriptor.nested_type(i), print_mode); } for (int i = 0; i < descriptor.enum_type_count(); ++i) { - PrintEnum(*descriptor.enum_type(i)); + if (print_mode == StripPrintDescriptor::kCreate) { + PrintCreateEnum(*descriptor.enum_type(i)); + } else { + PrintFindEnum(*descriptor.enum_type(i)); + } } } void Generator::PrintTopLevelExtensions() const { - const bool is_extension = true; for (int i = 0; i < file_->extension_count(); ++i) { const FieldDescriptor& extension_field = *file_->extension(i); TProtoStringType constant_name = extension_field.name() + "_FIELD_NUMBER"; @@ -582,27 +648,32 @@ void Generator::PrintTopLevelExtensions() const { printer_->Print("$constant_name$ = $number$\n", "constant_name", constant_name, "number", StrCat(extension_field.number())); - printer_->Print("$name$ = ", "name", - ResolveKeyword(extension_field.name())); - PrintFieldDescriptor(extension_field, is_extension); - printer_->Print("\n"); + printer_->Print( + "$resolved_name$ = " + "$file$.extensions_by_name['$name$']\n", + "resolved_name", ResolveKeyword(extension_field.name()), "file", + kDescriptorKey, "name", extension_field.name()); } printer_->Print("\n"); } // Prints Python equivalents of all Descriptors in |file|. -void Generator::PrintMessageDescriptors() const { - for (int i = 0; i < file_->message_type_count(); ++i) { - PrintDescriptor(*file_->message_type(i)); - printer_->Print("\n"); +void Generator::PrintMessageDescriptors(StripPrintDescriptor print_mode) const { + if (print_mode == StripPrintDescriptor::kCreate) { + for (int i = 0; i < file_->message_type_count(); ++i) { + PrintCreateDescriptor(*file_->message_type(i)); + printer_->Print("\n"); + } + } else { + for (int i = 0; i < file_->message_type_count(); ++i) { + PrintFindDescriptor(*file_->message_type(i)); + } } } void Generator::PrintServiceDescriptors() const { for (int i = 0; i < file_->service_count(); ++i) { PrintServiceDescriptor(*file_->service(i)); - AddServiceToFileDescriptor(*file_->service(i)); - printer_->Print("\n"); } } @@ -616,65 +687,11 @@ void Generator::PrintServices() const { void Generator::PrintServiceDescriptor( const ServiceDescriptor& descriptor) const { - printer_->Print("\n"); - TProtoStringType service_name = ModuleLevelServiceDescriptorName(descriptor); - TProtoStringType options_string; - descriptor.options().SerializeToString(&options_string); - - printer_->Print("$service_name$ = _descriptor.ServiceDescriptor(\n", - "service_name", service_name); - printer_->Indent(); std::map<TProtoStringType, TProtoStringType> m; + m["service_name"] = ModuleLevelServiceDescriptorName(descriptor); m["name"] = descriptor.name(); - m["full_name"] = descriptor.full_name(); m["file"] = kDescriptorKey; - m["index"] = StrCat(descriptor.index()); - m["options_value"] = OptionsValue(options_string); - const char required_function_arguments[] = - "name='$name$',\n" - "full_name='$full_name$',\n" - "file=$file$,\n" - "index=$index$,\n" - "serialized_options=$options_value$,\n" - "create_key=_descriptor._internal_create_key,\n"; - printer_->Print(m, required_function_arguments); - - ServiceDescriptorProto sdp; - PrintSerializedPbInterval(descriptor, sdp); - - printer_->Print("methods=[\n"); - for (int i = 0; i < descriptor.method_count(); ++i) { - const MethodDescriptor* method = descriptor.method(i); - method->options().SerializeToString(&options_string); - - m.clear(); - m["name"] = method->name(); - m["full_name"] = method->full_name(); - m["index"] = StrCat(method->index()); - m["serialized_options"] = CEscape(options_string); - m["input_type"] = ModuleLevelDescriptorName(*(method->input_type())); - m["output_type"] = ModuleLevelDescriptorName(*(method->output_type())); - m["options_value"] = OptionsValue(options_string); - printer_->Print("_descriptor.MethodDescriptor(\n"); - printer_->Indent(); - printer_->Print(m, - "name='$name$',\n" - "full_name='$full_name$',\n" - "index=$index$,\n" - "containing_service=None,\n" - "input_type=$input_type$,\n" - "output_type=$output_type$,\n" - "serialized_options=$options_value$,\n" - "create_key=_descriptor._internal_create_key,\n"); - printer_->Outdent(); - printer_->Print("),\n"); - } - - printer_->Outdent(); - printer_->Print("])\n"); - printer_->Print("_sym_db.RegisterServiceDescriptor($name$)\n", "name", - service_name); - printer_->Print("\n"); + printer_->Print(m, "$service_name$ = $file$.services_by_name['$name$']\n"); } void Generator::PrintDescriptorKeyAndModuleName( @@ -719,18 +736,20 @@ void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const { // to a Python Descriptor object for message_descriptor. // // Mutually recursive with PrintNestedDescriptors(). -void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { - PrintNestedDescriptors(message_descriptor); +void Generator::PrintCreateDescriptor( + const Descriptor& message_descriptor) const { + std::map<TProtoStringType, TProtoStringType> m; + m["name"] = message_descriptor.name(); + m["full_name"] = message_descriptor.full_name(); + m["file"] = kDescriptorKey; + + PrintNestedDescriptors(message_descriptor, StripPrintDescriptor::kCreate); printer_->Print("\n"); printer_->Print("$descriptor_name$ = _descriptor.Descriptor(\n", "descriptor_name", ModuleLevelDescriptorName(message_descriptor)); printer_->Indent(); - std::map<TProtoStringType, TProtoStringType> m; - m["name"] = message_descriptor.name(); - m["full_name"] = message_descriptor.full_name(); - m["file"] = kDescriptorKey; const char required_function_arguments[] = "name='$name$',\n" "full_name='$full_name$',\n" @@ -786,12 +805,11 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { printer_->Indent(); for (int i = 0; i < message_descriptor.oneof_decl_count(); ++i) { const OneofDescriptor* desc = message_descriptor.oneof_decl(i); - std::map<TProtoStringType, TProtoStringType> m; + m.clear(); m["name"] = desc->name(); m["full_name"] = desc->full_name(); m["index"] = StrCat(desc->index()); - TProtoStringType options_string = - OptionsValue(desc->options().SerializeAsString()); + options_string = OptionsValue(desc->options().SerializeAsString()); if (options_string == "None") { m["serialized_options"] = ""; } else { @@ -806,22 +824,46 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { } printer_->Outdent(); printer_->Print("],\n"); - // Serialization of proto - DescriptorProto edp; - PrintSerializedPbInterval(message_descriptor, edp); printer_->Outdent(); printer_->Print(")\n"); } +void Generator::PrintFindDescriptor( + const Descriptor& message_descriptor) const { + std::map<TProtoStringType, TProtoStringType> m; + m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor); + m["name"] = message_descriptor.name(); + + if (message_descriptor.containing_type()) { + m["containing_type"] = + ModuleLevelDescriptorName(*message_descriptor.containing_type()); + printer_->Print(m, + "$descriptor_name$ = " + "$containing_type$.nested_types_by_name['$name$']\n"); + } else { + m["file"] = kDescriptorKey; + printer_->Print( + m, "$descriptor_name$ = $file$.message_types_by_name['$name$']\n"); + } + + PrintNestedDescriptors(message_descriptor, StripPrintDescriptor::kFind); +} + // Prints Python Descriptor objects for all nested types contained in // message_descriptor. // // Mutually recursive with PrintDescriptor(). -void Generator::PrintNestedDescriptors( - const Descriptor& containing_descriptor) const { - for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) { - PrintDescriptor(*containing_descriptor.nested_type(i)); +void Generator::PrintNestedDescriptors(const Descriptor& containing_descriptor, + StripPrintDescriptor print_mode) const { + if (print_mode == StripPrintDescriptor::kCreate) { + for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) { + PrintCreateDescriptor(*containing_descriptor.nested_type(i)); + } + } else { + for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) { + PrintFindDescriptor(*containing_descriptor.nested_type(i)); + } } } @@ -1104,10 +1146,6 @@ void Generator::FixForeignFieldsInExtensions() const { void Generator::FixForeignFieldsInExtension( const FieldDescriptor& extension_field) const { GOOGLE_CHECK(extension_field.is_extension()); - // extension_scope() will be NULL for top-level extensions, which is - // exactly what FixForeignFieldsInField() wants. - FixForeignFieldsInField(extension_field.extension_scope(), extension_field, - "extensions_by_name"); std::map<TProtoStringType, TProtoStringType> m; // Confusingly, for FieldDescriptors that happen to be extensions, @@ -1306,7 +1344,8 @@ TProtoStringType Generator::ModuleLevelServiceDescriptorName( // template <typename DescriptorT, typename DescriptorProtoT> void Generator::PrintSerializedPbInterval(const DescriptorT& descriptor, - DescriptorProtoT& proto) const { + DescriptorProtoT& proto, + const TProtoStringType& name) const { descriptor.CopyTo(&proto); TProtoStringType sp; proto.SerializeToString(&sp); @@ -1314,9 +1353,9 @@ void Generator::PrintSerializedPbInterval(const DescriptorT& descriptor, GOOGLE_CHECK_GE(offset, 0); printer_->Print( - "serialized_start=$serialized_start$,\n" - "serialized_end=$serialized_end$,\n", - "serialized_start", StrCat(offset), "serialized_end", + "$name$._serialized_start=$serialized_start$\n" + "$name$._serialized_end=$serialized_end$\n", + "name", name, "serialized_start", StrCat(offset), "serialized_end", StrCat(offset + sp.size())); } @@ -1326,16 +1365,62 @@ void PrintDescriptorOptionsFixingCode(const TProtoStringType& descriptor, io::Printer* printer) { // Reset the _options to None thus DescriptorBase.GetOptions() can // parse _options again after extensions are registered. - printer->Print("$descriptor$._options = None\n", "descriptor", descriptor); + printer->Print( + "$descriptor$._options = None\n" + "$descriptor$._serialized_options = $serialized_value$\n", + "descriptor", descriptor, "serialized_value", options); } } // namespace +void Generator::SetSerializedPbInterval() const { + // Top level enums. + for (int i = 0; i < file_->enum_type_count(); ++i) { + EnumDescriptorProto proto; + const EnumDescriptor& descriptor = *file_->enum_type(i); + PrintSerializedPbInterval(descriptor, proto, + ModuleLevelDescriptorName(descriptor)); + } + + // Messages. + for (int i = 0; i < file_->message_type_count(); ++i) { + SetMessagePbInterval(*file_->message_type(i)); + } + + // Services. + for (int i = 0; i < file_->service_count(); ++i) { + ServiceDescriptorProto proto; + const ServiceDescriptor& service = *file_->service(i); + PrintSerializedPbInterval(service, proto, + ModuleLevelServiceDescriptorName(service)); + } +} + +void Generator::SetMessagePbInterval(const Descriptor& descriptor) const { + DescriptorProto message_proto; + PrintSerializedPbInterval(descriptor, message_proto, + ModuleLevelDescriptorName(descriptor)); + + // Nested messages. + for (int i = 0; i < descriptor.nested_type_count(); ++i) { + SetMessagePbInterval(*descriptor.nested_type(i)); + } + + for (int i = 0; i < descriptor.enum_type_count(); ++i) { + EnumDescriptorProto proto; + const EnumDescriptor& enum_des = *descriptor.enum_type(i); + PrintSerializedPbInterval(enum_des, proto, + ModuleLevelDescriptorName(enum_des)); + } +} + // Prints expressions that set the options field of all descriptors. void Generator::FixAllDescriptorOptions() const { // Prints an expression that sets the file descriptor's options. TProtoStringType file_options = OptionsValue(file_->options().SerializeAsString()); if (file_options != "None") { PrintDescriptorOptionsFixingCode(kDescriptorKey, file_options, printer_); + } else { + printer_->Print("DESCRIPTOR._options = None\n"); } // Prints expressions that set the options for all top level enums. for (int i = 0; i < file_->enum_type_count(); ++i) { @@ -1352,6 +1437,10 @@ void Generator::FixAllDescriptorOptions() const { for (int i = 0; i < file_->message_type_count(); ++i) { FixOptionsForMessage(*file_->message_type(i)); } + + for (int i = 0; i < file_->service_count(); ++i) { + FixOptionsForService(*file_->service(i)); + } } void Generator::FixOptionsForOneof(const OneofDescriptor& oneof) const { @@ -1386,6 +1475,31 @@ void Generator::FixOptionsForEnum(const EnumDescriptor& enum_descriptor) const { } } +// Prints expressions that set the options for an service descriptor and its +// value descriptors. +void Generator::FixOptionsForService( + const ServiceDescriptor& service_descriptor) const { + TProtoStringType descriptor_name = + ModuleLevelServiceDescriptorName(service_descriptor); + TProtoStringType service_options = + OptionsValue(service_descriptor.options().SerializeAsString()); + if (service_options != "None") { + PrintDescriptorOptionsFixingCode(descriptor_name, service_options, + printer_); + } + + for (int i = 0; i < service_descriptor.method_count(); ++i) { + const MethodDescriptor* method = service_descriptor.method(i); + TProtoStringType method_options = + OptionsValue(method->options().SerializeAsString()); + if (method_options != "None") { + TProtoStringType method_name = + descriptor_name + ".methods_by_name['" + method->name() + "']"; + PrintDescriptorOptionsFixingCode(method_name, method_options, printer_); + } + } +} + // Prints expressions that set the options for field descriptors (including // extensions). void Generator::FixOptionsForField(const FieldDescriptor& field) const { diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h index 83dbce951a..d5af959fce 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h @@ -59,6 +59,8 @@ class Printer; namespace compiler { namespace python { +enum class StripPrintDescriptor { kCreate, kFind }; + // CodeGenerator implementation for generated Python protocol buffer classes. // If you create your own protocol compiler binary and you want it to support // Python output, you can do so by registering an instance of this @@ -79,9 +81,11 @@ class PROTOC_EXPORT Generator : public CodeGenerator { void PrintImports() const; void PrintFileDescriptor() const; void PrintTopLevelEnums() const; - void PrintAllNestedEnumsInFile() const; - void PrintNestedEnums(const Descriptor& descriptor) const; - void PrintEnum(const EnumDescriptor& enum_descriptor) const; + void PrintAllNestedEnumsInFile(StripPrintDescriptor print_mode) const; + void PrintNestedEnums(const Descriptor& descriptor, + StripPrintDescriptor print_mode) const; + void PrintCreateEnum(const EnumDescriptor& enum_descriptor) const; + void PrintFindEnum(const EnumDescriptor& enum_descriptor) const; void PrintTopLevelExtensions() const; @@ -93,9 +97,11 @@ class PROTOC_EXPORT Generator : public CodeGenerator { const FieldDescriptor* (Descriptor::*GetterFn)(int)const) const; void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const; void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const; - void PrintMessageDescriptors() const; - void PrintDescriptor(const Descriptor& message_descriptor) const; - void PrintNestedDescriptors(const Descriptor& containing_descriptor) const; + void PrintMessageDescriptors(StripPrintDescriptor print_mode) const; + void PrintCreateDescriptor(const Descriptor& message_descriptor) const; + void PrintFindDescriptor(const Descriptor& message_descriptor) const; + void PrintNestedDescriptors(const Descriptor& containing_descriptor, + StripPrintDescriptor print_mode) const; void PrintMessages() const; void PrintMessage(const Descriptor& message_descriptor, @@ -150,14 +156,19 @@ class PROTOC_EXPORT Generator : public CodeGenerator { template <typename DescriptorT, typename DescriptorProtoT> void PrintSerializedPbInterval(const DescriptorT& descriptor, - DescriptorProtoT& proto) const; + DescriptorProtoT& proto, + const TProtoStringType& name) const; void FixAllDescriptorOptions() const; void FixOptionsForField(const FieldDescriptor& field) const; void FixOptionsForOneof(const OneofDescriptor& oneof) const; void FixOptionsForEnum(const EnumDescriptor& descriptor) const; + void FixOptionsForService(const ServiceDescriptor& descriptor) const; void FixOptionsForMessage(const Descriptor& descriptor) const; + void SetSerializedPbInterval() const; + void SetMessagePbInterval(const Descriptor& descriptor) const; + void CopyPublicDependenciesAliases(const TProtoStringType& copy_from, const FileDescriptor* file) const; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc index acf806a7e6..d4b4b482d6 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/ruby/ruby_generator.cc @@ -465,35 +465,8 @@ void EndPackageModules(int levels, io::Printer* printer) { } } -bool UsesTypeFromFile(const Descriptor* message, const FileDescriptor* file, - TProtoStringType* error) { - for (int i = 0; i < message->field_count(); i++) { - const FieldDescriptor* field = message->field(i); - if ((field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - field->message_type()->file() == file) || - (field->type() == FieldDescriptor::TYPE_ENUM && - field->enum_type()->file() == file)) { - *error = "proto3 message field " + field->full_name() + " in file " + - file->name() + " has a dependency on a type from proto2 file " + - file->name() + - ". Ruby doesn't support proto2 yet, so we must fail."; - return true; - } - } - - for (int i = 0; i < message->nested_type_count(); i++) { - if (UsesTypeFromFile(message->nested_type(i), file, error)) { - return true; - } - } - - return false; -} - bool GenerateDslDescriptor(const FileDescriptor* file, io::Printer* printer, TProtoStringType* error) { - printer->Print( - "require 'google/protobuf'\n\n"); printer->Print("Google::Protobuf::DescriptorPool.generated_pool.build do\n"); printer->Indent(); printer->Print("add_file(\"$filename$\", :syntax => :$syntax$) do\n", @@ -534,8 +507,13 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer, "\n", "filename", file->name()); - for (int i = 0; i < file->dependency_count(); i++) { - printer->Print("require '$name$'\n", "name", GetRequireName(file->dependency(i)->name())); + printer->Print("require 'google/protobuf'\n\n"); + + if (file->dependency_count() != 0) { + for (int i = 0; i < file->dependency_count(); i++) { + printer->Print("require '$name$'\n", "name", GetRequireName(file->dependency(i)->name())); + } + printer->Print("\n"); } // TODO: Remove this when ruby supports extensions for proto2 syntax. |