blob: 4f0e348569c25ebadcc80756d8c082edfea219cf [file] [log] [blame]
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001// Protocol Buffers - Google's data interchange format
2// Copyright 2011 Google Inc. All rights reserved.
3//
Joshua Haberman200c9582023-09-08 17:42:37 -07004// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
Thomas Van Lenten30650d82015-05-01 08:57:16 -04007
8syntax = "proto2";
9
Thomas Van Lenten7da023b2016-05-09 13:53:20 -040010import "google/protobuf/any.proto";
Thomas Van Lenten28bc3ba2022-08-23 17:23:28 -040011import "objectivec/Tests/unittest.proto";
Thomas Van Lenten30650d82015-05-01 08:57:16 -040012
Thomas Van Lentenbc9880b2022-08-23 14:05:47 -040013package objc.protobuf.tests;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040014
Thomas Van Lenten5cf61b72022-08-29 16:37:36 -040015// Explicit empty prefix, tests some validations code paths also.
16option objc_class_prefix = "";
17
Sergio Campamá237f3212016-08-09 05:26:24 -070018// Used to check that Headerdocs and appledoc work correctly. If these comments
19// are not handled correctly, Xcode will fail to build the tests.
20message TestGeneratedComments {
21 // This is a string that could contain stuff like
22 // mime types as image/* or */plain. Maybe twitter usernames
23 // like @protobuf, @google or @something.
24 optional string string_field = 1;
25}
26
Thomas Van Lenten30650d82015-05-01 08:57:16 -040027// Using the messages in unittest.proto, setup for recursive cases for testing
28// extensions at various depths.
29extend TestAllExtensions {
30 optional TestAllExtensions recursive_extension = 86;
31}
32
33// Recursive message to for testing autocreators at different depths.
34message TestRecursiveMessageWithRepeatedField {
35 optional TestRecursiveMessageWithRepeatedField a = 1;
36 repeated int32 i = 2;
37 repeated string str = 3;
Thomas Van Lenten1dcc3292015-05-21 17:14:52 -040038 map<int32, int32> i_to_i = 4;
39 map<string, string> str_to_str = 5;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040040}
41
Thomas Van Lenten156161d2018-01-03 11:19:53 -050042// Message with a few types of maps to cover the different custom flows
43// in the runtime.
44message TestMessageOfMaps {
45 map<string, string> str_to_str = 1;
46
47 map<string, int32> str_to_int = 2;
48 map<int32, string> int_to_str = 3;
49 map<int32, int32> int_to_int = 4;
50
51 map<string, bool> str_to_bool = 5;
52 map<bool, string> bool_to_str = 6;
53 map<bool, bool> bool_to_bool = 7;
54
55 map<int32, bool> int_to_bool = 8;
56 map<bool, int32> bool_to_int = 9;
57
58 map<string, TestAllTypes> str_to_msg = 10;
59 map<int32, TestAllTypes> int_to_msg = 11;
60 map<bool, TestAllTypes> bool_to_msg = 12;
61}
62
Thomas Van Lenten30650d82015-05-01 08:57:16 -040063// Recursive message and extension to for testing autocreators at different
64// depths.
65message TestRecursiveExtension {
66 optional TestRecursiveExtension recursive_sub_message = 1;
67 repeated int32 repeated_value = 2;
68 extensions 1000 to max;
69}
70
71extend TestRecursiveExtension {
72 optional TestRecursiveExtension recursive_message_extension = 1000;
73}
74
75message self {
76 message super {
77 optional int32 description = 1;
78 }
79
80 enum autorelease {
81 retain = 1;
82 release = 2;
83 retainCount = 3;
84 }
85
86 // Singular
Dave MacLachlanbe83b292018-10-25 12:35:20 -070087 // Objective C Keywords
88 optional bool id = 1;
89 optional bool _cmd = 2;
90 // super is used as submessage above
91 optional bool in = 4;
92 optional bool out = 5;
93 optional bool inout = 6;
94 optional bool bycopy = 7;
95 optional bool byref = 8;
96 optional bool oneway = 9;
97 optional bool self = 10;
98 optional bool instancetype = 11;
99 optional bool nullable = 12;
100 optional bool nonnull = 13;
101 optional bool nil = 14;
102 // Nil and nil can't be in the same message
103 optional bool YES = 16;
104 optional bool NO = 17;
105 optional bool weak = 18;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400106
Dave MacLachlanbe83b292018-10-25 12:35:20 -0700107 // Some C/C++ Keywords
108 optional bool case = 30;
109 optional bool if = 31;
110 optional bool and_eq = 32;
111 optional bool public = 33;
112 optional bool private = 34;
113 optional bool typename = 35;
114 optional bool static_cast = 36;
115 optional bool typeof = 37;
116 optional bool restrict = 38;
117 optional bool NULL = 39;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400118
Dave MacLachlanbe83b292018-10-25 12:35:20 -0700119 // Some NSObject Methods
120 optional bool dealloc = 110;
121 optional bool isProxy = 111;
122 optional bool copy = 112;
123 optional bool description = 113;
124 optional bool zone = 114;
125 optional bool className = 115;
126 optional bool __retain_OA = 116;
127 optional bool CAMLType = 117;
128 optional bool isNSDictionary__ = 118;
129 optional bool accessibilityLabel = 119;
130
131 // Some Objc "keywords" that we shouldn't
132 // have to worry about because they
133 // can only appear in specialized areas.
134 optional bool assign = 200;
135 optional bool getter = 201;
136 optional bool setter = 202;
137 optional bool atomic = 203;
138 optional bool nonatomic = 204;
139 optional bool strong = 205;
140 optional bool null_resettable = 206;
141 optional bool readonly = 207;
142
143 // Some GPBMessage methods
144 optional bool clear = 300;
145 optional bool data = 301;
146 optional bool descriptor = 302;
147 optional bool delimitedData = 303;
148
149 // Some MacTypes
150 optional bool Fixed = 400;
151 optional bool Point = 401;
152 optional bool FixedPoint = 402;
153 optional bool Style = 403;
154
155 // C/C++ reserved identifiers
156 optional bool _Generic = 500;
157 optional bool __block = 501;
158
159 // Try a keyword as a type
160 optional autorelease SubEnum = 1000;
161
162 optional group New = 2000 {
163 optional string copy = 1;
164 }
165 optional group MutableCopy = 2001 {
166 optional int32 extensionRegistry = 1;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400167 }
168
Dave MacLachlanbe83b292018-10-25 12:35:20 -0700169 extensions 3000 to 3999;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400170
171}
172
173enum retain {
174 count = 4;
175 initialized = 5;
176 serializedSize = 6;
177}
178
Thomas Van Lenten1bf4b382016-03-08 09:29:49 -0500179message ObjCPropertyNaming {
180 // Test that the properties properly get things all caps.
181 optional string url = 1;
182 optional string thumbnail_url = 2;
183 optional string url_foo = 3;
184 optional string some_url_blah = 4;
185 optional string http = 5;
186 optional string https = 6;
187 // This one doesn't.
188 repeated string urls = 7;
189}
190
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400191// EnumValueShortName: The short names shouldn't get suffixes/prefixes.
192enum Foo {
193 SERIALIZED_SIZE = 1;
194 SIZE = 2;
195 OTHER = 3;
196}
197
198// EnumValueShortName: The enum name gets a prefix.
199enum Category {
200 RED = 1;
201 BLUE = 2;
202}
203
204// EnumValueShortName: Twist case, full name gets PB, but the short names
205// should still end up correct.
206enum Time {
207 BASE = 1;
208 RECORD = 2;
209 SOMETHING_ELSE = 3;
210}
211
212extend self {
Dave MacLachlanbe83b292018-10-25 12:35:20 -0700213 repeated int32 debugDescription = 3000 [packed = true];
214 repeated int64 finalize = 3001 [packed = true];
215 repeated uint32 hash = 3002 [packed = true];
216 repeated uint64 classForCoder = 3003 [packed = true];
217 repeated sint32 byref = 3004 [packed = true];
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400218}
219
Thomas Van Lentenbc4cbf92022-09-20 08:35:56 -0400220// Test handing of fields that start with init*.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400221message ObjCInitFoo {
222 optional string init_val = 11;
223 optional int32 init_size = 12;
224 optional self init_self = 13;
225
226 repeated string init_vals = 21;
227 repeated int32 init_sizes = 22;
228 repeated self init_selfs = 23;
229}
230
231// Test handling of fields that start with retained names.
232message ObjCRetainedFoo {
233 optional string new_val_lower_complex = 11;
234 optional string new_Val_upper_complex = 12;
235 optional string newvalue_lower_no_underscore_complex = 13;
236 optional string newValue_upper_no_underscore_complex = 14;
237
238 optional int32 new_val_lower_primitive = 15;
239 optional int32 new_Val_upper_primitive = 16;
240 optional int32 newvalue_lower_no_underscore_primitive = 17;
241 optional int32 newValue_upper_no_underscore_primitive = 18;
242
243 optional self new_val_lower_message = 19;
244 optional self new_Val_upper_message = 20;
245 optional self newvalue_lower_no_underscore_message = 21;
246 optional self newValue_upper_no_underscore_message = 22;
247
248 optional Foo new_val_lower_enum = 23;
249 optional Foo new_Val_upper_enum = 24;
250 optional Foo newvalue_lower_no_underscore_enum = 25;
251 optional Foo newValue_upper_no_underscore_enum = 26;
252
253 repeated string new_val_lower_complex_repeated = 111;
254 repeated string new_Val_upper_complex_repeated = 112;
255 repeated string newvalue_lower_no_underscore_complex_repeated = 113;
256 repeated string newValue_upper_no_underscore_complex_repeated = 114;
257
258 repeated int32 new_val_lower_primitive_repeated = 115;
259 repeated int32 new_Val_upper_primitive_repeated = 116;
260 repeated int32 newvalue_lower_no_underscore_primitive_repeated = 117;
261 repeated int32 newValue_upper_no_underscore_primitive_repeated = 118;
262
263 repeated self new_val_lower_message_repeated = 119;
264 repeated self new_Val_upper_message_repeated = 120;
265 repeated self newvalue_lower_no_underscore_message_repeated = 121;
266 repeated self newValue_upper_no_underscore_message_repeated = 122;
267
268 repeated Foo new_val_lower_enum_repeated = 123;
269 repeated Foo new_Val_upper_enum_repeated = 124;
270 repeated Foo newvalue_lower_no_underscore_enum_repeated = 125;
271 repeated Foo newValue_upper_no_underscore_enum_repeated = 126;
272
273 optional string alloc_val_lower_complex = 211;
274 optional string alloc_Val_upper_complex = 212;
275 optional string allocvalue_lower_no_underscore_complex = 213;
276 optional string allocValue_upper_no_underscore_complex = 214;
277
278 optional int32 alloc_val_lower_primitive = 215;
279 optional int32 alloc_Val_upper_primitive = 216;
280 optional int32 allocvalue_lower_no_underscore_primitive = 217;
281 optional int32 allocValue_upper_no_underscore_primitive = 218;
282
283 optional self alloc_val_lower_message = 219;
284 optional self alloc_Val_upper_message = 220;
285 optional self allocvalue_lower_no_underscore_message = 221;
286 optional self allocValue_upper_no_underscore_message = 222;
287
288 optional Foo alloc_val_lower_enum = 223;
289 optional Foo alloc_Val_upper_enum = 224;
290 optional Foo allocvalue_lower_no_underscore_enum = 225;
291 optional Foo allocValue_upper_no_underscore_enum = 226;
292
293 repeated string alloc_val_lower_complex_repeated = 311;
294 repeated string alloc_Val_upper_complex_repeated = 312;
295 repeated string allocvalue_lower_no_underscore_complex_repeated = 313;
296 repeated string allocValue_upper_no_underscore_complex_repeated = 314;
297
298 repeated int32 alloc_val_lower_primitive_repeated = 315;
299 repeated int32 alloc_Val_upper_primitive_repeated = 316;
300 repeated int32 allocvalue_lower_no_underscore_primitive_repeated = 317;
301 repeated int32 allocValue_upper_no_underscore_primitive_repeated = 318;
302
303 repeated self alloc_val_lower_message_repeated = 319;
304 repeated self alloc_Val_upper_message_repeated = 320;
305 repeated self allocvalue_lower_no_underscore_message_repeated = 321;
306 repeated self allocValue_upper_no_underscore_message_repeated = 322;
307
308 repeated Foo alloc_val_lower_enum_repeated = 323;
309 repeated Foo alloc_Val_upper_enum_repeated = 324;
310 repeated Foo allocvalue_lower_no_underscore_enum_repeated = 325;
311 repeated Foo allocValue_upper_no_underscore_enum_repeated = 326;
312
313 optional string copy_val_lower_complex = 411;
314 optional string copy_Val_upper_complex = 412;
315 optional string copyvalue_lower_no_underscore_complex = 413;
316 optional string copyValue_upper_no_underscore_complex = 414;
317
318 optional int32 copy_val_lower_primitive = 415;
319 optional int32 copy_Val_upper_primitive = 416;
320 optional int32 copyvalue_lower_no_underscore_primitive = 417;
321 optional int32 copyValue_upper_no_underscore_primitive = 418;
322
323 optional self copy_val_lower_message = 419;
324 optional self copy_Val_upper_message = 420;
325 optional self copyvalue_lower_no_underscore_message = 421;
326 optional self copyValue_upper_no_underscore_message = 422;
327
328 optional Foo copy_val_lower_enum = 423;
329 optional Foo copy_Val_upper_enum = 424;
330 optional Foo copyvalue_lower_no_underscore_enum = 425;
331 optional Foo copyValue_upper_no_underscore_enum = 426;
332
333 repeated string copy_val_lower_complex_repeated = 511;
334 repeated string copy_Val_upper_complex_repeated = 512;
335 repeated string copyvalue_lower_no_underscore_complex_repeated = 513;
336 repeated string copyValue_upper_no_underscore_complex_repeated = 514;
337
338 repeated int32 copy_val_lower_primitive_repeated = 515;
339 repeated int32 copy_Val_upper_primitive_repeated = 516;
340 repeated int32 copyvalue_lower_no_underscore_primitive_repeated = 517;
341 repeated int32 copyValue_upper_no_underscore_primitive_repeated = 518;
342
343 repeated self copy_val_lower_message_repeated = 519;
344 repeated self copy_Val_upper_message_repeated = 520;
345 repeated self copyvalue_lower_no_underscore_message_repeated = 521;
346 repeated self copyValue_upper_no_underscore_message_repeated = 522;
347
348 repeated Foo copy_val_lower_enum_repeated = 523;
349 repeated Foo copy_Val_upper_enum_repeated = 524;
350 repeated Foo copyvalue_lower_no_underscore_enum_repeated = 525;
351 repeated Foo copyValue_upper_no_underscore_enum_repeated = 526;
352
353 optional string mutableCopy_val_lower_complex = 611;
354 optional string mutableCopy_Val_upper_complex = 612;
355 optional string mutableCopyvalue_lower_no_underscore_complex = 613;
356 optional string mutableCopyValue_upper_no_underscore_complex = 614;
357
358 optional int32 mutableCopy_val_lower_primitive = 615;
359 optional int32 mutableCopy_Val_upper_primitive = 616;
360 optional int32 mutableCopyvalue_lower_no_underscore_primitive = 617;
361 optional int32 mutableCopyValue_upper_no_underscore_primitive = 618;
362
363 optional self mutableCopy_val_lower_message = 619;
364 optional self mutableCopy_Val_upper_message = 620;
365 optional self mutableCopyvalue_lower_no_underscore_message = 621;
366 optional self mutableCopyValue_upper_no_underscore_message = 622;
367
368 optional Foo mutableCopy_val_lower_enum = 623;
369 optional Foo mutableCopy_Val_upper_enum = 624;
370 optional Foo mutableCopyvalue_lower_no_underscore_enum = 625;
371 optional Foo mutableCopyValue_upper_no_underscore_enum = 626;
372
373 repeated string mutableCopy_val_lower_complex_repeated = 711;
374 repeated string mutableCopy_Val_upper_complex_repeated = 712;
375 repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 713;
376 repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 714;
377
378 repeated int32 mutableCopy_val_lower_primitive_repeated = 715;
379 repeated int32 mutableCopy_Val_upper_primitive_repeated = 716;
380 repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 717;
381 repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 718;
382
383 repeated self mutableCopy_val_lower_message_repeated = 719;
384 repeated self mutableCopy_Val_upper_message_repeated = 720;
385 repeated self mutableCopyvalue_lower_no_underscore_message_repeated = 721;
386 repeated self mutableCopyValue_upper_no_underscore_message_repeated = 722;
387
388 repeated Foo mutableCopy_val_lower_enum_repeated = 723;
389 repeated Foo mutableCopy_Val_upper_enum_repeated = 724;
390 repeated Foo mutableCopyvalue_lower_no_underscore_enum_repeated = 725;
391 repeated Foo mutableCopyValue_upper_no_underscore_enum_repeated = 726;
Thomas Van Lenten1484b582018-12-05 11:22:30 -0500392
393 extensions 1000 to 3999;
394}
395
396// Extension fields with retained names.
397extend ObjCRetainedFoo {
398 optional string new_val_lower_complex = 1011;
399 optional string new_Val_upper_complex = 1012;
400 optional string newvalue_lower_no_underscore_complex = 1013;
401 optional string newValue_upper_no_underscore_complex = 1014;
402
403 optional int32 new_val_lower_primitive = 1015;
404 optional int32 new_Val_upper_primitive = 1016;
405 optional int32 newvalue_lower_no_underscore_primitive = 1017;
406 optional int32 newValue_upper_no_underscore_primitive = 1018;
407
408 optional self new_val_lower_message = 1019;
409 optional self new_Val_upper_message = 1020;
410 optional self newvalue_lower_no_underscore_message = 1021;
411 optional self newValue_upper_no_underscore_message = 1022;
412
413 optional Foo new_val_lower_enum = 1023;
414 optional Foo new_Val_upper_enum = 1024;
415 optional Foo newvalue_lower_no_underscore_enum = 1025;
416 optional Foo newValue_upper_no_underscore_enum = 1026;
417
418 repeated string new_val_lower_complex_repeated = 1111;
419 repeated string new_Val_upper_complex_repeated = 1112;
420 repeated string newvalue_lower_no_underscore_complex_repeated = 1113;
421 repeated string newValue_upper_no_underscore_complex_repeated = 1114;
422
423 repeated int32 new_val_lower_primitive_repeated = 1115;
424 repeated int32 new_Val_upper_primitive_repeated = 1116;
425 repeated int32 newvalue_lower_no_underscore_primitive_repeated = 1117;
426 repeated int32 newValue_upper_no_underscore_primitive_repeated = 1118;
427
428 repeated self new_val_lower_message_repeated = 1119;
429 repeated self new_Val_upper_message_repeated = 1120;
430 repeated self newvalue_lower_no_underscore_message_repeated = 1121;
431 repeated self newValue_upper_no_underscore_message_repeated = 1122;
432
433 repeated Foo new_val_lower_enum_repeated = 1123;
434 repeated Foo new_Val_upper_enum_repeated = 1124;
435 repeated Foo newvalue_lower_no_underscore_enum_repeated = 1125;
436 repeated Foo newValue_upper_no_underscore_enum_repeated = 1126;
437
438 optional string alloc_val_lower_complex = 1211;
439 optional string alloc_Val_upper_complex = 1212;
440 optional string allocvalue_lower_no_underscore_complex = 1213;
441 optional string allocValue_upper_no_underscore_complex = 1214;
442
443 optional int32 alloc_val_lower_primitive = 1215;
444 optional int32 alloc_Val_upper_primitive = 1216;
445 optional int32 allocvalue_lower_no_underscore_primitive = 1217;
446 optional int32 allocValue_upper_no_underscore_primitive = 1218;
447
448 optional self alloc_val_lower_message = 1219;
449 optional self alloc_Val_upper_message = 1220;
450 optional self allocvalue_lower_no_underscore_message = 1221;
451 optional self allocValue_upper_no_underscore_message = 1222;
452
453 optional Foo alloc_val_lower_enum = 1223;
454 optional Foo alloc_Val_upper_enum = 1224;
455 optional Foo allocvalue_lower_no_underscore_enum = 1225;
456 optional Foo allocValue_upper_no_underscore_enum = 1226;
457
458 repeated string alloc_val_lower_complex_repeated = 1311;
459 repeated string alloc_Val_upper_complex_repeated = 1312;
460 repeated string allocvalue_lower_no_underscore_complex_repeated = 1313;
461 repeated string allocValue_upper_no_underscore_complex_repeated = 1314;
462
463 repeated int32 alloc_val_lower_primitive_repeated = 1315;
464 repeated int32 alloc_Val_upper_primitive_repeated = 1316;
465 repeated int32 allocvalue_lower_no_underscore_primitive_repeated = 1317;
466 repeated int32 allocValue_upper_no_underscore_primitive_repeated = 1318;
467
468 repeated self alloc_val_lower_message_repeated = 1319;
469 repeated self alloc_Val_upper_message_repeated = 1320;
470 repeated self allocvalue_lower_no_underscore_message_repeated = 1321;
471 repeated self allocValue_upper_no_underscore_message_repeated = 1322;
472
473 repeated Foo alloc_val_lower_enum_repeated = 1323;
474 repeated Foo alloc_Val_upper_enum_repeated = 1324;
475 repeated Foo allocvalue_lower_no_underscore_enum_repeated = 1325;
476 repeated Foo allocValue_upper_no_underscore_enum_repeated = 1326;
477
478 optional string copy_val_lower_complex = 1411;
479 optional string copy_Val_upper_complex = 1412;
480 optional string copyvalue_lower_no_underscore_complex = 1413;
481 optional string copyValue_upper_no_underscore_complex = 1414;
482
483 optional int32 copy_val_lower_primitive = 1415;
484 optional int32 copy_Val_upper_primitive = 1416;
485 optional int32 copyvalue_lower_no_underscore_primitive = 1417;
486 optional int32 copyValue_upper_no_underscore_primitive = 1418;
487
488 optional self copy_val_lower_message = 1419;
489 optional self copy_Val_upper_message = 1420;
490 optional self copyvalue_lower_no_underscore_message = 1421;
491 optional self copyValue_upper_no_underscore_message = 1422;
492
493 optional Foo copy_val_lower_enum = 1423;
494 optional Foo copy_Val_upper_enum = 1424;
495 optional Foo copyvalue_lower_no_underscore_enum = 1425;
496 optional Foo copyValue_upper_no_underscore_enum = 1426;
497
498 repeated string copy_val_lower_complex_repeated = 1511;
499 repeated string copy_Val_upper_complex_repeated = 1512;
500 repeated string copyvalue_lower_no_underscore_complex_repeated = 1513;
501 repeated string copyValue_upper_no_underscore_complex_repeated = 1514;
502
503 repeated int32 copy_val_lower_primitive_repeated = 1515;
504 repeated int32 copy_Val_upper_primitive_repeated = 1516;
505 repeated int32 copyvalue_lower_no_underscore_primitive_repeated = 1517;
506 repeated int32 copyValue_upper_no_underscore_primitive_repeated = 1518;
507
508 repeated self copy_val_lower_message_repeated = 1519;
509 repeated self copy_Val_upper_message_repeated = 1520;
510 repeated self copyvalue_lower_no_underscore_message_repeated = 1521;
511 repeated self copyValue_upper_no_underscore_message_repeated = 1522;
512
513 repeated Foo copy_val_lower_enum_repeated = 1523;
514 repeated Foo copy_Val_upper_enum_repeated = 1524;
515 repeated Foo copyvalue_lower_no_underscore_enum_repeated = 1525;
516 repeated Foo copyValue_upper_no_underscore_enum_repeated = 1526;
517
518 optional string mutableCopy_val_lower_complex = 1611;
519 optional string mutableCopy_Val_upper_complex = 1612;
520 optional string mutableCopyvalue_lower_no_underscore_complex = 1613;
521 optional string mutableCopyValue_upper_no_underscore_complex = 1614;
522
523 optional int32 mutableCopy_val_lower_primitive = 1615;
524 optional int32 mutableCopy_Val_upper_primitive = 1616;
525 optional int32 mutableCopyvalue_lower_no_underscore_primitive = 1617;
526 optional int32 mutableCopyValue_upper_no_underscore_primitive = 1618;
527
528 optional self mutableCopy_val_lower_message = 1619;
529 optional self mutableCopy_Val_upper_message = 1620;
530 optional self mutableCopyvalue_lower_no_underscore_message = 1621;
531 optional self mutableCopyValue_upper_no_underscore_message = 1622;
532
533 optional Foo mutableCopy_val_lower_enum = 1623;
534 optional Foo mutableCopy_Val_upper_enum = 1624;
535 optional Foo mutableCopyvalue_lower_no_underscore_enum = 1625;
536 optional Foo mutableCopyValue_upper_no_underscore_enum = 1626;
537
538 repeated string mutableCopy_val_lower_complex_repeated = 1711;
539 repeated string mutableCopy_Val_upper_complex_repeated = 1712;
540 repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 1713;
541 repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 1714;
542
543 repeated int32 mutableCopy_val_lower_primitive_repeated = 1715;
544 repeated int32 mutableCopy_Val_upper_primitive_repeated = 1716;
545 repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 1717;
546 repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 1718;
547
548 repeated self mutableCopy_val_lower_message_repeated = 1719;
549 repeated self mutableCopy_Val_upper_message_repeated = 1720;
550 repeated self mutableCopyvalue_lower_no_underscore_message_repeated = 1721;
551 repeated self mutableCopyValue_upper_no_underscore_message_repeated = 1722;
552
553 repeated Foo mutableCopy_val_lower_enum_repeated = 1723;
554 repeated Foo mutableCopy_Val_upper_enum_repeated = 1724;
555 repeated Foo mutableCopyvalue_lower_no_underscore_enum_repeated = 1725;
556 repeated Foo mutableCopyValue_upper_no_underscore_enum_repeated = 1726;
557}
558
559message JustToScopeExtensions {
560 extend ObjCRetainedFoo {
561 optional string new_val_lower_complex = 2011;
562 optional string new_Val_upper_complex = 2012;
563 optional string newvalue_lower_no_underscore_complex = 2013;
564 optional string newValue_upper_no_underscore_complex = 2014;
565
566 optional int32 new_val_lower_primitive = 2015;
567 optional int32 new_Val_upper_primitive = 2016;
568 optional int32 newvalue_lower_no_underscore_primitive = 2017;
569 optional int32 newValue_upper_no_underscore_primitive = 2018;
570
571 optional self new_val_lower_message = 2019;
572 optional self new_Val_upper_message = 2020;
573 optional self newvalue_lower_no_underscore_message = 2021;
574 optional self newValue_upper_no_underscore_message = 2022;
575
576 optional Foo new_val_lower_enum = 2023;
577 optional Foo new_Val_upper_enum = 2024;
578 optional Foo newvalue_lower_no_underscore_enum = 2025;
579 optional Foo newValue_upper_no_underscore_enum = 2026;
580
581 repeated string new_val_lower_complex_repeated = 2111;
582 repeated string new_Val_upper_complex_repeated = 2112;
583 repeated string newvalue_lower_no_underscore_complex_repeated = 2113;
584 repeated string newValue_upper_no_underscore_complex_repeated = 2114;
585
586 repeated int32 new_val_lower_primitive_repeated = 2115;
587 repeated int32 new_Val_upper_primitive_repeated = 2116;
588 repeated int32 newvalue_lower_no_underscore_primitive_repeated = 2117;
589 repeated int32 newValue_upper_no_underscore_primitive_repeated = 2118;
590
591 repeated self new_val_lower_message_repeated = 2119;
592 repeated self new_Val_upper_message_repeated = 2120;
593 repeated self newvalue_lower_no_underscore_message_repeated = 2121;
594 repeated self newValue_upper_no_underscore_message_repeated = 2122;
595
596 repeated Foo new_val_lower_enum_repeated = 2123;
597 repeated Foo new_Val_upper_enum_repeated = 2124;
598 repeated Foo newvalue_lower_no_underscore_enum_repeated = 2125;
599 repeated Foo newValue_upper_no_underscore_enum_repeated = 2126;
600
601 optional string alloc_val_lower_complex = 2211;
602 optional string alloc_Val_upper_complex = 2212;
603 optional string allocvalue_lower_no_underscore_complex = 2213;
604 optional string allocValue_upper_no_underscore_complex = 2214;
605
606 optional int32 alloc_val_lower_primitive = 2215;
607 optional int32 alloc_Val_upper_primitive = 2216;
608 optional int32 allocvalue_lower_no_underscore_primitive = 2217;
609 optional int32 allocValue_upper_no_underscore_primitive = 2218;
610
611 optional self alloc_val_lower_message = 2219;
612 optional self alloc_Val_upper_message = 2220;
613 optional self allocvalue_lower_no_underscore_message = 2221;
614 optional self allocValue_upper_no_underscore_message = 2222;
615
616 optional Foo alloc_val_lower_enum = 2223;
617 optional Foo alloc_Val_upper_enum = 2224;
618 optional Foo allocvalue_lower_no_underscore_enum = 2225;
619 optional Foo allocValue_upper_no_underscore_enum = 2226;
620
621 repeated string alloc_val_lower_complex_repeated = 2311;
622 repeated string alloc_Val_upper_complex_repeated = 2312;
623 repeated string allocvalue_lower_no_underscore_complex_repeated = 2313;
624 repeated string allocValue_upper_no_underscore_complex_repeated = 2314;
625
626 repeated int32 alloc_val_lower_primitive_repeated = 2315;
627 repeated int32 alloc_Val_upper_primitive_repeated = 2316;
628 repeated int32 allocvalue_lower_no_underscore_primitive_repeated = 2317;
629 repeated int32 allocValue_upper_no_underscore_primitive_repeated = 2318;
630
631 repeated self alloc_val_lower_message_repeated = 2319;
632 repeated self alloc_Val_upper_message_repeated = 2320;
633 repeated self allocvalue_lower_no_underscore_message_repeated = 2321;
634 repeated self allocValue_upper_no_underscore_message_repeated = 2322;
635
636 repeated Foo alloc_val_lower_enum_repeated = 2323;
637 repeated Foo alloc_Val_upper_enum_repeated = 2324;
638 repeated Foo allocvalue_lower_no_underscore_enum_repeated = 2325;
639 repeated Foo allocValue_upper_no_underscore_enum_repeated = 2326;
640
641 optional string copy_val_lower_complex = 2411;
642 optional string copy_Val_upper_complex = 2412;
643 optional string copyvalue_lower_no_underscore_complex = 2413;
644 optional string copyValue_upper_no_underscore_complex = 2414;
645
646 optional int32 copy_val_lower_primitive = 2415;
647 optional int32 copy_Val_upper_primitive = 2416;
648 optional int32 copyvalue_lower_no_underscore_primitive = 2417;
649 optional int32 copyValue_upper_no_underscore_primitive = 2418;
650
651 optional self copy_val_lower_message = 2419;
652 optional self copy_Val_upper_message = 2420;
653 optional self copyvalue_lower_no_underscore_message = 2421;
654 optional self copyValue_upper_no_underscore_message = 2422;
655
656 optional Foo copy_val_lower_enum = 2423;
657 optional Foo copy_Val_upper_enum = 2424;
658 optional Foo copyvalue_lower_no_underscore_enum = 2425;
659 optional Foo copyValue_upper_no_underscore_enum = 2426;
660
661 repeated string copy_val_lower_complex_repeated = 2511;
662 repeated string copy_Val_upper_complex_repeated = 2512;
663 repeated string copyvalue_lower_no_underscore_complex_repeated = 2513;
664 repeated string copyValue_upper_no_underscore_complex_repeated = 2514;
665
666 repeated int32 copy_val_lower_primitive_repeated = 2515;
667 repeated int32 copy_Val_upper_primitive_repeated = 2516;
668 repeated int32 copyvalue_lower_no_underscore_primitive_repeated = 2517;
669 repeated int32 copyValue_upper_no_underscore_primitive_repeated = 2518;
670
671 repeated self copy_val_lower_message_repeated = 2519;
672 repeated self copy_Val_upper_message_repeated = 2520;
673 repeated self copyvalue_lower_no_underscore_message_repeated = 2521;
674 repeated self copyValue_upper_no_underscore_message_repeated = 2522;
675
676 repeated Foo copy_val_lower_enum_repeated = 2523;
677 repeated Foo copy_Val_upper_enum_repeated = 2524;
678 repeated Foo copyvalue_lower_no_underscore_enum_repeated = 2525;
679 repeated Foo copyValue_upper_no_underscore_enum_repeated = 2526;
680
681 optional string mutableCopy_val_lower_complex = 2611;
682 optional string mutableCopy_Val_upper_complex = 2612;
683 optional string mutableCopyvalue_lower_no_underscore_complex = 2613;
684 optional string mutableCopyValue_upper_no_underscore_complex = 2614;
685
686 optional int32 mutableCopy_val_lower_primitive = 2615;
687 optional int32 mutableCopy_Val_upper_primitive = 2616;
688 optional int32 mutableCopyvalue_lower_no_underscore_primitive = 2617;
689 optional int32 mutableCopyValue_upper_no_underscore_primitive = 2618;
690
691 optional self mutableCopy_val_lower_message = 2619;
692 optional self mutableCopy_Val_upper_message = 2620;
693 optional self mutableCopyvalue_lower_no_underscore_message = 2621;
694 optional self mutableCopyValue_upper_no_underscore_message = 2622;
695
696 optional Foo mutableCopy_val_lower_enum = 2623;
697 optional Foo mutableCopy_Val_upper_enum = 2624;
698 optional Foo mutableCopyvalue_lower_no_underscore_enum = 2625;
699 optional Foo mutableCopyValue_upper_no_underscore_enum = 2626;
700
701 repeated string mutableCopy_val_lower_complex_repeated = 2711;
702 repeated string mutableCopy_Val_upper_complex_repeated = 2712;
703 repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 2713;
704 repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 2714;
705
706 repeated int32 mutableCopy_val_lower_primitive_repeated = 2715;
707 repeated int32 mutableCopy_Val_upper_primitive_repeated = 2716;
708 repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 2717;
709 repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 2718;
710
711 repeated self mutableCopy_val_lower_message_repeated = 2719;
712 repeated self mutableCopy_Val_upper_message_repeated = 2720;
713 repeated self mutableCopyvalue_lower_no_underscore_message_repeated = 2721;
714 repeated self mutableCopyValue_upper_no_underscore_message_repeated = 2722;
715
716 repeated Foo mutableCopy_val_lower_enum_repeated = 2723;
717 repeated Foo mutableCopy_Val_upper_enum_repeated = 2724;
718 repeated Foo mutableCopyvalue_lower_no_underscore_enum_repeated = 2725;
719 repeated Foo mutableCopyValue_upper_no_underscore_enum_repeated = 2726;
720 }
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400721}
722
723// Test handling of fields that are the retained names.
724message ObjCRetainedComplex {
725 optional string new = 1;
726 optional string alloc = 2;
727 optional string copy = 3;
728 optional string mutableCopy = 4;
729}
730
731message ObjCRetainedComplexRepeated {
732 repeated string new = 1;
733 repeated string alloc = 2;
734 repeated string copy = 3;
735 repeated string mutableCopy = 4;
736}
737
738message ObjCRetainedPrimitive {
739 optional int32 new = 1;
740 optional int32 alloc = 2;
741 optional int32 copy = 3;
742 optional int32 mutableCopy = 4;
743}
744
745message ObjCRetainedPrimitiveRepeated {
746 repeated int32 new = 1;
747 repeated int32 alloc = 2;
748 repeated int32 copy = 3;
749 repeated int32 mutableCopy = 4;
750}
751
752message ObjCRetainedMessage {
753 optional self new = 1;
754 optional self alloc = 2;
755 optional self copy = 3;
756 optional self mutableCopy = 4;
757}
758
759message ObjCRetainedMessageRepeated {
760 repeated self new = 1;
761 repeated self alloc = 2;
762 repeated self copy = 3;
763 repeated self mutableCopy = 4;
764}
765
766// Test Handling some MacTypes
767message Point {
768 message Rect {
769 optional int32 TimeValue = 1;
770 }
771}
772
773// Test some weird defaults that we see in protos.
774message ObjcWeirdDefaults {
775 // Set default values that match the protocol buffer defined defaults to
776 // confirm hasDefault and the default values are set correctly.
777 optional string foo = 1 [default = ""];
778 optional bytes bar = 2 [default = ""];
779}
780
781// Used to confirm negative enum values work as expected.
782message EnumTestMsg {
783 enum MyEnum {
784 ZERO = 0;
785 ONE = 1;
786 TWO = 2;
787 NEG_ONE = -1;
788 NEG_TWO = -2;
789 }
790 optional MyEnum foo = 1;
791 optional MyEnum bar = 2 [default = ONE];
792 optional MyEnum baz = 3 [default = NEG_ONE];
793
794 repeated MyEnum mumble = 4;
795}
Thomas Van Lenten18b6a322016-04-26 14:40:11 -0400796
Feng Xiaoafe98de2018-08-22 11:55:30 -0700797// Test case for https://github.com/protocolbuffers/protobuf/issues/1453
Thomas Van Lenten18b6a322016-04-26 14:40:11 -0400798// Message with no explicit defaults, but a non zero default for an enum.
799message MessageWithOneBasedEnum {
800 enum OneBasedEnum {
801 ONE = 1;
802 TWO = 2;
803 }
804 optional OneBasedEnum enum_field = 1;
805}
Thomas Van Lenten30646282016-04-27 13:11:16 -0400806
807// Message with all bools for testing things related to bool storage.
808message BoolOnlyMessage {
809 optional bool bool_field_1 = 1;
810 optional bool bool_field_2 = 2;
811 optional bool bool_field_3 = 3;
812 optional bool bool_field_4 = 4;
813 optional bool bool_field_5 = 5;
814 optional bool bool_field_6 = 6;
815 optional bool bool_field_7 = 7;
816 optional bool bool_field_8 = 8;
817 optional bool bool_field_9 = 9;
818 optional bool bool_field_10 = 10;
819 optional bool bool_field_11 = 11;
820 optional bool bool_field_12 = 12;
821 optional bool bool_field_13 = 13;
822 optional bool bool_field_14 = 14;
823 optional bool bool_field_15 = 15;
824 optional bool bool_field_16 = 16;
825 optional bool bool_field_17 = 17;
826 optional bool bool_field_18 = 18;
827 optional bool bool_field_19 = 19;
828 optional bool bool_field_20 = 20;
829 optional bool bool_field_21 = 21;
830 optional bool bool_field_22 = 22;
831 optional bool bool_field_23 = 23;
832 optional bool bool_field_24 = 24;
833 optional bool bool_field_25 = 25;
834 optional bool bool_field_26 = 26;
835 optional bool bool_field_27 = 27;
836 optional bool bool_field_28 = 28;
837 optional bool bool_field_29 = 29;
838 optional bool bool_field_30 = 30;
839 optional bool bool_field_31 = 31;
840 optional bool bool_field_32 = 32;
841}
Thomas Van Lenten7da023b2016-05-09 13:53:20 -0400842
843// Reference to a WKT to test (via generated code inspection), the handling
844// of #imports. Within the WKTs, references to each other are just path
845// based imports, but when reference from another proto file, they should be
846// conditional to support the framework import style.
847message WKTRefereceMessage {
848 optional google.protobuf.Any an_any = 1;
849}
Thomas Van Lentend5297202018-12-17 17:20:56 -0500850
851// This is in part a compile test, it ensures that when aliases end up with
852// the same ObjC name, we drop them to avoid the duplication names. There
853// is a test to ensure the descriptors are still generated to support
854// reflection and TextFormat.
855enum TestEnumObjCNameCollision {
856 option allow_alias = true;
857
858 FOO = 1;
859 foo = 1;
860
861 BAR = 2;
862 mumble = 2;
863 MUMBLE = 2;
864}