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// A message representing a option the parser does not recognize. This only 86// appears in options protos created by the compiler::Parser class. 87// DescriptorPool resolves these when building Descriptor objects. Therefore, 88// options protos in descriptor objects (e.g. returned by Descriptor::options(), 89// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions 90// in them. 91message UninterpretedOption { 92 // The name of the uninterpreted option. Each string represents a segment in 93 // a dot-separated name. is_extension is true iff a segment represents an 94 // extension (denoted with parentheses in options specs in .proto files). 95 // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents 96 // "foo.(bar.baz).moo". 97 message NamePart { 98 optional string name_part = 1; 99 optional bool is_extension = 2; 100 } 101 repeated NamePart name = 2; 102 103 // The value of the uninterpreted option, in whatever type the tokenizer 104 // identified it as during parsing. Exactly one of these should be set. 105 optional string identifier_value = 3; 106 optional uint64 positive_int_value = 4; 107 optional int64 negative_int_value = 5; 108 optional double double_value = 6; 109 optional bytes string_value = 7; 110 optional string aggregate_value = 8; 111} 112 113message FieldOptions { 114 // The packed option can be enabled for repeated primitive fields to enable 115 // a more efficient representation on the wire. Rather than repeatedly 116 // writing the tag and type for each element, the entire array is encoded as 117 // a single length-delimited blob. In proto3, only explicit setting it to 118 // false will avoid using packed encoding. 119 optional bool packed = 2; 120 121 // The parser stores options it doesn't recognize here. See above. 122 repeated UninterpretedOption uninterpreted_option = 999; 123} 124 125// Describes a field within a message. 126message FieldDescriptorProto { 127 enum Type { 128 // 0 is reserved for errors. 129 // Order is weird for historical reasons. 130 TYPE_DOUBLE = 1; 131 TYPE_FLOAT = 2; 132 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if 133 // negative values are likely. 134 TYPE_INT64 = 3; 135 TYPE_UINT64 = 4; 136 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if 137 // negative values are likely. 138 TYPE_INT32 = 5; 139 TYPE_FIXED64 = 6; 140 TYPE_FIXED32 = 7; 141 TYPE_BOOL = 8; 142 TYPE_STRING = 9; 143 // Tag-delimited aggregate. 144 // Group type is deprecated and not supported in proto3. However, Proto3 145 // implementations should still be able to parse the group wire format and 146 // treat group fields as unknown fields. 147 TYPE_GROUP = 10; 148 // Length-delimited aggregate. 149 TYPE_MESSAGE = 11; 150 151 // New in version 2. 152 TYPE_BYTES = 12; 153 TYPE_UINT32 = 13; 154 TYPE_ENUM = 14; 155 TYPE_SFIXED32 = 15; 156 TYPE_SFIXED64 = 16; 157 // Uses ZigZag encoding. 158 TYPE_SINT32 = 17; 159 // Uses ZigZag encoding. 160 TYPE_SINT64 = 18; 161 }; 162 163 enum Label { 164 // 0 is reserved for errors 165 LABEL_OPTIONAL = 1; 166 LABEL_REQUIRED = 2; 167 LABEL_REPEATED = 3; 168 }; 169 170 optional string name = 1; 171 optional int32 number = 3; 172 optional Label label = 4; 173 174 // If type_name is set, this need not be set. If both this and type_name 175 // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. 176 optional Type type = 5; 177 178 // For message and enum types, this is the name of the type. If the name 179 // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping 180 // rules are used to find the type (i.e. first the nested types within this 181 // message are searched, then within the parent, on up to the root 182 // namespace). 183 optional string type_name = 6; 184 185 // For extensions, this is the name of the type being extended. It is 186 // resolved in the same manner as type_name. 187 optional string extendee = 2; 188 189 // For numeric types, contains the original text representation of the value. 190 // For booleans, "true" or "false". 191 // For strings, contains the default text contents (not escaped in any way). 192 // For bytes, contains the C escaped value. All bytes >= 128 are escaped. 193 // TODO(kenton): Base-64 encode? 194 optional string default_value = 7; 195 196 optional FieldOptions options = 8; 197 198 // If set, gives the index of a oneof in the containing type's oneof_decl 199 // list. This field is a member of that oneof. 200 optional int32 oneof_index = 9; 201 202 reserved 10; 203} 204 205// Describes a oneof. 206message OneofDescriptorProto { 207 optional string name = 1; 208 optional OneofOptions options = 2; 209} 210 211// Describes an enum type. 212message EnumDescriptorProto { 213 optional string name = 1; 214 215 repeated EnumValueDescriptorProto value = 2; 216 217 reserved 3; 218 reserved 4; 219 220 // Reserved enum value names, which may not be reused. A given name may only 221 // be reserved once. 222 repeated string reserved_name = 5; 223} 224 225// Describes a value within an enum. 226message EnumValueDescriptorProto { 227 optional string name = 1; 228 optional int32 number = 2; 229 230 reserved 3; 231} 232 233message OneofOptions { 234 reserved 999; 235 236 // Clients can define custom options in extensions of this message. See above. 237 extensions 1000 to max; 238} 239