From e4bb9eb5af5b0899dc0921d5580220b20e15bd5a Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Fri, 12 Feb 2016 22:18:51 -0800 Subject: AAPT2: Introduce notion of 'product' to ResourceTable This allows us to preserve the various product definitions during the compile phase, and allows us to select the product in the link phase. This allows compiled files to remain product-independent, so that they do not need to be recompiled when switching targets. Bug:25958912 Change-Id: Iaa7eed25c834b67a39cdc9be43613e8b5ab6cdd7 --- tools/aapt2/java/JavaClassGenerator.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'tools/aapt2/java/JavaClassGenerator.cpp') diff --git a/tools/aapt2/java/JavaClassGenerator.cpp b/tools/aapt2/java/JavaClassGenerator.cpp index 7280f3a968a0..6e340a2a2742 100644 --- a/tools/aapt2/java/JavaClassGenerator.cpp +++ b/tools/aapt2/java/JavaClassGenerator.cpp @@ -23,7 +23,6 @@ #include "java/AnnotationProcessor.h" #include "java/ClassDefinitionWriter.h" #include "java/JavaClassGenerator.h" -#include "util/Comparators.h" #include "util/StringPiece.h" #include @@ -258,12 +257,12 @@ bool JavaClassGenerator::writeEntriesForClass(ClassDefinitionWriter* outClassDef } for (const auto& configValue : entry->values) { - processor.appendComment(configValue.value->getComment()); + processor.appendComment(configValue->value->getComment()); } // If this is an Attribute, append the format Javadoc. if (!entry->values.empty()) { - if (Attribute* attr = valueCast(entry->values.front().value.get())) { + if (Attribute* attr = valueCast(entry->values.front()->value.get())) { // We list out the available values for the given attribute. addAttributeFormatDoc(&processor, attr); } @@ -272,7 +271,7 @@ bool JavaClassGenerator::writeEntriesForClass(ClassDefinitionWriter* outClassDef if (type->type == ResourceType::kStyleable) { assert(!entry->values.empty()); const Styleable* styleable = static_cast( - entry->values.front().value.get()); + entry->values.front()->value.get()); writeStyleableEntryForClass(outClassDef, &processor, packageNameToGenerate, unmangledName, styleable); } else { @@ -311,11 +310,10 @@ bool JavaClassGenerator::generate(const StringPiece16& packageNameToGenerate, if (type->type == ResourceType::kAttr) { // Also include private attributes in this same class. - auto iter = std::lower_bound(package->types.begin(), package->types.end(), - ResourceType::kAttrPrivate, cmp::lessThanType); - if (iter != package->types.end() && (*iter)->type == ResourceType::kAttrPrivate) { + ResourceTableType* privType = package->findType(ResourceType::kAttrPrivate); + if (privType) { result = writeEntriesForClass(&classDef, packageNameToGenerate, - package.get(), iter->get()); + package.get(), privType); if (!result) { return false; } -- cgit v1.2.3