diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index 8c4b97d225..a01cdc60bb 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -1239,6 +1239,8 @@ UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b) { #ifndef UPB_MESSAGE_ACCESSORS_H_ #define UPB_MESSAGE_ACCESSORS_H_ +#include + #ifndef UPB_MESSAGE_ARRAY_H_ #define UPB_MESSAGE_ARRAY_H_ @@ -3764,6 +3766,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) { @@ -3932,8 +3941,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 @@ -4372,6 +4381,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); @@ -4444,6 +4457,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); diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index 21abe03c76..014e092676 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -1241,6 +1241,8 @@ UPB_INLINE bool upb_StringView_IsEqual(upb_StringView a, upb_StringView b) { #ifndef UPB_MESSAGE_ACCESSORS_H_ #define UPB_MESSAGE_ACCESSORS_H_ +#include + #ifndef UPB_MESSAGE_ARRAY_H_ #define UPB_MESSAGE_ARRAY_H_ @@ -3766,6 +3768,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) { @@ -3934,8 +3943,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 @@ -4374,6 +4383,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); @@ -4446,6 +4459,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);