Auto-generate files after cl/587127664

pull/14920/head
Protobuf Team Bot 12 months ago
parent 848a2bfd41
commit 7bdd38e1f1
  1. 95
      php/ext/google/protobuf/php-upb.c
  2. 22
      php/ext/google/protobuf/php-upb.h
  3. 95
      ruby/ext/google/protobuf_c/ruby-upb.c
  4. 22
      ruby/ext/google/protobuf_c/ruby-upb.h

@ -7027,7 +7027,7 @@ static void upb_MtDecoder_ModifyField(upb_MtDecoder* d,
if (!upb_MtDecoder_FieldIsPackable(field)) {
upb_MdDecoder_ErrorJmp(&d->base,
"Cannot flip packed on unpackable field %" PRIu32,
field->number);
upb_MiniTableField_Number(field));
}
field->UPB_PRIVATE(mode) ^= kUpb_LabelFlags_IsPacked;
}
@ -7035,11 +7035,12 @@ static void upb_MtDecoder_ModifyField(upb_MtDecoder* d,
if (field_modifiers & kUpb_EncodedFieldModifier_FlipValidateUtf8) {
if (field->UPB_PRIVATE(descriptortype) != kUpb_FieldType_Bytes ||
!(field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsAlternate)) {
upb_MdDecoder_ErrorJmp(
&d->base,
"Cannot flip ValidateUtf8 on field %" PRIu32 ", type=%d, mode=%d",
field->number, (int)field->UPB_PRIVATE(descriptortype),
(int)field->UPB_PRIVATE(mode));
upb_MdDecoder_ErrorJmp(&d->base,
"Cannot flip ValidateUtf8 on field %" PRIu32
", type=%d, mode=%d",
upb_MiniTableField_Number(field),
(int)field->UPB_PRIVATE(descriptortype),
(int)field->UPB_PRIVATE(mode));
}
field->UPB_PRIVATE(descriptortype) = kUpb_FieldType_String;
field->UPB_PRIVATE(mode) &= ~kUpb_LabelFlags_IsAlternate;
@ -7052,12 +7053,12 @@ static void upb_MtDecoder_ModifyField(upb_MtDecoder* d,
if ((singular || required) && field->offset != kHasbitPresence) {
upb_MdDecoder_ErrorJmp(&d->base,
"Invalid modifier(s) for repeated field %" PRIu32,
field->number);
upb_MiniTableField_Number(field));
}
if (singular && required) {
upb_MdDecoder_ErrorJmp(
&d->base, "Field %" PRIu32 " cannot be both singular and required",
field->number);
upb_MiniTableField_Number(field));
}
if (singular) field->offset = kNoPresence;
@ -7258,7 +7259,7 @@ static const char* upb_MtDecoder_Parse(upb_MtDecoder* d, const char* ptr,
upb_MiniTableField* field = fields;
*field_count += 1;
fields = (char*)fields + field_size;
field->number = ++last_field_number;
field->UPB_PRIVATE(number) = ++last_field_number;
last_field = field;
upb_MiniTable_SetField(d, ch, field, msg_modifiers, sub_counts);
} else if (kUpb_EncodedValue_MinModifier <= ch &&
@ -7460,10 +7461,11 @@ static void upb_MtDecoder_ValidateEntryField(upb_MtDecoder* d,
const upb_MiniTableField* f,
uint32_t expected_num) {
const char* name = expected_num == 1 ? "key" : "val";
if (f->number != expected_num) {
const uint32_t f_number = upb_MiniTableField_Number(f);
if (f_number != expected_num) {
upb_MdDecoder_ErrorJmp(&d->base,
"map %s did not have expected number (%d vs %d)",
name, expected_num, (int)f->number);
name, expected_num, f_number);
}
if (!upb_MiniTableField_IsScalar(f)) {
@ -8241,7 +8243,7 @@ const upb_MiniTableField* upb_MiniTable_FindFieldByNumber(
// Ideal case: index into dense fields
if (i < m->UPB_PRIVATE(dense_below)) {
UPB_ASSERT(m->UPB_PRIVATE(fields)[i].number == number);
UPB_ASSERT(m->UPB_PRIVATE(fields)[i].UPB_PRIVATE(number) == number);
return &m->UPB_PRIVATE(fields)[i];
}
@ -8250,7 +8252,7 @@ const upb_MiniTableField* upb_MiniTable_FindFieldByNumber(
int hi = m->UPB_PRIVATE(field_count) - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
uint32_t num = m->UPB_PRIVATE(fields)[mid].number;
uint32_t num = m->UPB_PRIVATE(fields)[mid].UPB_PRIVATE(number);
if (num < number) {
lo = mid + 1;
continue;
@ -12917,7 +12919,8 @@ static const char* _upb_Decoder_DecodeKnownGroup(
const upb_MiniTableSub* subs, const upb_MiniTableField* field) {
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
UPB_ASSERT(subl);
return _upb_Decoder_DecodeGroup(d, ptr, submsg, subl, field->number);
return _upb_Decoder_DecodeGroup(d, ptr, submsg, subl,
field->UPB_PRIVATE(number));
}
static char* upb_Decoder_EncodeVarint32(uint32_t val, char* ptr) {
@ -12954,7 +12957,8 @@ static bool _upb_Decoder_CheckEnum(upb_Decoder* d, const char* ptr,
// Unrecognized enum goes into unknown fields.
// For packed fields the tag could be arbitrarily far in the past,
// so we just re-encode the tag and value here.
const uint32_t tag = ((uint32_t)field->number << 3) | kUpb_WireType_Varint;
const uint32_t tag =
((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint;
upb_Message* unknown_msg =
field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension ? d->unknown_msg
: msg;
@ -13214,7 +13218,8 @@ static const char* _upb_Decoder_DecodeToMap(upb_Decoder* d, const char* ptr,
if (size != 0) {
char* buf;
size_t size;
uint32_t tag = ((uint32_t)field->number << 3) | kUpb_WireType_Delimited;
uint32_t tag =
((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Delimited;
upb_EncodeStatus status =
upb_Encode(&ent.data, entry, 0, &d->arena, &buf, &size);
if (status != kUpb_EncodeStatus_Ok) {
@ -13254,10 +13259,11 @@ static const char* _upb_Decoder_DecodeToSubMessage(
} else if (field->presence < 0) {
/* Oneof case */
uint32_t* oneof_case = _upb_Message_OneofCasePtr(msg, field);
if (op == kUpb_DecodeOp_SubMessage && *oneof_case != field->number) {
if (op == kUpb_DecodeOp_SubMessage &&
*oneof_case != field->UPB_PRIVATE(number)) {
memset(mem, 0, sizeof(void*));
}
*oneof_case = field->number;
*oneof_case = field->UPB_PRIVATE(number);
}
/* Store into message. */
@ -13490,13 +13496,13 @@ static const upb_MiniTableField* _upb_Decoder_FindField(upb_Decoder* d,
* since fields are usually in order. */
size_t last = *last_field_index;
for (idx = last; idx < t->UPB_PRIVATE(field_count); idx++) {
if (t->UPB_PRIVATE(fields)[idx].number == field_number) {
if (t->UPB_PRIVATE(fields)[idx].UPB_PRIVATE(number) == field_number) {
goto found;
}
}
for (idx = t->UPB_PRIVATE(dense_below); idx < last; idx++) {
if (t->UPB_PRIVATE(fields)[idx].number == field_number) {
if (t->UPB_PRIVATE(fields)[idx].UPB_PRIVATE(number) == field_number) {
goto found;
}
}
@ -13523,7 +13529,7 @@ static const upb_MiniTableField* _upb_Decoder_FindField(upb_Decoder* d,
return &none; /* Unknown field. */
found:
UPB_ASSERT(t->UPB_PRIVATE(fields)[idx].number == field_number);
UPB_ASSERT(t->UPB_PRIVATE(fields)[idx].UPB_PRIVATE(number) == field_number);
*last_field_index = idx;
return &t->UPB_PRIVATE(fields)[idx];
}
@ -13681,7 +13687,7 @@ static const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
*op = _upb_Decoder_GetDelimitedOp(d, mt, field);
return ptr;
case kUpb_WireType_StartGroup:
val->uint32_val = field->number;
val->uint32_val = field->UPB_PRIVATE(number);
if (field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Group) {
*op = kUpb_DecodeOp_SubMessage;
_upb_Decoder_CheckUnlinked(d, mt, field, op);
@ -15175,7 +15181,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->number, kUpb_WireType_EndGroup);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_EndGroup);
encode_TaggedMessagePtr(e, submsg, subm, &size);
wire_type = kUpb_WireType_StartGroup;
e->depth++;
@ -15201,7 +15207,7 @@ static void encode_scalar(upb_encstate* e, const void* _field_mem,
}
#undef CASE
encode_tag(e, f->number, wire_type);
encode_tag(e, f->UPB_PRIVATE(number), wire_type);
}
static void encode_array(upb_encstate* e, const upb_Message* msg,
@ -15215,20 +15221,21 @@ static void encode_array(upb_encstate* e, const upb_Message* msg,
return;
}
#define VARINT_CASE(ctype, encode) \
{ \
const ctype* start = _upb_array_constptr(arr); \
const ctype* ptr = start + arr->size; \
uint32_t tag = packed ? 0 : (f->number << 3) | kUpb_WireType_Varint; \
do { \
ptr--; \
encode_varint(e, encode); \
if (tag) encode_varint(e, tag); \
} while (ptr != start); \
} \
#define VARINT_CASE(ctype, encode) \
{ \
const ctype* start = _upb_array_constptr(arr); \
const ctype* ptr = start + arr->size; \
uint32_t tag = \
packed ? 0 : (f->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint; \
do { \
ptr--; \
encode_varint(e, encode); \
if (tag) encode_varint(e, tag); \
} while (ptr != start); \
} \
break;
#define TAG(wire_type) (packed ? 0 : (f->number << 3 | wire_type))
#define TAG(wire_type) (packed ? 0 : (f->UPB_PRIVATE(number) << 3 | wire_type))
switch (f->UPB_PRIVATE(descriptortype)) {
case kUpb_FieldType_Double:
@ -15267,7 +15274,7 @@ static void encode_array(upb_encstate* e, const upb_Message* msg,
ptr--;
encode_bytes(e, ptr->data, ptr->size);
encode_varint(e, ptr->size);
encode_tag(e, f->number, kUpb_WireType_Delimited);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_Delimited);
} while (ptr != start);
return;
}
@ -15280,9 +15287,9 @@ static void encode_array(upb_encstate* e, const upb_Message* msg,
do {
size_t size;
ptr--;
encode_tag(e, f->number, kUpb_WireType_EndGroup);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_EndGroup);
encode_TaggedMessagePtr(e, *ptr, subm, &size);
encode_tag(e, f->number, kUpb_WireType_StartGroup);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_StartGroup);
} while (ptr != start);
e->depth++;
return;
@ -15298,7 +15305,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->number, kUpb_WireType_Delimited);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_Delimited);
} while (ptr != start);
e->depth++;
return;
@ -15308,7 +15315,7 @@ 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->number, kUpb_WireType_Delimited);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_Delimited);
}
}
@ -15343,7 +15350,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->number, layout, &ent);
encode_mapentry(e, f->UPB_PRIVATE(number), layout, &ent);
}
_upb_mapsorter_popmap(&e->sorter, &sorted);
} else {
@ -15354,7 +15361,7 @@ static void encode_map(upb_encstate* e, const upb_Message* msg,
upb_MapEntry ent;
_upb_map_fromkey(key, &ent.data.k, map->key_size);
_upb_map_fromvalue(val, &ent.data.v, map->val_size);
encode_mapentry(e, f->number, layout, &ent);
encode_mapentry(e, f->UPB_PRIVATE(number), layout, &ent);
}
}
}
@ -15393,7 +15400,7 @@ static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg,
return _upb_Message_GetHasbitByField(msg, f);
} else {
// Field is in a oneof.
return _upb_Message_GetOneofCase(msg, f) == f->number;
return _upb_Message_GetOneofCase(msg, f) == f->UPB_PRIVATE(number);
}
}

@ -1009,6 +1009,8 @@ UPB_INLINE bool upb_MiniTableEnum_CheckValue(const upb_MiniTableEnum* e,
#ifndef UPB_MINI_TABLE_FIELD_H_
#define UPB_MINI_TABLE_FIELD_H_
#include <stdint.h>
#ifndef UPB_MINI_TABLE_INTERNAL_FIELD_H_
#define UPB_MINI_TABLE_INTERNAL_FIELD_H_
@ -1088,7 +1090,7 @@ UPB_INLINE int upb_FieldType_SizeLg2(upb_FieldType field_type) {
// LINT.IfChange(struct_definition)
struct upb_MiniTableField {
uint32_t number;
uint32_t UPB_ONLYBITS(number);
uint16_t offset;
int16_t presence; // If >0, hasbit_index. If <0, ~oneof_index
@ -1224,6 +1226,11 @@ UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_HasPresence)(
}
}
UPB_INLINE uint32_t
UPB_PRIVATE(_upb_MiniTableField_Number)(const struct upb_MiniTableField* f) {
return f->UPB_ONLYBITS(number);
}
UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(
const struct upb_MiniTableField* f) {
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
@ -1306,6 +1313,10 @@ UPB_API_INLINE bool upb_MiniTableField_IsSubMessage(
return UPB_PRIVATE(_upb_MiniTableField_IsSubMessage)(f);
}
UPB_API_INLINE uint32_t upb_MiniTableField_Number(const upb_MiniTableField* f) {
return UPB_PRIVATE(_upb_MiniTableField_Number)(f);
}
UPB_API_INLINE upb_FieldType
upb_MiniTableField_Type(const upb_MiniTableField* f) {
return UPB_PRIVATE(_upb_MiniTableField_Type)(f);
@ -1629,7 +1640,7 @@ UPB_INLINE const struct upb_MiniTableField* UPB_PRIVATE(
UPB_INLINE uint32_t UPB_PRIVATE(_upb_MiniTableExtension_Number)(
const struct upb_MiniTableExtension* e) {
return e->UPB_PRIVATE(field).number;
return e->UPB_PRIVATE(field).UPB_ONLYBITS(number);
}
UPB_INLINE const struct upb_MiniTable* UPB_PRIVATE(
@ -2554,7 +2565,7 @@ UPB_INLINE uint32_t _upb_Message_GetOneofCase(const upb_Message* msg,
UPB_INLINE void _upb_Message_SetOneofCase(upb_Message* msg,
const upb_MiniTableField* f) {
*_upb_Message_OneofCasePtr(msg, f) = f->number;
*_upb_Message_OneofCasePtr(msg, f) = upb_MiniTableField_Number(f);
}
// TODO: implement _upb_Message_ClearOneofCase()
@ -2662,7 +2673,8 @@ UPB_INLINE bool _upb_Message_HasNonExtensionField(
UPB_ASSERT(upb_MiniTableField_HasPresence(field));
UPB_ASSUME(!upb_MiniTableField_IsExtension(field));
if (upb_MiniTableField_IsInOneof(field)) {
return _upb_Message_GetOneofCase(msg, field) == field->number;
return _upb_Message_GetOneofCase(msg, field) ==
upb_MiniTableField_Number(field);
} else {
return _upb_Message_GetHasbitByField(msg, field);
}
@ -2760,7 +2772,7 @@ UPB_INLINE void _upb_Message_ClearNonExtensionField(
_upb_Message_ClearHasbitByField(msg, field);
} else if (upb_MiniTableField_IsInOneof(field)) {
uint32_t* ptr = _upb_Message_OneofCasePtr(msg, field);
if (*ptr != field->number) return;
if (*ptr != upb_MiniTableField_Number(field)) return;
*ptr = 0;
}
const char zeros[16] = {0};

@ -6541,7 +6541,7 @@ static void upb_MtDecoder_ModifyField(upb_MtDecoder* d,
if (!upb_MtDecoder_FieldIsPackable(field)) {
upb_MdDecoder_ErrorJmp(&d->base,
"Cannot flip packed on unpackable field %" PRIu32,
field->number);
upb_MiniTableField_Number(field));
}
field->UPB_PRIVATE(mode) ^= kUpb_LabelFlags_IsPacked;
}
@ -6549,11 +6549,12 @@ static void upb_MtDecoder_ModifyField(upb_MtDecoder* d,
if (field_modifiers & kUpb_EncodedFieldModifier_FlipValidateUtf8) {
if (field->UPB_PRIVATE(descriptortype) != kUpb_FieldType_Bytes ||
!(field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsAlternate)) {
upb_MdDecoder_ErrorJmp(
&d->base,
"Cannot flip ValidateUtf8 on field %" PRIu32 ", type=%d, mode=%d",
field->number, (int)field->UPB_PRIVATE(descriptortype),
(int)field->UPB_PRIVATE(mode));
upb_MdDecoder_ErrorJmp(&d->base,
"Cannot flip ValidateUtf8 on field %" PRIu32
", type=%d, mode=%d",
upb_MiniTableField_Number(field),
(int)field->UPB_PRIVATE(descriptortype),
(int)field->UPB_PRIVATE(mode));
}
field->UPB_PRIVATE(descriptortype) = kUpb_FieldType_String;
field->UPB_PRIVATE(mode) &= ~kUpb_LabelFlags_IsAlternate;
@ -6566,12 +6567,12 @@ static void upb_MtDecoder_ModifyField(upb_MtDecoder* d,
if ((singular || required) && field->offset != kHasbitPresence) {
upb_MdDecoder_ErrorJmp(&d->base,
"Invalid modifier(s) for repeated field %" PRIu32,
field->number);
upb_MiniTableField_Number(field));
}
if (singular && required) {
upb_MdDecoder_ErrorJmp(
&d->base, "Field %" PRIu32 " cannot be both singular and required",
field->number);
upb_MiniTableField_Number(field));
}
if (singular) field->offset = kNoPresence;
@ -6772,7 +6773,7 @@ static const char* upb_MtDecoder_Parse(upb_MtDecoder* d, const char* ptr,
upb_MiniTableField* field = fields;
*field_count += 1;
fields = (char*)fields + field_size;
field->number = ++last_field_number;
field->UPB_PRIVATE(number) = ++last_field_number;
last_field = field;
upb_MiniTable_SetField(d, ch, field, msg_modifiers, sub_counts);
} else if (kUpb_EncodedValue_MinModifier <= ch &&
@ -6974,10 +6975,11 @@ static void upb_MtDecoder_ValidateEntryField(upb_MtDecoder* d,
const upb_MiniTableField* f,
uint32_t expected_num) {
const char* name = expected_num == 1 ? "key" : "val";
if (f->number != expected_num) {
const uint32_t f_number = upb_MiniTableField_Number(f);
if (f_number != expected_num) {
upb_MdDecoder_ErrorJmp(&d->base,
"map %s did not have expected number (%d vs %d)",
name, expected_num, (int)f->number);
name, expected_num, f_number);
}
if (!upb_MiniTableField_IsScalar(f)) {
@ -7755,7 +7757,7 @@ const upb_MiniTableField* upb_MiniTable_FindFieldByNumber(
// Ideal case: index into dense fields
if (i < m->UPB_PRIVATE(dense_below)) {
UPB_ASSERT(m->UPB_PRIVATE(fields)[i].number == number);
UPB_ASSERT(m->UPB_PRIVATE(fields)[i].UPB_PRIVATE(number) == number);
return &m->UPB_PRIVATE(fields)[i];
}
@ -7764,7 +7766,7 @@ const upb_MiniTableField* upb_MiniTable_FindFieldByNumber(
int hi = m->UPB_PRIVATE(field_count) - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
uint32_t num = m->UPB_PRIVATE(fields)[mid].number;
uint32_t num = m->UPB_PRIVATE(fields)[mid].UPB_PRIVATE(number);
if (num < number) {
lo = mid + 1;
continue;
@ -12431,7 +12433,8 @@ static const char* _upb_Decoder_DecodeKnownGroup(
const upb_MiniTableSub* subs, const upb_MiniTableField* field) {
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
UPB_ASSERT(subl);
return _upb_Decoder_DecodeGroup(d, ptr, submsg, subl, field->number);
return _upb_Decoder_DecodeGroup(d, ptr, submsg, subl,
field->UPB_PRIVATE(number));
}
static char* upb_Decoder_EncodeVarint32(uint32_t val, char* ptr) {
@ -12468,7 +12471,8 @@ static bool _upb_Decoder_CheckEnum(upb_Decoder* d, const char* ptr,
// Unrecognized enum goes into unknown fields.
// For packed fields the tag could be arbitrarily far in the past,
// so we just re-encode the tag and value here.
const uint32_t tag = ((uint32_t)field->number << 3) | kUpb_WireType_Varint;
const uint32_t tag =
((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint;
upb_Message* unknown_msg =
field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension ? d->unknown_msg
: msg;
@ -12728,7 +12732,8 @@ static const char* _upb_Decoder_DecodeToMap(upb_Decoder* d, const char* ptr,
if (size != 0) {
char* buf;
size_t size;
uint32_t tag = ((uint32_t)field->number << 3) | kUpb_WireType_Delimited;
uint32_t tag =
((uint32_t)field->UPB_PRIVATE(number) << 3) | kUpb_WireType_Delimited;
upb_EncodeStatus status =
upb_Encode(&ent.data, entry, 0, &d->arena, &buf, &size);
if (status != kUpb_EncodeStatus_Ok) {
@ -12768,10 +12773,11 @@ static const char* _upb_Decoder_DecodeToSubMessage(
} else if (field->presence < 0) {
/* Oneof case */
uint32_t* oneof_case = _upb_Message_OneofCasePtr(msg, field);
if (op == kUpb_DecodeOp_SubMessage && *oneof_case != field->number) {
if (op == kUpb_DecodeOp_SubMessage &&
*oneof_case != field->UPB_PRIVATE(number)) {
memset(mem, 0, sizeof(void*));
}
*oneof_case = field->number;
*oneof_case = field->UPB_PRIVATE(number);
}
/* Store into message. */
@ -13004,13 +13010,13 @@ static const upb_MiniTableField* _upb_Decoder_FindField(upb_Decoder* d,
* since fields are usually in order. */
size_t last = *last_field_index;
for (idx = last; idx < t->UPB_PRIVATE(field_count); idx++) {
if (t->UPB_PRIVATE(fields)[idx].number == field_number) {
if (t->UPB_PRIVATE(fields)[idx].UPB_PRIVATE(number) == field_number) {
goto found;
}
}
for (idx = t->UPB_PRIVATE(dense_below); idx < last; idx++) {
if (t->UPB_PRIVATE(fields)[idx].number == field_number) {
if (t->UPB_PRIVATE(fields)[idx].UPB_PRIVATE(number) == field_number) {
goto found;
}
}
@ -13037,7 +13043,7 @@ static const upb_MiniTableField* _upb_Decoder_FindField(upb_Decoder* d,
return &none; /* Unknown field. */
found:
UPB_ASSERT(t->UPB_PRIVATE(fields)[idx].number == field_number);
UPB_ASSERT(t->UPB_PRIVATE(fields)[idx].UPB_PRIVATE(number) == field_number);
*last_field_index = idx;
return &t->UPB_PRIVATE(fields)[idx];
}
@ -13195,7 +13201,7 @@ static const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
*op = _upb_Decoder_GetDelimitedOp(d, mt, field);
return ptr;
case kUpb_WireType_StartGroup:
val->uint32_val = field->number;
val->uint32_val = field->UPB_PRIVATE(number);
if (field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Group) {
*op = kUpb_DecodeOp_SubMessage;
_upb_Decoder_CheckUnlinked(d, mt, field, op);
@ -14689,7 +14695,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->number, kUpb_WireType_EndGroup);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_EndGroup);
encode_TaggedMessagePtr(e, submsg, subm, &size);
wire_type = kUpb_WireType_StartGroup;
e->depth++;
@ -14715,7 +14721,7 @@ static void encode_scalar(upb_encstate* e, const void* _field_mem,
}
#undef CASE
encode_tag(e, f->number, wire_type);
encode_tag(e, f->UPB_PRIVATE(number), wire_type);
}
static void encode_array(upb_encstate* e, const upb_Message* msg,
@ -14729,20 +14735,21 @@ static void encode_array(upb_encstate* e, const upb_Message* msg,
return;
}
#define VARINT_CASE(ctype, encode) \
{ \
const ctype* start = _upb_array_constptr(arr); \
const ctype* ptr = start + arr->size; \
uint32_t tag = packed ? 0 : (f->number << 3) | kUpb_WireType_Varint; \
do { \
ptr--; \
encode_varint(e, encode); \
if (tag) encode_varint(e, tag); \
} while (ptr != start); \
} \
#define VARINT_CASE(ctype, encode) \
{ \
const ctype* start = _upb_array_constptr(arr); \
const ctype* ptr = start + arr->size; \
uint32_t tag = \
packed ? 0 : (f->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint; \
do { \
ptr--; \
encode_varint(e, encode); \
if (tag) encode_varint(e, tag); \
} while (ptr != start); \
} \
break;
#define TAG(wire_type) (packed ? 0 : (f->number << 3 | wire_type))
#define TAG(wire_type) (packed ? 0 : (f->UPB_PRIVATE(number) << 3 | wire_type))
switch (f->UPB_PRIVATE(descriptortype)) {
case kUpb_FieldType_Double:
@ -14781,7 +14788,7 @@ static void encode_array(upb_encstate* e, const upb_Message* msg,
ptr--;
encode_bytes(e, ptr->data, ptr->size);
encode_varint(e, ptr->size);
encode_tag(e, f->number, kUpb_WireType_Delimited);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_Delimited);
} while (ptr != start);
return;
}
@ -14794,9 +14801,9 @@ static void encode_array(upb_encstate* e, const upb_Message* msg,
do {
size_t size;
ptr--;
encode_tag(e, f->number, kUpb_WireType_EndGroup);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_EndGroup);
encode_TaggedMessagePtr(e, *ptr, subm, &size);
encode_tag(e, f->number, kUpb_WireType_StartGroup);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_StartGroup);
} while (ptr != start);
e->depth++;
return;
@ -14812,7 +14819,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->number, kUpb_WireType_Delimited);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_Delimited);
} while (ptr != start);
e->depth++;
return;
@ -14822,7 +14829,7 @@ 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->number, kUpb_WireType_Delimited);
encode_tag(e, f->UPB_PRIVATE(number), kUpb_WireType_Delimited);
}
}
@ -14857,7 +14864,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->number, layout, &ent);
encode_mapentry(e, f->UPB_PRIVATE(number), layout, &ent);
}
_upb_mapsorter_popmap(&e->sorter, &sorted);
} else {
@ -14868,7 +14875,7 @@ static void encode_map(upb_encstate* e, const upb_Message* msg,
upb_MapEntry ent;
_upb_map_fromkey(key, &ent.data.k, map->key_size);
_upb_map_fromvalue(val, &ent.data.v, map->val_size);
encode_mapentry(e, f->number, layout, &ent);
encode_mapentry(e, f->UPB_PRIVATE(number), layout, &ent);
}
}
}
@ -14907,7 +14914,7 @@ static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg,
return _upb_Message_GetHasbitByField(msg, f);
} else {
// Field is in a oneof.
return _upb_Message_GetOneofCase(msg, f) == f->number;
return _upb_Message_GetOneofCase(msg, f) == f->UPB_PRIVATE(number);
}
}

@ -1011,6 +1011,8 @@ UPB_INLINE bool upb_MiniTableEnum_CheckValue(const upb_MiniTableEnum* e,
#ifndef UPB_MINI_TABLE_FIELD_H_
#define UPB_MINI_TABLE_FIELD_H_
#include <stdint.h>
#ifndef UPB_MINI_TABLE_INTERNAL_FIELD_H_
#define UPB_MINI_TABLE_INTERNAL_FIELD_H_
@ -1090,7 +1092,7 @@ UPB_INLINE int upb_FieldType_SizeLg2(upb_FieldType field_type) {
// LINT.IfChange(struct_definition)
struct upb_MiniTableField {
uint32_t number;
uint32_t UPB_ONLYBITS(number);
uint16_t offset;
int16_t presence; // If >0, hasbit_index. If <0, ~oneof_index
@ -1226,6 +1228,11 @@ UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_HasPresence)(
}
}
UPB_INLINE uint32_t
UPB_PRIVATE(_upb_MiniTableField_Number)(const struct upb_MiniTableField* f) {
return f->UPB_ONLYBITS(number);
}
UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(
const struct upb_MiniTableField* f) {
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
@ -1308,6 +1315,10 @@ UPB_API_INLINE bool upb_MiniTableField_IsSubMessage(
return UPB_PRIVATE(_upb_MiniTableField_IsSubMessage)(f);
}
UPB_API_INLINE uint32_t upb_MiniTableField_Number(const upb_MiniTableField* f) {
return UPB_PRIVATE(_upb_MiniTableField_Number)(f);
}
UPB_API_INLINE upb_FieldType
upb_MiniTableField_Type(const upb_MiniTableField* f) {
return UPB_PRIVATE(_upb_MiniTableField_Type)(f);
@ -1631,7 +1642,7 @@ UPB_INLINE const struct upb_MiniTableField* UPB_PRIVATE(
UPB_INLINE uint32_t UPB_PRIVATE(_upb_MiniTableExtension_Number)(
const struct upb_MiniTableExtension* e) {
return e->UPB_PRIVATE(field).number;
return e->UPB_PRIVATE(field).UPB_ONLYBITS(number);
}
UPB_INLINE const struct upb_MiniTable* UPB_PRIVATE(
@ -2556,7 +2567,7 @@ UPB_INLINE uint32_t _upb_Message_GetOneofCase(const upb_Message* msg,
UPB_INLINE void _upb_Message_SetOneofCase(upb_Message* msg,
const upb_MiniTableField* f) {
*_upb_Message_OneofCasePtr(msg, f) = f->number;
*_upb_Message_OneofCasePtr(msg, f) = upb_MiniTableField_Number(f);
}
// TODO: implement _upb_Message_ClearOneofCase()
@ -2664,7 +2675,8 @@ UPB_INLINE bool _upb_Message_HasNonExtensionField(
UPB_ASSERT(upb_MiniTableField_HasPresence(field));
UPB_ASSUME(!upb_MiniTableField_IsExtension(field));
if (upb_MiniTableField_IsInOneof(field)) {
return _upb_Message_GetOneofCase(msg, field) == field->number;
return _upb_Message_GetOneofCase(msg, field) ==
upb_MiniTableField_Number(field);
} else {
return _upb_Message_GetHasbitByField(msg, field);
}
@ -2762,7 +2774,7 @@ UPB_INLINE void _upb_Message_ClearNonExtensionField(
_upb_Message_ClearHasbitByField(msg, field);
} else if (upb_MiniTableField_IsInOneof(field)) {
uint32_t* ptr = _upb_Message_OneofCasePtr(msg, field);
if (*ptr != field->number) return;
if (*ptr != upb_MiniTableField_Number(field)) return;
*ptr = 0;
}
const char zeros[16] = {0};

Loading…
Cancel
Save