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/jsruntime/qv4sequenceobject.cpp | |
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/jsruntime/qv4sequenceobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4sequenceobject.cpp | 39 |
1 files changed, 19 insertions, 20 deletions
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) |