diff options
Diffstat (limited to 'src/qml/qml/qqmldelayedcallqueue.cpp')
-rw-r--r-- | src/qml/qml/qqmldelayedcallqueue.cpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index 13e62ec696..61cb0a9065 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -42,6 +42,7 @@ #include <private/qqmlengine_p.h> #include <private/qqmljavascriptexpression_p.h> #include <private/qv4value_p.h> +#include <private/qv4jscall_p.h> #include <private/qv4qobjectwrapper_p.h> #include <QQmlError> @@ -63,17 +64,17 @@ void QQmlDelayedCallQueue::DelayedFunctionCall::execute(QV4::ExecutionEngine *en QV4::Scope scope(engine); QV4::ArrayObject *array = m_args.as<QV4::ArrayObject>(); + const QV4::FunctionObject *callback = m_function.as<QV4::FunctionObject>(); + Q_ASSERT(callback); const int argCount = array ? array->getLength() : 0; - QV4::ScopedCallData callData(scope, argCount); - callData->thisObject = QV4::Encode::undefined(); + QV4::JSCallData jsCallData(scope, argCount); + *jsCallData->thisObject = QV4::Encode::undefined(); for (int i = 0; i < argCount; i++) { - callData->args[i] = array->getIndexed(i); + jsCallData->args[i] = array->get(i); } - const QV4::FunctionObject *callback = m_function.as<QV4::FunctionObject>(); - Q_ASSERT(callback); - callback->call(scope, callData); + callback->call(jsCallData); if (scope.engine->hasException) { QQmlError error = scope.engine->catchExceptionAsQmlError(); @@ -88,7 +89,7 @@ void QQmlDelayedCallQueue::DelayedFunctionCall::execute(QV4::ExecutionEngine *en // QQmlDelayedCallQueue::QQmlDelayedCallQueue() - : QObject(0), m_engine(0), m_callbackOutstanding(false) + : QObject(nullptr), m_engine(nullptr), m_callbackOutstanding(false) { } @@ -105,17 +106,19 @@ void QQmlDelayedCallQueue::init(QV4::ExecutionEngine* engine) m_tickedMethod = metaObject.method(methodIndex); } -void QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) +QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc) { - if (callData->argc == 0) + QV4::Scope scope(b); + if (argc == 0) THROW_GENERIC_ERROR("Qt.callLater: no arguments given"); - const QV4::FunctionObject *func = callData->args[0].as<QV4::FunctionObject>(); + const QV4::FunctionObject *func = argv[0].as<QV4::FunctionObject>(); if (!func) THROW_GENERIC_ERROR("Qt.callLater: first argument not a function or signal"); QPair<QObject *, int> functionData = QV4::QObjectMethod::extractQtMethod(func); + QV4::ReturnedValue arg0 = argc ? argv[0].asReturnedValue() : QV4::Encode::undefined(); QVector<DelayedFunctionCall>::Iterator iter; if (functionData.second != -1) { @@ -134,7 +137,7 @@ void QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::BuiltinFunction iter = m_delayedFunctionCalls.begin(); while (iter != m_delayedFunctionCalls.end()) { DelayedFunctionCall& dfc = *iter; - if (callData->argument(0) == dfc.m_function.value()) { + if (arg0 == dfc.m_function.value()) { break; // Already stored! } ++iter; @@ -147,7 +150,7 @@ void QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::BuiltinFunction m_delayedFunctionCalls.erase(iter); m_delayedFunctionCalls.append(dfc); } else { - m_delayedFunctionCalls.append(QV4::PersistentValue(m_engine, callData->argument(0))); + m_delayedFunctionCalls.append(QV4::PersistentValue(m_engine, arg0)); } DelayedFunctionCall& dfc = m_delayedFunctionCalls.last(); @@ -158,33 +161,32 @@ void QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::BuiltinFunction dfc.m_guarded = true; } else if (func->scope()->type == QV4::Heap::ExecutionContext::Type_QmlContext) { QV4::QmlContext::Data *g = static_cast<QV4::QmlContext::Data *>(func->scope()); - Q_ASSERT(g->qml->scopeObject); - dfc.m_objectGuard = QQmlGuard<QObject>(g->qml->scopeObject); + Q_ASSERT(g->qml()->scopeObject); + dfc.m_objectGuard = QQmlGuard<QObject>(g->qml()->scopeObject); dfc.m_guarded = true; } } - storeAnyArguments(dfc, callData, 1, m_engine); + storeAnyArguments(dfc, argv, argc, 1, m_engine); if (!m_callbackOutstanding) { m_tickedMethod.invoke(this, Qt::QueuedConnection); m_callbackOutstanding = true; } - scope.result = QV4::Encode::undefined(); + return QV4::Encode::undefined(); } -void QQmlDelayedCallQueue::storeAnyArguments(DelayedFunctionCall &dfc, const QV4::CallData *callData, int offset, QV4::ExecutionEngine *engine) +void QQmlDelayedCallQueue::storeAnyArguments(DelayedFunctionCall &dfc, const QV4::Value *argv, int argc, int offset, QV4::ExecutionEngine *engine) { - const int length = callData->argc - offset; + const int length = argc - offset; if (length == 0) { dfc.m_args.clear(); return; } QV4::Scope scope(engine); QV4::ScopedArrayObject array(scope, engine->newArrayObject(length)); - int i = 0; - for (int j = offset; j < callData->argc; ++i, ++j) { - array->putIndexed(i, callData->args[j]); - } + uint i = 0; + for (int j = offset, ej = argc; j < ej; ++i, ++j) + array->put(i, argv[j]); dfc.m_args.set(engine, array); } |