diff options
author | Tom Roeder <tmroeder@google.com> | 2016-08-02 14:57:37 -0700 |
---|---|---|
committer | Tom Roeder <tmroeder@google.com> | 2016-08-04 19:01:43 -0400 |
commit | 62afd54964528c1fbd5ab802134f7e9ad912d904 (patch) | |
tree | b96eaefeaeaacd123e8d7e2f033dda3ba1698681 /docs/concepts.rst | |
parent | 0198210f2cc349e7bc5199e8db7f4afc8208d843 (diff) |
Add inline allocation of bytes fields
This commit adds a new FT_INLINE allocation type that forces bytes
fields to be inlined into the struct. E.g., pb_byte_t my_bytes[32].
This requires max_size for the bytes field. The FT_INLINE type is
represented as a new LTYPE: FT_LTYPE_FIXED_LENGTH_BYTES.
This commit also updates the documentation with FT_INLINE and
FT_LTYPE_FIXED_LENGTH_BYTES.
Added an AUTHORS file in apparent order of appearance in the git log
history from $(git log --all).
Diffstat (limited to 'docs/concepts.rst')
-rw-r--r-- | docs/concepts.rst | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/docs/concepts.rst b/docs/concepts.rst index b4f657e2..c43d8299 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -148,6 +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 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. =============================================================================== ======================= @@ -160,9 +161,10 @@ repeated string name = 1 [(nanopb).max_size = 40, (nanopb).max_count = 5]; | char name[5][40]; required bytes data = 1 [(nanopb).max_size = 40]; | typedef struct { | size_t size; - | uint8_t bytes[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]; =============================================================================== ======================= The maximum lengths are checked in runtime. If string/bytes/array exceeds the allocated length, *pb_decode* will return false. |