summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceUtils.cpp
diff options
context:
space:
mode:
author Adam Lesinski <adamlesinski@google.com> 2017-05-30 15:15:58 -0700
committer Adam Lesinski <adamlesinski@google.com> 2017-05-31 10:09:06 -0700
commit5924d8c9ab7bd8614e8bd99864903ce9d50f3bf7 (patch)
treef094afb0142ab4a81faff62f37be306ca0587c33 /tools/aapt2/ResourceUtils.cpp
parentbacaffa497de1877657f9cb3f59a82e3955f0f75 (diff)
AAPT2: Allow merging of Style attributes from overlays
Previously style overlays would completely override an existing style. To be compatible with AAPT, styles now merge with the overlay, allowing the overlay's attributes and parent to take precedence. Bug: 38355988 Test: make aapt2_tests Change-Id: Id25c7240050a43e6a4a177c6e3d51e048d0cceb5
Diffstat (limited to 'tools/aapt2/ResourceUtils.cpp')
-rw-r--r--tools/aapt2/ResourceUtils.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp
index 1bb7d9beee45..818c8cec30f9 100644
--- a/tools/aapt2/ResourceUtils.cpp
+++ b/tools/aapt2/ResourceUtils.cpp
@@ -496,19 +496,17 @@ Maybe<int> ParseSdkVersion(const StringPiece& str) {
std::unique_ptr<BinaryPrimitive> TryParseBool(const StringPiece& str) {
if (Maybe<bool> maybe_result = ParseBool(str)) {
- android::Res_value value = {};
- value.dataType = android::Res_value::TYPE_INT_BOOLEAN;
-
- if (maybe_result.value()) {
- value.data = 0xffffffffu;
- } else {
- value.data = 0;
- }
- return util::make_unique<BinaryPrimitive>(value);
+ const uint32_t data = maybe_result.value() ? 0xffffffffu : 0u;
+ return util::make_unique<BinaryPrimitive>(android::Res_value::TYPE_INT_BOOLEAN, data);
}
return {};
}
+std::unique_ptr<BinaryPrimitive> MakeBool(bool val) {
+ return util::make_unique<BinaryPrimitive>(android::Res_value::TYPE_INT_BOOLEAN,
+ val ? 0xffffffffu : 0u);
+}
+
std::unique_ptr<BinaryPrimitive> TryParseInt(const StringPiece& str) {
std::u16string str16 = util::Utf8ToUtf16(str);
android::Res_value value;