Auto-generate files after cl/592075816

pull/15121/head
Protobuf Team Bot 1 year ago
parent 5b7bafc60e
commit 212067d6a2
  1. 67
      php/ext/google/protobuf/php-upb.c
  2. 43
      php/ext/google/protobuf/php-upb.h
  3. 67
      ruby/ext/google/protobuf_c/ruby-upb.c
  4. 43
      ruby/ext/google/protobuf_c/ruby-upb.h

@ -5934,10 +5934,10 @@ void upb_Arena_DecRefFor(upb_Arena* arena, const void* owner) {
// Must be last.
const upb_Message_Extension* upb_Message_FindExtensionByNumber(
const upb_Message* msg, uint32_t field_number) {
const upb_Extension* upb_Message_FindExtensionByNumber(const upb_Message* msg,
uint32_t field_number) {
size_t count = 0;
const upb_Message_Extension* ext = _upb_Message_Getexts(msg, &count);
const upb_Extension* ext = _upb_Message_Getexts(msg, &count);
while (count--) {
if (upb_MiniTableExtension_Number(ext->ext) == field_number) return ext;
@ -6154,9 +6154,8 @@ static bool upb_Message_Array_DeepClone(const upb_Array* array,
}
static bool upb_Clone_ExtensionValue(
const upb_MiniTableExtension* mini_table_ext,
const upb_Message_Extension* source, upb_Message_Extension* dest,
upb_Arena* arena) {
const upb_MiniTableExtension* mini_table_ext, const upb_Extension* source,
upb_Extension* dest, upb_Arena* arena) {
dest->data = source->data;
return upb_Clone_MessageValue(
&dest->data,
@ -6232,11 +6231,11 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
}
// Clone extensions.
size_t ext_count;
const upb_Message_Extension* ext = _upb_Message_Getexts(src, &ext_count);
const upb_Extension* ext = _upb_Message_Getexts(src, &ext_count);
for (size_t i = 0; i < ext_count; ++i) {
const upb_Message_Extension* msg_ext = &ext[i];
const upb_Extension* msg_ext = &ext[i];
const upb_MiniTableField* field = &msg_ext->ext->UPB_PRIVATE(field);
upb_Message_Extension* dst_ext =
upb_Extension* dst_ext =
_upb_Message_GetOrCreateExtension(dst, msg_ext->ext, arena);
if (!dst_ext) return NULL;
if (upb_MiniTableField_IsScalar(field)) {
@ -6415,10 +6414,10 @@ bool UPB_PRIVATE(_upb_Array_Realloc)(upb_Array* array, size_t min_capacity,
// Must be last.
const upb_Message_Extension* _upb_Message_Getext(
const upb_Message* msg, const upb_MiniTableExtension* e) {
const upb_Extension* _upb_Message_Getext(const upb_Message* msg,
const upb_MiniTableExtension* e) {
size_t n;
const upb_Message_Extension* ext = _upb_Message_Getexts(msg, &n);
const upb_Extension* ext = _upb_Message_Getexts(msg, &n);
// For now we use linear search exclusively to find extensions.
// If this becomes an issue due to messages with lots of extensions,
@ -6432,12 +6431,12 @@ const upb_Message_Extension* _upb_Message_Getext(
return NULL;
}
const upb_Message_Extension* _upb_Message_Getexts(const upb_Message* msg,
size_t* count) {
const upb_Extension* _upb_Message_Getexts(const upb_Message* msg,
size_t* count) {
const upb_Message_Internal* in = upb_Message_Getinternal(msg);
if (in->internal) {
*count = (in->internal->size - in->internal->ext_begin) /
sizeof(upb_Message_Extension);
*count =
(in->internal->size - in->internal->ext_begin) / sizeof(upb_Extension);
return UPB_PTR_AT(in->internal, in->internal->ext_begin, void);
} else {
*count = 0;
@ -6445,16 +6444,16 @@ const upb_Message_Extension* _upb_Message_Getexts(const upb_Message* msg,
}
}
upb_Message_Extension* _upb_Message_GetOrCreateExtension(
upb_Extension* _upb_Message_GetOrCreateExtension(
upb_Message* msg, const upb_MiniTableExtension* e, upb_Arena* arena) {
upb_Message_Extension* ext =
(upb_Message_Extension*)_upb_Message_Getext(msg, e);
upb_Extension* ext = (upb_Extension*)_upb_Message_Getext(msg, e);
if (ext) return ext;
if (!UPB_PRIVATE(_upb_Message_Realloc)(msg, sizeof(upb_Message_Extension), arena)) return NULL;
if (!UPB_PRIVATE(_upb_Message_Realloc)(msg, sizeof(upb_Extension), arena))
return NULL;
upb_Message_Internal* in = upb_Message_Getinternal(msg);
in->internal->ext_begin -= sizeof(upb_Message_Extension);
in->internal->ext_begin -= sizeof(upb_Extension);
ext = UPB_PTR_AT(in->internal, in->internal->ext_begin, void);
memset(ext, 0, sizeof(upb_Message_Extension));
memset(ext, 0, sizeof(upb_Extension));
ext->ext = e;
return ext;
}
@ -6738,17 +6737,16 @@ bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
}
static int _upb_mapsorter_cmpext(const void* _a, const void* _b) {
const upb_Message_Extension* const* a = _a;
const upb_Message_Extension* const* b = _b;
const upb_Extension* const* a = _a;
const upb_Extension* const* b = _b;
uint32_t a_num = upb_MiniTableExtension_Number((*a)->ext);
uint32_t b_num = upb_MiniTableExtension_Number((*b)->ext);
assert(a_num != b_num);
return a_num < b_num ? -1 : 1;
}
bool _upb_mapsorter_pushexts(_upb_mapsorter* s,
const upb_Message_Extension* exts, size_t count,
_upb_sortedmap* sorted) {
bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Extension* exts,
size_t count, _upb_sortedmap* sorted) {
if (!_upb_mapsorter_resize(s, sorted, count)) return false;
for (size_t i = 0; i < count; i++) {
@ -11438,7 +11436,7 @@ bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
if (ext_pool) {
// Return any extensions that are set.
size_t count;
const upb_Message_Extension* ext = _upb_Message_Getexts(msg, &count);
const upb_Extension* ext = _upb_Message_Getexts(msg, &count);
if (i - n < count) {
ext += count - 1 - (i - n);
memcpy(out_val, &ext->data, sizeof(*out_val));
@ -13484,7 +13482,7 @@ enum {
static void upb_Decoder_AddKnownMessageSetItem(
upb_Decoder* d, upb_Message* msg, const upb_MiniTableExtension* item_mt,
const char* data, uint32_t size) {
upb_Message_Extension* ext =
upb_Extension* ext =
_upb_Message_GetOrCreateExtension(msg, item_mt, &d->arena);
if (UPB_UNLIKELY(!ext)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
@ -13828,7 +13826,7 @@ static const char* _upb_Decoder_DecodeKnownField(
if (UPB_UNLIKELY(mode & kUpb_LabelFlags_IsExtension)) {
const upb_MiniTableExtension* ext_layout =
(const upb_MiniTableExtension*)field;
upb_Message_Extension* ext =
upb_Extension* ext =
_upb_Message_GetOrCreateExtension(msg, ext_layout, &d->arena);
if (UPB_UNLIKELY(!ext)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
@ -15537,8 +15535,7 @@ static void encode_field(upb_encstate* e, const upb_Message* msg,
}
}
static void encode_msgset_item(upb_encstate* e,
const upb_Message_Extension* ext) {
static void encode_msgset_item(upb_encstate* e, const upb_Extension* ext) {
size_t size;
encode_tag(e, kUpb_MsgSet_Item, kUpb_WireType_EndGroup);
encode_message(e, ext->data.ptr,
@ -15550,7 +15547,7 @@ static void encode_msgset_item(upb_encstate* e,
encode_tag(e, kUpb_MsgSet_Item, kUpb_WireType_StartGroup);
}
static void encode_ext(upb_encstate* e, const upb_Message_Extension* ext,
static void encode_ext(upb_encstate* e, const upb_Extension* ext,
bool is_message_set) {
if (UPB_UNLIKELY(is_message_set)) {
encode_msgset_item(e, ext);
@ -15588,7 +15585,7 @@ static void encode_message(upb_encstate* e, const upb_Message* msg,
* these in field number order relative to normal fields or even to each
* other. */
size_t ext_count;
const upb_Message_Extension* ext = _upb_Message_Getexts(msg, &ext_count);
const upb_Extension* ext = _upb_Message_Getexts(msg, &ext_count);
if (ext_count) {
if (e->options & kUpb_EncodeOption_Deterministic) {
_upb_sortedmap sorted;
@ -15598,7 +15595,7 @@ static void encode_message(upb_encstate* e, const upb_Message* msg,
}
_upb_mapsorter_popmap(&e->sorter, &sorted);
} else {
const upb_Message_Extension* end = ext + ext_count;
const upb_Extension* end = ext + ext_count;
for (; ext != end; ext++) {
encode_ext(e, ext, m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet);
}

@ -1625,7 +1625,7 @@ bool upb_MiniTable_NextOneofField(const upb_MiniTable* m,
// Must be last.
typedef struct upb_Message_Extension upb_Message_Extension;
typedef struct upb_Extension upb_Extension;
#ifdef __cplusplus
extern "C" {
@ -1749,7 +1749,7 @@ UPB_API_INLINE void upb_MiniTableExtension_SetSubMessage(
// This is rather wasteful for scalars (in the extreme case of bool,
// it wastes 15 bytes). We accept this because we expect messages to be
// the most common extension type.
struct upb_Message_Extension {
struct upb_Extension {
const upb_MiniTableExtension* ext;
union {
upb_StringView str;
@ -1765,18 +1765,18 @@ extern "C" {
// 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_GetOrCreateExtension(
upb_Extension* _upb_Message_GetOrCreateExtension(
upb_Message* msg, const upb_MiniTableExtension* ext, upb_Arena* arena);
// Returns an array of extensions for this message.
// Note: the array is ordered in reverse relative to the order of creation.
const upb_Message_Extension* _upb_Message_Getexts(const upb_Message* msg,
size_t* count);
const upb_Extension* _upb_Message_Getexts(const upb_Message* msg,
size_t* count);
// Returns an extension for the given field number, or NULL if no extension
// exists for this field number.
const upb_Message_Extension* _upb_Message_Getext(
const upb_Message* msg, const upb_MiniTableExtension* ext);
const upb_Extension* _upb_Message_Getext(const upb_Message* msg,
const upb_MiniTableExtension* ext);
#ifdef __cplusplus
} /* extern "C" */
@ -2381,7 +2381,7 @@ extern const double kUpb_NaN;
struct upb_Message_InternalData {
/* Total size of this structure, including the data that follows.
* Must be aligned to 8, which is alignof(upb_Message_Extension) */
* Must be aligned to 8, which is alignof(upb_Extension) */
uint32_t size;
/* Offsets relative to the beginning of this structure.
@ -2644,7 +2644,7 @@ static UPB_FORCEINLINE void _upb_Message_GetNonExtensionField(
UPB_INLINE void _upb_Message_GetExtensionField(
const upb_Message* msg, const upb_MiniTableExtension* mt_ext,
const void* default_val, void* val) {
const upb_Message_Extension* ext = _upb_Message_Getext(msg, mt_ext);
const upb_Extension* ext = _upb_Message_Getext(msg, mt_ext);
const upb_MiniTableField* f = &mt_ext->UPB_PRIVATE(field);
UPB_ASSUME(upb_MiniTableField_IsExtension(f));
@ -2694,8 +2694,7 @@ UPB_INLINE bool _upb_Message_SetExtensionField(
upb_Message* msg, const upb_MiniTableExtension* mt_ext, const void* val,
upb_Arena* a) {
UPB_ASSERT(a);
upb_Message_Extension* ext =
_upb_Message_GetOrCreateExtension(msg, mt_ext, a);
upb_Extension* ext = _upb_Message_GetOrCreateExtension(msg, mt_ext, a);
if (!ext) return false;
UPB_PRIVATE(_upb_MiniTableField_DataCopy)
(&mt_ext->UPB_PRIVATE(field), &ext->data, val);
@ -2706,13 +2705,12 @@ UPB_INLINE void _upb_Message_ClearExtensionField(
upb_Message* msg, const upb_MiniTableExtension* ext_l) {
upb_Message_Internal* in = upb_Message_Getinternal(msg);
if (!in->internal) return;
const upb_Message_Extension* base =
UPB_PTR_AT(in->internal, in->internal->ext_begin, upb_Message_Extension);
upb_Message_Extension* ext =
(upb_Message_Extension*)_upb_Message_Getext(msg, ext_l);
const upb_Extension* base =
UPB_PTR_AT(in->internal, in->internal->ext_begin, upb_Extension);
upb_Extension* ext = (upb_Extension*)_upb_Message_Getext(msg, ext_l);
if (ext) {
*ext = *base;
in->internal->ext_begin += sizeof(upb_Message_Extension);
in->internal->ext_begin += sizeof(upb_Extension);
}
}
@ -12284,8 +12282,8 @@ extern "C" {
#endif
// Returns the extension with the given field number, or NULL on failure.
const upb_Message_Extension* upb_Message_FindExtensionByNumber(
const upb_Message* msg, uint32_t field_number);
const upb_Extension* upb_Message_FindExtensionByNumber(const upb_Message* msg,
uint32_t field_number);
#ifdef __cplusplus
} /* extern "C" */
@ -12424,9 +12422,9 @@ UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter* s, const upb_Map* map,
UPB_INLINE bool _upb_sortedmap_nextext(_upb_mapsorter* s,
_upb_sortedmap* sorted,
const upb_Message_Extension** ext) {
const upb_Extension** ext) {
if (sorted->pos == sorted->end) return false;
*ext = (const upb_Message_Extension*)s->entries[sorted->pos++];
*ext = (const upb_Extension*)s->entries[sorted->pos++];
return true;
}
@ -12438,9 +12436,8 @@ UPB_INLINE void _upb_mapsorter_popmap(_upb_mapsorter* s,
bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
const upb_Map* map, _upb_sortedmap* sorted);
bool _upb_mapsorter_pushexts(_upb_mapsorter* s,
const upb_Message_Extension* exts, size_t count,
_upb_sortedmap* sorted);
bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Extension* exts,
size_t count, _upb_sortedmap* sorted);
#ifdef __cplusplus
} /* extern "C" */

@ -5448,10 +5448,10 @@ void upb_Arena_DecRefFor(upb_Arena* arena, const void* owner) {
// Must be last.
const upb_Message_Extension* upb_Message_FindExtensionByNumber(
const upb_Message* msg, uint32_t field_number) {
const upb_Extension* upb_Message_FindExtensionByNumber(const upb_Message* msg,
uint32_t field_number) {
size_t count = 0;
const upb_Message_Extension* ext = _upb_Message_Getexts(msg, &count);
const upb_Extension* ext = _upb_Message_Getexts(msg, &count);
while (count--) {
if (upb_MiniTableExtension_Number(ext->ext) == field_number) return ext;
@ -5668,9 +5668,8 @@ static bool upb_Message_Array_DeepClone(const upb_Array* array,
}
static bool upb_Clone_ExtensionValue(
const upb_MiniTableExtension* mini_table_ext,
const upb_Message_Extension* source, upb_Message_Extension* dest,
upb_Arena* arena) {
const upb_MiniTableExtension* mini_table_ext, const upb_Extension* source,
upb_Extension* dest, upb_Arena* arena) {
dest->data = source->data;
return upb_Clone_MessageValue(
&dest->data,
@ -5746,11 +5745,11 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
}
// Clone extensions.
size_t ext_count;
const upb_Message_Extension* ext = _upb_Message_Getexts(src, &ext_count);
const upb_Extension* ext = _upb_Message_Getexts(src, &ext_count);
for (size_t i = 0; i < ext_count; ++i) {
const upb_Message_Extension* msg_ext = &ext[i];
const upb_Extension* msg_ext = &ext[i];
const upb_MiniTableField* field = &msg_ext->ext->UPB_PRIVATE(field);
upb_Message_Extension* dst_ext =
upb_Extension* dst_ext =
_upb_Message_GetOrCreateExtension(dst, msg_ext->ext, arena);
if (!dst_ext) return NULL;
if (upb_MiniTableField_IsScalar(field)) {
@ -5929,10 +5928,10 @@ bool UPB_PRIVATE(_upb_Array_Realloc)(upb_Array* array, size_t min_capacity,
// Must be last.
const upb_Message_Extension* _upb_Message_Getext(
const upb_Message* msg, const upb_MiniTableExtension* e) {
const upb_Extension* _upb_Message_Getext(const upb_Message* msg,
const upb_MiniTableExtension* e) {
size_t n;
const upb_Message_Extension* ext = _upb_Message_Getexts(msg, &n);
const upb_Extension* ext = _upb_Message_Getexts(msg, &n);
// For now we use linear search exclusively to find extensions.
// If this becomes an issue due to messages with lots of extensions,
@ -5946,12 +5945,12 @@ const upb_Message_Extension* _upb_Message_Getext(
return NULL;
}
const upb_Message_Extension* _upb_Message_Getexts(const upb_Message* msg,
size_t* count) {
const upb_Extension* _upb_Message_Getexts(const upb_Message* msg,
size_t* count) {
const upb_Message_Internal* in = upb_Message_Getinternal(msg);
if (in->internal) {
*count = (in->internal->size - in->internal->ext_begin) /
sizeof(upb_Message_Extension);
*count =
(in->internal->size - in->internal->ext_begin) / sizeof(upb_Extension);
return UPB_PTR_AT(in->internal, in->internal->ext_begin, void);
} else {
*count = 0;
@ -5959,16 +5958,16 @@ const upb_Message_Extension* _upb_Message_Getexts(const upb_Message* msg,
}
}
upb_Message_Extension* _upb_Message_GetOrCreateExtension(
upb_Extension* _upb_Message_GetOrCreateExtension(
upb_Message* msg, const upb_MiniTableExtension* e, upb_Arena* arena) {
upb_Message_Extension* ext =
(upb_Message_Extension*)_upb_Message_Getext(msg, e);
upb_Extension* ext = (upb_Extension*)_upb_Message_Getext(msg, e);
if (ext) return ext;
if (!UPB_PRIVATE(_upb_Message_Realloc)(msg, sizeof(upb_Message_Extension), arena)) return NULL;
if (!UPB_PRIVATE(_upb_Message_Realloc)(msg, sizeof(upb_Extension), arena))
return NULL;
upb_Message_Internal* in = upb_Message_Getinternal(msg);
in->internal->ext_begin -= sizeof(upb_Message_Extension);
in->internal->ext_begin -= sizeof(upb_Extension);
ext = UPB_PTR_AT(in->internal, in->internal->ext_begin, void);
memset(ext, 0, sizeof(upb_Message_Extension));
memset(ext, 0, sizeof(upb_Extension));
ext->ext = e;
return ext;
}
@ -6252,17 +6251,16 @@ bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
}
static int _upb_mapsorter_cmpext(const void* _a, const void* _b) {
const upb_Message_Extension* const* a = _a;
const upb_Message_Extension* const* b = _b;
const upb_Extension* const* a = _a;
const upb_Extension* const* b = _b;
uint32_t a_num = upb_MiniTableExtension_Number((*a)->ext);
uint32_t b_num = upb_MiniTableExtension_Number((*b)->ext);
assert(a_num != b_num);
return a_num < b_num ? -1 : 1;
}
bool _upb_mapsorter_pushexts(_upb_mapsorter* s,
const upb_Message_Extension* exts, size_t count,
_upb_sortedmap* sorted) {
bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Extension* exts,
size_t count, _upb_sortedmap* sorted) {
if (!_upb_mapsorter_resize(s, sorted, count)) return false;
for (size_t i = 0; i < count; i++) {
@ -10952,7 +10950,7 @@ bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
if (ext_pool) {
// Return any extensions that are set.
size_t count;
const upb_Message_Extension* ext = _upb_Message_Getexts(msg, &count);
const upb_Extension* ext = _upb_Message_Getexts(msg, &count);
if (i - n < count) {
ext += count - 1 - (i - n);
memcpy(out_val, &ext->data, sizeof(*out_val));
@ -12998,7 +12996,7 @@ enum {
static void upb_Decoder_AddKnownMessageSetItem(
upb_Decoder* d, upb_Message* msg, const upb_MiniTableExtension* item_mt,
const char* data, uint32_t size) {
upb_Message_Extension* ext =
upb_Extension* ext =
_upb_Message_GetOrCreateExtension(msg, item_mt, &d->arena);
if (UPB_UNLIKELY(!ext)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
@ -13342,7 +13340,7 @@ static const char* _upb_Decoder_DecodeKnownField(
if (UPB_UNLIKELY(mode & kUpb_LabelFlags_IsExtension)) {
const upb_MiniTableExtension* ext_layout =
(const upb_MiniTableExtension*)field;
upb_Message_Extension* ext =
upb_Extension* ext =
_upb_Message_GetOrCreateExtension(msg, ext_layout, &d->arena);
if (UPB_UNLIKELY(!ext)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
@ -15051,8 +15049,7 @@ static void encode_field(upb_encstate* e, const upb_Message* msg,
}
}
static void encode_msgset_item(upb_encstate* e,
const upb_Message_Extension* ext) {
static void encode_msgset_item(upb_encstate* e, const upb_Extension* ext) {
size_t size;
encode_tag(e, kUpb_MsgSet_Item, kUpb_WireType_EndGroup);
encode_message(e, ext->data.ptr,
@ -15064,7 +15061,7 @@ static void encode_msgset_item(upb_encstate* e,
encode_tag(e, kUpb_MsgSet_Item, kUpb_WireType_StartGroup);
}
static void encode_ext(upb_encstate* e, const upb_Message_Extension* ext,
static void encode_ext(upb_encstate* e, const upb_Extension* ext,
bool is_message_set) {
if (UPB_UNLIKELY(is_message_set)) {
encode_msgset_item(e, ext);
@ -15102,7 +15099,7 @@ static void encode_message(upb_encstate* e, const upb_Message* msg,
* these in field number order relative to normal fields or even to each
* other. */
size_t ext_count;
const upb_Message_Extension* ext = _upb_Message_Getexts(msg, &ext_count);
const upb_Extension* ext = _upb_Message_Getexts(msg, &ext_count);
if (ext_count) {
if (e->options & kUpb_EncodeOption_Deterministic) {
_upb_sortedmap sorted;
@ -15112,7 +15109,7 @@ static void encode_message(upb_encstate* e, const upb_Message* msg,
}
_upb_mapsorter_popmap(&e->sorter, &sorted);
} else {
const upb_Message_Extension* end = ext + ext_count;
const upb_Extension* end = ext + ext_count;
for (; ext != end; ext++) {
encode_ext(e, ext, m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet);
}

@ -1627,7 +1627,7 @@ bool upb_MiniTable_NextOneofField(const upb_MiniTable* m,
// Must be last.
typedef struct upb_Message_Extension upb_Message_Extension;
typedef struct upb_Extension upb_Extension;
#ifdef __cplusplus
extern "C" {
@ -1751,7 +1751,7 @@ UPB_API_INLINE void upb_MiniTableExtension_SetSubMessage(
// This is rather wasteful for scalars (in the extreme case of bool,
// it wastes 15 bytes). We accept this because we expect messages to be
// the most common extension type.
struct upb_Message_Extension {
struct upb_Extension {
const upb_MiniTableExtension* ext;
union {
upb_StringView str;
@ -1767,18 +1767,18 @@ extern "C" {
// 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_GetOrCreateExtension(
upb_Extension* _upb_Message_GetOrCreateExtension(
upb_Message* msg, const upb_MiniTableExtension* ext, upb_Arena* arena);
// Returns an array of extensions for this message.
// Note: the array is ordered in reverse relative to the order of creation.
const upb_Message_Extension* _upb_Message_Getexts(const upb_Message* msg,
size_t* count);
const upb_Extension* _upb_Message_Getexts(const upb_Message* msg,
size_t* count);
// Returns an extension for the given field number, or NULL if no extension
// exists for this field number.
const upb_Message_Extension* _upb_Message_Getext(
const upb_Message* msg, const upb_MiniTableExtension* ext);
const upb_Extension* _upb_Message_Getext(const upb_Message* msg,
const upb_MiniTableExtension* ext);
#ifdef __cplusplus
} /* extern "C" */
@ -2383,7 +2383,7 @@ extern const double kUpb_NaN;
struct upb_Message_InternalData {
/* Total size of this structure, including the data that follows.
* Must be aligned to 8, which is alignof(upb_Message_Extension) */
* Must be aligned to 8, which is alignof(upb_Extension) */
uint32_t size;
/* Offsets relative to the beginning of this structure.
@ -2646,7 +2646,7 @@ static UPB_FORCEINLINE void _upb_Message_GetNonExtensionField(
UPB_INLINE void _upb_Message_GetExtensionField(
const upb_Message* msg, const upb_MiniTableExtension* mt_ext,
const void* default_val, void* val) {
const upb_Message_Extension* ext = _upb_Message_Getext(msg, mt_ext);
const upb_Extension* ext = _upb_Message_Getext(msg, mt_ext);
const upb_MiniTableField* f = &mt_ext->UPB_PRIVATE(field);
UPB_ASSUME(upb_MiniTableField_IsExtension(f));
@ -2696,8 +2696,7 @@ UPB_INLINE bool _upb_Message_SetExtensionField(
upb_Message* msg, const upb_MiniTableExtension* mt_ext, const void* val,
upb_Arena* a) {
UPB_ASSERT(a);
upb_Message_Extension* ext =
_upb_Message_GetOrCreateExtension(msg, mt_ext, a);
upb_Extension* ext = _upb_Message_GetOrCreateExtension(msg, mt_ext, a);
if (!ext) return false;
UPB_PRIVATE(_upb_MiniTableField_DataCopy)
(&mt_ext->UPB_PRIVATE(field), &ext->data, val);
@ -2708,13 +2707,12 @@ UPB_INLINE void _upb_Message_ClearExtensionField(
upb_Message* msg, const upb_MiniTableExtension* ext_l) {
upb_Message_Internal* in = upb_Message_Getinternal(msg);
if (!in->internal) return;
const upb_Message_Extension* base =
UPB_PTR_AT(in->internal, in->internal->ext_begin, upb_Message_Extension);
upb_Message_Extension* ext =
(upb_Message_Extension*)_upb_Message_Getext(msg, ext_l);
const upb_Extension* base =
UPB_PTR_AT(in->internal, in->internal->ext_begin, upb_Extension);
upb_Extension* ext = (upb_Extension*)_upb_Message_Getext(msg, ext_l);
if (ext) {
*ext = *base;
in->internal->ext_begin += sizeof(upb_Message_Extension);
in->internal->ext_begin += sizeof(upb_Extension);
}
}
@ -12056,8 +12054,8 @@ extern "C" {
#endif
// Returns the extension with the given field number, or NULL on failure.
const upb_Message_Extension* upb_Message_FindExtensionByNumber(
const upb_Message* msg, uint32_t field_number);
const upb_Extension* upb_Message_FindExtensionByNumber(const upb_Message* msg,
uint32_t field_number);
#ifdef __cplusplus
} /* extern "C" */
@ -12196,9 +12194,9 @@ UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter* s, const upb_Map* map,
UPB_INLINE bool _upb_sortedmap_nextext(_upb_mapsorter* s,
_upb_sortedmap* sorted,
const upb_Message_Extension** ext) {
const upb_Extension** ext) {
if (sorted->pos == sorted->end) return false;
*ext = (const upb_Message_Extension*)s->entries[sorted->pos++];
*ext = (const upb_Extension*)s->entries[sorted->pos++];
return true;
}
@ -12210,9 +12208,8 @@ UPB_INLINE void _upb_mapsorter_popmap(_upb_mapsorter* s,
bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
const upb_Map* map, _upb_sortedmap* sorted);
bool _upb_mapsorter_pushexts(_upb_mapsorter* s,
const upb_Message_Extension* exts, size_t count,
_upb_sortedmap* sorted);
bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Extension* exts,
size_t count, _upb_sortedmap* sorted);
#ifdef __cplusplus
} /* extern "C" */

Loading…
Cancel
Save