diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-02 17:51:53 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-02 17:51:53 +0200 |
commit | 3102ec9ce009d0f28355c5b7df9c5bd5013e6e75 (patch) | |
tree | 80a1ea19ff06cc9308b236a0d8d6358d21dd0381 /CAN-binder/libs/nanopb/tests/options/options.proto | |
parent | 12e680a3c97a2750c657a8c561a79706f3689149 (diff) | |
parent | 278ffb890e3d8722e4c7d824baaf221a1e375fc4 (diff) |
Add 'CAN-binder/libs/nanopb/' from commit '278ffb890e3d8722e4c7d824baaf221a1e375fc4'
git-subtree-dir: CAN-binder/libs/nanopb
git-subtree-mainline: 12e680a3c97a2750c657a8c561a79706f3689149
git-subtree-split: 278ffb890e3d8722e4c7d824baaf221a1e375fc4
Diffstat (limited to 'CAN-binder/libs/nanopb/tests/options/options.proto')
-rw-r--r-- | CAN-binder/libs/nanopb/tests/options/options.proto | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/CAN-binder/libs/nanopb/tests/options/options.proto b/CAN-binder/libs/nanopb/tests/options/options.proto new file mode 100644 index 0000000..c6ca5e2 --- /dev/null +++ b/CAN-binder/libs/nanopb/tests/options/options.proto @@ -0,0 +1,98 @@ +/* Test nanopb option parsing. + * options.expected lists the patterns that are searched for in the output. + */ + +syntax = "proto2"; + +import "nanopb.proto"; + +// File level options +option (nanopb_fileopt).max_size = 20; + +message Message1 +{ + required string filesize = 1; +} + +// Message level options +message Message2 +{ + option (nanopb_msgopt).max_size = 30; + required string msgsize = 1; +} + +// Field level options +message Message3 +{ + option (nanopb_msgopt).msgid = 103; + required string fieldsize = 1 [(nanopb).max_size = 40]; + required string fieldlen = 2 [(nanopb).max_length = 40]; +} + +// Forced callback field +message Message4 +{ + option (nanopb_msgopt).msgid = 104; + required int32 int32_callback = 1 [(nanopb).type = FT_CALLBACK]; +} + +// Short enum names +enum Enum1 +{ + option (nanopb_enumopt).long_names = false; + EnumValue1 = 1; + EnumValue2 = 2; +} + +message EnumTest +{ + required Enum1 field = 1 [default = EnumValue2]; +} + +// Short enum names inside message +message Message5 +{ + option (nanopb_msgopt).msgid = 105; + enum Enum2 + { + option (nanopb_enumopt).long_names = false; + EnumValue1 = 1; + } + required Enum2 field = 1 [default = EnumValue1]; +} + +// Packed structure +message my_packed_struct +{ + option (nanopb_msgopt).packed_struct = true; + optional int32 myfield = 1; +} + +// Message with ignored field +message Message6 +{ + required int32 field1 = 1; + optional int32 skipped_field = 2 [(nanopb).type = FT_IGNORE]; +} + +// Message that is skipped +message SkippedMessage +{ + option (nanopb_msgopt).skip_message = true; + required int32 foo = 1; +} + +// Message with oneof field +message OneofMessage +{ + oneof foo { + int32 bar = 1; + } +} + +// Proto3-style optional field in proto2 file +message Proto3Field +{ + optional int32 proto3field = 1 [(nanopb).proto3 = true]; +} + |