unittest_proto3_arena_lite.proto 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. package proto3_arena_lite_unittest;
  9. import "google/protobuf/unittest_import.proto";
  10. option cc_enable_arenas = true;
  11. option optimize_for = LITE_RUNTIME;
  12. // This proto includes every type of field in both singular and repeated
  13. // forms.
  14. message TestAllTypes {
  15. message NestedMessage {
  16. // The field name "b" fails to compile in proto1 because it conflicts with
  17. // a local variable named "b" in one of the generated methods. Doh.
  18. // This file needs to compile in proto1 to test backwards-compatibility.
  19. int32 bb = 1;
  20. }
  21. enum NestedEnum {
  22. ZERO = 0;
  23. FOO = 1;
  24. BAR = 2;
  25. BAZ = 3;
  26. NEG = -1; // Intentionally negative.
  27. }
  28. // Singular
  29. int32 optional_int32 = 1;
  30. int64 optional_int64 = 2;
  31. uint32 optional_uint32 = 3;
  32. uint64 optional_uint64 = 4;
  33. sint32 optional_sint32 = 5;
  34. sint64 optional_sint64 = 6;
  35. fixed32 optional_fixed32 = 7;
  36. fixed64 optional_fixed64 = 8;
  37. sfixed32 optional_sfixed32 = 9;
  38. sfixed64 optional_sfixed64 = 10;
  39. float optional_float = 11;
  40. double optional_double = 12;
  41. bool optional_bool = 13;
  42. string optional_string = 14;
  43. bytes optional_bytes = 15;
  44. // Groups are not allowed in proto3.
  45. // optional group OptionalGroup = 16 {
  46. // optional int32 a = 17;
  47. // }
  48. NestedMessage optional_nested_message = 18;
  49. ForeignMessage optional_foreign_message = 19;
  50. protobuf_unittest_import.ImportMessage optional_import_message = 20;
  51. NestedEnum optional_nested_enum = 21;
  52. ForeignEnum optional_foreign_enum = 22;
  53. // Omitted (compared to unittest.proto) because proto2 enums are not allowed
  54. // inside proto2 messages.
  55. //
  56. // optional protobuf_unittest_import.ImportEnum optional_import_enum = 23;
  57. string optional_string_piece = 24 [ctype = STRING_PIECE];
  58. string optional_cord = 25 [ctype = CORD];
  59. // Defined in unittest_import_public.proto
  60. protobuf_unittest_import.PublicImportMessage optional_public_import_message =
  61. 26;
  62. NestedMessage optional_lazy_message = 27 [lazy = true];
  63. // Repeated
  64. repeated int32 repeated_int32 = 31;
  65. repeated int64 repeated_int64 = 32;
  66. repeated uint32 repeated_uint32 = 33;
  67. repeated uint64 repeated_uint64 = 34;
  68. repeated sint32 repeated_sint32 = 35;
  69. repeated sint64 repeated_sint64 = 36;
  70. repeated fixed32 repeated_fixed32 = 37;
  71. repeated fixed64 repeated_fixed64 = 38;
  72. repeated sfixed32 repeated_sfixed32 = 39;
  73. repeated sfixed64 repeated_sfixed64 = 40;
  74. repeated float repeated_float = 41;
  75. repeated double repeated_double = 42;
  76. repeated bool repeated_bool = 43;
  77. repeated string repeated_string = 44;
  78. repeated bytes repeated_bytes = 45;
  79. // Groups are not allowed in proto3.
  80. // repeated group RepeatedGroup = 46 {
  81. // optional int32 a = 47;
  82. // }
  83. repeated NestedMessage repeated_nested_message = 48;
  84. repeated ForeignMessage repeated_foreign_message = 49;
  85. repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
  86. repeated NestedEnum repeated_nested_enum = 51;
  87. repeated ForeignEnum repeated_foreign_enum = 52;
  88. // Omitted (compared to unittest.proto) because proto2 enums are not allowed
  89. // inside proto2 messages.
  90. //
  91. // repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
  92. repeated string repeated_string_piece = 54 [ctype = STRING_PIECE];
  93. repeated string repeated_cord = 55 [ctype = CORD];
  94. repeated NestedMessage repeated_lazy_message = 57 ;
  95. oneof oneof_field {
  96. uint32 oneof_uint32 = 111;
  97. NestedMessage oneof_nested_message = 112;
  98. string oneof_string = 113;
  99. bytes oneof_bytes = 114;
  100. }
  101. }
  102. // Test messages for packed fields
  103. message TestPackedTypes {
  104. repeated int32 packed_int32 = 90 [packed = true];
  105. repeated int64 packed_int64 = 91 [packed = true];
  106. repeated uint32 packed_uint32 = 92 [packed = true];
  107. repeated uint64 packed_uint64 = 93 [packed = true];
  108. repeated sint32 packed_sint32 = 94 [packed = true];
  109. repeated sint64 packed_sint64 = 95 [packed = true];
  110. repeated fixed32 packed_fixed32 = 96 [packed = true];
  111. repeated fixed64 packed_fixed64 = 97 [packed = true];
  112. repeated sfixed32 packed_sfixed32 = 98 [packed = true];
  113. repeated sfixed64 packed_sfixed64 = 99 [packed = true];
  114. repeated float packed_float = 100 [packed = true];
  115. repeated double packed_double = 101 [packed = true];
  116. repeated bool packed_bool = 102 [packed = true];
  117. repeated ForeignEnum packed_enum = 103 [packed = true];
  118. }
  119. // Explicitly set packed to false
  120. message TestUnpackedTypes {
  121. repeated int32 repeated_int32 = 1 [packed = false];
  122. repeated int64 repeated_int64 = 2 [packed = false];
  123. repeated uint32 repeated_uint32 = 3 [packed = false];
  124. repeated uint64 repeated_uint64 = 4 [packed = false];
  125. repeated sint32 repeated_sint32 = 5 [packed = false];
  126. repeated sint64 repeated_sint64 = 6 [packed = false];
  127. repeated fixed32 repeated_fixed32 = 7 [packed = false];
  128. repeated fixed64 repeated_fixed64 = 8 [packed = false];
  129. repeated sfixed32 repeated_sfixed32 = 9 [packed = false];
  130. repeated sfixed64 repeated_sfixed64 = 10 [packed = false];
  131. repeated float repeated_float = 11 [packed = false];
  132. repeated double repeated_double = 12 [packed = false];
  133. repeated bool repeated_bool = 13 [packed = false];
  134. repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false];
  135. }
  136. // This proto includes a recursively nested message.
  137. message NestedTestAllTypes {
  138. NestedTestAllTypes child = 1;
  139. TestAllTypes payload = 2;
  140. }
  141. // Define these after TestAllTypes to make sure the compiler can handle
  142. // that.
  143. message ForeignMessage {
  144. int32 c = 1;
  145. }
  146. enum ForeignEnum {
  147. FOREIGN_ZERO = 0;
  148. FOREIGN_FOO = 4;
  149. FOREIGN_BAR = 5;
  150. FOREIGN_BAZ = 6;
  151. }
  152. // TestEmptyMessage is used to test behavior of unknown fields.
  153. message TestEmptyMessage {}