aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arraydata_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/jsruntime/qv4arraydata_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/jsruntime/qv4arraydata_p.h')
-rw-r--r--src/qml/jsruntime/qv4arraydata_p.h33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h
index 882f8d1f8d..1ede463d6d 100644
--- a/src/qml/jsruntime/qv4arraydata_p.h
+++ b/src/qml/jsruntime/qv4arraydata_p.h
@@ -90,28 +90,19 @@ struct ArrayVTable
namespace Heap {
-struct ArrayDataData {
- enum Type {
- Simple = 0,
- Complex = 1,
- Sparse = 2,
- Custom = 3
- };
-
- Type type;
- uint offset;
- PropertyAttributes *attrs;
- ReturnedValue freeList;
- SparseArray *sparse;
- ValueArray values;
-};
-static Q_CONSTEXPR quint64 ArrayData_markTable = \
- (MarkFlagsForType<decltype(ArrayDataData::values)>::markFlags << (offsetof(ArrayDataData, values) >> 2)) \
- << (sizeof(Base) >> 2) | QV4::Heap::Base::markTable;
-
-struct ArrayData : public Base, ArrayDataData {
+#define ArrayDataMembers(class, Member) \
+ Member(class, NoMark, uint, type) \
+ Member(class, NoMark, uint, offset) \
+ Member(class, NoMark, PropertyAttributes *, attrs) \
+ Member(class, NoMark, ReturnedValue, freeList) \
+ Member(class, NoMark, SparseArray *, sparse) \
+ Member(class, ValueArray, ValueArray, values)
+
+DECLARE_HEAP_OBJECT(ArrayData, Base) {
DECLARE_MARK_TABLE(ArrayData);
+ enum Type { Simple = 0, Complex = 1, Sparse = 2, Custom = 3 };
+
bool isSparse() const { return type == Sparse; }
const ArrayVTable *vtable() const { return reinterpret_cast<const ArrayVTable *>(Base::vtable()); }
@@ -197,7 +188,7 @@ struct Q_QML_EXPORT ArrayData : public Managed
uint alloc() const { return d()->values.alloc; }
uint &alloc() { return d()->values.alloc; }
void setAlloc(uint a) { d()->values.alloc = a; }
- Type type() const { return d()->type; }
+ Type type() const { return static_cast<Type>(d()->type); }
void setType(Type t) { d()->type = t; }
PropertyAttributes *attrs() const { return d()->attrs; }
void setAttrs(PropertyAttributes *a) { d()->attrs = a; }