From 73bff1e8519bb73f17a801f45977d41b69b5b0d0 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Fri, 8 Dec 2017 16:06:10 -0800 Subject: AAPT2: Allow compatible duplicate Attributes If a resource XML file defines two compatible Attributes, they should be merged without throwing an error. Ex: In this case, string|reference and string are the same, so these should merge correctly. Bug: 65699599 Test: make aapt2_tests Test: make AaptBasicTest Change-Id: I7b0f956d2332f7f0b458acd59ca0a606b2cfdf95 --- tools/aapt2/ResourceValues.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tools/aapt2/ResourceValues.h') diff --git a/tools/aapt2/ResourceValues.h b/tools/aapt2/ResourceValues.h index b2ec8bdd7c77..6371c4cbb7b5 100644 --- a/tools/aapt2/ResourceValues.h +++ b/tools/aapt2/ResourceValues.h @@ -300,10 +300,15 @@ struct Attribute : public BaseValue { int32_t max_int; std::vector symbols; - Attribute(); - explicit Attribute(bool w, uint32_t t = 0u); + explicit Attribute(uint32_t t = 0u); bool Equals(const Value* value) const override; + + // Returns true if this Attribute's format is compatible with the given Attribute. The basic + // rule is that TYPE_REFERENCE can be ignored for both of the Attributes, and TYPE_FLAGS and + // TYPE_ENUMS are never compatible. + bool IsCompatibleWith(const Attribute& attr) const; + Attribute* Clone(StringPool* new_pool) const override; std::string MaskString() const; void Print(std::ostream* out) const override; -- cgit v1.2.3-59-g8ed1b