• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// This is a subset of descriptor.proto from the Protobuf library.
18syntax = "proto2";
19
20package perfetto.protos;
21
22// The protocol compiler can output a FileDescriptorSet containing the .proto
23// files it parses.
24message FileDescriptorSet {
25  repeated FileDescriptorProto file = 1;
26}
27
28// Describes a complete .proto file.
29message FileDescriptorProto {
30  // file name, relative to root of source tree
31  optional string name = 1;
32  // e.g. "foo", "foo.bar", etc.
33  optional string package = 2;
34
35  // Names of files imported by this file.
36  repeated string dependency = 3;
37  // Indexes of the public imported files in the dependency list above.
38  repeated int32 public_dependency = 10;
39  // Indexes of the weak imported files in the dependency list.
40  // For Google-internal migration only. Do not use.
41  repeated int32 weak_dependency = 11;
42
43  // All top-level definitions in this file.
44  repeated DescriptorProto message_type = 4;
45  repeated EnumDescriptorProto enum_type = 5;
46  repeated FieldDescriptorProto extension = 7;
47
48  reserved 6;
49  reserved 8;
50  reserved 9;
51  reserved 12;
52}
53
54// Describes a message type.
55message DescriptorProto {
56  optional string name = 1;
57
58  repeated FieldDescriptorProto field = 2;
59  repeated FieldDescriptorProto extension = 6;
60
61  repeated DescriptorProto nested_type = 3;
62  repeated EnumDescriptorProto enum_type = 4;
63
64  reserved 5;
65
66  repeated OneofDescriptorProto oneof_decl = 8;
67
68  reserved 7;
69
70  // Range of reserved tag numbers. Reserved tag numbers may not be used by
71  // fields or extension ranges in the same message. Reserved ranges may
72  // not overlap.
73  message ReservedRange {
74    // Inclusive.
75    optional int32 start = 1;
76    // Exclusive.
77    optional int32 end = 2;
78  }
79  repeated ReservedRange reserved_range = 9;
80  // Reserved field names, which may not be used by fields in the same message.
81  // A given name may only be reserved once.
82  repeated string reserved_name = 10;
83}
84
85// Describes a field within a message.
86message FieldDescriptorProto {
87  enum Type {
88    // 0 is reserved for errors.
89    // Order is weird for historical reasons.
90    TYPE_DOUBLE = 1;
91    TYPE_FLOAT = 2;
92    // Not ZigZag encoded.  Negative numbers take 10 bytes.  Use TYPE_SINT64 if
93    // negative values are likely.
94    TYPE_INT64 = 3;
95    TYPE_UINT64 = 4;
96    // Not ZigZag encoded.  Negative numbers take 10 bytes.  Use TYPE_SINT32 if
97    // negative values are likely.
98    TYPE_INT32 = 5;
99    TYPE_FIXED64 = 6;
100    TYPE_FIXED32 = 7;
101    TYPE_BOOL = 8;
102    TYPE_STRING = 9;
103    // Tag-delimited aggregate.
104    // Group type is deprecated and not supported in proto3. However, Proto3
105    // implementations should still be able to parse the group wire format and
106    // treat group fields as unknown fields.
107    TYPE_GROUP = 10;
108    // Length-delimited aggregate.
109    TYPE_MESSAGE = 11;
110
111    // New in version 2.
112    TYPE_BYTES = 12;
113    TYPE_UINT32 = 13;
114    TYPE_ENUM = 14;
115    TYPE_SFIXED32 = 15;
116    TYPE_SFIXED64 = 16;
117    // Uses ZigZag encoding.
118    TYPE_SINT32 = 17;
119    // Uses ZigZag encoding.
120    TYPE_SINT64 = 18;
121  };
122
123  enum Label {
124    // 0 is reserved for errors
125    LABEL_OPTIONAL = 1;
126    LABEL_REQUIRED = 2;
127    LABEL_REPEATED = 3;
128  };
129
130  optional string name = 1;
131  optional int32 number = 3;
132  optional Label label = 4;
133
134  // If type_name is set, this need not be set.  If both this and type_name
135  // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
136  optional Type type = 5;
137
138  // For message and enum types, this is the name of the type.  If the name
139  // starts with a '.', it is fully-qualified.  Otherwise, C++-like scoping
140  // rules are used to find the type (i.e. first the nested types within this
141  // message are searched, then within the parent, on up to the root
142  // namespace).
143  optional string type_name = 6;
144
145  // For extensions, this is the name of the type being extended.  It is
146  // resolved in the same manner as type_name.
147  optional string extendee = 2;
148
149  // For numeric types, contains the original text representation of the value.
150  // For booleans, "true" or "false".
151  // For strings, contains the default text contents (not escaped in any way).
152  // For bytes, contains the C escaped value.  All bytes >= 128 are escaped.
153  // TODO(kenton):  Base-64 encode?
154  optional string default_value = 7;
155
156  // If set, gives the index of a oneof in the containing type's oneof_decl
157  // list.  This field is a member of that oneof.
158  optional int32 oneof_index = 9;
159
160  reserved 10;
161
162  reserved 8;
163}
164
165// Describes a oneof.
166message OneofDescriptorProto {
167  optional string name = 1;
168  optional OneofOptions options = 2;
169}
170
171// Describes an enum type.
172message EnumDescriptorProto {
173  optional string name = 1;
174
175  repeated EnumValueDescriptorProto value = 2;
176
177  reserved 3;
178  reserved 4;
179
180  // Reserved enum value names, which may not be reused. A given name may only
181  // be reserved once.
182  repeated string reserved_name = 5;
183}
184
185// Describes a value within an enum.
186message EnumValueDescriptorProto {
187  optional string name = 1;
188  optional int32 number = 2;
189
190  reserved 3;
191}
192
193message OneofOptions {
194  reserved 999;
195
196  // Clients can define custom options in extensions of this message. See above.
197  extensions 1000 to max;
198}
199