aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-02-12 21:03:53 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-03-02 16:34:09 +0000
commit69fe583cbebcbd593cb0cee266ffc8b0b647235c (patch)
tree2267cdff1f35304a7a61f1cca9dd4686c7e04fd2
parent9951ea5cab60f4bc23919d963abd595a1710cf54 (diff)
Introduce a Heap::Pointer class
This is required to properly mark pointers to other heap objects, as well as to have a single point where to implement a write barrier later on. Change-Id: I7d57044f1a306ca8da8183793635ed49a3637146 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/qml/jsruntime/qv4object_p.h2
-rw-r--r--src/qml/jsruntime/qv4value_p.h14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 71a997e133..a8bd97b7c1 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -55,7 +55,7 @@ struct Object : Base {
Property *propertyAt(uint index) { return reinterpret_cast<Property *>(memberData->data + index); }
InternalClass *internalClass;
- Heap::Object *prototype;
+ Pointer<Object> prototype;
MemberData *memberData;
ArrayData *arrayData;
};
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 5159ad8d68..93cbe9b52d 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -90,6 +90,20 @@ struct Q_QML_EXPORT Base {
void operator delete(void *, Heap::Base *) {}
};
+template <typename T>
+struct Pointer {
+ Pointer() {}
+ Pointer(T *t) : ptr(t) {}
+
+ T *operator->() const { return static_cast<T *>(ptr); }
+ operator T *() const { return static_cast<T *>(ptr); }
+
+ Pointer &operator =(T *t) { ptr = t; return *this; }
+
+ // Use Base, not T here, to ensure T inherits from ptr
+ Base *ptr;
+};
+
}
struct Q_QML_PRIVATE_EXPORT Value