unittest_proto3_arena.proto 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. //
  4. // Use of this source code is governed by a BSD-style
  5. // license that can be found in the LICENSE file or at
  6. // https://developers.google.com/open-source/licenses/bsd
  7. syntax = "proto3";
  8. option cc_enable_arenas = true;
  9. import "google/protobuf/unittest_import.proto";
  10. package proto3_arena_unittest;
  11. // This proto includes every type of field in both singular and repeated
  12. // forms.
  13. message TestAllTypes {
  14. message NestedMessage {
  15. // The field name "b" fails to compile in proto1 because it conflicts with
  16. // a local variable named "b" in one of the generated methods. Doh.
  17. // This file needs to compile in proto1 to test backwards-compatibility.
  18. int32 bb = 1;
  19. }
  20. enum NestedEnum {
  21. ZERO = 0;
  22. FOO = 1;
  23. BAR = 2;
  24. BAZ = 3;
  25. NEG = -1; // Intentionally negative.
  26. }
  27. // Singular
  28. int32 optional_int32 = 1;
  29. int64 optional_int64 = 2;
  30. uint32 optional_uint32 = 3;
  31. uint64 optional_uint64 = 4;
  32. sint32 optional_sint32 = 5;
  33. sint64 optional_sint64 = 6;
  34. fixed32 optional_fixed32 = 7;
  35. fixed64 optional_fixed64 = 8;
  36. sfixed32 optional_sfixed32 = 9;
  37. sfixed64 optional_sfixed64 = 10;
  38. float optional_float = 11;
  39. double optional_double = 12;
  40. bool optional_bool = 13;
  41. string optional_string = 14;
  42. bytes optional_bytes = 15;
  43. // Groups are not allowed in proto3.
  44. // optional group OptionalGroup = 16 {
  45. // optional int32 a = 17;
  46. // }
  47. NestedMessage optional_nested_message = 18;
  48. ForeignMessage optional_foreign_message = 19;
  49. protobuf_unittest_import.ImportMessage optional_import_message = 20;
  50. NestedEnum optional_nested_enum = 21;
  51. ForeignEnum optional_foreign_enum = 22;
  52. // Omitted (compared to unittest.proto) because proto2 enums are not allowed
  53. // inside proto2 messages.
  54. //
  55. // optional protobuf_unittest_import.ImportEnum optional_import_enum = 23;
  56. string optional_string_piece = 24 [ctype=STRING_PIECE];
  57. string optional_cord = 25 [ctype=CORD];
  58. bytes optional_bytes_cord = 86 [ctype=CORD];
  59. // Defined in unittest_import_public.proto
  60. protobuf_unittest_import.PublicImportMessage
  61. optional_public_import_message = 26;
  62. NestedMessage optional_lazy_message = 27 [lazy=true];
  63. NestedMessage optional_unverified_lazy_message = 28 [unverified_lazy=true];
  64. protobuf_unittest_import.ImportMessage optional_lazy_import_message = 115
  65. [lazy = true];
  66. // Repeated
  67. repeated int32 repeated_int32 = 31;
  68. repeated int64 repeated_int64 = 32;
  69. repeated uint32 repeated_uint32 = 33;
  70. repeated uint64 repeated_uint64 = 34;
  71. repeated sint32 repeated_sint32 = 35;
  72. repeated sint64 repeated_sint64 = 36;
  73. repeated fixed32 repeated_fixed32 = 37;
  74. repeated fixed64 repeated_fixed64 = 38;
  75. repeated sfixed32 repeated_sfixed32 = 39;
  76. repeated sfixed64 repeated_sfixed64 = 40;
  77. repeated float repeated_float = 41;
  78. repeated double repeated_double = 42;
  79. repeated bool repeated_bool = 43;
  80. repeated string repeated_string = 44;
  81. repeated bytes repeated_bytes = 45;
  82. // Optional
  83. optional int32 proto3_optional_int32 = 116;
  84. optional int64 proto3_optional_int64 = 117;
  85. optional uint32 proto3_optional_uint32 = 118;
  86. optional uint64 proto3_optional_uint64 = 119;
  87. optional sint32 proto3_optional_sint32 = 120;
  88. optional sint64 proto3_optional_sint64 = 121;
  89. optional fixed32 proto3_optional_fixed32 = 122;
  90. optional fixed64 proto3_optional_fixed64 = 123;
  91. optional sfixed32 proto3_optional_sfixed32 = 124;
  92. optional sfixed64 proto3_optional_sfixed64 = 125;
  93. optional float proto3_optional_float = 126;
  94. optional double proto3_optional_double = 127;
  95. optional bool proto3_optional_bool = 128;
  96. optional string proto3_optional_string = 129;
  97. optional bytes proto3_optional_bytes = 130;
  98. // Groups are not allowed in proto3.
  99. // repeated group RepeatedGroup = 46 {
  100. // optional int32 a = 47;
  101. // }
  102. repeated NestedMessage repeated_nested_message = 48;
  103. repeated ForeignMessage repeated_foreign_message = 49;
  104. repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
  105. repeated NestedEnum repeated_nested_enum = 51;
  106. repeated ForeignEnum repeated_foreign_enum = 52;
  107. // Omitted (compared to unittest.proto) because proto2 enums are not allowed
  108. // inside proto2 messages.
  109. //
  110. // repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
  111. repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
  112. repeated string repeated_cord = 55 [ctype=CORD];
  113. repeated NestedMessage repeated_lazy_message = 57 ;
  114. oneof oneof_field {
  115. uint32 oneof_uint32 = 111;
  116. NestedMessage oneof_nested_message = 112;
  117. string oneof_string = 113;
  118. bytes oneof_bytes = 114;
  119. }
  120. }
  121. // Test messages for packed fields
  122. message TestPackedTypes {
  123. repeated int32 packed_int32 = 90 [packed = true];
  124. repeated int64 packed_int64 = 91 [packed = true];
  125. repeated uint32 packed_uint32 = 92 [packed = true];
  126. repeated uint64 packed_uint64 = 93 [packed = true];
  127. repeated sint32 packed_sint32 = 94 [packed = true];
  128. repeated sint64 packed_sint64 = 95 [packed = true];
  129. repeated fixed32 packed_fixed32 = 96 [packed = true];
  130. repeated fixed64 packed_fixed64 = 97 [packed = true];
  131. repeated sfixed32 packed_sfixed32 = 98 [packed = true];
  132. repeated sfixed64 packed_sfixed64 = 99 [packed = true];
  133. repeated float packed_float = 100 [packed = true];
  134. repeated double packed_double = 101 [packed = true];
  135. repeated bool packed_bool = 102 [packed = true];
  136. repeated ForeignEnum packed_enum = 103 [packed = true];
  137. }
  138. // Explicitly set packed to false
  139. message TestUnpackedTypes {
  140. repeated int32 repeated_int32 = 1 [packed = false];
  141. repeated int64 repeated_int64 = 2 [packed = false];
  142. repeated uint32 repeated_uint32 = 3 [packed = false];
  143. repeated uint64 repeated_uint64 = 4 [packed = false];
  144. repeated sint32 repeated_sint32 = 5 [packed = false];
  145. repeated sint64 repeated_sint64 = 6 [packed = false];
  146. repeated fixed32 repeated_fixed32 = 7 [packed = false];
  147. repeated fixed64 repeated_fixed64 = 8 [packed = false];
  148. repeated sfixed32 repeated_sfixed32 = 9 [packed = false];
  149. repeated sfixed64 repeated_sfixed64 = 10 [packed = false];
  150. repeated float repeated_float = 11 [packed = false];
  151. repeated double repeated_double = 12 [packed = false];
  152. repeated bool repeated_bool = 13 [packed = false];
  153. repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false];
  154. }
  155. // This proto includes a recursively nested message.
  156. message NestedTestAllTypes {
  157. NestedTestAllTypes child = 1;
  158. TestAllTypes payload = 2;
  159. repeated NestedTestAllTypes repeated_child = 3;
  160. TestAllTypes lazy_payload = 4 [lazy = true];
  161. }
  162. // Define these after TestAllTypes to make sure the compiler can handle
  163. // that.
  164. message ForeignMessage {
  165. int32 c = 1;
  166. }
  167. enum ForeignEnum {
  168. FOREIGN_ZERO = 0;
  169. FOREIGN_FOO = 4;
  170. FOREIGN_BAR = 5;
  171. FOREIGN_BAZ = 6;
  172. FOREIGN_LARGE = 123456; // Large enough to escape the Boxed Integer cache.
  173. }
  174. // TestEmptyMessage is used to test behavior of unknown fields.
  175. message TestEmptyMessage {
  176. }
  177. // Needed for a Python test.
  178. message TestPickleNestedMessage {
  179. message NestedMessage {
  180. int32 bb = 1;
  181. message NestedNestedMessage {
  182. int32 cc = 1;
  183. }
  184. }
  185. }