upb: Add upb_Message_GetExtensionMessage

PiperOrigin-RevId: 693801612
pull/19144/head
Hong Shin 3 weeks ago committed by Copybara-Service
parent d9a8e7a8fc
commit a862499b19
  1. 4
      upb/message/accessors.h
  2. 11
      upb/message/internal/accessors.h

@ -196,6 +196,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_Message* upb_Message_GetExtensionMessage(
const upb_Message* msg, const upb_MiniTableExtension* f,
struct upb_Message* default_val);
// Extension Setters ///////////////////////////////////////////////////////////
UPB_API_INLINE bool upb_Message_SetExtension(upb_Message* msg,

@ -994,6 +994,17 @@ UPB_API_INLINE uint64_t upb_Message_GetExtensionUInt64(
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) {
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Message);
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) ==
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
struct upb_Message* ret;
_upb_Message_GetExtensionField(msg, e, &default_val, &ret);
return ret;
}
#ifdef __cplusplus
} /* extern "C" */
#endif

Loading…
Cancel
Save