From 919775de74969e3d42209b51282cd9543f69ced4 Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Thu, 14 Nov 2024 13:56:22 -0800 Subject: [PATCH] upb: Add upb_Message_GetExtensionArray PiperOrigin-RevId: 696640453 --- upb/message/accessors.h | 3 +++ upb/message/internal/accessors.h | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/upb/message/accessors.h b/upb/message/accessors.h index f262609277..7dfb2f5ac0 100644 --- a/upb/message/accessors.h +++ b/upb/message/accessors.h @@ -203,6 +203,9 @@ UPB_API_INLINE upb_Message* upb_Message_GetExtensionMessage( const upb_Message* msg, const upb_MiniTableExtension* f, struct upb_Message* default_val); +UPB_API_INLINE const upb_Array* upb_Message_GetExtensionArray( + const upb_Message* msg, const upb_MiniTableExtension* f); + // Extension Setters /////////////////////////////////////////////////////////// UPB_API_INLINE bool upb_Message_SetExtension(upb_Message* msg, diff --git a/upb/message/internal/accessors.h b/upb/message/internal/accessors.h index b289dad07c..5a89323cce 100644 --- a/upb/message/internal/accessors.h +++ b/upb/message/internal/accessors.h @@ -1017,6 +1017,19 @@ UPB_API_INLINE struct upb_Message* upb_Message_GetExtensionMessage( return ret; } +// Repeated +UPB_API_INLINE const upb_Array* upb_Message_GetExtensionArray( + const struct upb_Message* msg, const upb_MiniTableExtension* e) { + UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(&e->UPB_PRIVATE(field)) == + kUpb_FieldRep_NativePointer); + UPB_ASSUME(upb_MiniTableField_IsArray(&e->UPB_PRIVATE(field))); + UPB_ASSUME(e->UPB_PRIVATE(field).presence == 0); + upb_Array* ret; + const upb_Array* default_val = NULL; + _upb_Message_GetExtensionField(msg, e, &default_val, &ret); + return ret; +} + #ifdef __cplusplus } /* extern "C" */ #endif