Loading tools/aapt2/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ testSources := \ toolSources := \ compile/Compile.cpp \ diff/Diff.cpp \ dump/Dump.cpp \ link/Link.cpp Loading tools/aapt2/Main.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ namespace aapt { extern int compile(const std::vector<StringPiece>& args); extern int link(const std::vector<StringPiece>& args); extern int dump(const std::vector<StringPiece>& args); extern int diff(const std::vector<StringPiece>& args); } // namespace aapt Loading @@ -44,12 +45,14 @@ int main(int argc, char** argv) { return aapt::link(args); } else if (command == "dump" || command == "d") { return aapt::dump(args); } else if (command == "diff") { return aapt::diff(args); } std::cerr << "unknown command '" << command << "'\n"; } else { std::cerr << "no command specified\n"; } std::cerr << "\nusage: aapt2 [compile|link|dump] ..." << std::endl; std::cerr << "\nusage: aapt2 [compile|link|dump|diff] ..." << std::endl; return 1; } tools/aapt2/ResourceParser.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -152,7 +152,7 @@ bool ResourceParser::flattenXmlSubtree(xml::XmlPullParser* parser, std::u16strin break; } spanStack.back().lastChar = builder.str().size(); spanStack.back().lastChar = builder.str().size() - 1; outStyleString->spans.push_back(spanStack.back()); spanStack.pop_back(); Loading Loading @@ -1058,6 +1058,16 @@ bool ResourceParser::parseArrayImpl(xml::XmlPullParser* parser, ParsedResource* std::unique_ptr<Array> array = util::make_unique<Array>(); bool translateable = mOptions.translatable; if (Maybe<StringPiece16> translateableAttr = xml::findAttribute(parser, u"translatable")) { if (!ResourceUtils::tryParseBool(translateableAttr.value(), &translateable)) { mDiag->error(DiagMessage(outResource->source) << "invalid value for 'translatable'. Must be a boolean"); return false; } } array->setTranslateable(translateable); bool error = false; const size_t depth = parser->getDepth(); while (xml::XmlPullParser::nextChildNode(parser, depth)) { Loading tools/aapt2/ResourceTable.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,17 @@ std::vector<ResourceConfigValue*> ResourceEntry::findAllValues(const ConfigDescr return results; } std::vector<ResourceConfigValue*> ResourceEntry::findValuesIf( const std::function<bool(ResourceConfigValue*)>& f) { std::vector<ResourceConfigValue*> results; for (auto& configValue : values) { if (f(configValue.get())) { results.push_back(configValue.get()); } } return results; } /** * The default handler for collisions. A return value of -1 means keep the * existing value, 0 means fail, and +1 means take the incoming value. Loading tools/aapt2/ResourceTable.h +4 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "io/File.h" #include <android-base/macros.h> #include <functional> #include <map> #include <memory> #include <string> Loading Loading @@ -109,6 +110,9 @@ public: ResourceConfigValue* findOrCreateValue(const ConfigDescription& config, const StringPiece& product); std::vector<ResourceConfigValue*> findAllValues(const ConfigDescription& config); std::vector<ResourceConfigValue*> findValuesIf( const std::function<bool(ResourceConfigValue*)>& f); private: DISALLOW_COPY_AND_ASSIGN(ResourceEntry); Loading Loading
tools/aapt2/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ testSources := \ toolSources := \ compile/Compile.cpp \ diff/Diff.cpp \ dump/Dump.cpp \ link/Link.cpp Loading
tools/aapt2/Main.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ namespace aapt { extern int compile(const std::vector<StringPiece>& args); extern int link(const std::vector<StringPiece>& args); extern int dump(const std::vector<StringPiece>& args); extern int diff(const std::vector<StringPiece>& args); } // namespace aapt Loading @@ -44,12 +45,14 @@ int main(int argc, char** argv) { return aapt::link(args); } else if (command == "dump" || command == "d") { return aapt::dump(args); } else if (command == "diff") { return aapt::diff(args); } std::cerr << "unknown command '" << command << "'\n"; } else { std::cerr << "no command specified\n"; } std::cerr << "\nusage: aapt2 [compile|link|dump] ..." << std::endl; std::cerr << "\nusage: aapt2 [compile|link|dump|diff] ..." << std::endl; return 1; }
tools/aapt2/ResourceParser.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -152,7 +152,7 @@ bool ResourceParser::flattenXmlSubtree(xml::XmlPullParser* parser, std::u16strin break; } spanStack.back().lastChar = builder.str().size(); spanStack.back().lastChar = builder.str().size() - 1; outStyleString->spans.push_back(spanStack.back()); spanStack.pop_back(); Loading Loading @@ -1058,6 +1058,16 @@ bool ResourceParser::parseArrayImpl(xml::XmlPullParser* parser, ParsedResource* std::unique_ptr<Array> array = util::make_unique<Array>(); bool translateable = mOptions.translatable; if (Maybe<StringPiece16> translateableAttr = xml::findAttribute(parser, u"translatable")) { if (!ResourceUtils::tryParseBool(translateableAttr.value(), &translateable)) { mDiag->error(DiagMessage(outResource->source) << "invalid value for 'translatable'. Must be a boolean"); return false; } } array->setTranslateable(translateable); bool error = false; const size_t depth = parser->getDepth(); while (xml::XmlPullParser::nextChildNode(parser, depth)) { Loading
tools/aapt2/ResourceTable.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,17 @@ std::vector<ResourceConfigValue*> ResourceEntry::findAllValues(const ConfigDescr return results; } std::vector<ResourceConfigValue*> ResourceEntry::findValuesIf( const std::function<bool(ResourceConfigValue*)>& f) { std::vector<ResourceConfigValue*> results; for (auto& configValue : values) { if (f(configValue.get())) { results.push_back(configValue.get()); } } return results; } /** * The default handler for collisions. A return value of -1 means keep the * existing value, 0 means fail, and +1 means take the incoming value. Loading
tools/aapt2/ResourceTable.h +4 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "io/File.h" #include <android-base/macros.h> #include <functional> #include <map> #include <memory> #include <string> Loading Loading @@ -109,6 +110,9 @@ public: ResourceConfigValue* findOrCreateValue(const ConfigDescription& config, const StringPiece& product); std::vector<ResourceConfigValue*> findAllValues(const ConfigDescription& config); std::vector<ResourceConfigValue*> findValuesIf( const std::function<bool(ResourceConfigValue*)>& f); private: DISALLOW_COPY_AND_ASSIGN(ResourceEntry); Loading