Merge the generated has_<name> fields into a single one.

git-svn-id: https://svn.kapsi.fi/jpa/nanopb-dev@1008 e3a754e5-d11d-0410-8d38-ebb782a927b9
This commit is contained in:
Michael Poole
2011-11-13 18:10:19 +00:00
committed by Petteri Aimonen
parent 43b8e20744
commit 8e5337e9ef
12 changed files with 87 additions and 40 deletions

View File

@@ -192,7 +192,7 @@ int main()
{
uint8_t buffer[10];
pb_ostream_t s;
IntegerArray msg = {5, {1, 2, 3, 4, 5}};
IntegerArray msg = {{0}, 5, {1, 2, 3, 4, 5}};
COMMENT("Test pb_encode with int32 array")
@@ -208,7 +208,7 @@ int main()
{
uint8_t buffer[10];
pb_ostream_t s;
FloatArray msg = {1, {99.0f}};
FloatArray msg = {{0}, 1, {99.0f}};
COMMENT("Test pb_encode with float array")
@@ -236,7 +236,7 @@ int main()
{
uint8_t buffer[10];
pb_ostream_t s;
IntegerContainer msg = {{5, {1,2,3,4,5}}};
IntegerContainer msg = {{0}, {{0}, 5, {1,2,3,4,5}}};
COMMENT("Test pb_encode with packed array in a submessage.")
TEST(WRITES(pb_encode(&s, IntegerContainer_msg, &msg),

View File

@@ -25,7 +25,7 @@ bool print_person(pb_istream_t *stream)
printf("name: \"%s\"\n", person.name);
printf("id: %d\n", person.id);
if (person.has_email)
if (Person_has(person, email))
printf("email: \"%s\"\n", person.email);
for (i = 0; i < person.phone_count; i++)

View File

@@ -17,9 +17,11 @@ bool streamcallback(pb_ostream_t *stream, const uint8_t *buf, size_t count)
int main()
{
/* Initialize the structure with constants */
Person person = {"Test Person 99", 99, true, "test@person.com",
1, {{"555-12345678", true, Person_PhoneType_MOBILE}}};
Person person = {{0}, "Test Person 99", 99, "test@person.com",
1, {{{0}, "555-12345678", Person_PhoneType_MOBILE}}};
Person_set(person, email);
Person_PhoneNumber_set(person.phone[0], type);
/* Prepare the stream, output goes directly to stdout */
pb_ostream_t stream = {&streamcallback, stdout, SIZE_MAX, 0};

View File

@@ -52,7 +52,7 @@ int main()
testmessage.fixed32value.funcs.encode = &encode_fixed32;
testmessage.fixed64value.funcs.encode = &encode_fixed64;
testmessage.has_submsg = true;
TestMessage_set(testmessage, submsg);
testmessage.submsg.stringvalue.funcs.encode = &encode_string;
testmessage.submsg.int32value.funcs.encode = &encode_int32;
testmessage.submsg.fixed32value.funcs.encode = &encode_fixed32;