diff options
author | Lars Knoll <[email protected]> | 2017-12-05 10:45:14 +0100 |
---|---|---|
committer | Lars Knoll <[email protected]> | 2018-01-12 07:04:27 +0000 |
commit | 4e1512baf6d1220c9e89c8a36f16de400bb1b519 (patch) | |
tree | a4edebfeeebfd19e0aba8e376ddf593783f05100 /src | |
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 <[email protected]>
Diffstat (limited to 'src')
25 files changed, 165 insertions, 166 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index c97ba38dec..58e0c2ae6a 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -101,7 +101,7 @@ using namespace QV4; static QBasicAtomicInt engineSerial = Q_BASIC_ATOMIC_INITIALIZER(1); -ReturnedValue throwTypeError(const BuiltinFunction *b, CallData *) +ReturnedValue throwTypeError(const FunctionObject *b, const QV4::Value *, const QV4::Value *, int) { return b->engine()->throwTypeError(); } diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index d61006a6b0..0687491feb 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -110,8 +110,8 @@ struct Q_QML_EXPORT BuiltinFunction : FunctionObject { ReturnedValue (*code)(const QV4::BuiltinFunction *, CallData *); }; -struct IndexedBuiltinFunction : BuiltinFunction { - inline void init(QV4::ExecutionContext *scope, uint index, ReturnedValue (*code)(const QV4::BuiltinFunction *, CallData *)); +struct IndexedBuiltinFunction : FunctionObject { + inline void init(QV4::ExecutionContext *scope, uint index, ReturnedValue (*code)(const QV4::FunctionObject *, const Value *, const Value *, int)); uint index; }; @@ -222,16 +222,16 @@ struct Q_QML_EXPORT BuiltinFunction : FunctionObject { static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); }; -struct IndexedBuiltinFunction: BuiltinFunction +struct IndexedBuiltinFunction : FunctionObject { - V4_OBJECT2(IndexedBuiltinFunction, BuiltinFunction) + V4_OBJECT2(IndexedBuiltinFunction, FunctionObject) }; void Heap::IndexedBuiltinFunction::init(QV4::ExecutionContext *scope, uint index, - ReturnedValue (*code)(const QV4::BuiltinFunction *, CallData *)) + ReturnedValue (*code)(const QV4::FunctionObject *, const Value *thisObject, const Value *argv, int argc)) { Heap::FunctionObject::init(scope); - this->code = code; + this->jsCall = code; this->index = index; } diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 3e04ed63df..e9d3d1c95d 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -196,10 +196,10 @@ void QV4Include::finished() /* Documented in qv8engine.cpp */ -QV4::ReturnedValue QV4Include::method_include(const QV4::BuiltinFunction *b, QV4::CallData *callData) +QV4::ReturnedValue QV4Include::method_include(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - if (!callData->argc()) + if (!argc) RETURN_UNDEFINED(); QQmlContextData *context = scope.engine->callingQmlContext(); @@ -208,11 +208,11 @@ QV4::ReturnedValue QV4Include::method_include(const QV4::BuiltinFunction *b, QV4 RETURN_RESULT(scope.engine->throwError(QString::fromUtf8("Qt.include(): Can only be called from JavaScript files"))); QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue()); - if (callData->argc() >= 2 && callData->args[1].as<QV4::FunctionObject>()) - callbackFunction = callData->args[1]; + if (argc >= 2 && argv[1].as<QV4::FunctionObject>()) + callbackFunction = argv[1]; #if QT_CONFIG(qml_network) - QUrl url(scope.engine->resolvedUrl(callData->args[0].toQStringNoThrow())); + QUrl url(scope.engine->resolvedUrl(argv[0].toQStringNoThrow())); if (scope.engine->qmlEngine() && scope.engine->qmlEngine()->urlInterceptor()) url = scope.engine->qmlEngine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::JavaScriptFile); diff --git a/src/qml/jsruntime/qv4include_p.h b/src/qml/jsruntime/qv4include_p.h index 68537ba2e8..8015722afc 100644 --- a/src/qml/jsruntime/qv4include_p.h +++ b/src/qml/jsruntime/qv4include_p.h @@ -77,7 +77,7 @@ public: Exception = 3 }; - static QV4::ReturnedValue method_include(const QV4::BuiltinFunction *, QV4::CallData *callData); + static QV4::ReturnedValue method_include(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); private Q_SLOTS: void finished(); diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 5e580b8b4d..51802d895b 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -884,12 +884,12 @@ void Heap::JsonObject::init() } -ReturnedValue JsonObject::method_parse(const BuiltinFunction *b, CallData *callData) +ReturnedValue JsonObject::method_parse(const FunctionObject *b, const Value *, const Value *argv, int argc) { ExecutionEngine *v4 = b->engine(); QString jtext; - if (callData->argc() > 0) - jtext = callData->args[0].toQString(); + if (argc > 0) + jtext = argv[0].toQString(); DEBUG << "parsing source = " << jtext; JsonParser parser(v4, jtext.constData(), jtext.length()); @@ -903,12 +903,12 @@ ReturnedValue JsonObject::method_parse(const BuiltinFunction *b, CallData *callD return result; } -ReturnedValue JsonObject::method_stringify(const BuiltinFunction *b, CallData *callData) +ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value *, const Value *argv, int argc) { Scope scope(b); Stringify stringify(scope.engine); - ScopedObject o(scope, callData->argument(1)); + ScopedObject o(scope, argc > 1 ? argv[1] : Primitive::undefinedValue()); if (o) { stringify.replacerFunction = o->as<FunctionObject>(); if (o->isArrayObject()) { @@ -933,7 +933,7 @@ ReturnedValue JsonObject::method_stringify(const BuiltinFunction *b, CallData *c } } - ScopedValue s(scope, callData->argument(2)); + ScopedValue s(scope, argc > 2 ? argv[2] : Primitive::undefinedValue()); if (NumberObject *n = s->as<NumberObject>()) s = Encode(n->value()); else if (StringObject *so = s->as<StringObject>()) @@ -946,7 +946,7 @@ ReturnedValue JsonObject::method_stringify(const BuiltinFunction *b, CallData *c } - ScopedValue arg0(scope, callData->argument(0)); + ScopedValue arg0(scope, argc ? argv[0] : Primitive::undefinedValue()); QString result = stringify.Str(QString(), arg0); if (result.isEmpty() || scope.engine->hasException) RETURN_UNDEFINED(); diff --git a/src/qml/jsruntime/qv4jsonobject_p.h b/src/qml/jsruntime/qv4jsonobject_p.h index 19dba14aef..7d9f204910 100644 --- a/src/qml/jsruntime/qv4jsonobject_p.h +++ b/src/qml/jsruntime/qv4jsonobject_p.h @@ -88,8 +88,8 @@ private: typedef QSet<ObjectItem> V4ObjectSet; public: - static ReturnedValue method_parse(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_stringify(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_parse(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_stringify(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static ReturnedValue fromJsonValue(ExecutionEngine *engine, const QJsonValue &value); static ReturnedValue fromJsonObject(ExecutionEngine *engine, const QJsonObject &object); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 6d7d929b61..56d9234be8 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -900,14 +900,14 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase } // namespace QV4 -ReturnedValue QObjectWrapper::method_connect(const BuiltinFunction *b, CallData *callData) +ReturnedValue QObjectWrapper::method_connect(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() == 0) + if (argc == 0) THROW_GENERIC_ERROR("Function.prototype.connect: no arguments given"); - QPair<QObject *, int> signalInfo = extractQtSignal(callData->thisObject); + QPair<QObject *, int> signalInfo = extractQtSignal(*thisObject); QObject *signalObject = signalInfo.first; int signalIndex = signalInfo.second; // in method range, not signal range! @@ -921,25 +921,25 @@ ReturnedValue QObjectWrapper::method_connect(const BuiltinFunction *b, CallData THROW_GENERIC_ERROR("Function.prototype.connect: this object is not a signal"); QV4::ScopedFunctionObject f(scope); - QV4::ScopedValue thisObject (scope, QV4::Encode::undefined()); + QV4::ScopedValue object (scope, QV4::Encode::undefined()); - if (callData->argc() == 1) { - f = callData->args[0]; - } else if (callData->argc() >= 2) { - thisObject = callData->args[0]; - f = callData->args[1]; + if (argc == 1) { + f = argv[0]; + } else if (argc >= 2) { + object = argv[0]; + f = argv[1]; } if (!f) THROW_GENERIC_ERROR("Function.prototype.connect: target is not a function"); - if (!thisObject->isUndefined() && !thisObject->isObject()) + if (!object->isUndefined() && !object->isObject()) THROW_GENERIC_ERROR("Function.prototype.connect: target this is not an object"); QV4::QObjectSlotDispatcher *slot = new QV4::QObjectSlotDispatcher; slot->signalIndex = signalIndex; - slot->thisObject.set(scope.engine, thisObject); + slot->thisObject.set(scope.engine, object); slot->function.set(scope.engine, f); if (QQmlData *ddata = QQmlData::get(signalObject)) { @@ -952,14 +952,14 @@ ReturnedValue QObjectWrapper::method_connect(const BuiltinFunction *b, CallData RETURN_UNDEFINED(); } -ReturnedValue QObjectWrapper::method_disconnect(const BuiltinFunction *b, CallData *callData) +ReturnedValue QObjectWrapper::method_disconnect(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { QV4::Scope scope(b); - if (callData->argc() == 0) + if (argc == 0) THROW_GENERIC_ERROR("Function.prototype.disconnect: no arguments given"); - QPair<QObject *, int> signalInfo = extractQtSignal(callData->thisObject); + QPair<QObject *, int> signalInfo = extractQtSignal(*thisObject); QObject *signalObject = signalInfo.first; int signalIndex = signalInfo.second; @@ -975,11 +975,11 @@ ReturnedValue QObjectWrapper::method_disconnect(const BuiltinFunction *b, CallDa QV4::ScopedFunctionObject functionValue(scope); QV4::ScopedValue functionThisValue(scope, QV4::Encode::undefined()); - if (callData->argc() == 1) { - functionValue = callData->args[0]; - } else if (callData->argc() >= 2) { - functionThisValue = callData->args[0]; - functionValue = callData->args[1]; + if (argc == 1) { + functionValue = argv[0]; + } else if (argc >= 2) { + functionThisValue = argv[0]; + functionValue = argv[1]; } if (!functionValue) diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index c00e82e4fa..28717b5d80 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -198,8 +198,8 @@ protected: 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_connect(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_disconnect(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_connect(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_disconnect(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); private: Q_NEVER_INLINE static ReturnedValue wrap_slowPath(ExecutionEngine *engine, QObject *object); diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 78cd7529d8..78413f1b0e 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -420,11 +420,10 @@ public: ScopedFunctionObject compare(scope, m_compareFn); if (!compare) return m_v4->throwTypeError(); - JSCallData jsCallData(scope, 2); - jsCallData->args[0] = convertElementToValue(m_v4, lhs); - jsCallData->args[1] = convertElementToValue(m_v4, rhs); - *jsCallData->thisObject = m_v4->globalObject; - QV4::ScopedValue result(scope, compare->call(jsCallData)); + Value *argv = scope.alloc(2); + argv[0] = convertElementToValue(m_v4, lhs); + argv[1] = convertElementToValue(m_v4, rhs); + QV4::ScopedValue result(scope, compare->call(m_v4->globalObject, argv, 2)); return result->toNumber() < 0; } @@ -433,7 +432,7 @@ public: const QV4::Value *m_compareFn; }; - void sort(const BuiltinFunction *, Scope &scope, CallData *callData) + void sort(const FunctionObject *f, const Value *, const Value *argv, int argc) { if (d()->isReference) { if (!d()->object) @@ -441,8 +440,8 @@ public: loadReference(); } - if (callData->argc() == 1 && callData->args[0].as<FunctionObject>()) { - CompareFunctor cf(scope.engine, callData->args[0]); + if (argc == 1 && argv[0].as<FunctionObject>()) { + CompareFunctor cf(f->engine(), argv[0]); std::sort(d()->container->begin(), d()->container->end(), cf); } else { DefaultCompareFunctor cf; @@ -453,10 +452,10 @@ public: storeReference(); } - static QV4::ReturnedValue method_get_length(const BuiltinFunction *b, CallData *callData) + static QV4::ReturnedValue method_get_length(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QQmlSequence<Container> > This(scope, callData->thisObject.as<QQmlSequence<Container> >()); + QV4::Scoped<QQmlSequence<Container>> This(scope, thisObject->as<QQmlSequence<Container> >()); if (!This) THROW_TYPE_ERROR(); @@ -468,14 +467,14 @@ public: RETURN_RESULT(Encode(qint32(This->d()->container->size()))); } - static QV4::ReturnedValue method_set_length(const BuiltinFunction *b, CallData *callData) + static QV4::ReturnedValue method_set_length(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) { - QV4::Scope scope(b); - QV4::Scoped<QQmlSequence<Container> > This(scope, callData->thisObject.as<QQmlSequence<Container> >()); + QV4::Scope scope(f); + QV4::Scoped<QQmlSequence<Container>> This(scope, thisObject->as<QQmlSequence<Container> >()); if (!This) THROW_TYPE_ERROR(); - quint32 newLength = callData->args[0].toUInt32(); + quint32 newLength = argc ? argv[0].toUInt32() : 0; /* Qt containers have int (rather than uint) allowable indexes. */ if (newLength > INT_MAX) { generateWarning(scope.engine, QLatin1String("Index out of range during length set")); @@ -652,24 +651,24 @@ void SequencePrototype::init() } #undef REGISTER_QML_SEQUENCE_METATYPE -ReturnedValue SequencePrototype::method_valueOf(const BuiltinFunction *f, CallData *callData) +ReturnedValue SequencePrototype::method_valueOf(const FunctionObject *f, const Value *thisObject, const Value *, int) { - return Encode(callData->thisObject.toString(f->engine())); + return Encode(thisObject->toString(f->engine())); } -ReturnedValue SequencePrototype::method_sort(const BuiltinFunction *b, CallData *callData) +ReturnedValue SequencePrototype::method_sort(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - QV4::ScopedObject o(scope, callData->thisObject); + QV4::ScopedObject o(scope, thisObject); if (!o || !o->isListType()) THROW_TYPE_ERROR(); - if (callData->argc() >= 2) + if (argc >= 2) return o.asReturnedValue(); #define CALL_SORT(SequenceElementType, SequenceElementTypeName, SequenceType, DefaultValue) \ if (QQml##SequenceElementTypeName##List *s = o->as<QQml##SequenceElementTypeName##List>()) { \ - s->sort(b, scope, callData); \ + s->sort(b, thisObject, argv, argc); \ } else FOREACH_QML_SEQUENCE_TYPE(CALL_SORT) diff --git a/src/qml/jsruntime/qv4sequenceobject_p.h b/src/qml/jsruntime/qv4sequenceobject_p.h index 169a48c2f9..e9bef2f604 100644 --- a/src/qml/jsruntime/qv4sequenceobject_p.h +++ b/src/qml/jsruntime/qv4sequenceobject_p.h @@ -68,8 +68,8 @@ struct SequencePrototype : public QV4::Object V4_PROTOTYPE(arrayPrototype) void init(); - static ReturnedValue method_valueOf(const BuiltinFunction *f, CallData *callData); - static ReturnedValue method_sort(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); static bool isSequenceType(int sequenceTypeId); static ReturnedValue newSequence(QV4::ExecutionEngine *engine, int sequenceTypeId, QObject *object, int propertyIndex, bool *succeeded); diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp index 00be90b3c2..bee17e0390 100644 --- a/src/qml/jsruntime/qv4variantobject.cpp +++ b/src/qml/jsruntime/qv4variantobject.cpp @@ -113,17 +113,17 @@ void VariantPrototype::init() defineDefaultProperty(engine()->id_toString(), method_toString, 0); } -ReturnedValue VariantPrototype::method_preserve(const BuiltinFunction *, CallData *callData) +ReturnedValue VariantPrototype::method_preserve(const FunctionObject *, const Value *thisObject, const Value *, int) { - VariantObject *o = callData->thisObject.as<QV4::VariantObject>(); + const VariantObject *o = thisObject->as<QV4::VariantObject>(); if (o && o->d()->isScarce()) o->d()->addVmePropertyReference(); RETURN_UNDEFINED(); } -ReturnedValue VariantPrototype::method_destroy(const BuiltinFunction *, CallData *callData) +ReturnedValue VariantPrototype::method_destroy(const FunctionObject *, const Value *thisObject, const Value *, int) { - VariantObject *o = callData->thisObject.as<QV4::VariantObject>(); + const VariantObject *o = thisObject->as<QV4::VariantObject>(); if (o) { if (o->d()->isScarce()) o->d()->addVmePropertyReference(); @@ -132,10 +132,10 @@ ReturnedValue VariantPrototype::method_destroy(const BuiltinFunction *, CallData RETURN_UNDEFINED(); } -ReturnedValue VariantPrototype::method_toString(const BuiltinFunction *b, CallData *callData) +ReturnedValue VariantPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int) { ExecutionEngine *v4 = b->engine(); - VariantObject *o = callData->thisObject.as<QV4::VariantObject>(); + const VariantObject *o = thisObject->as<QV4::VariantObject>(); if (!o) RETURN_UNDEFINED(); QString result = o->d()->data().toString(); @@ -147,9 +147,9 @@ ReturnedValue VariantPrototype::method_toString(const BuiltinFunction *b, CallDa return Encode(v4->newString(result)); } -ReturnedValue VariantPrototype::method_valueOf(const BuiltinFunction *b, CallData *callData) +ReturnedValue VariantPrototype::method_valueOf(const FunctionObject *b, const Value *thisObject, const Value *, int) { - VariantObject *o = callData->thisObject.as<QV4::VariantObject>(); + const VariantObject *o = thisObject->as<QV4::VariantObject>(); if (o) { QVariant v = o->d()->data(); switch (v.type()) { @@ -170,7 +170,7 @@ ReturnedValue VariantPrototype::method_valueOf(const BuiltinFunction *b, CallDat break; } } - return callData->thisObject.asReturnedValue(); + return thisObject->asReturnedValue(); } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4variantobject_p.h b/src/qml/jsruntime/qv4variantobject_p.h index 07b3310e91..62fa7ff9a8 100644 --- a/src/qml/jsruntime/qv4variantobject_p.h +++ b/src/qml/jsruntime/qv4variantobject_p.h @@ -108,10 +108,10 @@ public: V4_PROTOTYPE(objectPrototype) void init(); - static ReturnedValue method_preserve(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_destroy(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_toString(const BuiltinFunction *, CallData *callData); - static ReturnedValue method_valueOf(const BuiltinFunction *, CallData *callData); + static ReturnedValue method_preserve(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_destroy(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); }; } 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(); diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index ab22f97adf..fa1be563b5 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1813,10 +1813,10 @@ int QQmlDelegateModelItemMetaType::parseGroups(const QV4::Value &groups) const return groupFlags; } -QV4::ReturnedValue QQmlDelegateModelItem::get_model(const QV4::BuiltinFunction *b, QV4::CallData *callData) +QV4::ReturnedValue QQmlDelegateModelItem::get_model(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); if (!o) return b->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); if (!o->d()->item->metaType->model) @@ -1825,10 +1825,10 @@ QV4::ReturnedValue QQmlDelegateModelItem::get_model(const QV4::BuiltinFunction * return o->d()->item->get(); } -QV4::ReturnedValue QQmlDelegateModelItem::get_groups(const QV4::BuiltinFunction *b, QV4::CallData *callData) +QV4::ReturnedValue QQmlDelegateModelItem::get_groups(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); if (!o) return scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -1841,21 +1841,21 @@ QV4::ReturnedValue QQmlDelegateModelItem::get_groups(const QV4::BuiltinFunction return scope.engine->fromVariant(groups); } -QV4::ReturnedValue QQmlDelegateModelItem::set_groups(const QV4::BuiltinFunction *b, QV4::CallData *callData) +QV4::ReturnedValue QQmlDelegateModelItem::set_groups(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); if (!o) return scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!callData->argc()) + if (!argc) THROW_TYPE_ERROR(); if (!o->d()->item->metaType->model) RETURN_UNDEFINED(); QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(o->d()->item->metaType->model); - const int groupFlags = model->m_cacheMetaType->parseGroups(callData->args[0]); + const int groupFlags = model->m_cacheMetaType->parseGroups(argv[0]); const int cacheIndex = model->m_cache.indexOf(o->d()->item); Compositor::iterator it = model->m_compositor.find(Compositor::Cache, cacheIndex); model->setGroups(it, 1, Compositor::Cache, groupFlags); @@ -3241,23 +3241,23 @@ struct QQmlDelegateModelGroupChange : QV4::Object return e->memoryManager->allocObject<QQmlDelegateModelGroupChange>(); } - static QV4::ReturnedValue method_get_index(const QV4::BuiltinFunction *b, QV4::CallData *callData) { + static QV4::ReturnedValue method_get_index(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, callData->thisObject.as<QQmlDelegateModelGroupChange>()); + QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, thisObject->as<QQmlDelegateModelGroupChange>()); if (!that) THROW_TYPE_ERROR(); return QV4::Encode(that->d()->change.index); } - static QV4::ReturnedValue method_get_count(const QV4::BuiltinFunction *b, QV4::CallData *callData) { + static QV4::ReturnedValue method_get_count(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, callData->thisObject.as<QQmlDelegateModelGroupChange>()); + QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, thisObject->as<QQmlDelegateModelGroupChange>()); if (!that) THROW_TYPE_ERROR(); return QV4::Encode(that->d()->change.count); } - static QV4::ReturnedValue method_get_moveId(const QV4::BuiltinFunction *b, QV4::CallData *callData) { + static QV4::ReturnedValue method_get_moveId(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, callData->thisObject.as<QQmlDelegateModelGroupChange>()); + QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, thisObject->as<QQmlDelegateModelGroupChange>()); if (!that) THROW_TYPE_ERROR(); if (that->d()->change.moveId < 0) diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index 5f72bd66be..537937df57 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -126,9 +126,9 @@ public: virtual void setValue(const QString &role, const QVariant &value) { Q_UNUSED(role); Q_UNUSED(value); } virtual bool resolveIndex(const QQmlAdaptorModel &, int) { return false; } - static QV4::ReturnedValue get_model(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue get_groups(const QV4::BuiltinFunction *, QV4::CallData *callData); - static QV4::ReturnedValue set_groups(const QV4::BuiltinFunction *, QV4::CallData *callData); + static QV4::ReturnedValue get_model(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue get_groups(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue set_groups(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); static QV4::ReturnedValue get_member(QQmlDelegateModelItem *thisItem, uint flag, const QV4::Value &); static QV4::ReturnedValue set_member(QQmlDelegateModelItem *thisItem, uint flag, const QV4::Value &arg); static QV4::ReturnedValue get_index(QQmlDelegateModelItem *thisItem, uint flag, const QV4::Value &arg); diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 346f2e6a61..43ba21afad 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -186,7 +186,7 @@ public: int m_nextId; - static QV4::ReturnedValue method_sendMessage(const QV4::BuiltinFunction *, QV4::CallData *callData); + static QV4::ReturnedValue method_sendMessage(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); signals: void stopThread(); @@ -293,15 +293,15 @@ QQuickWorkerScriptEnginePrivate::QQuickWorkerScriptEnginePrivate(QQmlEngine *eng { } -QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::method_sendMessage(const QV4::BuiltinFunction *b, - QV4::CallData *callData) +QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::method_sendMessage(const QV4::FunctionObject *b, + const QV4::Value *, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - WorkerEngine *engine = (WorkerEngine*)scope.engine->v8Engine; + WorkerEngine *engine = static_cast<WorkerEngine *>(scope.engine->v8Engine); - int id = callData->argc() > 1 ? callData->args[1].toInt32() : 0; + int id = argc > 1 ? argv[1].toInt32() : 0; - QV4::ScopedValue v(scope, callData->argument(2)); + QV4::ScopedValue v(scope, argc > 2 ? argv[2] : QV4::Primitive::undefinedValue()); QByteArray data = QV4::Serialize::serialize(v, scope.engine); QMutexLocker locker(&engine->p->m_lock); diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index d5b38f6d3e..7afafec1fe 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -61,10 +61,10 @@ public: V4_DEFINE_EXTENSION(QQmlAdaptorModelEngineData, engineData) -static QV4::ReturnedValue get_index(const QV4::BuiltinFunction *f, QV4::CallData *callData) +static QV4::ReturnedValue get_index(const QV4::FunctionObject *f, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(f); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); if (!o) RETURN_RESULT(scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object"))); @@ -106,8 +106,8 @@ public: void setValue(const QString &role, const QVariant &value) override; bool resolveIndex(const QQmlAdaptorModel &model, int idx) override; - static QV4::ReturnedValue get_property(const QV4::BuiltinFunction *, QV4::CallData *); - static QV4::ReturnedValue set_property(const QV4::BuiltinFunction *, QV4::CallData *); + static QV4::ReturnedValue get_property(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue set_property(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); VDMModelDelegateDataType *type; QVector<QVariant> cachedData; @@ -195,10 +195,10 @@ public: dataType->watchedRoles += newRoles; } - static QV4::ReturnedValue get_hasModelChildren(const QV4::BuiltinFunction *b, QV4::CallData *callData) + static QV4::ReturnedValue get_hasModelChildren(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); if (!o) RETURN_RESULT(scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object"))); @@ -343,10 +343,10 @@ bool QQmlDMCachedModelData::resolveIndex(const QQmlAdaptorModel &, int idx) } } -QV4::ReturnedValue QQmlDMCachedModelData::get_property(const QV4::BuiltinFunction *b, QV4::CallData *callData) +QV4::ReturnedValue QQmlDMCachedModelData::get_property(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::Scope scope(b); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); if (!o) return scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -365,13 +365,13 @@ QV4::ReturnedValue QQmlDMCachedModelData::get_property(const QV4::BuiltinFunctio return QV4::Encode::undefined(); } -QV4::ReturnedValue QQmlDMCachedModelData::set_property(const QV4::BuiltinFunction *b, QV4::CallData *callData) +QV4::ReturnedValue QQmlDMCachedModelData::set_property(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { QV4::Scope scope(b); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); if (!o) return scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!callData->argc()) + if (!argc) return scope.engine->throwTypeError(); uint propertyId = static_cast<const QV4::IndexedBuiltinFunction *>(b)->d()->index; @@ -380,10 +380,10 @@ QV4::ReturnedValue QQmlDMCachedModelData::set_property(const QV4::BuiltinFunctio QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->d()->item); if (!modelData->cachedData.isEmpty()) { if (modelData->cachedData.count() > 1) { - modelData->cachedData[propertyId] = scope.engine->toVariant(callData->args[0], QVariant::Invalid); + modelData->cachedData[propertyId] = scope.engine->toVariant(argv[0], QVariant::Invalid); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), propertyId, 0); } else if (modelData->cachedData.count() == 1) { - modelData->cachedData[0] = scope.engine->toVariant(callData->args[0], QVariant::Invalid); + modelData->cachedData[0] = scope.engine->toVariant(argv[0], QVariant::Invalid); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 0, 0); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 1, 0); } @@ -586,26 +586,26 @@ public: } } - static QV4::ReturnedValue get_modelData(const QV4::BuiltinFunction *b, QV4::CallData *callData) + static QV4::ReturnedValue get_modelData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { QV4::ExecutionEngine *v4 = b->engine(); - QQmlDelegateModelItemObject *o = callData->thisObject.as<QQmlDelegateModelItemObject>(); + const QQmlDelegateModelItemObject *o = thisObject->as<QQmlDelegateModelItemObject>(); if (!o) return v4->throwTypeError(QStringLiteral("Not a valid VisualData object")); return v4->fromVariant(static_cast<QQmlDMListAccessorData *>(o->d()->item)->cachedData); } - static QV4::ReturnedValue set_modelData(const QV4::BuiltinFunction *b, QV4::CallData *callData) + static QV4::ReturnedValue set_modelData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { QV4::ExecutionEngine *v4 = b->engine(); - QQmlDelegateModelItemObject *o = callData->thisObject.as<QQmlDelegateModelItemObject>(); + const QQmlDelegateModelItemObject *o = thisObject->as<QQmlDelegateModelItemObject>(); if (!o) return v4->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!callData->argc()) + if (!argc) return v4->throwTypeError(); - static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(v4->toVariant(callData->args[0], QVariant::Invalid)); + static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(v4->toVariant(argv[0], QVariant::Invalid)); return QV4::Encode::undefined(); } |