aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-05 13:22:23 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-11 13:01:50 +0200
commit6e8e5d16e16d6ee683a5c06a24f8f202ed5239ff (patch)
treefa8e710ad0ee4ff6cc9738fa717883c74d452b95 /src/qml/qml
parent736afb8e9b3694efb8ca1fa8f3a8eeeaef530da2 (diff)
Move CallData onto the JS stack
Change-Id: I22e853acfd2da337344b581bb0412c5f9930c510 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp41
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp13
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp9
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp7
-rw-r--r--src/qml/qml/v8/qv8engine.cpp9
-rw-r--r--src/qml/qml/v8/qv8engine_p.h4
6 files changed, 43 insertions, 40 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 5f3a2e971c..a1399b4f43 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -62,6 +62,7 @@
#include <private/qv4functionobject_p.h>
#include <private/qv4script_p.h>
+#include <private/qv4scopedvalue_p.h>
#include <QStack>
#include <QStringList>
@@ -1224,12 +1225,12 @@ void QQmlComponent::createObject(QQmlV4Function *args)
if (!valuemap.isEmpty()) {
QQmlComponentExtension *e = componentExtension(v8engine);
- QV4::Value f = QV4::Script::evaluate(QV8Engine::getV4(v8engine), QString::fromLatin1(INITIALPROPERTIES_SOURCE), args->qmlGlobal().asObject());
- CALLDATA(2);
- d.thisObject = QV4::Value::fromObject(v4engine->globalObject);
- d.args[0] = object;
- d.args[1] = valuemap;
- f.asFunctionObject()->call(d);
+ QV4::Value f = QV4::Script::evaluate(v4engine, QString::fromLatin1(INITIALPROPERTIES_SOURCE), args->qmlGlobal().asObject());
+ QV4::ScopedCallData callData(v4engine, 2);
+ callData->thisObject = QV4::Value::fromObject(v4engine->globalObject);
+ callData->args[0] = object;
+ callData->args[1] = valuemap;
+ f.asFunctionObject()->call(callData);
}
d->completeCreate();
@@ -1372,11 +1373,11 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::Valu
if (!valuemap.isEmpty()) {
QQmlComponentExtension *e = componentExtension(v8engine);
QV4::Value f = QV4::Script::evaluate(QV8Engine::getV4(v8engine), QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobal.asObject());
- CALLDATA(2);
- d.thisObject = QV4::Value::fromObject(v4engine->globalObject);
- d.args[0] = object;
- d.args[1] = valuemap;
- f.asFunctionObject()->call(d);
+ QV4::ScopedCallData callData(v4engine, 2);
+ callData->thisObject = QV4::Value::fromObject(v4engine->globalObject);
+ callData->args[0] = object;
+ callData->args[1] = valuemap;
+ f.asFunctionObject()->call(callData);
}
}
@@ -1471,11 +1472,11 @@ void QmlIncubatorObject::setInitialState(QObject *o)
QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8);
QV4::Value f = QV4::Script::evaluate(v4, QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobal.asObject());
- CALLDATA(2);
- d.thisObject = QV4::Value::fromObject(v4->globalObject);
- d.args[0] = QV4::QObjectWrapper::wrap(v4, o);
- d.args[1] = valuemap;
- f.asFunctionObject()->call(d);
+ QV4::ScopedCallData callData(v4, 2);
+ callData->thisObject = QV4::Value::fromObject(v4->globalObject);
+ callData->args[0] = QV4::QObjectWrapper::wrap(v4, o);
+ callData->args[1] = valuemap;
+ f.asFunctionObject()->call(callData);
}
}
@@ -1508,10 +1509,10 @@ void QmlIncubatorObject::statusChanged(Status s)
if (QV4::FunctionObject *f = callback.asFunctionObject()) {
QV4::ExecutionContext *ctx = f->engine()->current;
try {
- CALLDATA(1);
- d.thisObject = QV4::Value::fromObject(this);
- d.args[0] = QV4::Value::fromUInt32(s);
- f->call(d);
+ QV4::ScopedCallData callData(ctx->engine, 1);
+ callData->thisObject = QV4::Value::fromObject(this);
+ callData->args[0] = QV4::Value::fromUInt32(s);
+ f->call(callData);
} catch (QV4::Exception &e) {
e.accept(ctx);
QQmlError error;
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 41be44a0a7..2974bbcfbe 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -47,6 +47,7 @@
#include <private/qv4functionobject_p.h>
#include <private/qv4script_p.h>
#include <private/qv4errorobject_p.h>
+#include <private/qv4scopedvalue_p.h>
QT_BEGIN_NAMESPACE
@@ -125,8 +126,7 @@ QV4::Value
QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
const QV4::Value &function, bool *isUndefined)
{
- QV4::Value args[QV4::Global::ReservedArgumentCount];
- return evaluate(context, function, 0, args, isUndefined);
+ return evaluate(context, function, 0, 0, isUndefined);
}
QV4::Value
@@ -173,11 +173,10 @@ QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
This = value;
}
- QV4::CallData d;
- d.thisObject = This;
- d.args = args;
- d.argc = argc;
- result = function.asFunctionObject()->call(d);
+ QV4::ScopedCallData callData(v4, argc);
+ callData->thisObject = This;
+ memcpy(callData->args, args, argc*sizeof(QV4::Value));
+ result = function.asFunctionObject()->call(callData);
if (isUndefined)
*isUndefined = result.isUndefined();
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 3d2d54ccfa..0079b9580f 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -55,6 +55,7 @@
#include <private/qv4object_p.h>
#include <private/qv4variantobject_p.h>
#include <private/qv4functionobject_p.h>
+#include <private/qv4scopedvalue_p.h>
QT_BEGIN_NAMESPACE
@@ -926,16 +927,16 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
QQmlVMEMetaData::MethodData *data = metaData->methodData() + id;
- CALLDATA(data->parameterCount);
- d.thisObject = ep->v8engine()->global();
+ QV4::ScopedCallData callData(function->engine(), data->parameterCount);
+ callData->thisObject = ep->v8engine()->global();
for (int ii = 0; ii < data->parameterCount; ++ii)
- d.args[ii] = ep->v8engine()->fromVariant(*(QVariant *)a[ii + 1]);
+ callData->args[ii] = ep->v8engine()->fromVariant(*(QVariant *)a[ii + 1]);
QV4::Value result = QV4::Value::undefinedValue();
QV4::ExecutionContext *ctx = function->engine()->current;
try {
- result = function->call(d);
+ result = function->call(callData);
if (a[0]) *(QVariant *)a[0] = ep->v8engine()->toVariant(result, 0);
} catch (QV4::Exception &e) {
e.accept(ctx);
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 211383ae58..8e7fa43667 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -53,6 +53,7 @@
#include <private/qv4engine_p.h>
#include <private/qv4functionobject_p.h>
#include <private/qqmlcontextwrapper_p.h>
+#include <private/qv4scopedvalue_p.h>
#include <QtCore/qobject.h>
#include <QtQml/qjsvalue.h>
@@ -1481,9 +1482,9 @@ void QQmlXMLHttpRequest::dispatchCallback(const Value &me)
QQmlContextData *callingContext = QmlContextWrapper::getContext(activationObject);
if (callingContext) {
- CALLDATA(0);
- d.thisObject = activationObject;
- callback->call(d);
+ QV4::ScopedCallData callData(v4, 0);
+ callData->thisObject = activationObject;
+ callback->call(callData);
}
// if the callingContext object is no longer valid, then it has been
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index 6737c14b17..5b43dd6192 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -57,6 +57,7 @@
#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmlvaluetypewrapper_p.h>
#include <private/qqmllistwrapper_p.h>
+#include <private/qv4scopedvalue_p.h>
#include "qv4domerrors_p.h"
#include "qv4sqlerrors_p.h"
@@ -442,10 +443,10 @@ void QV8Engine::initializeGlobal()
void QV8Engine::freezeObject(const QV4::Value &value)
{
- CALLDATA(1);
- d.args[0] = value;
- d.thisObject = QV4::Value::fromObject(m_v4Engine->globalObject);
- m_freezeObject.value().asFunctionObject()->call(d);
+ QV4::ScopedCallData callData(m_v4Engine, 1);
+ callData->args[0] = value;
+ callData->thisObject = QV4::Value::fromObject(m_v4Engine->globalObject);
+ m_freezeObject.value().asFunctionObject()->call(callData);
}
void QV8Engine::gc()
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 9c486d9809..8f724fa2eb 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -136,13 +136,13 @@ private:
QQmlV4Function(const QQmlV4Function &);
QQmlV4Function &operator=(const QQmlV4Function &);
- QQmlV4Function(int length, QV4::Value *args,
+ QQmlV4Function(int length, const QV4::Value *args,
QV4::Value *rv, const QV4::Value &global,
QQmlContextData *c, QV8Engine *e)
: argc(length), args(args), retVal(rv), global(global), ctx(c), e(e) {}
int argc;
- QV4::Value *args;
+ const QV4::Value *args;
QV4::Value *retVal;
QV4::Value global;
QQmlContextData *ctx;