Updated API for accessing extensions.

PiperOrigin-RevId: 442947856
pull/13171/head
Joshua Haberman 3 years ago committed by Copybara-Service
parent e5468b47f8
commit 76c7ca9327
  1. 2
      upb/decode.c
  2. 2
      upb/msg.c
  3. 2
      upb/msg_internal.h
  4. 2
      upb/reflection.c
  5. 2
      upbc/protoc-gen-upb.cc

@ -905,7 +905,7 @@ static const char* decode_known(upb_Decoder* d, const char* ptr,
const upb_MiniTable_Extension* ext_layout =
(const upb_MiniTable_Extension*)field;
upb_Message_Extension* ext =
_upb_Message_Getorcreateext(msg, ext_layout, &d->arena);
_upb_Message_GetOrCreateExtension(msg, ext_layout, &d->arena);
if (UPB_UNLIKELY(!ext)) return decode_err(d, kUpb_DecodeStatus_OutOfMemory);
msg = &ext->data;
subs = &ext->ext->sub;

@ -153,7 +153,7 @@ void _upb_Message_Clearext(upb_Message* msg,
}
}
upb_Message_Extension* _upb_Message_Getorcreateext(
upb_Message_Extension* _upb_Message_GetOrCreateExtension(
upb_Message* msg, const upb_MiniTable_Extension* e, upb_Arena* arena) {
upb_Message_Extension* ext =
(upb_Message_Extension*)_upb_Message_Getext(msg, e);

@ -324,7 +324,7 @@ typedef struct {
/* Adds the given extension data to the given message. |ext| is copied into the
* message instance. This logically replaces any previously-added extension with
* this number */
upb_Message_Extension* _upb_Message_Getorcreateext(
upb_Message_Extension* _upb_Message_GetOrCreateExtension(
upb_Message* msg, const upb_MiniTable_Extension* ext, upb_Arena* arena);
/* Returns an array of extensions for this message. Note: the array is

@ -202,7 +202,7 @@ make:
bool upb_Message_Set(upb_Message* msg, const upb_FieldDef* f,
upb_MessageValue val, upb_Arena* a) {
if (upb_FieldDef_IsExtension(f)) {
upb_Message_Extension* ext = _upb_Message_Getorcreateext(
upb_Message_Extension* ext = _upb_Message_GetOrCreateExtension(
msg, _upb_FieldDef_ExtensionMiniTable(f), a);
if (!ext) return false;
memcpy(&ext->data, &val, sizeof(val));

@ -776,7 +776,7 @@ void GenerateExtensionInHeader(const protobuf::FieldDescriptor* ext,
R"cc(
UPB_INLINE void $1_set_$2(struct $3* msg, $0 ext, upb_Arena* arena) {
const upb_Message_Extension* msg_ext =
_upb_Message_Getorcreateext(msg, &$4, arena);
_upb_Message_GetOrCreateExtension(msg, &$4, arena);
UPB_ASSERT(msg_ext);
*UPB_PTR_AT(&msg_ext->data, 0, $0) = ext;
}

Loading…
Cancel
Save