Lines Matching refs:iter
28 …kreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter);
29 …eturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter);
30 …ol checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter);
31 static void iter_from_extension(pb_field_iter_t *iter, pb_extension_t *extension);
33 …ode_extension(pb_istream_t *stream, uint32_t tag, pb_wire_type_t wire_type, pb_field_iter_t *iter);
34 static bool checkreturn find_extension_field(pb_field_iter_t *iter);
35 static void pb_field_set_to_default(pb_field_iter_t *iter);
52 static bool checkreturn pb_release_union_field(pb_istream_t *stream, pb_field_iter_t *iter);
53 static void pb_release_single_field(const pb_field_iter_t *iter);
401 …ckreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) in decode_static_field() argument
406 type = iter->pos->type; in decode_static_field()
412 return func(stream, iter->pos, iter->pData); in decode_static_field()
415 if (iter->pSize != iter->pData) in decode_static_field()
416 *(bool*)iter->pSize = true; in decode_static_field()
417 return func(stream, iter->pos, iter->pData); in decode_static_field()
425 pb_size_t *size = (pb_size_t*)iter->pSize; in decode_static_field()
431 while (substream.bytes_left > 0 && *size < iter->pos->array_size) in decode_static_field()
433 void *pItem = (char*)iter->pData + iter->pos->data_size * (*size); in decode_static_field()
434 if (!func(&substream, iter->pos, pItem)) in decode_static_field()
452 pb_size_t *size = (pb_size_t*)iter->pSize; in decode_static_field()
453 char *pItem = (char*)iter->pData + iter->pos->data_size * (*size); in decode_static_field()
455 if ((*size)++ >= iter->pos->array_size) in decode_static_field()
458 return func(stream, iter->pos, pItem); in decode_static_field()
462 *(pb_size_t*)iter->pSize = iter->pos->tag; in decode_static_field()
467 memset(iter->pData, 0, iter->pos->data_size); in decode_static_field()
468 pb_message_set_to_defaults((const pb_field_t*)iter->pos->ptr, iter->pData); in decode_static_field()
470 return func(stream, iter->pos, iter->pData); in decode_static_field()
518 static void initialize_pointer_field(void *pItem, pb_field_iter_t *iter) in initialize_pointer_field() argument
520 if (PB_LTYPE(iter->pos->type) == PB_LTYPE_STRING || in initialize_pointer_field()
521 PB_LTYPE(iter->pos->type) == PB_LTYPE_BYTES) in initialize_pointer_field()
525 else if (PB_LTYPE(iter->pos->type) == PB_LTYPE_SUBMESSAGE) in initialize_pointer_field()
529 memset(pItem, 0, iter->pos->data_size); in initialize_pointer_field()
530 pb_message_set_to_defaults((const pb_field_t *) iter->pos->ptr, pItem); in initialize_pointer_field()
535 …kreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) in decode_pointer_field() argument
539 PB_UNUSED(iter); in decode_pointer_field()
545 type = iter->pos->type; in decode_pointer_field()
554 *(void**)iter->pData != NULL) in decode_pointer_field()
557 pb_release_single_field(iter); in decode_pointer_field()
562 *(pb_size_t*)iter->pSize = iter->pos->tag; in decode_pointer_field()
568 return func(stream, iter->pos, iter->pData); in decode_pointer_field()
572 if (!allocate_field(stream, iter->pData, iter->pos->data_size, 1)) in decode_pointer_field()
575 initialize_pointer_field(*(void**)iter->pData, iter); in decode_pointer_field()
576 return func(stream, iter->pos, *(void**)iter->pData); in decode_pointer_field()
585 pb_size_t *size = (pb_size_t*)iter->pSize; in decode_pointer_field()
600 allocated_size += (substream.bytes_left - 1) / iter->pos->data_size + 1; in decode_pointer_field()
602 … if (!allocate_field(&substream, iter->pData, iter->pos->data_size, allocated_size)) in decode_pointer_field()
610 pItem = *(char**)iter->pData + iter->pos->data_size * (*size); in decode_pointer_field()
611 initialize_pointer_field(pItem, iter); in decode_pointer_field()
612 if (!func(&substream, iter->pos, pItem)) in decode_pointer_field()
637 pb_size_t *size = (pb_size_t*)iter->pSize; in decode_pointer_field()
644 if (!allocate_field(stream, iter->pData, iter->pos->data_size, *size)) in decode_pointer_field()
647 pItem = *(char**)iter->pData + iter->pos->data_size * (*size - 1); in decode_pointer_field()
648 initialize_pointer_field(pItem, iter); in decode_pointer_field()
649 return func(stream, iter->pos, pItem); in decode_pointer_field()
658 …return decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) in decode_callback_field() argument
660 pb_callback_t *pCallback = (pb_callback_t*)iter->pData; in decode_callback_field()
680 if (!pCallback->funcs.decode(&substream, iter->pos, arg)) in decode_callback_field()
703 return pCallback->funcs.decode(&substream, iter->pos, arg); in decode_callback_field()
707 …ool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) in decode_field() argument
712 if (PB_HTYPE(iter->pos->type) == PB_HTYPE_ONEOF) in decode_field()
714 if (!pb_release_union_field(stream, iter)) in decode_field()
719 switch (PB_ATYPE(iter->pos->type)) in decode_field()
722 return decode_static_field(stream, wire_type, iter); in decode_field()
725 return decode_pointer_field(stream, wire_type, iter); in decode_field()
728 return decode_callback_field(stream, wire_type, iter); in decode_field()
735 static void iter_from_extension(pb_field_iter_t *iter, pb_extension_t *extension) in iter_from_extension() argument
741 (void)pb_field_iter_begin(iter, field, extension->dest); in iter_from_extension()
742 iter->pData = extension->dest; in iter_from_extension()
743 iter->pSize = &extension->found; in iter_from_extension()
750 iter->pData = &extension->dest; in iter_from_extension()
760 pb_field_iter_t iter; in default_extension_decoder() local
765 iter_from_extension(&iter, extension); in default_extension_decoder()
767 return decode_field(stream, wire_type, &iter); in default_extension_decoder()
773 uint32_t tag, pb_wire_type_t wire_type, pb_field_iter_t *iter) in decode_extension() argument
775 pb_extension_t *extension = *(pb_extension_t* const *)iter->pData; in decode_extension()
798 static bool checkreturn find_extension_field(pb_field_iter_t *iter) in find_extension_field() argument
800 const pb_field_t *start = iter->pos; in find_extension_field()
803 if (PB_LTYPE(iter->pos->type) == PB_LTYPE_EXTENSION) in find_extension_field()
805 (void)pb_field_iter_next(iter); in find_extension_field()
806 } while (iter->pos != start); in find_extension_field()
812 static void pb_field_set_to_default(pb_field_iter_t *iter) in pb_field_set_to_default() argument
815 type = iter->pos->type; in pb_field_set_to_default()
819 pb_extension_t *ext = *(pb_extension_t* const *)iter->pData; in pb_field_set_to_default()
832 if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && iter->pSize != iter->pData) in pb_field_set_to_default()
836 *(bool*)iter->pSize = false; in pb_field_set_to_default()
843 *(pb_size_t*)iter->pSize = 0; in pb_field_set_to_default()
849 if (PB_LTYPE(iter->pos->type) == PB_LTYPE_SUBMESSAGE) in pb_field_set_to_default()
852 pb_message_set_to_defaults((const pb_field_t *) iter->pos->ptr, iter->pData); in pb_field_set_to_default()
854 else if (iter->pos->ptr != NULL) in pb_field_set_to_default()
857 memcpy(iter->pData, iter->pos->ptr, iter->pos->data_size); in pb_field_set_to_default()
862 memset(iter->pData, 0, iter->pos->data_size); in pb_field_set_to_default()
869 *(void**)iter->pData = NULL; in pb_field_set_to_default()
875 *(pb_size_t*)iter->pSize = 0; in pb_field_set_to_default()
886 pb_field_iter_t iter; in pb_message_set_to_defaults() local
888 if (!pb_field_iter_begin(&iter, fields, dest_struct)) in pb_message_set_to_defaults()
893 pb_field_set_to_default(&iter); in pb_message_set_to_defaults()
894 } while (pb_field_iter_next(&iter)); in pb_message_set_to_defaults()
906 pb_field_iter_t iter; in pb_decode_noinit() local
917 (void)pb_field_iter_begin(&iter, fields, dest_struct); in pb_decode_noinit()
933 if (!pb_field_iter_find(&iter, tag)) in pb_decode_noinit()
938 if (!find_extension_field(&iter)) in pb_decode_noinit()
941 extension_range_start = iter.pos->tag; in pb_decode_noinit()
947 if (!decode_extension(stream, tag, wire_type, &iter)) in pb_decode_noinit()
967 if (PB_HTYPE(iter.pos->type) == PB_HTYPE_REPEATED in pb_decode_noinit()
968 && iter.pSize == iter.pData) in pb_decode_noinit()
970 if (fixed_count_field != iter.pos) { in pb_decode_noinit()
981 fixed_count_field = iter.pos; in pb_decode_noinit()
985 iter.pSize = &fixed_count_size; in pb_decode_noinit()
988 if (PB_HTYPE(iter.pos->type) == PB_HTYPE_REQUIRED in pb_decode_noinit()
989 && iter.required_field_index < PB_MAX_REQUIRED_FIELDS) in pb_decode_noinit()
991 uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31)); in pb_decode_noinit()
992 fields_seen[iter.required_field_index >> 5] |= tmp; in pb_decode_noinit()
995 if (!decode_field(stream, wire_type, &iter)) in pb_decode_noinit()
1016 req_field_count = iter.required_field_index; in pb_decode_noinit()
1017 last_type = iter.pos->type; in pb_decode_noinit()
1018 } while (pb_field_iter_next(&iter)); in pb_decode_noinit()
1021 if (PB_HTYPE(last_type) == PB_HTYPE_REQUIRED && iter.pos->tag != 0) in pb_decode_noinit()
1104 static bool pb_release_union_field(pb_istream_t *stream, pb_field_iter_t *iter) in pb_release_union_field() argument
1106 pb_size_t old_tag = *(pb_size_t*)iter->pSize; /* Previous which_ value */ in pb_release_union_field()
1107 pb_size_t new_tag = iter->pos->tag; /* New which_ value */ in pb_release_union_field()
1117 if (!pb_field_iter_find(iter, old_tag)) in pb_release_union_field()
1120 pb_release_single_field(iter); in pb_release_union_field()
1124 if (!pb_field_iter_find(iter, new_tag)) in pb_release_union_field()
1130 static void pb_release_single_field(const pb_field_iter_t *iter) in pb_release_single_field() argument
1133 type = iter->pos->type; in pb_release_single_field()
1137 if (*(pb_size_t*)iter->pSize != iter->pos->tag) in pb_release_single_field()
1147 pb_extension_t *ext = *(pb_extension_t**)iter->pData; in pb_release_single_field()
1159 void *pItem = iter->pData; in pb_release_single_field()
1164 pItem = *(void**)iter->pData; in pb_release_single_field()
1169 if (PB_ATYPE(type) == PB_ATYPE_STATIC && iter->pSize == iter->pData) { in pb_release_single_field()
1171 count = iter->pos->array_size; in pb_release_single_field()
1173 count = *(pb_size_t*)iter->pSize; in pb_release_single_field()
1176 if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > iter->pos->array_size) in pb_release_single_field()
1179 count = iter->pos->array_size; in pb_release_single_field()
1187 pb_release((const pb_field_t*)iter->pos->ptr, pItem); in pb_release_single_field()
1188 pItem = (char*)pItem + iter->pos->data_size; in pb_release_single_field()
1200 void **pItem = *(void***)iter->pData; in pb_release_single_field()
1201 pb_size_t count = *(pb_size_t*)iter->pSize; in pb_release_single_field()
1212 *(pb_size_t*)iter->pSize = 0; in pb_release_single_field()
1216 pb_free(*(void**)iter->pData); in pb_release_single_field()
1217 *(void**)iter->pData = NULL; in pb_release_single_field()
1223 pb_field_iter_t iter; in pb_release() local
1228 if (!pb_field_iter_begin(&iter, fields, dest_struct)) in pb_release()
1233 pb_release_single_field(&iter); in pb_release()
1234 } while (pb_field_iter_next(&iter)); in pb_release()