upb: tag upb_Array.size as UPB_ONLYBITS()

PiperOrigin-RevId: 592035282
pull/15108/head
Eric Salo 11 months ago committed by Copybara-Service
parent ba57a4e715
commit a4a98bdcc0
  1. 29
      upb/message/array.c
  2. 2
      upb/message/copy.c
  3. 11
      upb/message/internal/array.h
  4. 2
      upb/message/promote.c
  5. 560
      upb/reflection/stage0/google/protobuf/descriptor.upb.h
  6. 44
      upb/wire/decode.c
  7. 6
      upb/wire/decode_fast.c
  8. 12
      upb/wire/encode.c
  9. 20
      upb_generator/protoc-gen-upb.cc
  10. 56
      upb_generator/stage0/google/protobuf/compiler/plugin.upb.h

@ -28,13 +28,13 @@ const void* upb_Array_DataPtr(const upb_Array* arr) {
void* upb_Array_MutableDataPtr(upb_Array* arr) { return _upb_array_ptr(arr); }
size_t upb_Array_Size(const upb_Array* arr) { return arr->size; }
size_t upb_Array_Size(const upb_Array* arr) { return arr->UPB_PRIVATE(size); }
upb_MessageValue upb_Array_Get(const upb_Array* arr, size_t i) {
upb_MessageValue ret;
const char* data = _upb_array_constptr(arr);
const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr);
UPB_ASSERT(i < arr->size);
UPB_ASSERT(i < arr->UPB_PRIVATE(size));
memcpy(&ret, data + (i << lg2), 1 << lg2);
return ret;
}
@ -42,16 +42,16 @@ upb_MessageValue upb_Array_Get(const upb_Array* arr, size_t i) {
void upb_Array_Set(upb_Array* arr, size_t i, upb_MessageValue val) {
char* data = _upb_array_ptr(arr);
const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr);
UPB_ASSERT(i < arr->size);
UPB_ASSERT(i < arr->UPB_PRIVATE(size));
memcpy(data + (i << lg2), &val, 1 << lg2);
}
bool upb_Array_Append(upb_Array* arr, upb_MessageValue val, upb_Arena* arena) {
UPB_ASSERT(arena);
if (!_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) {
if (!_upb_Array_ResizeUninitialized(arr, arr->UPB_PRIVATE(size) + 1, arena)) {
return false;
}
upb_Array_Set(arr, arr->size - 1, val);
upb_Array_Set(arr, arr->UPB_PRIVATE(size) - 1, val);
return true;
}
@ -65,10 +65,11 @@ void upb_Array_Move(upb_Array* arr, size_t dst_idx, size_t src_idx,
bool upb_Array_Insert(upb_Array* arr, size_t i, size_t count,
upb_Arena* arena) {
UPB_ASSERT(arena);
UPB_ASSERT(i <= arr->size);
UPB_ASSERT(count + arr->size >= count);
const size_t oldsize = arr->size;
if (!_upb_Array_ResizeUninitialized(arr, arr->size + count, arena)) {
UPB_ASSERT(i <= arr->UPB_PRIVATE(size));
UPB_ASSERT(count + arr->UPB_PRIVATE(size) >= count);
const size_t oldsize = arr->UPB_PRIVATE(size);
if (!_upb_Array_ResizeUninitialized(arr, arr->UPB_PRIVATE(size) + count,
arena)) {
return false;
}
upb_Array_Move(arr, i + count, i, oldsize - i);
@ -82,17 +83,17 @@ bool upb_Array_Insert(upb_Array* arr, size_t i, size_t count,
void upb_Array_Delete(upb_Array* arr, size_t i, size_t count) {
const size_t end = i + count;
UPB_ASSERT(i <= end);
UPB_ASSERT(end <= arr->size);
upb_Array_Move(arr, i, end, arr->size - end);
arr->size -= count;
UPB_ASSERT(end <= arr->UPB_PRIVATE(size));
upb_Array_Move(arr, i, end, arr->UPB_PRIVATE(size) - end);
arr->UPB_PRIVATE(size) -= count;
}
bool upb_Array_Resize(upb_Array* arr, size_t size, upb_Arena* arena) {
const size_t oldsize = arr->size;
const size_t oldsize = arr->UPB_PRIVATE(size);
if (UPB_UNLIKELY(!_upb_Array_ResizeUninitialized(arr, size, arena))) {
return false;
}
const size_t newsize = arr->size;
const size_t newsize = arr->UPB_PRIVATE(size);
if (newsize > oldsize) {
const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr);
char* data = _upb_array_ptr(arr);

@ -142,7 +142,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) {
size_t size = array->size;
size_t size = array->UPB_PRIVATE(size);
upb_Array* cloned_array =
UPB_PRIVATE(_upb_Array_New)(arena, size, upb_CType_SizeLg2(value_type));
if (!cloned_array) {

@ -35,7 +35,7 @@ struct upb_Array {
// Bit #2 contains the frozen/immutable flag (currently unimplemented).
uintptr_t data;
size_t size; // The number of elements in the array.
size_t UPB_ONLYBITS(size); // The number of elements in the array.
size_t UPB_PRIVATE(capacity); // Allocated storage. Measured in elements.
};
@ -73,7 +73,7 @@ UPB_INLINE upb_Array* UPB_PRIVATE(_upb_Array_New)(upb_Arena* arena,
if (!array) return NULL;
UPB_PRIVATE(_upb_Array_SetTaggedPtr)
(array, UPB_PTR_AT(array, array_size, void), elem_size_lg2);
array->size = 0;
array->UPB_ONLYBITS(size) = 0;
array->UPB_PRIVATE(capacity) = init_capacity;
return array;
}
@ -92,9 +92,10 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Array_Reserve)(upb_Array* array, size_t size,
// Resize without initializing new elements.
UPB_INLINE bool _upb_Array_ResizeUninitialized(upb_Array* array, size_t size,
upb_Arena* arena) {
UPB_ASSERT(size <= array->size || arena); // Allow NULL arena when shrinking.
UPB_ASSERT(size <= array->UPB_ONLYBITS(size) ||
arena); // Allow NULL arena when shrinking.
if (!UPB_PRIVATE(_upb_Array_Reserve)(array, size, arena)) return false;
array->size = size;
array->UPB_ONLYBITS(size) = size;
return true;
}
@ -104,7 +105,7 @@ UPB_INLINE bool _upb_Array_ResizeUninitialized(upb_Array* array, size_t size,
UPB_INLINE void UPB_PRIVATE(_upb_Array_Set)(upb_Array* array, size_t i,
const void* data,
size_t elem_size) {
UPB_ASSERT(i < array->size);
UPB_ASSERT(i < array->UPB_ONLYBITS(size));
UPB_ASSERT(elem_size == 1U << UPB_PRIVATE(_upb_Array_ElemSizeLg2)(array));
char* arr_data = (char*)_upb_array_ptr(array);
memcpy(arr_data + (i * elem_size), data, elem_size);

@ -196,7 +196,7 @@ upb_DecodeStatus upb_Array_PromoteMessages(upb_Array* arr,
int decode_options,
upb_Arena* arena) {
void** data = _upb_array_ptr(arr);
size_t size = arr->size;
size_t size = arr->UPB_PRIVATE(size);
for (size_t i = 0; i < size; i++) {
upb_TaggedMessagePtr tagged;
memcpy(&tagged, &data[i], sizeof(tagged));

File diff suppressed because it is too large Load Diff

@ -133,9 +133,10 @@ static void _upb_Decoder_VerifyUtf8(upb_Decoder* d, const char* buf, int len) {
}
static bool _upb_Decoder_Reserve(upb_Decoder* d, upb_Array* arr, size_t elem) {
bool need_realloc = arr->UPB_PRIVATE(capacity) - arr->size < elem;
if (need_realloc &&
!UPB_PRIVATE(_upb_Array_Realloc)(arr, arr->size + elem, &d->arena)) {
bool need_realloc =
arr->UPB_PRIVATE(capacity) - arr->UPB_PRIVATE(size) < elem;
if (need_realloc && !UPB_PRIVATE(_upb_Array_Realloc)(
arr, arr->UPB_PRIVATE(size) + elem, &d->arena)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
}
return need_realloc;
@ -409,8 +410,8 @@ static const char* _upb_Decoder_DecodeEnumArray(upb_Decoder* d, const char* ptr,
wireval* val) {
const upb_MiniTableEnum* e = _upb_MiniTableSubs_EnumByField(subs, field);
if (!_upb_Decoder_CheckEnum(d, ptr, msg, e, field, val)) return ptr;
void* mem = UPB_PTR_AT(_upb_array_ptr(arr), arr->size * 4, void);
arr->size++;
void* mem = UPB_PTR_AT(_upb_array_ptr(arr), arr->UPB_PRIVATE(size) * 4, void);
arr->UPB_PRIVATE(size)++;
memcpy(mem, val, 4);
return ptr;
}
@ -426,8 +427,9 @@ static const char* _upb_Decoder_DecodeFixedPacked(
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed);
}
_upb_Decoder_Reserve(d, arr, count);
void* mem = UPB_PTR_AT(_upb_array_ptr(arr), arr->size << lg2, void);
arr->size += count;
void* mem =
UPB_PTR_AT(_upb_array_ptr(arr), arr->UPB_PRIVATE(size) << lg2, void);
arr->UPB_PRIVATE(size) += count;
// Note: if/when the decoder supports multi-buffer input, we will need to
// handle buffer seams here.
if (_upb_IsLittleEndian()) {
@ -457,15 +459,17 @@ static const char* _upb_Decoder_DecodeVarintPacked(
const upb_MiniTableField* field, int lg2) {
int scale = 1 << lg2;
int saved_limit = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, val->size);
char* out = UPB_PTR_AT(_upb_array_ptr(arr), arr->size << lg2, void);
char* out =
UPB_PTR_AT(_upb_array_ptr(arr), arr->UPB_PRIVATE(size) << lg2, void);
while (!_upb_Decoder_IsDone(d, &ptr)) {
wireval elem;
ptr = _upb_Decoder_DecodeVarint(d, ptr, &elem.uint64_val);
_upb_Decoder_Munge(field->UPB_PRIVATE(descriptortype), &elem);
if (_upb_Decoder_Reserve(d, arr, 1)) {
out = UPB_PTR_AT(_upb_array_ptr(arr), arr->size << lg2, void);
out =
UPB_PTR_AT(_upb_array_ptr(arr), arr->UPB_PRIVATE(size) << lg2, void);
}
arr->size++;
arr->UPB_PRIVATE(size)++;
memcpy(out, &elem, scale);
out += scale;
}
@ -480,7 +484,7 @@ static const char* _upb_Decoder_DecodeEnumPacked(
wireval* val) {
const upb_MiniTableEnum* e = _upb_MiniTableSubs_EnumByField(subs, field);
int saved_limit = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, val->size);
char* out = UPB_PTR_AT(_upb_array_ptr(arr), arr->size * 4, void);
char* out = UPB_PTR_AT(_upb_array_ptr(arr), arr->UPB_PRIVATE(size) * 4, void);
while (!_upb_Decoder_IsDone(d, &ptr)) {
wireval elem;
ptr = _upb_Decoder_DecodeVarint(d, ptr, &elem.uint64_val);
@ -489,9 +493,9 @@ static const char* _upb_Decoder_DecodeEnumPacked(
continue;
}
if (_upb_Decoder_Reserve(d, arr, 1)) {
out = UPB_PTR_AT(_upb_array_ptr(arr), arr->size * 4, void);
out = UPB_PTR_AT(_upb_array_ptr(arr), arr->UPB_PRIVATE(size) * 4, void);
}
arr->size++;
arr->UPB_PRIVATE(size)++;
memcpy(out, &elem, 4);
out += 4;
}
@ -529,8 +533,8 @@ static const char* _upb_Decoder_DecodeToArray(upb_Decoder* d, const char* ptr,
case kUpb_DecodeOp_Scalar4Byte:
case kUpb_DecodeOp_Scalar8Byte:
/* Append scalar value. */
mem = UPB_PTR_AT(_upb_array_ptr(arr), arr->size << op, void);
arr->size++;
mem = UPB_PTR_AT(_upb_array_ptr(arr), arr->UPB_PRIVATE(size) << op, void);
arr->UPB_PRIVATE(size)++;
memcpy(mem, val, 1 << op);
return ptr;
case kUpb_DecodeOp_String:
@ -538,16 +542,18 @@ static const char* _upb_Decoder_DecodeToArray(upb_Decoder* d, const char* ptr,
/* Fallthrough. */
case kUpb_DecodeOp_Bytes: {
/* Append bytes. */
upb_StringView* str = (upb_StringView*)_upb_array_ptr(arr) + arr->size;
arr->size++;
upb_StringView* str =
(upb_StringView*)_upb_array_ptr(arr) + arr->UPB_PRIVATE(size);
arr->UPB_PRIVATE(size)++;
return _upb_Decoder_ReadString(d, ptr, val->size, str);
}
case kUpb_DecodeOp_SubMessage: {
/* Append submessage / group. */
upb_TaggedMessagePtr* target = UPB_PTR_AT(
_upb_array_ptr(arr), arr->size * sizeof(void*), upb_TaggedMessagePtr);
_upb_array_ptr(arr), arr->UPB_PRIVATE(size) * sizeof(void*),
upb_TaggedMessagePtr);
upb_Message* submsg = _upb_Decoder_NewSubMessage(d, subs, field, target);
arr->size++;
arr->UPB_PRIVATE(size)++;
if (UPB_UNLIKELY(field->UPB_PRIVATE(descriptortype) ==
kUpb_FieldType_Group)) {
return _upb_Decoder_DecodeKnownGroup(d, ptr, submsg, subs, field);

@ -193,7 +193,7 @@ static bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) {
UPB_FORCEINLINE
static void fastdecode_commitarr(void* dst, fastdecode_arr* farr,
int valbytes) {
farr->arr->size =
farr->arr->UPB_PRIVATE(size) =
(size_t)((char*)dst - (char*)_upb_array_ptr(farr->arr)) / valbytes;
}
@ -264,7 +264,7 @@ static void* fastdecode_getfield(upb_Decoder* d, const char* ptr,
begin = _upb_array_ptr(farr->arr);
farr->end = begin + (farr->arr->UPB_PRIVATE(capacity) * valbytes);
*data = _upb_FastDecoder_LoadTag(ptr);
return begin + (farr->arr->size * valbytes);
return begin + (farr->arr->UPB_PRIVATE(size) * valbytes);
}
default:
UPB_UNREACHABLE();
@ -552,7 +552,7 @@ TAGBYTES(p)
\
char* dst = _upb_array_ptr(arr); \
memcpy(dst, ptr, size); \
arr->size = elems; \
arr->UPB_PRIVATE(size) = elems; \
\
ptr += size; \
UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS);

@ -181,7 +181,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->size * elem_size;
size_t bytes = arr->UPB_PRIVATE(size) * elem_size;
const char* data = _upb_array_constptr(arr);
const char* ptr = data + bytes - elem_size;
@ -313,14 +313,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->size == 0) {
if (arr == NULL || arr->UPB_PRIVATE(size) == 0) {
return;
}
#define VARINT_CASE(ctype, encode) \
{ \
const ctype* start = _upb_array_constptr(arr); \
const ctype* ptr = start + arr->size; \
const ctype* ptr = start + arr->UPB_PRIVATE(size); \
uint32_t tag = \
packed ? 0 : (f->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint; \
do { \
@ -365,7 +365,7 @@ 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_constptr(arr);
const upb_StringView* ptr = start + arr->size;
const upb_StringView* ptr = start + arr->UPB_PRIVATE(size);
do {
ptr--;
encode_bytes(e, ptr->data, ptr->size);
@ -376,7 +376,7 @@ static void encode_array(upb_encstate* e, const upb_Message* msg,
}
case kUpb_FieldType_Group: {
const upb_TaggedMessagePtr* start = _upb_array_constptr(arr);
const upb_TaggedMessagePtr* ptr = start + arr->size;
const upb_TaggedMessagePtr* ptr = start + arr->UPB_PRIVATE(size);
const upb_MiniTable* subm =
upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]);
if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded);
@ -392,7 +392,7 @@ static void encode_array(upb_encstate* e, const upb_Message* msg,
}
case kUpb_FieldType_Message: {
const upb_TaggedMessagePtr* start = _upb_array_constptr(arr);
const upb_TaggedMessagePtr* ptr = start + arr->size;
const upb_TaggedMessagePtr* ptr = start + arr->UPB_PRIVATE(size);
const upb_MiniTable* subm =
upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]);
if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded);

@ -503,7 +503,7 @@ void GenerateRepeatedGetters(upb::FieldDefPtr field, const DefPoolPair& pools,
const upb_MiniTableField field = $3;
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (arr) {
if (size) *size = arr->size;
if (size) *size = arr->UPB_PRIVATE(size);
return ($0 const*)_upb_array_constptr(arr);
} else {
if (size) *size = 0;
@ -528,7 +528,7 @@ void GenerateRepeatedGetters(upb::FieldDefPtr field, const DefPoolPair& pools,
const upb_MiniTableField field = $3;
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
*size = arr ? arr->UPB_PRIVATE(size) : 0;
}
return arr;
}
@ -537,7 +537,7 @@ void GenerateRepeatedGetters(upb::FieldDefPtr field, const DefPoolPair& pools,
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
*size = arr ? arr->UPB_PRIVATE(size) : 0;
}
return arr;
}
@ -649,7 +649,7 @@ void GenerateRepeatedSetters(upb::FieldDefPtr field, const DefPoolPair& pools,
upb_MiniTableField field = $3;
upb_Array* arr = upb_Message_GetMutableArray(msg, &field);
if (arr) {
if (size) *size = arr->size;
if (size) *size = arr->UPB_PRIVATE(size);
return ($0*)_upb_array_ptr(arr);
} else {
if (size) *size = 0;
@ -674,12 +674,14 @@ void GenerateRepeatedSetters(upb::FieldDefPtr field, const DefPoolPair& pools,
UPB_INLINE struct $0* $1_add_$2($1* msg, upb_Arena* arena) {
upb_MiniTableField field = $4;
upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena);
if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) {
if (!arr || !_upb_Array_ResizeUninitialized(
arr, arr->UPB_PRIVATE(size) + 1, arena)) {
return NULL;
}
struct $0* sub = (struct $0*)_upb_Message_New($3, arena);
if (!arr || !sub) return NULL;
UPB_PRIVATE(_upb_Array_Set)(arr, arr->size - 1, &sub, sizeof(sub));
UPB_PRIVATE(_upb_Array_Set)
(arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
return sub;
}
)cc",
@ -692,10 +694,12 @@ void GenerateRepeatedSetters(upb::FieldDefPtr field, const DefPoolPair& pools,
UPB_INLINE bool $1_add_$2($1* msg, $0 val, upb_Arena* arena) {
upb_MiniTableField field = $3;
upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena);
if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) {
if (!arr || !_upb_Array_ResizeUninitialized(
arr, arr->UPB_PRIVATE(size) + 1, arena)) {
return false;
}
UPB_PRIVATE(_upb_Array_Set)(arr, arr->size - 1, &val, sizeof(val));
UPB_PRIVATE(_upb_Array_Set)
(arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val));
return true;
}
)cc",

@ -196,7 +196,7 @@ UPB_INLINE upb_StringView const* google_protobuf_compiler_CodeGeneratorRequest_f
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 1);
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (arr) {
if (size) *size = arr->size;
if (size) *size = arr->UPB_PRIVATE(size);
return (upb_StringView const*)_upb_array_constptr(arr);
} else {
if (size) *size = 0;
@ -207,7 +207,7 @@ UPB_INLINE const upb_Array* _google_protobuf_compiler_CodeGeneratorRequest_file_
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 1);
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
*size = arr ? arr->UPB_PRIVATE(size) : 0;
}
return arr;
}
@ -216,7 +216,7 @@ UPB_INLINE upb_Array* _google_protobuf_compiler_CodeGeneratorRequest_file_to_gen
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
*size = arr ? arr->UPB_PRIVATE(size) : 0;
}
return arr;
}
@ -258,7 +258,7 @@ UPB_INLINE const struct google_protobuf_FileDescriptorProto* const* google_proto
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 15);
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (arr) {
if (size) *size = arr->size;
if (size) *size = arr->UPB_PRIVATE(size);
return (const struct google_protobuf_FileDescriptorProto* const*)_upb_array_constptr(arr);
} else {
if (size) *size = 0;
@ -269,7 +269,7 @@ UPB_INLINE const upb_Array* _google_protobuf_compiler_CodeGeneratorRequest_proto
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 15);
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
*size = arr ? arr->UPB_PRIVATE(size) : 0;
}
return arr;
}
@ -278,7 +278,7 @@ UPB_INLINE upb_Array* _google_protobuf_compiler_CodeGeneratorRequest_proto_file_
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
*size = arr ? arr->UPB_PRIVATE(size) : 0;
}
return arr;
}
@ -290,7 +290,7 @@ UPB_INLINE const struct google_protobuf_FileDescriptorProto* const* google_proto
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 17);
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (arr) {
if (size) *size = arr->size;
if (size) *size = arr->UPB_PRIVATE(size);
return (const struct google_protobuf_FileDescriptorProto* const*)_upb_array_constptr(arr);
} else {
if (size) *size = 0;
@ -301,7 +301,7 @@ UPB_INLINE const upb_Array* _google_protobuf_compiler_CodeGeneratorRequest_sourc
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 17);
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
*size = arr ? arr->UPB_PRIVATE(size) : 0;
}
return arr;
}
@ -310,7 +310,7 @@ UPB_INLINE upb_Array* _google_protobuf_compiler_CodeGeneratorRequest_source_file
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
*size = arr ? arr->UPB_PRIVATE(size) : 0;
}
return arr;
}
@ -319,7 +319,7 @@ UPB_INLINE upb_StringView* google_protobuf_compiler_CodeGeneratorRequest_mutable
upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 1);
upb_Array* arr = upb_Message_GetMutableArray(msg, &field);
if (arr) {
if (size) *size = arr->size;
if (size) *size = arr->UPB_PRIVATE(size);
return (upb_StringView*)_upb_array_ptr(arr);
} else {
if (size) *size = 0;
@ -333,10 +333,12 @@ UPB_INLINE upb_StringView* google_protobuf_compiler_CodeGeneratorRequest_resize_
UPB_INLINE bool google_protobuf_compiler_CodeGeneratorRequest_add_file_to_generate(google_protobuf_compiler_CodeGeneratorRequest* msg, upb_StringView val, upb_Arena* arena) {
upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 1);
upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena);
if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) {
if (!arr || !_upb_Array_ResizeUninitialized(
arr, arr->UPB_PRIVATE(size) + 1, arena)) {
return false;
}
UPB_PRIVATE(_upb_Array_Set)(arr, arr->size - 1, &val, sizeof(val));
UPB_PRIVATE(_upb_Array_Set)
(arr, arr->UPB_PRIVATE(size) - 1, &val, sizeof(val));
return true;
}
UPB_INLINE void google_protobuf_compiler_CodeGeneratorRequest_set_parameter(google_protobuf_compiler_CodeGeneratorRequest *msg, upb_StringView value) {
@ -359,7 +361,7 @@ UPB_INLINE struct google_protobuf_FileDescriptorProto** google_protobuf_compiler
upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 15);
upb_Array* arr = upb_Message_GetMutableArray(msg, &field);
if (arr) {
if (size) *size = arr->size;
if (size) *size = arr->UPB_PRIVATE(size);
return (struct google_protobuf_FileDescriptorProto**)_upb_array_ptr(arr);
} else {
if (size) *size = 0;
@ -373,19 +375,21 @@ UPB_INLINE struct google_protobuf_FileDescriptorProto** google_protobuf_compiler
UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_compiler_CodeGeneratorRequest_add_proto_file(google_protobuf_compiler_CodeGeneratorRequest* msg, upb_Arena* arena) {
upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 15);
upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena);
if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) {
if (!arr || !_upb_Array_ResizeUninitialized(
arr, arr->UPB_PRIVATE(size) + 1, arena)) {
return NULL;
}
struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)_upb_Message_New(google__protobuf__FileDescriptorProto_msg_init(), arena);
if (!arr || !sub) return NULL;
UPB_PRIVATE(_upb_Array_Set)(arr, arr->size - 1, &sub, sizeof(sub));
UPB_PRIVATE(_upb_Array_Set)
(arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
return sub;
}
UPB_INLINE struct google_protobuf_FileDescriptorProto** google_protobuf_compiler_CodeGeneratorRequest_mutable_source_file_descriptors(google_protobuf_compiler_CodeGeneratorRequest* msg, size_t* size) {
upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 17);
upb_Array* arr = upb_Message_GetMutableArray(msg, &field);
if (arr) {
if (size) *size = arr->size;
if (size) *size = arr->UPB_PRIVATE(size);
return (struct google_protobuf_FileDescriptorProto**)_upb_array_ptr(arr);
} else {
if (size) *size = 0;
@ -399,12 +403,14 @@ UPB_INLINE struct google_protobuf_FileDescriptorProto** google_protobuf_compiler
UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_compiler_CodeGeneratorRequest_add_source_file_descriptors(google_protobuf_compiler_CodeGeneratorRequest* msg, upb_Arena* arena) {
upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorRequest_msg_init(), 17);
upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena);
if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) {
if (!arr || !_upb_Array_ResizeUninitialized(
arr, arr->UPB_PRIVATE(size) + 1, arena)) {
return NULL;
}
struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)_upb_Message_New(google__protobuf__FileDescriptorProto_msg_init(), arena);
if (!arr || !sub) return NULL;
UPB_PRIVATE(_upb_Array_Set)(arr, arr->size - 1, &sub, sizeof(sub));
UPB_PRIVATE(_upb_Array_Set)
(arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
return sub;
}
@ -511,7 +517,7 @@ UPB_INLINE const google_protobuf_compiler_CodeGeneratorResponse_File* const* goo
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorResponse_msg_init(), 15);
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (arr) {
if (size) *size = arr->size;
if (size) *size = arr->UPB_PRIVATE(size);
return (const google_protobuf_compiler_CodeGeneratorResponse_File* const*)_upb_array_constptr(arr);
} else {
if (size) *size = 0;
@ -522,7 +528,7 @@ UPB_INLINE const upb_Array* _google_protobuf_compiler_CodeGeneratorResponse_file
const upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorResponse_msg_init(), 15);
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
*size = arr ? arr->UPB_PRIVATE(size) : 0;
}
return arr;
}
@ -531,7 +537,7 @@ UPB_INLINE upb_Array* _google_protobuf_compiler_CodeGeneratorResponse_file_mutab
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
*size = arr ? arr->UPB_PRIVATE(size) : 0;
}
return arr;
}
@ -556,7 +562,7 @@ UPB_INLINE google_protobuf_compiler_CodeGeneratorResponse_File** google_protobuf
upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorResponse_msg_init(), 15);
upb_Array* arr = upb_Message_GetMutableArray(msg, &field);
if (arr) {
if (size) *size = arr->size;
if (size) *size = arr->UPB_PRIVATE(size);
return (google_protobuf_compiler_CodeGeneratorResponse_File**)_upb_array_ptr(arr);
} else {
if (size) *size = 0;
@ -570,12 +576,14 @@ UPB_INLINE google_protobuf_compiler_CodeGeneratorResponse_File** google_protobuf
UPB_INLINE struct google_protobuf_compiler_CodeGeneratorResponse_File* google_protobuf_compiler_CodeGeneratorResponse_add_file(google_protobuf_compiler_CodeGeneratorResponse* msg, upb_Arena* arena) {
upb_MiniTableField field = *upb_MiniTable_FindFieldByNumber(google__protobuf__compiler__CodeGeneratorResponse_msg_init(), 15);
upb_Array* arr = upb_Message_GetOrCreateMutableArray(msg, &field, arena);
if (!arr || !_upb_Array_ResizeUninitialized(arr, arr->size + 1, arena)) {
if (!arr || !_upb_Array_ResizeUninitialized(
arr, arr->UPB_PRIVATE(size) + 1, arena)) {
return NULL;
}
struct google_protobuf_compiler_CodeGeneratorResponse_File* sub = (struct google_protobuf_compiler_CodeGeneratorResponse_File*)_upb_Message_New(google__protobuf__compiler__CodeGeneratorResponse__File_msg_init(), arena);
if (!arr || !sub) return NULL;
UPB_PRIVATE(_upb_Array_Set)(arr, arr->size - 1, &sub, sizeof(sub));
UPB_PRIVATE(_upb_Array_Set)
(arr, arr->UPB_PRIVATE(size) - 1, &sub, sizeof(sub));
return sub;
}

Loading…
Cancel
Save