test.proto 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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: mwr@google.com (Mark Rawling)
  31. syntax = "proto2";
  32. option java_package = "com.google.apps.jspb.proto";
  33. option java_multiple_files = true;
  34. import "google/protobuf/descriptor.proto";
  35. package jspb.test;
  36. message Empty {
  37. }
  38. enum OuterEnum {
  39. FOO = 1;
  40. BAR = 2;
  41. }
  42. message EnumContainer {
  43. optional OuterEnum outer_enum = 1;
  44. }
  45. message Simple1 {
  46. required string a_string = 1;
  47. repeated string a_repeated_string = 2;
  48. optional bool a_boolean = 3;
  49. }
  50. // A message that differs from Simple1 only by name
  51. message Simple2 {
  52. required string a_string = 1;
  53. repeated string a_repeated_string = 2;
  54. }
  55. message SpecialCases {
  56. required string normal = 1;
  57. // Examples of Js reserved names that are converted to pb_<name>.
  58. required string default = 2;
  59. required string function = 3;
  60. required string var = 4;
  61. }
  62. message OptionalFields {
  63. message Nested {
  64. optional int32 an_int = 1;
  65. }
  66. optional string a_string = 1;
  67. required bool a_bool = 2;
  68. optional Nested a_nested_message = 3;
  69. repeated Nested a_repeated_message = 4;
  70. repeated string a_repeated_string = 5;
  71. }
  72. message HasExtensions {
  73. optional string str1 = 1;
  74. optional string str2 = 2;
  75. optional string str3 = 3;
  76. extensions 10 to max;
  77. }
  78. message Complex {
  79. message Nested {
  80. required int32 an_int = 2;
  81. }
  82. required string a_string = 1;
  83. required bool an_out_of_order_bool = 9;
  84. optional Nested a_nested_message = 4;
  85. repeated Nested a_repeated_message = 5;
  86. repeated string a_repeated_string = 7;
  87. }
  88. message OuterMessage {
  89. // Make sure this doesn't conflict with the other Complex message.
  90. message Complex {
  91. optional int32 inner_complex_field = 1;
  92. }
  93. }
  94. message IsExtension {
  95. extend HasExtensions {
  96. optional IsExtension ext_field = 100;
  97. }
  98. optional string ext1 = 1;
  99. // Extensions of proto2 Descriptor messages will be ignored.
  100. extend google.protobuf.EnumOptions {
  101. optional string simple_option = 42113038;
  102. }
  103. }
  104. message IndirectExtension {
  105. extend HasExtensions {
  106. optional Simple1 simple = 101;
  107. optional string str = 102;
  108. repeated string repeated_str = 103;
  109. repeated Simple1 repeated_simple = 104;
  110. }
  111. }
  112. extend HasExtensions {
  113. optional Simple1 simple1 = 105;
  114. }
  115. message DefaultValues {
  116. enum Enum {
  117. E1 = 13;
  118. E2 = 77;
  119. }
  120. optional string string_field = 1 [default="default<>\'\"abc"];
  121. optional bool bool_field = 2 [default=true];
  122. optional int64 int_field = 3 [default=11];
  123. optional Enum enum_field = 4 [default=E1];
  124. optional string empty_field = 6 [default=""];
  125. optional bytes bytes_field = 8 [default="moo"]; // Base64 encoding is "bW9v"
  126. }
  127. message FloatingPointFields {
  128. optional float optional_float_field = 1;
  129. required float required_float_field = 2;
  130. repeated float repeated_float_field = 3;
  131. optional float default_float_field = 4 [default = 2.0];
  132. optional double optional_double_field = 5;
  133. required double required_double_field = 6;
  134. repeated double repeated_double_field = 7;
  135. optional double default_double_field = 8 [default = 2.0];
  136. }
  137. message TestClone {
  138. optional string str = 1;
  139. optional Simple1 simple1 = 3;
  140. repeated Simple1 simple2 = 5;
  141. optional bytes bytes_field = 6;
  142. optional string unused = 7;
  143. extensions 10 to max;
  144. }
  145. message CloneExtension {
  146. extend TestClone {
  147. optional CloneExtension ext_field = 100;
  148. }
  149. optional string ext = 2;
  150. }
  151. message TestGroup {
  152. repeated group RepeatedGroup = 1 {
  153. required string id = 1;
  154. repeated bool some_bool = 2;
  155. }
  156. required group RequiredGroup = 2 {
  157. required string id = 1;
  158. }
  159. optional group OptionalGroup = 3 {
  160. required string id = 1;
  161. }
  162. optional string id = 4;
  163. required Simple2 required_simple = 5;
  164. optional Simple2 optional_simple = 6;
  165. }
  166. message TestGroup1 {
  167. optional TestGroup.RepeatedGroup group = 1;
  168. }
  169. message TestReservedNames {
  170. optional int32 extension = 1;
  171. extensions 10 to max;
  172. }
  173. message TestReservedNamesExtension {
  174. extend TestReservedNames {
  175. optional int32 foo = 10;
  176. }
  177. }
  178. message TestMessageWithOneof {
  179. oneof partial_oneof {
  180. string pone = 3;
  181. string pthree = 5;
  182. }
  183. oneof recursive_oneof {
  184. TestMessageWithOneof rone = 6;
  185. string rtwo = 7;
  186. }
  187. optional bool normal_field = 8;
  188. repeated string repeated_field = 9;
  189. oneof default_oneof_a {
  190. int32 aone = 10 [default = 1234];
  191. int32 atwo = 11;
  192. }
  193. oneof default_oneof_b {
  194. int32 bone = 12;
  195. int32 btwo = 13 [default = 1234];
  196. }
  197. }
  198. message TestEndsWithBytes {
  199. optional int32 value = 1;
  200. optional bytes data = 2;
  201. }