diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-02-03 14:55:22 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-03-09 08:58:43 +0000 |
commit | ae92e34a0c3e8a2df88a854081678fa35c4f6b42 (patch) | |
tree | ad79eb85d4c81b14af8073191b7c1d00c96bc88c /src/qml/jsruntime/qv4arraydata_p.h | |
parent | 38c9bc6b9f5f019f55896369c3b46c77fc29fb41 (diff) |
Get rid of methods returning a pointer to a Property structure
Those are unsafe to use when we introduce write barriers.
Change-Id: I686b3544437fc344d14f3561173521600ecb77a0
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 | 56 |
1 files changed, 17 insertions, 39 deletions
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index 71ed96a9a5..65cf69f6cd 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -122,9 +122,8 @@ DECLARE_HEAP_OBJECT(ArrayData, Base) { inline ReturnedValue get(uint i) const { return vtable()->get(this, i); } - inline void getProperty(uint index, Property *p, PropertyAttributes *attrs); - inline void setProperty(uint index, const Property *p); - inline Property *getProperty(uint index); + inline bool getProperty(uint index, Property *p, PropertyAttributes *attrs); + inline void setProperty(ExecutionEngine *e, uint index, const Property *p); inline Index getValueOrSetter(uint index, PropertyAttributes *attrs); inline PropertyAttributes attributes(uint i) const; @@ -145,15 +144,6 @@ struct SimpleArrayData : public ArrayData { Value data(uint index) const { return values[mappedIndex(index)]; } Value &data(uint index) { return values[mappedIndex(index)]; } - Property *getProperty(uint index) { - if (index >= values.size) - return 0; - index = mappedIndex(index); - if (values[index].isEmpty()) - return 0; - return reinterpret_cast<Property *>(values.v + index); - } - PropertyAttributes attributes(uint i) const { return attrs ? attrs[i] : Attr_Data; } @@ -173,13 +163,6 @@ struct SparseArrayData : public ArrayData { return n->value; } - Property *getProperty(uint index) { - SparseArrayNode *n = sparse->findNode(index); - if (!n) - return 0; - return reinterpret_cast<Property *>(values.v + n->value); - } - PropertyAttributes attributes(uint i) const { if (!attrs) return Attr_Data; @@ -231,9 +214,6 @@ struct Q_QML_EXPORT ArrayData : public Managed ReturnedValue get(uint i) const { return d()->get(i); } - inline Property *getProperty(uint index) { - return d()->getProperty(index); - } static void ensureAttributes(Object *o); static void realloc(Object *o, Type newType, uint alloc, bool enforceAttributes); @@ -306,30 +286,28 @@ inline uint ArrayData::mappedIndex(uint index) const return values[idx].isEmpty() ? UINT_MAX : idx; } -void ArrayData::getProperty(uint index, Property *p, PropertyAttributes *attrs) +bool ArrayData::getProperty(uint index, Property *p, PropertyAttributes *attrs) { - Property *pd = getProperty(index); - Q_ASSERT(pd); + uint mapped = mappedIndex(index); + if (mapped == UINT_MAX) { + *attrs = Attr_Invalid; + return false; + } + *attrs = attributes(index); - p->value = pd->value; + p->value = *(Index{ this, mapped }); if (attrs->isAccessor()) - p->set = pd->set; + p->set = *(Index{ this, mapped + 1 /*Object::SetterOffset*/ }); + return true; } -void ArrayData::setProperty(uint index, const Property *p) +void ArrayData::setProperty(QV4::ExecutionEngine *e, uint index, const Property *p) { - Property *pd = getProperty(index); - Q_ASSERT(pd); - pd->value = p->value; + uint mapped = mappedIndex(index); + Q_ASSERT(mapped != UINT_MAX); + values.set(e, mapped, p->value); if (attributes(index).isAccessor()) - pd->set = p->set; -} - -inline Property *ArrayData::getProperty(uint index) -{ - if (isSparse()) - return static_cast<SparseArrayData *>(this)->getProperty(index); - return static_cast<SimpleArrayData *>(this)->getProperty(index); + values.set(e, mapped + 1 /*QV4::Object::SetterOffset*/, p->set); } inline PropertyAttributes ArrayData::attributes(uint i) const |