From b6b774ee14c30f29604d5a2f7c8a695a65fdae5d Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Fri, 15 Nov 2024 18:22:04 +0000 Subject: [PATCH] Auto-generate files after cl/696922501 --- .../Reflection/FeatureSetDescriptor.g.cs | 17 +++++++ php/ext/google/protobuf/php-upb.c | 50 ++++++++++++------- ruby/ext/google/protobuf_c/ruby-upb.c | 50 ++++++++++++------- 3 files changed, 79 insertions(+), 38 deletions(-) create mode 100644 csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs diff --git a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs b/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs new file mode 100644 index 0000000000000..208ce1fcb6319 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs @@ -0,0 +1,17 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd +#endregion + +namespace Google.Protobuf.Reflection; + +internal sealed partial class FeatureSetDescriptor +{ + // Canonical serialized form of the edition defaults, generated by embed_edition_defaults. + private const string DefaultsBase64 = + "ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH"; +} diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index d3e51ec34dd2a..a269a7dd58d91 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -4267,6 +4267,7 @@ bool upb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2, #include +#include #include @@ -4520,12 +4521,12 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src, } // Clone unknowns. - size_t unknown_size = 0; - const char* ptr = upb_Message_GetUnknown(src, &unknown_size); - if (unknown_size != 0) { - UPB_ASSERT(ptr); + uintptr_t iter = kUpb_Message_UnknownBegin; + upb_StringView unknowns; + while (upb_Message_NextUnknown(src, &unknowns, &iter)) { // Make a copy into destination arena. - if (!UPB_PRIVATE(_upb_Message_AddUnknown)(dst, ptr, unknown_size, arena)) { + if (!UPB_PRIVATE(_upb_Message_AddUnknown)(dst, unknowns.data, unknowns.size, + arena)) { return NULL; } } @@ -6224,11 +6225,14 @@ static upb_Message* _upb_Decoder_ReuseSubMessage( upb_Message* existing = UPB_PRIVATE(_upb_TaggedMessagePtr_GetEmptyMessage)(tagged); upb_Message* promoted = _upb_Decoder_NewSubMessage(d, subs, field, target); - size_t size; - const char* unknown = upb_Message_GetUnknown(existing, &size); - upb_DecodeStatus status = upb_Decode(unknown, size, promoted, subl, d->extreg, - d->options, &d->arena); - if (status != kUpb_DecodeStatus_Ok) _upb_Decoder_ErrorJmp(d, status); + uintptr_t iter = kUpb_Message_UnknownBegin; + upb_StringView unknown; + while (upb_Message_NextUnknown(existing, &unknown, &iter)) { + upb_DecodeStatus status = + upb_Decode(unknown.data, unknown.size, promoted, subl, d->extreg, + d->options, &d->arena); + if (status != kUpb_DecodeStatus_Ok) _upb_Decoder_ErrorJmp(d, status); + } return promoted; } @@ -6594,10 +6598,7 @@ static const char* _upb_Decoder_DecodeToMap( ptr = _upb_Decoder_DecodeSubMessage(d, ptr, &ent.message, subs, field, val->size); - // check if ent had any unknown fields - size_t size; - upb_Message_GetUnknown(&ent.message, &size); - if (size != 0) { + if (upb_Message_HasUnknown(&ent.message)) { char* buf; size_t size; uint32_t tag = @@ -7937,11 +7938,22 @@ static void encode_message(upb_encstate* e, const upb_Message* msg, } if ((e->options & kUpb_EncodeOption_SkipUnknown) == 0) { - size_t unknown_size; - const char* unknown = upb_Message_GetUnknown(msg, &unknown_size); - - if (unknown) { - encode_bytes(e, unknown, unknown_size); + size_t unknown_size = 0; + uintptr_t iter = kUpb_Message_UnknownBegin; + upb_StringView unknown; + // Need to write in reverse order, but list is single-linked; scan to + // reserve capacity up front, then write in-order + while (upb_Message_NextUnknown(msg, &unknown, &iter)) { + unknown_size += unknown.size; + } + if (unknown_size != 0) { + encode_reserve(e, unknown_size); + char* ptr = e->ptr; + iter = kUpb_Message_UnknownBegin; + while (upb_Message_NextUnknown(msg, &unknown, &iter)) { + memcpy(ptr, unknown.data, unknown.size); + ptr += unknown.size; + } } } diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 9102f55a2e77b..0b4b5ff88905c 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -4267,6 +4267,7 @@ bool upb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2, #include +#include #include @@ -4520,12 +4521,12 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src, } // Clone unknowns. - size_t unknown_size = 0; - const char* ptr = upb_Message_GetUnknown(src, &unknown_size); - if (unknown_size != 0) { - UPB_ASSERT(ptr); + uintptr_t iter = kUpb_Message_UnknownBegin; + upb_StringView unknowns; + while (upb_Message_NextUnknown(src, &unknowns, &iter)) { // Make a copy into destination arena. - if (!UPB_PRIVATE(_upb_Message_AddUnknown)(dst, ptr, unknown_size, arena)) { + if (!UPB_PRIVATE(_upb_Message_AddUnknown)(dst, unknowns.data, unknowns.size, + arena)) { return NULL; } } @@ -6224,11 +6225,14 @@ static upb_Message* _upb_Decoder_ReuseSubMessage( upb_Message* existing = UPB_PRIVATE(_upb_TaggedMessagePtr_GetEmptyMessage)(tagged); upb_Message* promoted = _upb_Decoder_NewSubMessage(d, subs, field, target); - size_t size; - const char* unknown = upb_Message_GetUnknown(existing, &size); - upb_DecodeStatus status = upb_Decode(unknown, size, promoted, subl, d->extreg, - d->options, &d->arena); - if (status != kUpb_DecodeStatus_Ok) _upb_Decoder_ErrorJmp(d, status); + uintptr_t iter = kUpb_Message_UnknownBegin; + upb_StringView unknown; + while (upb_Message_NextUnknown(existing, &unknown, &iter)) { + upb_DecodeStatus status = + upb_Decode(unknown.data, unknown.size, promoted, subl, d->extreg, + d->options, &d->arena); + if (status != kUpb_DecodeStatus_Ok) _upb_Decoder_ErrorJmp(d, status); + } return promoted; } @@ -6594,10 +6598,7 @@ static const char* _upb_Decoder_DecodeToMap( ptr = _upb_Decoder_DecodeSubMessage(d, ptr, &ent.message, subs, field, val->size); - // check if ent had any unknown fields - size_t size; - upb_Message_GetUnknown(&ent.message, &size); - if (size != 0) { + if (upb_Message_HasUnknown(&ent.message)) { char* buf; size_t size; uint32_t tag = @@ -7937,11 +7938,22 @@ static void encode_message(upb_encstate* e, const upb_Message* msg, } if ((e->options & kUpb_EncodeOption_SkipUnknown) == 0) { - size_t unknown_size; - const char* unknown = upb_Message_GetUnknown(msg, &unknown_size); - - if (unknown) { - encode_bytes(e, unknown, unknown_size); + size_t unknown_size = 0; + uintptr_t iter = kUpb_Message_UnknownBegin; + upb_StringView unknown; + // Need to write in reverse order, but list is single-linked; scan to + // reserve capacity up front, then write in-order + while (upb_Message_NextUnknown(msg, &unknown, &iter)) { + unknown_size += unknown.size; + } + if (unknown_size != 0) { + encode_reserve(e, unknown_size); + char* ptr = e->ptr; + iter = kUpb_Message_UnknownBegin; + while (upb_Message_NextUnknown(msg, &unknown, &iter)) { + memcpy(ptr, unknown.data, unknown.size); + ptr += unknown.size; + } } }