upb: Add upb_Message_GetExtensionString

PiperOrigin-RevId: 694107230
pull/19160/head
Hong Shin 4 months ago committed by Copybara-Service
parent d777bd9036
commit 76382571d9
  1. 17
      csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
  2. 5
      upb/message/accessors.h
  3. 12
      upb/message/internal/accessors.h

@ -1,17 +0,0 @@
#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";
}

@ -169,7 +169,6 @@ UPB_API_INLINE void upb_Message_SetBaseFieldUInt64(struct upb_Message* msg,
uint64_t value);
// Extension Getters ///////////////////////////////////////////////////////////
// TODO: b/374976899 - Add support for non scalars
UPB_API_INLINE bool upb_Message_GetExtensionBool(
const upb_Message* msg, const upb_MiniTableExtension* f, bool default_val);
@ -196,6 +195,10 @@ UPB_API_INLINE uint64_t upb_Message_GetExtensionUInt64(
const upb_Message* msg, const upb_MiniTableExtension* f,
uint64_t default_val);
UPB_API_INLINE upb_StringView upb_Message_GetExtensionString(
const upb_Message* msg, const upb_MiniTableExtension* f,
upb_StringView default_val);
UPB_API_INLINE upb_Message* upb_Message_GetExtensionMessage(
const upb_Message* msg, const upb_MiniTableExtension* f,
struct upb_Message* default_val);

@ -994,6 +994,18 @@ UPB_API_INLINE uint64_t upb_Message_GetExtensionUInt64(
return ret;
}
UPB_API_INLINE upb_StringView upb_Message_GetExtensionString(
const struct upb_Message* msg, const upb_MiniTableExtension* e,
upb_StringView default_val) {
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_String ||
upb_MiniTableExtension_CType(e) == kUpb_CType_Bytes);
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) ==
kUpb_FieldRep_StringView);
upb_StringView ret;
_upb_Message_GetExtensionField(msg, e, &default_val, &ret);
return ret;
}
UPB_API_INLINE struct upb_Message* upb_Message_GetExtensionMessage(
const struct upb_Message* msg, const upb_MiniTableExtension* e,
struct upb_Message* default_val) {

Loading…
Cancel
Save