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);
127 static bool checkreturn encode_array(pb_ostream_t *stream, pb_field_iter_t *field) in encode_array() argument
135 count = *(pb_size_t*)field->pSize; in encode_array()
140 if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size) in encode_array()
145 if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE) in encode_array()
147 if (!pb_encode_tag(stream, PB_WT_STRING, field->tag)) in encode_array()
151 if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32) in encode_array()
155 else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64) in encode_array()
162 void *pData_orig = field->pData; in encode_array()
165 if (!pb_enc_varint(&sizestream, field)) in encode_array()
167 field->pData = (char*)field->pData + field->data_size; in encode_array()
169 field->pData = pData_orig; in encode_array()
182 … if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64) in encode_array()
184 if (!pb_enc_fixed(stream, field)) in encode_array()
189 if (!pb_enc_varint(stream, field)) in encode_array()
193 field->pData = (char*)field->pData + field->data_size; in encode_array()
205 if (PB_ATYPE(field->type) == PB_ATYPE_POINTER && in encode_array()
206 (PB_LTYPE(field->type) == PB_LTYPE_STRING || in encode_array()
207 PB_LTYPE(field->type) == PB_LTYPE_BYTES)) in encode_array()
210 void *pData_orig = field->pData; in encode_array()
211 field->pData = *(void* const*)field->pData; in encode_array()
213 if (!field->pData) in encode_array()
216 status = pb_encode_tag_for_field(stream, field) && in encode_array()
221 status = encode_basic_field(stream, field); in encode_array()
224 field->pData = pData_orig; in encode_array()
231 if (!encode_basic_field(stream, field)) in encode_array()
234 field->pData = (char*)field->pData + field->data_size; in encode_array()
243 static bool checkreturn pb_check_proto3_default_value(const pb_field_iter_t *field) in pb_check_proto3_default_value() argument
245 pb_type_t type = field->type; in pb_check_proto3_default_value()
257 return *(const pb_size_t*)field->pSize == 0; in pb_check_proto3_default_value()
262 return *(const pb_size_t*)field->pSize == 0; in pb_check_proto3_default_value()
264 else if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL) in pb_check_proto3_default_value()
268 return safe_read_bool(field->pSize) == false; in pb_check_proto3_default_value()
270 else if (field->descriptor->default_value) in pb_check_proto3_default_value()
285 const char *p = (const char*)field->pData; in pb_check_proto3_default_value()
286 for (i = 0; i < field->data_size; i++) in pb_check_proto3_default_value()
298 const pb_bytes_array_t *bytes = (const pb_bytes_array_t*)field->pData; in pb_check_proto3_default_value()
303 return *(const char*)field->pData == '\0'; in pb_check_proto3_default_value()
310 return field->data_size == 0; in pb_check_proto3_default_value()
321 if (pb_field_iter_begin(&iter, field->submsg_desc, field->pData)) in pb_check_proto3_default_value()
336 return field->pData == NULL; in pb_check_proto3_default_value()
342 const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData; in pb_check_proto3_default_value()
345 else if (field->descriptor->field_callback == pb_default_field_callback) in pb_check_proto3_default_value()
347 pb_callback_t *pCallback = (pb_callback_t*)field->pData; in pb_check_proto3_default_value()
352 return field->descriptor->field_callback == NULL; in pb_check_proto3_default_value()
361 static bool checkreturn encode_basic_field(pb_ostream_t *stream, const pb_field_iter_t *field) in encode_basic_field() argument
363 if (!field->pData) in encode_basic_field()
369 if (!pb_encode_tag_for_field(stream, field)) in encode_basic_field()
372 switch (PB_LTYPE(field->type)) in encode_basic_field()
375 return pb_enc_bool(stream, field); in encode_basic_field()
380 return pb_enc_varint(stream, field); in encode_basic_field()
384 return pb_enc_fixed(stream, field); in encode_basic_field()
387 return pb_enc_bytes(stream, field); in encode_basic_field()
390 return pb_enc_string(stream, field); in encode_basic_field()
394 return pb_enc_submessage(stream, field); in encode_basic_field()
397 return pb_enc_fixed_length_bytes(stream, field); in encode_basic_field()
406 static bool checkreturn encode_callback_field(pb_ostream_t *stream, const pb_field_iter_t *field) in encode_callback_field() argument
408 if (field->descriptor->field_callback != NULL) in encode_callback_field()
410 if (!field->descriptor->field_callback(NULL, stream, field)) in encode_callback_field()
417 static bool checkreturn encode_field(pb_ostream_t *stream, pb_field_iter_t *field) in encode_field() argument
420 if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF) in encode_field()
422 if (*(const pb_size_t*)field->pSize != field->tag) in encode_field()
428 else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL) in encode_field()
430 if (field->pSize) in encode_field()
432 if (safe_read_bool(field->pSize) == false) in encode_field()
438 else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC) in encode_field()
441 if (pb_check_proto3_default_value(field)) in encode_field()
446 if (!field->pData) in encode_field()
448 if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED) in encode_field()
456 if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK) in encode_field()
458 return encode_callback_field(stream, field); in encode_field()
460 else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED) in encode_field()
462 return encode_array(stream, field); in encode_field()
466 return encode_basic_field(stream, field); in encode_field()
486 static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_iter_t *field) in encode_extension_field() argument
488 const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData; in encode_extension_field()
680 bool pb_encode_tag_for_field ( pb_ostream_t* stream, const pb_field_iter_t* field ) in pb_encode_tag_for_field() argument
683 switch (PB_LTYPE(field->type)) in pb_encode_tag_for_field()
712 return pb_encode_tag(stream, wiretype, field->tag); in pb_encode_tag_for_field()
775 static bool checkreturn pb_enc_bool(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_bool() argument
777 uint32_t value = safe_read_bool(field->pData) ? 1 : 0; in pb_enc_bool()
778 PB_UNUSED(field); in pb_enc_bool()
782 static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_varint() argument
784 if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT) in pb_enc_varint()
789 if (field->data_size == sizeof(uint_least8_t)) in pb_enc_varint()
790 value = *(const uint_least8_t*)field->pData; in pb_enc_varint()
791 else if (field->data_size == sizeof(uint_least16_t)) in pb_enc_varint()
792 value = *(const uint_least16_t*)field->pData; in pb_enc_varint()
793 else if (field->data_size == sizeof(uint32_t)) in pb_enc_varint()
794 value = *(const uint32_t*)field->pData; in pb_enc_varint()
795 else if (field->data_size == sizeof(pb_uint64_t)) in pb_enc_varint()
796 value = *(const pb_uint64_t*)field->pData; in pb_enc_varint()
807 if (field->data_size == sizeof(int_least8_t)) in pb_enc_varint()
808 value = *(const int_least8_t*)field->pData; in pb_enc_varint()
809 else if (field->data_size == sizeof(int_least16_t)) in pb_enc_varint()
810 value = *(const int_least16_t*)field->pData; in pb_enc_varint()
811 else if (field->data_size == sizeof(int32_t)) in pb_enc_varint()
812 value = *(const int32_t*)field->pData; in pb_enc_varint()
813 else if (field->data_size == sizeof(pb_int64_t)) in pb_enc_varint()
814 value = *(const pb_int64_t*)field->pData; in pb_enc_varint()
818 if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT) in pb_enc_varint()
830 static bool checkreturn pb_enc_fixed(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_fixed() argument
833 if (field->data_size == sizeof(float) && PB_LTYPE(field->type) == PB_LTYPE_FIXED64) in pb_enc_fixed()
835 return pb_encode_float_as_double(stream, *(float*)field->pData); in pb_enc_fixed()
839 if (field->data_size == sizeof(uint32_t)) in pb_enc_fixed()
841 return pb_encode_fixed32(stream, field->pData); in pb_enc_fixed()
844 else if (field->data_size == sizeof(uint64_t)) in pb_enc_fixed()
846 return pb_encode_fixed64(stream, field->pData); in pb_enc_fixed()
855 static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_bytes() argument
859 bytes = (const pb_bytes_array_t*)field->pData; in pb_enc_bytes()
867 if (PB_ATYPE(field->type) == PB_ATYPE_STATIC && in pb_enc_bytes()
868 bytes->size > field->data_size - offsetof(pb_bytes_array_t, bytes)) in pb_enc_bytes()
876 static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_string() argument
879 size_t max_size = (size_t)field->data_size; in pb_enc_string()
880 const char *str = (const char*)field->pData; in pb_enc_string()
882 if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) in pb_enc_string()
929 static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_iter_t *field) in pb_enc_submessage() argument
931 if (field->submsg_desc == NULL) in pb_enc_submessage()
934 if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) in pb_enc_submessage()
937 pb_callback_t *callback = (pb_callback_t*)field->pSize - 1; in pb_enc_submessage()
940 if (!callback->funcs.encode(stream, field, &callback->arg)) in pb_enc_submessage()
945 return pb_encode_submessage(stream, field->submsg_desc, field->pData); in pb_enc_submessage()
948 …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
950 return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size); in pb_enc_fixed_length_bytes()