diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-10-22 20:34:36 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-10-22 20:34:36 +0000 |
commit | 3b7acbb86207df78eccfeb40aabcc8543703a58f (patch) | |
tree | 83f34be40fa67c390d4edbbec8d7b85e450cc879 /tools/aapt2/ResourceTable.cpp | |
parent | 1b433617675c58e6878e5eccf1635a43b5377135 (diff) | |
parent | 9e10ac70155c993e7053323ad36beaea7bf7d54f (diff) |
Merge "AAPT2: Process <java-symbols> and private symbol package"
Diffstat (limited to 'tools/aapt2/ResourceTable.cpp')
-rw-r--r-- | tools/aapt2/ResourceTable.cpp | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp index e32fb5ee22ea..84674e841063 100644 --- a/tools/aapt2/ResourceTable.cpp +++ b/tools/aapt2/ResourceTable.cpp @@ -220,6 +220,16 @@ bool ResourceTable::addResourceAllowMangled(const ResourceNameRef& name, kValidNameMangledChars, diag); } +bool ResourceTable::addResourceAllowMangled(const ResourceNameRef& name, + const ResourceId id, + const ConfigDescription& config, + const Source& source, + std::unique_ptr<Value> value, + IDiagnostics* diag) { + return addResourceImpl(name, id, config, source, std::move(value), + kValidNameMangledChars, diag); +} + bool ResourceTable::addResourceImpl(const ResourceNameRef& name, const ResourceId resId, const ConfigDescription& config, const Source& source, std::unique_ptr<Value> value, const char16_t* validChars, @@ -305,19 +315,25 @@ bool ResourceTable::addResourceImpl(const ResourceNameRef& name, const ResourceI return true; } -bool ResourceTable::markPublic(const ResourceNameRef& name, const ResourceId resId, - const Source& source, IDiagnostics* diag) { - return markPublicImpl(name, resId, source, kValidNameChars, diag); +bool ResourceTable::setSymbolState(const ResourceNameRef& name, const ResourceId resId, + const Source& source, SymbolState state, IDiagnostics* diag) { + return setSymbolStateImpl(name, resId, source, state, kValidNameChars, diag); } -bool ResourceTable::markPublicAllowMangled(const ResourceNameRef& name, const ResourceId resId, - const Source& source, IDiagnostics* diag) { - return markPublicImpl(name, resId, source, kValidNameMangledChars, diag); +bool ResourceTable::setSymbolStateAllowMangled(const ResourceNameRef& name, const ResourceId resId, + const Source& source, SymbolState state, + IDiagnostics* diag) { + return setSymbolStateImpl(name, resId, source, state, kValidNameMangledChars, diag); } -bool ResourceTable::markPublicImpl(const ResourceNameRef& name, const ResourceId resId, - const Source& source, const char16_t* validChars, - IDiagnostics* diag) { +bool ResourceTable::setSymbolStateImpl(const ResourceNameRef& name, const ResourceId resId, + const Source& source, SymbolState state, + const char16_t* validChars, IDiagnostics* diag) { + if (state == SymbolState::kUndefined) { + // Nothing to do. + return true; + } + auto badCharIter = util::findNonAlphaNumericAndNotInSet(name.entry, validChars); if (badCharIter != name.entry.end()) { diag->error(DiagMessage(source) @@ -371,9 +387,18 @@ bool ResourceTable::markPublicImpl(const ResourceNameRef& name, const ResourceId return false; } - type->publicStatus.isPublic = true; - entry->publicStatus.isPublic = true; - entry->publicStatus.source = source; + // Only mark the type state as public, it doesn't care about being private. + if (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 != state) { + entry->symbolStatus.state = state; + entry->symbolStatus.source = source; + } + } if (resId.isValid()) { package->id = resId.packageId(); |