诸暨麻将添加redis
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

431 lines
13 KiB

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