From 8b3df249ae1078e7edcff9f76b066a50d818d20a Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Tue, 12 Nov 2024 22:23:27 +0000 Subject: [PATCH] Auto-generate files after cl/695864676 --- .../Reflection/FeatureSetDescriptor.g.cs | 17 ++++++++++++ php/ext/google/protobuf/php-upb.c | 27 ++++++++++++------- php/ext/google/protobuf/php-upb.h | 25 +++++++++++++++-- ruby/ext/google/protobuf_c/ruby-upb.c | 27 ++++++++++++------- ruby/ext/google/protobuf_c/ruby-upb.h | 25 +++++++++++++++-- 5 files changed, 97 insertions(+), 24 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 0000000000..208ce1fcb6 --- /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 0acb5805e0..fd2d1eeadb 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -3926,24 +3926,31 @@ const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len) { } } -void upb_Message_DeleteUnknown(upb_Message* msg, const char* data, size_t len) { +bool upb_Message_DeleteUnknown(upb_Message* msg, upb_StringView* data, + uintptr_t* iter) { UPB_ASSERT(!upb_Message_IsFrozen(msg)); + UPB_ASSERT(*iter == kUpb_Message_UnknownBegin + 1); upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); const char* internal_unknown_end = UPB_PTR_AT(in, in->unknown_end, char); #ifndef NDEBUG size_t full_unknown_size; const char* full_unknown = upb_Message_GetUnknown(msg, &full_unknown_size); - UPB_ASSERT((uintptr_t)data >= (uintptr_t)full_unknown); - UPB_ASSERT((uintptr_t)data < (uintptr_t)(full_unknown + full_unknown_size)); - UPB_ASSERT((uintptr_t)(data + len) > (uintptr_t)data); - UPB_ASSERT((uintptr_t)(data + len) <= (uintptr_t)internal_unknown_end); + UPB_ASSERT((uintptr_t)data->data >= (uintptr_t)full_unknown); + UPB_ASSERT((uintptr_t)data->data < + (uintptr_t)(full_unknown + full_unknown_size)); + UPB_ASSERT((uintptr_t)(data->data + data->size) > (uintptr_t)data->data); + UPB_ASSERT((uintptr_t)(data->data + data->size) <= + (uintptr_t)internal_unknown_end); #endif - - if ((data + len) != internal_unknown_end) { - memmove((char*)data, data + len, internal_unknown_end - data - len); - } - in->unknown_end -= len; + const char* end = data->data + data->size; + size_t offset = data->data - (const char*)in; + if (end != internal_unknown_end) { + memmove(UPB_PTR_AT(in, offset, char), end, internal_unknown_end - end); + } + in->unknown_end -= data->size; + data->size = in->unknown_end - offset; + return data->size != 0; } size_t upb_Message_ExtensionCount(const upb_Message* msg) { diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index 337f132b77..8a300d053c 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -4353,8 +4353,29 @@ bool upb_Message_NextUnknown(const upb_Message* msg, upb_StringView* data, // Returns a reference to the message's unknown data. const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len); -// Removes partial unknown data from message. -void upb_Message_DeleteUnknown(upb_Message* msg, const char* data, size_t len); +// Removes a segment of unknown data from the message, advancing to the next +// segment. Returns false if the removed segment was at the end of the last +// chunk. +// +// This must be done while iterating: +// +// uintptr_t iter = kUpb_Message_UnknownBegin; +// upb_StringView data; +// // Iterate chunks +// while (upb_Message_NextUnknown(msg, &data, &iter)) { +// // Iterate within a chunk, deleting ranges +// while (ShouldDeleteSubSegment(&data)) { +// // Data now points to the region to be deleted +// if (!upb_Message_DeleteUnknown(msg, &data, &iter)) return; +// // If DeleteUnknown returned true, then data now points to the +// // remaining unknown fields after the region that was just deleted. +// } +// } +// +// The range given in `data` must be contained inside the most recently +// returned region. +bool upb_Message_DeleteUnknown(upb_Message* msg, upb_StringView* data, + uintptr_t* iter); // Returns the number of extensions present in this message. size_t upb_Message_ExtensionCount(const upb_Message* msg); diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 7d4db7e4fa..584be6eab2 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -3926,24 +3926,31 @@ const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len) { } } -void upb_Message_DeleteUnknown(upb_Message* msg, const char* data, size_t len) { +bool upb_Message_DeleteUnknown(upb_Message* msg, upb_StringView* data, + uintptr_t* iter) { UPB_ASSERT(!upb_Message_IsFrozen(msg)); + UPB_ASSERT(*iter == kUpb_Message_UnknownBegin + 1); upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); const char* internal_unknown_end = UPB_PTR_AT(in, in->unknown_end, char); #ifndef NDEBUG size_t full_unknown_size; const char* full_unknown = upb_Message_GetUnknown(msg, &full_unknown_size); - UPB_ASSERT((uintptr_t)data >= (uintptr_t)full_unknown); - UPB_ASSERT((uintptr_t)data < (uintptr_t)(full_unknown + full_unknown_size)); - UPB_ASSERT((uintptr_t)(data + len) > (uintptr_t)data); - UPB_ASSERT((uintptr_t)(data + len) <= (uintptr_t)internal_unknown_end); + UPB_ASSERT((uintptr_t)data->data >= (uintptr_t)full_unknown); + UPB_ASSERT((uintptr_t)data->data < + (uintptr_t)(full_unknown + full_unknown_size)); + UPB_ASSERT((uintptr_t)(data->data + data->size) > (uintptr_t)data->data); + UPB_ASSERT((uintptr_t)(data->data + data->size) <= + (uintptr_t)internal_unknown_end); #endif - - if ((data + len) != internal_unknown_end) { - memmove((char*)data, data + len, internal_unknown_end - data - len); - } - in->unknown_end -= len; + const char* end = data->data + data->size; + size_t offset = data->data - (const char*)in; + if (end != internal_unknown_end) { + memmove(UPB_PTR_AT(in, offset, char), end, internal_unknown_end - end); + } + in->unknown_end -= data->size; + data->size = in->unknown_end - offset; + return data->size != 0; } size_t upb_Message_ExtensionCount(const upb_Message* msg) { diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index a915b87917..8f0fe1fd90 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -4355,8 +4355,29 @@ bool upb_Message_NextUnknown(const upb_Message* msg, upb_StringView* data, // Returns a reference to the message's unknown data. const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len); -// Removes partial unknown data from message. -void upb_Message_DeleteUnknown(upb_Message* msg, const char* data, size_t len); +// Removes a segment of unknown data from the message, advancing to the next +// segment. Returns false if the removed segment was at the end of the last +// chunk. +// +// This must be done while iterating: +// +// uintptr_t iter = kUpb_Message_UnknownBegin; +// upb_StringView data; +// // Iterate chunks +// while (upb_Message_NextUnknown(msg, &data, &iter)) { +// // Iterate within a chunk, deleting ranges +// while (ShouldDeleteSubSegment(&data)) { +// // Data now points to the region to be deleted +// if (!upb_Message_DeleteUnknown(msg, &data, &iter)) return; +// // If DeleteUnknown returned true, then data now points to the +// // remaining unknown fields after the region that was just deleted. +// } +// } +// +// The range given in `data` must be contained inside the most recently +// returned region. +bool upb_Message_DeleteUnknown(upb_Message* msg, upb_StringView* data, + uintptr_t* iter); // Returns the number of extensions present in this message. size_t upb_Message_ExtensionCount(const upb_Message* msg);