diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2017-02-22 21:06:32 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2017-02-22 21:10:26 +0200 |
commit | 07375a126337916f3a34ea94f8085b8f89d789a1 (patch) | |
tree | ef95d9138252d8ae4797e0a7092bc7417c1abefb /docs | |
parent | ca74746e23b5a9e7916e8fde6632d71d61603f50 (diff) |
Extend inline / fixed length bytes array support (issue #244)
Adds support for proto3 and POINTER field types to have
fixed length bytes arrays. Also changed the .proto option
to a separate fixed_length:true, while also supporting the old FT_INLINE
option.
Restructured the generator and decoder logic to threat the inline
bytes fields more like "just another field type".
Diffstat (limited to 'docs')
-rw-r--r-- | docs/concepts.rst | 4 | ||||
-rw-r--r-- | docs/reference.rst | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/docs/concepts.rst b/docs/concepts.rst index ea33863c..2e0d3f9b 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -148,7 +148,7 @@ Most Protocol Buffers datatypes have directly corresponding C datatypes, such as 1) Strings, bytes and repeated fields of any type map to callback functions by default. 2) If there is a special option *(nanopb).max_size* specified in the .proto file, string maps to null-terminated char array and bytes map to a structure containing a char array and a size field. -3) If *(nanopb).type* is set to *FT_INLINE* and *(nanopb).max_size* is also set, then bytes map to an inline byte array of fixed size. +3) If *(nanopb).fixed_length* is set to *true* and *(nanopb).max_size* is also set, then bytes map to an inline byte array of fixed size. 4) If there is a special option *(nanopb).max_count* specified on a repeated field, it maps to an array of whatever type is being repeated. Another field will be created for the actual number of entries stored. =============================================================================== ======================= @@ -164,7 +164,7 @@ required bytes data = 1 [(nanopb).max_size = 40]; | pb_byte_t bytes[40]; | } Person_data_t; | Person_data_t data; -required bytes data = 1 [(nanopb).max_size = 40, (nanopb).type = FT_INLINE]; | pb_byte_t data[40]; +required bytes data = 1 [(nanopb).max_size = 40, (nanopb).fixed_length = true]; | pb_byte_t data[40]; =============================================================================== ======================= The maximum lengths are checked in runtime. If string/bytes/array exceeds the allocated length, *pb_decode* will return false. diff --git a/docs/reference.rst b/docs/reference.rst index ef3867a1..e59a0c94 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -77,11 +77,10 @@ int_size Override the integer type of a field. type Type of the generated field. Default value is *FT_DEFAULT*, which selects automatically. You can use *FT_CALLBACK*, *FT_POINTER*, - *FT_STATIC*, *FT_IGNORE*, or *FT_INLINE* to + *FT_STATIC* or *FT_IGNORE* to force a callback field, a dynamically - allocated field, a static field, to - completely ignore the field or to - generate an inline bytes field. + allocated field, a static field or to + completely ignore the field. long_names Prefix the enum name to the enum value in definitions, i.e. *EnumName_EnumValue*. Enabled by default. @@ -94,6 +93,7 @@ no_unions Generate 'oneof' fields as optional fields msgid Specifies a unique id for this message type. Can be used by user code as an identifier. anonymous_oneof Generate 'oneof' fields as anonymous unions. +fixed_length Generate 'bytes' fields with constant length. ============================ ================================================ These options can be defined for the .proto files before they are converted |