summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceTable.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-10-16 14:37:48 -0700
committerAdam Lesinski <adamlesinski@google.com>2015-10-22 12:52:49 -0700
commit9e10ac70155c993e7053323ad36beaea7bf7d54f (patch)
tree6d5ba83f2ff0e6ff0a0ac1fede1154902b3f14ab /tools/aapt2/ResourceTable.cpp
parent5359893effd12bac156505e1ad3a77a30d27cc0a (diff)
AAPT2: Process <java-symbols> and private symbol package
Need to introduce the idea of multiple levels of visibility to support <java-symbol>. Public, Private, Undefined. Public means it is accessible from outside and requires an ID assigned. Private means that we explicitly want this to be a symbol (show up in R.java), but not visible to other packages. No ID required. Undefined is any normal resource. When --private-symbols is specified in the link phase, these resources will not show up in R.java. Change-Id: Icba89221e08e685dee7683786aa7112baf28c856
Diffstat (limited to 'tools/aapt2/ResourceTable.cpp')
-rw-r--r--tools/aapt2/ResourceTable.cpp49
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();