diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-12-09 15:20:52 -0800 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2015-12-10 16:24:15 -0800 |
commit | a6fe345be955368a13aea76aefb4db821aad11df (patch) | |
tree | c5385f798a6e1fb674f6f13c0f323726258618ca /tools/aapt2/ResourceTable.cpp | |
parent | 01655232371d7c7ea5b58ccf66ad99917072018a (diff) |
AAPT2: Fix overlay support
Supports the <add-resource> tag and mimics old AAPT behavior of
not allowing new resources defined unless <add-resource> was used
or --auto-add-overlay was specified.
Change-Id: I9b461137357617ade37fd7045b418b8e6450b9c4
Diffstat (limited to 'tools/aapt2/ResourceTable.cpp')
-rw-r--r-- | tools/aapt2/ResourceTable.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp index 73d85852b2b0..8a3d047f6e8d 100644 --- a/tools/aapt2/ResourceTable.cpp +++ b/tools/aapt2/ResourceTable.cpp @@ -101,7 +101,7 @@ ResourceTableType* ResourceTablePackage::findOrCreateType(ResourceType type) { if (iter != last && (*iter)->type == type) { return iter->get(); } - return types.emplace(iter, new ResourceTableType{ type })->get(); + return types.emplace(iter, new ResourceTableType(type))->get(); } ResourceEntry* ResourceTableType::findEntry(const StringPiece16& name) { @@ -121,7 +121,7 @@ ResourceEntry* ResourceTableType::findOrCreateEntry(const StringPiece16& name) { if (iter != last && name == (*iter)->name) { return iter->get(); } - return entries.emplace(iter, new ResourceEntry{ name })->get(); + return entries.emplace(iter, new ResourceEntry(name))->get(); } /** @@ -342,11 +342,6 @@ bool ResourceTable::setSymbolStateImpl(const ResourceNameRef& name, const Resour IDiagnostics* diag) { assert(diag && "diagnostics can't be nullptr"); - if (symbol.state == SymbolState::kUndefined) { - // Nothing to do. - return true; - } - auto badCharIter = util::findNonAlphaNumericAndNotInSet(name.entry, validChars); if (badCharIter != name.entry.end()) { diag->error(DiagMessage(symbol.source) @@ -400,23 +395,30 @@ bool ResourceTable::setSymbolStateImpl(const ResourceNameRef& name, const Resour return false; } + if (resId.isValid()) { + package->id = resId.packageId(); + type->id = resId.typeId(); + entry->id = resId.entryId(); + } + // Only mark the type state as public, it doesn't care about being private. if (symbol.state == SymbolState::kPublic) { type->symbolStatus.state = SymbolState::kPublic; } - // Downgrading to a private symbol from a public one is not allowed. - if (entry->symbolStatus.state != SymbolState::kPublic) { - if (entry->symbolStatus.state != symbol.state) { - entry->symbolStatus = std::move(symbol); - } + if (symbol.state == SymbolState::kUndefined && + entry->symbolStatus.state != SymbolState::kUndefined) { + // We can't undefine a symbol (remove its visibility). Ignore. + return true; } - if (resId.isValid()) { - package->id = resId.packageId(); - type->id = resId.typeId(); - entry->id = resId.entryId(); + if (symbol.state == SymbolState::kPrivate && + entry->symbolStatus.state == SymbolState::kPublic) { + // We can't downgrade public to private. Ignore. + return true; } + + entry->symbolStatus = std::move(symbol); return true; } |