diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-12-05 10:45:14 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-01-12 07:04:27 +0000 |
commit | 4e1512baf6d1220c9e89c8a36f16de400bb1b519 (patch) | |
tree | a4edebfeeebfd19e0aba8e376ddf593783f05100 /src/qml/qml | |
parent | 4d6830546619d16275b01f1f049fdcb0b6489f7a (diff) |
Convert more builtin functions to use the new calling convention
Convert most of the methods used QML objects to the new calling
convention. Converted IndexedBuiltinFunction to do the same.
Change-Id: I41b26042c2f56f24988485b06e8ccd214e2573c0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 34 | ||||
-rw-r--r-- | src/qml/qml/qqmldelayedcallqueue.cpp | 21 | ||||
-rw-r--r-- | src/qml/qml/qqmldelayedcallqueue_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmllistwrapper.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmllistwrapper_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper.cpp | 15 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 2 |
9 files changed, 46 insertions, 46 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 5a03f2dd93..e3dc3be81e 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1111,11 +1111,11 @@ struct QmlIncubatorObject : public QV4::Object V4_OBJECT2(QmlIncubatorObject, Object) V4_NEEDS_DESTROY - static ReturnedValue method_get_statusChanged(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_set_statusChanged(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_get_status(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_get_object(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_forceCompletion(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_get_statusChanged(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_set_statusChanged(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_status(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_object(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_forceCompletion(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); void statusChanged(QQmlIncubator::Status); void setInitialState(QObject *); @@ -1460,20 +1460,20 @@ QQmlComponentExtension::QQmlComponentExtension(QV4::ExecutionEngine *v4) incubationProto.set(v4, proto); } -QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_object(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_object(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QmlIncubatorObject> o(scope, callData->thisObject.as<QmlIncubatorObject>()); + QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>()); if (!o) THROW_TYPE_ERROR(); return QV4::QObjectWrapper::wrap(scope.engine, o->d()->incubator->object()); } -QV4::ReturnedValue QV4::QmlIncubatorObject::method_forceCompletion(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_forceCompletion(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QmlIncubatorObject> o(scope, callData->thisObject.as<QmlIncubatorObject>()); + QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>()); if (!o) THROW_TYPE_ERROR(); @@ -1482,34 +1482,34 @@ QV4::ReturnedValue QV4::QmlIncubatorObject::method_forceCompletion(const Builtin RETURN_UNDEFINED(); } -QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_status(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_status(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QmlIncubatorObject> o(scope, callData->thisObject.as<QmlIncubatorObject>()); + QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>()); if (!o) THROW_TYPE_ERROR(); return QV4::Encode(o->d()->incubator->status()); } -QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_statusChanged(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_statusChanged(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QmlIncubatorObject> o(scope, callData->thisObject.as<QmlIncubatorObject>()); + QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>()); if (!o) THROW_TYPE_ERROR(); return QV4::Encode(o->d()->statusChanged); } -QV4::ReturnedValue QV4::QmlIncubatorObject::method_set_statusChanged(const BuiltinFunction *b, CallData *callData) +QV4::ReturnedValue QV4::QmlIncubatorObject::method_set_statusChanged(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { QV4::Scope scope(b); - QV4::Scoped<QmlIncubatorObject> o(scope, callData->thisObject.as<QmlIncubatorObject>()); - if (!o || callData->argc() < 1) + QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>()); + if (!o || argc < 1) THROW_TYPE_ERROR(); - o->d()->statusChanged.set(scope.engine, callData->args[0]); + o->d()->statusChanged.set(scope.engine, argv[0]); RETURN_UNDEFINED(); } diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index df4030e522..268f91c8ba 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -106,18 +106,19 @@ void QQmlDelayedCallQueue::init(QV4::ExecutionEngine* engine) m_tickedMethod = metaObject.method(methodIndex); } -QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::BuiltinFunction *b, QV4::CallData *callData) +QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() == 0) + 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) { @@ -136,7 +137,7 @@ QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::B 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; @@ -149,7 +150,7 @@ QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::B 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(); @@ -165,7 +166,7 @@ QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::B 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); @@ -174,9 +175,9 @@ QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::B 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; @@ -184,8 +185,8 @@ void QQmlDelayedCallQueue::storeAnyArguments(DelayedFunctionCall &dfc, const QV4 QV4::Scope scope(engine); QV4::ScopedArrayObject array(scope, engine->newArrayObject(length)); uint i = 0; - for (int j = offset, ej = callData->argc(); j < ej; ++i, ++j) - array->putIndexed(i, callData->args[j]); + for (int j = offset, ej = argc; j < ej; ++i, ++j) + array->putIndexed(i, argv[j]); dfc.m_args.set(engine, array); } diff --git a/src/qml/qml/qqmldelayedcallqueue_p.h b/src/qml/qml/qqmldelayedcallqueue_p.h index 5b3043cfed..b3d361581d 100644 --- a/src/qml/qml/qqmldelayedcallqueue_p.h +++ b/src/qml/qml/qqmldelayedcallqueue_p.h @@ -70,7 +70,7 @@ public: void init(QV4::ExecutionEngine *); - QV4::ReturnedValue addUniquelyAndExecuteLater(const QV4::BuiltinFunction *, QV4::CallData *callData); + QV4::ReturnedValue addUniquelyAndExecuteLater(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); public Q_SLOTS: void ticked(); @@ -90,7 +90,7 @@ private: bool m_guarded; }; - void storeAnyArguments(DelayedFunctionCall& dfc, const QV4::CallData *callData, int offset, QV4::ExecutionEngine *engine); + void storeAnyArguments(DelayedFunctionCall& dfc, const QV4::Value *argv, int argc, int offset, QV4::ExecutionEngine *engine); void executeAllExpired_Later(); QV4::ExecutionEngine *m_engine; diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index b4be83a156..cdeb991e11 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -171,10 +171,10 @@ void PropertyListPrototype::init(ExecutionEngine *) defineDefaultProperty(QStringLiteral("push"), method_push, 1); } -ReturnedValue PropertyListPrototype::method_push(const BuiltinFunction *b, CallData *callData) +ReturnedValue PropertyListPrototype::method_push(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - ScopedObject instance(scope, callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, thisObject->toObject(scope.engine)); if (!instance) RETURN_UNDEFINED(); QmlListWrapper *w = instance->as<QmlListWrapper>(); @@ -184,9 +184,9 @@ ReturnedValue PropertyListPrototype::method_push(const BuiltinFunction *b, CallD THROW_GENERIC_ERROR("List doesn't define an Append function"); QV4::ScopedObject so(scope); - for (int i = 0, ei = callData->argc(); i < ei; ++i) + for (int i = 0, ei = argc; i < ei; ++i) { - so = callData->args[i].toObject(scope.engine); + so = argv[i].toObject(scope.engine); if (QV4::QObjectWrapper *wrapper = so->as<QV4::QObjectWrapper>()) w->d()->property().append(&w->d()->property(), wrapper->object() ); } diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h index 0b53395d2b..e02831c8d1 100644 --- a/src/qml/qml/qqmllistwrapper_p.h +++ b/src/qml/qml/qqmllistwrapper_p.h @@ -103,7 +103,7 @@ struct PropertyListPrototype : Object { void init(ExecutionEngine *engine); - static ReturnedValue method_push(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_push(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); }; } diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 90ca08537c..d37065ce43 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -316,17 +316,16 @@ bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const return true; } -ReturnedValue QQmlValueTypeWrapper::method_toString(const BuiltinFunction *b, CallData *callData) +ReturnedValue QQmlValueTypeWrapper::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int) { - Scope scope(b); - Object *o = callData->thisObject.as<Object>(); + const Object *o = thisObject->as<Object>(); if (!o) - THROW_TYPE_ERROR(); - QQmlValueTypeWrapper *w = o->as<QQmlValueTypeWrapper>(); + return b->engine()->throwTypeError(); + const QQmlValueTypeWrapper *w = o->as<QQmlValueTypeWrapper>(); if (!w) - THROW_TYPE_ERROR(); + return b->engine()->throwTypeError(); - if (QQmlValueTypeReference *ref = w->as<QQmlValueTypeReference>()) + if (const QQmlValueTypeReference *ref = w->as<QQmlValueTypeReference>()) if (!ref->readReferenceValue()) RETURN_UNDEFINED(); @@ -351,7 +350,7 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(const BuiltinFunction *b, Ca } result += QLatin1Char(')'); } - return Encode(scope.engine->newString(result)); + return Encode(b->engine()->newString(result)); } ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *hasProperty) diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h index da03af6dbc..f99d207d68 100644 --- a/src/qml/qml/qqmlvaluetypewrapper_p.h +++ b/src/qml/qml/qqmlvaluetypewrapper_p.h @@ -112,7 +112,7 @@ public: static PropertyAttributes query(const Managed *, String *name); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); - static ReturnedValue method_toString(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_toString(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); static void initProto(ExecutionEngine *v4); }; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 3627f29cb2..14245831a1 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -2098,10 +2098,10 @@ be passed on to the function invoked. Note that if redundant calls are eliminated, then only the last set of arguments will be passed to the function. */ -ReturnedValue QtObject::method_callLater(const BuiltinFunction *b, CallData *callData) +ReturnedValue QtObject::method_callLater(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { QV8Engine *v8engine = b->engine()->v8Engine; - return v8engine->delayedCallQueue()->addUniquelyAndExecuteLater(b, callData); + return v8engine->delayedCallQueue()->addUniquelyAndExecuteLater(b, thisObject, argv, argc); } QT_END_NAMESPACE diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index 7d61aa0ada..5b7dc67e8c 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -131,7 +131,7 @@ struct QtObject : Object static ReturnedValue method_get_inputMethod(const BuiltinFunction *, CallData *callData); static ReturnedValue method_get_styleHints(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_callLater(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_callLater(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); private: void addAll(); |