blob: 36fb86560e6e0e8c73e2ce7f6c5184eaea4a24b4 [file] [log] [blame]
Feng Xiao6ef984a2014-11-10 17:34:54 -08001// 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
31// Author: kenton@google.com (Kenton Varda)
32// Based on original Protocol Buffers design by
33// Sanjay Ghemawat, Jeff Dean, and others.
34//
35// This proto file contains copies of TestAllTypes and friends, but with arena
36// support disabled in code generation. It allows us to test the performance
37// impact against baseline (non-arena) google.protobuf.
38
39syntax = "proto2";
40
41// Some generic_services option(s) added automatically.
42// See: http://go/proto2-generic-services-default
43option cc_generic_services = true; // auto-added
44option java_generic_services = true; // auto-added
45option py_generic_services = true; // auto-added
Feng Xiaof157a562014-11-14 11:50:31 -080046option cc_enable_arenas = false;
Feng Xiao6ef984a2014-11-10 17:34:54 -080047
48import "google/protobuf/unittest_import.proto";
49import "google/protobuf/unittest_arena.proto";
50
51// We don't put this in a package within proto2 because we need to make sure
52// that the generated code doesn't depend on being in the proto2 namespace.
53// In test_util.h we do "using namespace unittest = protobuf_unittest".
54package protobuf_unittest_no_arena;
55
56// Protos optimized for SPEED use a strict superset of the generated code
57// of equivalent ones optimized for CODE_SIZE, so we should optimize all our
58// tests for speed unless explicitly testing code size optimization.
59option optimize_for = SPEED;
60
61option java_outer_classname = "UnittestProto";
62
63// This proto includes every type of field in both singular and repeated
64// forms.
65message TestAllTypes {
66 message NestedMessage {
67 // The field name "b" fails to compile in proto1 because it conflicts with
68 // a local variable named "b" in one of the generated methods. Doh.
69 // This file needs to compile in proto1 to test backwards-compatibility.
70 optional int32 bb = 1;
71 }
72
73 enum NestedEnum {
74 FOO = 1;
75 BAR = 2;
76 BAZ = 3;
77 NEG = -1; // Intentionally negative.
78 }
79
80 // Singular
81 optional int32 optional_int32 = 1;
82 optional int64 optional_int64 = 2;
83 optional uint32 optional_uint32 = 3;
84 optional uint64 optional_uint64 = 4;
85 optional sint32 optional_sint32 = 5;
86 optional sint64 optional_sint64 = 6;
87 optional fixed32 optional_fixed32 = 7;
88 optional fixed64 optional_fixed64 = 8;
89 optional sfixed32 optional_sfixed32 = 9;
90 optional sfixed64 optional_sfixed64 = 10;
91 optional float optional_float = 11;
92 optional double optional_double = 12;
93 optional bool optional_bool = 13;
94 optional string optional_string = 14;
95 optional bytes optional_bytes = 15;
96
97 optional group OptionalGroup = 16 {
98 optional int32 a = 17;
99 }
100
101 optional NestedMessage optional_nested_message = 18;
102 optional ForeignMessage optional_foreign_message = 19;
103 optional protobuf_unittest_import.ImportMessage optional_import_message = 20;
104
105 optional NestedEnum optional_nested_enum = 21;
106 optional ForeignEnum optional_foreign_enum = 22;
107 optional protobuf_unittest_import.ImportEnum optional_import_enum = 23;
108
109 optional string optional_string_piece = 24 [ctype=STRING_PIECE];
110 optional string optional_cord = 25 [ctype=CORD];
111
112 // Defined in unittest_import_public.proto
113 optional protobuf_unittest_import.PublicImportMessage
114 optional_public_import_message = 26;
115
Jisi Liu885b6122015-02-28 14:51:22 -0800116 optional NestedMessage optional_message = 27 [lazy=true];
Feng Xiao6ef984a2014-11-10 17:34:54 -0800117
118 // Repeated
119 repeated int32 repeated_int32 = 31;
120 repeated int64 repeated_int64 = 32;
121 repeated uint32 repeated_uint32 = 33;
122 repeated uint64 repeated_uint64 = 34;
123 repeated sint32 repeated_sint32 = 35;
124 repeated sint64 repeated_sint64 = 36;
125 repeated fixed32 repeated_fixed32 = 37;
126 repeated fixed64 repeated_fixed64 = 38;
127 repeated sfixed32 repeated_sfixed32 = 39;
128 repeated sfixed64 repeated_sfixed64 = 40;
129 repeated float repeated_float = 41;
130 repeated double repeated_double = 42;
131 repeated bool repeated_bool = 43;
132 repeated string repeated_string = 44;
133 repeated bytes repeated_bytes = 45;
134
135 repeated group RepeatedGroup = 46 {
136 optional int32 a = 47;
137 }
138
139 repeated NestedMessage repeated_nested_message = 48;
140 repeated ForeignMessage repeated_foreign_message = 49;
141 repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
142
143 repeated NestedEnum repeated_nested_enum = 51;
144 repeated ForeignEnum repeated_foreign_enum = 52;
145 repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
146
147 repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
148 repeated string repeated_cord = 55 [ctype=CORD];
149
150 repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
151
152 // Singular with defaults
153 optional int32 default_int32 = 61 [default = 41 ];
154 optional int64 default_int64 = 62 [default = 42 ];
155 optional uint32 default_uint32 = 63 [default = 43 ];
156 optional uint64 default_uint64 = 64 [default = 44 ];
157 optional sint32 default_sint32 = 65 [default = -45 ];
158 optional sint64 default_sint64 = 66 [default = 46 ];
159 optional fixed32 default_fixed32 = 67 [default = 47 ];
160 optional fixed64 default_fixed64 = 68 [default = 48 ];
161 optional sfixed32 default_sfixed32 = 69 [default = 49 ];
162 optional sfixed64 default_sfixed64 = 70 [default = -50 ];
163 optional float default_float = 71 [default = 51.5 ];
164 optional double default_double = 72 [default = 52e3 ];
165 optional bool default_bool = 73 [default = true ];
166 optional string default_string = 74 [default = "hello"];
167 optional bytes default_bytes = 75 [default = "world"];
168
169 optional NestedEnum default_nested_enum = 81 [default = BAR ];
170 optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR];
171 optional protobuf_unittest_import.ImportEnum
172 default_import_enum = 83 [default = IMPORT_BAR];
173
174 optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
175 optional string default_cord = 85 [ctype=CORD,default="123"];
176
177 // For oneof test
178 oneof oneof_field {
179 uint32 oneof_uint32 = 111;
180 NestedMessage oneof_nested_message = 112;
181 string oneof_string = 113;
182 bytes oneof_bytes = 114;
Jisi Liu885b6122015-02-28 14:51:22 -0800183 NestedMessage lazy_oneof_nested_message = 115 [lazy=true];
Feng Xiao6ef984a2014-11-10 17:34:54 -0800184 }
185}
186
187// Define these after TestAllTypes to make sure the compiler can handle
188// that.
189message ForeignMessage {
190 optional int32 c = 1;
191}
192
193enum ForeignEnum {
194 FOREIGN_FOO = 4;
195 FOREIGN_BAR = 5;
196 FOREIGN_BAZ = 6;
197}
198
199message TestNoArenaMessage {
200 optional proto2_arena_unittest.ArenaMessage arena_message = 1;
201};