OLD | NEW |
(Empty) | |
| 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2011 Google Inc. All rights reserved. |
| 3 // |
| 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are |
| 6 // met: |
| 7 // |
| 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above |
| 11 // copyright notice, this list of conditions and the following disclaimer |
| 12 // in the documentation and/or other materials provided with the |
| 13 // distribution. |
| 14 // * Neither the name of Google Inc. nor the names of its |
| 15 // contributors may be used to endorse or promote products derived from |
| 16 // this software without specific prior written permission. |
| 17 // |
| 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 |
| 30 syntax = "proto2"; |
| 31 |
| 32 import "google/protobuf/unittest.proto"; |
| 33 |
| 34 package protobuf_unittest; |
| 35 |
| 36 // Using the messages in unittest.proto, setup for recursive cases for testing |
| 37 // extensions at various depths. |
| 38 extend TestAllExtensions { |
| 39 optional TestAllExtensions recursive_extension = 86; |
| 40 } |
| 41 |
| 42 // Recursive message to for testing autocreators at different depths. |
| 43 message TestRecursiveMessageWithRepeatedField { |
| 44 optional TestRecursiveMessageWithRepeatedField a = 1; |
| 45 repeated int32 i = 2; |
| 46 repeated string str = 3; |
| 47 map<int32, int32> i_to_i = 4; |
| 48 map<string, string> str_to_str = 5; |
| 49 } |
| 50 |
| 51 // Recursive message and extension to for testing autocreators at different |
| 52 // depths. |
| 53 message TestRecursiveExtension { |
| 54 optional TestRecursiveExtension recursive_sub_message = 1; |
| 55 repeated int32 repeated_value = 2; |
| 56 extensions 1000 to max; |
| 57 } |
| 58 |
| 59 extend TestRecursiveExtension { |
| 60 optional TestRecursiveExtension recursive_message_extension = 1000; |
| 61 } |
| 62 |
| 63 message self { |
| 64 message super { |
| 65 optional int32 description = 1; |
| 66 } |
| 67 |
| 68 enum autorelease { |
| 69 retain = 1; |
| 70 release = 2; |
| 71 retainCount = 3; |
| 72 } |
| 73 |
| 74 // Singular |
| 75 optional bool id = 1; |
| 76 optional bool _cmd = 2; |
| 77 optional bool in = 3; |
| 78 optional bool out = 4; |
| 79 optional bool inout = 5; |
| 80 optional bool bycopy = 6; |
| 81 optional bool byref = 7; |
| 82 optional bool oneway = 8; |
| 83 optional bool dealloc = 9; |
| 84 optional bool zone = 10; |
| 85 optional bool isProxy = 11; |
| 86 optional bool copy = 12; |
| 87 optional bool readonly = 13; |
| 88 optional bool default = 14; |
| 89 optional bool assign = 15; |
| 90 optional bool getter = 16; |
| 91 optional bool setter = 17; |
| 92 optional bool weak = 18; |
| 93 optional bool public = 19; |
| 94 optional bool case = 20; |
| 95 |
| 96 optional autorelease SubEnum = 25; |
| 97 |
| 98 optional group New = 50 { |
| 99 optional string copy = 51; |
| 100 } |
| 101 optional group MutableCopy = 60 { |
| 102 optional int32 extensionRegistry = 61; |
| 103 } |
| 104 |
| 105 extensions 90 to 94; |
| 106 |
| 107 } |
| 108 |
| 109 enum retain { |
| 110 count = 4; |
| 111 initialized = 5; |
| 112 serializedSize = 6; |
| 113 } |
| 114 |
| 115 // EnumValueShortName: The short names shouldn't get suffixes/prefixes. |
| 116 enum Foo { |
| 117 SERIALIZED_SIZE = 1; |
| 118 SIZE = 2; |
| 119 OTHER = 3; |
| 120 } |
| 121 |
| 122 // EnumValueShortName: The enum name gets a prefix. |
| 123 enum Category { |
| 124 RED = 1; |
| 125 BLUE = 2; |
| 126 } |
| 127 |
| 128 // EnumValueShortName: Twist case, full name gets PB, but the short names |
| 129 // should still end up correct. |
| 130 enum Time { |
| 131 BASE = 1; |
| 132 RECORD = 2; |
| 133 SOMETHING_ELSE = 3; |
| 134 } |
| 135 |
| 136 extend self { |
| 137 repeated int32 debugDescription = 90 [packed = true]; |
| 138 repeated int64 finalize = 91 [packed = true]; |
| 139 repeated uint32 hash = 92 [packed = true]; |
| 140 repeated uint64 classForCoder = 93 [packed = true]; |
| 141 repeated sint32 byref = 94 [packed = true]; |
| 142 } |
| 143 |
| 144 // Test handing of fields that start with init* since Xcode 5's ARC support |
| 145 // doesn't like messages that look like initializers but aren't. |
| 146 message ObjCInitFoo { |
| 147 optional string init_val = 11; |
| 148 optional int32 init_size = 12; |
| 149 optional self init_self = 13; |
| 150 |
| 151 repeated string init_vals = 21; |
| 152 repeated int32 init_sizes = 22; |
| 153 repeated self init_selfs = 23; |
| 154 } |
| 155 |
| 156 // Test handling of fields that start with retained names. |
| 157 message ObjCRetainedFoo { |
| 158 optional string new_val_lower_complex = 11; |
| 159 optional string new_Val_upper_complex = 12; |
| 160 optional string newvalue_lower_no_underscore_complex = 13; |
| 161 optional string newValue_upper_no_underscore_complex = 14; |
| 162 |
| 163 optional int32 new_val_lower_primitive = 15; |
| 164 optional int32 new_Val_upper_primitive = 16; |
| 165 optional int32 newvalue_lower_no_underscore_primitive = 17; |
| 166 optional int32 newValue_upper_no_underscore_primitive = 18; |
| 167 |
| 168 optional self new_val_lower_message = 19; |
| 169 optional self new_Val_upper_message = 20; |
| 170 optional self newvalue_lower_no_underscore_message = 21; |
| 171 optional self newValue_upper_no_underscore_message = 22; |
| 172 |
| 173 optional Foo new_val_lower_enum = 23; |
| 174 optional Foo new_Val_upper_enum = 24; |
| 175 optional Foo newvalue_lower_no_underscore_enum = 25; |
| 176 optional Foo newValue_upper_no_underscore_enum = 26; |
| 177 |
| 178 repeated string new_val_lower_complex_repeated = 111; |
| 179 repeated string new_Val_upper_complex_repeated = 112; |
| 180 repeated string newvalue_lower_no_underscore_complex_repeated = 113; |
| 181 repeated string newValue_upper_no_underscore_complex_repeated = 114; |
| 182 |
| 183 repeated int32 new_val_lower_primitive_repeated = 115; |
| 184 repeated int32 new_Val_upper_primitive_repeated = 116; |
| 185 repeated int32 newvalue_lower_no_underscore_primitive_repeated = 117; |
| 186 repeated int32 newValue_upper_no_underscore_primitive_repeated = 118; |
| 187 |
| 188 repeated self new_val_lower_message_repeated = 119; |
| 189 repeated self new_Val_upper_message_repeated = 120; |
| 190 repeated self newvalue_lower_no_underscore_message_repeated = 121; |
| 191 repeated self newValue_upper_no_underscore_message_repeated = 122; |
| 192 |
| 193 repeated Foo new_val_lower_enum_repeated = 123; |
| 194 repeated Foo new_Val_upper_enum_repeated = 124; |
| 195 repeated Foo newvalue_lower_no_underscore_enum_repeated = 125; |
| 196 repeated Foo newValue_upper_no_underscore_enum_repeated = 126; |
| 197 |
| 198 optional string alloc_val_lower_complex = 211; |
| 199 optional string alloc_Val_upper_complex = 212; |
| 200 optional string allocvalue_lower_no_underscore_complex = 213; |
| 201 optional string allocValue_upper_no_underscore_complex = 214; |
| 202 |
| 203 optional int32 alloc_val_lower_primitive = 215; |
| 204 optional int32 alloc_Val_upper_primitive = 216; |
| 205 optional int32 allocvalue_lower_no_underscore_primitive = 217; |
| 206 optional int32 allocValue_upper_no_underscore_primitive = 218; |
| 207 |
| 208 optional self alloc_val_lower_message = 219; |
| 209 optional self alloc_Val_upper_message = 220; |
| 210 optional self allocvalue_lower_no_underscore_message = 221; |
| 211 optional self allocValue_upper_no_underscore_message = 222; |
| 212 |
| 213 optional Foo alloc_val_lower_enum = 223; |
| 214 optional Foo alloc_Val_upper_enum = 224; |
| 215 optional Foo allocvalue_lower_no_underscore_enum = 225; |
| 216 optional Foo allocValue_upper_no_underscore_enum = 226; |
| 217 |
| 218 repeated string alloc_val_lower_complex_repeated = 311; |
| 219 repeated string alloc_Val_upper_complex_repeated = 312; |
| 220 repeated string allocvalue_lower_no_underscore_complex_repeated = 313; |
| 221 repeated string allocValue_upper_no_underscore_complex_repeated = 314; |
| 222 |
| 223 repeated int32 alloc_val_lower_primitive_repeated = 315; |
| 224 repeated int32 alloc_Val_upper_primitive_repeated = 316; |
| 225 repeated int32 allocvalue_lower_no_underscore_primitive_repeated = 317; |
| 226 repeated int32 allocValue_upper_no_underscore_primitive_repeated = 318; |
| 227 |
| 228 repeated self alloc_val_lower_message_repeated = 319; |
| 229 repeated self alloc_Val_upper_message_repeated = 320; |
| 230 repeated self allocvalue_lower_no_underscore_message_repeated = 321; |
| 231 repeated self allocValue_upper_no_underscore_message_repeated = 322; |
| 232 |
| 233 repeated Foo alloc_val_lower_enum_repeated = 323; |
| 234 repeated Foo alloc_Val_upper_enum_repeated = 324; |
| 235 repeated Foo allocvalue_lower_no_underscore_enum_repeated = 325; |
| 236 repeated Foo allocValue_upper_no_underscore_enum_repeated = 326; |
| 237 |
| 238 optional string copy_val_lower_complex = 411; |
| 239 optional string copy_Val_upper_complex = 412; |
| 240 optional string copyvalue_lower_no_underscore_complex = 413; |
| 241 optional string copyValue_upper_no_underscore_complex = 414; |
| 242 |
| 243 optional int32 copy_val_lower_primitive = 415; |
| 244 optional int32 copy_Val_upper_primitive = 416; |
| 245 optional int32 copyvalue_lower_no_underscore_primitive = 417; |
| 246 optional int32 copyValue_upper_no_underscore_primitive = 418; |
| 247 |
| 248 optional self copy_val_lower_message = 419; |
| 249 optional self copy_Val_upper_message = 420; |
| 250 optional self copyvalue_lower_no_underscore_message = 421; |
| 251 optional self copyValue_upper_no_underscore_message = 422; |
| 252 |
| 253 optional Foo copy_val_lower_enum = 423; |
| 254 optional Foo copy_Val_upper_enum = 424; |
| 255 optional Foo copyvalue_lower_no_underscore_enum = 425; |
| 256 optional Foo copyValue_upper_no_underscore_enum = 426; |
| 257 |
| 258 repeated string copy_val_lower_complex_repeated = 511; |
| 259 repeated string copy_Val_upper_complex_repeated = 512; |
| 260 repeated string copyvalue_lower_no_underscore_complex_repeated = 513; |
| 261 repeated string copyValue_upper_no_underscore_complex_repeated = 514; |
| 262 |
| 263 repeated int32 copy_val_lower_primitive_repeated = 515; |
| 264 repeated int32 copy_Val_upper_primitive_repeated = 516; |
| 265 repeated int32 copyvalue_lower_no_underscore_primitive_repeated = 517; |
| 266 repeated int32 copyValue_upper_no_underscore_primitive_repeated = 518; |
| 267 |
| 268 repeated self copy_val_lower_message_repeated = 519; |
| 269 repeated self copy_Val_upper_message_repeated = 520; |
| 270 repeated self copyvalue_lower_no_underscore_message_repeated = 521; |
| 271 repeated self copyValue_upper_no_underscore_message_repeated = 522; |
| 272 |
| 273 repeated Foo copy_val_lower_enum_repeated = 523; |
| 274 repeated Foo copy_Val_upper_enum_repeated = 524; |
| 275 repeated Foo copyvalue_lower_no_underscore_enum_repeated = 525; |
| 276 repeated Foo copyValue_upper_no_underscore_enum_repeated = 526; |
| 277 |
| 278 optional string mutableCopy_val_lower_complex = 611; |
| 279 optional string mutableCopy_Val_upper_complex = 612; |
| 280 optional string mutableCopyvalue_lower_no_underscore_complex = 613; |
| 281 optional string mutableCopyValue_upper_no_underscore_complex = 614; |
| 282 |
| 283 optional int32 mutableCopy_val_lower_primitive = 615; |
| 284 optional int32 mutableCopy_Val_upper_primitive = 616; |
| 285 optional int32 mutableCopyvalue_lower_no_underscore_primitive = 617; |
| 286 optional int32 mutableCopyValue_upper_no_underscore_primitive = 618; |
| 287 |
| 288 optional self mutableCopy_val_lower_message = 619; |
| 289 optional self mutableCopy_Val_upper_message = 620; |
| 290 optional self mutableCopyvalue_lower_no_underscore_message = 621; |
| 291 optional self mutableCopyValue_upper_no_underscore_message = 622; |
| 292 |
| 293 optional Foo mutableCopy_val_lower_enum = 623; |
| 294 optional Foo mutableCopy_Val_upper_enum = 624; |
| 295 optional Foo mutableCopyvalue_lower_no_underscore_enum = 625; |
| 296 optional Foo mutableCopyValue_upper_no_underscore_enum = 626; |
| 297 |
| 298 repeated string mutableCopy_val_lower_complex_repeated = 711; |
| 299 repeated string mutableCopy_Val_upper_complex_repeated = 712; |
| 300 repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 713; |
| 301 repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 714; |
| 302 |
| 303 repeated int32 mutableCopy_val_lower_primitive_repeated = 715; |
| 304 repeated int32 mutableCopy_Val_upper_primitive_repeated = 716; |
| 305 repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 717; |
| 306 repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 718; |
| 307 |
| 308 repeated self mutableCopy_val_lower_message_repeated = 719; |
| 309 repeated self mutableCopy_Val_upper_message_repeated = 720; |
| 310 repeated self mutableCopyvalue_lower_no_underscore_message_repeated = 721; |
| 311 repeated self mutableCopyValue_upper_no_underscore_message_repeated = 722; |
| 312 |
| 313 repeated Foo mutableCopy_val_lower_enum_repeated = 723; |
| 314 repeated Foo mutableCopy_Val_upper_enum_repeated = 724; |
| 315 repeated Foo mutableCopyvalue_lower_no_underscore_enum_repeated = 725; |
| 316 repeated Foo mutableCopyValue_upper_no_underscore_enum_repeated = 726; |
| 317 } |
| 318 |
| 319 // Test handling of fields that are the retained names. |
| 320 message ObjCRetainedComplex { |
| 321 optional string new = 1; |
| 322 optional string alloc = 2; |
| 323 optional string copy = 3; |
| 324 optional string mutableCopy = 4; |
| 325 } |
| 326 |
| 327 message ObjCRetainedComplexRepeated { |
| 328 repeated string new = 1; |
| 329 repeated string alloc = 2; |
| 330 repeated string copy = 3; |
| 331 repeated string mutableCopy = 4; |
| 332 } |
| 333 |
| 334 message ObjCRetainedPrimitive { |
| 335 optional int32 new = 1; |
| 336 optional int32 alloc = 2; |
| 337 optional int32 copy = 3; |
| 338 optional int32 mutableCopy = 4; |
| 339 } |
| 340 |
| 341 message ObjCRetainedPrimitiveRepeated { |
| 342 repeated int32 new = 1; |
| 343 repeated int32 alloc = 2; |
| 344 repeated int32 copy = 3; |
| 345 repeated int32 mutableCopy = 4; |
| 346 } |
| 347 |
| 348 message ObjCRetainedMessage { |
| 349 optional self new = 1; |
| 350 optional self alloc = 2; |
| 351 optional self copy = 3; |
| 352 optional self mutableCopy = 4; |
| 353 } |
| 354 |
| 355 message ObjCRetainedMessageRepeated { |
| 356 repeated self new = 1; |
| 357 repeated self alloc = 2; |
| 358 repeated self copy = 3; |
| 359 repeated self mutableCopy = 4; |
| 360 } |
| 361 |
| 362 // Test Handling some MacTypes |
| 363 message Point { |
| 364 message Rect { |
| 365 optional int32 TimeValue = 1; |
| 366 } |
| 367 } |
| 368 |
| 369 // Test some weird defaults that we see in protos. |
| 370 message ObjcWeirdDefaults { |
| 371 // Set default values that match the protocol buffer defined defaults to |
| 372 // confirm hasDefault and the default values are set correctly. |
| 373 optional string foo = 1 [default = ""]; |
| 374 optional bytes bar = 2 [default = ""]; |
| 375 } |
| 376 |
| 377 // Used to confirm negative enum values work as expected. |
| 378 message EnumTestMsg { |
| 379 enum MyEnum { |
| 380 ZERO = 0; |
| 381 ONE = 1; |
| 382 TWO = 2; |
| 383 NEG_ONE = -1; |
| 384 NEG_TWO = -2; |
| 385 } |
| 386 optional MyEnum foo = 1; |
| 387 optional MyEnum bar = 2 [default = ONE]; |
| 388 optional MyEnum baz = 3 [default = NEG_ONE]; |
| 389 |
| 390 repeated MyEnum mumble = 4; |
| 391 } |
OLD | NEW |