Loading tools/aapt2/Android.bp +2 −1 Original line number Diff line number Diff line Loading @@ -143,7 +143,8 @@ cc_library_host_static { "xml/XmlDom.cpp", "xml/XmlPullParser.cpp", "xml/XmlUtil.cpp", "Format.proto", "Resources.proto", "ResourcesInternal.proto", ], proto: { export_proto_headers: true, Loading tools/aapt2/ResourceParser.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -1219,7 +1219,7 @@ bool ResourceParser::ParseArrayImpl(xml::XmlPullParser* parser, 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())) Loading tools/aapt2/ResourceParser_test.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -540,11 +540,11 @@ TEST_F(ResourceParserTest, ParseArray) { 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) { Loading @@ -565,9 +565,9 @@ TEST_F(ResourceParserTest, ParseArrayWithFormat) { 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")); } Loading tools/aapt2/ResourceValues.cpp +6 −7 Original line number Diff line number Diff line Loading @@ -805,13 +805,12 @@ bool Array::Equals(const Value* value) const { 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()); }); } Loading @@ -820,14 +819,14 @@ Array* Array::Clone(StringPool* new_pool) const { 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 { Loading tools/aapt2/ResourceValues.h +1 −1 Original line number Diff line number Diff line Loading @@ -292,7 +292,7 @@ struct Style : public BaseValue<Style> { }; 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; Loading Loading
tools/aapt2/Android.bp +2 −1 Original line number Diff line number Diff line Loading @@ -143,7 +143,8 @@ cc_library_host_static { "xml/XmlDom.cpp", "xml/XmlPullParser.cpp", "xml/XmlUtil.cpp", "Format.proto", "Resources.proto", "ResourcesInternal.proto", ], proto: { export_proto_headers: true, Loading
tools/aapt2/ResourceParser.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -1219,7 +1219,7 @@ bool ResourceParser::ParseArrayImpl(xml::XmlPullParser* parser, 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())) Loading
tools/aapt2/ResourceParser_test.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -540,11 +540,11 @@ TEST_F(ResourceParserTest, ParseArray) { 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) { Loading @@ -565,9 +565,9 @@ TEST_F(ResourceParserTest, ParseArrayWithFormat) { 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")); } Loading
tools/aapt2/ResourceValues.cpp +6 −7 Original line number Diff line number Diff line Loading @@ -805,13 +805,12 @@ bool Array::Equals(const Value* value) const { 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()); }); } Loading @@ -820,14 +819,14 @@ Array* Array::Clone(StringPool* new_pool) const { 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 { Loading
tools/aapt2/ResourceValues.h +1 −1 Original line number Diff line number Diff line Loading @@ -292,7 +292,7 @@ struct Style : public BaseValue<Style> { }; 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; Loading