|
|
|
@ -4914,20 +4914,19 @@ void UPB_PRIVATE(_upb_Arena_SwapOut)(upb_Arena* des, const upb_Arena* src) { |
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table, |
|
|
|
|
bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* m, |
|
|
|
|
const upb_MiniTableField* f, |
|
|
|
|
upb_Message* map_entry_message, upb_Arena* arena) { |
|
|
|
|
UPB_ASSERT(!upb_Message_IsFrozen(map_entry_message)); |
|
|
|
|
|
|
|
|
|
// TODO: use a variant of upb_MiniTable_GetSubMessageTable() here.
|
|
|
|
|
const upb_MiniTable* map_entry_mini_table = upb_MiniTableSub_Message( |
|
|
|
|
mini_table->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); |
|
|
|
|
m->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); |
|
|
|
|
UPB_ASSERT(map_entry_mini_table); |
|
|
|
|
UPB_ASSERT(map_entry_mini_table->UPB_PRIVATE(field_count) == 2); |
|
|
|
|
const upb_MiniTableField* map_entry_key_field = |
|
|
|
|
&map_entry_mini_table->UPB_PRIVATE(fields)[0]; |
|
|
|
|
upb_MiniTable_MapKey(map_entry_mini_table); |
|
|
|
|
const upb_MiniTableField* map_entry_value_field = |
|
|
|
|
&map_entry_mini_table->UPB_PRIVATE(fields)[1]; |
|
|
|
|
upb_MiniTable_MapValue(map_entry_mini_table); |
|
|
|
|
// Map key/value cannot have explicit defaults,
|
|
|
|
|
// hence assuming a zero default is valid.
|
|
|
|
|
upb_MessageValue default_val; |
|
|
|
@ -4952,28 +4951,28 @@ upb_Array* upb_Array_New(upb_Arena* a, upb_CType type) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
upb_MessageValue upb_Array_Get(const upb_Array* arr, size_t i) { |
|
|
|
|
UPB_ASSERT(i < upb_Array_Size(arr)); |
|
|
|
|
upb_MessageValue ret; |
|
|
|
|
const char* data = upb_Array_DataPtr(arr); |
|
|
|
|
const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr); |
|
|
|
|
UPB_ASSERT(i < arr->UPB_PRIVATE(size)); |
|
|
|
|
memcpy(&ret, data + (i << lg2), 1 << lg2); |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
upb_MutableMessageValue upb_Array_GetMutable(upb_Array* arr, size_t i) { |
|
|
|
|
UPB_ASSERT(i < upb_Array_Size(arr)); |
|
|
|
|
upb_MutableMessageValue ret; |
|
|
|
|
char* data = upb_Array_MutableDataPtr(arr); |
|
|
|
|
const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr); |
|
|
|
|
UPB_ASSERT(i < arr->UPB_PRIVATE(size)); |
|
|
|
|
memcpy(&ret, data + (i << lg2), 1 << lg2); |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void upb_Array_Set(upb_Array* arr, size_t i, upb_MessageValue val) { |
|
|
|
|
UPB_ASSERT(!upb_Array_IsFrozen(arr)); |
|
|
|
|
UPB_ASSERT(i < upb_Array_Size(arr)); |
|
|
|
|
char* data = upb_Array_MutableDataPtr(arr); |
|
|
|
|
const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr); |
|
|
|
|
UPB_ASSERT(i < arr->UPB_PRIVATE(size)); |
|
|
|
|
memcpy(data + (i << lg2), &val, 1 << lg2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -5610,7 +5609,7 @@ upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type, |
|
|
|
|
size_t iter = kUpb_Map_Begin; |
|
|
|
|
while (upb_Map_Next(map, &key, &val, &iter)) { |
|
|
|
|
const upb_MiniTableField* value_field = |
|
|
|
|
&map_entry_table->UPB_PRIVATE(fields)[1]; |
|
|
|
|
upb_MiniTable_MapValue(map_entry_table); |
|
|
|
|
const upb_MiniTable* value_sub = |
|
|
|
|
upb_MiniTableField_CType(value_field) == kUpb_CType_Message |
|
|
|
|
? upb_MiniTable_GetSubMessageTable(map_entry_table, value_field) |
|
|
|
@ -5636,10 +5635,9 @@ static upb_Map* upb_Message_Map_DeepClone(const upb_Map* map, |
|
|
|
|
mini_table->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); |
|
|
|
|
UPB_ASSERT(map_entry_table); |
|
|
|
|
|
|
|
|
|
const upb_MiniTableField* key_field = |
|
|
|
|
&map_entry_table->UPB_PRIVATE(fields)[0]; |
|
|
|
|
const upb_MiniTableField* key_field = upb_MiniTable_MapKey(map_entry_table); |
|
|
|
|
const upb_MiniTableField* value_field = |
|
|
|
|
&map_entry_table->UPB_PRIVATE(fields)[1]; |
|
|
|
|
upb_MiniTable_MapValue(map_entry_table); |
|
|
|
|
|
|
|
|
|
upb_Map* cloned_map = upb_Map_DeepClone( |
|
|
|
|
map, upb_MiniTableField_CType(key_field), |
|
|
|
@ -5653,7 +5651,7 @@ static upb_Map* upb_Message_Map_DeepClone(const upb_Map* map, |
|
|
|
|
|
|
|
|
|
upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type, |
|
|
|
|
const upb_MiniTable* sub, upb_Arena* arena) { |
|
|
|
|
const size_t size = array->UPB_PRIVATE(size); |
|
|
|
|
const size_t size = upb_Array_Size(array); |
|
|
|
|
const int lg2 = UPB_PRIVATE(_upb_CType_SizeLg2)(value_type); |
|
|
|
|
upb_Array* cloned_array = UPB_PRIVATE(_upb_Array_New)(arena, size, lg2); |
|
|
|
|
if (!cloned_array) { |
|
|
|
@ -5694,8 +5692,7 @@ static bool upb_Clone_ExtensionValue( |
|
|
|
|
upb_Extension* dest, upb_Arena* arena) { |
|
|
|
|
dest->data = source->data; |
|
|
|
|
return upb_Clone_MessageValue( |
|
|
|
|
&dest->data, |
|
|
|
|
upb_MiniTableField_CType(&mini_table_ext->UPB_PRIVATE(field)), |
|
|
|
|
&dest->data, upb_MiniTableExtension_CType(mini_table_ext), |
|
|
|
|
upb_MiniTableExtension_GetSubMessage(mini_table_ext), arena); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -5705,8 +5702,9 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src, |
|
|
|
|
upb_StringView empty_string = upb_StringView_FromDataAndSize(NULL, 0); |
|
|
|
|
// Only copy message area skipping upb_Message_Internal.
|
|
|
|
|
memcpy(dst + 1, src + 1, mini_table->UPB_PRIVATE(size) - sizeof(upb_Message)); |
|
|
|
|
for (size_t i = 0; i < mini_table->UPB_PRIVATE(field_count); ++i) { |
|
|
|
|
const upb_MiniTableField* field = &mini_table->UPB_PRIVATE(fields)[i]; |
|
|
|
|
for (int i = 0; i < upb_MiniTable_FieldCount(mini_table); ++i) { |
|
|
|
|
const upb_MiniTableField* field = |
|
|
|
|
upb_MiniTable_GetFieldByIndex(mini_table, i); |
|
|
|
|
if (upb_MiniTableField_IsScalar(field)) { |
|
|
|
|
switch (upb_MiniTableField_CType(field)) { |
|
|
|
|
case kUpb_CType_Message: { |
|
|
|
@ -6884,13 +6882,13 @@ bool upb_MiniTable_SetSubEnum(upb_MiniTable* table, upb_MiniTableField* field, |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* mt, |
|
|
|
|
uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* m, |
|
|
|
|
const upb_MiniTableField** subs) { |
|
|
|
|
uint32_t msg_count = 0; |
|
|
|
|
uint32_t enum_count = 0; |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < mt->UPB_PRIVATE(field_count); i++) { |
|
|
|
|
const upb_MiniTableField* f = &mt->UPB_PRIVATE(fields)[i]; |
|
|
|
|
for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) { |
|
|
|
|
const upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, i); |
|
|
|
|
if (upb_MiniTableField_CType(f) == kUpb_CType_Message) { |
|
|
|
|
*subs = f; |
|
|
|
|
++subs; |
|
|
|
@ -6898,8 +6896,8 @@ uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* mt, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < mt->UPB_PRIVATE(field_count); i++) { |
|
|
|
|
const upb_MiniTableField* f = &mt->UPB_PRIVATE(fields)[i]; |
|
|
|
|
for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) { |
|
|
|
|
const upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, i); |
|
|
|
|
if (upb_MiniTableField_CType(f) == kUpb_CType_Enum) { |
|
|
|
|
*subs = f; |
|
|
|
|
++subs; |
|
|
|
@ -6913,31 +6911,33 @@ uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* mt, |
|
|
|
|
// The list of sub_tables and sub_enums must exactly match the number and order
|
|
|
|
|
// of sub-message fields and sub-enum fields given by upb_MiniTable_GetSubList()
|
|
|
|
|
// above.
|
|
|
|
|
bool upb_MiniTable_Link(upb_MiniTable* mt, const upb_MiniTable** sub_tables, |
|
|
|
|
bool upb_MiniTable_Link(upb_MiniTable* m, const upb_MiniTable** sub_tables, |
|
|
|
|
size_t sub_table_count, |
|
|
|
|
const upb_MiniTableEnum** sub_enums, |
|
|
|
|
size_t sub_enum_count) { |
|
|
|
|
uint32_t msg_count = 0; |
|
|
|
|
uint32_t enum_count = 0; |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < mt->UPB_PRIVATE(field_count); i++) { |
|
|
|
|
upb_MiniTableField* f = (upb_MiniTableField*)&mt->UPB_PRIVATE(fields)[i]; |
|
|
|
|
for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) { |
|
|
|
|
upb_MiniTableField* f = |
|
|
|
|
(upb_MiniTableField*)upb_MiniTable_GetFieldByIndex(m, i); |
|
|
|
|
if (upb_MiniTableField_CType(f) == kUpb_CType_Message) { |
|
|
|
|
const upb_MiniTable* sub = sub_tables[msg_count++]; |
|
|
|
|
if (msg_count > sub_table_count) return false; |
|
|
|
|
if (sub != NULL) { |
|
|
|
|
if (!upb_MiniTable_SetSubMessage(mt, f, sub)) return false; |
|
|
|
|
if (!upb_MiniTable_SetSubMessage(m, f, sub)) return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < mt->UPB_PRIVATE(field_count); i++) { |
|
|
|
|
upb_MiniTableField* f = (upb_MiniTableField*)&mt->UPB_PRIVATE(fields)[i]; |
|
|
|
|
for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) { |
|
|
|
|
upb_MiniTableField* f = |
|
|
|
|
(upb_MiniTableField*)upb_MiniTable_GetFieldByIndex(m, i); |
|
|
|
|
if (upb_MiniTableField_IsClosedEnum(f)) { |
|
|
|
|
const upb_MiniTableEnum* sub = sub_enums[enum_count++]; |
|
|
|
|
if (enum_count > sub_enum_count) return false; |
|
|
|
|
if (sub != NULL) { |
|
|
|
|
if (!upb_MiniTable_SetSubEnum(mt, f, sub)) return false; |
|
|
|
|
if (!upb_MiniTable_SetSubEnum(m, f, sub)) return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -8693,7 +8693,7 @@ static void encode_tag(upb_encstate* e, uint32_t field_number, |
|
|
|
|
|
|
|
|
|
static void encode_fixedarray(upb_encstate* e, const upb_Array* arr, |
|
|
|
|
size_t elem_size, uint32_t tag) { |
|
|
|
|
size_t bytes = arr->UPB_PRIVATE(size) * elem_size; |
|
|
|
|
size_t bytes = upb_Array_Size(arr) * elem_size; |
|
|
|
|
const char* data = upb_Array_DataPtr(arr); |
|
|
|
|
const char* ptr = data + bytes - elem_size; |
|
|
|
|
|
|
|
|
@ -8790,7 +8790,7 @@ static void encode_scalar(upb_encstate* e, const void* _field_mem, |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded); |
|
|
|
|
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_EndGroup); |
|
|
|
|
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_EndGroup); |
|
|
|
|
encode_TaggedMessagePtr(e, submsg, subm, &size); |
|
|
|
|
wire_type = kUpb_WireType_StartGroup; |
|
|
|
|
e->depth++; |
|
|
|
@ -8816,7 +8816,7 @@ static void encode_scalar(upb_encstate* e, const void* _field_mem, |
|
|
|
|
} |
|
|
|
|
#undef CASE |
|
|
|
|
|
|
|
|
|
encode_tag(e, f->UPB_PRIVATE(number), wire_type); |
|
|
|
|
encode_tag(e, upb_MiniTableField_Number(f), wire_type); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void encode_array(upb_encstate* e, const upb_Message* msg, |
|
|
|
@ -8826,14 +8826,14 @@ static void encode_array(upb_encstate* e, const upb_Message* msg, |
|
|
|
|
bool packed = upb_MiniTableField_IsPacked(f); |
|
|
|
|
size_t pre_len = e->limit - e->ptr; |
|
|
|
|
|
|
|
|
|
if (arr == NULL || arr->UPB_PRIVATE(size) == 0) { |
|
|
|
|
if (arr == NULL || upb_Array_Size(arr) == 0) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#define VARINT_CASE(ctype, encode) \ |
|
|
|
|
{ \
|
|
|
|
|
const ctype* start = upb_Array_DataPtr(arr); \
|
|
|
|
|
const ctype* ptr = start + arr->UPB_PRIVATE(size); \
|
|
|
|
|
const ctype* ptr = start + upb_Array_Size(arr); \
|
|
|
|
|
uint32_t tag = \
|
|
|
|
|
packed ? 0 : (f->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint; \
|
|
|
|
|
do { \
|
|
|
|
@ -8878,34 +8878,34 @@ static void encode_array(upb_encstate* e, const upb_Message* msg, |
|
|
|
|
case kUpb_FieldType_String: |
|
|
|
|
case kUpb_FieldType_Bytes: { |
|
|
|
|
const upb_StringView* start = upb_Array_DataPtr(arr); |
|
|
|
|
const upb_StringView* ptr = start + arr->UPB_PRIVATE(size); |
|
|
|
|
const upb_StringView* ptr = start + upb_Array_Size(arr); |
|
|
|
|
do { |
|
|
|
|
ptr--; |
|
|
|
|
encode_bytes(e, ptr->data, ptr->size); |
|
|
|
|
encode_varint(e, ptr->size); |
|
|
|
|
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_Delimited); |
|
|
|
|
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_Delimited); |
|
|
|
|
} while (ptr != start); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
case kUpb_FieldType_Group: { |
|
|
|
|
const upb_TaggedMessagePtr* start = upb_Array_DataPtr(arr); |
|
|
|
|
const upb_TaggedMessagePtr* ptr = start + arr->UPB_PRIVATE(size); |
|
|
|
|
const upb_TaggedMessagePtr* ptr = start + upb_Array_Size(arr); |
|
|
|
|
const upb_MiniTable* subm = |
|
|
|
|
upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]); |
|
|
|
|
if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded); |
|
|
|
|
do { |
|
|
|
|
size_t size; |
|
|
|
|
ptr--; |
|
|
|
|
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_EndGroup); |
|
|
|
|
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_EndGroup); |
|
|
|
|
encode_TaggedMessagePtr(e, *ptr, subm, &size); |
|
|
|
|
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_StartGroup); |
|
|
|
|
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_StartGroup); |
|
|
|
|
} while (ptr != start); |
|
|
|
|
e->depth++; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
case kUpb_FieldType_Message: { |
|
|
|
|
const upb_TaggedMessagePtr* start = upb_Array_DataPtr(arr); |
|
|
|
|
const upb_TaggedMessagePtr* ptr = start + arr->UPB_PRIVATE(size); |
|
|
|
|
const upb_TaggedMessagePtr* ptr = start + upb_Array_Size(arr); |
|
|
|
|
const upb_MiniTable* subm = |
|
|
|
|
upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]); |
|
|
|
|
if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded); |
|
|
|
@ -8914,7 +8914,7 @@ static void encode_array(upb_encstate* e, const upb_Message* msg, |
|
|
|
|
ptr--; |
|
|
|
|
encode_TaggedMessagePtr(e, *ptr, subm, &size); |
|
|
|
|
encode_varint(e, size); |
|
|
|
|
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_Delimited); |
|
|
|
|
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_Delimited); |
|
|
|
|
} while (ptr != start); |
|
|
|
|
e->depth++; |
|
|
|
|
return; |
|
|
|
@ -8924,15 +8924,15 @@ static void encode_array(upb_encstate* e, const upb_Message* msg, |
|
|
|
|
|
|
|
|
|
if (packed) { |
|
|
|
|
encode_varint(e, e->limit - e->ptr - pre_len); |
|
|
|
|
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_Delimited); |
|
|
|
|
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_Delimited); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void encode_mapentry(upb_encstate* e, uint32_t number, |
|
|
|
|
const upb_MiniTable* layout, |
|
|
|
|
const upb_MapEntry* ent) { |
|
|
|
|
const upb_MiniTableField* key_field = &layout->UPB_PRIVATE(fields)[0]; |
|
|
|
|
const upb_MiniTableField* val_field = &layout->UPB_PRIVATE(fields)[1]; |
|
|
|
|
const upb_MiniTableField* key_field = upb_MiniTable_MapKey(layout); |
|
|
|
|
const upb_MiniTableField* val_field = upb_MiniTable_MapValue(layout); |
|
|
|
|
size_t pre_len = e->limit - e->ptr; |
|
|
|
|
size_t size; |
|
|
|
|
encode_scalar(e, &ent->v, layout->UPB_PRIVATE(subs), val_field); |
|
|
|
@ -8948,7 +8948,7 @@ static void encode_map(upb_encstate* e, const upb_Message* msg, |
|
|
|
|
const upb_Map* map = *UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), const upb_Map*); |
|
|
|
|
const upb_MiniTable* layout = |
|
|
|
|
upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]); |
|
|
|
|
UPB_ASSERT(layout->UPB_PRIVATE(field_count) == 2); |
|
|
|
|
UPB_ASSERT(upb_MiniTable_FieldCount(layout) == 2); |
|
|
|
|
|
|
|
|
|
if (!map || !upb_Map_Size(map)) return; |
|
|
|
|
|
|
|
|
@ -8959,7 +8959,7 @@ static void encode_map(upb_encstate* e, const upb_Message* msg, |
|
|
|
|
map, &sorted); |
|
|
|
|
upb_MapEntry ent; |
|
|
|
|
while (_upb_sortedmap_next(&e->sorter, map, &sorted, &ent)) { |
|
|
|
|
encode_mapentry(e, f->UPB_PRIVATE(number), layout, &ent); |
|
|
|
|
encode_mapentry(e, upb_MiniTableField_Number(f), layout, &ent); |
|
|
|
|
} |
|
|
|
|
_upb_mapsorter_popmap(&e->sorter, &sorted); |
|
|
|
|
} else { |
|
|
|
@ -8970,7 +8970,7 @@ static void encode_map(upb_encstate* e, const upb_Message* msg, |
|
|
|
|
upb_MapEntry ent; |
|
|
|
|
_upb_map_fromkey(key, &ent.k, map->key_size); |
|
|
|
|
_upb_map_fromvalue(val, &ent.v, map->val_size); |
|
|
|
|
encode_mapentry(e, f->UPB_PRIVATE(number), layout, &ent); |
|
|
|
|
encode_mapentry(e, upb_MiniTableField_Number(f), layout, &ent); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -9010,7 +9010,7 @@ static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg, |
|
|
|
|
} else { |
|
|
|
|
// Field is in a oneof.
|
|
|
|
|
return UPB_PRIVATE(_upb_Message_GetOneofCase)(msg, f) == |
|
|
|
|
f->UPB_PRIVATE(number); |
|
|
|
|
upb_MiniTableField_Number(f); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -9100,7 +9100,7 @@ static void encode_message(upb_encstate* e, const upb_Message* msg, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (m->UPB_PRIVATE(field_count)) { |
|
|
|
|
if (upb_MiniTable_FieldCount(m)) { |
|
|
|
|
const upb_MiniTableField* f = |
|
|
|
|
&m->UPB_PRIVATE(fields)[m->UPB_PRIVATE(field_count)]; |
|
|
|
|
const upb_MiniTableField* first = &m->UPB_PRIVATE(fields)[0]; |
|
|
|
@ -15157,7 +15157,7 @@ void _upb_MessageDef_CreateMiniTable(upb_DefBuilder* ctx, upb_MessageDef* m) { |
|
|
|
|
m->layout = _upb_MessageDef_MakeMiniTable(ctx, m); |
|
|
|
|
} else { |
|
|
|
|
m->layout = upb_MiniTableFile_Message(ctx->layout, ctx->msg_count++); |
|
|
|
|
UPB_ASSERT(m->field_count == m->layout->UPB_PRIVATE(field_count)); |
|
|
|
|
UPB_ASSERT(m->field_count == upb_MiniTable_FieldCount(m->layout)); |
|
|
|
|
|
|
|
|
|
// We don't need the result of this call, but it will assign layout_index
|
|
|
|
|
// for all the fields in O(n lg n) time.
|
|
|
|
@ -15215,7 +15215,7 @@ void _upb_MessageDef_LinkMiniTable(upb_DefBuilder* ctx, |
|
|
|
|
for (int i = 0; i < m->field_count; i++) { |
|
|
|
|
const upb_FieldDef* f = upb_MessageDef_Field(m, i); |
|
|
|
|
const int layout_index = _upb_FieldDef_LayoutIndex(f); |
|
|
|
|
UPB_ASSERT(layout_index < m->layout->UPB_PRIVATE(field_count)); |
|
|
|
|
UPB_ASSERT(layout_index < upb_MiniTable_FieldCount(m->layout)); |
|
|
|
|
const upb_MiniTableField* mt_f = |
|
|
|
|
&m->layout->UPB_PRIVATE(fields)[layout_index]; |
|
|
|
|
UPB_ASSERT(upb_FieldDef_Type(f) == upb_MiniTableField_Type(mt_f)); |
|
|
|
|