1/* Test nanopb option parsing. 2 * options.expected lists the patterns that are searched for in the output. 3 */ 4 5import "nanopb.proto"; 6 7// File level options 8option (nanopb_fileopt).max_size = 20; 9 10message Message1 11{ 12 required string filesize = 1; 13} 14 15// Message level options 16message Message2 17{ 18 option (nanopb_msgopt).max_size = 30; 19 required string msgsize = 1; 20} 21 22// Field level options 23message Message3 24{ 25 required string fieldsize = 1 [(nanopb).max_size = 40]; 26} 27 28// Forced callback field 29message Message4 30{ 31 required int32 int32_callback = 1 [(nanopb).type = FT_CALLBACK]; 32} 33 34// Short enum names 35enum Enum1 36{ 37 option (nanopb_enumopt).long_names = false; 38 EnumValue1 = 1; 39 EnumValue2 = 2; 40} 41 42message EnumTest 43{ 44 required Enum1 field = 1 [default = EnumValue2]; 45} 46 47// Short enum names inside message 48message Message5 49{ 50 enum Enum2 51 { 52 option (nanopb_enumopt).long_names = false; 53 EnumValue1 = 1; 54 } 55 required Enum2 field = 1 [default = EnumValue1]; 56} 57 58// Packed structure 59message my_packed_struct 60{ 61 option (nanopb_msgopt).packed_struct = true; 62 optional int32 myfield = 1; 63} 64 65// Message with ignored field 66// Note: doesn't really test if the field is missing in the output, 67// but atleast tests that the output compiles. 68message Message6 69{ 70 required int32 field1 = 1; 71 optional int32 field2 = 2 [(nanopb).type = FT_IGNORE]; 72} 73 74