AAPT2: Define intermediate compiled XML proto
This proto format is meant to encapsulate more information
that is specific to Android and allows for easier validation
and manipulation across tools.
Test: make aapt2_tests
Change-Id: I13bc34a460671fc0a36246be0d287a3d37d244d6
diff --git a/tools/aapt2/proto/ProtoHelpers.cpp b/tools/aapt2/proto/ProtoHelpers.cpp
index 6b21364..aa99c98 100644
--- a/tools/aapt2/proto/ProtoHelpers.cpp
+++ b/tools/aapt2/proto/ProtoHelpers.cpp
@@ -36,7 +36,7 @@
StringPool::Ref ref = src_pool->MakeRef(source.path);
out_pb_source->set_path_idx(static_cast<uint32_t>(ref.index()));
if (source.line) {
- out_pb_source->set_line_no(static_cast<uint32_t>(source.line.value()));
+ out_pb_source->mutable_position()->set_line_number(static_cast<uint32_t>(source.line.value()));
}
}
@@ -46,29 +46,28 @@
out_source->path = util::GetString(src_pool, pb_source.path_idx());
}
- if (pb_source.has_line_no()) {
- out_source->line = static_cast<size_t>(pb_source.line_no());
+ if (pb_source.has_position()) {
+ out_source->line = static_cast<size_t>(pb_source.position().line_number());
}
}
pb::SymbolStatus_Visibility SerializeVisibilityToPb(SymbolState state) {
switch (state) {
case SymbolState::kPrivate:
- return pb::SymbolStatus_Visibility_Private;
+ return pb::SymbolStatus_Visibility_PRIVATE;
case SymbolState::kPublic:
- return pb::SymbolStatus_Visibility_Public;
+ return pb::SymbolStatus_Visibility_PUBLIC;
default:
break;
}
- return pb::SymbolStatus_Visibility_Unknown;
+ return pb::SymbolStatus_Visibility_UNKNOWN;
}
-SymbolState DeserializeVisibilityFromPb(
- pb::SymbolStatus_Visibility pb_visibility) {
+SymbolState DeserializeVisibilityFromPb(pb::SymbolStatus_Visibility pb_visibility) {
switch (pb_visibility) {
- case pb::SymbolStatus_Visibility_Private:
+ case pb::SymbolStatus_Visibility_PRIVATE:
return SymbolState::kPrivate;
- case pb::SymbolStatus_Visibility_Public:
+ case pb::SymbolStatus_Visibility_PUBLIC:
return SymbolState::kPublic;
default:
break;
@@ -102,20 +101,20 @@
pb::Reference_Type SerializeReferenceTypeToPb(Reference::Type type) {
switch (type) {
case Reference::Type::kResource:
- return pb::Reference_Type_Ref;
+ return pb::Reference_Type_REFERENCE;
case Reference::Type::kAttribute:
- return pb::Reference_Type_Attr;
+ return pb::Reference_Type_ATTRIBUTE;
default:
break;
}
- return pb::Reference_Type_Ref;
+ return pb::Reference_Type_REFERENCE;
}
Reference::Type DeserializeReferenceTypeFromPb(pb::Reference_Type pb_type) {
switch (pb_type) {
- case pb::Reference_Type_Ref:
+ case pb::Reference_Type_REFERENCE:
return Reference::Type::kResource;
- case pb::Reference_Type_Attr:
+ case pb::Reference_Type_ATTRIBUTE:
return Reference::Type::kAttribute;
default:
break;
@@ -126,32 +125,32 @@
pb::Plural_Arity SerializePluralEnumToPb(size_t plural_idx) {
switch (plural_idx) {
case Plural::Zero:
- return pb::Plural_Arity_Zero;
+ return pb::Plural_Arity_ZERO;
case Plural::One:
- return pb::Plural_Arity_One;
+ return pb::Plural_Arity_ONE;
case Plural::Two:
- return pb::Plural_Arity_Two;
+ return pb::Plural_Arity_TWO;
case Plural::Few:
- return pb::Plural_Arity_Few;
+ return pb::Plural_Arity_FEW;
case Plural::Many:
- return pb::Plural_Arity_Many;
+ return pb::Plural_Arity_MANY;
default:
break;
}
- return pb::Plural_Arity_Other;
+ return pb::Plural_Arity_OTHER;
}
size_t DeserializePluralEnumFromPb(pb::Plural_Arity arity) {
switch (arity) {
- case pb::Plural_Arity_Zero:
+ case pb::Plural_Arity_ZERO:
return Plural::Zero;
- case pb::Plural_Arity_One:
+ case pb::Plural_Arity_ONE:
return Plural::One;
- case pb::Plural_Arity_Two:
+ case pb::Plural_Arity_TWO:
return Plural::Two;
- case pb::Plural_Arity_Few:
+ case pb::Plural_Arity_FEW:
return Plural::Few;
- case pb::Plural_Arity_Many:
+ case pb::Plural_Arity_MANY:
return Plural::Many;
default:
break;
diff --git a/tools/aapt2/proto/ProtoHelpers.h b/tools/aapt2/proto/ProtoHelpers.h
index cecec2d..2f268f4 100644
--- a/tools/aapt2/proto/ProtoHelpers.h
+++ b/tools/aapt2/proto/ProtoHelpers.h
@@ -23,7 +23,8 @@
#include "ResourceTable.h"
#include "Source.h"
#include "StringPool.h"
-#include "Format.pb.h"
+#include "Resources.pb.h"
+#include "ResourcesInternal.pb.h"
namespace aapt {
diff --git a/tools/aapt2/proto/ProtoSerialize.h b/tools/aapt2/proto/ProtoSerialize.h
index 39c5003..8c46642 100644
--- a/tools/aapt2/proto/ProtoSerialize.h
+++ b/tools/aapt2/proto/ProtoSerialize.h
@@ -30,11 +30,10 @@
class CompiledFileOutputStream {
public:
- explicit CompiledFileOutputStream(
- google::protobuf::io::ZeroCopyOutputStream* out);
+ explicit CompiledFileOutputStream(google::protobuf::io::ZeroCopyOutputStream* out);
void WriteLittleEndian32(uint32_t value);
- void WriteCompiledFile(const pb::CompiledFile* compiledFile);
+ void WriteCompiledFile(const pb::internal::CompiledFile* compiledFile);
void WriteData(const BigBuffer* buffer);
void WriteData(const void* data, size_t len);
bool HadError();
@@ -52,7 +51,7 @@
explicit CompiledFileInputStream(const void* data, size_t size);
bool ReadLittleEndian32(uint32_t* outVal);
- bool ReadCompiledFile(pb::CompiledFile* outVal);
+ bool ReadCompiledFile(pb::internal::CompiledFile* outVal);
bool ReadDataMetaData(uint64_t* outOffset, uint64_t* outLen);
private:
@@ -64,13 +63,12 @@
};
std::unique_ptr<pb::ResourceTable> SerializeTableToPb(ResourceTable* table);
-std::unique_ptr<ResourceTable> DeserializeTableFromPb(
- const pb::ResourceTable& pbTable, const Source& source, IDiagnostics* diag);
+std::unique_ptr<ResourceTable> DeserializeTableFromPb(const pb::ResourceTable& pbTable,
+ const Source& source, IDiagnostics* diag);
-std::unique_ptr<pb::CompiledFile> SerializeCompiledFileToPb(
- const ResourceFile& file);
+std::unique_ptr<pb::internal::CompiledFile> SerializeCompiledFileToPb(const ResourceFile& file);
std::unique_ptr<ResourceFile> DeserializeCompiledFileFromPb(
- const pb::CompiledFile& pbFile, const Source& source, IDiagnostics* diag);
+ const pb::internal::CompiledFile& pbFile, const Source& source, IDiagnostics* diag);
} // namespace aapt
diff --git a/tools/aapt2/proto/TableProtoDeserializer.cpp b/tools/aapt2/proto/TableProtoDeserializer.cpp
index e891954..b9d5878 100644
--- a/tools/aapt2/proto/TableProtoDeserializer.cpp
+++ b/tools/aapt2/proto/TableProtoDeserializer.cpp
@@ -61,54 +61,55 @@
}
public:
- bool DeserializeFromPb(const pb::Package& pbPackage, ResourceTable* table) {
+ bool DeserializeFromPb(const pb::Package& pb_package, ResourceTable* table) {
Maybe<uint8_t> id;
- if (pbPackage.has_package_id()) {
- id = static_cast<uint8_t>(pbPackage.package_id());
+ if (pb_package.has_package_id()) {
+ id = static_cast<uint8_t>(pb_package.package_id());
}
- std::map<ResourceId, ResourceNameRef> idIndex;
+ std::map<ResourceId, ResourceNameRef> id_index;
- ResourceTablePackage* pkg = table->CreatePackage(pbPackage.package_name(), id);
- for (const pb::Type& pbType : pbPackage.types()) {
- const ResourceType* resType = ParseResourceType(pbType.name());
- if (!resType) {
- diag_->Error(DiagMessage(source_) << "unknown type '" << pbType.name() << "'");
+ ResourceTablePackage* pkg = table->CreatePackage(pb_package.package_name(), id);
+ for (const pb::Type& pb_type : pb_package.type()) {
+ const ResourceType* res_type = ParseResourceType(pb_type.name());
+ if (res_type == nullptr) {
+ diag_->Error(DiagMessage(source_) << "unknown type '" << pb_type.name() << "'");
return {};
}
- ResourceTableType* type = pkg->FindOrCreateType(*resType);
+ ResourceTableType* type = pkg->FindOrCreateType(*res_type);
- for (const pb::Entry& pbEntry : pbType.entries()) {
- ResourceEntry* entry = type->FindOrCreateEntry(pbEntry.name());
+ for (const pb::Entry& pb_entry : pb_type.entry()) {
+ ResourceEntry* entry = type->FindOrCreateEntry(pb_entry.name());
// Deserialize the symbol status (public/private with source and comments).
- if (pbEntry.has_symbol_status()) {
- const pb::SymbolStatus& pbStatus = pbEntry.symbol_status();
- if (pbStatus.has_source()) {
- DeserializeSourceFromPb(pbStatus.source(), *source_pool_, &entry->symbol_status.source);
+ if (pb_entry.has_symbol_status()) {
+ const pb::SymbolStatus& pb_status = pb_entry.symbol_status();
+ if (pb_status.has_source()) {
+ DeserializeSourceFromPb(pb_status.source(), *source_pool_,
+ &entry->symbol_status.source);
}
- if (pbStatus.has_comment()) {
- entry->symbol_status.comment = pbStatus.comment();
+ if (pb_status.has_comment()) {
+ entry->symbol_status.comment = pb_status.comment();
}
- entry->symbol_status.allow_new = pbStatus.allow_new();
+ entry->symbol_status.allow_new = pb_status.allow_new();
- SymbolState visibility = DeserializeVisibilityFromPb(pbStatus.visibility());
+ SymbolState visibility = DeserializeVisibilityFromPb(pb_status.visibility());
entry->symbol_status.state = visibility;
if (visibility == SymbolState::kPublic) {
// This is a public symbol, we must encode the ID now if there is one.
- if (pbEntry.has_id()) {
- entry->id = static_cast<uint16_t>(pbEntry.id());
+ if (pb_entry.has_id()) {
+ entry->id = static_cast<uint16_t>(pb_entry.id());
}
if (type->symbol_status.state != SymbolState::kPublic) {
// If the type has not been made public, do so now.
type->symbol_status.state = SymbolState::kPublic;
- if (pbType.has_id()) {
- type->id = static_cast<uint8_t>(pbType.id());
+ if (pb_type.has_id()) {
+ type->id = static_cast<uint8_t>(pb_type.id());
}
}
} else if (visibility == SymbolState::kPrivate) {
@@ -118,37 +119,37 @@
}
}
- ResourceId resId(pbPackage.package_id(), pbType.id(), pbEntry.id());
- if (resId.is_valid()) {
- idIndex[resId] = ResourceNameRef(pkg->name, type->type, entry->name);
+ ResourceId resid(pb_package.package_id(), pb_type.id(), pb_entry.id());
+ if (resid.is_valid()) {
+ id_index[resid] = ResourceNameRef(pkg->name, type->type, entry->name);
}
- for (const pb::ConfigValue& pbConfigValue : pbEntry.config_values()) {
- const pb::ConfigDescription& pbConfig = pbConfigValue.config();
+ for (const pb::ConfigValue& pb_config_value : pb_entry.config_value()) {
+ const pb::ConfigDescription& pb_config = pb_config_value.config();
ConfigDescription config;
- if (!DeserializeConfigDescriptionFromPb(pbConfig, &config)) {
+ if (!DeserializeConfigDescriptionFromPb(pb_config, &config)) {
diag_->Error(DiagMessage(source_) << "invalid configuration");
return {};
}
- ResourceConfigValue* configValue = entry->FindOrCreateValue(config, pbConfig.product());
- if (configValue->value) {
+ ResourceConfigValue* config_value = entry->FindOrCreateValue(config, pb_config.product());
+ if (config_value->value) {
// Duplicate config.
diag_->Error(DiagMessage(source_) << "duplicate configuration");
return {};
}
- configValue->value =
- DeserializeValueFromPb(pbConfigValue.value(), config, &table->string_pool);
- if (!configValue->value) {
+ config_value->value =
+ DeserializeValueFromPb(pb_config_value.value(), config, &table->string_pool);
+ if (!config_value->value) {
return {};
}
}
}
}
- ReferenceIdToNameVisitor visitor(&idIndex);
+ ReferenceIdToNameVisitor visitor(&id_index);
VisitAllValuesInPackage(pkg, &visitor);
return true;
}
@@ -202,8 +203,6 @@
std::unique_ptr<Value> DeserializeValueFromPb(const pb::Value& pb_value,
const ConfigDescription& config,
StringPool* pool) {
- const bool is_weak = pb_value.has_weak() ? pb_value.weak() : false;
-
std::unique_ptr<Value> value;
if (pb_value.has_item()) {
value = DeserializeItemFromPb(pb_value.item(), config, pool);
@@ -215,11 +214,11 @@
const pb::CompoundValue& pb_compound_value = pb_value.compound_value();
if (pb_compound_value.has_attr()) {
const pb::Attribute& pb_attr = pb_compound_value.attr();
- std::unique_ptr<Attribute> attr = util::make_unique<Attribute>(is_weak);
+ std::unique_ptr<Attribute> attr = util::make_unique<Attribute>();
attr->type_mask = pb_attr.format_flags();
attr->min_int = pb_attr.min_int();
attr->max_int = pb_attr.max_int();
- for (const pb::Attribute_Symbol& pb_symbol : pb_attr.symbols()) {
+ for (const pb::Attribute_Symbol& pb_symbol : pb_attr.symbol()) {
Attribute::Symbol symbol;
DeserializeItemCommon(pb_symbol, &symbol.symbol);
if (!DeserializeReferenceFromPb(pb_symbol.name(), &symbol.symbol)) {
@@ -246,7 +245,7 @@
}
}
- for (const pb::Style_Entry& pb_entry : pb_style.entries()) {
+ for (const pb::Style_Entry& pb_entry : pb_style.entry()) {
Style::Entry entry;
DeserializeItemCommon(pb_entry, &entry.key);
if (!DeserializeReferenceFromPb(pb_entry.key(), &entry.key)) {
@@ -266,7 +265,7 @@
} else if (pb_compound_value.has_styleable()) {
const pb::Styleable& pb_styleable = pb_compound_value.styleable();
std::unique_ptr<Styleable> styleable = util::make_unique<Styleable>();
- for (const pb::Styleable_Entry& pb_entry : pb_styleable.entries()) {
+ for (const pb::Styleable_Entry& pb_entry : pb_styleable.entry()) {
Reference attr_ref;
DeserializeItemCommon(pb_entry, &attr_ref);
DeserializeReferenceFromPb(pb_entry.attr(), &attr_ref);
@@ -277,21 +276,21 @@
} else if (pb_compound_value.has_array()) {
const pb::Array& pb_array = pb_compound_value.array();
std::unique_ptr<Array> array = util::make_unique<Array>();
- for (const pb::Array_Entry& pb_entry : pb_array.entries()) {
+ for (const pb::Array_Element& pb_entry : pb_array.element()) {
std::unique_ptr<Item> item = DeserializeItemFromPb(pb_entry.item(), config, pool);
if (!item) {
return {};
}
DeserializeItemCommon(pb_entry, item.get());
- array->items.push_back(std::move(item));
+ array->elements.push_back(std::move(item));
}
value = std::move(array);
} else if (pb_compound_value.has_plural()) {
const pb::Plural& pb_plural = pb_compound_value.plural();
std::unique_ptr<Plural> plural = util::make_unique<Plural>();
- for (const pb::Plural_Entry& pb_entry : pb_plural.entries()) {
+ for (const pb::Plural_Entry& pb_entry : pb_plural.entry()) {
size_t pluralIdx = DeserializePluralEnumFromPb(pb_entry.arity());
plural->values[pluralIdx] = DeserializeItemFromPb(pb_entry.item(), config, pool);
if (!plural->values[pluralIdx]) {
@@ -313,7 +312,7 @@
CHECK(value) << "forgot to set value";
- value->SetWeak(is_weak);
+ value->SetWeak(pb_value.weak());
DeserializeItemCommon(pb_value, value.get());
return value;
}
@@ -378,7 +377,7 @@
}
PackagePbDeserializer package_pb_deserializer(&source_pool, source, diag);
- for (const pb::Package& pb_package : pb_table.packages()) {
+ for (const pb::Package& pb_package : pb_table.package()) {
if (!package_pb_deserializer.DeserializeFromPb(pb_package, table.get())) {
return {};
}
@@ -387,7 +386,7 @@
}
std::unique_ptr<ResourceFile> DeserializeCompiledFileFromPb(
- const pb::CompiledFile& pb_file, const Source& source, IDiagnostics* diag) {
+ const pb::internal::CompiledFile& pb_file, const Source& source, IDiagnostics* diag) {
std::unique_ptr<ResourceFile> file = util::make_unique<ResourceFile>();
ResourceNameRef name_ref;
@@ -403,19 +402,20 @@
file->source.path = pb_file.source_path();
DeserializeConfigDescriptionFromPb(pb_file.config(), &file->config);
- for (const pb::CompiledFile_Symbol& pb_symbol : pb_file.exported_symbols()) {
- // Need to create an lvalue here so that nameRef can point to something
- // real.
- if (!ResourceUtils::ParseResourceName(pb_symbol.resource_name(),
- &name_ref)) {
+ for (const pb::internal::CompiledFile_Symbol& pb_symbol : pb_file.exported_symbol()) {
+ // Need to create an lvalue here so that nameRef can point to something real.
+ if (!ResourceUtils::ParseResourceName(pb_symbol.resource_name(), &name_ref)) {
diag->Error(DiagMessage(source)
<< "invalid resource name for exported symbol in "
"compiled file header: "
<< pb_file.resource_name());
return {};
}
- file->exported_symbols.push_back(
- SourcedResourceName{name_ref.ToResourceName(), pb_symbol.line_no()});
+ size_t line = 0u;
+ if (pb_symbol.has_source()) {
+ line = pb_symbol.source().line_number();
+ }
+ file->exported_symbols.push_back(SourcedResourceName{name_ref.ToResourceName(), line});
}
return file;
}
diff --git a/tools/aapt2/proto/TableProtoSerializer.cpp b/tools/aapt2/proto/TableProtoSerializer.cpp
index 3f48655..a08df71 100644
--- a/tools/aapt2/proto/TableProtoSerializer.cpp
+++ b/tools/aapt2/proto/TableProtoSerializer.cpp
@@ -98,7 +98,7 @@
pb_attr->set_max_int(attr->max_int);
for (auto& symbol : attr->symbols) {
- pb::Attribute_Symbol* pb_symbol = pb_attr->add_symbols();
+ pb::Attribute_Symbol* pb_symbol = pb_attr->add_symbol();
SerializeItemCommonToPb(symbol.symbol, pb_symbol);
SerializeReferenceToPb(symbol.symbol, pb_symbol->mutable_name());
pb_symbol->set_value(symbol.value);
@@ -114,7 +114,7 @@
}
for (Style::Entry& entry : style->entries) {
- pb::Style_Entry* pb_entry = pb_style->add_entries();
+ pb::Style_Entry* pb_entry = pb_style->add_entry();
SerializeReferenceToPb(entry.key, pb_entry->mutable_key());
pb::Item* pb_item = pb_entry->mutable_item();
@@ -127,7 +127,7 @@
void Visit(Styleable* styleable) override {
pb::Styleable* pb_styleable = pb_compound_value()->mutable_styleable();
for (Reference& entry : styleable->entries) {
- pb::Styleable_Entry* pb_entry = pb_styleable->add_entries();
+ pb::Styleable_Entry* pb_entry = pb_styleable->add_entry();
SerializeItemCommonToPb(entry, pb_entry);
SerializeReferenceToPb(entry, pb_entry->mutable_attr());
}
@@ -135,10 +135,10 @@
void Visit(Array* array) override {
pb::Array* pb_array = pb_compound_value()->mutable_array();
- for (auto& value : array->items) {
- pb::Array_Entry* pb_entry = pb_array->add_entries();
- SerializeItemCommonToPb(*value, pb_entry);
- PbSerializerVisitor sub_visitor(source_pool_, pb_entry->mutable_item());
+ for (auto& value : array->elements) {
+ pb::Array_Element* pb_element = pb_array->add_element();
+ SerializeItemCommonToPb(*value, pb_element);
+ PbSerializerVisitor sub_visitor(source_pool_, pb_element->mutable_item());
value->Accept(&sub_visitor);
}
}
@@ -152,7 +152,7 @@
continue;
}
- pb::Plural_Entry* pb_entry = pb_plural->add_entries();
+ pb::Plural_Entry* pb_entry = pb_plural->add_entry();
pb_entry->set_arity(SerializePluralEnumToPb(i));
pb::Item* pb_element = pb_entry->mutable_item();
SerializeItemCommonToPb(*plural->values[i], pb_entry);
@@ -219,21 +219,21 @@
StringPool source_pool;
for (auto& package : table->packages) {
- pb::Package* pb_package = pb_table->add_packages();
+ pb::Package* pb_package = pb_table->add_package();
if (package->id) {
pb_package->set_package_id(package->id.value());
}
pb_package->set_package_name(package->name);
for (auto& type : package->types) {
- pb::Type* pb_type = pb_package->add_types();
+ pb::Type* pb_type = pb_package->add_type();
if (type->id) {
pb_type->set_id(type->id.value());
}
pb_type->set_name(ToString(type->type).to_string());
for (auto& entry : type->entries) {
- pb::Entry* pb_entry = pb_type->add_entries();
+ pb::Entry* pb_entry = pb_type->add_entry();
if (entry->id) {
pb_entry->set_id(entry->id.value());
}
@@ -247,7 +247,7 @@
pb_status->set_allow_new(entry->symbol_status.allow_new);
for (auto& config_value : entry->values) {
- pb::ConfigValue* pb_config_value = pb_entry->add_config_values();
+ pb::ConfigValue* pb_config_value = pb_entry->add_config_value();
SerializeConfig(config_value->config, pb_config_value->mutable_config());
if (!config_value->product.empty()) {
pb_config_value->mutable_config()->set_product(config_value->product);
@@ -275,23 +275,22 @@
return pb_table;
}
-std::unique_ptr<pb::CompiledFile> SerializeCompiledFileToPb(
- const ResourceFile& file) {
- auto pb_file = util::make_unique<pb::CompiledFile>();
+std::unique_ptr<pb::internal::CompiledFile> SerializeCompiledFileToPb(const ResourceFile& file) {
+ auto pb_file = util::make_unique<pb::internal::CompiledFile>();
pb_file->set_resource_name(file.name.ToString());
pb_file->set_source_path(file.source.path);
SerializeConfig(file.config, pb_file->mutable_config());
for (const SourcedResourceName& exported : file.exported_symbols) {
- pb::CompiledFile_Symbol* pb_symbol = pb_file->add_exported_symbols();
+ pb::internal::CompiledFile_Symbol* pb_symbol = pb_file->add_exported_symbol();
pb_symbol->set_resource_name(exported.name.ToString());
- pb_symbol->set_line_no(exported.line);
+ pb_symbol->mutable_source()->set_line_number(exported.line);
}
return pb_file;
}
-CompiledFileOutputStream::CompiledFileOutputStream(ZeroCopyOutputStream* out)
- : out_(out) {}
+CompiledFileOutputStream::CompiledFileOutputStream(ZeroCopyOutputStream* out) : out_(out) {
+}
void CompiledFileOutputStream::EnsureAlignedWrite() {
const int padding = out_.ByteCount() % 4;
@@ -306,8 +305,7 @@
out_.WriteLittleEndian32(val);
}
-void CompiledFileOutputStream::WriteCompiledFile(
- const pb::CompiledFile* compiled_file) {
+void CompiledFileOutputStream::WriteCompiledFile(const pb::internal::CompiledFile* compiled_file) {
EnsureAlignedWrite();
out_.WriteLittleEndian64(static_cast<uint64_t>(compiled_file->ByteSize()));
compiled_file->SerializeWithCachedSizes(&out_);
@@ -327,7 +325,9 @@
out_.WriteRaw(data, len);
}
-bool CompiledFileOutputStream::HadError() { return out_.HadError(); }
+bool CompiledFileOutputStream::HadError() {
+ return out_.HadError();
+}
CompiledFileInputStream::CompiledFileInputStream(const void* data, size_t size)
: in_(static_cast<const uint8_t*>(data), size) {}
@@ -345,7 +345,7 @@
return in_.ReadLittleEndian32(out_val);
}
-bool CompiledFileInputStream::ReadCompiledFile(pb::CompiledFile* out_val) {
+bool CompiledFileInputStream::ReadCompiledFile(pb::internal::CompiledFile* out_val) {
EnsureAlignedRead();
google::protobuf::uint64 pb_size = 0u;
@@ -372,8 +372,7 @@
return true;
}
-bool CompiledFileInputStream::ReadDataMetaData(uint64_t* out_offset,
- uint64_t* out_len) {
+bool CompiledFileInputStream::ReadDataMetaData(uint64_t* out_offset, uint64_t* out_len) {
EnsureAlignedRead();
google::protobuf::uint64 pb_size = 0u;
diff --git a/tools/aapt2/proto/TableProtoSerializer_test.cpp b/tools/aapt2/proto/TableProtoSerializer_test.cpp
index 3ba4e6b..80608b3 100644
--- a/tools/aapt2/proto/TableProtoSerializer_test.cpp
+++ b/tools/aapt2/proto/TableProtoSerializer_test.cpp
@@ -151,10 +151,10 @@
std::string output_str;
{
- std::unique_ptr<pb::CompiledFile> pb_file1 = SerializeCompiledFileToPb(f);
+ std::unique_ptr<pb::internal::CompiledFile> pb_file1 = SerializeCompiledFileToPb(f);
f.name.entry = "__" + f.name.entry + "$0";
- std::unique_ptr<pb::CompiledFile> pb_file2 = SerializeCompiledFileToPb(f);
+ std::unique_ptr<pb::internal::CompiledFile> pb_file2 = SerializeCompiledFileToPb(f);
StringOutputStream out_stream(&output_str);
CompiledFileOutputStream out_file_stream(&out_stream);
@@ -173,7 +173,7 @@
// Read the first compiled file.
- pb::CompiledFile new_pb_file;
+ pb::internal::CompiledFile new_pb_file;
ASSERT_TRUE(in_file_stream.ReadCompiledFile(&new_pb_file));
std::unique_ptr<ResourceFile> file = DeserializeCompiledFileFromPb(
@@ -210,7 +210,7 @@
TEST(TableProtoSerializer, DeserializeCorruptHeaderSafely) {
ResourceFile f;
- std::unique_ptr<pb::CompiledFile> pb_file = SerializeCompiledFileToPb(f);
+ std::unique_ptr<pb::internal::CompiledFile> pb_file = SerializeCompiledFileToPb(f);
const std::string expected_data = "1234";
@@ -232,7 +232,7 @@
EXPECT_TRUE(in_file_stream.ReadLittleEndian32(&num_files));
EXPECT_EQ(1u, num_files);
- pb::CompiledFile new_pb_file;
+ pb::internal::CompiledFile new_pb_file;
EXPECT_FALSE(in_file_stream.ReadCompiledFile(&new_pb_file));
uint64_t offset, len;