diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-04-06 20:01:17 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-02 14:18:15 +0000 |
commit | 1941e4587bf6b38e2a8a1875329ed75b829b617f (patch) | |
tree | 92a7bc19a64d8e41cfc677161dda1d72eb212b1a /src/qml/jsruntime/qv4arraydata_p.h | |
parent | e4a2b2885d1847624dcbc6b9e4dfdedf04767fe3 (diff) |
Unify MemberData::Index and ArrayData::Index
Both classes basically did the same thing. Unify them in a new
PropertyIndex class.
Change-Id: Ieb6fb670e4d204bf20ee4c0b70b4381c95c6268e
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.h | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index 613c3b2b50..887b8f283f 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -103,18 +103,6 @@ DECLARE_HEAP_OBJECT(ArrayData, Base) { enum Type { Simple = 0, Complex = 1, Sparse = 2, Custom = 3 }; - struct Index { - Heap::ArrayData *arrayData; - uint index; - - void set(EngineBase *e, Value newVal) { - arrayData->values.set(e, index, newVal); - } - const Value *operator->() const { return &arrayData->values[index]; } - const Value &operator*() const { return arrayData->values[index]; } - bool isNull() const { return !arrayData; } - }; - bool isSparse() const { return type == Sparse; } const ArrayVTable *vtable() const { return reinterpret_cast<const ArrayVTable *>(internalClass->vtable); } @@ -124,7 +112,7 @@ DECLARE_HEAP_OBJECT(ArrayData, Base) { } inline bool getProperty(uint index, Property *p, PropertyAttributes *attrs); inline void setProperty(EngineBase *e, uint index, const Property *p); - inline Index getValueOrSetter(uint index, PropertyAttributes *attrs); + inline PropertyIndex getValueOrSetter(uint index, PropertyAttributes *attrs); inline PropertyAttributes attributes(uint i) const; bool isEmpty(uint i) const { @@ -189,8 +177,6 @@ struct Q_QML_EXPORT ArrayData : public Managed IsArrayData = true }; - typedef Heap::ArrayData::Index Index; - uint alloc() const { return d()->values.alloc; } uint &alloc() { return d()->values.alloc; } void setAlloc(uint a) { d()->values.alloc = a; } @@ -305,9 +291,9 @@ bool ArrayData::getProperty(uint index, Property *p, PropertyAttributes *attrs) *attrs = attributes(index); if (p) { - p->value = *(Index{ this, mapped }); + p->value = *(PropertyIndex{ this, values.values + mapped }); if (attrs->isAccessor()) - p->set = *(Index{ this, mapped + 1 /*Object::SetterOffset*/ }); + p->set = *(PropertyIndex{ this, values.values + mapped + 1 /*Object::SetterOffset*/ }); } return true; } @@ -328,16 +314,18 @@ inline PropertyAttributes ArrayData::attributes(uint i) const return static_cast<const SimpleArrayData *>(this)->attributes(i); } -ArrayData::Index ArrayData::getValueOrSetter(uint index, PropertyAttributes *attrs) +PropertyIndex ArrayData::getValueOrSetter(uint index, PropertyAttributes *attrs) { uint idx = mappedIndex(index); if (idx == UINT_MAX) { *attrs = Attr_Invalid; - return { nullptr, 0 }; + return { nullptr, nullptr }; } *attrs = attributes(index); - return { this, attrs->isAccessor() ? idx + 1 /* QV4::Object::SetterOffset*/ : idx }; + if (attrs->isAccessor()) + ++idx; + return { this, values.values + idx }; } |