unittest_objc.proto 16 KB

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