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/Android.bp b/tools/aapt2/Android.bp
index 15fb016..24aa6eb 100644
--- a/tools/aapt2/Android.bp
+++ b/tools/aapt2/Android.bp
@@ -143,7 +143,8 @@
"xml/XmlDom.cpp",
"xml/XmlPullParser.cpp",
"xml/XmlUtil.cpp",
- "Format.proto",
+ "Resources.proto",
+ "ResourcesInternal.proto",
],
proto: {
export_proto_headers: true,
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index a5783a5..1c3ac2a 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -1219,7 +1219,7 @@
continue;
}
item->SetSource(item_source);
- array->items.emplace_back(std::move(item));
+ array->elements.emplace_back(std::move(item));
} else if (!ShouldIgnoreElement(element_namespace, element_name)) {
diag_->Error(DiagMessage(source_.WithLine(parser->line_number()))
diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp
index 971b45e..144ebd2 100644
--- a/tools/aapt2/ResourceParser_test.cpp
+++ b/tools/aapt2/ResourceParser_test.cpp
@@ -540,11 +540,11 @@
Array* array = test::GetValue<Array>(&table_, "array/foo");
ASSERT_THAT(array, NotNull());
- ASSERT_THAT(array->items, SizeIs(3));
+ ASSERT_THAT(array->elements, SizeIs(3));
- EXPECT_THAT(ValueCast<Reference>(array->items[0].get()), NotNull());
- EXPECT_THAT(ValueCast<String>(array->items[1].get()), NotNull());
- EXPECT_THAT(ValueCast<BinaryPrimitive>(array->items[2].get()), NotNull());
+ EXPECT_THAT(ValueCast<Reference>(array->elements[0].get()), NotNull());
+ EXPECT_THAT(ValueCast<String>(array->elements[1].get()), NotNull());
+ EXPECT_THAT(ValueCast<BinaryPrimitive>(array->elements[2].get()), NotNull());
}
TEST_F(ResourceParserTest, ParseStringArray) {
@@ -565,9 +565,9 @@
Array* array = test::GetValue<Array>(&table_, "array/foo");
ASSERT_THAT(array, NotNull());
- ASSERT_THAT(array->items, SizeIs(1));
+ ASSERT_THAT(array->elements, SizeIs(1));
- String* str = ValueCast<String>(array->items[0].get());
+ String* str = ValueCast<String>(array->elements[0].get());
ASSERT_THAT(str, NotNull());
EXPECT_THAT(*str, StrValueEq("100"));
}
diff --git a/tools/aapt2/ResourceValues.cpp b/tools/aapt2/ResourceValues.cpp
index eb59175..1cba194 100644
--- a/tools/aapt2/ResourceValues.cpp
+++ b/tools/aapt2/ResourceValues.cpp
@@ -805,13 +805,12 @@
return false;
}
- if (items.size() != other->items.size()) {
+ if (elements.size() != other->elements.size()) {
return false;
}
- return std::equal(items.begin(), items.end(), other->items.begin(),
- [](const std::unique_ptr<Item>& a,
- const std::unique_ptr<Item>& b) -> bool {
+ return std::equal(elements.begin(), elements.end(), other->elements.begin(),
+ [](const std::unique_ptr<Item>& a, const std::unique_ptr<Item>& b) -> bool {
return a->Equals(b.get());
});
}
@@ -820,14 +819,14 @@
Array* array = new Array();
array->comment_ = comment_;
array->source_ = source_;
- for (auto& item : items) {
- array->items.emplace_back(std::unique_ptr<Item>(item->Clone(new_pool)));
+ for (auto& item : elements) {
+ array->elements.emplace_back(std::unique_ptr<Item>(item->Clone(new_pool)));
}
return array;
}
void Array::Print(std::ostream* out) const {
- *out << "(array) [" << util::Joiner(items, ", ") << "]";
+ *out << "(array) [" << util::Joiner(elements, ", ") << "]";
}
bool Plural::Equals(const Value* value) const {
diff --git a/tools/aapt2/ResourceValues.h b/tools/aapt2/ResourceValues.h
index 7e7547f..275864b 100644
--- a/tools/aapt2/ResourceValues.h
+++ b/tools/aapt2/ResourceValues.h
@@ -292,7 +292,7 @@
};
struct Array : public BaseValue<Array> {
- std::vector<std::unique_ptr<Item>> items;
+ std::vector<std::unique_ptr<Item>> elements;
bool Equals(const Value* value) const override;
Array* Clone(StringPool* new_pool) const override;
diff --git a/tools/aapt2/ResourceValues_test.cpp b/tools/aapt2/ResourceValues_test.cpp
index 06c3404..10f9b55 100644
--- a/tools/aapt2/ResourceValues_test.cpp
+++ b/tools/aapt2/ResourceValues_test.cpp
@@ -54,19 +54,19 @@
StringPool pool;
Array a;
- a.items.push_back(util::make_unique<String>(pool.MakeRef("one")));
- a.items.push_back(util::make_unique<String>(pool.MakeRef("two")));
+ a.elements.push_back(util::make_unique<String>(pool.MakeRef("one")));
+ a.elements.push_back(util::make_unique<String>(pool.MakeRef("two")));
Array b;
- b.items.push_back(util::make_unique<String>(pool.MakeRef("une")));
- b.items.push_back(util::make_unique<String>(pool.MakeRef("deux")));
+ b.elements.push_back(util::make_unique<String>(pool.MakeRef("une")));
+ b.elements.push_back(util::make_unique<String>(pool.MakeRef("deux")));
Array c;
- c.items.push_back(util::make_unique<String>(pool.MakeRef("uno")));
+ c.elements.push_back(util::make_unique<String>(pool.MakeRef("uno")));
Array d;
- d.items.push_back(util::make_unique<String>(pool.MakeRef("one")));
- d.items.push_back(util::make_unique<String>(pool.MakeRef("two")));
+ d.elements.push_back(util::make_unique<String>(pool.MakeRef("one")));
+ d.elements.push_back(util::make_unique<String>(pool.MakeRef("two")));
EXPECT_FALSE(a.Equals(&b));
EXPECT_FALSE(a.Equals(&c));
@@ -78,8 +78,8 @@
StringPool pool;
Array a;
- a.items.push_back(util::make_unique<String>(pool.MakeRef("one")));
- a.items.push_back(util::make_unique<String>(pool.MakeRef("two")));
+ a.elements.push_back(util::make_unique<String>(pool.MakeRef("one")));
+ a.elements.push_back(util::make_unique<String>(pool.MakeRef("two")));
std::unique_ptr<Array> b(a.Clone(&pool));
EXPECT_TRUE(a.Equals(b.get()));
diff --git a/tools/aapt2/Format.proto b/tools/aapt2/Resources.proto
similarity index 77%
rename from tools/aapt2/Format.proto
rename to tools/aapt2/Resources.proto
index 6be7f02..71f33b0 100644
--- a/tools/aapt2/Format.proto
+++ b/tools/aapt2/Resources.proto
@@ -14,14 +14,18 @@
* limitations under the License.
*/
+// Keep proto2 syntax because we require the distinction between fields that
+// are set and unset.
syntax = "proto2";
+option java_package = "com.android.aapt";
option optimize_for = LITE_RUNTIME;
package aapt.pb;
// A configuration description that wraps the binary form of the C++ class
// aapt::ConfigDescription, with an added product definition.
+// TODO(adamlesinski): Flesh this out to be represented in proto.
message ConfigDescription {
optional bytes data = 1;
optional string product = 2;
@@ -32,37 +36,17 @@
optional bytes data = 1;
}
+// The position of a declared entity within a file.
+message SourcePosition {
+ optional uint32 line_number = 1;
+ optional uint32 column_number = 2;
+}
+
// Developer friendly source file information for an entity in the resource table.
message Source {
// The index of the string path within the source string pool of a ResourceTable.
optional uint32 path_idx = 1;
-
- optional uint32 line_no = 2;
- optional uint32 col_no = 3;
-}
-
-// The top level message representing an external resource file (layout XML, PNG, etc).
-message CompiledFile {
- message Symbol {
- // The name of the symbol (in the form package:type/name).
- optional string resource_name = 1;
-
- // Line number in the file at which this symbol is defined. For debug use.
- optional uint32 line_no = 2;
- }
-
- // The name of the resource (in the form package:type/name).
- optional string resource_name = 1;
-
- // The configuration for which the resource is defined.
- optional ConfigDescription config = 2;
-
- // The filesystem path to where the source file originated.
- // Mainly used to display helpful error messages.
- optional string source_path = 3;
-
- // Any symbols this file auto-generates/exports (eg. @+id/foo in an XML file).
- repeated Symbol exported_symbols = 4;
+ optional SourcePosition position = 2;
}
// Top level message representing a resource table.
@@ -72,7 +56,7 @@
optional StringPool source_pool = 1;
// Resource definitions corresponding to an Android package.
- repeated Package packages = 2;
+ repeated Package package = 2;
}
// Defines resources for an Android package.
@@ -89,7 +73,7 @@
optional string package_name = 2;
// The series of types defined by the package.
- repeated Type types = 3;
+ repeated Type type = 3;
}
// A set of resources grouped under a common type. Such types include string, layout, xml, dimen,
@@ -103,7 +87,7 @@
optional string name = 2;
// The entries defined for this type.
- repeated Entry entries = 3;
+ repeated Entry entry = 3;
}
// The status of a symbol/entry. This contains information like visibility (public/private),
@@ -115,17 +99,17 @@
// The distinction is important when two separate R.java files are generated: a public and
// private one. An unknown visibility, in this case, would cause the resource to be omitted
// from either R.java.
- Unknown = 0;
+ UNKNOWN = 0;
// A resource was explicitly marked as private. This means the resource can not be accessed
// outside of its package unless the @*package:type/entry notation is used (the asterisk being
// the private accessor). If two R.java files are generated (private + public), the resource
// will only be emitted to the private R.java file.
- Private = 1;
+ PRIVATE = 1;
// A resource was explicitly marked as public. This means the resource can be accessed
// from any package, and is emitted into all R.java files, public and private.
- Public = 2;
+ PUBLIC = 2;
}
optional Visibility visibility = 1;
@@ -159,7 +143,7 @@
// The set of values defined for this entry, each corresponding to a different
// configuration/variant.
- repeated ConfigValue config_values = 4;
+ repeated ConfigValue config_value = 4;
}
// A Configuration/Value pair.
@@ -214,10 +198,10 @@
message Reference {
enum Type {
// A plain reference (@package:type/entry).
- Ref = 0;
+ REFERENCE = 0;
// A reference to a theme attribute (?package:type/entry).
- Attr = 1;
+ ATTRIBUTE = 1;
}
optional Type type = 1;
@@ -301,21 +285,38 @@
optional uint32 value = 4;
}
- // A bitmask of types that this XML attribute accepts. Corresponds to the flags in the C struct
- // android::ResTable_map.
+ // Bitmask of formats allowed for an attribute.
+ enum FormatFlags {
+ ANY = 0x0000ffff; // Allows any type except ENUM and FLAGS.
+ REFERENCE = 0x01; // Allows Reference values.
+ STRING = 0x02; // Allows String/StyledString values.
+ INTEGER = 0x04; // Allows any integer BinaryPrimitive values.
+ BOOLEAN = 0x08; // Allows any boolean BinaryPrimitive values.
+ COLOR = 0x010; // Allows any color BinaryPrimitive values.
+ FLOAT = 0x020; // Allows any float BinaryPrimitive values.
+ DIMENSION = 0x040; // Allows any dimension BinaryPrimitive values.
+ FRACTION = 0x080; // Allows any fraction BinaryPrimitive values.
+ ENUM = 0x00010000; // Allows enums that are defined in the Attribute's symbols.
+ // ENUM and FLAGS cannot BOTH be set.
+ FLAGS = 0x00020000; // Allows flags that are defined in the Attribute's symbols.
+ // ENUM and FLAGS cannot BOTH be set.
+ }
+
+ // A bitmask of types that this XML attribute accepts. Corresponds to the flags in the
+ // enum FormatFlags.
optional uint32 format_flags = 1;
// The smallest integer allowed for this XML attribute. Only makes sense if the format includes
- // TYPE_INTEGER.
+ // FormatFlags::INTEGER.
optional int32 min_int = 2;
// The largest integer allowed for this XML attribute. Only makes sense if the format includes
- // TYPE_INTEGER.
+ // FormatFlags::INTEGER.
optional int32 max_int = 3;
// The set of enums/flags defined in this attribute. Only makes sense if the format includes
- // either TYPE_ENUM or TYPE_FLAGS. Having both is an error.
- repeated Symbol symbols = 4;
+ // either FormatFlags::ENUM or FormatFlags::FLAGS. Having both is an error.
+ repeated Symbol symbol = 4;
}
// A value that represents a style.
@@ -342,7 +343,7 @@
optional Source parent_source = 2;
// The set of XML attribute/value pairs for this style.
- repeated Entry entries = 3;
+ repeated Entry entry = 3;
}
// A value that represents a <declare-styleable> XML resource. These are not real resources and
@@ -361,13 +362,13 @@
}
// The set of attribute declarations.
- repeated Entry entries = 1;
+ repeated Entry entry = 1;
}
// A value that represents an array of resource values.
message Array {
// A single element of the array.
- message Entry {
+ message Element {
// Where the element was defined.
optional Source source = 1;
@@ -379,19 +380,19 @@
}
// The list of array elements.
- repeated Entry entries = 1;
+ repeated Element element = 1;
}
// A value that represents a string and its many variations based on plurality.
message Plural {
// The arity of the plural.
enum Arity {
- Zero = 0;
- One = 1;
- Two = 2;
- Few = 3;
- Many = 4;
- Other = 5;
+ ZERO = 0;
+ ONE = 1;
+ TWO = 2;
+ FEW = 3;
+ MANY = 4;
+ OTHER = 5;
}
// The plural value for a given arity.
@@ -410,5 +411,61 @@
}
// The set of arity/plural mappings.
- repeated Entry entries = 1;
+ repeated Entry entry = 1;
+}
+
+// Defines an abstract XmlNode that must be either an XmlElement, or
+// a text node represented by a string.
+message XmlNode {
+ // If set, this node is an element/tag.
+ optional XmlElement element = 1;
+
+ // If set, this node is a chunk of text.
+ optional string text = 2;
+
+ // Source line and column info.
+ optional SourcePosition source = 3;
+}
+
+// An <element> in an XML document.
+message XmlElement {
+ // Namespaces defined on this element.
+ repeated XmlNamespace namespace_declaration = 1;
+
+ // The namespace URI of this element.
+ optional string namespace_uri = 2;
+
+ // The name of this element.
+ optional string name = 3;
+
+ // The attributes of this element.
+ repeated XmlAttribute attribute = 4;
+
+ // The children of this element.
+ repeated XmlNode child = 5;
+}
+
+// A namespace declaration on an XmlElement (xmlns:android="http://...").
+message XmlNamespace {
+ optional string prefix = 1;
+ optional string uri = 2;
+
+ // Source line and column info.
+ optional SourcePosition source = 3;
+}
+
+// An attribute defined on an XmlElement (android:text="...").
+message XmlAttribute {
+ optional string namespace_uri = 1;
+ optional string name = 2;
+ optional string value = 3;
+
+ // Source line and column info.
+ optional SourcePosition source = 4;
+
+ // The resource ID (0xPPTTEEEE) of the attribute.
+ optional uint32 resource_id = 5;
+
+ // The interpreted/compiled version of the `value` string.
+ optional Item compiled_item = 6;
}
diff --git a/tools/aapt2/ResourcesInternal.proto b/tools/aapt2/ResourcesInternal.proto
new file mode 100644
index 0000000..3117917
--- /dev/null
+++ b/tools/aapt2/ResourcesInternal.proto
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+option java_package = "android.aapt.pb.internal";
+option optimize_for = LITE_RUNTIME;
+
+import "frameworks/base/tools/aapt2/Resources.proto";
+
+package aapt.pb.internal;
+
+// The top level message representing an external resource file (layout XML, PNG, etc).
+// This is used to represent a compiled file before it is linked. Only useful to aapt2.
+message CompiledFile {
+ message Symbol {
+ // The name of the symbol (in the form package:type/name).
+ optional string resource_name = 1;
+
+ // The position in the file at which this symbol is defined. For debug use.
+ optional aapt.pb.SourcePosition source = 2;
+ }
+
+ // The name of the resource (in the form package:type/name).
+ optional string resource_name = 1;
+
+ // The configuration for which the resource is defined.
+ optional aapt.pb.ConfigDescription config = 2;
+
+ // The filesystem path to where the source file originated.
+ // Mainly used to display helpful error messages.
+ optional string source_path = 3;
+
+ // Any symbols this file auto-generates/exports (eg. @+id/foo in an XML file).
+ repeated Symbol exported_symbol = 4;
+
+ // If this is a compiled XML file, this is the root node.
+ optional aapt.pb.XmlNode xml_root = 5;
+}
diff --git a/tools/aapt2/ValueVisitor.h b/tools/aapt2/ValueVisitor.h
index 2763d49..eb4fa49 100644
--- a/tools/aapt2/ValueVisitor.h
+++ b/tools/aapt2/ValueVisitor.h
@@ -80,7 +80,7 @@
}
void VisitSubValues(Array* array) {
- for (std::unique_ptr<Item>& item : array->items) {
+ for (std::unique_ptr<Item>& item : array->elements) {
item->Accept(this);
}
}
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index 8536edb..7f5bbf0 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -282,7 +282,7 @@
// Number of CompiledFiles.
output_stream.WriteLittleEndian32(1);
- std::unique_ptr<pb::CompiledFile> compiled_file = SerializeCompiledFileToPb(file);
+ std::unique_ptr<pb::internal::CompiledFile> compiled_file = SerializeCompiledFileToPb(file);
output_stream.WriteCompiledFile(compiled_file.get());
output_stream.WriteData(&buffer);
@@ -319,7 +319,7 @@
// Number of CompiledFiles.
output_stream.WriteLittleEndian32(1);
- std::unique_ptr<pb::CompiledFile> compiled_file = SerializeCompiledFileToPb(file);
+ std::unique_ptr<pb::internal::CompiledFile> compiled_file = SerializeCompiledFileToPb(file);
output_stream.WriteCompiledFile(compiled_file.get());
output_stream.WriteData(map.getDataPtr(), map.getDataLength());
@@ -346,7 +346,8 @@
return false;
}
- std::unique_ptr<pb::CompiledFile> pb_compiled_file = SerializeCompiledFileToPb(xmlres->file);
+ std::unique_ptr<pb::internal::CompiledFile> pb_compiled_file =
+ SerializeCompiledFileToPb(xmlres->file);
out->WriteCompiledFile(pb_compiled_file.get());
out->WriteData(&buffer);
diff --git a/tools/aapt2/cmd/Dump.cpp b/tools/aapt2/cmd/Dump.cpp
index aa94723..0965910 100644
--- a/tools/aapt2/cmd/Dump.cpp
+++ b/tools/aapt2/cmd/Dump.cpp
@@ -27,11 +27,11 @@
#include "unflatten/BinaryResourceParser.h"
#include "util/Files.h"
-using android::StringPiece;
+using ::android::StringPiece;
namespace aapt {
-bool DumpCompiledFile(const pb::CompiledFile& pb_file, const void* data, size_t len,
+bool DumpCompiledFile(const pb::internal::CompiledFile& pb_file, const void* data, size_t len,
const Source& source, IAaptContext* context) {
std::unique_ptr<ResourceFile> file =
DeserializeCompiledFileFromPb(pb_file, source, context->GetDiagnostics());
@@ -118,7 +118,7 @@
}
for (uint32_t i = 0; i < num_files; i++) {
- pb::CompiledFile compiled_file;
+ pb::internal::CompiledFile compiled_file;
if (!input.ReadCompiledFile(&compiled_file)) {
context->GetDiagnostics()->Warn(DiagMessage() << "failed to read compiled file");
return false;
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index 35ab3c6..d4ff618 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -1295,7 +1295,7 @@
}
for (uint32_t i = 0; i < num_files; i++) {
- pb::CompiledFile compiled_file;
+ pb::internal::CompiledFile compiled_file;
if (!input_stream.ReadCompiledFile(&compiled_file)) {
context_->GetDiagnostics()->Error(DiagMessage(src)
<< "failed to read compiled file header");
diff --git a/tools/aapt2/flatten/TableFlattener.cpp b/tools/aapt2/flatten/TableFlattener.cpp
index e5993a6..14b776b 100644
--- a/tools/aapt2/flatten/TableFlattener.cpp
+++ b/tools/aapt2/flatten/TableFlattener.cpp
@@ -133,7 +133,7 @@
}
void Visit(Array* array) override {
- for (auto& item : array->items) {
+ for (auto& item : array->elements) {
ResTable_map* out_entry = buffer_->NextBlock<ResTable_map>();
FlattenValue(item.get(), out_entry);
out_entry->value.size = util::HostToDevice16(sizeof(out_entry->value));
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;
diff --git a/tools/aapt2/unflatten/BinaryResourceParser.cpp b/tools/aapt2/unflatten/BinaryResourceParser.cpp
index 728d1f4..892aee6 100644
--- a/tools/aapt2/unflatten/BinaryResourceParser.cpp
+++ b/tools/aapt2/unflatten/BinaryResourceParser.cpp
@@ -544,7 +544,7 @@
const ResTable_map_entry* map) {
std::unique_ptr<Array> array = util::make_unique<Array>();
for (const ResTable_map& map_entry : map) {
- array->items.push_back(ParseValue(name, config, map_entry.value));
+ array->elements.push_back(ParseValue(name, config, map_entry.value));
}
return array;
}