Lines Matching refs:field

24 static bool checkreturn encode_array(pb_ostream_t *stream, pb_field_iter_t *field);
25 static bool checkreturn pb_check_proto3_default_value(const pb_field_iter_t *field);
26 static bool checkreturn encode_basic_field(pb_ostream_t *stream, const pb_field_iter_t *field);
27 static bool checkreturn encode_callback_field(pb_ostream_t *stream, const pb_field_iter_t *field);
28 static bool checkreturn encode_field(pb_ostream_t *stream, pb_field_iter_t *field);
29 static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_iter_t *field);
32 static bool checkreturn pb_enc_bool(pb_ostream_t *stream, const pb_field_iter_t *field);
33 static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_iter_t *field);
34 static bool checkreturn pb_enc_fixed(pb_ostream_t *stream, const pb_field_iter_t *field);
35 static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_iter_t *field);
36 static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_iter_t *field);
37 static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_iter_t *field);
38 …tic bool checkreturn pb_enc_fixed_length_bytes(pb_ostream_t *stream, const pb_field_iter_t *field);
125 static bool checkreturn encode_array(pb_ostream_t *stream, pb_field_iter_t *field) in encode_array() argument
133 count = *(pb_size_t*)field->pSize; in encode_array()
138 if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size) in encode_array()
143 if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE) in encode_array()
145 if (!pb_encode_tag(stream, PB_WT_STRING, field->tag)) in encode_array()
149 if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32) in encode_array()
153 else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64) in encode_array()
160 void *pData_orig = field->pData; in encode_array()
163 if (!pb_enc_varint(&sizestream, field)) in encode_array()
165 field->pData = (char*)field->pData + field->data_size; in encode_array()
167 field->pData = pData_orig; in encode_array()
180 … if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64) in encode_array()
182 if (!pb_enc_fixed(stream, field)) in encode_array()
187 if (!pb_enc_varint(stream, field)) in encode_array()
191 field->pData = (char*)field->pData + field->data_size; in encode_array()
203 if (PB_ATYPE(field->type) == PB_ATYPE_POINTER && in encode_array()
204 (PB_LTYPE(field->type) == PB_LTYPE_STRING || in encode_array()
205 PB_LTYPE(field->type) == PB_LTYPE_BYTES)) in encode_array()
208 void *pData_orig = field->pData; in encode_array()
209 field->pData = *(void* const*)field->pData; in encode_array()
211 if (!field->pData) in encode_array()
214 status = pb_encode_tag_for_field(stream, field) && in encode_array()
219 status = encode_basic_field(stream, field); in encode_array()
222 field->pData = pData_orig; in encode_array()
229 if (!encode_basic_field(stream, field)) in encode_array()
232 field->pData = (char*)field->pData + field->data_size; in encode_array()
241 static bool checkreturn pb_check_proto3_default_value(const pb_field_iter_t *field) in pb_check_proto3_default_value() argument
243 pb_type_t type = field->type; in pb_check_proto3_default_value()
255 return *(const pb_size_t*)field->pSize == 0; in pb_check_proto3_default_value()
260 return *(const pb_size_t*)field->pSize == 0; in pb_check_proto3_default_value()
262 else if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL) in pb_check_proto3_default_value()
266 return safe_read_bool(field->pSize) == false; in pb_check_proto3_default_value()
268 else if (field->descriptor->default_value) in pb_check_proto3_default_value()
283 const char *p = (const char*)field->pData; in pb_check_proto3_default_value()
284 for (i = 0; i < field->data_size; i++) in pb_check_proto3_default_value()
296 const pb_bytes_array_t *bytes = (const pb_bytes_array_t*)field->pData; in pb_check_proto3_default_value()
301 return *(const char*)field->pData == '\0'; in pb_check_proto3_default_value()
308 return field->data_size == 0; in pb_check_proto3_default_value()
319 if (pb_field_iter_begin(&iter, field->submsg_desc, field->pData)) in pb_check_proto3_default_value()
334 return field->pData == NULL; in pb_check_proto3_default_value()
340 const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData; in pb_check_proto3_default_value()
343 else if (field->descriptor->field_callback == pb_default_field_callback) in pb_check_proto3_default_value()
345 pb_callback_t *pCallback = (pb_callback_t*)field->pData; in pb_check_proto3_default_value()
350 return field->descriptor->field_callback == NULL; in pb_check_proto3_default_value()
359 static bool checkreturn encode_basic_field(pb_ostream_t *stream, const pb_field_iter_t *field) in encode_basic_field() argument
361 if (!field->pData) in encode_basic_field()
367 if (!pb_encode_tag_for_field(stream, field)) in encode_basic_field()
370 switch (PB_LTYPE(field->type)) in encode_basic_field()
373 return pb_enc_bool(stream, field); in encode_basic_field()
378 return pb_enc_varint(stream, field); in encode_basic_field()
382 return pb_enc_fixed(stream, field); in encode_basic_field()
385 return pb_enc_bytes(stream, field); in encode_basic_field()
388 return pb_enc_string(stream, field); in encode_basic_field()
392 return pb_enc_submessage(stream, field); in encode_basic_field()
395 return pb_enc_fixed_length_bytes(stream, field); in encode_basic_field()
404 static bool checkreturn encode_callback_field(pb_ostream_t *stream, const pb_field_iter_t *field) in encode_callback_field() argument
406 if (field->descriptor->field_callback != NULL) in encode_callback_field()
408 if (!field->descriptor->field_callback(NULL, stream, field)) in encode_callback_field()
415 static bool checkreturn encode_field(pb_ostream_t *stream, pb_field_iter_t *field) in encode_field() argument
418 if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF) in encode_field()
420 if (*(const pb_size_t*)field->pSize != field->tag) in encode_field()
426 else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL) in encode_field()
428 if (field->pSize) in encode_field()
430 if (safe_read_bool(field->pSize) == false) in encode_field()
436 else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC) in encode_field()
439 if (pb_check_proto3_default_value(field)) in encode_field()
444 if (!field->pData) in encode_field()
446 if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED) in encode_field()
454 if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK) in encode_field()
456 return encode_callback_field(stream, field); in encode_field()
458 else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED) in encode_field()
460 return encode_array(stream, field); in encode_field()
464 return encode_basic_field(stream, field); in encode_field()
484 static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_iter_t *field) in encode_extension_field() argument
486 const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData; in encode_extension_field()
667 bool pb_encode_tag_for_field ( pb_ostream_t* stream, const pb_field_iter_t* field ) in pb_encode_tag_for_field() argument
670 switch (PB_LTYPE(field->type)) in pb_encode_tag_for_field()
699 return pb_encode_tag(stream, wiretype, field->tag); in pb_encode_tag_for_field()
762 static bool checkreturn pb_enc_bool(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_bool() argument
764 uint32_t value = safe_read_bool(field->pData) ? 1 : 0; in pb_enc_bool()
765 PB_UNUSED(field); in pb_enc_bool()
769 static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_varint() argument
771 if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT) in pb_enc_varint()
776 if (field->data_size == sizeof(uint_least8_t)) in pb_enc_varint()
777 value = *(const uint_least8_t*)field->pData; in pb_enc_varint()
778 else if (field->data_size == sizeof(uint_least16_t)) in pb_enc_varint()
779 value = *(const uint_least16_t*)field->pData; in pb_enc_varint()
780 else if (field->data_size == sizeof(uint32_t)) in pb_enc_varint()
781 value = *(const uint32_t*)field->pData; in pb_enc_varint()
782 else if (field->data_size == sizeof(pb_uint64_t)) in pb_enc_varint()
783 value = *(const pb_uint64_t*)field->pData; in pb_enc_varint()
794 if (field->data_size == sizeof(int_least8_t)) in pb_enc_varint()
795 value = *(const int_least8_t*)field->pData; in pb_enc_varint()
796 else if (field->data_size == sizeof(int_least16_t)) in pb_enc_varint()
797 value = *(const int_least16_t*)field->pData; in pb_enc_varint()
798 else if (field->data_size == sizeof(int32_t)) in pb_enc_varint()
799 value = *(const int32_t*)field->pData; in pb_enc_varint()
800 else if (field->data_size == sizeof(pb_int64_t)) in pb_enc_varint()
801 value = *(const pb_int64_t*)field->pData; in pb_enc_varint()
805 if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT) in pb_enc_varint()
817 static bool checkreturn pb_enc_fixed(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_fixed() argument
820 if (field->data_size == sizeof(float) && PB_LTYPE(field->type) == PB_LTYPE_FIXED64) in pb_enc_fixed()
822 return pb_encode_float_as_double(stream, *(float*)field->pData); in pb_enc_fixed()
826 if (field->data_size == sizeof(uint32_t)) in pb_enc_fixed()
828 return pb_encode_fixed32(stream, field->pData); in pb_enc_fixed()
831 else if (field->data_size == sizeof(uint64_t)) in pb_enc_fixed()
833 return pb_encode_fixed64(stream, field->pData); in pb_enc_fixed()
842 static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_bytes() argument
846 bytes = (const pb_bytes_array_t*)field->pData; in pb_enc_bytes()
854 if (PB_ATYPE(field->type) == PB_ATYPE_STATIC && in pb_enc_bytes()
855 bytes->size > field->data_size - offsetof(pb_bytes_array_t, bytes)) in pb_enc_bytes()
863 static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_string() argument
866 size_t max_size = (size_t)field->data_size; in pb_enc_string()
867 const char *str = (const char*)field->pData; in pb_enc_string()
869 if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) in pb_enc_string()
916 static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_submessage() argument
918 if (field->submsg_desc == NULL) in pb_enc_submessage()
921 if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) in pb_enc_submessage()
924 pb_callback_t *callback = (pb_callback_t*)field->pSize - 1; in pb_enc_submessage()
927 if (!callback->funcs.encode(stream, field, &callback->arg)) in pb_enc_submessage()
932 return pb_encode_submessage(stream, field->submsg_desc, field->pData); in pb_enc_submessage()
935 …atic bool checkreturn pb_enc_fixed_length_bytes(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_fixed_length_bytes() argument
937 return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size); in pb_enc_fixed_length_bytes()