/thirdparty/breakpad/third_party/protobuf/protobuf/src/google/protobuf/unittest_custom_options.proto

http://github.com/tomahawk-player/tomahawk · Protocol Buffers · 366 lines · 236 code · 66 blank · 64 comment · 0 complexity · 1e5cbaae39b4428e000337c4ae8d3793 MD5 · raw file

  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // http://code.google.com/p/protobuf/
  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. // Author: benjy@google.com (Benjy Weinberger)
  31. // Based on original Protocol Buffers design by
  32. // Sanjay Ghemawat, Jeff Dean, and others.
  33. //
  34. // A proto file used to test the "custom options" feature of proto2.
  35. // Some generic_services option(s) added automatically.
  36. // See: http://go/proto2-generic-services-default
  37. option cc_generic_services = true; // auto-added
  38. option java_generic_services = true; // auto-added
  39. option py_generic_services = true;
  40. // A custom file option (defined below).
  41. option (file_opt1) = 9876543210;
  42. import "google/protobuf/descriptor.proto";
  43. // We don't put this in a package within proto2 because we need to make sure
  44. // that the generated code doesn't depend on being in the proto2 namespace.
  45. package protobuf_unittest;
  46. // Some simple test custom options of various types.
  47. extend google.protobuf.FileOptions {
  48. optional uint64 file_opt1 = 7736974;
  49. }
  50. extend google.protobuf.MessageOptions {
  51. optional int32 message_opt1 = 7739036;
  52. }
  53. extend google.protobuf.FieldOptions {
  54. optional fixed64 field_opt1 = 7740936;
  55. // This is useful for testing that we correctly register default values for
  56. // extension options.
  57. optional int32 field_opt2 = 7753913 [default=42];
  58. }
  59. extend google.protobuf.EnumOptions {
  60. optional sfixed32 enum_opt1 = 7753576;
  61. }
  62. extend google.protobuf.EnumValueOptions {
  63. optional int32 enum_value_opt1 = 1560678;
  64. }
  65. extend google.protobuf.ServiceOptions {
  66. optional sint64 service_opt1 = 7887650;
  67. }
  68. enum MethodOpt1 {
  69. METHODOPT1_VAL1 = 1;
  70. METHODOPT1_VAL2 = 2;
  71. }
  72. extend google.protobuf.MethodOptions {
  73. optional MethodOpt1 method_opt1 = 7890860;
  74. }
  75. // A test message with custom options at all possible locations (and also some
  76. // regular options, to make sure they interact nicely).
  77. message TestMessageWithCustomOptions {
  78. option message_set_wire_format = false;
  79. option (message_opt1) = -56;
  80. optional string field1 = 1 [ctype=CORD,
  81. (field_opt1)=8765432109];
  82. enum AnEnum {
  83. option (enum_opt1) = -789;
  84. ANENUM_VAL1 = 1;
  85. ANENUM_VAL2 = 2 [(enum_value_opt1) = 123];
  86. }
  87. }
  88. // A test RPC service with custom options at all possible locations (and also
  89. // some regular options, to make sure they interact nicely).
  90. message CustomOptionFooRequest {
  91. }
  92. message CustomOptionFooResponse {
  93. }
  94. service TestServiceWithCustomOptions {
  95. option (service_opt1) = -9876543210;
  96. rpc Foo(CustomOptionFooRequest) returns (CustomOptionFooResponse) {
  97. option (method_opt1) = METHODOPT1_VAL2;
  98. }
  99. }
  100. // Options of every possible field type, so we can test them all exhaustively.
  101. message DummyMessageContainingEnum {
  102. enum TestEnumType {
  103. TEST_OPTION_ENUM_TYPE1 = 22;
  104. TEST_OPTION_ENUM_TYPE2 = -23;
  105. }
  106. }
  107. message DummyMessageInvalidAsOptionType {
  108. }
  109. extend google.protobuf.MessageOptions {
  110. optional bool bool_opt = 7706090;
  111. optional int32 int32_opt = 7705709;
  112. optional int64 int64_opt = 7705542;
  113. optional uint32 uint32_opt = 7704880;
  114. optional uint64 uint64_opt = 7702367;
  115. optional sint32 sint32_opt = 7701568;
  116. optional sint64 sint64_opt = 7700863;
  117. optional fixed32 fixed32_opt = 7700307;
  118. optional fixed64 fixed64_opt = 7700194;
  119. optional sfixed32 sfixed32_opt = 7698645;
  120. optional sfixed64 sfixed64_opt = 7685475;
  121. optional float float_opt = 7675390;
  122. optional double double_opt = 7673293;
  123. optional string string_opt = 7673285;
  124. optional bytes bytes_opt = 7673238;
  125. optional DummyMessageContainingEnum.TestEnumType enum_opt = 7673233;
  126. optional DummyMessageInvalidAsOptionType message_type_opt = 7665967;
  127. }
  128. message CustomOptionMinIntegerValues {
  129. option (bool_opt) = false;
  130. option (int32_opt) = -0x80000000;
  131. option (int64_opt) = -0x8000000000000000;
  132. option (uint32_opt) = 0;
  133. option (uint64_opt) = 0;
  134. option (sint32_opt) = -0x80000000;
  135. option (sint64_opt) = -0x8000000000000000;
  136. option (fixed32_opt) = 0;
  137. option (fixed64_opt) = 0;
  138. option (sfixed32_opt) = -0x80000000;
  139. option (sfixed64_opt) = -0x8000000000000000;
  140. }
  141. message CustomOptionMaxIntegerValues {
  142. option (bool_opt) = true;
  143. option (int32_opt) = 0x7FFFFFFF;
  144. option (int64_opt) = 0x7FFFFFFFFFFFFFFF;
  145. option (uint32_opt) = 0xFFFFFFFF;
  146. option (uint64_opt) = 0xFFFFFFFFFFFFFFFF;
  147. option (sint32_opt) = 0x7FFFFFFF;
  148. option (sint64_opt) = 0x7FFFFFFFFFFFFFFF;
  149. option (fixed32_opt) = 0xFFFFFFFF;
  150. option (fixed64_opt) = 0xFFFFFFFFFFFFFFFF;
  151. option (sfixed32_opt) = 0x7FFFFFFF;
  152. option (sfixed64_opt) = 0x7FFFFFFFFFFFFFFF;
  153. }
  154. message CustomOptionOtherValues {
  155. option (int32_opt) = -100; // To test sign-extension.
  156. option (float_opt) = 12.3456789;
  157. option (double_opt) = 1.234567890123456789;
  158. option (string_opt) = "Hello, \"World\"";
  159. option (bytes_opt) = "Hello\0World";
  160. option (enum_opt) = TEST_OPTION_ENUM_TYPE2;
  161. }
  162. message SettingRealsFromPositiveInts {
  163. option (float_opt) = 12;
  164. option (double_opt) = 154;
  165. }
  166. message SettingRealsFromNegativeInts {
  167. option (float_opt) = -12;
  168. option (double_opt) = -154;
  169. }
  170. // Options of complex message types, themselves combined and extended in
  171. // various ways.
  172. message ComplexOptionType1 {
  173. optional int32 foo = 1;
  174. optional int32 foo2 = 2;
  175. optional int32 foo3 = 3;
  176. extensions 100 to max;
  177. }
  178. message ComplexOptionType2 {
  179. optional ComplexOptionType1 bar = 1;
  180. optional int32 baz = 2;
  181. message ComplexOptionType4 {
  182. optional int32 waldo = 1;
  183. extend google.protobuf.MessageOptions {
  184. optional ComplexOptionType4 complex_opt4 = 7633546;
  185. }
  186. }
  187. optional ComplexOptionType4 fred = 3;
  188. extensions 100 to max;
  189. }
  190. message ComplexOptionType3 {
  191. optional int32 qux = 1;
  192. optional group ComplexOptionType5 = 2 {
  193. optional int32 plugh = 3;
  194. }
  195. }
  196. extend ComplexOptionType1 {
  197. optional int32 quux = 7663707;
  198. optional ComplexOptionType3 corge = 7663442;
  199. }
  200. extend ComplexOptionType2 {
  201. optional int32 grault = 7650927;
  202. optional ComplexOptionType1 garply = 7649992;
  203. }
  204. extend google.protobuf.MessageOptions {
  205. optional protobuf_unittest.ComplexOptionType1 complex_opt1 = 7646756;
  206. optional ComplexOptionType2 complex_opt2 = 7636949;
  207. optional ComplexOptionType3 complex_opt3 = 7636463;
  208. optional group ComplexOpt6 = 7595468 {
  209. optional int32 xyzzy = 7593951;
  210. }
  211. }
  212. // Note that we try various different ways of naming the same extension.
  213. message VariousComplexOptions {
  214. option (.protobuf_unittest.complex_opt1).foo = 42;
  215. option (protobuf_unittest.complex_opt1).(.protobuf_unittest.quux) = 324;
  216. option (.protobuf_unittest.complex_opt1).(protobuf_unittest.corge).qux = 876;
  217. option (complex_opt2).baz = 987;
  218. option (complex_opt2).(grault) = 654;
  219. option (complex_opt2).bar.foo = 743;
  220. option (complex_opt2).bar.(quux) = 1999;
  221. option (complex_opt2).bar.(protobuf_unittest.corge).qux = 2008;
  222. option (complex_opt2).(garply).foo = 741;
  223. option (complex_opt2).(garply).(.protobuf_unittest.quux) = 1998;
  224. option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121;
  225. option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971;
  226. option (complex_opt2).fred.waldo = 321;
  227. option (protobuf_unittest.complex_opt3).qux = 9;
  228. option (complex_opt3).complexoptiontype5.plugh = 22;
  229. option (complexopt6).xyzzy = 24;
  230. }
  231. // ------------------------------------------------------
  232. // Definitions for testing aggregate option parsing.
  233. // See descriptor_unittest.cc.
  234. message AggregateMessageSet {
  235. option message_set_wire_format = true;
  236. extensions 4 to max;
  237. }
  238. message AggregateMessageSetElement {
  239. extend AggregateMessageSet {
  240. optional AggregateMessageSetElement message_set_extension = 15447542;
  241. }
  242. optional string s = 1;
  243. }
  244. // A helper type used to test aggregate option parsing
  245. message Aggregate {
  246. optional int32 i = 1;
  247. optional string s = 2;
  248. // A nested object
  249. optional Aggregate sub = 3;
  250. // To test the parsing of extensions inside aggregate values
  251. optional google.protobuf.FileOptions file = 4;
  252. extend google.protobuf.FileOptions {
  253. optional Aggregate nested = 15476903;
  254. }
  255. // An embedded message set
  256. optional AggregateMessageSet mset = 5;
  257. }
  258. // Allow Aggregate to be used as an option at all possible locations
  259. // in the .proto grammer.
  260. extend google.protobuf.FileOptions { optional Aggregate fileopt = 15478479; }
  261. extend google.protobuf.MessageOptions { optional Aggregate msgopt = 15480088; }
  262. extend google.protobuf.FieldOptions { optional Aggregate fieldopt = 15481374; }
  263. extend google.protobuf.EnumOptions { optional Aggregate enumopt = 15483218; }
  264. extend google.protobuf.EnumValueOptions { optional Aggregate enumvalopt = 15486921; }
  265. extend google.protobuf.ServiceOptions { optional Aggregate serviceopt = 15497145; }
  266. extend google.protobuf.MethodOptions { optional Aggregate methodopt = 15512713; }
  267. // Try using AggregateOption at different points in the proto grammar
  268. option (fileopt) = {
  269. s: 'FileAnnotation'
  270. // Also test the handling of comments
  271. /* of both types */ i: 100
  272. sub { s: 'NestedFileAnnotation' }
  273. // Include a google.protobuf.FileOptions and recursively extend it with
  274. // another fileopt.
  275. file {
  276. [protobuf_unittest.fileopt] {
  277. s:'FileExtensionAnnotation'
  278. }
  279. }
  280. // A message set inside an option value
  281. mset {
  282. [protobuf_unittest.AggregateMessageSetElement.message_set_extension] {
  283. s: 'EmbeddedMessageSetElement'
  284. }
  285. }
  286. };
  287. message AggregateMessage {
  288. option (msgopt) = { i:101 s:'MessageAnnotation' };
  289. optional int32 fieldname = 1 [(fieldopt) = { s:'FieldAnnotation' }];
  290. }
  291. service AggregateService {
  292. option (serviceopt) = { s:'ServiceAnnotation' };
  293. rpc Method (AggregateMessage) returns (AggregateMessage) {
  294. option (methodopt) = { s:'MethodAnnotation' };
  295. }
  296. }
  297. enum AggregateEnum {
  298. option (enumopt) = { s:'EnumAnnotation' };
  299. VALUE = 1 [(enumvalopt) = { s:'EnumValueAnnotation' }];
  300. }