summaryrefslogtreecommitdiff
path: root/tools/aapt2/xml/XmlPullParser.h
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2021-04-12 07:50:42 -0700
committerRyan Mitchell <rtmitchell@google.com>2021-04-28 14:58:23 -0700
commit326e35ffaf0ee1e3d07c977217f4e600088fd9d5 (patch)
treec229a21641960bae0297e0b8bedb03305693024f /tools/aapt2/xml/XmlPullParser.h
parentff68a9adc3454b7cddb2501d8e82bd4b10b2037c (diff)
Add <macro> tag to aapt2
AAPT2 Macros are compile-time resources definitions that are expanded when referenced during the link phase. A macro must be defined in the res/values.xml directory. A macro definition for a macro named "foo" looks like the following: <macro name="foo">contents</macro> When "@macro/foo" is used in the res/values directory or in a compiled XML file, the contents of the macro replace the macro reference and then the substituted contents are compiled and linked. If the macro contents reference xml namespaces from its original definition, the namespaces of the original macro definition will be used to determine which package is being referenced. Macros can be used anywhere resources can be referenced using the @package:type/entry syntax. Macros are not included in the final resource table or the R.java since they are not actual resources. Bug: 175616308 Test: aapt2_tests Change-Id: I48b29ab6564357b32b4b4e32bff7ef06036382bc
Diffstat (limited to 'tools/aapt2/xml/XmlPullParser.h')
-rw-r--r--tools/aapt2/xml/XmlPullParser.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/aapt2/xml/XmlPullParser.h b/tools/aapt2/xml/XmlPullParser.h
index 6ebaa285745b..5da2d4b10a4b 100644
--- a/tools/aapt2/xml/XmlPullParser.h
+++ b/tools/aapt2/xml/XmlPullParser.h
@@ -123,6 +123,13 @@ class XmlPullParser : public IPackageDeclStack {
*/
Maybe<ExtractedPackage> TransformPackageAlias(const android::StringPiece& alias) const override;
+ struct PackageDecl {
+ std::string prefix;
+ ExtractedPackage package;
+ };
+
+ const std::vector<PackageDecl>& package_decls() const;
+
//
// Remaining methods are for retrieving information about attributes
// associated with a StartElement.
@@ -180,11 +187,6 @@ class XmlPullParser : public IPackageDeclStack {
const std::string empty_;
size_t depth_;
std::stack<std::string> namespace_uris_;
-
- struct PackageDecl {
- std::string prefix;
- ExtractedPackage package;
- };
std::vector<PackageDecl> package_aliases_;
};