upb: Add upb_Message_GetExtensionArray

PiperOrigin-RevId: 696640453
pull/19248/head
Hong Shin 2 weeks ago committed by Copybara-Service
parent c52223127f
commit 919775de74
  1. 3
      upb/message/accessors.h
  2. 13
      upb/message/internal/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,

@ -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

Loading…
Cancel
Save