Add namespace handling in attribute values
Previously, you could only reference namespace prefixes in attribute names:
<View xmlns:appcompat="http://schemas.android.com/apk/res/android.support.v7.appcompat"
appcompat:name="hey"
...
Now you can also reference them in resource names within an attribute value:
...
android:text="@appcompat:string/confirm"
...
Which will be treated as "@android.support.v7.appcompat:string/confirm".
Change-Id: Ib076e867a990c80cf877a704eb77cd1ef0b23b52
diff --git a/tools/aapt2/Maybe_test.cpp b/tools/aapt2/Maybe_test.cpp
index 348d7dd..71bbb94 100644
--- a/tools/aapt2/Maybe_test.cpp
+++ b/tools/aapt2/Maybe_test.cpp
@@ -23,20 +23,64 @@
struct Dummy {
Dummy() {
- std::cerr << "Constructing Dummy " << (void *) this << std::endl;
+ data = new int;
+ *data = 1;
+ std::cerr << "Construct Dummy{0x" << (void *) this
+ << "} with data=0x" << (void*) data
+ << std::endl;
}
Dummy(const Dummy& rhs) {
- std::cerr << "Copying Dummy " << (void *) this << " from " << (const void*) &rhs << std::endl;
+ data = nullptr;
+ if (rhs.data) {
+ data = new int;
+ *data = *rhs.data;
+ }
+ std::cerr << "CopyConstruct Dummy{0x" << (void *) this
+ << "} from Dummy{0x" << (const void*) &rhs
+ << "}" << std::endl;
}
Dummy(Dummy&& rhs) {
- std::cerr << "Moving Dummy " << (void *) this << " from " << (void*) &rhs << std::endl;
+ data = rhs.data;
+ rhs.data = nullptr;
+ std::cerr << "MoveConstruct Dummy{0x" << (void *) this
+ << "} from Dummy{0x" << (const void*) &rhs
+ << "}" << std::endl;
+ }
+
+ Dummy& operator=(const Dummy& rhs) {
+ delete data;
+ data = nullptr;
+
+ if (rhs.data) {
+ data = new int;
+ *data = *rhs.data;
+ }
+ std::cerr << "CopyAssign Dummy{0x" << (void *) this
+ << "} from Dummy{0x" << (const void*) &rhs
+ << "}" << std::endl;
+ return *this;
+ }
+
+ Dummy& operator=(Dummy&& rhs) {
+ delete data;
+ data = rhs.data;
+ rhs.data = nullptr;
+ std::cerr << "MoveAssign Dummy{0x" << (void *) this
+ << "} from Dummy{0x" << (const void*) &rhs
+ << "}" << std::endl;
+ return *this;
}
~Dummy() {
- std::cerr << "Destroying Dummy " << (void *) this << std::endl;
+ std::cerr << "Destruct Dummy{0x" << (void *) this
+ << "} with data=0x" << (void*) data
+ << std::endl;
+ delete data;
}
+
+ int* data;
};
TEST(MaybeTest, MakeNothing) {
@@ -66,4 +110,12 @@
Maybe<Dummy> val2 = make_value(Dummy());
}
+TEST(MaybeTest, MoveAssign) {
+ Maybe<Dummy> val;
+ {
+ Maybe<Dummy> val2 = Dummy();
+ val = std::move(val2);
+ }
+}
+
} // namespace aapt