Auto-generate files after cl/582708011

pull/14760/head
Protobuf Team Bot 1 year ago
parent 88f0a82a18
commit b8c1a2743b
  1. 14
      php/ext/google/protobuf/php-upb.c
  2. 88
      php/ext/google/protobuf/php-upb.h
  3. 14
      ruby/ext/google/protobuf_c/ruby-upb.c
  4. 88
      ruby/ext/google/protobuf_c/ruby-upb.h

@ -13187,10 +13187,10 @@ static const char* _upb_Decoder_DecodeToSubMessage(
/* Set presence if necessary. */
if (field->presence > 0) {
_upb_sethas_field(msg, field);
_upb_Message_SetHasbitByField(msg, field);
} else if (field->presence < 0) {
/* Oneof case */
uint32_t* oneof_case = _upb_oneofcase_field(msg, field);
uint32_t* oneof_case = _upb_Message_OneofCasePtr(msg, field);
if (op == kUpb_DecodeOp_SubMessage && *oneof_case != field->number) {
memset(mem, 0, sizeof(void*));
}
@ -15290,7 +15290,7 @@ static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg,
const upb_MiniTableSub* subs,
const upb_MiniTableField* f) {
if (f->presence == 0) {
/* Proto3 presence or map/array. */
// Proto3 presence or map/array.
const void* mem = UPB_PTR_AT(msg, f->offset, void);
switch (_upb_MiniTableField_GetRep(f)) {
case kUpb_FieldRep_1Byte: {
@ -15316,11 +15316,11 @@ static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg,
UPB_UNREACHABLE();
}
} else if (f->presence > 0) {
/* Proto2 presence: hasbit. */
return _upb_hasbit_field(msg, f);
// Proto2 presence: hasbit.
return _upb_Message_GetHasbitByField(msg, f);
} else {
/* Field is in a oneof. */
return _upb_getoneofcase_field(msg, f) == f->number;
// Field is in a oneof.
return _upb_Message_GetOneofCase(msg, f) == f->number;
}
}

@ -2241,55 +2241,75 @@ extern "C" {
// Hasbit access ///////////////////////////////////////////////////////////////
UPB_INLINE size_t _upb_hasbit_ofs(size_t idx) { return idx / 8; }
UPB_INLINE size_t _upb_Hasbit_Offset(size_t index) { return index / 8; }
UPB_INLINE char _upb_hasbit_mask(size_t idx) { return 1 << (idx % 8); }
UPB_INLINE char _upb_Hasbit_Mask(size_t index) { return 1 << (index % 8); }
UPB_INLINE bool _upb_hasbit(const upb_Message* msg, size_t idx) {
return (*UPB_PTR_AT(msg, _upb_hasbit_ofs(idx), const char) &
_upb_hasbit_mask(idx)) != 0;
UPB_INLINE size_t _upb_Hasbit_Index(const upb_MiniTableField* f) {
UPB_ASSERT(f->presence > 0);
return f->presence;
}
UPB_INLINE void _upb_sethas(const upb_Message* msg, size_t idx) {
(*UPB_PTR_AT(msg, _upb_hasbit_ofs(idx), char)) |= _upb_hasbit_mask(idx);
UPB_INLINE bool _upb_Message_GetHasbitByIndex(const upb_Message* msg,
size_t index) {
const size_t offset = _upb_Hasbit_Offset(index);
const char mask = _upb_Hasbit_Mask(index);
return (*UPB_PTR_AT(msg, offset, const char) & mask) != 0;
}
UPB_INLINE void _upb_clearhas(const upb_Message* msg, size_t idx) {
(*UPB_PTR_AT(msg, _upb_hasbit_ofs(idx), char)) &= ~_upb_hasbit_mask(idx);
UPB_INLINE void _upb_Message_SetHasbitByIndex(const upb_Message* msg,
size_t index) {
const size_t offset = _upb_Hasbit_Offset(index);
const char mask = _upb_Hasbit_Mask(index);
(*UPB_PTR_AT(msg, offset, char)) |= mask;
}
UPB_INLINE size_t _upb_Message_Hasidx(const upb_MiniTableField* f) {
UPB_ASSERT(f->presence > 0);
return f->presence;
UPB_INLINE void _upb_Message_ClearHasbitByIndex(const upb_Message* msg,
size_t index) {
const size_t offset = _upb_Hasbit_Offset(index);
const char mask = _upb_Hasbit_Mask(index);
(*UPB_PTR_AT(msg, offset, char)) &= ~mask;
}
UPB_INLINE bool _upb_Message_GetHasbitByField(const upb_Message* msg,
const upb_MiniTableField* f) {
return _upb_Message_GetHasbitByIndex(msg, _upb_Hasbit_Index(f));
}
UPB_INLINE bool _upb_hasbit_field(const upb_Message* msg,
const upb_MiniTableField* f) {
return _upb_hasbit(msg, _upb_Message_Hasidx(f));
UPB_INLINE void _upb_Message_SetHasbitByField(const upb_Message* msg,
const upb_MiniTableField* f) {
_upb_Message_SetHasbitByIndex(msg, _upb_Hasbit_Index(f));
}
UPB_INLINE void _upb_sethas_field(const upb_Message* msg,
const upb_MiniTableField* f) {
_upb_sethas(msg, _upb_Message_Hasidx(f));
UPB_INLINE void _upb_Message_ClearHasbitByField(const upb_Message* msg,
const upb_MiniTableField* f) {
_upb_Message_ClearHasbitByIndex(msg, _upb_Hasbit_Index(f));
}
// Oneof case access ///////////////////////////////////////////////////////////
UPB_INLINE size_t _upb_oneofcase_ofs(const upb_MiniTableField* f) {
UPB_INLINE size_t _upb_OneofCase_Offset(const upb_MiniTableField* f) {
UPB_ASSERT(f->presence < 0);
return ~(ptrdiff_t)f->presence;
}
UPB_INLINE uint32_t* _upb_oneofcase_field(upb_Message* msg,
const upb_MiniTableField* f) {
return UPB_PTR_AT(msg, _upb_oneofcase_ofs(f), uint32_t);
UPB_INLINE uint32_t* _upb_Message_OneofCasePtr(upb_Message* msg,
const upb_MiniTableField* f) {
return UPB_PTR_AT(msg, _upb_OneofCase_Offset(f), uint32_t);
}
UPB_INLINE uint32_t _upb_getoneofcase_field(const upb_Message* msg,
const upb_MiniTableField* f) {
return *_upb_oneofcase_field((upb_Message*)msg, f);
UPB_INLINE uint32_t _upb_Message_GetOneofCase(const upb_Message* msg,
const upb_MiniTableField* f) {
return *_upb_Message_OneofCasePtr((upb_Message*)msg, f);
}
UPB_INLINE void _upb_Message_SetOneofCase(upb_Message* msg,
const upb_MiniTableField* f) {
*_upb_Message_OneofCasePtr(msg, f) = f->number;
}
// TODO: implement _upb_Message_ClearOneofCase()
// LINT.ThenChange(GoogleInternalName2)
UPB_INLINE bool _upb_MiniTableField_InOneOf(const upb_MiniTableField* field) {
@ -2309,9 +2329,9 @@ UPB_INLINE const void* _upb_MiniTableField_GetConstPtr(
UPB_INLINE void _upb_Message_SetPresence(upb_Message* msg,
const upb_MiniTableField* field) {
if (field->presence > 0) {
_upb_sethas_field(msg, field);
_upb_Message_SetHasbitByField(msg, field);
} else if (_upb_MiniTableField_InOneOf(field)) {
*_upb_oneofcase_field(msg, field) = field->number;
_upb_Message_SetOneofCase(msg, field);
}
}
@ -2402,9 +2422,9 @@ UPB_INLINE bool _upb_Message_HasNonExtensionField(
UPB_ASSERT(upb_MiniTableField_HasPresence(field));
UPB_ASSUME(!upb_MiniTableField_IsExtension(field));
if (_upb_MiniTableField_InOneOf(field)) {
return _upb_getoneofcase_field(msg, field) == field->number;
return _upb_Message_GetOneofCase(msg, field) == field->number;
} else {
return _upb_hasbit_field(msg, field);
return _upb_Message_GetHasbitByField(msg, field);
}
}
@ -2493,11 +2513,11 @@ UPB_INLINE void _upb_Message_ClearExtensionField(
UPB_INLINE void _upb_Message_ClearNonExtensionField(
upb_Message* msg, const upb_MiniTableField* field) {
if (field->presence > 0) {
_upb_clearhas(msg, _upb_Message_Hasidx(field));
_upb_Message_ClearHasbitByField(msg, field);
} else if (_upb_MiniTableField_InOneOf(field)) {
uint32_t* oneof_case = _upb_oneofcase_field(msg, field);
if (*oneof_case != field->number) return;
*oneof_case = 0;
uint32_t* ptr = _upb_Message_OneofCasePtr(msg, field);
if (*ptr != field->number) return;
*ptr = 0;
}
const char zeros[16] = {0};
_upb_MiniTable_CopyFieldData(_upb_MiniTableField_GetPtr(msg, field), zeros,
@ -2680,7 +2700,7 @@ UPB_API_INLINE bool upb_Message_HasField(const upb_Message* msg,
UPB_API_INLINE uint32_t upb_Message_WhichOneofFieldNumber(
const upb_Message* message, const upb_MiniTableField* oneof_field) {
UPB_ASSUME(_upb_MiniTableField_InOneOf(oneof_field));
return _upb_getoneofcase_field(message, oneof_field);
return _upb_Message_GetOneofCase(message, oneof_field);
}
UPB_API_INLINE bool upb_Message_GetBool(const upb_Message* msg,

@ -12702,10 +12702,10 @@ static const char* _upb_Decoder_DecodeToSubMessage(
/* Set presence if necessary. */
if (field->presence > 0) {
_upb_sethas_field(msg, field);
_upb_Message_SetHasbitByField(msg, field);
} else if (field->presence < 0) {
/* Oneof case */
uint32_t* oneof_case = _upb_oneofcase_field(msg, field);
uint32_t* oneof_case = _upb_Message_OneofCasePtr(msg, field);
if (op == kUpb_DecodeOp_SubMessage && *oneof_case != field->number) {
memset(mem, 0, sizeof(void*));
}
@ -14805,7 +14805,7 @@ static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg,
const upb_MiniTableSub* subs,
const upb_MiniTableField* f) {
if (f->presence == 0) {
/* Proto3 presence or map/array. */
// Proto3 presence or map/array.
const void* mem = UPB_PTR_AT(msg, f->offset, void);
switch (_upb_MiniTableField_GetRep(f)) {
case kUpb_FieldRep_1Byte: {
@ -14831,11 +14831,11 @@ static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg,
UPB_UNREACHABLE();
}
} else if (f->presence > 0) {
/* Proto2 presence: hasbit. */
return _upb_hasbit_field(msg, f);
// Proto2 presence: hasbit.
return _upb_Message_GetHasbitByField(msg, f);
} else {
/* Field is in a oneof. */
return _upb_getoneofcase_field(msg, f) == f->number;
// Field is in a oneof.
return _upb_Message_GetOneofCase(msg, f) == f->number;
}
}

@ -2243,55 +2243,75 @@ extern "C" {
// Hasbit access ///////////////////////////////////////////////////////////////
UPB_INLINE size_t _upb_hasbit_ofs(size_t idx) { return idx / 8; }
UPB_INLINE size_t _upb_Hasbit_Offset(size_t index) { return index / 8; }
UPB_INLINE char _upb_hasbit_mask(size_t idx) { return 1 << (idx % 8); }
UPB_INLINE char _upb_Hasbit_Mask(size_t index) { return 1 << (index % 8); }
UPB_INLINE bool _upb_hasbit(const upb_Message* msg, size_t idx) {
return (*UPB_PTR_AT(msg, _upb_hasbit_ofs(idx), const char) &
_upb_hasbit_mask(idx)) != 0;
UPB_INLINE size_t _upb_Hasbit_Index(const upb_MiniTableField* f) {
UPB_ASSERT(f->presence > 0);
return f->presence;
}
UPB_INLINE void _upb_sethas(const upb_Message* msg, size_t idx) {
(*UPB_PTR_AT(msg, _upb_hasbit_ofs(idx), char)) |= _upb_hasbit_mask(idx);
UPB_INLINE bool _upb_Message_GetHasbitByIndex(const upb_Message* msg,
size_t index) {
const size_t offset = _upb_Hasbit_Offset(index);
const char mask = _upb_Hasbit_Mask(index);
return (*UPB_PTR_AT(msg, offset, const char) & mask) != 0;
}
UPB_INLINE void _upb_clearhas(const upb_Message* msg, size_t idx) {
(*UPB_PTR_AT(msg, _upb_hasbit_ofs(idx), char)) &= ~_upb_hasbit_mask(idx);
UPB_INLINE void _upb_Message_SetHasbitByIndex(const upb_Message* msg,
size_t index) {
const size_t offset = _upb_Hasbit_Offset(index);
const char mask = _upb_Hasbit_Mask(index);
(*UPB_PTR_AT(msg, offset, char)) |= mask;
}
UPB_INLINE size_t _upb_Message_Hasidx(const upb_MiniTableField* f) {
UPB_ASSERT(f->presence > 0);
return f->presence;
UPB_INLINE void _upb_Message_ClearHasbitByIndex(const upb_Message* msg,
size_t index) {
const size_t offset = _upb_Hasbit_Offset(index);
const char mask = _upb_Hasbit_Mask(index);
(*UPB_PTR_AT(msg, offset, char)) &= ~mask;
}
UPB_INLINE bool _upb_Message_GetHasbitByField(const upb_Message* msg,
const upb_MiniTableField* f) {
return _upb_Message_GetHasbitByIndex(msg, _upb_Hasbit_Index(f));
}
UPB_INLINE bool _upb_hasbit_field(const upb_Message* msg,
const upb_MiniTableField* f) {
return _upb_hasbit(msg, _upb_Message_Hasidx(f));
UPB_INLINE void _upb_Message_SetHasbitByField(const upb_Message* msg,
const upb_MiniTableField* f) {
_upb_Message_SetHasbitByIndex(msg, _upb_Hasbit_Index(f));
}
UPB_INLINE void _upb_sethas_field(const upb_Message* msg,
const upb_MiniTableField* f) {
_upb_sethas(msg, _upb_Message_Hasidx(f));
UPB_INLINE void _upb_Message_ClearHasbitByField(const upb_Message* msg,
const upb_MiniTableField* f) {
_upb_Message_ClearHasbitByIndex(msg, _upb_Hasbit_Index(f));
}
// Oneof case access ///////////////////////////////////////////////////////////
UPB_INLINE size_t _upb_oneofcase_ofs(const upb_MiniTableField* f) {
UPB_INLINE size_t _upb_OneofCase_Offset(const upb_MiniTableField* f) {
UPB_ASSERT(f->presence < 0);
return ~(ptrdiff_t)f->presence;
}
UPB_INLINE uint32_t* _upb_oneofcase_field(upb_Message* msg,
const upb_MiniTableField* f) {
return UPB_PTR_AT(msg, _upb_oneofcase_ofs(f), uint32_t);
UPB_INLINE uint32_t* _upb_Message_OneofCasePtr(upb_Message* msg,
const upb_MiniTableField* f) {
return UPB_PTR_AT(msg, _upb_OneofCase_Offset(f), uint32_t);
}
UPB_INLINE uint32_t _upb_getoneofcase_field(const upb_Message* msg,
const upb_MiniTableField* f) {
return *_upb_oneofcase_field((upb_Message*)msg, f);
UPB_INLINE uint32_t _upb_Message_GetOneofCase(const upb_Message* msg,
const upb_MiniTableField* f) {
return *_upb_Message_OneofCasePtr((upb_Message*)msg, f);
}
UPB_INLINE void _upb_Message_SetOneofCase(upb_Message* msg,
const upb_MiniTableField* f) {
*_upb_Message_OneofCasePtr(msg, f) = f->number;
}
// TODO: implement _upb_Message_ClearOneofCase()
// LINT.ThenChange(GoogleInternalName2)
UPB_INLINE bool _upb_MiniTableField_InOneOf(const upb_MiniTableField* field) {
@ -2311,9 +2331,9 @@ UPB_INLINE const void* _upb_MiniTableField_GetConstPtr(
UPB_INLINE void _upb_Message_SetPresence(upb_Message* msg,
const upb_MiniTableField* field) {
if (field->presence > 0) {
_upb_sethas_field(msg, field);
_upb_Message_SetHasbitByField(msg, field);
} else if (_upb_MiniTableField_InOneOf(field)) {
*_upb_oneofcase_field(msg, field) = field->number;
_upb_Message_SetOneofCase(msg, field);
}
}
@ -2404,9 +2424,9 @@ UPB_INLINE bool _upb_Message_HasNonExtensionField(
UPB_ASSERT(upb_MiniTableField_HasPresence(field));
UPB_ASSUME(!upb_MiniTableField_IsExtension(field));
if (_upb_MiniTableField_InOneOf(field)) {
return _upb_getoneofcase_field(msg, field) == field->number;
return _upb_Message_GetOneofCase(msg, field) == field->number;
} else {
return _upb_hasbit_field(msg, field);
return _upb_Message_GetHasbitByField(msg, field);
}
}
@ -2495,11 +2515,11 @@ UPB_INLINE void _upb_Message_ClearExtensionField(
UPB_INLINE void _upb_Message_ClearNonExtensionField(
upb_Message* msg, const upb_MiniTableField* field) {
if (field->presence > 0) {
_upb_clearhas(msg, _upb_Message_Hasidx(field));
_upb_Message_ClearHasbitByField(msg, field);
} else if (_upb_MiniTableField_InOneOf(field)) {
uint32_t* oneof_case = _upb_oneofcase_field(msg, field);
if (*oneof_case != field->number) return;
*oneof_case = 0;
uint32_t* ptr = _upb_Message_OneofCasePtr(msg, field);
if (*ptr != field->number) return;
*ptr = 0;
}
const char zeros[16] = {0};
_upb_MiniTable_CopyFieldData(_upb_MiniTableField_GetPtr(msg, field), zeros,
@ -2682,7 +2702,7 @@ UPB_API_INLINE bool upb_Message_HasField(const upb_Message* msg,
UPB_API_INLINE uint32_t upb_Message_WhichOneofFieldNumber(
const upb_Message* message, const upb_MiniTableField* oneof_field) {
UPB_ASSUME(_upb_MiniTableField_InOneOf(oneof_field));
return _upb_getoneofcase_field(message, oneof_field);
return _upb_Message_GetOneofCase(message, oneof_field);
}
UPB_API_INLINE bool upb_Message_GetBool(const upb_Message* msg,

Loading…
Cancel
Save