Lines Matching refs:iter

39 static void pb_field_init(pb_field_iterator_t *iter, const pb_field_t *fields, void *dest_struct);
40 static bool pb_field_next(pb_field_iterator_t *iter);
41 static bool checkreturn pb_field_find(pb_field_iterator_t *iter, uint32_t tag);
42 …urn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
43 …n decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
44 …heckreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
46 …extension(pb_istream_t *stream, uint32_t tag, pb_wire_type_t wire_type, pb_field_iterator_t *iter);
47 static bool checkreturn find_extension_field(pb_field_iterator_t *iter);
341 static void pb_field_init(pb_field_iterator_t *iter, const pb_field_t *fields, void *dest_struct) in pb_field_init() argument
343 iter->start = iter->pos = fields; in pb_field_init()
344 iter->field_index = 0; in pb_field_init()
345 iter->required_field_index = 0; in pb_field_init()
346 iter->pData = (char*)dest_struct + iter->pos->data_offset; in pb_field_init()
347 iter->pSize = (char*)iter->pData + iter->pos->size_offset; in pb_field_init()
348 iter->dest_struct = dest_struct; in pb_field_init()
351 static bool pb_field_next(pb_field_iterator_t *iter) in pb_field_next() argument
354 size_t prev_size = iter->pos->data_size; in pb_field_next()
356 if (PB_ATYPE(iter->pos->type) == PB_ATYPE_STATIC && in pb_field_next()
357 PB_HTYPE(iter->pos->type) == PB_HTYPE_REPEATED) in pb_field_next()
359 prev_size *= iter->pos->array_size; in pb_field_next()
361 else if (PB_ATYPE(iter->pos->type) == PB_ATYPE_POINTER) in pb_field_next()
366 if (iter->pos->tag == 0) in pb_field_next()
369 if (PB_HTYPE(iter->pos->type) == PB_HTYPE_REQUIRED) in pb_field_next()
370 iter->required_field_index++; in pb_field_next()
372 iter->pos++; in pb_field_next()
373 iter->field_index++; in pb_field_next()
374 if (iter->pos->tag == 0) in pb_field_next()
376 iter->pos = iter->start; in pb_field_next()
377 iter->field_index = 0; in pb_field_next()
378 iter->required_field_index = 0; in pb_field_next()
379 iter->pData = iter->dest_struct; in pb_field_next()
384 iter->pData = (char*)iter->pData + prev_size + iter->pos->data_offset; in pb_field_next()
385 iter->pSize = (char*)iter->pData + iter->pos->size_offset; in pb_field_next()
389 static bool checkreturn pb_field_find(pb_field_iterator_t *iter, uint32_t tag) in pb_field_find() argument
391 unsigned start = iter->field_index; in pb_field_find()
394 if (iter->pos->tag == tag && in pb_field_find()
395 PB_LTYPE(iter->pos->type) != PB_LTYPE_EXTENSION) in pb_field_find()
399 (void)pb_field_next(iter); in pb_field_find()
400 } while (iter->field_index != start); in pb_field_find()
409 …turn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter) in decode_static_field() argument
414 type = iter->pos->type; in decode_static_field()
420 return func(stream, iter->pos, iter->pData); in decode_static_field()
423 *(bool*)iter->pSize = true; in decode_static_field()
424 return func(stream, iter->pos, iter->pData); in decode_static_field()
432 size_t *size = (size_t*)iter->pSize; in decode_static_field()
437 while (substream.bytes_left > 0 && *size < iter->pos->array_size) in decode_static_field()
439 void *pItem = (uint8_t*)iter->pData + iter->pos->data_size * (*size); in decode_static_field()
440 if (!func(&substream, iter->pos, pItem)) in decode_static_field()
457 size_t *size = (size_t*)iter->pSize; in decode_static_field()
458 void *pItem = (uint8_t*)iter->pData + iter->pos->data_size * (*size); in decode_static_field()
459 if (*size >= iter->pos->array_size) in decode_static_field()
463 return func(stream, iter->pos, pItem); in decode_static_field()
491 static void initialize_pointer_field(void *pItem, pb_field_iterator_t *iter) in initialize_pointer_field() argument
493 if (PB_LTYPE(iter->pos->type) == PB_LTYPE_STRING || in initialize_pointer_field()
494 PB_LTYPE(iter->pos->type) == PB_LTYPE_BYTES) in initialize_pointer_field()
498 else if (PB_LTYPE(iter->pos->type) == PB_LTYPE_SUBMESSAGE) in initialize_pointer_field()
500 pb_message_set_to_defaults((const pb_field_t *) iter->pos->ptr, pItem); in initialize_pointer_field()
505 …urn decode_pointer_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter) in decode_pointer_field() argument
509 UNUSED(iter); in decode_pointer_field()
515 type = iter->pos->type; in decode_pointer_field()
525 return func(stream, iter->pos, iter->pData); in decode_pointer_field()
529 if (!allocate_field(stream, iter->pData, iter->pos->data_size, 1)) in decode_pointer_field()
532 initialize_pointer_field(*(void**)iter->pData, iter); in decode_pointer_field()
533 return func(stream, iter->pos, *(void**)iter->pData); in decode_pointer_field()
542 size_t *size = (size_t*)iter->pSize; in decode_pointer_field()
557 allocated_size += (substream.bytes_left - 1) / iter->pos->data_size + 1; in decode_pointer_field()
559 … if (!allocate_field(&substream, iter->pData, iter->pos->data_size, allocated_size)) in decode_pointer_field()
567 pItem = *(uint8_t**)iter->pData + iter->pos->data_size * (*size); in decode_pointer_field()
568 initialize_pointer_field(pItem, iter); in decode_pointer_field()
569 if (!func(&substream, iter->pos, pItem)) in decode_pointer_field()
583 size_t *size = (size_t*)iter->pSize; in decode_pointer_field()
587 if (!allocate_field(stream, iter->pData, iter->pos->data_size, *size)) in decode_pointer_field()
590 pItem = *(uint8_t**)iter->pData + iter->pos->data_size * (*size - 1); in decode_pointer_field()
591 initialize_pointer_field(pItem, iter); in decode_pointer_field()
592 return func(stream, iter->pos, pItem); in decode_pointer_field()
601 …rn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter) in decode_callback_field() argument
603 pb_callback_t *pCallback = (pb_callback_t*)iter->pData; in decode_callback_field()
623 if (!pCallback->funcs.decode(&substream, iter->pos, arg)) in decode_callback_field()
644 return pCallback->funcs.decode(&substream, iter->pos, arg); in decode_callback_field()
648 …checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter) in decode_field() argument
650 switch (PB_ATYPE(iter->pos->type)) in decode_field()
653 return decode_static_field(stream, wire_type, iter); in decode_field()
656 return decode_pointer_field(stream, wire_type, iter); in decode_field()
659 return decode_callback_field(stream, wire_type, iter); in decode_field()
672 pb_field_iterator_t iter; in default_extension_decoder() local
677 iter.start = field; in default_extension_decoder()
678 iter.pos = field; in default_extension_decoder()
679 iter.field_index = 0; in default_extension_decoder()
680 iter.required_field_index = 0; in default_extension_decoder()
681 iter.dest_struct = extension->dest; in default_extension_decoder()
682 iter.pData = extension->dest; in default_extension_decoder()
683 iter.pSize = &extension->found; in default_extension_decoder()
685 return decode_field(stream, wire_type, &iter); in default_extension_decoder()
691 uint32_t tag, pb_wire_type_t wire_type, pb_field_iterator_t *iter) in decode_extension() argument
693 pb_extension_t *extension = *(pb_extension_t* const *)iter->pData; in decode_extension()
716 static bool checkreturn find_extension_field(pb_field_iterator_t *iter) in find_extension_field() argument
718 unsigned start = iter->field_index; in find_extension_field()
721 if (PB_LTYPE(iter->pos->type) == PB_LTYPE_EXTENSION) in find_extension_field()
723 (void)pb_field_next(iter); in find_extension_field()
724 } while (iter->field_index != start); in find_extension_field()
732 pb_field_iterator_t iter; in pb_message_set_to_defaults() local
733 pb_field_init(&iter, fields, dest_struct); in pb_message_set_to_defaults()
738 type = iter.pos->type; in pb_message_set_to_defaults()
741 if (iter.pos->tag == 0) in pb_message_set_to_defaults()
750 *(bool*)iter.pSize = false; in pb_message_set_to_defaults()
755 *(size_t*)iter.pSize = 0; in pb_message_set_to_defaults()
759 if (PB_LTYPE(iter.pos->type) == PB_LTYPE_SUBMESSAGE) in pb_message_set_to_defaults()
762 pb_message_set_to_defaults((const pb_field_t *) iter.pos->ptr, iter.pData); in pb_message_set_to_defaults()
764 else if (iter.pos->ptr != NULL) in pb_message_set_to_defaults()
767 memcpy(iter.pData, iter.pos->ptr, iter.pos->data_size); in pb_message_set_to_defaults()
772 memset(iter.pData, 0, iter.pos->data_size); in pb_message_set_to_defaults()
778 *(void**)iter.pData = NULL; in pb_message_set_to_defaults()
783 *(size_t*)iter.pSize = 0; in pb_message_set_to_defaults()
790 } while (pb_field_next(&iter)); in pb_message_set_to_defaults()
801 pb_field_iterator_t iter; in pb_decode_noinit() local
803 pb_field_init(&iter, fields, dest_struct); in pb_decode_noinit()
819 if (!pb_field_find(&iter, tag)) in pb_decode_noinit()
824 if (!find_extension_field(&iter)) in pb_decode_noinit()
827 extension_range_start = iter.pos->tag; in pb_decode_noinit()
833 if (!decode_extension(stream, tag, wire_type, &iter)) in pb_decode_noinit()
850 if (PB_HTYPE(iter.pos->type) == PB_HTYPE_REQUIRED in pb_decode_noinit()
851 && iter.required_field_index < PB_MAX_REQUIRED_FIELDS) in pb_decode_noinit()
853 … fields_seen[iter.required_field_index >> 3] |= (uint8_t)(1 << (iter.required_field_index & 7)); in pb_decode_noinit()
856 if (!decode_field(stream, wire_type, &iter)) in pb_decode_noinit()
870 req_field_count = iter.required_field_index; in pb_decode_noinit()
871 last_type = iter.pos->type; in pb_decode_noinit()
872 } while (pb_field_next(&iter)); in pb_decode_noinit()
875 if (PB_HTYPE(last_type) == PB_HTYPE_REQUIRED && iter.pos->tag != 0) in pb_decode_noinit()
923 pb_field_iterator_t iter; in pb_release() local
924 pb_field_init(&iter, fields, dest_struct); in pb_release()
929 type = iter.pos->type; in pb_release()
932 if (iter.pos->tag == 0) in pb_release()
942 void **pItem = *(void***)iter.pData; in pb_release()
943 size_t count = *(size_t*)iter.pSize; in pb_release()
953 void *pItem = *(void**)iter.pData; in pb_release()
958 count = *(size_t*)iter.pSize; in pb_release()
963 pb_release((const pb_field_t*)iter.pos->ptr, pItem); in pb_release()
964 pItem = (uint8_t*)pItem + iter.pos->data_size; in pb_release()
969 pb_free(*(void**)iter.pData); in pb_release()
970 *(void**)iter.pData = NULL; in pb_release()
972 } while (pb_field_next(&iter)); in pb_release()