Switch ResourceTable to use ResourceNamedType instead of ResourceType.
DD: go/custom-resource-types-in-aapt2
Bug: b/215108200
Test: existing
Change-Id: If9ddcd529dff66c8ec4238f56ab64391c2f44c28
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index fe56018..e27b9aa 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -243,9 +243,9 @@
r_txt_printer.Print("private ");
}
- if (type->type != ResourceType::kStyleable) {
+ if (type->named_type.type != ResourceType::kStyleable) {
r_txt_printer.Print("int ");
- r_txt_printer.Print(to_string(type->type));
+ r_txt_printer.Print(type->named_type.to_string());
r_txt_printer.Print(" ");
r_txt_printer.Println(entry->name);
} else {
diff --git a/tools/aapt2/cmd/Diff.cpp b/tools/aapt2/cmd/Diff.cpp
index d9e8c92..a854146 100644
--- a/tools/aapt2/cmd/Diff.cpp
+++ b/tools/aapt2/cmd/Diff.cpp
@@ -105,7 +105,7 @@
Value* value_b = config_value_b->value.get();
if (!value_a->Equals(value_b)) {
std::stringstream str_stream;
- str_stream << "value " << pkg_a.name << ":" << type_a.type << "/" << entry_a.name
+ str_stream << "value " << pkg_a.name << ":" << type_a.named_type << "/" << entry_a.name
<< " config=" << config_value_a->config << " does not match:\n";
value_a->Print(&str_stream);
str_stream << "\n vs \n";
@@ -128,7 +128,7 @@
auto config_value_b = entry_b.FindValue(config_value_a->config);
if (!config_value_b) {
std::stringstream str_stream;
- str_stream << "missing " << pkg_a.name << ":" << type_a.type << "/" << entry_a.name
+ str_stream << "missing " << pkg_a.name << ":" << type_a.named_type << "/" << entry_a.name
<< " config=" << config_value_a->config;
EmitDiffLine(apk_b->GetSource(), str_stream.str());
diff = true;
@@ -143,7 +143,7 @@
auto config_value_a = entry_a.FindValue(config_value_b->config);
if (!config_value_a) {
std::stringstream str_stream;
- str_stream << "new config " << pkg_b.name << ":" << type_b.type << "/" << entry_b.name
+ str_stream << "new config " << pkg_b.name << ":" << type_b.named_type << "/" << entry_b.name
<< " config=" << config_value_b->config;
EmitDiffLine(apk_b->GetSource(), str_stream.str());
diff = true;
@@ -164,13 +164,15 @@
if (entry_b_iter == type_b.entries.end()) {
// Type A contains a type that type B does not have.
std::stringstream str_stream;
- str_stream << "missing " << pkg_a.name << ":" << type_a.type << "/" << entry_a_iter->name;
+ str_stream << "missing " << pkg_a.name << ":" << type_a.named_type << "/"
+ << entry_a_iter->name;
EmitDiffLine(apk_a->GetSource(), str_stream.str());
diff = true;
} else if (entry_a_iter == type_a.entries.end()) {
// Type B contains a type that type A does not have.
std::stringstream str_stream;
- str_stream << "new entry " << pkg_b.name << ":" << type_b.type << "/" << entry_b_iter->name;
+ str_stream << "new entry " << pkg_b.name << ":" << type_b.named_type << "/"
+ << entry_b_iter->name;
EmitDiffLine(apk_b->GetSource(), str_stream.str());
diff = true;
} else {
@@ -178,7 +180,7 @@
const auto& entry_b = *entry_b_iter;
if (IsSymbolVisibilityDifferent(entry_a.visibility, entry_b.visibility)) {
std::stringstream str_stream;
- str_stream << pkg_a.name << ":" << type_a.type << "/" << entry_a.name
+ str_stream << pkg_a.name << ":" << type_a.named_type << "/" << entry_a.name
<< " has different visibility (";
if (entry_b.visibility.staged_api) {
str_stream << "STAGED ";
@@ -203,7 +205,7 @@
} else if (IsIdDiff(entry_a.visibility.level, entry_a.id, entry_b.visibility.level,
entry_b.id)) {
std::stringstream str_stream;
- str_stream << pkg_a.name << ":" << type_a.type << "/" << entry_a.name
+ str_stream << pkg_a.name << ":" << type_a.named_type << "/" << entry_a.name
<< " has different public ID (";
if (entry_b.id) {
str_stream << "0x" << std::hex << entry_b.id.value();
@@ -243,13 +245,13 @@
if (type_b_iter == pkg_b.types.end()) {
// Type A contains a type that type B does not have.
std::stringstream str_stream;
- str_stream << "missing " << pkg_a.name << ":" << type_a_iter->type;
+ str_stream << "missing " << pkg_a.name << ":" << type_a_iter->named_type;
EmitDiffLine(apk_a->GetSource(), str_stream.str());
diff = true;
} else if (type_a_iter == pkg_a.types.end()) {
// Type B contains a type that type A does not have.
std::stringstream str_stream;
- str_stream << "new type " << pkg_b.name << ":" << type_b_iter->type;
+ str_stream << "new type " << pkg_b.name << ":" << type_b_iter->named_type;
EmitDiffLine(apk_b->GetSource(), str_stream.str());
diff = true;
} else {
@@ -257,7 +259,7 @@
const auto& type_b = *type_b_iter;
if (type_a.visibility_level != type_b.visibility_level) {
std::stringstream str_stream;
- str_stream << pkg_a.name << ":" << type_a.type << " has different visibility (";
+ str_stream << pkg_a.name << ":" << type_a.named_type << " has different visibility (";
if (type_b.visibility_level == Visibility::Level::kPublic) {
str_stream << "PUBLIC";
} else {
@@ -274,7 +276,7 @@
diff = true;
} else if (IsIdDiff(type_a.visibility_level, type_a.id, type_b.visibility_level, type_b.id)) {
std::stringstream str_stream;
- str_stream << pkg_a.name << ":" << type_a.type << " has different public ID (";
+ str_stream << pkg_a.name << ":" << type_a.named_type << " has different public ID (";
if (type_b.id) {
str_stream << "0x" << std::hex << type_b.id.value();
} else {
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index 1efe6c2..bd74cc7 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -556,7 +556,7 @@
file_op.config = config_value->config;
file_op.file_to_copy = file;
- if (type->type != ResourceType::kRaw &&
+ if (type->named_type.type != ResourceType::kRaw &&
(file_ref->type == ResourceFile::Type::kBinaryXml ||
file_ref->type == ResourceFile::Type::kProtoXml)) {
std::unique_ptr<io::IData> data = file->OpenAsData();
@@ -596,7 +596,8 @@
file_op.xml_to_flatten->file.config = config_value->config;
file_op.xml_to_flatten->file.source = file_ref->GetSource();
- file_op.xml_to_flatten->file.name = ResourceName(pkg->name, type->type, entry->name);
+ file_op.xml_to_flatten->file.name =
+ ResourceName(pkg->name, type->named_type, entry->name);
}
// NOTE(adamlesinski): Explicitly construct a StringPiece here, or
@@ -1009,7 +1010,7 @@
// We have a package that is not related to the one we're building!
for (const auto& type : package->types) {
for (const auto& entry : type->entries) {
- ResourceNameRef res_name(package->name, type->type, entry->name);
+ ResourceNameRef res_name(package->name, type->named_type, entry->name);
for (const auto& config_value : entry->values) {
// Special case the occurrence of an ID that is being generated
@@ -1046,7 +1047,7 @@
for (const auto& type : package->types) {
for (const auto& entry : type->entries) {
if (entry->id) {
- ResourceNameRef res_name(package->name, type->type, entry->name);
+ ResourceNameRef res_name(package->name, type->named_type, entry->name);
context_->GetDiagnostics()->Error(DiagMessage() << "resource " << res_name << " has ID "
<< entry->id.value() << " assigned");
return false;
@@ -2016,7 +2017,7 @@
for (auto& package : final_table_.packages) {
for (auto& type : package->types) {
for (auto& entry : type->entries) {
- ResourceName name(package->name, type->type, entry->name);
+ ResourceName name(package->name, type->named_type, entry->name);
// The IDs are guaranteed to exist.
options_.stable_id_map[std::move(name)] = entry->id.value();
}
diff --git a/tools/aapt2/cmd/Optimize.cpp b/tools/aapt2/cmd/Optimize.cpp
index caa3e60..e1370fd 100644
--- a/tools/aapt2/cmd/Optimize.cpp
+++ b/tools/aapt2/cmd/Optimize.cpp
@@ -254,7 +254,7 @@
}
if (file_ref->file == nullptr) {
- ResourceNameRef name(pkg->name, type->type, entry->name);
+ ResourceNameRef name(pkg->name, type->named_type, entry->name);
context_->GetDiagnostics()->Warn(DiagMessage(file_ref->GetSource())
<< "file for resource " << name << " with config '"
<< config_value->config << "' not found");