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
30syntax = "proto2";
31
32import "google/protobuf/any.proto";
33import "google/protobuf/unittest.proto";
34
35package protobuf_unittest;
36
37// Using the messages in unittest.proto, setup for recursive cases for testing
38// extensions at various depths.
39extend TestAllExtensions {
40  optional TestAllExtensions recursive_extension = 86;
41}
42
43// Recursive message to for testing autocreators at different depths.
44message TestRecursiveMessageWithRepeatedField {
45  optional TestRecursiveMessageWithRepeatedField a = 1;
46  repeated int32 i = 2;
47  repeated string str = 3;
48  map<int32, int32> i_to_i = 4;
49  map<string, string> str_to_str = 5;
50}
51
52// Recursive message and extension to for testing autocreators at different
53// depths.
54message TestRecursiveExtension {
55  optional TestRecursiveExtension recursive_sub_message = 1;
56  repeated int32 repeated_value = 2;
57  extensions 1000 to max;
58}
59
60extend TestRecursiveExtension {
61  optional TestRecursiveExtension recursive_message_extension = 1000;
62}
63
64message self {
65  message super {
66    optional int32 description = 1;
67  }
68
69  enum autorelease {
70    retain      = 1;
71    release     = 2;
72    retainCount = 3;
73  }
74
75  // Singular
76  optional   bool id                =  1;
77  optional   bool _cmd              =  2;
78  optional   bool in                =  3;
79  optional   bool out               =  4;
80  optional   bool inout             =  5;
81  optional   bool bycopy            =  6;
82  optional   bool byref             =  7;
83  optional   bool oneway            =  8;
84  optional   bool dealloc           =  9;
85  optional   bool zone              = 10;
86  optional   bool isProxy           = 11;
87  optional   bool copy              = 12;
88  optional   bool readonly          = 13;
89  optional   bool default           = 14;
90  optional   bool assign            = 15;
91  optional   bool getter            = 16;
92  optional   bool setter            = 17;
93  optional   bool weak              = 18;
94  optional   bool public            = 19;
95  optional   bool case              = 20;
96
97  optional   autorelease SubEnum    = 25;
98
99 optional group New = 50 {
100   optional string copy = 51;
101 }
102  optional group MutableCopy = 60 {
103    optional int32 extensionRegistry = 61;
104  }
105
106  extensions 90 to 94;
107
108}
109
110enum retain {
111  count          = 4;
112  initialized    = 5;
113  serializedSize = 6;
114}
115
116message ObjCPropertyNaming {
117  // Test that the properties properly get things all caps.
118  optional string url           = 1;
119  optional string thumbnail_url = 2;
120  optional string url_foo       = 3;
121  optional string some_url_blah = 4;
122  optional string http          = 5;
123  optional string https         = 6;
124  // This one doesn't.
125  repeated string urls          = 7;
126}
127
128// EnumValueShortName: The short names shouldn't get suffixes/prefixes.
129enum Foo {
130  SERIALIZED_SIZE = 1;
131  SIZE            = 2;
132  OTHER           = 3;
133}
134
135// EnumValueShortName: The enum name gets a prefix.
136enum Category {
137  RED  = 1;
138  BLUE = 2;
139}
140
141// EnumValueShortName: Twist case, full name gets PB, but the short names
142// should still end up correct.
143enum Time {
144  BASE            = 1;
145  RECORD          = 2;
146  SOMETHING_ELSE  = 3;
147}
148
149extend self {
150  repeated    int32 debugDescription    =  90 [packed = true];
151  repeated    int64 finalize            =  91 [packed = true];
152  repeated   uint32 hash                =  92 [packed = true];
153  repeated   uint64 classForCoder       =  93 [packed = true];
154  repeated   sint32 byref               =  94 [packed = true];
155}
156
157// Test handing of fields that start with init* since Xcode 5's ARC support
158// doesn't like messages that look like initializers but aren't.
159message ObjCInitFoo {
160  optional string init_val = 11;
161  optional int32 init_size = 12;
162  optional self init_self = 13;
163
164  repeated string init_vals = 21;
165  repeated int32 init_sizes = 22;
166  repeated self init_selfs = 23;
167}
168
169// Test handling of fields that start with retained names.
170message ObjCRetainedFoo {
171  optional string new_val_lower_complex = 11;
172  optional string new_Val_upper_complex = 12;
173  optional string newvalue_lower_no_underscore_complex = 13;
174  optional string newValue_upper_no_underscore_complex = 14;
175
176  optional int32 new_val_lower_primitive = 15;
177  optional int32 new_Val_upper_primitive = 16;
178  optional int32 newvalue_lower_no_underscore_primitive = 17;
179  optional int32 newValue_upper_no_underscore_primitive = 18;
180
181  optional self new_val_lower_message = 19;
182  optional self new_Val_upper_message = 20;
183  optional self newvalue_lower_no_underscore_message = 21;
184  optional self newValue_upper_no_underscore_message = 22;
185
186  optional Foo new_val_lower_enum = 23;
187  optional Foo new_Val_upper_enum = 24;
188  optional Foo newvalue_lower_no_underscore_enum = 25;
189  optional Foo newValue_upper_no_underscore_enum = 26;
190
191  repeated string new_val_lower_complex_repeated = 111;
192  repeated string new_Val_upper_complex_repeated = 112;
193  repeated string newvalue_lower_no_underscore_complex_repeated = 113;
194  repeated string newValue_upper_no_underscore_complex_repeated = 114;
195
196  repeated int32 new_val_lower_primitive_repeated = 115;
197  repeated int32 new_Val_upper_primitive_repeated = 116;
198  repeated int32 newvalue_lower_no_underscore_primitive_repeated = 117;
199  repeated int32 newValue_upper_no_underscore_primitive_repeated = 118;
200
201  repeated self new_val_lower_message_repeated = 119;
202  repeated self new_Val_upper_message_repeated = 120;
203  repeated self newvalue_lower_no_underscore_message_repeated = 121;
204  repeated self newValue_upper_no_underscore_message_repeated = 122;
205
206  repeated Foo new_val_lower_enum_repeated = 123;
207  repeated Foo new_Val_upper_enum_repeated = 124;
208  repeated Foo newvalue_lower_no_underscore_enum_repeated = 125;
209  repeated Foo newValue_upper_no_underscore_enum_repeated = 126;
210
211  optional string alloc_val_lower_complex = 211;
212  optional string alloc_Val_upper_complex = 212;
213  optional string allocvalue_lower_no_underscore_complex = 213;
214  optional string allocValue_upper_no_underscore_complex = 214;
215
216  optional int32 alloc_val_lower_primitive = 215;
217  optional int32 alloc_Val_upper_primitive = 216;
218  optional int32 allocvalue_lower_no_underscore_primitive = 217;
219  optional int32 allocValue_upper_no_underscore_primitive = 218;
220
221  optional self alloc_val_lower_message = 219;
222  optional self alloc_Val_upper_message = 220;
223  optional self allocvalue_lower_no_underscore_message = 221;
224  optional self allocValue_upper_no_underscore_message = 222;
225
226  optional Foo alloc_val_lower_enum = 223;
227  optional Foo alloc_Val_upper_enum = 224;
228  optional Foo allocvalue_lower_no_underscore_enum = 225;
229  optional Foo allocValue_upper_no_underscore_enum = 226;
230
231  repeated string alloc_val_lower_complex_repeated = 311;
232  repeated string alloc_Val_upper_complex_repeated = 312;
233  repeated string allocvalue_lower_no_underscore_complex_repeated = 313;
234  repeated string allocValue_upper_no_underscore_complex_repeated = 314;
235
236  repeated int32 alloc_val_lower_primitive_repeated = 315;
237  repeated int32 alloc_Val_upper_primitive_repeated = 316;
238  repeated int32 allocvalue_lower_no_underscore_primitive_repeated = 317;
239  repeated int32 allocValue_upper_no_underscore_primitive_repeated = 318;
240
241  repeated self alloc_val_lower_message_repeated = 319;
242  repeated self alloc_Val_upper_message_repeated = 320;
243  repeated self allocvalue_lower_no_underscore_message_repeated = 321;
244  repeated self allocValue_upper_no_underscore_message_repeated = 322;
245
246  repeated Foo alloc_val_lower_enum_repeated = 323;
247  repeated Foo alloc_Val_upper_enum_repeated = 324;
248  repeated Foo allocvalue_lower_no_underscore_enum_repeated = 325;
249  repeated Foo allocValue_upper_no_underscore_enum_repeated = 326;
250
251  optional string copy_val_lower_complex = 411;
252  optional string copy_Val_upper_complex = 412;
253  optional string copyvalue_lower_no_underscore_complex = 413;
254  optional string copyValue_upper_no_underscore_complex = 414;
255
256  optional int32 copy_val_lower_primitive = 415;
257  optional int32 copy_Val_upper_primitive = 416;
258  optional int32 copyvalue_lower_no_underscore_primitive = 417;
259  optional int32 copyValue_upper_no_underscore_primitive = 418;
260
261  optional self copy_val_lower_message = 419;
262  optional self copy_Val_upper_message = 420;
263  optional self copyvalue_lower_no_underscore_message = 421;
264  optional self copyValue_upper_no_underscore_message = 422;
265
266  optional Foo copy_val_lower_enum = 423;
267  optional Foo copy_Val_upper_enum = 424;
268  optional Foo copyvalue_lower_no_underscore_enum = 425;
269  optional Foo copyValue_upper_no_underscore_enum = 426;
270
271  repeated string copy_val_lower_complex_repeated = 511;
272  repeated string copy_Val_upper_complex_repeated = 512;
273  repeated string copyvalue_lower_no_underscore_complex_repeated = 513;
274  repeated string copyValue_upper_no_underscore_complex_repeated = 514;
275
276  repeated int32 copy_val_lower_primitive_repeated = 515;
277  repeated int32 copy_Val_upper_primitive_repeated = 516;
278  repeated int32 copyvalue_lower_no_underscore_primitive_repeated = 517;
279  repeated int32 copyValue_upper_no_underscore_primitive_repeated = 518;
280
281  repeated self copy_val_lower_message_repeated = 519;
282  repeated self copy_Val_upper_message_repeated = 520;
283  repeated self copyvalue_lower_no_underscore_message_repeated = 521;
284  repeated self copyValue_upper_no_underscore_message_repeated = 522;
285
286  repeated Foo copy_val_lower_enum_repeated = 523;
287  repeated Foo copy_Val_upper_enum_repeated = 524;
288  repeated Foo copyvalue_lower_no_underscore_enum_repeated = 525;
289  repeated Foo copyValue_upper_no_underscore_enum_repeated = 526;
290
291  optional string mutableCopy_val_lower_complex = 611;
292  optional string mutableCopy_Val_upper_complex = 612;
293  optional string mutableCopyvalue_lower_no_underscore_complex = 613;
294  optional string mutableCopyValue_upper_no_underscore_complex = 614;
295
296  optional int32 mutableCopy_val_lower_primitive = 615;
297  optional int32 mutableCopy_Val_upper_primitive = 616;
298  optional int32 mutableCopyvalue_lower_no_underscore_primitive = 617;
299  optional int32 mutableCopyValue_upper_no_underscore_primitive = 618;
300
301  optional self mutableCopy_val_lower_message = 619;
302  optional self mutableCopy_Val_upper_message = 620;
303  optional self mutableCopyvalue_lower_no_underscore_message = 621;
304  optional self mutableCopyValue_upper_no_underscore_message = 622;
305
306  optional Foo mutableCopy_val_lower_enum = 623;
307  optional Foo mutableCopy_Val_upper_enum = 624;
308  optional Foo mutableCopyvalue_lower_no_underscore_enum = 625;
309  optional Foo mutableCopyValue_upper_no_underscore_enum = 626;
310
311  repeated string mutableCopy_val_lower_complex_repeated = 711;
312  repeated string mutableCopy_Val_upper_complex_repeated = 712;
313  repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 713;
314  repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 714;
315
316  repeated int32 mutableCopy_val_lower_primitive_repeated = 715;
317  repeated int32 mutableCopy_Val_upper_primitive_repeated = 716;
318  repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 717;
319  repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 718;
320
321  repeated self mutableCopy_val_lower_message_repeated = 719;
322  repeated self mutableCopy_Val_upper_message_repeated = 720;
323  repeated self mutableCopyvalue_lower_no_underscore_message_repeated = 721;
324  repeated self mutableCopyValue_upper_no_underscore_message_repeated = 722;
325
326  repeated Foo mutableCopy_val_lower_enum_repeated = 723;
327  repeated Foo mutableCopy_Val_upper_enum_repeated = 724;
328  repeated Foo mutableCopyvalue_lower_no_underscore_enum_repeated = 725;
329  repeated Foo mutableCopyValue_upper_no_underscore_enum_repeated = 726;
330}
331
332// Test handling of fields that are the retained names.
333message ObjCRetainedComplex {
334  optional string new = 1;
335  optional string alloc = 2;
336  optional string copy = 3;
337  optional string mutableCopy = 4;
338}
339
340message ObjCRetainedComplexRepeated {
341  repeated string new = 1;
342  repeated string alloc = 2;
343  repeated string copy = 3;
344  repeated string mutableCopy = 4;
345}
346
347message ObjCRetainedPrimitive {
348  optional int32 new = 1;
349  optional int32 alloc = 2;
350  optional int32 copy = 3;
351  optional int32 mutableCopy = 4;
352}
353
354message ObjCRetainedPrimitiveRepeated {
355  repeated int32 new = 1;
356  repeated int32 alloc = 2;
357  repeated int32 copy = 3;
358  repeated int32 mutableCopy = 4;
359}
360
361message ObjCRetainedMessage {
362  optional self new = 1;
363  optional self alloc = 2;
364  optional self copy = 3;
365  optional self mutableCopy = 4;
366}
367
368message ObjCRetainedMessageRepeated {
369  repeated self new = 1;
370  repeated self alloc = 2;
371  repeated self copy = 3;
372  repeated self mutableCopy = 4;
373}
374
375// Test Handling some MacTypes
376message Point {
377  message Rect {
378    optional int32 TimeValue = 1;
379  }
380}
381
382// Test some weird defaults that we see in protos.
383message ObjcWeirdDefaults {
384  // Set default values that match the protocol buffer defined defaults to
385  // confirm hasDefault and the default values are set correctly.
386  optional string foo = 1 [default = ""];
387  optional bytes bar = 2 [default = ""];
388}
389
390// Used to confirm negative enum values work as expected.
391message EnumTestMsg {
392  enum MyEnum {
393    ZERO    = 0;
394    ONE     = 1;
395    TWO     = 2;
396    NEG_ONE = -1;
397    NEG_TWO = -2;
398  }
399  optional MyEnum foo = 1;
400  optional MyEnum bar = 2 [default = ONE];
401  optional MyEnum baz = 3 [default = NEG_ONE];
402
403  repeated MyEnum mumble = 4;
404}
405
406// Test case for https://github.com/google/protobuf/issues/1453
407// Message with no explicit defaults, but a non zero default for an enum.
408message MessageWithOneBasedEnum {
409  enum OneBasedEnum {
410    ONE = 1;
411    TWO = 2;
412  }
413  optional OneBasedEnum enum_field = 1;
414}
415
416// Message with all bools for testing things related to bool storage.
417message BoolOnlyMessage {
418  optional bool bool_field_1 = 1;
419  optional bool bool_field_2 = 2;
420  optional bool bool_field_3 = 3;
421  optional bool bool_field_4 = 4;
422  optional bool bool_field_5 = 5;
423  optional bool bool_field_6 = 6;
424  optional bool bool_field_7 = 7;
425  optional bool bool_field_8 = 8;
426  optional bool bool_field_9 = 9;
427  optional bool bool_field_10 = 10;
428  optional bool bool_field_11 = 11;
429  optional bool bool_field_12 = 12;
430  optional bool bool_field_13 = 13;
431  optional bool bool_field_14 = 14;
432  optional bool bool_field_15 = 15;
433  optional bool bool_field_16 = 16;
434  optional bool bool_field_17 = 17;
435  optional bool bool_field_18 = 18;
436  optional bool bool_field_19 = 19;
437  optional bool bool_field_20 = 20;
438  optional bool bool_field_21 = 21;
439  optional bool bool_field_22 = 22;
440  optional bool bool_field_23 = 23;
441  optional bool bool_field_24 = 24;
442  optional bool bool_field_25 = 25;
443  optional bool bool_field_26 = 26;
444  optional bool bool_field_27 = 27;
445  optional bool bool_field_28 = 28;
446  optional bool bool_field_29 = 29;
447  optional bool bool_field_30 = 30;
448  optional bool bool_field_31 = 31;
449  optional bool bool_field_32 = 32;
450}
451
452// Reference to a WKT to test (via generated code inspection), the handling
453// of #imports.  Within the WKTs, references to each other are just path
454// based imports, but when reference from another proto file, they should be
455// conditional to support the framework import style.
456message WKTRefereceMessage {
457  optional google.protobuf.Any an_any = 1;
458}
459