summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceValues.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-12-17 13:03:11 -0800
committerAdam Lesinski <adamlesinski@google.com>2016-01-06 12:05:41 -0800
commit393b5f0d6130d3848dd82075986a5cf40c09ce44 (patch)
tree5643311ac74ad383b2efa37fee2f3d21878cf6d8 /tools/aapt2/ResourceValues.cpp
parent24b8ff0faf7c59323d0171cdd825ca09e712aa1e (diff)
AAPT2: Port AAPT pseudolocalization to AAPT2
Pseudolocalization happens at the compile phase. Pseudolocalized values are weak, such that manually specified values will take precedence. Change-Id: I5e064ce0d270c9f4f9022f75aecedab9d45bc980
Diffstat (limited to 'tools/aapt2/ResourceValues.cpp')
-rw-r--r--tools/aapt2/ResourceValues.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/tools/aapt2/ResourceValues.cpp b/tools/aapt2/ResourceValues.cpp
index be963ffde2b3..b93e6d889ad0 100644
--- a/tools/aapt2/ResourceValues.cpp
+++ b/tools/aapt2/ResourceValues.cpp
@@ -36,10 +36,6 @@ void BaseItem<Derived>::accept(RawValueVisitor* visitor) {
visitor->visit(static_cast<Derived*>(this));
}
-bool Value::isWeak() const {
- return false;
-}
-
RawString::RawString(const StringPool::Ref& ref) : value(ref) {
}
@@ -101,10 +97,6 @@ void Reference::print(std::ostream* out) const {
}
}
-bool Id::isWeak() const {
- return true;
-}
-
bool Id::flatten(android::Res_value* out) const {
out->dataType = android::Res_value::TYPE_INT_BOOLEAN;
out->data = util::hostToDevice32(0);
@@ -119,7 +111,15 @@ void Id::print(std::ostream* out) const {
*out << "(id)";
}
-String::String(const StringPool::Ref& ref) : value(ref) {
+String::String(const StringPool::Ref& ref) : value(ref), mTranslateable(true) {
+}
+
+void String::setTranslateable(bool val) {
+ mTranslateable = val;
+}
+
+bool String::isTranslateable() const {
+ return mTranslateable;
}
bool String::flatten(android::Res_value* outValue) const {
@@ -144,7 +144,15 @@ void String::print(std::ostream* out) const {
*out << "(string) \"" << *value << "\"";
}
-StyledString::StyledString(const StringPool::StyleRef& ref) : value(ref) {
+StyledString::StyledString(const StringPool::StyleRef& ref) : value(ref), mTranslateable(true) {
+}
+
+void StyledString::setTranslateable(bool val) {
+ mTranslateable = val;
+}
+
+bool StyledString::isTranslateable() const {
+ return mTranslateable;
}
bool StyledString::flatten(android::Res_value* outValue) const {
@@ -238,13 +246,10 @@ void BinaryPrimitive::print(std::ostream* out) const {
}
Attribute::Attribute(bool w, uint32_t t) :
- weak(w), typeMask(t),
+ typeMask(t),
minInt(std::numeric_limits<int32_t>::min()),
maxInt(std::numeric_limits<int32_t>::max()) {
-}
-
-bool Attribute::isWeak() const {
- return weak;
+ mWeak = w;
}
Attribute* Attribute::clone(StringPool* /*newPool*/) const {
@@ -359,7 +364,7 @@ void Attribute::print(std::ostream* out) const {
<< "]";
}
- if (weak) {
+ if (isWeak()) {
*out << " [weak]";
}
}