Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 17 | syntax = "proto3"; |
| 18 | |
Adam Lesinski | b58c3ef | 2017-09-12 17:39:52 -0700 | [diff] [blame] | 19 | import "frameworks/base/tools/aapt2/Configuration.proto"; |
| 20 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 21 | package aapt.pb; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 22 | |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 23 | option java_package = "com.android.aapt"; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 24 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 25 | // A string pool that wraps the binary form of the C++ class android::ResStringPool. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 26 | message StringPool { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 27 | bytes data = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 28 | } |
| 29 | |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 30 | // The position of a declared entity within a file. |
| 31 | message SourcePosition { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 32 | uint32 line_number = 1; |
| 33 | uint32 column_number = 2; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 36 | // Developer friendly source file information for an entity in the resource table. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 37 | message Source { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 38 | // The index of the string path within the source string pool of a ResourceTable. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 39 | uint32 path_idx = 1; |
| 40 | SourcePosition position = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 41 | } |
| 42 | |
Ryan Mitchell | 34039b2 | 2019-03-18 08:57:47 -0700 | [diff] [blame] | 43 | // The name and version fingerprint of a build tool. |
| 44 | message ToolFingerprint { |
| 45 | string tool = 1; |
| 46 | string version = 2; |
| 47 | } |
| 48 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 49 | // Top level message representing a resource table. |
| 50 | message ResourceTable { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 51 | // The string pool containing source paths referenced throughout the resource table. This does |
| 52 | // not end up in the final binary ARSC file. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 53 | StringPool source_pool = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 54 | |
| 55 | // Resource definitions corresponding to an Android package. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 56 | repeated Package package = 2; |
Ryan Mitchell | 54237ff | 2018-12-13 15:44:29 -0800 | [diff] [blame] | 57 | |
| 58 | // The <overlayable> declarations within the resource table. |
| 59 | repeated Overlayable overlayable = 3; |
Ryan Mitchell | 34039b2 | 2019-03-18 08:57:47 -0700 | [diff] [blame] | 60 | |
| 61 | // The version fingerprints of the tools that built the resource table. |
| 62 | repeated ToolFingerprint tool_fingerprint = 4; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 65 | // A package ID in the range [0x00, 0xff]. |
| 66 | message PackageId { |
| 67 | uint32 id = 1; |
| 68 | } |
| 69 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 70 | // Defines resources for an Android package. |
| 71 | message Package { |
| 72 | // The package ID of this package, in the range [0x00, 0xff]. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 73 | // - ID 0x00 is reserved for shared libraries, or when the ID is assigned at run-time. |
| 74 | // - ID 0x01 is reserved for the 'android' package (framework). |
| 75 | // - ID range [0x02, 0x7f) is reserved for auto-assignment to shared libraries at run-time. |
| 76 | // - ID 0x7f is reserved for the application package. |
| 77 | // - IDs > 0x7f are reserved for the application as well and are treated as feature splits. |
| 78 | // This may not be set if no ID was assigned. |
| 79 | PackageId package_id = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 80 | |
| 81 | // The Java compatible Android package name of the app. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 82 | string package_name = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 83 | |
| 84 | // The series of types defined by the package. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 85 | repeated Type type = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 88 | // A type ID in the range [0x01, 0xff]. |
| 89 | message TypeId { |
| 90 | uint32 id = 1; |
| 91 | } |
| 92 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 93 | // A set of resources grouped under a common type. Such types include string, layout, xml, dimen, |
| 94 | // attr, etc. This maps to the second part of a resource identifier in Java (R.type.entry). |
| 95 | message Type { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 96 | // The ID of the type. This may not be set if no ID was assigned. |
| 97 | TypeId type_id = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 98 | |
| 99 | // The name of the type. This corresponds to the 'type' part of a full resource name of the form |
| 100 | // package:type/entry. The set of legal type names is listed in Resource.cpp. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 101 | string name = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 102 | |
| 103 | // The entries defined for this type. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 104 | repeated Entry entry = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 107 | // The Visibility of a symbol/entry (public, private, undefined). |
| 108 | message Visibility { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 109 | // The visibility of the resource outside of its package. |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 110 | enum Level { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 111 | // No visibility was explicitly specified. This is typically treated as private. |
| 112 | // The distinction is important when two separate R.java files are generated: a public and |
| 113 | // private one. An unknown visibility, in this case, would cause the resource to be omitted |
| 114 | // from either R.java. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 115 | UNKNOWN = 0; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 116 | |
| 117 | // A resource was explicitly marked as private. This means the resource can not be accessed |
| 118 | // outside of its package unless the @*package:type/entry notation is used (the asterisk being |
| 119 | // the private accessor). If two R.java files are generated (private + public), the resource |
| 120 | // will only be emitted to the private R.java file. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 121 | PRIVATE = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 122 | |
| 123 | // A resource was explicitly marked as public. This means the resource can be accessed |
| 124 | // from any package, and is emitted into all R.java files, public and private. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 125 | PUBLIC = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 128 | Level level = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 129 | |
| 130 | // The path at which this entry's visibility was defined (eg. public.xml). |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 131 | Source source = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 132 | |
| 133 | // The comment associated with the <public> tag. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 134 | string comment = 3; |
Ryan Mitchell | 2e9bec1 | 2021-03-22 09:31:00 -0700 | [diff] [blame] | 135 | |
| 136 | // Indicates that the resource id may change across builds and that the public R.java identifier |
| 137 | // for this resource should not be final. This is set to `true` for resources in `staging-group` |
| 138 | // tags. |
| 139 | bool staged_api = 4; |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 140 | } |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 141 | |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 142 | // Whether a resource comes from a compile-time overlay and is explicitly allowed to not overlay an |
| 143 | // existing resource. |
| 144 | message AllowNew { |
| 145 | // Where this was defined in source. |
| 146 | Source source = 1; |
| 147 | |
| 148 | // Any comment associated with the declaration. |
| 149 | string comment = 2; |
| 150 | } |
| 151 | |
Ryan Mitchell | 54237ff | 2018-12-13 15:44:29 -0800 | [diff] [blame] | 152 | // Represents a set of overlayable resources. |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 153 | message Overlayable { |
Winson | b2d7f53 | 2019-02-04 16:32:43 -0800 | [diff] [blame] | 154 | // The name of the <overlayable>. |
Ryan Mitchell | 54237ff | 2018-12-13 15:44:29 -0800 | [diff] [blame] | 155 | string name = 1; |
| 156 | |
Winson | b2d7f53 | 2019-02-04 16:32:43 -0800 | [diff] [blame] | 157 | // The location of the <overlayable> declaration in the source. |
Ryan Mitchell | 54237ff | 2018-12-13 15:44:29 -0800 | [diff] [blame] | 158 | Source source = 2; |
| 159 | |
| 160 | // The component responsible for enabling and disabling overlays targeting this <overlayable>. |
| 161 | string actor = 3; |
| 162 | } |
| 163 | |
| 164 | // Represents an overlayable <item> declaration within an <overlayable> tag. |
| 165 | message OverlayableItem { |
Ryan Mitchell | e4e989c | 2018-10-29 02:21:50 -0700 | [diff] [blame] | 166 | enum Policy { |
Winson | 6bee425 | 2019-02-13 07:57:24 -0800 | [diff] [blame] | 167 | NONE = 0; |
| 168 | PUBLIC = 1; |
| 169 | SYSTEM = 2; |
| 170 | VENDOR = 3; |
| 171 | PRODUCT = 4; |
| 172 | SIGNATURE = 5; |
Ryan Mitchell | 939df09 | 2019-04-09 17:13:50 -0700 | [diff] [blame] | 173 | ODM = 6; |
| 174 | OEM = 7; |
Winson | f56ade3 | 2019-12-04 11:32:41 -0800 | [diff] [blame] | 175 | ACTOR = 8; |
Zoran Jovanovic | 9336d9e | 2020-06-09 18:51:57 +0200 | [diff] [blame] | 176 | CONFIG_SIGNATURE = 9; |
Ryan Mitchell | e4e989c | 2018-10-29 02:21:50 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Ryan Mitchell | 54237ff | 2018-12-13 15:44:29 -0800 | [diff] [blame] | 179 | // The location of the <item> declaration in source. |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 180 | Source source = 1; |
| 181 | |
| 182 | // Any comment associated with the declaration. |
| 183 | string comment = 2; |
Ryan Mitchell | e4e989c | 2018-10-29 02:21:50 -0700 | [diff] [blame] | 184 | |
Ryan Mitchell | 54237ff | 2018-12-13 15:44:29 -0800 | [diff] [blame] | 185 | // The policy defined by the enclosing <policy> tag of this <item>. |
Ryan Mitchell | 1bb1fe0 | 2018-11-16 11:21:41 -0800 | [diff] [blame] | 186 | repeated Policy policy = 3; |
Ryan Mitchell | 54237ff | 2018-12-13 15:44:29 -0800 | [diff] [blame] | 187 | |
| 188 | // The index into overlayable list that points to the <overlayable> tag that contains |
| 189 | // this <item>. |
| 190 | uint32 overlayable_idx = 4; |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Ryan Mitchell | 2fedba9 | 2021-04-23 07:47:38 -0700 | [diff] [blame^] | 193 | // The staged resource ID definition of a finalized resource. |
| 194 | message StagedId { |
| 195 | Source source = 1; |
| 196 | uint32 staged_id = 2; |
| 197 | } |
| 198 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 199 | // An entry ID in the range [0x0000, 0xffff]. |
| 200 | message EntryId { |
| 201 | uint32 id = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | // An entry declaration. An entry has a full resource ID that is the combination of package ID, |
| 205 | // type ID, and its own entry ID. An entry on its own has no value, but values are defined for |
| 206 | // various configurations/variants. |
| 207 | message Entry { |
| 208 | // The ID of this entry. Together with the package ID and type ID, this forms a full resource ID |
| 209 | // of the form 0xPPTTEEEE, where PP is the package ID, TT is the type ID, and EEEE is the entry |
| 210 | // ID. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 211 | // This may not be set if no ID was assigned. |
| 212 | EntryId entry_id = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 213 | |
| 214 | // The name of this entry. This corresponds to the 'entry' part of a full resource name of the |
| 215 | // form package:type/entry. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 216 | string name = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 217 | |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 218 | // The visibility of this entry (public, private, undefined). |
| 219 | Visibility visibility = 3; |
| 220 | |
| 221 | // Whether this resource, when originating from a compile-time overlay, is allowed to NOT overlay |
| 222 | // any existing resources. |
| 223 | AllowNew allow_new = 4; |
| 224 | |
| 225 | // Whether this resource can be overlaid by a runtime resource overlay (RRO). |
Ryan Mitchell | 54237ff | 2018-12-13 15:44:29 -0800 | [diff] [blame] | 226 | OverlayableItem overlayable_item = 5; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 227 | |
| 228 | // The set of values defined for this entry, each corresponding to a different |
| 229 | // configuration/variant. |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 230 | repeated ConfigValue config_value = 6; |
Ryan Mitchell | 2fedba9 | 2021-04-23 07:47:38 -0700 | [diff] [blame^] | 231 | |
| 232 | // The staged resource ID of this finalized resource. |
| 233 | StagedId staged_id = 7; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | // A Configuration/Value pair. |
| 237 | message ConfigValue { |
Adam Lesinski | b58c3ef | 2017-09-12 17:39:52 -0700 | [diff] [blame] | 238 | Configuration config = 1; |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 239 | Value value = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | // The generic meta-data for every value in a resource table. |
| 243 | message Value { |
| 244 | // Where the value was defined. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 245 | Source source = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 246 | |
| 247 | // Any comment associated with the value. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 248 | string comment = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 249 | |
| 250 | // Whether the value can be overridden. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 251 | bool weak = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 252 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 253 | // The value is either an Item or a CompoundValue. |
| 254 | oneof value { |
| 255 | Item item = 4; |
| 256 | CompoundValue compound_value = 5; |
| 257 | } |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | // An Item is an abstract type. It represents a value that can appear inline in many places, such |
| 261 | // as XML attribute values or on the right hand side of style attribute definitions. The concrete |
| 262 | // type is one of the types below. Only one can be set. |
| 263 | message Item { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 264 | oneof value { |
| 265 | Reference ref = 1; |
| 266 | String str = 2; |
| 267 | RawString raw_str = 3; |
| 268 | StyledString styled_str = 4; |
| 269 | FileReference file = 5; |
| 270 | Id id = 6; |
| 271 | Primitive prim = 7; |
| 272 | } |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | // A CompoundValue is an abstract type. It represents a value that is a made of other values. |
| 276 | // These can only usually appear as top-level resources. The concrete type is one of the types |
| 277 | // below. Only one can be set. |
| 278 | message CompoundValue { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 279 | oneof value { |
| 280 | Attribute attr = 1; |
| 281 | Style style = 2; |
| 282 | Styleable styleable = 3; |
| 283 | Array array = 4; |
| 284 | Plural plural = 5; |
Ryan Mitchell | 326e35ff | 2021-04-12 07:50:42 -0700 | [diff] [blame] | 285 | MacroBody macro = 6; |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 286 | } |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 287 | } |
| 288 | |
Clark DuVall | e9fedbe | 2020-01-09 11:52:52 -0800 | [diff] [blame] | 289 | // Message holding a boolean, so it can be optionally encoded. |
| 290 | message Boolean { |
| 291 | bool value = 1; |
| 292 | } |
| 293 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 294 | // A value that is a reference to another resource. This reference can be by name or resource ID. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 295 | message Reference { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 296 | enum Type { |
| 297 | // A plain reference (@package:type/entry). |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 298 | REFERENCE = 0; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 299 | |
| 300 | // A reference to a theme attribute (?package:type/entry). |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 301 | ATTRIBUTE = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 304 | Type type = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 305 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 306 | // The resource ID (0xPPTTEEEE) of the resource being referred. This is optional. |
| 307 | uint32 id = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 308 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 309 | // The name of the resource being referred. This is optional if the resource ID is set. |
| 310 | string name = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 311 | |
| 312 | // Whether this reference is referencing a private resource (@*package:type/entry). |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 313 | bool private = 4; |
Clark DuVall | e9fedbe | 2020-01-09 11:52:52 -0800 | [diff] [blame] | 314 | |
| 315 | // Whether this reference is dynamic. |
| 316 | Boolean is_dynamic = 5; |
Ryan Mitchell | 326e35ff | 2021-04-12 07:50:42 -0700 | [diff] [blame] | 317 | |
| 318 | // The type flags used when compiling the reference. Used for substituting the contents of macros. |
| 319 | uint32 type_flags = 6; |
| 320 | |
| 321 | // Whether raw string values would have been accepted in place of this reference definition. Used |
| 322 | // for substituting the contents of macros. |
| 323 | bool allow_raw = 7; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 324 | } |
| 325 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 326 | // A value that represents an ID. This is just a placeholder, as ID values are used to occupy a |
| 327 | // resource ID (0xPPTTEEEE) as a unique identifier. Their value is unimportant. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 328 | message Id { |
| 329 | } |
| 330 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 331 | // A value that is a string. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 332 | message String { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 333 | string value = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 334 | } |
| 335 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 336 | // A value that is a raw string, which is unescaped/uninterpreted. This is typically used to |
| 337 | // represent the value of a style attribute before the attribute is compiled and the set of |
| 338 | // allowed values is known. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 339 | message RawString { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 340 | string value = 1; |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | // A string with styling information, like html tags that specify boldness, italics, etc. |
| 344 | message StyledString { |
| 345 | // The raw text of the string. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 346 | string value = 1; |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 347 | |
| 348 | // A Span marks a region of the string text that is styled. |
| 349 | message Span { |
| 350 | // The name of the tag, and its attributes, encoded as follows: |
| 351 | // tag_name;attr1=value1;attr2=value2;[...] |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 352 | string tag = 1; |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 353 | |
| 354 | // The first character position this span applies to, in UTF-16 offset. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 355 | uint32 first_char = 2; |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 356 | |
| 357 | // The last character position this span applies to, in UTF-16 offset. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 358 | uint32 last_char = 3; |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | repeated Span span = 2; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 362 | } |
| 363 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 364 | // A value that is a reference to an external entity, like an XML file or a PNG. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 365 | message FileReference { |
Adam Lesinski | e59f0d8 | 2017-10-13 09:36:53 -0700 | [diff] [blame] | 366 | enum Type { |
| 367 | UNKNOWN = 0; |
| 368 | PNG = 1; |
| 369 | BINARY_XML = 2; |
| 370 | PROTO_XML = 3; |
| 371 | } |
| 372 | |
Adam Lesinski | 0853500 | 2017-08-04 16:15:17 -0700 | [diff] [blame] | 373 | // Path to a file within the APK (typically res/type-config/entry.ext). |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 374 | string path = 1; |
Adam Lesinski | e59f0d8 | 2017-10-13 09:36:53 -0700 | [diff] [blame] | 375 | |
| 376 | // The type of file this path points to. For UAM bundle, this cannot be |
| 377 | // BINARY_XML. |
| 378 | Type type = 2; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 379 | } |
| 380 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 381 | // A value that represents a primitive data type (float, int, boolean, etc.). |
Michael Wachenschwanz | 8b74927 | 2018-04-18 18:52:47 -0700 | [diff] [blame] | 382 | // Refer to Res_value in ResourceTypes.h for info on types and formatting |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 383 | message Primitive { |
Michael Wachenschwanz | d06f1f3 | 2018-01-11 18:36:22 -0800 | [diff] [blame] | 384 | message NullType { |
| 385 | } |
| 386 | message EmptyType { |
| 387 | } |
| 388 | oneof oneof_value { |
| 389 | NullType null_value = 1; |
| 390 | EmptyType empty_value = 2; |
| 391 | float float_value = 3; |
Michael Wachenschwanz | 8b74927 | 2018-04-18 18:52:47 -0700 | [diff] [blame] | 392 | uint32 dimension_value = 13; |
| 393 | uint32 fraction_value = 14; |
Michael Wachenschwanz | d06f1f3 | 2018-01-11 18:36:22 -0800 | [diff] [blame] | 394 | int32 int_decimal_value = 6; |
Dave Ingram | 22ed412 | 2018-01-30 16:11:52 -0800 | [diff] [blame] | 395 | uint32 int_hexadecimal_value = 7; |
Michael Wachenschwanz | d06f1f3 | 2018-01-11 18:36:22 -0800 | [diff] [blame] | 396 | bool boolean_value = 8; |
| 397 | uint32 color_argb8_value = 9; |
| 398 | uint32 color_rgb8_value = 10; |
| 399 | uint32 color_argb4_value = 11; |
| 400 | uint32 color_rgb4_value = 12; |
Michael Wachenschwanz | 8b74927 | 2018-04-18 18:52:47 -0700 | [diff] [blame] | 401 | float dimension_value_deprecated = 4 [deprecated=true]; |
| 402 | float fraction_value_deprecated = 5 [deprecated=true]; |
Michael Wachenschwanz | d06f1f3 | 2018-01-11 18:36:22 -0800 | [diff] [blame] | 403 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 404 | } |
| 405 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 406 | // A value that represents an XML attribute and what values it accepts. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 407 | message Attribute { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 408 | // A Symbol used to represent an enum or a flag. |
| 409 | message Symbol { |
| 410 | // Where the enum/flag item was defined. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 411 | Source source = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 412 | |
| 413 | // Any comments associated with the enum or flag. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 414 | string comment = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 415 | |
| 416 | // The name of the enum/flag as a reference. Enums/flag items are generated as ID resource |
| 417 | // values. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 418 | Reference name = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 419 | |
| 420 | // The value of the enum/flag. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 421 | uint32 value = 4; |
Ryan Mitchell | c167680 | 2019-05-20 16:47:08 -0700 | [diff] [blame] | 422 | |
| 423 | // The data type of the enum/flag as defined in android::Res_value. |
| 424 | uint32 type = 5; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 427 | // Bitmask of formats allowed for an attribute. |
| 428 | enum FormatFlags { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 429 | NONE = 0x0; // Proto3 requires a default of 0. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 430 | ANY = 0x0000ffff; // Allows any type except ENUM and FLAGS. |
| 431 | REFERENCE = 0x01; // Allows Reference values. |
| 432 | STRING = 0x02; // Allows String/StyledString values. |
| 433 | INTEGER = 0x04; // Allows any integer BinaryPrimitive values. |
| 434 | BOOLEAN = 0x08; // Allows any boolean BinaryPrimitive values. |
| 435 | COLOR = 0x010; // Allows any color BinaryPrimitive values. |
| 436 | FLOAT = 0x020; // Allows any float BinaryPrimitive values. |
| 437 | DIMENSION = 0x040; // Allows any dimension BinaryPrimitive values. |
| 438 | FRACTION = 0x080; // Allows any fraction BinaryPrimitive values. |
| 439 | ENUM = 0x00010000; // Allows enums that are defined in the Attribute's symbols. |
| 440 | // ENUM and FLAGS cannot BOTH be set. |
| 441 | FLAGS = 0x00020000; // Allows flags that are defined in the Attribute's symbols. |
| 442 | // ENUM and FLAGS cannot BOTH be set. |
| 443 | } |
| 444 | |
| 445 | // A bitmask of types that this XML attribute accepts. Corresponds to the flags in the |
| 446 | // enum FormatFlags. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 447 | uint32 format_flags = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 448 | |
| 449 | // The smallest integer allowed for this XML attribute. Only makes sense if the format includes |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 450 | // FormatFlags::INTEGER. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 451 | int32 min_int = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 452 | |
| 453 | // The largest integer allowed for this XML attribute. Only makes sense if the format includes |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 454 | // FormatFlags::INTEGER. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 455 | int32 max_int = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 456 | |
| 457 | // The set of enums/flags defined in this attribute. Only makes sense if the format includes |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 458 | // either FormatFlags::ENUM or FormatFlags::FLAGS. Having both is an error. |
| 459 | repeated Symbol symbol = 4; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 460 | } |
| 461 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 462 | // A value that represents a style. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 463 | message Style { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 464 | // An XML attribute/value pair defined in the style. |
| 465 | message Entry { |
| 466 | // Where the entry was defined. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 467 | Source source = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 468 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 469 | // Any comments associated with the entry. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 470 | string comment = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 471 | |
| 472 | // A reference to the XML attribute. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 473 | Reference key = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 474 | |
| 475 | // The Item defined for this XML attribute. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 476 | Item item = 4; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | // The optinal style from which this style inherits attributes. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 480 | Reference parent = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 481 | |
| 482 | // The source file information of the parent inheritance declaration. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 483 | Source parent_source = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 484 | |
| 485 | // The set of XML attribute/value pairs for this style. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 486 | repeated Entry entry = 3; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 487 | } |
| 488 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 489 | // A value that represents a <declare-styleable> XML resource. These are not real resources and |
| 490 | // only end up as Java fields in the generated R.java. They do not end up in the binary ARSC file. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 491 | message Styleable { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 492 | // An attribute defined for this styleable. |
| 493 | message Entry { |
| 494 | // Where the attribute was defined within the <declare-styleable> block. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 495 | Source source = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 496 | |
| 497 | // Any comments associated with the declaration. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 498 | string comment = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 499 | |
| 500 | // The reference to the attribute. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 501 | Reference attr = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 502 | } |
| 503 | |
| 504 | // The set of attribute declarations. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 505 | repeated Entry entry = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 506 | } |
| 507 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 508 | // A value that represents an array of resource values. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 509 | message Array { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 510 | // A single element of the array. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 511 | message Element { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 512 | // Where the element was defined. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 513 | Source source = 1; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 514 | |
| 515 | // Any comments associated with the element. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 516 | string comment = 2; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 517 | |
| 518 | // The value assigned to this element. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 519 | Item item = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | // The list of array elements. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 523 | repeated Element element = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 524 | } |
| 525 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 526 | // A value that represents a string and its many variations based on plurality. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 527 | message Plural { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 528 | // The arity of the plural. |
| 529 | enum Arity { |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 530 | ZERO = 0; |
| 531 | ONE = 1; |
| 532 | TWO = 2; |
| 533 | FEW = 3; |
| 534 | MANY = 4; |
| 535 | OTHER = 5; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 536 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 537 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 538 | // The plural value for a given arity. |
| 539 | message Entry { |
| 540 | // Where the plural was defined. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 541 | Source source = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 542 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 543 | // Any comments associated with the plural. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 544 | string comment = 2; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 545 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 546 | // The arity of the plural. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 547 | Arity arity = 3; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 548 | |
| 549 | // The value assigned to this plural. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 550 | Item item = 4; |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | // The set of arity/plural mappings. |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 554 | repeated Entry entry = 1; |
| 555 | } |
| 556 | |
| 557 | // Defines an abstract XmlNode that must be either an XmlElement, or |
| 558 | // a text node represented by a string. |
| 559 | message XmlNode { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 560 | oneof node { |
| 561 | XmlElement element = 1; |
| 562 | string text = 2; |
| 563 | } |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 564 | |
| 565 | // Source line and column info. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 566 | SourcePosition source = 3; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | // An <element> in an XML document. |
| 570 | message XmlElement { |
| 571 | // Namespaces defined on this element. |
| 572 | repeated XmlNamespace namespace_declaration = 1; |
| 573 | |
| 574 | // The namespace URI of this element. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 575 | string namespace_uri = 2; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 576 | |
| 577 | // The name of this element. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 578 | string name = 3; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 579 | |
| 580 | // The attributes of this element. |
| 581 | repeated XmlAttribute attribute = 4; |
| 582 | |
| 583 | // The children of this element. |
| 584 | repeated XmlNode child = 5; |
| 585 | } |
| 586 | |
| 587 | // A namespace declaration on an XmlElement (xmlns:android="http://..."). |
| 588 | message XmlNamespace { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 589 | string prefix = 1; |
| 590 | string uri = 2; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 591 | |
| 592 | // Source line and column info. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 593 | SourcePosition source = 3; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | // An attribute defined on an XmlElement (android:text="..."). |
| 597 | message XmlAttribute { |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 598 | string namespace_uri = 1; |
| 599 | string name = 2; |
| 600 | string value = 3; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 601 | |
| 602 | // Source line and column info. |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 603 | SourcePosition source = 4; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 604 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 605 | // The optional resource ID (0xPPTTEEEE) of the attribute. |
| 606 | uint32 resource_id = 5; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 607 | |
Adam Lesinski | 5bd4423 | 2017-09-07 09:39:07 -0700 | [diff] [blame] | 608 | // The optional interpreted/compiled version of the `value` string. |
| 609 | Item compiled_item = 6; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 610 | } |
Ryan Mitchell | 326e35ff | 2021-04-12 07:50:42 -0700 | [diff] [blame] | 611 | |
| 612 | message MacroBody { |
| 613 | string raw_string = 1; |
| 614 | StyleString style_string = 2; |
| 615 | repeated UntranslatableSection untranslatable_sections = 3; |
| 616 | repeated NamespaceAlias namespace_stack = 4; |
| 617 | SourcePosition source = 5; |
| 618 | } |
| 619 | |
| 620 | message NamespaceAlias { |
| 621 | string prefix = 1; |
| 622 | string package_name = 2; |
| 623 | bool is_private = 3; |
| 624 | } |
| 625 | |
| 626 | message StyleString { |
| 627 | message Span { |
| 628 | string name = 1; |
| 629 | uint32 start_index = 2; |
| 630 | uint32 end_index = 3; |
| 631 | } |
| 632 | string str = 1; |
| 633 | repeated Span spans = 2; |
| 634 | } |
| 635 | |
| 636 | message UntranslatableSection { |
| 637 | uint64 start_index = 1; |
| 638 | uint64 end_index = 2; |
| 639 | } |