Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [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: kenton@google.com (Kenton Varda) |
| 32 | // |
| 33 | // This is like unittest.proto but with optimize_for = LITE_RUNTIME. |
| 34 | |
| 35 | syntax = "proto2"; |
| 36 | package protobuf_unittest; |
| 37 | |
| 38 | import "google/protobuf/unittest_import_lite.proto"; |
| 39 | |
| 40 | option optimize_for = LITE_RUNTIME; |
| 41 | |
| 42 | option java_package = "com.google.protobuf"; |
| 43 | |
| 44 | // Same as TestAllTypes but with the lite runtime. |
| 45 | message TestAllTypesLite { |
| 46 | message NestedMessage { |
| 47 | optional int32 bb = 1; |
| 48 | } |
| 49 | |
| 50 | enum NestedEnum { |
| 51 | FOO = 1; |
| 52 | BAR = 2; |
| 53 | BAZ = 3; |
| 54 | } |
| 55 | |
| 56 | // Singular |
| 57 | optional int32 optional_int32 = 1; |
| 58 | optional int64 optional_int64 = 2; |
| 59 | optional uint32 optional_uint32 = 3; |
| 60 | optional uint64 optional_uint64 = 4; |
| 61 | optional sint32 optional_sint32 = 5; |
| 62 | optional sint64 optional_sint64 = 6; |
| 63 | optional fixed32 optional_fixed32 = 7; |
| 64 | optional fixed64 optional_fixed64 = 8; |
| 65 | optional sfixed32 optional_sfixed32 = 9; |
| 66 | optional sfixed64 optional_sfixed64 = 10; |
| 67 | optional float optional_float = 11; |
| 68 | optional double optional_double = 12; |
| 69 | optional bool optional_bool = 13; |
| 70 | optional string optional_string = 14; |
| 71 | optional bytes optional_bytes = 15; |
| 72 | |
| 73 | optional group OptionalGroup = 16 { |
| 74 | optional int32 a = 17; |
| 75 | } |
| 76 | |
| 77 | optional NestedMessage optional_nested_message = 18; |
| 78 | optional ForeignMessageLite optional_foreign_message = 19; |
| 79 | optional protobuf_unittest_import.ImportMessageLite |
| 80 | optional_import_message = 20; |
| 81 | |
| 82 | optional NestedEnum optional_nested_enum = 21; |
| 83 | optional ForeignEnumLite optional_foreign_enum = 22; |
| 84 | optional protobuf_unittest_import.ImportEnumLite optional_import_enum = 23; |
| 85 | |
| 86 | optional string optional_string_piece = 24 [ctype=STRING_PIECE]; |
| 87 | optional string optional_cord = 25 [ctype=CORD]; |
| 88 | |
| 89 | // Defined in unittest_import_public.proto |
| 90 | optional protobuf_unittest_import.PublicImportMessageLite |
| 91 | optional_public_import_message = 26; |
| 92 | |
| 93 | optional NestedMessage optional_lazy_message = 27 [lazy=true]; |
| 94 | |
| 95 | // Repeated |
| 96 | repeated int32 repeated_int32 = 31; |
| 97 | repeated int64 repeated_int64 = 32; |
| 98 | repeated uint32 repeated_uint32 = 33; |
| 99 | repeated uint64 repeated_uint64 = 34; |
| 100 | repeated sint32 repeated_sint32 = 35; |
| 101 | repeated sint64 repeated_sint64 = 36; |
| 102 | repeated fixed32 repeated_fixed32 = 37; |
| 103 | repeated fixed64 repeated_fixed64 = 38; |
| 104 | repeated sfixed32 repeated_sfixed32 = 39; |
| 105 | repeated sfixed64 repeated_sfixed64 = 40; |
| 106 | repeated float repeated_float = 41; |
| 107 | repeated double repeated_double = 42; |
| 108 | repeated bool repeated_bool = 43; |
| 109 | repeated string repeated_string = 44; |
| 110 | repeated bytes repeated_bytes = 45; |
| 111 | |
| 112 | repeated group RepeatedGroup = 46 { |
| 113 | optional int32 a = 47; |
| 114 | } |
| 115 | |
| 116 | repeated NestedMessage repeated_nested_message = 48; |
| 117 | repeated ForeignMessageLite repeated_foreign_message = 49; |
| 118 | repeated protobuf_unittest_import.ImportMessageLite |
| 119 | repeated_import_message = 50; |
| 120 | |
| 121 | repeated NestedEnum repeated_nested_enum = 51; |
| 122 | repeated ForeignEnumLite repeated_foreign_enum = 52; |
| 123 | repeated protobuf_unittest_import.ImportEnumLite repeated_import_enum = 53; |
| 124 | |
| 125 | repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; |
| 126 | repeated string repeated_cord = 55 [ctype=CORD]; |
| 127 | |
| 128 | repeated NestedMessage repeated_lazy_message = 57 [lazy=true]; |
| 129 | |
| 130 | // Singular with defaults |
| 131 | optional int32 default_int32 = 61 [default = 41 ]; |
| 132 | optional int64 default_int64 = 62 [default = 42 ]; |
| 133 | optional uint32 default_uint32 = 63 [default = 43 ]; |
| 134 | optional uint64 default_uint64 = 64 [default = 44 ]; |
| 135 | optional sint32 default_sint32 = 65 [default = -45 ]; |
| 136 | optional sint64 default_sint64 = 66 [default = 46 ]; |
| 137 | optional fixed32 default_fixed32 = 67 [default = 47 ]; |
| 138 | optional fixed64 default_fixed64 = 68 [default = 48 ]; |
| 139 | optional sfixed32 default_sfixed32 = 69 [default = 49 ]; |
| 140 | optional sfixed64 default_sfixed64 = 70 [default = -50 ]; |
| 141 | optional float default_float = 71 [default = 51.5 ]; |
| 142 | optional double default_double = 72 [default = 52e3 ]; |
| 143 | optional bool default_bool = 73 [default = true ]; |
| 144 | optional string default_string = 74 [default = "hello"]; |
| 145 | optional bytes default_bytes = 75 [default = "world"]; |
| 146 | |
| 147 | optional NestedEnum default_nested_enum = 81 [default = BAR]; |
| 148 | optional ForeignEnumLite default_foreign_enum = 82 |
| 149 | [default = FOREIGN_LITE_BAR]; |
| 150 | optional protobuf_unittest_import.ImportEnumLite |
| 151 | default_import_enum = 83 [default = IMPORT_LITE_BAR]; |
| 152 | |
| 153 | optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"]; |
| 154 | optional string default_cord = 85 [ctype=CORD,default="123"]; |
| 155 | |
| 156 | // For oneof test |
| 157 | oneof oneof_field { |
| 158 | uint32 oneof_uint32 = 111; |
| 159 | NestedMessage oneof_nested_message = 112; |
| 160 | string oneof_string = 113; |
| 161 | bytes oneof_bytes = 114; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | message ForeignMessageLite { |
| 166 | optional int32 c = 1; |
| 167 | } |
| 168 | |
| 169 | enum ForeignEnumLite { |
| 170 | FOREIGN_LITE_FOO = 4; |
| 171 | FOREIGN_LITE_BAR = 5; |
| 172 | FOREIGN_LITE_BAZ = 6; |
| 173 | } |
| 174 | |
| 175 | message TestPackedTypesLite { |
| 176 | repeated int32 packed_int32 = 90 [packed = true]; |
| 177 | repeated int64 packed_int64 = 91 [packed = true]; |
| 178 | repeated uint32 packed_uint32 = 92 [packed = true]; |
| 179 | repeated uint64 packed_uint64 = 93 [packed = true]; |
| 180 | repeated sint32 packed_sint32 = 94 [packed = true]; |
| 181 | repeated sint64 packed_sint64 = 95 [packed = true]; |
| 182 | repeated fixed32 packed_fixed32 = 96 [packed = true]; |
| 183 | repeated fixed64 packed_fixed64 = 97 [packed = true]; |
| 184 | repeated sfixed32 packed_sfixed32 = 98 [packed = true]; |
| 185 | repeated sfixed64 packed_sfixed64 = 99 [packed = true]; |
| 186 | repeated float packed_float = 100 [packed = true]; |
| 187 | repeated double packed_double = 101 [packed = true]; |
| 188 | repeated bool packed_bool = 102 [packed = true]; |
| 189 | repeated ForeignEnumLite packed_enum = 103 [packed = true]; |
| 190 | } |
| 191 | |
| 192 | message TestAllExtensionsLite { |
| 193 | extensions 1 to max; |
| 194 | } |
| 195 | |
| 196 | extend TestAllExtensionsLite { |
| 197 | // Singular |
| 198 | optional int32 optional_int32_extension_lite = 1; |
| 199 | optional int64 optional_int64_extension_lite = 2; |
| 200 | optional uint32 optional_uint32_extension_lite = 3; |
| 201 | optional uint64 optional_uint64_extension_lite = 4; |
| 202 | optional sint32 optional_sint32_extension_lite = 5; |
| 203 | optional sint64 optional_sint64_extension_lite = 6; |
| 204 | optional fixed32 optional_fixed32_extension_lite = 7; |
| 205 | optional fixed64 optional_fixed64_extension_lite = 8; |
| 206 | optional sfixed32 optional_sfixed32_extension_lite = 9; |
| 207 | optional sfixed64 optional_sfixed64_extension_lite = 10; |
| 208 | optional float optional_float_extension_lite = 11; |
| 209 | optional double optional_double_extension_lite = 12; |
| 210 | optional bool optional_bool_extension_lite = 13; |
| 211 | optional string optional_string_extension_lite = 14; |
| 212 | optional bytes optional_bytes_extension_lite = 15; |
| 213 | |
| 214 | optional group OptionalGroup_extension_lite = 16 { |
| 215 | optional int32 a = 17; |
| 216 | } |
| 217 | |
| 218 | optional TestAllTypesLite.NestedMessage optional_nested_message_extension_lite |
| 219 | = 18; |
| 220 | optional ForeignMessageLite optional_foreign_message_extension_lite = 19; |
| 221 | optional protobuf_unittest_import.ImportMessageLite |
| 222 | optional_import_message_extension_lite = 20; |
| 223 | |
| 224 | optional TestAllTypesLite.NestedEnum optional_nested_enum_extension_lite = 21; |
| 225 | optional ForeignEnumLite optional_foreign_enum_extension_lite = 22; |
| 226 | optional protobuf_unittest_import.ImportEnumLite |
| 227 | optional_import_enum_extension_lite = 23; |
| 228 | |
| 229 | optional string optional_string_piece_extension_lite = 24 |
| 230 | [ctype=STRING_PIECE]; |
| 231 | optional string optional_cord_extension_lite = 25 [ctype=CORD]; |
| 232 | |
| 233 | optional protobuf_unittest_import.PublicImportMessageLite |
| 234 | optional_public_import_message_extension_lite = 26; |
| 235 | |
| 236 | optional TestAllTypesLite.NestedMessage |
| 237 | optional_lazy_message_extension_lite = 27 [lazy=true]; |
| 238 | |
| 239 | // Repeated |
| 240 | repeated int32 repeated_int32_extension_lite = 31; |
| 241 | repeated int64 repeated_int64_extension_lite = 32; |
| 242 | repeated uint32 repeated_uint32_extension_lite = 33; |
| 243 | repeated uint64 repeated_uint64_extension_lite = 34; |
| 244 | repeated sint32 repeated_sint32_extension_lite = 35; |
| 245 | repeated sint64 repeated_sint64_extension_lite = 36; |
| 246 | repeated fixed32 repeated_fixed32_extension_lite = 37; |
| 247 | repeated fixed64 repeated_fixed64_extension_lite = 38; |
| 248 | repeated sfixed32 repeated_sfixed32_extension_lite = 39; |
| 249 | repeated sfixed64 repeated_sfixed64_extension_lite = 40; |
| 250 | repeated float repeated_float_extension_lite = 41; |
| 251 | repeated double repeated_double_extension_lite = 42; |
| 252 | repeated bool repeated_bool_extension_lite = 43; |
| 253 | repeated string repeated_string_extension_lite = 44; |
| 254 | repeated bytes repeated_bytes_extension_lite = 45; |
| 255 | |
| 256 | repeated group RepeatedGroup_extension_lite = 46 { |
| 257 | optional int32 a = 47; |
| 258 | } |
| 259 | |
| 260 | repeated TestAllTypesLite.NestedMessage repeated_nested_message_extension_lite |
| 261 | = 48; |
| 262 | repeated ForeignMessageLite repeated_foreign_message_extension_lite = 49; |
| 263 | repeated protobuf_unittest_import.ImportMessageLite |
| 264 | repeated_import_message_extension_lite = 50; |
| 265 | |
| 266 | repeated TestAllTypesLite.NestedEnum repeated_nested_enum_extension_lite = 51; |
| 267 | repeated ForeignEnumLite repeated_foreign_enum_extension_lite = 52; |
| 268 | repeated protobuf_unittest_import.ImportEnumLite |
| 269 | repeated_import_enum_extension_lite = 53; |
| 270 | |
| 271 | repeated string repeated_string_piece_extension_lite = 54 |
| 272 | [ctype=STRING_PIECE]; |
| 273 | repeated string repeated_cord_extension_lite = 55 [ctype=CORD]; |
| 274 | |
| 275 | repeated TestAllTypesLite.NestedMessage |
| 276 | repeated_lazy_message_extension_lite = 57 [lazy=true]; |
| 277 | |
| 278 | // Singular with defaults |
| 279 | optional int32 default_int32_extension_lite = 61 [default = 41 ]; |
| 280 | optional int64 default_int64_extension_lite = 62 [default = 42 ]; |
| 281 | optional uint32 default_uint32_extension_lite = 63 [default = 43 ]; |
| 282 | optional uint64 default_uint64_extension_lite = 64 [default = 44 ]; |
| 283 | optional sint32 default_sint32_extension_lite = 65 [default = -45 ]; |
| 284 | optional sint64 default_sint64_extension_lite = 66 [default = 46 ]; |
| 285 | optional fixed32 default_fixed32_extension_lite = 67 [default = 47 ]; |
| 286 | optional fixed64 default_fixed64_extension_lite = 68 [default = 48 ]; |
| 287 | optional sfixed32 default_sfixed32_extension_lite = 69 [default = 49 ]; |
| 288 | optional sfixed64 default_sfixed64_extension_lite = 70 [default = -50 ]; |
| 289 | optional float default_float_extension_lite = 71 [default = 51.5 ]; |
| 290 | optional double default_double_extension_lite = 72 [default = 52e3 ]; |
| 291 | optional bool default_bool_extension_lite = 73 [default = true ]; |
| 292 | optional string default_string_extension_lite = 74 [default = "hello"]; |
| 293 | optional bytes default_bytes_extension_lite = 75 [default = "world"]; |
| 294 | |
| 295 | optional TestAllTypesLite.NestedEnum |
| 296 | default_nested_enum_extension_lite = 81 [default = BAR]; |
| 297 | optional ForeignEnumLite |
| 298 | default_foreign_enum_extension_lite = 82 [default = FOREIGN_LITE_BAR]; |
| 299 | optional protobuf_unittest_import.ImportEnumLite |
| 300 | default_import_enum_extension_lite = 83 [default = IMPORT_LITE_BAR]; |
| 301 | |
| 302 | optional string default_string_piece_extension_lite = 84 [ctype=STRING_PIECE, |
| 303 | default="abc"]; |
| 304 | optional string default_cord_extension_lite = 85 [ctype=CORD, default="123"]; |
| 305 | |
| 306 | // For oneof test |
| 307 | optional uint32 oneof_uint32_extension_lite = 111; |
| 308 | optional TestAllTypesLite.NestedMessage oneof_nested_message_extension_lite = 112; |
| 309 | optional string oneof_string_extension_lite = 113; |
| 310 | optional bytes oneof_bytes_extension_lite = 114; |
| 311 | } |
| 312 | |
| 313 | message TestPackedExtensionsLite { |
| 314 | extensions 1 to max; |
| 315 | } |
| 316 | |
| 317 | extend TestPackedExtensionsLite { |
| 318 | repeated int32 packed_int32_extension_lite = 90 [packed = true]; |
| 319 | repeated int64 packed_int64_extension_lite = 91 [packed = true]; |
| 320 | repeated uint32 packed_uint32_extension_lite = 92 [packed = true]; |
| 321 | repeated uint64 packed_uint64_extension_lite = 93 [packed = true]; |
| 322 | repeated sint32 packed_sint32_extension_lite = 94 [packed = true]; |
| 323 | repeated sint64 packed_sint64_extension_lite = 95 [packed = true]; |
| 324 | repeated fixed32 packed_fixed32_extension_lite = 96 [packed = true]; |
| 325 | repeated fixed64 packed_fixed64_extension_lite = 97 [packed = true]; |
| 326 | repeated sfixed32 packed_sfixed32_extension_lite = 98 [packed = true]; |
| 327 | repeated sfixed64 packed_sfixed64_extension_lite = 99 [packed = true]; |
| 328 | repeated float packed_float_extension_lite = 100 [packed = true]; |
| 329 | repeated double packed_double_extension_lite = 101 [packed = true]; |
| 330 | repeated bool packed_bool_extension_lite = 102 [packed = true]; |
| 331 | repeated ForeignEnumLite packed_enum_extension_lite = 103 [packed = true]; |
| 332 | } |
| 333 | |
| 334 | message TestNestedExtensionLite { |
| 335 | extend TestAllExtensionsLite { |
| 336 | optional int32 nested_extension = 12345; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | // Test that deprecated fields work. We only verify that they compile (at one |
| 341 | // point this failed). |
| 342 | message TestDeprecatedLite { |
| 343 | optional int32 deprecated_field = 1 [deprecated = true]; |
| 344 | } |
| 345 | |
| 346 | // See the comments of the same type in unittest.proto. |
| 347 | message TestParsingMergeLite { |
| 348 | message RepeatedFieldsGenerator { |
| 349 | repeated TestAllTypesLite field1 = 1; |
| 350 | repeated TestAllTypesLite field2 = 2; |
| 351 | repeated TestAllTypesLite field3 = 3; |
| 352 | repeated group Group1 = 10 { |
| 353 | optional TestAllTypesLite field1 = 11; |
| 354 | } |
| 355 | repeated group Group2 = 20 { |
| 356 | optional TestAllTypesLite field1 = 21; |
| 357 | } |
| 358 | repeated TestAllTypesLite ext1 = 1000; |
| 359 | repeated TestAllTypesLite ext2 = 1001; |
| 360 | } |
| 361 | required TestAllTypesLite required_all_types = 1; |
| 362 | optional TestAllTypesLite optional_all_types = 2; |
| 363 | repeated TestAllTypesLite repeated_all_types = 3; |
| 364 | optional group OptionalGroup = 10 { |
| 365 | optional TestAllTypesLite optional_group_all_types = 11; |
| 366 | } |
| 367 | repeated group RepeatedGroup = 20 { |
| 368 | optional TestAllTypesLite repeated_group_all_types = 21; |
| 369 | } |
| 370 | extensions 1000 to max; |
| 371 | extend TestParsingMergeLite { |
| 372 | optional TestAllTypesLite optional_ext = 1000; |
| 373 | repeated TestAllTypesLite repeated_ext = 1001; |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | // TestEmptyMessageLite is used to test unknown fields support in lite mode. |
| 378 | message TestEmptyMessageLite{ |
| 379 | } |
| 380 | |
| 381 | // Like above, but declare all field numbers as potential extensions. No |
| 382 | // actual extensions should ever be defined for this type. |
| 383 | message TestEmptyMessageWithExtensionsLite { |
| 384 | extensions 1 to max; |
| 385 | } |