1. Include precalculated required field count and largest tag, to avoid calculating them at runtime.
2. Reorder fields for better natural alignment (pointers first in struct)
3. Remove PB_PACKED_STRUCT specification, no longer needed.
This may break things for users that have python-protobuf installed
only for Python 2. Easiest fix is to just install python3-protobuf.
After much consideration, I think making the change now will make
life easiest for most users. There are now alternative files that
can be used if only Python 2 is available, see migration.rst.
Removed PB_OLD_CALLBACK_STYLE. Added generator option
submsg_callback to have a message-level callback for
setting up callbacks inside oneofs. Added example/testcase
about using callbacks with oneofs.
This will be a breaking change for a lot of code using proto3 mode.
All proto3 submessages now have has_ field, that must be set to 'true' to
have the field encoded. To ease the transition, there is a generator
option proto3_singular_msgs to restore the old behavior.
Previously nanopb didn't enforce that decoded bool fields
had valid true/false values. This could lead to undefined
behavior in user code.
This has potential security implications when
1) message contains bool field (has_ fields are safe)
and
2) user code uses ternary operator dependent on the field value,
such as: int value = msg.my_bool ? 1234 : 0
and
3) the value returned from ternary operator affects a memory access,
such as: data_array[value] = 9999
Don't encode scalar arrays as packed. This is only to be used when
the decoder on the receiving side cannot process packed scalar arrays.
Such example is older protobuf.js.
This should simplify specifying combinations, so that we don't
need every variant of pb_decode_noinit_delimited() etc.
Also disables zero-terminated decoding in pb_decode (issue #278).
Now field information is stored as a variable-length uint32_t array.
This reduces the minimum size in most cases:
old new
basic field: 10 bytes 4 bytes
repeated field: 10 bytes 8 bytes
field with 12bit tag/size: 16 bytes 8 bytes
field with 16bit tag/size: 16 bytes 16 bytes
field with 32bit tag/size: 28 bytes 16 bytes
Further, now the descriptor size can be increased per-field and per-message,
instead of previous global PB_FIELD_16BIT and PB_FIELD_32BIT.
PB_FIELD_32BIT still affects the pb_size_t type, which is 16-bit by default.