Introduce upb_Message_SetBaseFieldMessage() This just behaves the same as the pre-existing upb_Message_SetMessage(), but with the intendended naming style (upb_Message_SetMessage should accept an arena and support extensions). PiperOrigin-RevId: 667998428
diff --git a/upb/message/accessors.h b/upb/message/accessors.h index 922026e..613f634 100644 --- a/upb/message/accessors.h +++ b/upb/message/accessors.h
@@ -8,6 +8,8 @@ #ifndef UPB_MESSAGE_ACCESSORS_H_ #define UPB_MESSAGE_ACCESSORS_H_ +#include <stdint.h> + #include "upb/base/string_view.h" #include "upb/mem/arena.h" #include "upb/message/array.h" @@ -150,6 +152,10 @@ const upb_MiniTableField* f, int64_t value); +UPB_API_INLINE void upb_Message_SetBaseFieldMessage(struct upb_Message* msg, + const upb_MiniTableField* f, + upb_Message* value); + UPB_API_INLINE void upb_Message_SetBaseFieldString(struct upb_Message* msg, const upb_MiniTableField* f, upb_StringView value); @@ -222,6 +228,8 @@ const upb_MiniTableField* f, int64_t value, upb_Arena* a); +// Unlike the other similarly-named setters, this function can only be +// called on base fields. Prefer upb_Message_SetBaseFieldMessage(). UPB_API_INLINE void upb_Message_SetMessage(upb_Message* msg, const upb_MiniTableField* f, upb_Message* value);
diff --git a/upb/message/internal/accessors.h b/upb/message/internal/accessors.h index 5bbfb1e..aae0fdc 100644 --- a/upb/message/internal/accessors.h +++ b/upb/message/internal/accessors.h
@@ -639,6 +639,13 @@ upb_Message_SetBaseField(msg, f, &value); } +UPB_API_INLINE void upb_Message_SetBaseFieldMessage(struct upb_Message* msg, + const upb_MiniTableField* f, + struct upb_Message* value) { + UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr) + (msg, f, UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(value, false)); +} + UPB_API_INLINE void upb_Message_SetBaseFieldString(struct upb_Message* msg, const upb_MiniTableField* f, upb_StringView value) { @@ -807,8 +814,8 @@ UPB_API_INLINE void upb_Message_SetMessage(struct upb_Message* msg, const upb_MiniTableField* f, struct upb_Message* value) { - UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr) - (msg, f, UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(value, false)); + UPB_ASSERT(!upb_MiniTableField_IsExtension(f)); + upb_Message_SetBaseFieldMessage(msg, f, value); } // Sets the value of a `string` or `bytes` field. The bytes of the value are not