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
pull/17969/head
Protobuf Team Bot 3 months ago committed by Copybara-Service
parent ede55fec7d
commit eafacfad50
  1. 8
      upb/message/accessors.h
  2. 11
      upb/message/internal/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 @@ UPB_API_INLINE void upb_Message_SetBaseFieldInt64(struct upb_Message* msg,
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 @@ UPB_API_INLINE bool upb_Message_SetInt64(upb_Message* msg,
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);

@ -639,6 +639,13 @@ UPB_API_INLINE void upb_Message_SetBaseFieldInt64(struct upb_Message* msg,
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 bool upb_Message_SetInt64(struct upb_Message* msg,
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

Loading…
Cancel
Save