aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-08-25 20:58:48 +0200
committerLars Knoll <lars.knoll@theqtcompany.com>2015-09-15 19:13:03 +0000
commit665f17782a984fa34934cb3fc6d8316a21da9862 (patch)
treef222f4e26a09b5a30af6a0c22f94ff482bca56e7 /src/qml/jsruntime
parent9ea6c69ab5e18cc4bb703f6d3572e7ddc87e34a5 (diff)
Simplify Object::getValue
Object::getValue only needs the value/property getter. Because of this it's enough to pass it the Value stored in the member/arrayData and the property attributes. Like this we avoid the reinterpret_cast to a Property pointer. Change-Id: Ib6873526f9db22ed0e607e3617be5729b15271ab Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp4
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp12
-rw-r--r--src/qml/jsruntime/qv4object.cpp16
-rw-r--r--src/qml/jsruntime/qv4object_p.h6
-rw-r--r--src/qml/jsruntime/qv4objectiterator.cpp4
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp2
6 files changed, 24 insertions, 20 deletions
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index da91db6aae..42b032f981 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -584,7 +584,7 @@ uint ArrayData::append(Object *obj, ArrayObject *otherObj, uint n)
ScopedValue v(scope);
for (const SparseArrayNode *it = os->sparse->begin();
it != os->sparse->end(); it = it->nextNode()) {
- v = otherObj->getValue(reinterpret_cast<Property *>(os->arrayData + it->value), other->d()->attrs[it->value]);
+ v = otherObj->getValue(os->arrayData[it->value], other->d()->attrs[it->value]);
obj->arraySet(oldSize + it->key(), v);
}
} else {
@@ -769,7 +769,7 @@ void ArrayData::sort(ExecutionEngine *engine, Object *thisObject, const Value &c
break;
PropertyAttributes a = sparse->attrs() ? sparse->attrs()[n->value] : Attr_Data;
- d->data(i) = thisObject->getValue(reinterpret_cast<Property *>(sparse->arrayData() + n->value), a);
+ d->data(i) = thisObject->getValue(sparse->arrayData()[n->value], a);
d->attrs[i] = a.isAccessor() ? Attr_Data : a;
n = n->nextNode();
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index cccc955202..0130a64187 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -53,7 +53,8 @@ ReturnedValue Lookup::lookup(const Value &thisObject, Object *o, PropertyAttribu
if (index != UINT_MAX) {
level = i;
*attrs = obj->internalClass->propertyData.at(index);
- return !attrs->isAccessor() ? obj->propertyData(index)->asReturnedValue() : Object::getValue(thisObject, obj->propertyAt(index), *attrs);
+ Value *v = obj->propertyData(index);
+ return !attrs->isAccessor() ? v->asReturnedValue() : Object::getValue(thisObject, *v, *attrs);
}
obj = obj->prototype;
@@ -65,7 +66,8 @@ ReturnedValue Lookup::lookup(const Value &thisObject, Object *o, PropertyAttribu
index = obj->internalClass->find(name);
if (index != UINT_MAX) {
*attrs = obj->internalClass->propertyData.at(index);
- return !attrs->isAccessor() ? obj->propertyData(index)->asReturnedValue() : Object::getValue(thisObject, obj->propertyAt(index), *attrs);
+ Value *v = obj->propertyData(index);
+ return !attrs->isAccessor() ? v->asReturnedValue() : Object::getValue(thisObject, *v, *attrs);
}
obj = obj->prototype;
@@ -86,7 +88,8 @@ ReturnedValue Lookup::lookup(const Object *thisObject, PropertyAttributes *attrs
if (index != UINT_MAX) {
level = i;
*attrs = obj->internalClass->propertyData.at(index);
- return !attrs->isAccessor() ? obj->propertyData(index)->asReturnedValue() : thisObject->getValue(obj->propertyAt(index), *attrs);
+ Value *v = obj->propertyData(index);
+ return !attrs->isAccessor() ? v->asReturnedValue() : thisObject->getValue(*v, *attrs);
}
obj = obj->prototype;
@@ -98,7 +101,8 @@ ReturnedValue Lookup::lookup(const Object *thisObject, PropertyAttributes *attrs
index = obj->internalClass->find(name);
if (index != UINT_MAX) {
*attrs = obj->internalClass->propertyData.at(index);
- return !attrs->isAccessor() ? obj->propertyData(index)->asReturnedValue() : thisObject->getValue(obj->propertyAt(index), *attrs);
+ Value *v = obj->propertyData(index);
+ return !attrs->isAccessor() ? v->asReturnedValue() : thisObject->getValue(*v, *attrs);
}
obj = obj->prototype;
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index d121b547ef..74e358b6a0 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -86,18 +86,18 @@ void Object::put(ExecutionEngine *engine, const QString &name, const Value &valu
put(n, value);
}
-ReturnedValue Object::getValue(const Value &thisObject, const Property *p, PropertyAttributes attrs)
+ReturnedValue Object::getValue(const Value &thisObject, const Value &v, PropertyAttributes attrs)
{
if (!attrs.isAccessor())
- return p->value.asReturnedValue();
- if (!p->getter())
+ return v.asReturnedValue();
+ const QV4::FunctionObject *f = v.as<FunctionObject>();
+ if (!f)
return Encode::undefined();
- Scope scope(p->getter()->internalClass->engine);
- ScopedFunctionObject getter(scope, p->getter());
+ Scope scope(f->engine());
ScopedCallData callData(scope);
callData->thisObject = thisObject;
- return getter->call(callData);
+ return f->call(callData);
}
void Object::putValue(uint memberIndex, const Value &value)
@@ -604,7 +604,7 @@ ReturnedValue Object::internalGet(String *name, bool *hasProperty) const
if (idx < UINT_MAX) {
if (hasProperty)
*hasProperty = true;
- return getValue(o->propertyAt(idx), o->internalClass()->propertyData.at(idx));
+ return getValue(*o->propertyData(idx), o->internalClass()->propertyData.at(idx));
}
o = o->prototype();
@@ -643,7 +643,7 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) const
if (pd) {
if (hasProperty)
*hasProperty = true;
- return getValue(pd, attrs);
+ return getValue(pd->value, attrs);
}
if (hasProperty)
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 2d82213ec0..2527e7953c 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -170,11 +170,11 @@ struct Q_QML_EXPORT Object: Managed {
//
void put(ExecutionEngine *engine, const QString &name, const Value &value);
- static ReturnedValue getValue(const Value &thisObject, const Property *p, PropertyAttributes attrs);
- ReturnedValue getValue(const Property *p, PropertyAttributes attrs) const {
+ static ReturnedValue getValue(const Value &thisObject, const Value &v, PropertyAttributes attrs);
+ ReturnedValue getValue(const Value &v, PropertyAttributes attrs) const {
Scope scope(this->engine());
ScopedValue t(scope, const_cast<Object *>(this));
- return getValue(t, p, attrs);
+ return getValue(t, v, attrs);
}
void putValue(uint memberIndex, const Value &value);
diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp
index 585f9f5c2e..7f97872092 100644
--- a/src/qml/jsruntime/qv4objectiterator.cpp
+++ b/src/qml/jsruntime/qv4objectiterator.cpp
@@ -144,7 +144,7 @@ ReturnedValue ObjectIterator::nextPropertyName(Value *value)
if (attrs.isEmpty())
return Encode::null();
- *value = object->objectValue()->getValue(p, attrs);
+ *value = object->objectValue()->getValue(p->value, attrs);
if (!!name)
return name->asReturnedValue();
@@ -166,7 +166,7 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString(Value *value)
if (attrs.isEmpty())
return Encode::null();
- *value = object->objectValue()->getValue(p, attrs);
+ *value = object->objectValue()->getValue(p->value, attrs);
if (!!name)
return name->asReturnedValue();
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index 5183cbf033..df7441ef5d 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -222,7 +222,7 @@ ReturnedValue ObjectPrototype::method_defineProperties(CallContext *ctx)
if (attrs.isEmpty())
break;
PropertyAttributes nattrs;
- val = o->getValue(pd, attrs);
+ val = o->getValue(pd->value, attrs);
toPropertyDescriptor(scope.engine, val, n, &nattrs);
if (scope.engine->hasException)
return Encode::undefined();