From 467f171315f9c2037fcd3eb5edcfabc40671bf7b Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Mon, 16 Nov 2015 17:35:44 -0800 Subject: AAPT2: Fail compiling when private symbols are referenced Also moved some XML specific stuff into its own directory, and refactored ReferenceLinker a bit. Change-Id: I912247a82023c1bbf72dc191fbdaf62858cbec0c --- tools/aapt2/ResourceValues.cpp | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'tools/aapt2/ResourceValues.cpp') diff --git a/tools/aapt2/ResourceValues.cpp b/tools/aapt2/ResourceValues.cpp index 8acff0d39019..5550f192d51a 100644 --- a/tools/aapt2/ResourceValues.cpp +++ b/tools/aapt2/ResourceValues.cpp @@ -71,27 +71,23 @@ Reference::Reference(const ResourceId& i, Type type) : id(i), referenceType(type } bool Reference::flatten(android::Res_value* outValue) const { - outValue->dataType = (referenceType == Reference::Type::kResource) - ? android::Res_value::TYPE_REFERENCE - : android::Res_value::TYPE_ATTRIBUTE; + outValue->dataType = (referenceType == Reference::Type::kResource) ? + android::Res_value::TYPE_REFERENCE : android::Res_value::TYPE_ATTRIBUTE; outValue->data = util::hostToDevice32(id ? id.value().id : 0); return true; } Reference* Reference::clone(StringPool* /*newPool*/) const { - Reference* ref = new Reference(); - ref->mComment = mComment; - ref->mSource = mSource; - ref->referenceType = referenceType; - ref->name = name; - ref->id = id; - return ref; + return new Reference(*this); } void Reference::print(std::ostream* out) const { *out << "(reference) "; if (referenceType == Reference::Type::kResource) { *out << "@"; + if (privateReference) { + *out << "*"; + } } else { *out << "?"; } @@ -116,10 +112,7 @@ bool Id::flatten(android::Res_value* out) const { } Id* Id::clone(StringPool* /*newPool*/) const { - Id* id = new Id(); - id->mComment = mComment; - id->mSource = mSource; - return id; + return new Id(*this); } void Id::print(std::ostream* out) const { @@ -214,10 +207,7 @@ bool BinaryPrimitive::flatten(android::Res_value* outValue) const { } BinaryPrimitive* BinaryPrimitive::clone(StringPool* /*newPool*/) const { - BinaryPrimitive* bp = new BinaryPrimitive(value); - bp->mComment = mComment; - bp->mSource = mSource; - return bp; + return new BinaryPrimitive(*this); } void BinaryPrimitive::print(std::ostream* out) const { @@ -255,12 +245,7 @@ bool Attribute::isWeak() const { } Attribute* Attribute::clone(StringPool* /*newPool*/) const { - Attribute* attr = new Attribute(weak); - attr->mComment = mComment; - attr->mSource = mSource; - attr->typeMask = typeMask; - std::copy(symbols.begin(), symbols.end(), std::back_inserter(attr->symbols)); - return attr; + return new Attribute(*this); } void Attribute::printMask(std::ostream* out) const { @@ -450,11 +435,7 @@ static ::std::ostream& operator<<(::std::ostream& out, const std::unique_ptrmComment = mComment; - styleable->mSource = mSource; - std::copy(entries.begin(), entries.end(), std::back_inserter(styleable->entries)); - return styleable; + return new Styleable(*this); } void Styleable::print(std::ostream* out) const { -- cgit v1.2.3-59-g8ed1b