Rename PB_HTYPE_ARRAY -> PB_HTYPE_REPEATED.
This is a more logical name in parallel with PB_HTYPE_REQUIRED and PB_HTYPE_OPTIONAL. Warning: This breaks backwards-compatibility of generated .pb.c files. You will have to regenerate the files and recompile.
This commit is contained in:
4
pb.h
4
pb.h
@@ -97,7 +97,7 @@ typedef uint8_t pb_type_t;
|
|||||||
/* Read to pre-allocated array
|
/* Read to pre-allocated array
|
||||||
* Maximum number of entries is array_size,
|
* Maximum number of entries is array_size,
|
||||||
* actual number is stored at size_offset */
|
* actual number is stored at size_offset */
|
||||||
#define PB_HTYPE_ARRAY 0x20
|
#define PB_HTYPE_REPEATED 0x20
|
||||||
|
|
||||||
/* Works for all required/optional/repeated fields.
|
/* Works for all required/optional/repeated fields.
|
||||||
* data_offset points to pb_callback_t structure.
|
* data_offset points to pb_callback_t structure.
|
||||||
@@ -226,7 +226,7 @@ typedef enum {
|
|||||||
|
|
||||||
/* Repeated fields have a _count field and also the maximum number of entries. */
|
/* Repeated fields have a _count field and also the maximum number of entries. */
|
||||||
#define PB_REPEATED_STATIC(tag, st, m, pm, ltype, ptr) \
|
#define PB_REPEATED_STATIC(tag, st, m, pm, ltype, ptr) \
|
||||||
{tag, PB_HTYPE_ARRAY | ltype, \
|
{tag, PB_HTYPE_REPEATED | ltype, \
|
||||||
pb_delta_end(st, m, pm), \
|
pb_delta_end(st, m, pm), \
|
||||||
pb_delta(st, m ## _count, m), \
|
pb_delta(st, m ## _count, m), \
|
||||||
pb_membersize(st, m[0]), \
|
pb_membersize(st, m[0]), \
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ static bool pb_field_next(pb_field_iterator_t *iter)
|
|||||||
bool notwrapped = true;
|
bool notwrapped = true;
|
||||||
size_t prev_size = iter->current->data_size;
|
size_t prev_size = iter->current->data_size;
|
||||||
|
|
||||||
if (PB_HTYPE(iter->current->type) == PB_HTYPE_ARRAY)
|
if (PB_HTYPE(iter->current->type) == PB_HTYPE_REPEATED)
|
||||||
prev_size *= iter->current->array_size;
|
prev_size *= iter->current->array_size;
|
||||||
|
|
||||||
if (PB_HTYPE(iter->current->type) == PB_HTYPE_REQUIRED)
|
if (PB_HTYPE(iter->current->type) == PB_HTYPE_REQUIRED)
|
||||||
@@ -356,7 +356,7 @@ static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_t
|
|||||||
*(bool*)iter->pSize = true;
|
*(bool*)iter->pSize = true;
|
||||||
return func(stream, iter->current, iter->pData);
|
return func(stream, iter->current, iter->pData);
|
||||||
|
|
||||||
case PB_HTYPE_ARRAY:
|
case PB_HTYPE_REPEATED:
|
||||||
if (wire_type == PB_WT_STRING
|
if (wire_type == PB_WT_STRING
|
||||||
&& PB_LTYPE(iter->current->type) <= PB_LTYPE_LAST_PACKABLE)
|
&& PB_LTYPE(iter->current->type) <= PB_LTYPE_LAST_PACKABLE)
|
||||||
{
|
{
|
||||||
@@ -459,7 +459,7 @@ static void pb_message_set_to_defaults(const pb_field_t fields[], void *dest_str
|
|||||||
{
|
{
|
||||||
*(bool*)iter.pSize = false;
|
*(bool*)iter.pSize = false;
|
||||||
}
|
}
|
||||||
else if (PB_HTYPE(iter.current->type) == PB_HTYPE_ARRAY)
|
else if (PB_HTYPE(iter.current->type) == PB_HTYPE_REPEATED)
|
||||||
{
|
{
|
||||||
*(size_t*)iter.pSize = 0;
|
*(size_t*)iter.pSize = 0;
|
||||||
continue; /* Array is empty, no need to initialize contents */
|
continue; /* Array is empty, no need to initialize contents */
|
||||||
@@ -715,7 +715,7 @@ bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field
|
|||||||
|
|
||||||
/* New array entries need to be initialized, while required and optional
|
/* New array entries need to be initialized, while required and optional
|
||||||
* submessages have already been initialized in the top-level pb_decode. */
|
* submessages have already been initialized in the top-level pb_decode. */
|
||||||
if (PB_HTYPE(field->type) == PB_HTYPE_ARRAY)
|
if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
|
||||||
status = pb_decode(&substream, submsg_fields, dest);
|
status = pb_decode(&substream, submsg_fields, dest);
|
||||||
else
|
else
|
||||||
status = pb_decode_noinit(&substream, submsg_fields, dest);
|
status = pb_decode_noinit(&substream, submsg_fields, dest);
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ bool checkreturn pb_encode(pb_ostream_t *stream, const pb_field_t fields[], cons
|
|||||||
pSize = (const char*)pData + field->size_offset;
|
pSize = (const char*)pData + field->size_offset;
|
||||||
|
|
||||||
prev_size = field->data_size;
|
prev_size = field->data_size;
|
||||||
if (PB_HTYPE(field->type) == PB_HTYPE_ARRAY)
|
if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
|
||||||
prev_size *= field->array_size;
|
prev_size *= field->array_size;
|
||||||
|
|
||||||
switch (PB_HTYPE(field->type))
|
switch (PB_HTYPE(field->type))
|
||||||
@@ -190,7 +190,7 @@ bool checkreturn pb_encode(pb_ostream_t *stream, const pb_field_t fields[], cons
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PB_HTYPE_ARRAY:
|
case PB_HTYPE_REPEATED:
|
||||||
if (!encode_array(stream, field, pData, *(const size_t*)pSize, func))
|
if (!encode_array(stream, field, pData, *(const size_t*)pSize, func))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
/* Automatically generated nanopb constant definitions */
|
/* Automatically generated nanopb constant definitions */
|
||||||
#include "bc_alltypes.pb.h"
|
/* Generated by 0.2.0-dev at Sun Feb 17 00:09:53 2013. */
|
||||||
|
/* This is a file generated using nanopb-0.2.0-dev.
|
||||||
|
* It is used as a part of test suite in order to detect any
|
||||||
|
* incompatible changes made to the generator in future versions.
|
||||||
|
*/
|
||||||
|
|
||||||
const char SubMessage_substuff1_default[17] = "1";
|
#include "alltypes.pb.h"
|
||||||
|
|
||||||
|
const char SubMessage_substuff1_default[16] = "1";
|
||||||
const int32_t SubMessage_substuff2_default = 2;
|
const int32_t SubMessage_substuff2_default = 2;
|
||||||
const uint32_t SubMessage_substuff3_default = 3;
|
const uint32_t SubMessage_substuff3_default = 3;
|
||||||
const int32_t AllTypes_opt_int32_default = 4041;
|
const int32_t AllTypes_opt_int32_default = 4041;
|
||||||
@@ -17,310 +23,71 @@ const float AllTypes_opt_float_default = 4050;
|
|||||||
const uint64_t AllTypes_opt_fixed64_default = 4051;
|
const uint64_t AllTypes_opt_fixed64_default = 4051;
|
||||||
const int64_t AllTypes_opt_sfixed64_default = 4052;
|
const int64_t AllTypes_opt_sfixed64_default = 4052;
|
||||||
const double AllTypes_opt_double_default = 4053;
|
const double AllTypes_opt_double_default = 4053;
|
||||||
const char AllTypes_opt_string_default[17] = "4054";
|
const char AllTypes_opt_string_default[16] = "4054";
|
||||||
const AllTypes_opt_bytes_t AllTypes_opt_bytes_default = {4, {0x34,0x30,0x35,0x35}};
|
const AllTypes_opt_bytes_t AllTypes_opt_bytes_default = {4, {0x34,0x30,0x35,0x35}};
|
||||||
const MyEnum AllTypes_opt_enum_default = MyEnum_Second;
|
const MyEnum AllTypes_opt_enum_default = MyEnum_Second;
|
||||||
|
|
||||||
|
|
||||||
const pb_field_t SubMessage_fields[4] = {
|
const pb_field_t SubMessage_fields[4] = {
|
||||||
{1, PB_HTYPE_REQUIRED | PB_LTYPE_STRING,
|
PB_FIELD( 1, STRING , REQUIRED, STATIC, SubMessage, substuff1, substuff1, &SubMessage_substuff1_default),
|
||||||
offsetof(SubMessage, substuff1), 0,
|
PB_FIELD( 2, INT32 , REQUIRED, STATIC, SubMessage, substuff2, substuff1, &SubMessage_substuff2_default),
|
||||||
pb_membersize(SubMessage, substuff1), 0,
|
PB_FIELD( 3, FIXED32 , OPTIONAL, STATIC, SubMessage, substuff3, substuff2, &SubMessage_substuff3_default),
|
||||||
&SubMessage_substuff1_default},
|
|
||||||
|
|
||||||
{2, PB_HTYPE_REQUIRED | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(SubMessage, substuff2, substuff1), 0,
|
|
||||||
pb_membersize(SubMessage, substuff2), 0,
|
|
||||||
&SubMessage_substuff2_default},
|
|
||||||
|
|
||||||
{3, PB_HTYPE_OPTIONAL | PB_LTYPE_FIXED32,
|
|
||||||
pb_delta_end(SubMessage, substuff3, substuff2),
|
|
||||||
pb_delta(SubMessage, has_substuff3, substuff3),
|
|
||||||
pb_membersize(SubMessage, substuff3), 0,
|
|
||||||
&SubMessage_substuff3_default},
|
|
||||||
|
|
||||||
PB_LAST_FIELD
|
PB_LAST_FIELD
|
||||||
};
|
};
|
||||||
|
|
||||||
const pb_field_t AllTypes_fields[53] = {
|
const pb_field_t AllTypes_fields[53] = {
|
||||||
{1, PB_HTYPE_REQUIRED | PB_LTYPE_VARINT,
|
PB_FIELD( 1, INT32 , REQUIRED, STATIC, AllTypes, req_int32, req_int32, 0),
|
||||||
offsetof(AllTypes, req_int32), 0,
|
PB_FIELD( 2, INT64 , REQUIRED, STATIC, AllTypes, req_int64, req_int32, 0),
|
||||||
pb_membersize(AllTypes, req_int32), 0, 0},
|
PB_FIELD( 3, UINT32 , REQUIRED, STATIC, AllTypes, req_uint32, req_int64, 0),
|
||||||
|
PB_FIELD( 4, UINT64 , REQUIRED, STATIC, AllTypes, req_uint64, req_uint32, 0),
|
||||||
{2, PB_HTYPE_REQUIRED | PB_LTYPE_VARINT,
|
PB_FIELD( 5, SINT32 , REQUIRED, STATIC, AllTypes, req_sint32, req_uint64, 0),
|
||||||
pb_delta_end(AllTypes, req_int64, req_int32), 0,
|
PB_FIELD( 6, SINT64 , REQUIRED, STATIC, AllTypes, req_sint64, req_sint32, 0),
|
||||||
pb_membersize(AllTypes, req_int64), 0, 0},
|
PB_FIELD( 7, BOOL , REQUIRED, STATIC, AllTypes, req_bool, req_sint64, 0),
|
||||||
|
PB_FIELD( 8, FIXED32 , REQUIRED, STATIC, AllTypes, req_fixed32, req_bool, 0),
|
||||||
{3, PB_HTYPE_REQUIRED | PB_LTYPE_VARINT,
|
PB_FIELD( 9, SFIXED32, REQUIRED, STATIC, AllTypes, req_sfixed32, req_fixed32, 0),
|
||||||
pb_delta_end(AllTypes, req_uint32, req_int64), 0,
|
PB_FIELD( 10, FLOAT , REQUIRED, STATIC, AllTypes, req_float, req_sfixed32, 0),
|
||||||
pb_membersize(AllTypes, req_uint32), 0, 0},
|
PB_FIELD( 11, FIXED64 , REQUIRED, STATIC, AllTypes, req_fixed64, req_float, 0),
|
||||||
|
PB_FIELD( 12, SFIXED64, REQUIRED, STATIC, AllTypes, req_sfixed64, req_fixed64, 0),
|
||||||
{4, PB_HTYPE_REQUIRED | PB_LTYPE_VARINT,
|
PB_FIELD( 13, DOUBLE , REQUIRED, STATIC, AllTypes, req_double, req_sfixed64, 0),
|
||||||
pb_delta_end(AllTypes, req_uint64, req_uint32), 0,
|
PB_FIELD( 14, STRING , REQUIRED, STATIC, AllTypes, req_string, req_double, 0),
|
||||||
pb_membersize(AllTypes, req_uint64), 0, 0},
|
PB_FIELD( 15, BYTES , REQUIRED, STATIC, AllTypes, req_bytes, req_string, 0),
|
||||||
|
PB_FIELD( 16, MESSAGE , REQUIRED, STATIC, AllTypes, req_submsg, req_bytes, &SubMessage_fields),
|
||||||
{5, PB_HTYPE_REQUIRED | PB_LTYPE_SVARINT,
|
PB_FIELD( 17, ENUM , REQUIRED, STATIC, AllTypes, req_enum, req_submsg, 0),
|
||||||
pb_delta_end(AllTypes, req_sint32, req_uint64), 0,
|
PB_FIELD( 21, INT32 , REPEATED, STATIC, AllTypes, rep_int32, req_enum, 0),
|
||||||
pb_membersize(AllTypes, req_sint32), 0, 0},
|
PB_FIELD( 22, INT64 , REPEATED, STATIC, AllTypes, rep_int64, rep_int32, 0),
|
||||||
|
PB_FIELD( 23, UINT32 , REPEATED, STATIC, AllTypes, rep_uint32, rep_int64, 0),
|
||||||
{6, PB_HTYPE_REQUIRED | PB_LTYPE_SVARINT,
|
PB_FIELD( 24, UINT64 , REPEATED, STATIC, AllTypes, rep_uint64, rep_uint32, 0),
|
||||||
pb_delta_end(AllTypes, req_sint64, req_sint32), 0,
|
PB_FIELD( 25, SINT32 , REPEATED, STATIC, AllTypes, rep_sint32, rep_uint64, 0),
|
||||||
pb_membersize(AllTypes, req_sint64), 0, 0},
|
PB_FIELD( 26, SINT64 , REPEATED, STATIC, AllTypes, rep_sint64, rep_sint32, 0),
|
||||||
|
PB_FIELD( 27, BOOL , REPEATED, STATIC, AllTypes, rep_bool, rep_sint64, 0),
|
||||||
{7, PB_HTYPE_REQUIRED | PB_LTYPE_VARINT,
|
PB_FIELD( 28, FIXED32 , REPEATED, STATIC, AllTypes, rep_fixed32, rep_bool, 0),
|
||||||
pb_delta_end(AllTypes, req_bool, req_sint64), 0,
|
PB_FIELD( 29, SFIXED32, REPEATED, STATIC, AllTypes, rep_sfixed32, rep_fixed32, 0),
|
||||||
pb_membersize(AllTypes, req_bool), 0, 0},
|
PB_FIELD( 30, FLOAT , REPEATED, STATIC, AllTypes, rep_float, rep_sfixed32, 0),
|
||||||
|
PB_FIELD( 31, FIXED64 , REPEATED, STATIC, AllTypes, rep_fixed64, rep_float, 0),
|
||||||
{8, PB_HTYPE_REQUIRED | PB_LTYPE_FIXED32,
|
PB_FIELD( 32, SFIXED64, REPEATED, STATIC, AllTypes, rep_sfixed64, rep_fixed64, 0),
|
||||||
pb_delta_end(AllTypes, req_fixed32, req_bool), 0,
|
PB_FIELD( 33, DOUBLE , REPEATED, STATIC, AllTypes, rep_double, rep_sfixed64, 0),
|
||||||
pb_membersize(AllTypes, req_fixed32), 0, 0},
|
PB_FIELD( 34, STRING , REPEATED, STATIC, AllTypes, rep_string, rep_double, 0),
|
||||||
|
PB_FIELD( 35, BYTES , REPEATED, STATIC, AllTypes, rep_bytes, rep_string, 0),
|
||||||
{9, PB_HTYPE_REQUIRED | PB_LTYPE_FIXED32,
|
PB_FIELD( 36, MESSAGE , REPEATED, STATIC, AllTypes, rep_submsg, rep_bytes, &SubMessage_fields),
|
||||||
pb_delta_end(AllTypes, req_sfixed32, req_fixed32), 0,
|
PB_FIELD( 37, ENUM , REPEATED, STATIC, AllTypes, rep_enum, rep_submsg, 0),
|
||||||
pb_membersize(AllTypes, req_sfixed32), 0, 0},
|
PB_FIELD( 41, INT32 , OPTIONAL, STATIC, AllTypes, opt_int32, rep_enum, &AllTypes_opt_int32_default),
|
||||||
|
PB_FIELD( 42, INT64 , OPTIONAL, STATIC, AllTypes, opt_int64, opt_int32, &AllTypes_opt_int64_default),
|
||||||
{10, PB_HTYPE_REQUIRED | PB_LTYPE_FIXED32,
|
PB_FIELD( 43, UINT32 , OPTIONAL, STATIC, AllTypes, opt_uint32, opt_int64, &AllTypes_opt_uint32_default),
|
||||||
pb_delta_end(AllTypes, req_float, req_sfixed32), 0,
|
PB_FIELD( 44, UINT64 , OPTIONAL, STATIC, AllTypes, opt_uint64, opt_uint32, &AllTypes_opt_uint64_default),
|
||||||
pb_membersize(AllTypes, req_float), 0, 0},
|
PB_FIELD( 45, SINT32 , OPTIONAL, STATIC, AllTypes, opt_sint32, opt_uint64, &AllTypes_opt_sint32_default),
|
||||||
|
PB_FIELD( 46, SINT64 , OPTIONAL, STATIC, AllTypes, opt_sint64, opt_sint32, &AllTypes_opt_sint64_default),
|
||||||
{11, PB_HTYPE_REQUIRED | PB_LTYPE_FIXED64,
|
PB_FIELD( 47, BOOL , OPTIONAL, STATIC, AllTypes, opt_bool, opt_sint64, &AllTypes_opt_bool_default),
|
||||||
pb_delta_end(AllTypes, req_fixed64, req_float), 0,
|
PB_FIELD( 48, FIXED32 , OPTIONAL, STATIC, AllTypes, opt_fixed32, opt_bool, &AllTypes_opt_fixed32_default),
|
||||||
pb_membersize(AllTypes, req_fixed64), 0, 0},
|
PB_FIELD( 49, SFIXED32, OPTIONAL, STATIC, AllTypes, opt_sfixed32, opt_fixed32, &AllTypes_opt_sfixed32_default),
|
||||||
|
PB_FIELD( 50, FLOAT , OPTIONAL, STATIC, AllTypes, opt_float, opt_sfixed32, &AllTypes_opt_float_default),
|
||||||
{12, PB_HTYPE_REQUIRED | PB_LTYPE_FIXED64,
|
PB_FIELD( 51, FIXED64 , OPTIONAL, STATIC, AllTypes, opt_fixed64, opt_float, &AllTypes_opt_fixed64_default),
|
||||||
pb_delta_end(AllTypes, req_sfixed64, req_fixed64), 0,
|
PB_FIELD( 52, SFIXED64, OPTIONAL, STATIC, AllTypes, opt_sfixed64, opt_fixed64, &AllTypes_opt_sfixed64_default),
|
||||||
pb_membersize(AllTypes, req_sfixed64), 0, 0},
|
PB_FIELD( 53, DOUBLE , OPTIONAL, STATIC, AllTypes, opt_double, opt_sfixed64, &AllTypes_opt_double_default),
|
||||||
|
PB_FIELD( 54, STRING , OPTIONAL, STATIC, AllTypes, opt_string, opt_double, &AllTypes_opt_string_default),
|
||||||
{13, PB_HTYPE_REQUIRED | PB_LTYPE_FIXED64,
|
PB_FIELD( 55, BYTES , OPTIONAL, STATIC, AllTypes, opt_bytes, opt_string, &AllTypes_opt_bytes_default),
|
||||||
pb_delta_end(AllTypes, req_double, req_sfixed64), 0,
|
PB_FIELD( 56, MESSAGE , OPTIONAL, STATIC, AllTypes, opt_submsg, opt_bytes, &SubMessage_fields),
|
||||||
pb_membersize(AllTypes, req_double), 0, 0},
|
PB_FIELD( 57, ENUM , OPTIONAL, STATIC, AllTypes, opt_enum, opt_submsg, &AllTypes_opt_enum_default),
|
||||||
|
PB_FIELD( 99, INT32 , REQUIRED, STATIC, AllTypes, end, opt_enum, 0),
|
||||||
{14, PB_HTYPE_REQUIRED | PB_LTYPE_STRING,
|
|
||||||
pb_delta_end(AllTypes, req_string, req_double), 0,
|
|
||||||
pb_membersize(AllTypes, req_string), 0, 0},
|
|
||||||
|
|
||||||
{15, PB_HTYPE_REQUIRED | PB_LTYPE_BYTES,
|
|
||||||
pb_delta_end(AllTypes, req_bytes, req_string), 0,
|
|
||||||
pb_membersize(AllTypes, req_bytes), 0, 0},
|
|
||||||
|
|
||||||
{16, PB_HTYPE_REQUIRED | PB_LTYPE_SUBMESSAGE,
|
|
||||||
pb_delta_end(AllTypes, req_submsg, req_bytes), 0,
|
|
||||||
pb_membersize(AllTypes, req_submsg), 0,
|
|
||||||
&SubMessage_fields},
|
|
||||||
|
|
||||||
{17, PB_HTYPE_REQUIRED | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, req_enum, req_submsg), 0,
|
|
||||||
pb_membersize(AllTypes, req_enum), 0, 0},
|
|
||||||
|
|
||||||
{21, PB_HTYPE_ARRAY | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, rep_int32, req_enum),
|
|
||||||
pb_delta(AllTypes, rep_int32_count, rep_int32),
|
|
||||||
pb_membersize(AllTypes, rep_int32[0]),
|
|
||||||
pb_membersize(AllTypes, rep_int32) / pb_membersize(AllTypes, rep_int32[0]), 0},
|
|
||||||
|
|
||||||
{22, PB_HTYPE_ARRAY | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, rep_int64, rep_int32),
|
|
||||||
pb_delta(AllTypes, rep_int64_count, rep_int64),
|
|
||||||
pb_membersize(AllTypes, rep_int64[0]),
|
|
||||||
pb_membersize(AllTypes, rep_int64) / pb_membersize(AllTypes, rep_int64[0]), 0},
|
|
||||||
|
|
||||||
{23, PB_HTYPE_ARRAY | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, rep_uint32, rep_int64),
|
|
||||||
pb_delta(AllTypes, rep_uint32_count, rep_uint32),
|
|
||||||
pb_membersize(AllTypes, rep_uint32[0]),
|
|
||||||
pb_membersize(AllTypes, rep_uint32) / pb_membersize(AllTypes, rep_uint32[0]), 0},
|
|
||||||
|
|
||||||
{24, PB_HTYPE_ARRAY | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, rep_uint64, rep_uint32),
|
|
||||||
pb_delta(AllTypes, rep_uint64_count, rep_uint64),
|
|
||||||
pb_membersize(AllTypes, rep_uint64[0]),
|
|
||||||
pb_membersize(AllTypes, rep_uint64) / pb_membersize(AllTypes, rep_uint64[0]), 0},
|
|
||||||
|
|
||||||
{25, PB_HTYPE_ARRAY | PB_LTYPE_SVARINT,
|
|
||||||
pb_delta_end(AllTypes, rep_sint32, rep_uint64),
|
|
||||||
pb_delta(AllTypes, rep_sint32_count, rep_sint32),
|
|
||||||
pb_membersize(AllTypes, rep_sint32[0]),
|
|
||||||
pb_membersize(AllTypes, rep_sint32) / pb_membersize(AllTypes, rep_sint32[0]), 0},
|
|
||||||
|
|
||||||
{26, PB_HTYPE_ARRAY | PB_LTYPE_SVARINT,
|
|
||||||
pb_delta_end(AllTypes, rep_sint64, rep_sint32),
|
|
||||||
pb_delta(AllTypes, rep_sint64_count, rep_sint64),
|
|
||||||
pb_membersize(AllTypes, rep_sint64[0]),
|
|
||||||
pb_membersize(AllTypes, rep_sint64) / pb_membersize(AllTypes, rep_sint64[0]), 0},
|
|
||||||
|
|
||||||
{27, PB_HTYPE_ARRAY | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, rep_bool, rep_sint64),
|
|
||||||
pb_delta(AllTypes, rep_bool_count, rep_bool),
|
|
||||||
pb_membersize(AllTypes, rep_bool[0]),
|
|
||||||
pb_membersize(AllTypes, rep_bool) / pb_membersize(AllTypes, rep_bool[0]), 0},
|
|
||||||
|
|
||||||
{28, PB_HTYPE_ARRAY | PB_LTYPE_FIXED32,
|
|
||||||
pb_delta_end(AllTypes, rep_fixed32, rep_bool),
|
|
||||||
pb_delta(AllTypes, rep_fixed32_count, rep_fixed32),
|
|
||||||
pb_membersize(AllTypes, rep_fixed32[0]),
|
|
||||||
pb_membersize(AllTypes, rep_fixed32) / pb_membersize(AllTypes, rep_fixed32[0]), 0},
|
|
||||||
|
|
||||||
{29, PB_HTYPE_ARRAY | PB_LTYPE_FIXED32,
|
|
||||||
pb_delta_end(AllTypes, rep_sfixed32, rep_fixed32),
|
|
||||||
pb_delta(AllTypes, rep_sfixed32_count, rep_sfixed32),
|
|
||||||
pb_membersize(AllTypes, rep_sfixed32[0]),
|
|
||||||
pb_membersize(AllTypes, rep_sfixed32) / pb_membersize(AllTypes, rep_sfixed32[0]), 0},
|
|
||||||
|
|
||||||
{30, PB_HTYPE_ARRAY | PB_LTYPE_FIXED32,
|
|
||||||
pb_delta_end(AllTypes, rep_float, rep_sfixed32),
|
|
||||||
pb_delta(AllTypes, rep_float_count, rep_float),
|
|
||||||
pb_membersize(AllTypes, rep_float[0]),
|
|
||||||
pb_membersize(AllTypes, rep_float) / pb_membersize(AllTypes, rep_float[0]), 0},
|
|
||||||
|
|
||||||
{31, PB_HTYPE_ARRAY | PB_LTYPE_FIXED64,
|
|
||||||
pb_delta_end(AllTypes, rep_fixed64, rep_float),
|
|
||||||
pb_delta(AllTypes, rep_fixed64_count, rep_fixed64),
|
|
||||||
pb_membersize(AllTypes, rep_fixed64[0]),
|
|
||||||
pb_membersize(AllTypes, rep_fixed64) / pb_membersize(AllTypes, rep_fixed64[0]), 0},
|
|
||||||
|
|
||||||
{32, PB_HTYPE_ARRAY | PB_LTYPE_FIXED64,
|
|
||||||
pb_delta_end(AllTypes, rep_sfixed64, rep_fixed64),
|
|
||||||
pb_delta(AllTypes, rep_sfixed64_count, rep_sfixed64),
|
|
||||||
pb_membersize(AllTypes, rep_sfixed64[0]),
|
|
||||||
pb_membersize(AllTypes, rep_sfixed64) / pb_membersize(AllTypes, rep_sfixed64[0]), 0},
|
|
||||||
|
|
||||||
{33, PB_HTYPE_ARRAY | PB_LTYPE_FIXED64,
|
|
||||||
pb_delta_end(AllTypes, rep_double, rep_sfixed64),
|
|
||||||
pb_delta(AllTypes, rep_double_count, rep_double),
|
|
||||||
pb_membersize(AllTypes, rep_double[0]),
|
|
||||||
pb_membersize(AllTypes, rep_double) / pb_membersize(AllTypes, rep_double[0]), 0},
|
|
||||||
|
|
||||||
{34, PB_HTYPE_ARRAY | PB_LTYPE_STRING,
|
|
||||||
pb_delta_end(AllTypes, rep_string, rep_double),
|
|
||||||
pb_delta(AllTypes, rep_string_count, rep_string),
|
|
||||||
pb_membersize(AllTypes, rep_string[0]),
|
|
||||||
pb_membersize(AllTypes, rep_string) / pb_membersize(AllTypes, rep_string[0]), 0},
|
|
||||||
|
|
||||||
{35, PB_HTYPE_ARRAY | PB_LTYPE_BYTES,
|
|
||||||
pb_delta_end(AllTypes, rep_bytes, rep_string),
|
|
||||||
pb_delta(AllTypes, rep_bytes_count, rep_bytes),
|
|
||||||
pb_membersize(AllTypes, rep_bytes[0]),
|
|
||||||
pb_membersize(AllTypes, rep_bytes) / pb_membersize(AllTypes, rep_bytes[0]), 0},
|
|
||||||
|
|
||||||
{36, PB_HTYPE_ARRAY | PB_LTYPE_SUBMESSAGE,
|
|
||||||
pb_delta_end(AllTypes, rep_submsg, rep_bytes),
|
|
||||||
pb_delta(AllTypes, rep_submsg_count, rep_submsg),
|
|
||||||
pb_membersize(AllTypes, rep_submsg[0]),
|
|
||||||
pb_membersize(AllTypes, rep_submsg) / pb_membersize(AllTypes, rep_submsg[0]),
|
|
||||||
&SubMessage_fields},
|
|
||||||
|
|
||||||
{37, PB_HTYPE_ARRAY | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, rep_enum, rep_submsg),
|
|
||||||
pb_delta(AllTypes, rep_enum_count, rep_enum),
|
|
||||||
pb_membersize(AllTypes, rep_enum[0]),
|
|
||||||
pb_membersize(AllTypes, rep_enum) / pb_membersize(AllTypes, rep_enum[0]), 0},
|
|
||||||
|
|
||||||
{41, PB_HTYPE_OPTIONAL | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, opt_int32, rep_enum),
|
|
||||||
pb_delta(AllTypes, has_opt_int32, opt_int32),
|
|
||||||
pb_membersize(AllTypes, opt_int32), 0,
|
|
||||||
&AllTypes_opt_int32_default},
|
|
||||||
|
|
||||||
{42, PB_HTYPE_OPTIONAL | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, opt_int64, opt_int32),
|
|
||||||
pb_delta(AllTypes, has_opt_int64, opt_int64),
|
|
||||||
pb_membersize(AllTypes, opt_int64), 0,
|
|
||||||
&AllTypes_opt_int64_default},
|
|
||||||
|
|
||||||
{43, PB_HTYPE_OPTIONAL | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, opt_uint32, opt_int64),
|
|
||||||
pb_delta(AllTypes, has_opt_uint32, opt_uint32),
|
|
||||||
pb_membersize(AllTypes, opt_uint32), 0,
|
|
||||||
&AllTypes_opt_uint32_default},
|
|
||||||
|
|
||||||
{44, PB_HTYPE_OPTIONAL | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, opt_uint64, opt_uint32),
|
|
||||||
pb_delta(AllTypes, has_opt_uint64, opt_uint64),
|
|
||||||
pb_membersize(AllTypes, opt_uint64), 0,
|
|
||||||
&AllTypes_opt_uint64_default},
|
|
||||||
|
|
||||||
{45, PB_HTYPE_OPTIONAL | PB_LTYPE_SVARINT,
|
|
||||||
pb_delta_end(AllTypes, opt_sint32, opt_uint64),
|
|
||||||
pb_delta(AllTypes, has_opt_sint32, opt_sint32),
|
|
||||||
pb_membersize(AllTypes, opt_sint32), 0,
|
|
||||||
&AllTypes_opt_sint32_default},
|
|
||||||
|
|
||||||
{46, PB_HTYPE_OPTIONAL | PB_LTYPE_SVARINT,
|
|
||||||
pb_delta_end(AllTypes, opt_sint64, opt_sint32),
|
|
||||||
pb_delta(AllTypes, has_opt_sint64, opt_sint64),
|
|
||||||
pb_membersize(AllTypes, opt_sint64), 0,
|
|
||||||
&AllTypes_opt_sint64_default},
|
|
||||||
|
|
||||||
{47, PB_HTYPE_OPTIONAL | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, opt_bool, opt_sint64),
|
|
||||||
pb_delta(AllTypes, has_opt_bool, opt_bool),
|
|
||||||
pb_membersize(AllTypes, opt_bool), 0,
|
|
||||||
&AllTypes_opt_bool_default},
|
|
||||||
|
|
||||||
{48, PB_HTYPE_OPTIONAL | PB_LTYPE_FIXED32,
|
|
||||||
pb_delta_end(AllTypes, opt_fixed32, opt_bool),
|
|
||||||
pb_delta(AllTypes, has_opt_fixed32, opt_fixed32),
|
|
||||||
pb_membersize(AllTypes, opt_fixed32), 0,
|
|
||||||
&AllTypes_opt_fixed32_default},
|
|
||||||
|
|
||||||
{49, PB_HTYPE_OPTIONAL | PB_LTYPE_FIXED32,
|
|
||||||
pb_delta_end(AllTypes, opt_sfixed32, opt_fixed32),
|
|
||||||
pb_delta(AllTypes, has_opt_sfixed32, opt_sfixed32),
|
|
||||||
pb_membersize(AllTypes, opt_sfixed32), 0,
|
|
||||||
&AllTypes_opt_sfixed32_default},
|
|
||||||
|
|
||||||
{50, PB_HTYPE_OPTIONAL | PB_LTYPE_FIXED32,
|
|
||||||
pb_delta_end(AllTypes, opt_float, opt_sfixed32),
|
|
||||||
pb_delta(AllTypes, has_opt_float, opt_float),
|
|
||||||
pb_membersize(AllTypes, opt_float), 0,
|
|
||||||
&AllTypes_opt_float_default},
|
|
||||||
|
|
||||||
{51, PB_HTYPE_OPTIONAL | PB_LTYPE_FIXED64,
|
|
||||||
pb_delta_end(AllTypes, opt_fixed64, opt_float),
|
|
||||||
pb_delta(AllTypes, has_opt_fixed64, opt_fixed64),
|
|
||||||
pb_membersize(AllTypes, opt_fixed64), 0,
|
|
||||||
&AllTypes_opt_fixed64_default},
|
|
||||||
|
|
||||||
{52, PB_HTYPE_OPTIONAL | PB_LTYPE_FIXED64,
|
|
||||||
pb_delta_end(AllTypes, opt_sfixed64, opt_fixed64),
|
|
||||||
pb_delta(AllTypes, has_opt_sfixed64, opt_sfixed64),
|
|
||||||
pb_membersize(AllTypes, opt_sfixed64), 0,
|
|
||||||
&AllTypes_opt_sfixed64_default},
|
|
||||||
|
|
||||||
{53, PB_HTYPE_OPTIONAL | PB_LTYPE_FIXED64,
|
|
||||||
pb_delta_end(AllTypes, opt_double, opt_sfixed64),
|
|
||||||
pb_delta(AllTypes, has_opt_double, opt_double),
|
|
||||||
pb_membersize(AllTypes, opt_double), 0,
|
|
||||||
&AllTypes_opt_double_default},
|
|
||||||
|
|
||||||
{54, PB_HTYPE_OPTIONAL | PB_LTYPE_STRING,
|
|
||||||
pb_delta_end(AllTypes, opt_string, opt_double),
|
|
||||||
pb_delta(AllTypes, has_opt_string, opt_string),
|
|
||||||
pb_membersize(AllTypes, opt_string), 0,
|
|
||||||
&AllTypes_opt_string_default},
|
|
||||||
|
|
||||||
{55, PB_HTYPE_OPTIONAL | PB_LTYPE_BYTES,
|
|
||||||
pb_delta_end(AllTypes, opt_bytes, opt_string),
|
|
||||||
pb_delta(AllTypes, has_opt_bytes, opt_bytes),
|
|
||||||
pb_membersize(AllTypes, opt_bytes), 0,
|
|
||||||
&AllTypes_opt_bytes_default},
|
|
||||||
|
|
||||||
{56, PB_HTYPE_OPTIONAL | PB_LTYPE_SUBMESSAGE,
|
|
||||||
pb_delta_end(AllTypes, opt_submsg, opt_bytes),
|
|
||||||
pb_delta(AllTypes, has_opt_submsg, opt_submsg),
|
|
||||||
pb_membersize(AllTypes, opt_submsg), 0,
|
|
||||||
&SubMessage_fields},
|
|
||||||
|
|
||||||
{57, PB_HTYPE_OPTIONAL | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, opt_enum, opt_submsg),
|
|
||||||
pb_delta(AllTypes, has_opt_enum, opt_enum),
|
|
||||||
pb_membersize(AllTypes, opt_enum), 0,
|
|
||||||
&AllTypes_opt_enum_default},
|
|
||||||
|
|
||||||
{99, PB_HTYPE_REQUIRED | PB_LTYPE_VARINT,
|
|
||||||
pb_delta_end(AllTypes, end, opt_enum), 0,
|
|
||||||
pb_membersize(AllTypes, end), 0, 0},
|
|
||||||
|
|
||||||
PB_LAST_FIELD
|
PB_LAST_FIELD
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
/* Automatically generated nanopb header */
|
/* Automatically generated nanopb header */
|
||||||
/* This is a file generated using nanopb-0.1.1.
|
/* This is a file generated using nanopb-0.2.0-dev.
|
||||||
* It is used as a part of test suite in order to detect any
|
* It is used as a part of test suite in order to detect any
|
||||||
* incompatible changes made to the generator in future versions.
|
* incompatible changes made to the generator in future versions.
|
||||||
*/
|
*/
|
||||||
#ifndef _PB_BC_ALLTYPES_PB_H_
|
|
||||||
#define _PB_BC_ALLTYPES_PB_H_
|
#ifndef _PB_ALLTYPES_PB_H_
|
||||||
|
#define _PB_ALLTYPES_PB_H_
|
||||||
#include <pb.h>
|
#include <pb.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Enum definitions */
|
/* Enum definitions */
|
||||||
typedef enum {
|
typedef enum _MyEnum {
|
||||||
MyEnum_Zero = 0,
|
MyEnum_Zero = 0,
|
||||||
MyEnum_First = 1,
|
MyEnum_First = 1,
|
||||||
MyEnum_Second = 2,
|
MyEnum_Second = 2,
|
||||||
@@ -16,7 +21,7 @@ typedef enum {
|
|||||||
} MyEnum;
|
} MyEnum;
|
||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
typedef struct {
|
typedef struct _SubMessage {
|
||||||
char substuff1[16];
|
char substuff1[16];
|
||||||
int32_t substuff2;
|
int32_t substuff2;
|
||||||
bool has_substuff3;
|
bool has_substuff3;
|
||||||
@@ -38,7 +43,7 @@ typedef struct {
|
|||||||
uint8_t bytes[16];
|
uint8_t bytes[16];
|
||||||
} AllTypes_opt_bytes_t;
|
} AllTypes_opt_bytes_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct _AllTypes {
|
||||||
int32_t req_int32;
|
int32_t req_int32;
|
||||||
int64_t req_int64;
|
int64_t req_int64;
|
||||||
uint32_t req_uint32;
|
uint32_t req_uint32;
|
||||||
@@ -128,7 +133,7 @@ typedef struct {
|
|||||||
} AllTypes;
|
} AllTypes;
|
||||||
|
|
||||||
/* Default values for struct fields */
|
/* Default values for struct fields */
|
||||||
extern const char SubMessage_substuff1_default[17];
|
extern const char SubMessage_substuff1_default[16];
|
||||||
extern const int32_t SubMessage_substuff2_default;
|
extern const int32_t SubMessage_substuff2_default;
|
||||||
extern const uint32_t SubMessage_substuff3_default;
|
extern const uint32_t SubMessage_substuff3_default;
|
||||||
extern const int32_t AllTypes_opt_int32_default;
|
extern const int32_t AllTypes_opt_int32_default;
|
||||||
@@ -144,7 +149,7 @@ extern const float AllTypes_opt_float_default;
|
|||||||
extern const uint64_t AllTypes_opt_fixed64_default;
|
extern const uint64_t AllTypes_opt_fixed64_default;
|
||||||
extern const int64_t AllTypes_opt_sfixed64_default;
|
extern const int64_t AllTypes_opt_sfixed64_default;
|
||||||
extern const double AllTypes_opt_double_default;
|
extern const double AllTypes_opt_double_default;
|
||||||
extern const char AllTypes_opt_string_default[17];
|
extern const char AllTypes_opt_string_default[16];
|
||||||
extern const AllTypes_opt_bytes_t AllTypes_opt_bytes_default;
|
extern const AllTypes_opt_bytes_t AllTypes_opt_bytes_default;
|
||||||
extern const MyEnum AllTypes_opt_enum_default;
|
extern const MyEnum AllTypes_opt_enum_default;
|
||||||
|
|
||||||
@@ -152,4 +157,22 @@ extern const MyEnum AllTypes_opt_enum_default;
|
|||||||
extern const pb_field_t SubMessage_fields[4];
|
extern const pb_field_t SubMessage_fields[4];
|
||||||
extern const pb_field_t AllTypes_fields[53];
|
extern const pb_field_t AllTypes_fields[53];
|
||||||
|
|
||||||
|
/* Check that field information fits in pb_field_t */
|
||||||
|
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
|
||||||
|
STATIC_ASSERT((pb_membersize(AllTypes, req_submsg) < 256 && pb_membersize(AllTypes, rep_submsg[0]) < 256 && pb_membersize(AllTypes, opt_submsg) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_SubMessage_AllTypes)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(PB_FIELD_32BIT)
|
||||||
|
STATIC_ASSERT((pb_membersize(AllTypes, req_submsg) < 65536 && pb_membersize(AllTypes, rep_submsg[0]) < 65536 && pb_membersize(AllTypes, opt_submsg) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_SubMessage_AllTypes)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* On some platforms (such as AVR), double is really float.
|
||||||
|
* These are not directly supported by nanopb, but see example_avr_double.
|
||||||
|
*/
|
||||||
|
STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user