testbinary.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. // LINT: ALLOW_GROUPS
  31. syntax = "proto2";
  32. package jspb.test;
  33. // These types are borrowed from `unittest.proto` in the protobuf tree. We want
  34. // to ensure that the binary-format support will handle all field types
  35. // properly.
  36. message TestAllTypes {
  37. optional int32 optional_int32 = 1;
  38. optional int64 optional_int64 = 2;
  39. optional uint32 optional_uint32 = 3;
  40. optional uint64 optional_uint64 = 4;
  41. optional sint32 optional_sint32 = 5;
  42. optional sint64 optional_sint64 = 6;
  43. optional fixed32 optional_fixed32 = 7;
  44. optional fixed64 optional_fixed64 = 8;
  45. optional sfixed32 optional_sfixed32 = 9;
  46. optional sfixed64 optional_sfixed64 = 10;
  47. optional float optional_float = 11;
  48. optional double optional_double = 12;
  49. optional bool optional_bool = 13;
  50. optional string optional_string = 14;
  51. optional bytes optional_bytes = 15;
  52. optional group OptionalGroup = 16 {
  53. optional int32 a = 17;
  54. }
  55. optional ForeignMessage optional_foreign_message = 19;
  56. optional ForeignEnum optional_foreign_enum = 22;
  57. // Repeated
  58. repeated int32 repeated_int32 = 31;
  59. repeated int64 repeated_int64 = 32;
  60. repeated uint32 repeated_uint32 = 33;
  61. repeated uint64 repeated_uint64 = 34;
  62. repeated sint32 repeated_sint32 = 35;
  63. repeated sint64 repeated_sint64 = 36;
  64. repeated fixed32 repeated_fixed32 = 37;
  65. repeated fixed64 repeated_fixed64 = 38;
  66. repeated sfixed32 repeated_sfixed32 = 39;
  67. repeated sfixed64 repeated_sfixed64 = 40;
  68. repeated float repeated_float = 41;
  69. repeated double repeated_double = 42;
  70. repeated bool repeated_bool = 43;
  71. repeated string repeated_string = 44;
  72. repeated bytes repeated_bytes = 45;
  73. repeated group RepeatedGroup = 46 {
  74. optional int32 a = 47;
  75. }
  76. repeated ForeignMessage repeated_foreign_message = 49;
  77. repeated ForeignEnum repeated_foreign_enum = 52;
  78. // Packed repeated
  79. repeated int32 packed_repeated_int32 = 61 [packed = true];
  80. repeated int64 packed_repeated_int64 = 62 [packed = true];
  81. repeated uint32 packed_repeated_uint32 = 63 [packed = true];
  82. repeated uint64 packed_repeated_uint64 = 64 [packed = true];
  83. repeated sint32 packed_repeated_sint32 = 65 [packed = true];
  84. repeated sint64 packed_repeated_sint64 = 66 [packed = true];
  85. repeated fixed32 packed_repeated_fixed32 = 67 [packed = true];
  86. repeated fixed64 packed_repeated_fixed64 = 68 [packed = true];
  87. repeated sfixed32 packed_repeated_sfixed32 = 69 [packed = true];
  88. repeated sfixed64 packed_repeated_sfixed64 = 70 [packed = true];
  89. repeated float packed_repeated_float = 71 [packed = true];
  90. repeated double packed_repeated_double = 72 [packed = true];
  91. repeated bool packed_repeated_bool = 73 [packed = true];
  92. oneof oneof_field {
  93. uint32 oneof_uint32 = 111;
  94. ForeignMessage oneof_foreign_message = 112;
  95. string oneof_string = 113;
  96. bytes oneof_bytes = 114;
  97. }
  98. }
  99. message ForeignMessage {
  100. optional int32 c = 1;
  101. }
  102. enum ForeignEnum {
  103. FOREIGN_FOO = 4;
  104. FOREIGN_BAR = 5;
  105. FOREIGN_BAZ = 6;
  106. }
  107. message TestExtendable {
  108. extensions 1 to max;
  109. }
  110. message ExtendsWithMessage {
  111. extend TestExtendable {
  112. optional ExtendsWithMessage optional_extension = 19;
  113. repeated ExtendsWithMessage repeated_extension = 49;
  114. }
  115. optional int32 foo = 1;
  116. }
  117. extend TestExtendable {
  118. optional int32 extend_optional_int32 = 1;
  119. optional int64 extend_optional_int64 = 2;
  120. optional uint32 extend_optional_uint32 = 3;
  121. optional uint64 extend_optional_uint64 = 4;
  122. optional sint32 extend_optional_sint32 = 5;
  123. optional sint64 extend_optional_sint64 = 6;
  124. optional fixed32 extend_optional_fixed32 = 7;
  125. optional fixed64 extend_optional_fixed64 = 8;
  126. optional sfixed32 extend_optional_sfixed32 = 9;
  127. optional sfixed64 extend_optional_sfixed64 = 10;
  128. optional float extend_optional_float = 11;
  129. optional double extend_optional_double = 12;
  130. optional bool extend_optional_bool = 13;
  131. optional string extend_optional_string = 14;
  132. optional bytes extend_optional_bytes = 15;
  133. optional ForeignEnum extend_optional_foreign_enum = 22;
  134. repeated int32 extend_repeated_int32 = 31;
  135. repeated int64 extend_repeated_int64 = 32;
  136. repeated uint32 extend_repeated_uint32 = 33;
  137. repeated uint64 extend_repeated_uint64 = 34;
  138. repeated sint32 extend_repeated_sint32 = 35;
  139. repeated sint64 extend_repeated_sint64 = 36;
  140. repeated fixed32 extend_repeated_fixed32 = 37;
  141. repeated fixed64 extend_repeated_fixed64 = 38;
  142. repeated sfixed32 extend_repeated_sfixed32 = 39;
  143. repeated sfixed64 extend_repeated_sfixed64 = 40;
  144. repeated float extend_repeated_float = 41;
  145. repeated double extend_repeated_double = 42;
  146. repeated bool extend_repeated_bool = 43;
  147. repeated string extend_repeated_string = 44;
  148. repeated bytes extend_repeated_bytes = 45;
  149. repeated ForeignEnum extend_repeated_foreign_enum = 52;
  150. repeated int32 extend_packed_repeated_int32 = 61 [packed = true];
  151. repeated int64 extend_packed_repeated_int64 = 62 [packed = true];
  152. repeated uint32 extend_packed_repeated_uint32 = 63 [packed = true];
  153. repeated uint64 extend_packed_repeated_uint64 = 64 [packed = true];
  154. repeated sint32 extend_packed_repeated_sint32 = 65 [packed = true];
  155. repeated sint64 extend_packed_repeated_sint64 = 66 [packed = true];
  156. repeated fixed32 extend_packed_repeated_fixed32 = 67 [packed = true];
  157. repeated fixed64 extend_packed_repeated_fixed64 = 68 [packed = true];
  158. repeated sfixed32 extend_packed_repeated_sfixed32 = 69 [packed = true];
  159. repeated sfixed64 extend_packed_repeated_sfixed64 = 70 [packed = true];
  160. repeated float extend_packed_repeated_float = 71 [packed = true];
  161. repeated double extend_packed_repeated_double = 72 [packed = true];
  162. repeated bool extend_packed_repeated_bool = 73 [packed = true];
  163. repeated ForeignEnum extend_packed_repeated_foreign_enum = 82 [packed = true];
  164. }
  165. message TestMapFields {
  166. map<string, string> map_string_string = 1;
  167. map<string, int32> map_string_int32 = 2;
  168. map<string, int64> map_string_int64 = 3;
  169. map<string, bool> map_string_bool = 4;
  170. map<string, double> map_string_double = 5;
  171. map<string, MapValueEnum> map_string_enum = 6;
  172. map<string, MapValueMessage> map_string_msg = 7;
  173. map<int32, string> map_int32_string = 8;
  174. map<int64, string> map_int64_string = 9;
  175. map<bool, string> map_bool_string = 10;
  176. optional TestMapFields test_map_fields = 11;
  177. map<string, TestMapFields> map_string_testmapfields = 12;
  178. }
  179. // These proto are 'mock map' entries to test the above map deserializing with
  180. // undefined keys. Make sure TestMapFieldsOptionalKeys is written to be
  181. // deserialized by TestMapFields
  182. message MapEntryOptionalKeysStringKey {
  183. optional string key = 1;
  184. optional string value = 2;
  185. }
  186. message MapEntryOptionalKeysInt32Key {
  187. optional int32 key = 1;
  188. optional string value = 2;
  189. }
  190. message MapEntryOptionalKeysInt64Key {
  191. optional int64 key = 1;
  192. optional string value = 2;
  193. }
  194. message MapEntryOptionalKeysBoolKey {
  195. optional bool key = 1;
  196. optional string value = 2;
  197. }
  198. message TestMapFieldsOptionalKeys {
  199. optional MapEntryOptionalKeysStringKey map_string_string = 1;
  200. optional MapEntryOptionalKeysInt32Key map_int32_string = 8;
  201. optional MapEntryOptionalKeysInt64Key map_int64_string = 9;
  202. optional MapEntryOptionalKeysBoolKey map_bool_string = 10;
  203. }
  204. // End mock-map entries
  205. // These proto are 'mock map' entries to test the above map deserializing with
  206. // undefined values. Make sure TestMapFieldsOptionalValues is written to be
  207. // deserialized by TestMapFields
  208. message MapEntryOptionalValuesStringValue {
  209. optional string key = 1;
  210. optional string value = 2;
  211. }
  212. message MapEntryOptionalValuesInt32Value {
  213. optional string key = 1;
  214. optional int32 value = 2;
  215. }
  216. message MapEntryOptionalValuesInt64Value {
  217. optional string key = 1;
  218. optional int64 value = 2;
  219. }
  220. message MapEntryOptionalValuesBoolValue {
  221. optional string key = 1;
  222. optional bool value = 2;
  223. }
  224. message MapEntryOptionalValuesDoubleValue {
  225. optional string key = 1;
  226. optional double value = 2;
  227. }
  228. message MapEntryOptionalValuesEnumValue {
  229. optional string key = 1;
  230. optional MapValueEnum value = 2;
  231. }
  232. message MapEntryOptionalValuesMessageValue {
  233. optional string key = 1;
  234. optional MapValueMessage value = 2;
  235. }
  236. message TestMapFieldsOptionalValues {
  237. optional MapEntryOptionalValuesStringValue map_string_string = 1;
  238. optional MapEntryOptionalValuesInt32Value map_string_int32 = 2;
  239. optional MapEntryOptionalValuesInt64Value map_string_int64 = 3;
  240. optional MapEntryOptionalValuesBoolValue map_string_bool = 4;
  241. optional MapEntryOptionalValuesDoubleValue map_string_double = 5;
  242. optional MapEntryOptionalValuesEnumValue map_string_enum = 6;
  243. optional MapEntryOptionalValuesMessageValue map_string_msg = 7;
  244. }
  245. // End mock-map entries
  246. enum MapValueEnum {
  247. MAP_VALUE_FOO = 0;
  248. MAP_VALUE_BAR = 1;
  249. MAP_VALUE_BAZ = 2;
  250. }
  251. message MapValueMessage {
  252. optional int32 foo = 1;
  253. }