Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | // Sample .proto file that we can translate to the corresponding .fbs. |
| 2 | |
| 3 | option some_option = is_ignored; |
| 4 | import "imported.proto"; |
| 5 | |
| 6 | package proto.test; |
| 7 | |
| 8 | /// Enum doc comment. |
| 9 | enum ProtoEnum { |
| 10 | option allow_alias = true; |
| 11 | NUL = 0; |
| 12 | FOO = 1; |
| 13 | /// Enum 2nd value doc comment misaligned. |
| 14 | BAR = 5; |
| 15 | // Aliases |
| 16 | FOO_A1 = 1; |
| 17 | BAR_A1 = 5; |
| 18 | FOO_A2 = 1; |
| 19 | } |
| 20 | |
| 21 | /// 2nd table doc comment with |
| 22 | /// many lines. |
| 23 | message ProtoMessage { |
| 24 | // Ignored non-doc comment. |
| 25 | // A nested message declaration, will be moved to top level in .fbs |
| 26 | message OtherMessage { |
| 27 | optional double a = 26; |
| 28 | /// doc comment for b. |
| 29 | optional float b = 32 [default = 3.14149]; |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 30 | |
| 31 | // Nested enum that aliases the outer one. |
| 32 | enum ProtoEnum { |
| 33 | NUL = 0; |
| 34 | FOO = 1; |
| 35 | BAR = 2; |
| 36 | BAZ = 3; |
| 37 | } |
| 38 | |
| 39 | optional ProtoEnum foo_bar_baz = 33; |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 40 | } |
| 41 | optional int32 c = 12 [default = 16]; |
| 42 | optional int64 d = 1 [default = 0]; |
| 43 | optional uint32 p = 1; |
| 44 | optional uint64 e = 2; |
| 45 | /// doc comment for f. |
| 46 | optional sint32 f = 3 [default = -1]; |
| 47 | optional sint64 g = 4; |
| 48 | optional fixed32 h = 5; |
| 49 | optional fixed64 q = 6; |
| 50 | optional sfixed32 i = 7; |
| 51 | optional sfixed64 j = 8; |
| 52 | /// doc comment for k. |
| 53 | optional bool k = 9; |
| 54 | /// doc comment for l on 2 |
| 55 | /// lines |
| 56 | required string l = 10; |
| 57 | optional bytes m = 11; |
| 58 | optional OtherMessage n = 12; |
| 59 | repeated string o = 14; |
| 60 | optional ImportedMessage z = 16; |
| 61 | /// doc comment for r. |
| 62 | oneof r { |
| 63 | /// doc comment for s. |
| 64 | ImportedMessage s = 17; |
| 65 | /// doc comment for t on 2 |
| 66 | /// lines. |
| 67 | OtherMessage t = 18; |
| 68 | } |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 69 | optional ProtoEnum outer_enum = 33; |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 70 | // Tests that `inf` and `+/-inf` can be parsed in proto options. |
| 71 | optional float u = 34 [default = inf]; |
| 72 | optional float v = 35 [default = +inf]; |
| 73 | optional float w = 36 [default = -inf]; |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame] | 74 | |
| 75 | map<string, float> grades = 37; |
| 76 | map<string, OtherMessage> other_message_map = 38; |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 77 | } |