• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* Test nanopb option parsing.
2 * options.expected lists the patterns that are searched for in the output.
3 */
4
5syntax = "proto2";
6
7import "nanopb.proto";
8
9// File level options
10option (nanopb_fileopt).max_size = 20;
11
12message Message1
13{
14    required string filesize = 1;
15}
16
17// Message level options
18message Message2
19{
20    option (nanopb_msgopt).max_size = 30;
21    required string msgsize = 1;
22}
23
24// Field level options
25message Message3
26{
27    option (nanopb_msgopt).msgid = 103;
28    required string fieldsize = 1 [(nanopb).max_size = 40];
29    required string fieldlen = 2 [(nanopb).max_length = 40];
30}
31
32// Forced callback field
33message Message4
34{
35    option (nanopb_msgopt).msgid = 104;
36    required int32 int32_callback = 1 [(nanopb).type = FT_CALLBACK];
37}
38
39// Short enum names
40enum Enum1
41{
42    option (nanopb_enumopt).long_names = false;
43    EnumValue1 = 1;
44    EnumValue2 = 2;
45}
46
47message EnumTest
48{
49    required Enum1 field = 1 [default = EnumValue2];
50}
51
52// Short enum names inside message
53message Message5
54{
55    option (nanopb_msgopt).msgid = 105;
56    enum Enum2
57    {
58       option (nanopb_enumopt).long_names = false;
59       EnumValue1 = 1;
60    }
61    required Enum2 field = 1 [default = EnumValue1];
62}
63
64// Packed structure
65message my_packed_struct
66{
67    option (nanopb_msgopt).packed_struct = true;
68    optional int32 myfield = 1;
69}
70
71// Message with ignored field
72message Message6
73{
74    required int32 field1 = 1;
75    optional int32 skipped_field = 2 [(nanopb).type = FT_IGNORE];
76}
77
78// Message that is skipped
79message SkippedMessage
80{
81    option (nanopb_msgopt).skip_message = true;
82    required int32 foo = 1;
83}
84
85// Message with oneof field
86message OneofMessage
87{
88    oneof foo {
89        int32 bar = 1;
90    }
91}
92
93// Proto3-style optional field in proto2 file
94message Proto3Field
95{
96    optional int32 proto3field = 1 [(nanopb).proto3 = true];
97}
98
99