aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory/qv4heap_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-01-30 22:22:00 +0100
committerLars Knoll <lars.knoll@qt.io>2017-03-09 08:58:28 +0000
commit8b3cbc4403e3eac286613691c11aa1ded588da59 (patch)
tree48bc8592a69ce2585639f4e83258bb776c4f32ab /src/qml/memory/qv4heap_p.h
parent2fbb5c93c765ea53c3bd5f30b8bf769ccc88874a (diff)
Refactor how we define Heap objects
Declare the type of Heap object in the Member() macro, instead of deducing it from templates. This allows us to encode the offset of the member in the second template argument to Pointer<> in a second step. Change-Id: I2cfb73785749d3fb991689b4e0554a72b3e5e13f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/memory/qv4heap_p.h')
-rw-r--r--src/qml/memory/qv4heap_p.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/qml/memory/qv4heap_p.h b/src/qml/memory/qv4heap_p.h
index 28d39b7fb7..febe4e6446 100644
--- a/src/qml/memory/qv4heap_p.h
+++ b/src/qml/memory/qv4heap_p.h
@@ -164,19 +164,20 @@ struct Q_QML_EXPORT Base {
};
V4_ASSERT_IS_TRIVIAL(Base)
-template <typename T>
+template <typename T, size_t>
struct Pointer {
- T *operator->() const { return ptr; }
- operator T *() const { return ptr; }
+ T operator->() const { return ptr; }
+ operator T () const { return ptr; }
- Pointer &operator =(T *t) { ptr = t; return *this; }
+ Pointer &operator =(T t) { ptr = t; return *this; }
template <typename Type>
Type *cast() { return static_cast<Type *>(ptr); }
- T *ptr;
+ T ptr;
};
-V4_ASSERT_IS_TRIVIAL(Pointer<void>)
+typedef Pointer<char *, 0> V4PointerCheck;
+V4_ASSERT_IS_TRIVIAL(V4PointerCheck)
}