Skip to content

Commit

Permalink
upb: Add upb_Message_GetExtensionArray
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 696640453
  • Loading branch information
honglooker authored and copybara-github committed Nov 14, 2024
1 parent c522231 commit 919775d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions upb/message/accessors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions upb/message/internal/accessors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 919775d

Please sign in to comment.