From 5a95ef8fa20703afef4f88843f55f5bc032d34d3 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Thu, 6 Oct 2022 21:55:54 -0700 Subject: [PATCH] Fixing merge issues --- src/google/protobuf/arena_align.h | 2 +- src/google/protobuf/arena_allocation_policy.h | 2 +- .../compiler/csharp/csharp_map_field.cc | 2 +- src/google/protobuf/json/internal/parser.cc | 12 ++++++------ .../protobuf/json/internal/parser_traits.h | 2 +- .../protobuf/util/message_differencer.h | 19 ++++--------------- .../util/message_differencer_unittest.cc | 3 +++ 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/google/protobuf/arena_align.h b/src/google/protobuf/arena_align.h index 779d54fbb9..28b259d920 100644 --- a/src/google/protobuf/arena_align.h +++ b/src/google/protobuf/arena_align.h @@ -30,7 +30,7 @@ // This file provides alignment utilities for use in arenas. // -// `ArenaAlign` constains a single `align` data member and provides +// `ArenaAlign` contains a single `align` data member and provides // the below functions which operate on the given alignment. // // Ceil(size_t n) - rounds `n` up to the nearest `align` boundary. diff --git a/src/google/protobuf/arena_allocation_policy.h b/src/google/protobuf/arena_allocation_policy.h index 699f8a2253..2427cf4c7d 100644 --- a/src/google/protobuf/arena_allocation_policy.h +++ b/src/google/protobuf/arena_allocation_policy.h @@ -41,7 +41,7 @@ namespace protobuf { namespace internal { // `AllocationPolicy` defines `Arena` allocation policies. Applications can -// customize the inital and maximum sizes for arena allocation, as well as set +// customize the initial and maximum sizes for arena allocation, as well as set // custom allocation and deallocation functions. `AllocationPolicy` is for // protocol buffer internal use only, and typically created from a user facing // public configuration class such as `ArenaOptions`. diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc index efe87f2a6a..50d8b1d828 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc @@ -88,7 +88,7 @@ void MapFieldGenerator::GenerateMembers(io::Printer* printer) { void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) { printer->Print( variables_, - "$name$_.Add(other.$name$_);\n"); + "$name$_.MergeFrom(other.$name$_);\n"); } void MapFieldGenerator::GenerateParsingCode(io::Printer* printer) { diff --git a/src/google/protobuf/json/internal/parser.cc b/src/google/protobuf/json/internal/parser.cc index 6655aae492..a7706f682b 100644 --- a/src/google/protobuf/json/internal/parser.cc +++ b/src/google/protobuf/json/internal/parser.cc @@ -75,20 +75,20 @@ namespace { // convert it into some form of proto. // // This semantic layer is duplicated: proto2-ish code can deserialize directly -// into a message, wheras proto3-ish code deserializes into a byte stream, using -// TypeResolvers instead of Descriptors. +// into a message, whereas proto3-ish code deserializes into a byte stream, +// using TypeResolvers instead of Descriptors. // // The parsing code is templated over which of these two reflection + output // combinations is used. The traits types that collect the per-instantiation // functionality can be found in json_util2_parser_traits-inl.h. -// This table maps an unsigned `char` value, intepreted as an ASCII character, +// This table maps an unsigned `char` value, interpreted as an ASCII character, // to a corresponding value in the base64 alphabet (both traditional and // "web-safe" characters are included). // // If a character is not valid base64, it maps to -1; this is used by the bit // operations that assemble a base64-encoded word to determine if an error -// occured, by checking the sign bit. +// occurred, by checking the sign bit. constexpr signed char kBase64Table[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -226,7 +226,7 @@ absl::StatusOr> ParseIntInner(JsonLexer& lex, double lo, absl::StatusOr> str = lex.ParseUtf8(); RETURN_IF_ERROR(str.status()); // SimpleAtoi will ignore leading and trailing whitespace, so we need - // to check for it outselves. + // to check for it ourselves. for (char c : str->value.AsView()) { if (absl::ascii_isspace(c)) { return lex.Invalid("non-number characters in quoted number"); @@ -1209,7 +1209,7 @@ absl::Status ParseField(JsonLexer& lex, const Desc& desc, if (Traits::IsRepeated(*field)) { if (lex.options().allow_legacy_syntax && !lex.Peek(JsonLexer::kArr)) { - // The original ESF parser premits a single element in place of an array + // The original ESF parser permits a single element in place of an array // thereof. return ParseSingular(lex, *field, msg); } diff --git a/src/google/protobuf/json/internal/parser_traits.h b/src/google/protobuf/json/internal/parser_traits.h index 6bc88736b1..957354cbe4 100644 --- a/src/google/protobuf/json/internal/parser_traits.h +++ b/src/google/protobuf/json/internal/parser_traits.h @@ -105,7 +105,7 @@ struct ParseProto2Descriptor : Proto2Descriptor { /// Functions for writing fields. /// // Marks a field as having been "seen". This will clear the field if it is - // the first occurence thereof. + // the first occurrence thereof. // // All setters call this function automatically, but it may also be called // eagerly to clear a pre-existing value that might not be overwritten, such diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index e87219300c..1985574e41 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h @@ -188,7 +188,7 @@ class PROTOBUF_EXPORT MessageDifferencer { // if the original message packs another Any, then unpacked_any=2, assuming // the differencer unpacked both of them. // - // When an Any object packes a non-Any proto object whose field includes + // When an Any object packs a non-Any proto object whose field includes // Any, then unpacked_any=1. Thus, in most practical applications, // unpacked_any will be 0 or 1. const Message* message1 = nullptr; @@ -330,31 +330,20 @@ class PROTOBUF_EXPORT MessageDifferencer { MapKeyComparator& operator=(const MapKeyComparator&) = delete; virtual ~MapKeyComparator(); - // This method is DEPRECATED. It is never called directly by - // MessageDifferencer. New code should implement only the next form of - // IsMatch. - // - // TODO(b/248337479) Remove this method. - virtual bool IsMatch( - const Message& /* message1 */, const Message& /* message2 */, - const std::vector& /* parent_fields */) const { - GOOGLE_CHECK(false) << "IsMatch() is not implemented."; - return false; - } - // This method should be overridden by every implementation. The arg // unmapped_any is nonzero the original messages provided by the user are of // type google.protobuf.Any. // // More precisely, unpacked_any defines the nesting level of Any. For // example, if Any packs another Any then unpacked_any=2, assuming the - // patcher unpacked both. Note that when an Any object packes a non-Any + // patcher unpacked both. Note that when an Any object packs a non-Any // proto object whose field includes Any, then unpacked_any=1. Thus, in most // practical applications, unpacked_any will be 0 or 1. virtual bool IsMatch(const Message& message1, const Message& message2, int /* unmapped_any */, const std::vector& fields) const { - return IsMatch(message1, message2, fields); + GOOGLE_CHECK(false) << "IsMatch() is not implemented."; + return false; } }; diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc index 93a4553538..8dbe9479c5 100644 --- a/src/google/protobuf/util/message_differencer_unittest.cc +++ b/src/google/protobuf/util/message_differencer_unittest.cc @@ -1907,6 +1907,7 @@ class ValueProductMapKeyComparator public: typedef util::MessageDifferencer::SpecificField SpecificField; bool IsMatch(const Message& message1, const Message& message2, + int unpacked_any, const std::vector& parent_fields) const override { const Reflection* reflection1 = message1.GetReflection(); const Reflection* reflection2 = message2.GetReflection(); @@ -1968,6 +1969,7 @@ class OffsetByOneMapKeyComparator public: typedef util::MessageDifferencer::SpecificField SpecificField; bool IsMatch(const Message& message1, const Message& message2, + int unpacked_any, const std::vector& parent_fields) const override { return parent_fields.back().index + 1 == parent_fields.back().new_index; } @@ -3402,6 +3404,7 @@ class LengthMapKeyComparator public: typedef util::MessageDifferencer::SpecificField SpecificField; bool IsMatch(const Message& message1, const Message& message2, + int unpacked_any, const std::vector& parent_fields) const override { const Reflection* reflection1 = message1.GetReflection(); const Reflection* reflection2 = message2.GetReflection();