Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 1 | // Protocol Buffers - Google's data interchange format |
| 2 | // Copyright 2008 Google Inc. All rights reserved. |
| 3 | // https://developers.google.com/protocol-buffers/ |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without |
| 6 | // modification, are permitted provided that the following conditions are |
| 7 | // met: |
| 8 | // |
| 9 | // * Redistributions of source code must retain the above copyright |
| 10 | // notice, this list of conditions and the following disclaimer. |
| 11 | // * Redistributions in binary form must reproduce the above |
| 12 | // copyright notice, this list of conditions and the following disclaimer |
| 13 | // in the documentation and/or other materials provided with the |
| 14 | // distribution. |
| 15 | // * Neither the name of Google Inc. nor the names of its |
| 16 | // contributors may be used to endorse or promote products derived from |
| 17 | // this software without specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | // Author: mwr@google.com (Mark Rawling) |
| 32 | |
| 33 | syntax = "proto2"; |
| 34 | |
| 35 | option java_package = "com.google.apps.jspb.proto"; |
| 36 | option java_multiple_files = true; |
| 37 | |
| 38 | import "google/protobuf/descriptor.proto"; |
| 39 | |
| 40 | package jspb.test; |
| 41 | |
| 42 | message Empty { |
| 43 | } |
| 44 | |
| 45 | enum OuterEnum { |
| 46 | FOO = 1; |
| 47 | BAR = 2; |
| 48 | } |
| 49 | |
| 50 | message EnumContainer { |
| 51 | optional OuterEnum outer_enum = 1; |
| 52 | } |
| 53 | |
| 54 | message Simple1 { |
| 55 | required string a_string = 1; |
| 56 | repeated string a_repeated_string = 2; |
| 57 | optional bool a_boolean = 3; |
| 58 | } |
| 59 | |
| 60 | // A message that differs from Simple1 only by name |
| 61 | message Simple2 { |
| 62 | required string a_string = 1; |
| 63 | repeated string a_repeated_string = 2; |
| 64 | } |
| 65 | |
| 66 | message SpecialCases { |
| 67 | required string normal = 1; |
| 68 | // Examples of Js reserved names that are converted to pb_<name>. |
| 69 | required string default = 2; |
| 70 | required string function = 3; |
| 71 | required string var = 4; |
| 72 | } |
| 73 | |
| 74 | message OptionalFields { |
| 75 | message Nested { |
| 76 | optional int32 an_int = 1; |
| 77 | } |
| 78 | optional string a_string = 1; |
| 79 | required bool a_bool = 2; |
| 80 | optional Nested a_nested_message = 3; |
| 81 | repeated Nested a_repeated_message = 4; |
| 82 | repeated string a_repeated_string = 5; |
| 83 | } |
| 84 | |
| 85 | message HasExtensions { |
| 86 | optional string str1 = 1; |
| 87 | optional string str2 = 2; |
| 88 | optional string str3 = 3; |
| 89 | extensions 10 to max; |
| 90 | } |
| 91 | |
| 92 | message Complex { |
| 93 | message Nested { |
| 94 | required int32 an_int = 2; |
| 95 | } |
| 96 | required string a_string = 1; |
| 97 | required bool an_out_of_order_bool = 9; |
| 98 | optional Nested a_nested_message = 4; |
| 99 | repeated Nested a_repeated_message = 5; |
| 100 | repeated string a_repeated_string = 7; |
| 101 | } |
| 102 | |
Josh Haberman | 77af5d0 | 2016-02-04 16:11:07 -0800 | [diff] [blame] | 103 | message OuterMessage { |
| 104 | // Make sure this doesn't conflict with the other Complex message. |
| 105 | message Complex { |
| 106 | optional int32 inner_complex_field = 1; |
| 107 | } |
| 108 | } |
| 109 | |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 110 | message IsExtension { |
| 111 | extend HasExtensions { |
| 112 | optional IsExtension ext_field = 100; |
| 113 | } |
| 114 | optional string ext1 = 1; |
| 115 | |
| 116 | // Extensions of proto2 Descriptor messages will be ignored. |
| 117 | extend google.protobuf.EnumOptions { |
| 118 | optional string simple_option = 42113038; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | message IndirectExtension { |
| 123 | extend HasExtensions { |
| 124 | optional Simple1 simple = 101; |
| 125 | optional string str = 102; |
| 126 | repeated string repeated_str = 103; |
| 127 | repeated Simple1 repeated_simple = 104; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | extend HasExtensions { |
| 132 | optional Simple1 simple1 = 105; |
| 133 | } |
| 134 | |
| 135 | message DefaultValues { |
| 136 | enum Enum { |
| 137 | E1 = 13; |
| 138 | E2 = 77; |
| 139 | } |
| 140 | optional string string_field = 1 [default="default<>\'\"abc"]; |
| 141 | optional bool bool_field = 2 [default=true]; |
| 142 | optional int64 int_field = 3 [default=11]; |
| 143 | optional Enum enum_field = 4 [default=E1]; |
| 144 | optional string empty_field = 6 [default=""]; |
| 145 | optional bytes bytes_field = 8 [default="moo"]; // Base64 encoding is "bW9v" |
| 146 | } |
| 147 | |
Jisi Liu | 3b3c8ab | 2016-03-30 11:39:59 -0700 | [diff] [blame] | 148 | message FloatingPointFields { |
| 149 | optional float optional_float_field = 1; |
| 150 | required float required_float_field = 2; |
| 151 | repeated float repeated_float_field = 3; |
| 152 | optional float default_float_field = 4 [default = 2.0]; |
| 153 | optional double optional_double_field = 5; |
| 154 | required double required_double_field = 6; |
| 155 | repeated double repeated_double_field = 7; |
| 156 | optional double default_double_field = 8 [default = 2.0]; |
| 157 | } |
| 158 | |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 159 | message TestClone { |
| 160 | optional string str = 1; |
| 161 | optional Simple1 simple1 = 3; |
| 162 | repeated Simple1 simple2 = 5; |
Adam Cozzette | d64a2d9 | 2016-06-29 15:23:27 -0700 | [diff] [blame] | 163 | optional bytes bytes_field = 6; |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 164 | optional string unused = 7; |
| 165 | extensions 10 to max; |
| 166 | } |
| 167 | |
Feng Xiao | 6bbe197 | 2018-08-08 17:00:41 -0700 | [diff] [blame] | 168 | message TestCloneExtension { |
| 169 | extend TestClone { |
| 170 | optional TestCloneExtension low_ext = 11; |
| 171 | } |
| 172 | optional int32 f = 1; |
| 173 | } |
| 174 | |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 175 | message CloneExtension { |
| 176 | extend TestClone { |
| 177 | optional CloneExtension ext_field = 100; |
| 178 | } |
| 179 | optional string ext = 2; |
| 180 | } |
| 181 | |
| 182 | message TestGroup { |
| 183 | repeated group RepeatedGroup = 1 { |
| 184 | required string id = 1; |
| 185 | repeated bool some_bool = 2; |
| 186 | } |
| 187 | required group RequiredGroup = 2 { |
| 188 | required string id = 1; |
| 189 | } |
| 190 | optional group OptionalGroup = 3 { |
| 191 | required string id = 1; |
| 192 | } |
| 193 | optional string id = 4; |
| 194 | required Simple2 required_simple = 5; |
| 195 | optional Simple2 optional_simple = 6; |
| 196 | } |
| 197 | |
| 198 | message TestGroup1 { |
| 199 | optional TestGroup.RepeatedGroup group = 1; |
| 200 | } |
| 201 | |
| 202 | message TestReservedNames { |
| 203 | optional int32 extension = 1; |
| 204 | extensions 10 to max; |
| 205 | } |
| 206 | |
| 207 | message TestReservedNamesExtension { |
| 208 | extend TestReservedNames { |
| 209 | optional int32 foo = 10; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | message TestMessageWithOneof { |
| 214 | |
| 215 | oneof partial_oneof { |
| 216 | string pone = 3; |
| 217 | string pthree = 5; |
| 218 | } |
| 219 | |
| 220 | oneof recursive_oneof { |
| 221 | TestMessageWithOneof rone = 6; |
| 222 | string rtwo = 7; |
| 223 | } |
| 224 | |
| 225 | optional bool normal_field = 8; |
| 226 | repeated string repeated_field = 9; |
| 227 | |
| 228 | oneof default_oneof_a { |
| 229 | int32 aone = 10 [default = 1234]; |
| 230 | int32 atwo = 11; |
| 231 | } |
| 232 | |
| 233 | oneof default_oneof_b { |
| 234 | int32 bone = 12; |
| 235 | int32 btwo = 13 [default = 1234]; |
| 236 | } |
| 237 | } |
Jisi Liu | 3b3c8ab | 2016-03-30 11:39:59 -0700 | [diff] [blame] | 238 | |
Adam Cozzette | c64d86e | 2016-07-06 12:04:49 -0700 | [diff] [blame] | 239 | message TestEndsWithBytes { |
| 240 | optional int32 value = 1; |
| 241 | optional bytes data = 2; |
| 242 | } |
Feng Xiao | 9086d96 | 2016-07-13 13:47:51 -0700 | [diff] [blame] | 243 | |
Adam Cozzette | 0894e07 | 2018-11-09 11:28:22 -0800 | [diff] [blame] | 244 | // This message is for testing extension handling doesn't affect fields before |
| 245 | // pivot. Don't add new field to this message. See b/117298778 for more detail. |
| 246 | message TestLastFieldBeforePivot { |
| 247 | optional int32 last_field_before_pivot = 1; |
| 248 | extensions 100 to max; |
| 249 | } |
| 250 | |
| 251 | extend TestLastFieldBeforePivot { |
| 252 | optional int32 extend_test_last_field_before_pivot_field = 101; |
| 253 | } |
| 254 | |
Adam Cozzette | 5a76e63 | 2016-11-17 16:48:38 -0800 | [diff] [blame] | 255 | |
Jisi Liu | 09354db | 2017-07-18 15:38:30 -0700 | [diff] [blame] | 256 | message Int64Types { |
| 257 | optional int64 int64_normal = 1 [jstype=JS_NORMAL]; |
| 258 | optional sint64 int64_string = 2 [jstype=JS_STRING]; |
| 259 | optional uint64 int64_number = 3 [jstype=JS_NUMBER]; |
| 260 | |
| 261 | } |
| 262 | |
Joshua Haberman | af62fde | 2016-09-20 13:56:18 -0700 | [diff] [blame] | 263 | message TestMapFieldsNoBinary { |
Adam Cozzette | 5a76e63 | 2016-11-17 16:48:38 -0800 | [diff] [blame] | 264 | |
Joshua Haberman | af62fde | 2016-09-20 13:56:18 -0700 | [diff] [blame] | 265 | map<string, string> map_string_string = 1; |
| 266 | map<string, int32> map_string_int32 = 2; |
| 267 | map<string, int64> map_string_int64 = 3; |
| 268 | map<string, bool> map_string_bool = 4; |
| 269 | map<string, double> map_string_double = 5; |
| 270 | map<string, MapValueEnumNoBinary> map_string_enum = 6; |
| 271 | map<string, MapValueMessageNoBinary> map_string_msg = 7; |
| 272 | |
| 273 | map<int32, string> map_int32_string = 8; |
| 274 | map<int64, string> map_int64_string = 9; |
| 275 | map<bool, string> map_bool_string = 10; |
| 276 | |
| 277 | optional TestMapFieldsNoBinary test_map_fields = 11; |
| 278 | map<string, TestMapFieldsNoBinary> map_string_testmapfields = 12; |
| 279 | } |
| 280 | |
| 281 | enum MapValueEnumNoBinary { |
Adam Cozzette | b4dd686 | 2016-11-18 10:22:46 -0800 | [diff] [blame] | 282 | MAP_VALUE_FOO_NOBINARY = 0; |
| 283 | MAP_VALUE_BAR_NOBINARY = 1; |
| 284 | MAP_VALUE_BAZ_NOBINARY = 2; |
Joshua Haberman | af62fde | 2016-09-20 13:56:18 -0700 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | message MapValueMessageNoBinary { |
Adam Cozzette | 5a76e63 | 2016-11-17 16:48:38 -0800 | [diff] [blame] | 288 | |
Joshua Haberman | af62fde | 2016-09-20 13:56:18 -0700 | [diff] [blame] | 289 | optional int32 foo = 1; |
| 290 | } |
Adam Cozzette | 4a4a162 | 2016-09-27 15:36:41 -0700 | [diff] [blame] | 291 | |
| 292 | message Deeply { |
| 293 | message Nested { |
| 294 | message Message { |
| 295 | optional int32 count = 1; |
| 296 | } |
| 297 | } |
| 298 | } |
Jisi Liu | 09354db | 2017-07-18 15:38:30 -0700 | [diff] [blame] | 299 | |