From 33811d12274c3725ed37582a3d195e505c875f0e Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Fri, 17 Nov 2023 07:20:03 -0800 Subject: [PATCH] Refactor ClassData to use MessageLite for merge_to_from. This CL has no behavior changes, but helps reduce boilerplate changes in a future CL where the signature will be used. PiperOrigin-RevId: 583379506 --- src/google/protobuf/compiler/cpp/message.cc | 9 +- .../compiler/java/java_features.pb.cc | 2 +- .../protobuf/compiler/java/java_features.pb.h | 5 +- src/google/protobuf/compiler/plugin.pb.cc | 8 +- src/google/protobuf/compiler/plugin.pb.h | 20 ++- src/google/protobuf/cpp_features.pb.cc | 2 +- src/google/protobuf/cpp_features.pb.h | 5 +- src/google/protobuf/descriptor.pb.cc | 64 +++---- src/google/protobuf/descriptor.pb.h | 160 +++++++++++------- .../protobuf/generated_message_bases.cc | 4 +- src/google/protobuf/generated_message_bases.h | 2 +- src/google/protobuf/message.cc | 12 +- src/google/protobuf/message.h | 2 +- src/google/protobuf/message_lite.h | 5 +- 14 files changed, 170 insertions(+), 130 deletions(-) diff --git a/src/google/protobuf/compiler/cpp/message.cc b/src/google/protobuf/compiler/cpp/message.cc index 4935b40226..ef41ba3e5f 100644 --- a/src/google/protobuf/compiler/cpp/message.cc +++ b/src/google/protobuf/compiler/cpp/message.cc @@ -1650,8 +1650,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) { void MergeFrom(const $classname$& from) { $classname$::MergeImpl(*this, from); } private: - static void MergeImpl(::$proto_ns$::Message& to_msg, - const ::$proto_ns$::Message& from_msg); + static void MergeImpl( + ::$proto_ns$::MessageLite& to_msg, + const ::$proto_ns$::MessageLite& from_msg); public: )cc"); @@ -3609,8 +3610,8 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) { " $classname$* const _this = this;\n"); } else { format( - "void $classname$::MergeImpl(::$proto_ns$::Message& to_msg, const " - "::$proto_ns$::Message& from_msg) {\n" + "void $classname$::MergeImpl(::$proto_ns$::MessageLite& to_msg, const " + "::$proto_ns$::MessageLite& from_msg) {\n" " auto* const _this = static_cast<$classname$*>(&to_msg);\n" " auto& from = static_cast(from_msg);\n"); } diff --git a/src/google/protobuf/compiler/java/java_features.pb.cc b/src/google/protobuf/compiler/java/java_features.pb.cc index 9e1d960177..9c2c10c108 100644 --- a/src/google/protobuf/compiler/java/java_features.pb.cc +++ b/src/google/protobuf/compiler/java/java_features.pb.cc @@ -322,7 +322,7 @@ const ::_pbi::TcParseTable<1, 2, 1, 0, 2> JavaFeatures::_table_ = { } -void JavaFeatures::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void JavaFeatures::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:pb.JavaFeatures) diff --git a/src/google/protobuf/compiler/java/java_features.pb.h b/src/google/protobuf/compiler/java/java_features.pb.h index 5794d1397e..e311e2e844 100644 --- a/src/google/protobuf/compiler/java/java_features.pb.h +++ b/src/google/protobuf/compiler/java/java_features.pb.h @@ -186,8 +186,9 @@ class PROTOC_EXPORT JavaFeatures final : public ::google::protobuf::Message void MergeFrom(const JavaFeatures& from) { JavaFeatures::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index e9bc8d7374..4047dcebbb 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -547,7 +547,7 @@ const ::_pbi::TcParseTable<2, 4, 0, 47, 2> Version::_table_ = { } -void Version::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void Version::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version) @@ -884,7 +884,7 @@ const ::_pbi::TcParseTable<3, 5, 3, 79, 2> CodeGeneratorRequest::_table_ = { } -void CodeGeneratorRequest::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void CodeGeneratorRequest::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -1207,7 +1207,7 @@ const ::_pbi::TcParseTable<2, 4, 1, 86, 2> CodeGeneratorResponse_File::_table_ = } -void CodeGeneratorResponse_File::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void CodeGeneratorResponse_File::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -1483,7 +1483,7 @@ const ::_pbi::TcParseTable<2, 3, 1, 60, 2> CodeGeneratorResponse::_table_ = { } -void CodeGeneratorResponse::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void CodeGeneratorResponse::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 5175f39931..14ea070a7a 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -203,8 +203,9 @@ class PROTOC_EXPORT Version final : public ::google::protobuf::Message void MergeFrom(const Version& from) { Version::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -414,8 +415,9 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : public ::google::protobuf void MergeFrom(const CodeGeneratorResponse_File& from) { CodeGeneratorResponse_File::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -641,8 +643,9 @@ class PROTOC_EXPORT CodeGeneratorResponse final : public ::google::protobuf::Mes void MergeFrom(const CodeGeneratorResponse& from) { CodeGeneratorResponse::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -867,8 +870,9 @@ class PROTOC_EXPORT CodeGeneratorRequest final : public ::google::protobuf::Mess void MergeFrom(const CodeGeneratorRequest& from) { CodeGeneratorRequest::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; diff --git a/src/google/protobuf/cpp_features.pb.cc b/src/google/protobuf/cpp_features.pb.cc index 3e96ced02e..f7dfe3eb0d 100644 --- a/src/google/protobuf/cpp_features.pb.cc +++ b/src/google/protobuf/cpp_features.pb.cc @@ -260,7 +260,7 @@ const ::_pbi::TcParseTable<0, 1, 0, 0, 2> CppFeatures::_table_ = { } -void CppFeatures::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void CppFeatures::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:pb.CppFeatures) diff --git a/src/google/protobuf/cpp_features.pb.h b/src/google/protobuf/cpp_features.pb.h index 7f653c99b2..6db7031969 100644 --- a/src/google/protobuf/cpp_features.pb.h +++ b/src/google/protobuf/cpp_features.pb.h @@ -155,8 +155,9 @@ class PROTOBUF_EXPORT CppFeatures final : public ::google::protobuf::Message void MergeFrom(const CppFeatures& from) { CppFeatures::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 5f34ccfa62..a89d833a34 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -2500,7 +2500,7 @@ constexpr ::_pbi::TcParseTable<0, 1, 1, 0, 2> FileDescriptorSet::_table_ = { } -void FileDescriptorSet::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void FileDescriptorSet::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet) @@ -3017,7 +3017,7 @@ constexpr ::_pbi::TcParseTable<4, 13, 7, 79, 2> FileDescriptorProto::_table_ = { } -void FileDescriptorProto::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void FileDescriptorProto::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -3347,7 +3347,7 @@ constexpr ::_pbi::TcParseTable<2, 3, 1, 0, 2> DescriptorProto_ExtensionRange::_t } -void DescriptorProto_ExtensionRange::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void DescriptorProto_ExtensionRange::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -3583,7 +3583,7 @@ constexpr ::_pbi::TcParseTable<1, 2, 0, 0, 2> DescriptorProto_ReservedRange::_ta } -void DescriptorProto_ReservedRange::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void DescriptorProto_ReservedRange::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) @@ -4027,7 +4027,7 @@ constexpr ::_pbi::TcParseTable<4, 10, 8, 65, 2> DescriptorProto::_table_ = { } -void DescriptorProto::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void DescriptorProto::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -4391,7 +4391,7 @@ constexpr ::_pbi::TcParseTable<3, 5, 0, 71, 2> ExtensionRangeOptions_Declaration } -void ExtensionRangeOptions_Declaration::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void ExtensionRangeOptions_Declaration::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ExtensionRangeOptions.Declaration) @@ -4706,7 +4706,7 @@ constexpr ::_pbi::TcParseTable<3, 4, 4, 0, 12> ExtensionRangeOptions::_table_ = } -void ExtensionRangeOptions::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void ExtensionRangeOptions::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -5208,7 +5208,7 @@ constexpr ::_pbi::TcParseTable<4, 11, 3, 96, 2> FieldDescriptorProto::_table_ = } -void FieldDescriptorProto::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void FieldDescriptorProto::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -5500,7 +5500,7 @@ constexpr ::_pbi::TcParseTable<1, 2, 1, 49, 2> OneofDescriptorProto::_table_ = { } -void OneofDescriptorProto::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void OneofDescriptorProto::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -5731,7 +5731,7 @@ constexpr ::_pbi::TcParseTable<1, 2, 0, 0, 2> EnumDescriptorProto_EnumReservedRa } -void EnumDescriptorProto_EnumReservedRange::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void EnumDescriptorProto_EnumReservedRange::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) @@ -6052,7 +6052,7 @@ constexpr ::_pbi::TcParseTable<3, 5, 3, 61, 2> EnumDescriptorProto::_table_ = { } -void EnumDescriptorProto::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void EnumDescriptorProto::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -6343,7 +6343,7 @@ constexpr ::_pbi::TcParseTable<2, 3, 1, 53, 2> EnumValueDescriptorProto::_table_ } -void EnumValueDescriptorProto::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void EnumValueDescriptorProto::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -6630,7 +6630,7 @@ constexpr ::_pbi::TcParseTable<2, 3, 2, 51, 2> ServiceDescriptorProto::_table_ = } -void ServiceDescriptorProto::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void ServiceDescriptorProto::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -6996,7 +6996,7 @@ constexpr ::_pbi::TcParseTable<3, 6, 1, 71, 2> MethodDescriptorProto::_table_ = } -void MethodDescriptorProto::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void MethodDescriptorProto::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -7764,7 +7764,7 @@ constexpr ::_pbi::TcParseTable<5, 22, 3, 202, 12> FileOptions::_table_ = { } -void FileOptions::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void FileOptions::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -8211,7 +8211,7 @@ constexpr ::_pbi::TcParseTable<3, 7, 2, 0, 7> MessageOptions::_table_ = { } -void MessageOptions::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void MessageOptions::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -8481,7 +8481,7 @@ constexpr ::_pbi::TcParseTable<1, 2, 1, 57, 2> FieldOptions_EditionDefault::_tab } -void FieldOptions_EditionDefault::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void FieldOptions_EditionDefault::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions.EditionDefault) @@ -8972,7 +8972,7 @@ constexpr ::_pbi::TcParseTable<4, 13, 7, 0, 7> FieldOptions::_table_ = { } -void FieldOptions::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void FieldOptions::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -9273,7 +9273,7 @@ constexpr ::_pbi::TcParseTable<2, 2, 2, 0, 7> OneofOptions::_table_ = { } -void OneofOptions::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void OneofOptions::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -9603,7 +9603,7 @@ constexpr ::_pbi::TcParseTable<3, 5, 2, 0, 7> EnumOptions::_table_ = { } -void EnumOptions::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void EnumOptions::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -9934,7 +9934,7 @@ constexpr ::_pbi::TcParseTable<3, 4, 2, 0, 7> EnumValueOptions::_table_ = { } -void EnumValueOptions::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void EnumValueOptions::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -10234,7 +10234,7 @@ constexpr ::_pbi::TcParseTable<2, 3, 2, 0, 12> ServiceOptions::_table_ = { } -void ServiceOptions::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void ServiceOptions::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -10564,7 +10564,7 @@ constexpr ::_pbi::TcParseTable<3, 4, 3, 0, 12> MethodOptions::_table_ = { } -void MethodOptions::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void MethodOptions::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -10827,7 +10827,7 @@ constexpr ::_pbi::TcParseTable<1, 2, 0, 62, 2> UninterpretedOption_NamePart::_ta } -void UninterpretedOption_NamePart::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void UninterpretedOption_NamePart::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart) @@ -11195,7 +11195,7 @@ constexpr ::_pbi::TcParseTable<3, 7, 1, 75, 2> UninterpretedOption::_table_ = { } -void UninterpretedOption::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void UninterpretedOption::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption) @@ -11552,7 +11552,7 @@ constexpr ::_pbi::TcParseTable<3, 6, 6, 0, 2> FeatureSet::_table_ = { } -void FeatureSet::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void FeatureSet::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FeatureSet) @@ -11811,7 +11811,7 @@ constexpr ::_pbi::TcParseTable<1, 2, 2, 0, 2> FeatureSetDefaults_FeatureSetEditi } -void FeatureSetDefaults_FeatureSetEditionDefault::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void FeatureSetDefaults_FeatureSetEditionDefault::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); ::google::protobuf::Arena* arena = _this->GetArena(); @@ -12086,7 +12086,7 @@ constexpr ::_pbi::TcParseTable<1, 3, 3, 0, 2> FeatureSetDefaults::_table_ = { } -void FeatureSetDefaults::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void FeatureSetDefaults::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FeatureSetDefaults) @@ -12429,7 +12429,7 @@ constexpr ::_pbi::TcParseTable<3, 5, 0, 106, 2> SourceCodeInfo_Location::_table_ } -void SourceCodeInfo_Location::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void SourceCodeInfo_Location::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location) @@ -12633,7 +12633,7 @@ constexpr ::_pbi::TcParseTable<0, 1, 1, 0, 2> SourceCodeInfo::_table_ = { } -void SourceCodeInfo::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void SourceCodeInfo::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) @@ -12946,7 +12946,7 @@ constexpr ::_pbi::TcParseTable<3, 5, 1, 64, 2> GeneratedCodeInfo_Annotation::_ta } -void GeneratedCodeInfo_Annotation::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void GeneratedCodeInfo_Annotation::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) @@ -13157,7 +13157,7 @@ constexpr ::_pbi::TcParseTable<0, 1, 1, 0, 2> GeneratedCodeInfo::_table_ = { } -void GeneratedCodeInfo::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) { +void GeneratedCodeInfo::MergeImpl(::google::protobuf::MessageLite& to_msg, const ::google::protobuf::MessageLite& from_msg) { auto* const _this = static_cast(&to_msg); auto& from = static_cast(from_msg); // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo) diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 2e08123230..fe6861b491 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -784,8 +784,9 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : public ::google::prot void MergeFrom(const UninterpretedOption_NamePart& from) { UninterpretedOption_NamePart::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -969,8 +970,9 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : public ::google::protobuf: void MergeFrom(const SourceCodeInfo_Location& from) { SourceCodeInfo_Location::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -1232,8 +1234,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : public ::google::prot void MergeFrom(const GeneratedCodeInfo_Annotation& from) { GeneratedCodeInfo_Annotation::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -1484,8 +1487,9 @@ class PROTOBUF_EXPORT FieldOptions_EditionDefault final : public ::google::proto void MergeFrom(const FieldOptions_EditionDefault& from) { FieldOptions_EditionDefault::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -1669,8 +1673,9 @@ class PROTOBUF_EXPORT FeatureSet final : public ::google::protobuf::Message void MergeFrom(const FeatureSet& from) { FeatureSet::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -2199,8 +2204,9 @@ class PROTOBUF_EXPORT ExtensionRangeOptions_Declaration final : public ::google: void MergeFrom(const ExtensionRangeOptions_Declaration& from) { ExtensionRangeOptions_Declaration::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -2429,8 +2435,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : public ::goo void MergeFrom(const EnumDescriptorProto_EnumReservedRange& from) { EnumDescriptorProto_EnumReservedRange::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -2608,8 +2615,9 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : public ::google::pro void MergeFrom(const DescriptorProto_ReservedRange& from) { DescriptorProto_ReservedRange::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -2787,8 +2795,9 @@ class PROTOBUF_EXPORT UninterpretedOption final : public ::google::protobuf::Mes void MergeFrom(const UninterpretedOption& from) { UninterpretedOption::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -3057,8 +3066,9 @@ class PROTOBUF_EXPORT SourceCodeInfo final : public ::google::protobuf::Message void MergeFrom(const SourceCodeInfo& from) { SourceCodeInfo::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -3230,8 +3240,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : public ::google::protobuf::Messa void MergeFrom(const GeneratedCodeInfo& from) { GeneratedCodeInfo::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -3403,8 +3414,9 @@ class PROTOBUF_EXPORT FeatureSetDefaults_FeatureSetEditionDefault final : public void MergeFrom(const FeatureSetDefaults_FeatureSetEditionDefault& from) { FeatureSetDefaults_FeatureSetEditionDefault::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -3586,8 +3598,9 @@ class PROTOBUF_EXPORT ServiceOptions final : public ::google::protobuf::Message void MergeFrom(const ServiceOptions& from) { ServiceOptions::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -3967,8 +3980,9 @@ class PROTOBUF_EXPORT OneofOptions final : public ::google::protobuf::Message void MergeFrom(const OneofOptions& from) { OneofOptions::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -4335,8 +4349,9 @@ class PROTOBUF_EXPORT MethodOptions final : public ::google::protobuf::Message void MergeFrom(const MethodOptions& from) { MethodOptions::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -4749,8 +4764,9 @@ class PROTOBUF_EXPORT MessageOptions final : public ::google::protobuf::Message void MergeFrom(const MessageOptions& from) { MessageOptions::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -5182,8 +5198,9 @@ class PROTOBUF_EXPORT FileOptions final : public ::google::protobuf::Message void MergeFrom(const FileOptions& from) { FileOptions::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -5890,8 +5907,9 @@ class PROTOBUF_EXPORT FieldOptions final : public ::google::protobuf::Message void MergeFrom(const FieldOptions& from) { FieldOptions::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -6504,8 +6522,9 @@ class PROTOBUF_EXPORT FeatureSetDefaults final : public ::google::protobuf::Mess void MergeFrom(const FeatureSetDefaults& from) { FeatureSetDefaults::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -6704,8 +6723,9 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : public ::google::protobuf::M void MergeFrom(const ExtensionRangeOptions& from) { ExtensionRangeOptions::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -7125,8 +7145,9 @@ class PROTOBUF_EXPORT EnumValueOptions final : public ::google::protobuf::Messag void MergeFrom(const EnumValueOptions& from) { EnumValueOptions::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -7519,8 +7540,9 @@ class PROTOBUF_EXPORT EnumOptions final : public ::google::protobuf::Message void MergeFrom(const EnumOptions& from) { EnumOptions::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -7926,8 +7948,9 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : public ::google::protobuf::Me void MergeFrom(const OneofDescriptorProto& from) { OneofDescriptorProto::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -8115,8 +8138,9 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : public ::google::protobuf::M void MergeFrom(const MethodDescriptorProto& from) { MethodDescriptorProto::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -8368,8 +8392,9 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : public ::google::protobuf::Me void MergeFrom(const FieldDescriptorProto& from) { FieldDescriptorProto::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -8753,8 +8778,9 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : public ::google::protobuf void MergeFrom(const EnumValueDescriptorProto& from) { EnumValueDescriptorProto::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -8955,8 +8981,9 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : public ::google::pr void MergeFrom(const DescriptorProto_ExtensionRange& from) { DescriptorProto_ExtensionRange::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -9151,8 +9178,9 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : public ::google::protobuf:: void MergeFrom(const ServiceDescriptorProto& from) { ServiceDescriptorProto::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -9360,8 +9388,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : public ::google::protobuf::Mes void MergeFrom(const EnumDescriptorProto& from) { EnumDescriptorProto::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -9620,8 +9649,9 @@ class PROTOBUF_EXPORT DescriptorProto final : public ::google::protobuf::Message void MergeFrom(const DescriptorProto& from) { DescriptorProto::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -9981,8 +10011,9 @@ class PROTOBUF_EXPORT FileDescriptorProto final : public ::google::protobuf::Mes void MergeFrom(const FileDescriptorProto& from) { FileDescriptorProto::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; @@ -10388,8 +10419,9 @@ class PROTOBUF_EXPORT FileDescriptorSet final : public ::google::protobuf::Messa void MergeFrom(const FileDescriptorSet& from) { FileDescriptorSet::MergeImpl(*this, from); } private: - static void MergeImpl(::google::protobuf::Message& to_msg, - const ::google::protobuf::Message& from_msg); + static void MergeImpl( + ::google::protobuf::MessageLite& to_msg, + const ::google::protobuf::MessageLite& from_msg); public: ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; diff --git a/src/google/protobuf/generated_message_bases.cc b/src/google/protobuf/generated_message_bases.cc index 45bdf0ceba..90a7921eb7 100644 --- a/src/google/protobuf/generated_message_bases.cc +++ b/src/google/protobuf/generated_message_bases.cc @@ -10,6 +10,7 @@ #include "google/protobuf/generated_message_reflection.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream_impl.h" +#include "google/protobuf/message_lite.h" #include "google/protobuf/parse_context.h" #include "google/protobuf/unknown_field_set.h" #include "google/protobuf/wire_format.h" @@ -76,7 +77,8 @@ failure: return target; } -void ZeroFieldsBase::MergeImpl(Message& to_param, const Message& from_param) { +void ZeroFieldsBase::MergeImpl(MessageLite& to_param, + const MessageLite& from_param) { auto* to = static_cast(&to_param); const auto* from = static_cast(&from_param); ABSL_DCHECK_NE(from, to); diff --git a/src/google/protobuf/generated_message_bases.h b/src/google/protobuf/generated_message_bases.h index 4cd97577e0..9e649d62ce 100644 --- a/src/google/protobuf/generated_message_bases.h +++ b/src/google/protobuf/generated_message_bases.h @@ -47,7 +47,7 @@ class PROTOBUF_EXPORT ZeroFieldsBase : public Message { const ClassData* GetClassData() const final; - static void MergeImpl(Message& to, const Message& from); + static void MergeImpl(MessageLite& to, const MessageLite& from); static void CopyImpl(Message& to, const Message& from); void InternalSwap(ZeroFieldsBase* other); diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index 200ba1e6a2..1b8b329ba6 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -58,20 +58,18 @@ using internal::ReflectionOps; using internal::WireFormat; using internal::WireFormatLite; -void Message::MergeImpl(Message& to, const Message& from) { - ReflectionOps::Merge(from, &to); +void Message::MergeImpl(MessageLite& to, const MessageLite& from) { + ReflectionOps::Merge(DownCast(from), DownCast(&to)); } void Message::MergeFrom(const Message& from) { auto* class_to = GetClassData(); auto* class_from = from.GetClassData(); - auto* merge_to_from = class_to ? class_to->merge_to_from : nullptr; if (class_to == nullptr || class_to != class_from) { - merge_to_from = [](Message& to, const Message& from) { - ReflectionOps::Merge(from, &to); - }; + ReflectionOps::Merge(from, this); + } else { + class_to->merge_to_from(*this, from); } - merge_to_from(*this, from); } void Message::CheckTypeAndMergeFrom(const MessageLite& other) { diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 27a5772d6b..c3b41a0190 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -370,7 +370,7 @@ class PROTOBUF_EXPORT Message : public MessageLite { internal::CachedSize* cached_size) const; // Reflection based version for reflection based types. - static void MergeImpl(Message& to, const Message& from); + static void MergeImpl(MessageLite& to, const MessageLite& from); static const DescriptorMethods kDescriptorMethods; diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index a785a10e8a..dbe08f471f 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -527,7 +527,7 @@ class PROTOBUF_EXPORT MessageLite { // Note: The order of arguments in the functions is chosen so that it has // the same ABI as the member function that calls them. Eg the `this` // pointer becomes the first argument in the free function. - void (*merge_to_from)(Message& to, const Message& from_msg); + void (*merge_to_from)(MessageLite& to, const MessageLite& from_msg); void (*on_demand_register_arena_dtor)(MessageLite& msg, Arena& arena); // LITE objects (ie !descriptor_methods) collocate their name as a // char[] just beyond the ClassData. @@ -536,7 +536,8 @@ class PROTOBUF_EXPORT MessageLite { // Offset of the CachedSize member. uint32_t cached_size_offset; - constexpr ClassData(void (*merge_to_from)(Message& to, const Message&), + constexpr ClassData(void (*merge_to_from)(MessageLite& to, + const MessageLite&), void (*on_demand_register_arena_dtor)(MessageLite&, Arena&), const DescriptorMethods* descriptor_methods,