Auto-generate files after cl/588088145

pull/14967/head
Protobuf Team Bot 12 months ago
parent b603fb69bf
commit 1f5de4a52d
  1. 46
      php/ext/google/protobuf/php-upb.c
  2. 19
      php/ext/google/protobuf/php-upb.h
  3. 46
      ruby/ext/google/protobuf_c/ruby-upb.c
  4. 19
      ruby/ext/google/protobuf_c/ruby-upb.h

@ -6104,7 +6104,7 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
upb_Arena* arena) { upb_Arena* arena) {
upb_StringView empty_string = upb_StringView_FromDataAndSize(NULL, 0); upb_StringView empty_string = upb_StringView_FromDataAndSize(NULL, 0);
// Only copy message area skipping upb_Message_Internal. // Only copy message area skipping upb_Message_Internal.
memcpy(dst, src, mini_table->size); memcpy(dst, src, mini_table->UPB_PRIVATE(size));
for (size_t i = 0; i < mini_table->UPB_PRIVATE(field_count); ++i) { for (size_t i = 0; i < mini_table->UPB_PRIVATE(field_count); ++i) {
const upb_MiniTableField* field = &mini_table->UPB_PRIVATE(fields)[i]; const upb_MiniTableField* field = &mini_table->UPB_PRIVATE(fields)[i];
if (upb_MiniTableField_IsScalar(field)) { if (upb_MiniTableField_IsScalar(field)) {
@ -6213,11 +6213,25 @@ bool upb_Message_DeepCopy(upb_Message* dst, const upb_Message* src,
// Deep clones a message using the provided target arena. // Deep clones a message using the provided target arena.
// //
// Returns NULL on failure. // Returns NULL on failure.
upb_Message* upb_Message_DeepClone(const upb_Message* message, upb_Message* upb_Message_DeepClone(const upb_Message* msg,
const upb_MiniTable* mini_table, const upb_MiniTable* m, upb_Arena* arena) {
upb_Message* clone = upb_Message_New(m, arena);
return _upb_Message_Copy(clone, msg, m, arena);
}
// Performs a shallow copy. TODO: Extend to handle unknown fields.
void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src,
const upb_MiniTable* m) {
memcpy(dst, src, m->UPB_PRIVATE(size));
}
// Performs a shallow clone. Ignores unknown fields.
upb_Message* upb_Message_ShallowClone(const upb_Message* msg,
const upb_MiniTable* m,
upb_Arena* arena) { upb_Arena* arena) {
upb_Message* clone = upb_Message_New(mini_table, arena); upb_Message* clone = upb_Message_New(m, arena);
return _upb_Message_Copy(clone, message, mini_table, arena); upb_Message_ShallowCopy(clone, msg, m);
return clone;
} }
@ -7405,20 +7419,21 @@ static void upb_MtDecoder_AssignHasbits(upb_MtDecoder* d) {
} }
} }
ret->size = last_hasbit ? upb_MiniTable_DivideRoundUp(last_hasbit + 1, 8) : 0; ret->UPB_PRIVATE(size) =
last_hasbit ? upb_MiniTable_DivideRoundUp(last_hasbit + 1, 8) : 0;
} }
size_t upb_MtDecoder_Place(upb_MtDecoder* d, upb_FieldRep rep) { size_t upb_MtDecoder_Place(upb_MtDecoder* d, upb_FieldRep rep) {
size_t size = upb_MtDecoder_SizeOfRep(rep, d->platform); size_t size = upb_MtDecoder_SizeOfRep(rep, d->platform);
size_t align = upb_MtDecoder_AlignOfRep(rep, d->platform); size_t align = upb_MtDecoder_AlignOfRep(rep, d->platform);
size_t ret = UPB_ALIGN_UP(d->table->size, align); size_t ret = UPB_ALIGN_UP(d->table->UPB_PRIVATE(size), align);
static const size_t max = UINT16_MAX; static const size_t max = UINT16_MAX;
size_t new_size = ret + size; size_t new_size = ret + size;
if (new_size > max) { if (new_size > max) {
upb_MdDecoder_ErrorJmp( upb_MdDecoder_ErrorJmp(
&d->base, "Message size exceeded maximum size of %zu bytes", max); &d->base, "Message size exceeded maximum size of %zu bytes", max);
} }
d->table->size = new_size; d->table->UPB_PRIVATE(size) = new_size;
return ret; return ret;
} }
@ -7468,7 +7483,7 @@ static void upb_MtDecoder_AssignOffsets(upb_MtDecoder* d) {
// //
// On 32-bit we could potentially make this smaller, but there is no // On 32-bit we could potentially make this smaller, but there is no
// compelling reason to optimize this right now. // compelling reason to optimize this right now.
d->table->size = UPB_ALIGN_UP(d->table->size, 8); d->table->UPB_PRIVATE(size) = UPB_ALIGN_UP(d->table->UPB_PRIVATE(size), 8);
} }
static void upb_MtDecoder_ValidateEntryField(upb_MtDecoder* d, static void upb_MtDecoder_ValidateEntryField(upb_MtDecoder* d,
@ -7529,7 +7544,8 @@ static void upb_MtDecoder_ParseMap(upb_MtDecoder* d, const char* data,
const size_t hasbit_size = 8; const size_t hasbit_size = 8;
d->fields[0].offset = hasbit_size; d->fields[0].offset = hasbit_size;
d->fields[1].offset = hasbit_size + kv_size; d->fields[1].offset = hasbit_size + kv_size;
d->table->size = UPB_ALIGN_UP(hasbit_size + kv_size + kv_size, 8); d->table->UPB_PRIVATE(size) =
UPB_ALIGN_UP(hasbit_size + kv_size + kv_size, 8);
// Map entries have a special bit set to signal it's a map entry, used in // Map entries have a special bit set to signal it's a map entry, used in
// upb_MiniTable_SetSubMessage() below. // upb_MiniTable_SetSubMessage() below.
@ -7544,7 +7560,7 @@ static void upb_MtDecoder_ParseMessageSet(upb_MtDecoder* d, const char* data,
} }
upb_MiniTable* ret = d->table; upb_MiniTable* ret = d->table;
ret->size = 0; ret->UPB_PRIVATE(size) = 0;
ret->UPB_PRIVATE(field_count) = 0; ret->UPB_PRIVATE(field_count) = 0;
ret->UPB_PRIVATE(ext) = kUpb_ExtMode_IsMessageSet; ret->UPB_PRIVATE(ext) = kUpb_ExtMode_IsMessageSet;
ret->UPB_PRIVATE(dense_below) = 0; ret->UPB_PRIVATE(dense_below) = 0;
@ -7557,7 +7573,7 @@ static upb_MiniTable* upb_MtDecoder_DoBuildMiniTableWithBuf(
size_t* buf_size) { size_t* buf_size) {
upb_MdDecoder_CheckOutOfMemory(&decoder->base, decoder->table); upb_MdDecoder_CheckOutOfMemory(&decoder->base, decoder->table);
decoder->table->size = 0; decoder->table->UPB_PRIVATE(size) = 0;
decoder->table->UPB_PRIVATE(field_count) = 0; decoder->table->UPB_PRIVATE(field_count) = 0;
decoder->table->UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable; decoder->table->UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable;
decoder->table->UPB_PRIVATE(dense_below) = 0; decoder->table->UPB_PRIVATE(dense_below) = 0;
@ -8319,7 +8335,7 @@ bool upb_MiniTable_NextOneofField(const upb_MiniTable* m,
const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty) = { const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty) = {
.UPB_PRIVATE(subs) = NULL, .UPB_PRIVATE(subs) = NULL,
.UPB_PRIVATE(fields) = NULL, .UPB_PRIVATE(fields) = NULL,
.size = 0, .UPB_PRIVATE(size) = 0,
.UPB_PRIVATE(field_count) = 0, .UPB_PRIVATE(field_count) = 0,
.UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable, .UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable,
.UPB_PRIVATE(dense_below) = 0, .UPB_PRIVATE(dense_below) = 0,
@ -14816,9 +14832,9 @@ TAGBYTES(r)
/* message fields *************************************************************/ /* message fields *************************************************************/
UPB_INLINE UPB_INLINE
upb_Message* decode_newmsg_ceil(upb_Decoder* d, const upb_MiniTable* l, upb_Message* decode_newmsg_ceil(upb_Decoder* d, const upb_MiniTable* m,
int msg_ceil_bytes) { int msg_ceil_bytes) {
size_t size = l->size + sizeof(upb_Message_Internal); size_t size = m->UPB_PRIVATE(size) + sizeof(upb_Message_Internal);
char* msg_data; char* msg_data;
if (UPB_LIKELY(msg_ceil_bytes > 0 && if (UPB_LIKELY(msg_ceil_bytes > 0 &&
_upb_ArenaHas(&d->arena) >= msg_ceil_bytes)) { _upb_ArenaHas(&d->arena) >= msg_ceil_bytes)) {

@ -1411,7 +1411,7 @@ struct upb_MiniTable {
// Must be aligned to sizeof(void*). Doesn't include internal members like // Must be aligned to sizeof(void*). Doesn't include internal members like
// unknown fields, extension dict, pointer to msglayout, etc. // unknown fields, extension dict, pointer to msglayout, etc.
uint16_t size; uint16_t UPB_PRIVATE(size);
uint16_t UPB_ONLYBITS(field_count); uint16_t UPB_ONLYBITS(field_count);
@ -2356,7 +2356,7 @@ struct upb_Message_InternalData {
}; };
UPB_INLINE size_t upb_msg_sizeof(const upb_MiniTable* m) { UPB_INLINE size_t upb_msg_sizeof(const upb_MiniTable* m) {
return m->size + sizeof(upb_Message_Internal); return m->UPB_PRIVATE(size) + sizeof(upb_Message_Internal);
} }
// Inline version upb_Message_New(), for internal use. // Inline version upb_Message_New(), for internal use.
@ -12413,9 +12413,12 @@ extern "C" {
#endif #endif
// Deep clones a message using the provided target arena. // Deep clones a message using the provided target arena.
upb_Message* upb_Message_DeepClone(const upb_Message* message, upb_Message* upb_Message_DeepClone(const upb_Message* msg,
const upb_MiniTable* mini_table, const upb_MiniTable* m, upb_Arena* arena);
upb_Arena* arena);
// Shallow clones a message using the provided target arena.
upb_Message* upb_Message_ShallowClone(const upb_Message* msg,
const upb_MiniTable* m, upb_Arena* arena);
// Deep clones array contents. // Deep clones array contents.
upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type, upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type,
@ -12429,7 +12432,11 @@ upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type,
// Deep copies the message from src to dst. // Deep copies the message from src to dst.
bool upb_Message_DeepCopy(upb_Message* dst, const upb_Message* src, bool upb_Message_DeepCopy(upb_Message* dst, const upb_Message* src,
const upb_MiniTable* mini_table, upb_Arena* arena); const upb_MiniTable* m, upb_Arena* arena);
// Shallow copies the message from src to dst.
void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src,
const upb_MiniTable* m);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

@ -5618,7 +5618,7 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
upb_Arena* arena) { upb_Arena* arena) {
upb_StringView empty_string = upb_StringView_FromDataAndSize(NULL, 0); upb_StringView empty_string = upb_StringView_FromDataAndSize(NULL, 0);
// Only copy message area skipping upb_Message_Internal. // Only copy message area skipping upb_Message_Internal.
memcpy(dst, src, mini_table->size); memcpy(dst, src, mini_table->UPB_PRIVATE(size));
for (size_t i = 0; i < mini_table->UPB_PRIVATE(field_count); ++i) { for (size_t i = 0; i < mini_table->UPB_PRIVATE(field_count); ++i) {
const upb_MiniTableField* field = &mini_table->UPB_PRIVATE(fields)[i]; const upb_MiniTableField* field = &mini_table->UPB_PRIVATE(fields)[i];
if (upb_MiniTableField_IsScalar(field)) { if (upb_MiniTableField_IsScalar(field)) {
@ -5727,11 +5727,25 @@ bool upb_Message_DeepCopy(upb_Message* dst, const upb_Message* src,
// Deep clones a message using the provided target arena. // Deep clones a message using the provided target arena.
// //
// Returns NULL on failure. // Returns NULL on failure.
upb_Message* upb_Message_DeepClone(const upb_Message* message, upb_Message* upb_Message_DeepClone(const upb_Message* msg,
const upb_MiniTable* mini_table, const upb_MiniTable* m, upb_Arena* arena) {
upb_Message* clone = upb_Message_New(m, arena);
return _upb_Message_Copy(clone, msg, m, arena);
}
// Performs a shallow copy. TODO: Extend to handle unknown fields.
void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src,
const upb_MiniTable* m) {
memcpy(dst, src, m->UPB_PRIVATE(size));
}
// Performs a shallow clone. Ignores unknown fields.
upb_Message* upb_Message_ShallowClone(const upb_Message* msg,
const upb_MiniTable* m,
upb_Arena* arena) { upb_Arena* arena) {
upb_Message* clone = upb_Message_New(mini_table, arena); upb_Message* clone = upb_Message_New(m, arena);
return _upb_Message_Copy(clone, message, mini_table, arena); upb_Message_ShallowCopy(clone, msg, m);
return clone;
} }
@ -6919,20 +6933,21 @@ static void upb_MtDecoder_AssignHasbits(upb_MtDecoder* d) {
} }
} }
ret->size = last_hasbit ? upb_MiniTable_DivideRoundUp(last_hasbit + 1, 8) : 0; ret->UPB_PRIVATE(size) =
last_hasbit ? upb_MiniTable_DivideRoundUp(last_hasbit + 1, 8) : 0;
} }
size_t upb_MtDecoder_Place(upb_MtDecoder* d, upb_FieldRep rep) { size_t upb_MtDecoder_Place(upb_MtDecoder* d, upb_FieldRep rep) {
size_t size = upb_MtDecoder_SizeOfRep(rep, d->platform); size_t size = upb_MtDecoder_SizeOfRep(rep, d->platform);
size_t align = upb_MtDecoder_AlignOfRep(rep, d->platform); size_t align = upb_MtDecoder_AlignOfRep(rep, d->platform);
size_t ret = UPB_ALIGN_UP(d->table->size, align); size_t ret = UPB_ALIGN_UP(d->table->UPB_PRIVATE(size), align);
static const size_t max = UINT16_MAX; static const size_t max = UINT16_MAX;
size_t new_size = ret + size; size_t new_size = ret + size;
if (new_size > max) { if (new_size > max) {
upb_MdDecoder_ErrorJmp( upb_MdDecoder_ErrorJmp(
&d->base, "Message size exceeded maximum size of %zu bytes", max); &d->base, "Message size exceeded maximum size of %zu bytes", max);
} }
d->table->size = new_size; d->table->UPB_PRIVATE(size) = new_size;
return ret; return ret;
} }
@ -6982,7 +6997,7 @@ static void upb_MtDecoder_AssignOffsets(upb_MtDecoder* d) {
// //
// On 32-bit we could potentially make this smaller, but there is no // On 32-bit we could potentially make this smaller, but there is no
// compelling reason to optimize this right now. // compelling reason to optimize this right now.
d->table->size = UPB_ALIGN_UP(d->table->size, 8); d->table->UPB_PRIVATE(size) = UPB_ALIGN_UP(d->table->UPB_PRIVATE(size), 8);
} }
static void upb_MtDecoder_ValidateEntryField(upb_MtDecoder* d, static void upb_MtDecoder_ValidateEntryField(upb_MtDecoder* d,
@ -7043,7 +7058,8 @@ static void upb_MtDecoder_ParseMap(upb_MtDecoder* d, const char* data,
const size_t hasbit_size = 8; const size_t hasbit_size = 8;
d->fields[0].offset = hasbit_size; d->fields[0].offset = hasbit_size;
d->fields[1].offset = hasbit_size + kv_size; d->fields[1].offset = hasbit_size + kv_size;
d->table->size = UPB_ALIGN_UP(hasbit_size + kv_size + kv_size, 8); d->table->UPB_PRIVATE(size) =
UPB_ALIGN_UP(hasbit_size + kv_size + kv_size, 8);
// Map entries have a special bit set to signal it's a map entry, used in // Map entries have a special bit set to signal it's a map entry, used in
// upb_MiniTable_SetSubMessage() below. // upb_MiniTable_SetSubMessage() below.
@ -7058,7 +7074,7 @@ static void upb_MtDecoder_ParseMessageSet(upb_MtDecoder* d, const char* data,
} }
upb_MiniTable* ret = d->table; upb_MiniTable* ret = d->table;
ret->size = 0; ret->UPB_PRIVATE(size) = 0;
ret->UPB_PRIVATE(field_count) = 0; ret->UPB_PRIVATE(field_count) = 0;
ret->UPB_PRIVATE(ext) = kUpb_ExtMode_IsMessageSet; ret->UPB_PRIVATE(ext) = kUpb_ExtMode_IsMessageSet;
ret->UPB_PRIVATE(dense_below) = 0; ret->UPB_PRIVATE(dense_below) = 0;
@ -7071,7 +7087,7 @@ static upb_MiniTable* upb_MtDecoder_DoBuildMiniTableWithBuf(
size_t* buf_size) { size_t* buf_size) {
upb_MdDecoder_CheckOutOfMemory(&decoder->base, decoder->table); upb_MdDecoder_CheckOutOfMemory(&decoder->base, decoder->table);
decoder->table->size = 0; decoder->table->UPB_PRIVATE(size) = 0;
decoder->table->UPB_PRIVATE(field_count) = 0; decoder->table->UPB_PRIVATE(field_count) = 0;
decoder->table->UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable; decoder->table->UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable;
decoder->table->UPB_PRIVATE(dense_below) = 0; decoder->table->UPB_PRIVATE(dense_below) = 0;
@ -7833,7 +7849,7 @@ bool upb_MiniTable_NextOneofField(const upb_MiniTable* m,
const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty) = { const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty) = {
.UPB_PRIVATE(subs) = NULL, .UPB_PRIVATE(subs) = NULL,
.UPB_PRIVATE(fields) = NULL, .UPB_PRIVATE(fields) = NULL,
.size = 0, .UPB_PRIVATE(size) = 0,
.UPB_PRIVATE(field_count) = 0, .UPB_PRIVATE(field_count) = 0,
.UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable, .UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable,
.UPB_PRIVATE(dense_below) = 0, .UPB_PRIVATE(dense_below) = 0,
@ -14330,9 +14346,9 @@ TAGBYTES(r)
/* message fields *************************************************************/ /* message fields *************************************************************/
UPB_INLINE UPB_INLINE
upb_Message* decode_newmsg_ceil(upb_Decoder* d, const upb_MiniTable* l, upb_Message* decode_newmsg_ceil(upb_Decoder* d, const upb_MiniTable* m,
int msg_ceil_bytes) { int msg_ceil_bytes) {
size_t size = l->size + sizeof(upb_Message_Internal); size_t size = m->UPB_PRIVATE(size) + sizeof(upb_Message_Internal);
char* msg_data; char* msg_data;
if (UPB_LIKELY(msg_ceil_bytes > 0 && if (UPB_LIKELY(msg_ceil_bytes > 0 &&
_upb_ArenaHas(&d->arena) >= msg_ceil_bytes)) { _upb_ArenaHas(&d->arena) >= msg_ceil_bytes)) {

@ -1413,7 +1413,7 @@ struct upb_MiniTable {
// Must be aligned to sizeof(void*). Doesn't include internal members like // Must be aligned to sizeof(void*). Doesn't include internal members like
// unknown fields, extension dict, pointer to msglayout, etc. // unknown fields, extension dict, pointer to msglayout, etc.
uint16_t size; uint16_t UPB_PRIVATE(size);
uint16_t UPB_ONLYBITS(field_count); uint16_t UPB_ONLYBITS(field_count);
@ -2358,7 +2358,7 @@ struct upb_Message_InternalData {
}; };
UPB_INLINE size_t upb_msg_sizeof(const upb_MiniTable* m) { UPB_INLINE size_t upb_msg_sizeof(const upb_MiniTable* m) {
return m->size + sizeof(upb_Message_Internal); return m->UPB_PRIVATE(size) + sizeof(upb_Message_Internal);
} }
// Inline version upb_Message_New(), for internal use. // Inline version upb_Message_New(), for internal use.
@ -12185,9 +12185,12 @@ extern "C" {
#endif #endif
// Deep clones a message using the provided target arena. // Deep clones a message using the provided target arena.
upb_Message* upb_Message_DeepClone(const upb_Message* message, upb_Message* upb_Message_DeepClone(const upb_Message* msg,
const upb_MiniTable* mini_table, const upb_MiniTable* m, upb_Arena* arena);
upb_Arena* arena);
// Shallow clones a message using the provided target arena.
upb_Message* upb_Message_ShallowClone(const upb_Message* msg,
const upb_MiniTable* m, upb_Arena* arena);
// Deep clones array contents. // Deep clones array contents.
upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type, upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type,
@ -12201,7 +12204,11 @@ upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type,
// Deep copies the message from src to dst. // Deep copies the message from src to dst.
bool upb_Message_DeepCopy(upb_Message* dst, const upb_Message* src, bool upb_Message_DeepCopy(upb_Message* dst, const upb_Message* src,
const upb_MiniTable* mini_table, upb_Arena* arena); const upb_MiniTable* m, upb_Arena* arena);
// Shallow copies the message from src to dst.
void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src,
const upb_MiniTable* m);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

Loading…
Cancel
Save