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