326e35ffaf
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
51 lines
1.8 KiB
C++
51 lines
1.8 KiB
C++
/*
|
|
* Copyright (C) 2021 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include "ValueTransformer.h"
|
|
|
|
#include "ResourceValues.h"
|
|
|
|
namespace aapt {
|
|
|
|
#define VALUE_CREATE_VALUE_DECL(T) \
|
|
std::unique_ptr<Value> ValueTransformer::TransformValue(const T* value) { \
|
|
return TransformDerived(value); \
|
|
}
|
|
|
|
#define VALUE_CREATE_ITEM_DECL(T) \
|
|
std::unique_ptr<Item> ValueTransformer::TransformItem(const T* value) { \
|
|
return TransformDerived(value); \
|
|
} \
|
|
std::unique_ptr<Value> ValueTransformer::TransformValue(const T* value) { \
|
|
return TransformItem(value); \
|
|
}
|
|
|
|
VALUE_CREATE_ITEM_DECL(Id);
|
|
VALUE_CREATE_ITEM_DECL(Reference);
|
|
VALUE_CREATE_ITEM_DECL(RawString);
|
|
VALUE_CREATE_ITEM_DECL(String);
|
|
VALUE_CREATE_ITEM_DECL(StyledString);
|
|
VALUE_CREATE_ITEM_DECL(FileReference);
|
|
VALUE_CREATE_ITEM_DECL(BinaryPrimitive);
|
|
|
|
VALUE_CREATE_VALUE_DECL(Attribute);
|
|
VALUE_CREATE_VALUE_DECL(Style);
|
|
VALUE_CREATE_VALUE_DECL(Array);
|
|
VALUE_CREATE_VALUE_DECL(Plural);
|
|
VALUE_CREATE_VALUE_DECL(Styleable);
|
|
VALUE_CREATE_VALUE_DECL(Macro);
|
|
|
|
} // namespace aapt
|