aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-19 09:10:42 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-22 01:06:20 +0200
commit332b870bd8f0fba6f09e539376a674d7a4413631 (patch)
treea3977c20b6331e1e6ab1d85e5e25836155797d0c
parentdf5edd28bc4258b89d9d5ffdddf837f339a17aad (diff)
Convert putIndexed()
Change-Id: I7d02b0fdf45079d0f7afcfb6d3158dd60cb09f33 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/particles/qquickcustomaffector.cpp3
-rw-r--r--src/particles/qquickparticleemitter.cpp3
-rw-r--r--src/particles/qquicktrailemitter.cpp3
-rw-r--r--src/qml/jsruntime/qv4global_p.h2
-rw-r--r--src/qml/jsruntime/qv4managed.cpp5
-rw-r--r--src/qml/jsruntime/qv4managed_p.h5
-rw-r--r--src/qml/jsruntime/qv4object.cpp12
-rw-r--r--src/qml/jsruntime/qv4object_p.h6
-rw-r--r--src/qml/jsruntime/qv4regexp.cpp2
-rw-r--r--src/qml/jsruntime/qv4regexp_p.h2
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp2
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp30
-rw-r--r--src/qml/jsruntime/qv4string.cpp2
-rw-r--r--src/qml/jsruntime/qv4string_p.h2
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp16
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp8
17 files changed, 61 insertions, 44 deletions
diff --git a/src/particles/qquickcustomaffector.cpp b/src/particles/qquickcustomaffector.cpp
index 09f8967045..583e3b6555 100644
--- a/src/particles/qquickcustomaffector.cpp
+++ b/src/particles/qquickcustomaffector.cpp
@@ -148,8 +148,9 @@ void QQuickCustomAffector::affectSystem(qreal dt)
QV4::Scope scope(v4);
QV4::Scoped<QV4::ArrayObject> array(scope, v4->newArrayObject(toAffect.size()));
+ QV4::ScopedValue v(scope);
for (int i=0; i<toAffect.size(); i++)
- array->putIndexed(i, toAffect[i]->v4Value().toValue());
+ array->putIndexed(i, (v = toAffect[i]->v4Value().toValue()));
if (dt >= simulationCutoff || dt <= simulationDelta) {
affectProperties(toAffect, dt);
diff --git a/src/particles/qquickparticleemitter.cpp b/src/particles/qquickparticleemitter.cpp
index 404554c9b6..d42c92304b 100644
--- a/src/particles/qquickparticleemitter.cpp
+++ b/src/particles/qquickparticleemitter.cpp
@@ -486,8 +486,9 @@ void QQuickParticleEmitter::emitWindow(int timeStamp)
//Done after emitParticle so that the Painter::load is done first, this allows you to customize its static variables
//We then don't need to request another reload, because the first reload isn't scheduled until we get back to the render thread
QV4::Scoped<QV4::ArrayObject> array(scope, v4->newArrayObject(toEmit.size()));
+ QV4::ScopedValue v(scope);
for (int i=0; i<toEmit.size(); i++)
- array->putIndexed(i, toEmit[i]->v4Value().toValue());
+ array->putIndexed(i, (v = toEmit[i]->v4Value().toValue()));
emitParticles(QQmlV4Handle(array.asValue()));//A chance for arbitrary JS changes
}
diff --git a/src/particles/qquicktrailemitter.cpp b/src/particles/qquicktrailemitter.cpp
index 84caebf5be..b78745f030 100644
--- a/src/particles/qquicktrailemitter.cpp
+++ b/src/particles/qquicktrailemitter.cpp
@@ -274,8 +274,9 @@ void QQuickTrailEmitter::emitWindow(int timeStamp)
QV4::Scope scope(v4);
QV4::Scoped<QV4::ArrayObject> array(scope, v4->newArrayObject(toEmit.size()));
+ QV4::ScopedValue v(scope);
for (int i=0; i<toEmit.size(); i++)
- array->putIndexed(i, toEmit[i]->v4Value().toValue());
+ array->putIndexed(i, (v = toEmit[i]->v4Value().toValue()));
if (isEmitFollowConnected())
emitFollowParticles(QQmlV4Handle(array.asValue()), d->v4Value());//A chance for many arbitrary JS changes
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h
index 9f963f345b..f0a5e30608 100644
--- a/src/qml/jsruntime/qv4global_p.h
+++ b/src/qml/jsruntime/qv4global_p.h
@@ -111,12 +111,14 @@ struct ValueRef;
template<typename T> struct Scoped;
typedef Scoped<String> ScopedString;
typedef Scoped<Object> ScopedObject;
+typedef Scoped<ArrayObject> ScopedArrayObject;
typedef Scoped<FunctionObject> ScopedFunctionObject;
template<typename T> struct Returned;
typedef Returned<String> ReturnedString;
typedef Returned<Object> ReturnedObject;
typedef Returned<FunctionObject> ReturnedFunctionObject;
template<typename T> struct Referenced;
+typedef Referenced<Managed> ManagedRef;
typedef Referenced<String> StringRef;
typedef Referenced<Object> ObjectRef;
typedef Referenced<FunctionObject> FunctionObjectRef;
diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp
index c469293f5e..7b0d4058a2 100644
--- a/src/qml/jsruntime/qv4managed.cpp
+++ b/src/qml/jsruntime/qv4managed.cpp
@@ -221,3 +221,8 @@ void Managed::setLookup(Lookup *l, const ValueRef v)
{
vtbl->setLookup(this, l, v);
}
+
+void Managed::putIndexed(uint index, const ValueRef value)
+{
+ vtbl->putIndexed(this, index, value);
+}
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 00ad52a9ef..c91b9453da 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -100,7 +100,7 @@ struct ManagedVTable
ReturnedValue (*get)(Managed *, const StringRef name, bool *hasProperty);
ReturnedValue (*getIndexed)(Managed *, uint index, bool *hasProperty);
void (*put)(Managed *, const StringRef name, const ValueRef value);
- void (*putIndexed)(Managed *, uint index, const Value &value);
+ void (*putIndexed)(Managed *, uint index, const ValueRef value);
PropertyAttributes (*query)(const Managed *, String *name);
PropertyAttributes (*queryIndexed)(const Managed *, uint index);
bool (*deleteProperty)(Managed *m, String *name);
@@ -266,8 +266,7 @@ public:
ReturnedValue get(const StringRef name, bool *hasProperty = 0);
ReturnedValue getIndexed(uint index, bool *hasProperty = 0);
void put(const StringRef name, const ValueRef value);
- void putIndexed(uint index, const Value &value)
- { vtbl->putIndexed(this, index, value); }
+ void putIndexed(uint index, const ValueRef value);
PropertyAttributes query(String *name) const
{ return vtbl->query(this, name); }
PropertyAttributes queryIndexed(uint index) const
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 44c248dd1a..2a36371bdd 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -472,7 +472,7 @@ void Object::put(Managed *m, const StringRef name, const ValueRef value)
static_cast<Object *>(m)->internalPut(name, value);
}
-void Object::putIndexed(Managed *m, uint index, const Value &value)
+void Object::putIndexed(Managed *m, uint index, const ValueRef value)
{
static_cast<Object *>(m)->internalPutIndexed(index, value);
}
@@ -723,7 +723,7 @@ void Object::internalPut(const StringRef name, const ValueRef value)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
- return putIndexed(idx, *value);
+ return putIndexed(idx, value);
name->makeIdentifier();
@@ -801,7 +801,7 @@ void Object::internalPut(const StringRef name, const ValueRef value)
}
}
-void Object::internalPutIndexed(uint index, const Value &value)
+void Object::internalPutIndexed(uint index, const ValueRef value)
{
Property *pd = 0;
PropertyAttributes attrs;
@@ -832,7 +832,7 @@ void Object::internalPutIndexed(uint index, const Value &value)
} else if (!attrs.isWritable())
goto reject;
else
- pd->value = value;
+ pd->value = *value;
return;
} else if (!prototype()) {
if (!extensible)
@@ -859,13 +859,13 @@ void Object::internalPutIndexed(uint index, const Value &value)
Scope scope(engine());
ScopedCallData callData(scope, 1);
- callData->args[0] = value;
+ callData->args[0] = *value;
callData->thisObject = Value::fromObject(this);
pd->setter()->call(callData);
return;
}
- arraySet(index, value);
+ arraySet(index, *value);
return;
reject:
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index dd75187cc2..99fbd8c94c 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -294,7 +294,7 @@ public:
{ return vtbl->getIndexed(this, idx, hasProperty); }
inline void put(const StringRef name, const ValueRef v)
{ vtbl->put(this, name, v); }
- inline void putIndexed(uint idx, const Value &v)
+ inline void putIndexed(uint idx, const ValueRef v)
{ vtbl->putIndexed(this, idx, v); }
using Managed::get;
using Managed::getIndexed;
@@ -313,7 +313,7 @@ protected:
static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
static void put(Managed *m, const StringRef name, const ValueRef value);
- static void putIndexed(Managed *m, uint index, const Value &value);
+ static void putIndexed(Managed *m, uint index, const ValueRef value);
static PropertyAttributes query(const Managed *m, String *name);
static PropertyAttributes queryIndexed(const Managed *m, uint index);
static bool deleteProperty(Managed *m, String *name);
@@ -327,7 +327,7 @@ private:
ReturnedValue internalGet(const StringRef name, bool *hasProperty);
ReturnedValue internalGetIndexed(uint index, bool *hasProperty);
void internalPut(const StringRef name, const ValueRef value);
- void internalPutIndexed(uint index, const Value &value);
+ void internalPutIndexed(uint index, const ValueRef value);
bool internalDeleteProperty(String *name);
bool internalDeleteIndexedProperty(uint index);
diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp
index 076bd72adf..ac7b122c4d 100644
--- a/src/qml/jsruntime/qv4regexp.cpp
+++ b/src/qml/jsruntime/qv4regexp.cpp
@@ -150,7 +150,7 @@ void RegExp::put(Managed *m, const StringRef name, const ValueRef value)
{
}
-void RegExp::putIndexed(Managed *m, uint index, const Value &value)
+void RegExp::putIndexed(Managed *m, uint index, const ValueRef value)
{
}
diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h
index 2600cac425..cbc60d9140 100644
--- a/src/qml/jsruntime/qv4regexp_p.h
+++ b/src/qml/jsruntime/qv4regexp_p.h
@@ -114,7 +114,7 @@ protected:
static ReturnedValue get(Managed *, const StringRef, bool *);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
static void put(Managed *m, const StringRef name, const ValueRef value);
- static void putIndexed(Managed *m, uint index, const Value &value);
+ static void putIndexed(Managed *m, uint index, const ValueRef value);
static PropertyAttributes query(const Managed *m, String *name);
static PropertyAttributes queryIndexed(const Managed *m, uint index);
static bool deleteProperty(Managed *, String *);
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 9ecb1bf103..63050c7c34 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -727,7 +727,7 @@ void __qmljs_set_element(ExecutionContext *ctx, const ValueRef object, const Val
return;
}
}
- o->putIndexed(idx, *value);
+ o->putIndexed(idx, value);
return;
}
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index 9b414b544d..f0a71a8318 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -134,31 +134,31 @@ static QString convertElementToString(bool element)
return QStringLiteral("false");
}
-template <typename ElementType> ElementType convertValueToElement(const QV4::Value &value);
+template <typename ElementType> ElementType convertValueToElement(const QV4::ValueRef value);
-template <> QString convertValueToElement(const QV4::Value &value)
+template <> QString convertValueToElement(const QV4::ValueRef value)
{
- return value.toQStringNoThrow();
+ return value->toQString();
}
-template <> int convertValueToElement(const QV4::Value &value)
+template <> int convertValueToElement(const QV4::ValueRef value)
{
- return value.toInt32();
+ return value->toInt32();
}
-template <> QUrl convertValueToElement(const QV4::Value &value)
+template <> QUrl convertValueToElement(const QV4::ValueRef value)
{
- return QUrl(value.toQStringNoThrow());
+ return QUrl(value->toQString());
}
-template <> qreal convertValueToElement(const QV4::Value &value)
+template <> qreal convertValueToElement(const QV4::ValueRef value)
{
- return value.toNumber();
+ return value->toNumber();
}
-template <> bool convertValueToElement(const QV4::Value &value)
+template <> bool convertValueToElement(const ValueRef value)
{
- return value.toBoolean();
+ return value->toBoolean();
}
template <typename Container>
@@ -223,7 +223,7 @@ public:
return QV4::Value::undefinedValue();
}
- void containerPutIndexed(uint index, const QV4::Value &value)
+ void containerPutIndexed(uint index, const QV4::ValueRef value)
{
/* Qt containers have int (rather than uint) allowable indexes. */
if (index > INT_MAX) {
@@ -455,10 +455,12 @@ public:
static QVariant toVariant(QV4::ArrayObject *array)
{
+ QV4::Scope scope(array->engine());
Container result;
quint32 length = array->arrayLength();
+ QV4::ScopedValue v(scope);
for (quint32 i = 0; i < length; ++i)
- result << convertValueToElement<typename Container::value_type>(QV4::Value::fromReturnedValue(array->getIndexed(i)));
+ result << convertValueToElement<typename Container::value_type>((v = array->getIndexed(i)));
return QVariant::fromValue(result);
}
@@ -488,7 +490,7 @@ private:
static QV4::ReturnedValue getIndexed(QV4::Managed *that, uint index, bool *hasProperty)
{ return static_cast<QQmlSequence<Container> *>(that)->containerGetIndexed(index, hasProperty).asReturnedValue(); }
- static void putIndexed(Managed *that, uint index, const QV4::Value &value)
+ static void putIndexed(Managed *that, uint index, const QV4::ValueRef value)
{ static_cast<QQmlSequence<Container> *>(that)->containerPutIndexed(index, value); }
static QV4::PropertyAttributes queryIndexed(const QV4::Managed *that, uint index)
{ return static_cast<const QQmlSequence<Container> *>(that)->containerQueryIndexed(index); }
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp
index 73e55a09dc..cff0d7a14f 100644
--- a/src/qml/jsruntime/qv4string.cpp
+++ b/src/qml/jsruntime/qv4string.cpp
@@ -181,7 +181,7 @@ void String::put(Managed *m, const StringRef name, const ValueRef value)
o->put(name, value);
}
-void String::putIndexed(Managed *m, uint index, const Value &value)
+void String::putIndexed(Managed *m, uint index, const ValueRef value)
{
Scope scope(m->engine());
String *that = static_cast<String *>(m);
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h
index 4289725cf9..5cfe0c4d25 100644
--- a/src/qml/jsruntime/qv4string_p.h
+++ b/src/qml/jsruntime/qv4string_p.h
@@ -130,7 +130,7 @@ protected:
static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
static void put(Managed *m, const StringRef name, const ValueRef value);
- static void putIndexed(Managed *m, uint index, const Value &value);
+ static void putIndexed(Managed *m, uint index, const ValueRef value);
static PropertyAttributes query(const Managed *m, String *name);
static PropertyAttributes queryIndexed(const Managed *m, uint index);
static bool deleteProperty(Managed *, String *);
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index e3a6621ab4..d70df5175b 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -73,9 +73,13 @@ void QQmlVMEVariantQObjectPtr::objectDestroyed(QObject *)
if (m_target && m_index >= 0) {
if (m_isVar && m_target->varPropertiesInitialized && !m_target->varProperties.isUndefined()) {
// Set the var property to NULL
- QV4::ArrayObject *a = m_target->varProperties.value().asArrayObject();
- if (a)
- a->putIndexed(m_index - m_target->firstVarPropertyIndex, QV4::Value::nullValue());
+ QV4::ExecutionEngine *v4 = m_target->varProperties.engine();
+ if (v4) {
+ QV4::Scope scope(v4);
+ QV4::ScopedArrayObject a(scope, m_target->varProperties.value().asArrayObject());
+ if (a)
+ a->putIndexed(m_index - m_target->firstVarPropertyIndex, QV4::ScopedValue(scope, QV4::Value::nullValue()));
+ }
}
m_target->activate(m_target->object, m_target->methodOffset() + m_index, 0);
@@ -1029,7 +1033,9 @@ void QQmlVMEMetaObject::writeVarProperty(int id, const QV4::Value &value)
QObject *valueObject = 0;
QQmlVMEVariantQObjectPtr *guard = getQObjectGuardForProperty(id);
- if (QV4::Object *o = value.asObject()) {
+ QV4::ScopedValue v(scope, value);
+ QV4::ScopedObject o(scope, v);
+ if (o) {
// And, if the new value is a scarce resource, we need to ensure that it does not get
// automatically released by the engine until no other references to it exist.
if (QV4::VariantObject *v = o->as<QV4::VariantObject>()) {
@@ -1051,7 +1057,7 @@ void QQmlVMEMetaObject::writeVarProperty(int id, const QV4::Value &value)
}
// Write the value and emit change signal as appropriate.
- varProperties.value().asObject()->putIndexed(id - firstVarPropertyIndex, value);
+ varProperties.value().asObject()->putIndexed(id - firstVarPropertyIndex, v);
activate(object, methodOffset() + id, 0);
}
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index c5cba16f48..a83b2d7ffd 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -959,7 +959,7 @@ ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx)
qmlerror->put((s = v4->newString("columnNumber")), (v = QV4::Value::fromInt32(error.column())));
qmlerror->put((s = v4->newString("fileName")), (v = Value::fromString(v4->newString(error.url().toString()))));
qmlerror->put((s = v4->newString("message")), (v = Value::fromString(v4->newString(error.description()))));
- qmlerrors->putIndexed(ii, qmlerror.asValue());
+ qmlerrors->putIndexed(ii, qmlerror);
}
Scoped<Object> errorObject(scope, v4->newErrorObject(Value::fromString(v4->newString(errorstr))));
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 2e0657d6c1..48456f8198 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -874,7 +874,7 @@ struct QQuickJSContext2DPixelData : public QV4::Object
static_cast<QQuickJSContext2DPixelData *>(that)->~QQuickJSContext2DPixelData();
}
static QV4::ReturnedValue getIndexed(QV4::Managed *m, uint index, bool *hasProperty);
- static void putIndexed(QV4::Managed *m, uint index, const QV4::Value &value);
+ static void putIndexed(QV4::Managed *m, uint index, const QV4::ValueRef value);
static QV4::ReturnedValue proto_get_length(QV4::SimpleCallContext *ctx);
@@ -3169,15 +3169,15 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint
return QV4::Encode::undefined();
}
-void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const QV4::Value &value)
+void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const QV4::ValueRef value)
{
QV4::ExecutionEngine *v4 = m->engine();
QV4::Scope scope(v4);
- QQuickJSContext2DPixelData *r = m->as<QQuickJSContext2DPixelData>();
+ QV4::Scoped<QQuickJSContext2DPixelData> r(scope, m->as<QQuickJSContext2DPixelData>());
if (!r)
m->engine()->current->throwTypeError();
- const int v = value.toInt32();
+ const int v = value->toInt32();
if (r && index < static_cast<quint32>(r->image.width() * r->image.height() * 4) && v >= 0 && v <= 255) {
const quint32 w = r->image.width();
const quint32 row = (index / 4) / w;