|
Maxious
|
1 |
// Protocol Buffers - Google's data interchange format |
|
|
2 |
// Copyright 2008 Google Inc. All rights reserved. |
|
|
3 |
// http://code.google.com/p/protobuf/ |
|
|
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 |
// The messages in this file describe the definitions found in .proto files. |
|
|
36 |
// A valid .proto file can be translated directly to a FileDescriptorProto |
|
|
37 |
// without any other information (e.g. without reading its imports). |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
package google.protobuf; |
|
|
42 |
|
|
|
43 |
option java_package = "com.google.protobuf"; |
|
|
44 |
option java_outer_classname = "DescriptorProtos"; |
|
|
45 |
|
|
|
46 |
// descriptor.proto must be optimized for speed because reflection-based |
|
|
47 |
// algorithms don't work during bootstrapping. |
|
|
48 |
option optimize_for = SPEED; |
|
|
49 |
|
|
|
50 |
// The protocol compiler can output a FileDescriptorSet containing the .proto |
|
|
51 |
// files it parses. |
|
|
52 |
message FileDescriptorSet { |
|
|
53 |
repeated FileDescriptorProto file = 1; |
|
|
54 |
} |
|
|
55 |
|
|
|
56 |
// Describes a complete .proto file. |
|
|
57 |
message FileDescriptorProto { |
|
|
58 |
optional string name = 1; // file name, relative to root of source tree |
|
|
59 |
optional string package = 2; // e.g. "foo", "foo.bar", etc. |
|
|
60 |
|
|
|
61 |
// Names of files imported by this file. |
|
|
62 |
repeated string dependency = 3; |
|
|
63 |
|
|
|
64 |
// All top-level definitions in this file. |
|
|
65 |
repeated DescriptorProto message_type = 4; |
|
|
66 |
repeated EnumDescriptorProto enum_type = 5; |
|
|
67 |
repeated ServiceDescriptorProto service = 6; |
|
|
68 |
repeated FieldDescriptorProto extension = 7; |
|
|
69 |
|
|
|
70 |
optional FileOptions options = 8; |
|
|
71 |
|
|
|
72 |
// This field contains optional information about the original source code. |
|
|
73 |
// You may safely remove this entire field whithout harming runtime |
|
|
74 |
// functionality of the descriptors -- the information is needed only by |
|
|
75 |
// development tools. |
|
|
76 |
optional SourceCodeInfo source_code_info = 9; |
|
|
77 |
} |
|
|
78 |
|
|
|
79 |
// Describes a message type. |
|
|
80 |
message DescriptorProto { |
|
|
81 |
optional string name = 1; |
|
|
82 |
|
|
|
83 |
repeated FieldDescriptorProto field = 2; |
|
|
84 |
repeated FieldDescriptorProto extension = 6; |
|
|
85 |
|
|
|
86 |
repeated DescriptorProto nested_type = 3; |
|
|
87 |
repeated EnumDescriptorProto enum_type = 4; |
|
|
88 |
|
|
|
89 |
message ExtensionRange { |
|
|
90 |
optional int32 start = 1; |
|
|
91 |
optional int32 end = 2; |
|
|
92 |
} |
|
|
93 |
repeated ExtensionRange extension_range = 5; |
|
|
94 |
|
|
|
95 |
optional MessageOptions options = 7; |
|
|
96 |
} |
|
|
97 |
|
|
|
98 |
// Describes a field within a message. |
|
|
99 |
message FieldDescriptorProto { |
|
|
100 |
enum Type { |
|
|
101 |
// 0 is reserved for errors. |
|
|
102 |
// Order is weird for historical reasons. |
|
|
103 |
TYPE_DOUBLE = 1; |
|
|
104 |
TYPE_FLOAT = 2; |
|
|
105 |
TYPE_INT64 = 3; // Not ZigZag encoded. Negative numbers |
|
|
106 |
// take 10 bytes. Use TYPE_SINT64 if negative |
|
|
107 |
// values are likely. |
|
|
108 |
TYPE_UINT64 = 4; |
|
|
109 |
TYPE_INT32 = 5; // Not ZigZag encoded. Negative numbers |
|
|
110 |
// take 10 bytes. Use TYPE_SINT32 if negative |
|
|
111 |
// values are likely. |
|
|
112 |
TYPE_FIXED64 = 6; |
|
|
113 |
TYPE_FIXED32 = 7; |
|
|
114 |
TYPE_BOOL = 8; |
|
|
115 |
TYPE_STRING = 9; |
|
|
116 |
TYPE_GROUP = 10; // Tag-delimited aggregate. |
|
|
117 |
TYPE_MESSAGE = 11; // Length-delimited aggregate. |
|
|
118 |
|
|
|
119 |
// New in version 2. |
|
|
120 |
TYPE_BYTES = 12; |
|
|
121 |
TYPE_UINT32 = 13; |
|
|
122 |
TYPE_ENUM = 14; |
|
|
123 |
TYPE_SFIXED32 = 15; |
|
|
124 |
TYPE_SFIXED64 = 16; |
|
|
125 |
TYPE_SINT32 = 17; // Uses ZigZag encoding. |
|
|
126 |
TYPE_SINT64 = 18; // Uses ZigZag encoding. |
|
|
127 |
}; |
|
|
128 |
|
|
|
129 |
enum Label { |
|
|
130 |
// 0 is reserved for errors |
|
|
131 |
LABEL_OPTIONAL = 1; |
|
|
132 |
LABEL_REQUIRED = 2; |
|
|
133 |
LABEL_REPEATED = 3; |
|
|
134 |
// TODO(sanjay): Should we add LABEL_MAP? |
|
|
135 |
}; |
|
|
136 |
|
|
|
137 |
optional string name = 1; |
|
|
138 |
optional int32 number = 3; |
|
|
139 |
optional Label label = 4; |
|
|
140 |
|
|
|
141 |
// If type_name is set, this need not be set. If both this and type_name |
|
|
142 |
// are set, this must be either TYPE_ENUM or TYPE_MESSAGE. |
|
|
143 |
optional Type type = 5; |
|
|
144 |
|
|
|
145 |
// For message and enum types, this is the name of the type. If the name |
|
|
146 |
// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping |
|
|
147 |
// rules are used to find the type (i.e. first the nested types within this |
|
|
148 |
// message are searched, then within the parent, on up to the root |
|
|
149 |
// namespace). |
|
|
150 |
optional string type_name = 6; |
|
|
151 |
|
|
|
152 |
// For extensions, this is the name of the type being extended. It is |
|
|
153 |
// resolved in the same manner as type_name. |
|
|
154 |
optional string extendee = 2; |
|
|
155 |
|
|
|
156 |
// For numeric types, contains the original text representation of the value. |
|
|
157 |
// For booleans, "true" or "false". |
|
|
158 |
// For strings, contains the default text contents (not escaped in any way). |
|
|
159 |
// For bytes, contains the C escaped value. All bytes >= 128 are escaped. |
|
|
160 |
// TODO(kenton): Base-64 encode? |
|
|
161 |
optional string default_value = 7; |
|
|
162 |
|
|
|
163 |
optional FieldOptions options = 8; |
|
|
164 |
} |
|
|
165 |
|
|
|
166 |
// Describes an enum type. |
|
|
167 |
message EnumDescriptorProto { |
|
|
168 |
optional string name = 1; |
|
|
169 |
|
|
|
170 |
repeated EnumValueDescriptorProto value = 2; |
|
|
171 |
|
|
|
172 |
optional EnumOptions options = 3; |
|
|
173 |
} |
|
|
174 |
|
|
|
175 |
// Describes a value within an enum. |
|
|
176 |
message EnumValueDescriptorProto { |
|
|
177 |
optional string name = 1; |
|
|
178 |
optional int32 number = 2; |
|
|
179 |
|
|
|
180 |
optional EnumValueOptions options = 3; |
|
|
181 |
} |
|
|
182 |
|
|
|
183 |
// Describes a service. |
|
|
184 |
message ServiceDescriptorProto { |
|
|
185 |
optional string name = 1; |
|
|
186 |
repeated MethodDescriptorProto method = 2; |
|
|
187 |
|
|
|
188 |
optional ServiceOptions options = 3; |
|
|
189 |
} |
|
|
190 |
|
|
|
191 |
// Describes a method of a service. |
|
|
192 |
message MethodDescriptorProto { |
|
|
193 |
optional string name = 1; |
|
|
194 |
|
|
|
195 |
// Input and output type names. These are resolved in the same way as |
|
|
196 |
// FieldDescriptorProto.type_name, but must refer to a message type. |
|
|
197 |
optional string input_type = 2; |
|
|
198 |
optional string output_type = 3; |
|
|
199 |
|
|
|
200 |
optional MethodOptions options = 4; |
|
|
201 |
} |
|
|
202 |
|
|
|
203 |
// =================================================================== |
|
|
204 |
// Options |
|
|
205 |
|
|
|
206 |
// Each of the definitions above may have "options" attached. These are |
|
|
207 |
// just annotations which may cause code to be generated slightly differently |
|
|
208 |
// or may contain hints for code that manipulates protocol messages. |
|
|
209 |
// |
|
|
210 |
// Clients may define custom options as extensions of the *Options messages. |
|
|
211 |
// These extensions may not yet be known at parsing time, so the parser cannot |
|
|
212 |
// store the values in them. Instead it stores them in a field in the *Options |
|
|
213 |
// message called uninterpreted_option. This field must have the same name |
|
|
214 |
// across all *Options messages. We then use this field to populate the |
|
|
215 |
// extensions when we build a descriptor, at which point all protos have been |
|
|
216 |
// parsed and so all extensions are known. |
|
|
217 |
// |
|
|
218 |
// Extension numbers for custom options may be chosen as follows: |
|
|
219 |
// * For options which will only be used within a single application or |
|
|