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 85message FieldOptions { 86 // The packed option can be enabled for repeated primitive fields to enable 87 // a more efficient representation on the wire. Rather than repeatedly 88 // writing the tag and type for each element, the entire array is encoded as 89 // a single length-delimited blob. In proto3, only explicit setting it to 90 // false will avoid using packed encoding. 91 optional bool packed = 2; 92} 93 94// Describes a field within a message. 95message FieldDescriptorProto { 96 enum Type { 97 // 0 is reserved for errors. 98 // Order is weird for historical reasons. 99 TYPE_DOUBLE = 1; 100 TYPE_FLOAT = 2; 101 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if 102 // negative values are likely. 103 TYPE_INT64 = 3; 104 TYPE_UINT64 = 4; 105 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if 106 // negative values are likely. 107 TYPE_INT32 = 5; 108 TYPE_FIXED64 = 6; 109 TYPE_FIXED32 = 7; 110 TYPE_BOOL = 8; 111 TYPE_STRING = 9; 112 // Tag-delimited aggregate. 113 // Group type is deprecated and not supported in proto3. However, Proto3 114 // implementations should still be able to parse the group wire format and 115 // treat group fields as unknown fields. 116 TYPE_GROUP = 10; 117 // Length-delimited aggregate. 118 TYPE_MESSAGE = 11; 119 120 // New in version 2. 121 TYPE_BYTES = 12; 122 TYPE_UINT32 = 13; 123 TYPE_ENUM = 14; 124 TYPE_SFIXED32 = 15; 125 TYPE_SFIXED64 = 16; 126 // Uses ZigZag encoding. 127 TYPE_SINT32 = 17; 128 // Uses ZigZag encoding. 129 TYPE_SINT64 = 18; 130 }; 131 132 enum Label { 133 // 0 is reserved for errors 134 LABEL_OPTIONAL = 1; 135 LABEL_REQUIRED = 2; 136 LABEL_REPEATED = 3; 137 }; 138 139 optional string name = 1; 140 optional int32 number = 3; 141 optional Label label = 4; 142 143 // If type_name is set, this need not be set. If both this and type_name 144 // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. 145 optional Type type = 5; 146 147 // For message and enum types, this is the name of the type. If the name 148 // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping 149 // rules are used to find the type (i.e. first the nested types within this 150 // message are searched, then within the parent, on up to the root 151 // namespace). 152 optional string type_name = 6; 153 154 // For extensions, this is the name of the type being extended. It is 155 // resolved in the same manner as type_name. 156 optional string extendee = 2; 157 158 // For numeric types, contains the original text representation of the value. 159 // For booleans, "true" or "false". 160 // For strings, contains the default text contents (not escaped in any way). 161 // For bytes, contains the C escaped value. All bytes >= 128 are escaped. 162 // TODO(kenton): Base-64 encode? 163 optional string default_value = 7; 164 165 optional FieldOptions options = 8; 166 167 // If set, gives the index of a oneof in the containing type's oneof_decl 168 // list. This field is a member of that oneof. 169 optional int32 oneof_index = 9; 170 171 reserved 10; 172} 173 174// Describes a oneof. 175message OneofDescriptorProto { 176 optional string name = 1; 177 optional OneofOptions options = 2; 178} 179 180// Describes an enum type. 181message EnumDescriptorProto { 182 optional string name = 1; 183 184 repeated EnumValueDescriptorProto value = 2; 185 186 reserved 3; 187 reserved 4; 188 189 // Reserved enum value names, which may not be reused. A given name may only 190 // be reserved once. 191 repeated string reserved_name = 5; 192} 193 194// Describes a value within an enum. 195message EnumValueDescriptorProto { 196 optional string name = 1; 197 optional int32 number = 2; 198 199 reserved 3; 200} 201 202message OneofOptions { 203 reserved 999; 204 205 // Clients can define custom options in extensions of this message. See above. 206 extensions 1000 to max; 207} 208