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

@@ -144,6 +144,7 @@ bool checkreturn pb_encode(pb_ostream_t *stream, const pb_message_t *msg, const
{
const void *pData = src_struct;
const void *pSize;
const char *has_fields = src_struct;
unsigned int i;
size_t prev_size = 0;
@@ -168,7 +169,7 @@ bool checkreturn pb_encode(pb_ostream_t *stream, const pb_message_t *msg, const
break;
case PB_HTYPE_OPTIONAL:
if (*(bool*)pSize)
if (has_fields[i/8] & (1 << i%8))
{
if (!pb_encode_tag_for_field(stream, field))
return false;