diff options
22 files changed, 199 insertions, 208 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index ab50301cd9..77bf587509 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -657,17 +657,17 @@ QJSValue QJSValue::call(const QJSValueList &args) Q_ASSERT(engine); Scope scope(engine); - JSCallData jsCall(scope, f, args.length()); - jsCall->thisObject = engine->globalObject; + JSCallData jsCallData(scope, f, args.length()); + jsCallData->thisObject = engine->globalObject; for (int i = 0; i < args.size(); ++i) { if (!QJSValuePrivate::checkEngine(engine, args.at(i))) { qWarning("QJSValue::call() failed: cannot call function with argument created in a different engine"); return QJSValue(); } - jsCall->args[i] = QJSValuePrivate::convertedToValue(engine, args.at(i)); + jsCallData->args[i] = QJSValuePrivate::convertedToValue(engine, args.at(i)); } - ScopedValue result(scope, jsCall.call()); + ScopedValue result(scope, f->call(jsCallData)); if (engine->hasException) result = engine->catchException(); @@ -713,17 +713,17 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList return QJSValue(); } - JSCallData jsCall(scope, f, args.size()); - jsCall->thisObject = QJSValuePrivate::convertedToValue(engine, instance); + JSCallData jsCallData(scope, f, args.size()); + jsCallData->thisObject = QJSValuePrivate::convertedToValue(engine, instance); for (int i = 0; i < args.size(); ++i) { if (!QJSValuePrivate::checkEngine(engine, args.at(i))) { qWarning("QJSValue::call() failed: cannot call function with argument created in a different engine"); return QJSValue(); } - jsCall->args[i] = QJSValuePrivate::convertedToValue(engine, args.at(i)); + jsCallData->args[i] = QJSValuePrivate::convertedToValue(engine, args.at(i)); } - ScopedValue result(scope, jsCall.call()); + ScopedValue result(scope, f->call(jsCallData)); if (engine->hasException) result = engine->catchException(); diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 787194cf86..298c674504 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -139,10 +139,10 @@ bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, con if (isMapped && attrs.isData()) { Q_ASSERT(arrayData()); ScopedFunctionObject setter(scope, map->setter()); - JSCallData jsCall(scope, setter, 1); - jsCall->thisObject = this->asReturnedValue(); - jsCall->args[0] = desc->value; - jsCall.call(); + JSCallData jsCallData(scope, setter, 1); + jsCallData->thisObject = this->asReturnedValue(); + jsCallData->args[0] = desc->value; + setter->call(jsCallData); if (attrs.isWritable()) { setArrayAttributes(index, mapAttrs); diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 1155dc46e5..8d048ca1d6 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -677,10 +677,10 @@ bool ArrayElementLessThan::operator()(Value v1, Value v2) const if (o) { Scope scope(o->engine()); ScopedValue result(scope); - JSCallData jsCall(scope, o, 2); - jsCall->args[0] = v1; - jsCall->args[1] = v2; - result = jsCall.call(); + JSCallData jsCallData(scope, o, 2); + jsCallData->args[0] = v1; + jsCallData->args[1] = v2; + result = o->call(jsCallData); return result->toNumber() < 0; } diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 164aa7b5c5..83bfe8e84c 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -198,8 +198,8 @@ ReturnedValue ArrayPrototype::method_find(const BuiltinFunction *b, CallData *ca if (!callback) THROW_TYPE_ERROR(); - JSCallData jsCall(scope, callback, 3); - jsCall->thisObject = callData->argument(1); + JSCallData jsCallData(scope, callback, 3); + jsCallData->thisObject = callData->argument(1); ScopedValue v(scope); ScopedValue result(scope); @@ -208,10 +208,10 @@ ReturnedValue ArrayPrototype::method_find(const BuiltinFunction *b, CallData *ca v = instance->getIndexed(k); CHECK_EXCEPTION(); - jsCall->args[0] = v; - jsCall->args[1] = Primitive::fromDouble(k); - jsCall->args[2] = instance; - result = jsCall.call(); + jsCallData->args[0] = v; + jsCallData->args[1] = Primitive::fromDouble(k); + jsCallData->args[2] = instance; + result = callback->call(jsCallData); CHECK_EXCEPTION(); if (result->toBoolean()) @@ -234,8 +234,8 @@ ReturnedValue ArrayPrototype::method_findIndex(const BuiltinFunction *b, CallDat if (!callback) THROW_TYPE_ERROR(); - JSCallData jsCall(scope, callback, 3); - jsCall->thisObject = callData->argument(1); + JSCallData jsCallData(scope, callback, 3); + jsCallData->thisObject = callData->argument(1); ScopedValue v(scope); ScopedValue result(scope); @@ -244,10 +244,10 @@ ReturnedValue ArrayPrototype::method_findIndex(const BuiltinFunction *b, CallDat v = instance->getIndexed(k); CHECK_EXCEPTION(); - jsCall->args[0] = v; - jsCall->args[1] = Primitive::fromDouble(k); - jsCall->args[2] = instance; - result = jsCall.call(); + jsCallData->args[0] = v; + jsCallData->args[1] = Primitive::fromDouble(k); + jsCallData->args[2] = instance; + result = callback->call(jsCallData); CHECK_EXCEPTION(); if (result->toBoolean()) @@ -793,8 +793,8 @@ ReturnedValue ArrayPrototype::method_every(const BuiltinFunction *b, CallData *c ScopedValue r(scope); ScopedValue v(scope); - JSCallData jsCall(scope, callback, 3); - jsCall->thisObject = callData->argument(1); + JSCallData jsCallData(scope, callback, 3); + jsCallData->thisObject = callData->argument(1); bool ok = true; for (uint k = 0; ok && k < len; ++k) { @@ -803,10 +803,10 @@ ReturnedValue ArrayPrototype::method_every(const BuiltinFunction *b, CallData *c if (!exists) continue; - jsCall->args[0] = v; - jsCall->args[1] = Primitive::fromDouble(k); - jsCall->args[2] = instance; - r = jsCall.call(); + jsCallData->args[0] = v; + jsCallData->args[1] = Primitive::fromDouble(k); + jsCallData->args[2] = instance; + r = callback->call(jsCallData); ok = r->toBoolean(); } return Encode(ok); @@ -827,8 +827,8 @@ ReturnedValue ArrayPrototype::method_some(const BuiltinFunction *b, CallData *ca ScopedValue v(scope); ScopedValue result(scope); - JSCallData jsCall(scope, callback, 3); - jsCall->thisObject = callData->argument(1); + JSCallData jsCallData(scope, callback, 3); + jsCallData->thisObject = callData->argument(1); for (uint k = 0; k < len; ++k) { bool exists; @@ -836,10 +836,10 @@ ReturnedValue ArrayPrototype::method_some(const BuiltinFunction *b, CallData *ca if (!exists) continue; - jsCall->args[0] = v; - jsCall->args[1] = Primitive::fromDouble(k); - jsCall->args[2] = instance; - result = jsCall.call(); + jsCallData->args[0] = v; + jsCallData->args[1] = Primitive::fromDouble(k); + jsCallData->args[2] = instance; + result = callback->call(jsCallData); if (result->toBoolean()) return Encode(true); } @@ -860,8 +860,8 @@ ReturnedValue ArrayPrototype::method_forEach(const BuiltinFunction *b, CallData THROW_TYPE_ERROR(); ScopedValue v(scope); - JSCallData jsCall(scope, callback, 3); - jsCall->thisObject = callData->argument(1); + JSCallData jsCallData(scope, callback, 3); + jsCallData->thisObject = callData->argument(1); for (uint k = 0; k < len; ++k) { bool exists; @@ -869,10 +869,10 @@ ReturnedValue ArrayPrototype::method_forEach(const BuiltinFunction *b, CallData if (!exists) continue; - jsCall->args[0] = v; - jsCall->args[1] = Primitive::fromDouble(k); - jsCall->args[2] = instance; - jsCall.call(); + jsCallData->args[0] = v; + jsCallData->args[1] = Primitive::fromDouble(k); + jsCallData->args[2] = instance; + callback->call(jsCallData); } RETURN_UNDEFINED(); } @@ -896,8 +896,8 @@ ReturnedValue ArrayPrototype::method_map(const BuiltinFunction *b, CallData *cal ScopedValue v(scope); ScopedValue mapped(scope); - JSCallData jsCall(scope, callback, 3); - jsCall->thisObject = callData->argument(1); + JSCallData jsCallData(scope, callback, 3); + jsCallData->thisObject = callData->argument(1); for (uint k = 0; k < len; ++k) { bool exists; @@ -905,10 +905,10 @@ ReturnedValue ArrayPrototype::method_map(const BuiltinFunction *b, CallData *cal if (!exists) continue; - jsCall->args[0] = v; - jsCall->args[1] = Primitive::fromDouble(k); - jsCall->args[2] = instance; - mapped = jsCall.call(); + jsCallData->args[0] = v; + jsCallData->args[1] = Primitive::fromDouble(k); + jsCallData->args[2] = instance; + mapped = callback->call(jsCallData); a->arraySet(k, mapped); } return a.asReturnedValue(); @@ -932,8 +932,8 @@ ReturnedValue ArrayPrototype::method_filter(const BuiltinFunction *b, CallData * ScopedValue selected(scope); ScopedValue v(scope); - JSCallData jsCall(scope, callback, 3); - jsCall->thisObject = callData->argument(1); + JSCallData jsCallData(scope, callback, 3); + jsCallData->thisObject = callData->argument(1); uint to = 0; for (uint k = 0; k < len; ++k) { @@ -942,10 +942,10 @@ ReturnedValue ArrayPrototype::method_filter(const BuiltinFunction *b, CallData * if (!exists) continue; - jsCall->args[0] = v; - jsCall->args[1] = Primitive::fromDouble(k); - jsCall->args[2] = instance; - selected = jsCall.call(); + jsCallData->args[0] = v; + jsCallData->args[1] = Primitive::fromDouble(k); + jsCallData->args[2] = instance; + selected = callback->call(jsCallData); if (selected->toBoolean()) { a->arraySet(to, v); ++to; @@ -985,17 +985,17 @@ ReturnedValue ArrayPrototype::method_reduce(const BuiltinFunction *b, CallData * THROW_TYPE_ERROR(); } - JSCallData jsCall(scope, callback, 4); + JSCallData jsCallData(scope, callback, 4); while (k < len) { bool kPresent; v = instance->getIndexed(k, &kPresent); if (kPresent) { - jsCall->args[0] = acc; - jsCall->args[1] = v; - jsCall->args[2] = Primitive::fromDouble(k); - jsCall->args[3] = instance; - acc = jsCall.call(); + jsCallData->args[0] = acc; + jsCallData->args[1] = v; + jsCallData->args[2] = Primitive::fromDouble(k); + jsCallData->args[3] = instance; + acc = callback->call(jsCallData); } ++k; } @@ -1038,18 +1038,18 @@ ReturnedValue ArrayPrototype::method_reduceRight(const BuiltinFunction *b, CallD THROW_TYPE_ERROR(); } - JSCallData jsCall(scope, callback, 4); - jsCall->thisObject = Primitive::undefinedValue(); + JSCallData jsCallData(scope, callback, 4); + jsCallData->thisObject = Primitive::undefinedValue(); while (k > 0) { bool kPresent; v = instance->getIndexed(k - 1, &kPresent); if (kPresent) { - jsCall->args[0] = acc; - jsCall->args[1] = v; - jsCall->args[2] = Primitive::fromDouble(k - 1); - jsCall->args[3] = instance; - acc = jsCall.call(); + jsCallData->args[0] = acc; + jsCallData->args[1] = v; + jsCallData->args[2] = Primitive::fromDouble(k - 1); + jsCallData->args[3] = instance; + acc = callback->call(jsCallData); } --k; } diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 6c971195f6..436950bf28 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -1451,9 +1451,9 @@ ReturnedValue DatePrototype::method_toJSON(const BuiltinFunction *b, CallData *c if (!toIso) return v4->throwTypeError(); - JSCallData jsCall(scope, toIso); - jsCall->thisObject = callData->thisObject; - return jsCall.call(); + JSCallData jsCallData(scope, toIso); + jsCallData->thisObject = callData->thisObject; + return toIso->call(jsCallData); } void DatePrototype::timezoneUpdated() diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 6f74ee4456..b4c228f6b3 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -374,12 +374,12 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const if (function->isStrict() || (ctx->d()->v4Function->isStrict())) { ScopedFunctionObject e(scope, FunctionObject::createScriptFunction(ctx, function)); - JSCallData jsCall(scope, e, 0); + JSCallData jsCallData(scope, e, 0); if (directCall) - jsCall->thisObject = scope.engine->currentStackFrame->thisObject(); + jsCallData->thisObject = scope.engine->currentStackFrame->thisObject(); else - jsCall->thisObject = scope.engine->globalObject; - return jsCall.call(); + jsCallData->thisObject = scope.engine->globalObject; + return e->call(jsCallData); } ContextStateSaver stateSaver(scope, ctx); diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 35a271527a..7feea14a05 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -119,10 +119,10 @@ void QV4Include::callback(const QV4::Value &callback, const QV4::Value &status) if (!f) return; - QV4::JSCallData jsCall(scope, f, 1); - jsCall->thisObject = v4->globalObject->asReturnedValue(); - jsCall->args[0] = status; - jsCall.call(); + QV4::JSCallData jsCallData(scope, f, 1); + jsCallData->thisObject = v4->globalObject->asReturnedValue(); + jsCallData->args[0] = status; + f->call(jsCallData); if (scope.hasException()) scope.engine->catchException(); } diff --git a/src/qml/jsruntime/qv4jscall_p.h b/src/qml/jsruntime/qv4jscall_p.h index a71d14ad6c..ed75fb7475 100644 --- a/src/qml/jsruntime/qv4jscall_p.h +++ b/src/qml/jsruntime/qv4jscall_p.h @@ -74,13 +74,6 @@ struct JSCallData { ptr->setArgc(argc); ptr->function = *function; } - JSCallData(const Scope &scope, Heap::FunctionObject *function, int argc = 0) - { - int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + argc; - ptr = reinterpret_cast<CallData *>(scope.alloc(size)); - ptr->setArgc(argc); - ptr->function = function; - } JSCallData(const Scope &scope, Value *argv, int argc, Value *thisObject = 0) { int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + argc; @@ -114,10 +107,6 @@ struct JSCallData { return ptr; } - ReturnedValue call() const { - return static_cast<FunctionObject &>(ptr->function).call(*this); - } - CallData *ptr; }; diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index cd365a1be9..7a4ae595ae 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -697,21 +697,21 @@ QString Stringify::Str(const QString &key, const Value &v) ScopedString s(scope, v4->newString(QStringLiteral("toJSON"))); ScopedFunctionObject toJSON(scope, o->get(s)); if (!!toJSON) { - JSCallData jsCall(scope, toJSON, 1); - jsCall->thisObject = value; - jsCall->args[0] = v4->newString(key); - value = jsCall.call(); + JSCallData jsCallData(scope, toJSON, 1); + jsCallData->thisObject = value; + jsCallData->args[0] = v4->newString(key); + value = toJSON->call(jsCallData); } } if (replacerFunction) { ScopedObject holder(scope, v4->newObject()); holder->put(scope.engine->id_empty(), value); - JSCallData jsCall(scope, replacerFunction, 2); - jsCall->args[0] = v4->newString(key); - jsCall->args[1] = value; - jsCall->thisObject = holder; - value = jsCall.call(); + JSCallData jsCallData(scope, replacerFunction, 2); + jsCallData->args[0] = v4->newString(key); + jsCallData->args[1] = value; + jsCallData->thisObject = holder; + value = replacerFunction->call(jsCallData); } o = value->asReturnedValue(); diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 780885869b..17667cbae6 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -400,9 +400,9 @@ ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const if (!getter) return Encode::undefined(); - JSCallData jsCall(scope, getter, 0); - jsCall->thisObject = object; - return jsCall.call(); + JSCallData jsCallData(scope, getter, 0); + jsCallData->thisObject = object; + return getter->call(jsCallData); } } l->getter = getterFallback; @@ -422,9 +422,9 @@ ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const if (!getter) return Encode::undefined(); - JSCallData jsCall(scope, getter, 0); - jsCall->thisObject = object; - return jsCall.call(); + JSCallData jsCallData(scope, getter, 0); + jsCallData->thisObject = object; + return getter->call(jsCallData); } } l->getter = getterFallback; @@ -447,9 +447,9 @@ ReturnedValue Lookup::getterAccessor2(Lookup *l, ExecutionEngine *engine, const if (!getter) return Encode::undefined(); - JSCallData jsCall(scope, getter, 0); - jsCall->thisObject = object; - return jsCall.call(); + JSCallData jsCallData(scope, getter, 0); + jsCallData->thisObject = object; + return getter->call(jsCallData); } } } @@ -502,9 +502,9 @@ ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engin if (!getter) return Encode::undefined(); - JSCallData jsCall(scope, getter, 0); - jsCall->thisObject = object; - return jsCall.call(); + JSCallData jsCallData(scope, getter, 0); + jsCallData->thisObject = object; + return getter->call(jsCallData); } } l->getter = getterGeneric; @@ -522,9 +522,9 @@ ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engin if (!getter) return Encode::undefined(); - JSCallData jsCall(scope, getter, 0); - jsCall->thisObject = object; - return jsCall.call(); + JSCallData jsCallData(scope, getter, 0); + jsCallData->thisObject = object; + return getter->call(jsCallData); } } l->getter = getterGeneric; @@ -641,8 +641,8 @@ ReturnedValue Lookup::globalGetterAccessor0(Lookup *l, ExecutionEngine *engine) if (!getter) return Encode::undefined(); - JSCallData jsCall(scope, getter, 0); - return jsCall.call(); + JSCallData jsCallData(scope, getter, 0); + return getter->call(jsCallData); } l->globalGetter = globalGetterGeneric; return globalGetterGeneric(l, engine); @@ -658,8 +658,8 @@ ReturnedValue Lookup::globalGetterAccessor1(Lookup *l, ExecutionEngine *engine) if (!getter) return Encode::undefined(); - JSCallData jsCall(scope, getter, 0); - return jsCall.call(); + JSCallData jsCallData(scope, getter, 0); + return getter->call(jsCallData); } l->globalGetter = globalGetterGeneric; return globalGetterGeneric(l, engine); @@ -678,8 +678,8 @@ ReturnedValue Lookup::globalGetterAccessor2(Lookup *l, ExecutionEngine *engine) if (!getter) return Encode::undefined(); - JSCallData jsCall(scope, getter, 0); - return jsCall.call(); + JSCallData jsCallData(scope, getter, 0); + return getter->call(jsCallData); } } } diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index e22b1dbe51..c52cad69d1 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -107,9 +107,9 @@ ReturnedValue Object::getValue(const Value &thisObject, const Value &v, Property return Encode::undefined(); Scope scope(f->engine()); - JSCallData jsCall(scope, f); - jsCall->thisObject = thisObject; - return jsCall.call(); + JSCallData jsCallData(scope, f); + jsCallData->thisObject = thisObject; + return f->call(jsCallData); } bool Object::putValue(uint memberIndex, const Value &value) @@ -125,10 +125,10 @@ bool Object::putValue(uint memberIndex, const Value &value) if (set) { Scope scope(ic->engine); ScopedFunctionObject setter(scope, set); - JSCallData jsCall(scope, setter, 1); - jsCall->args[0] = value; - jsCall->thisObject = this; - jsCall.call(); + JSCallData jsCallData(scope, setter, 1); + jsCallData->args[0] = value; + jsCallData->thisObject = this; + setter->call(jsCallData); return !ic->engine->hasException; } return false; @@ -764,10 +764,10 @@ bool Object::internalPut(String *name, const Value &value) Scope scope(engine); ScopedFunctionObject setter(scope, *memberIndex); - JSCallData jsCall(scope, setter, 1); - jsCall->args[0] = value; - jsCall->thisObject = this; - jsCall.call(); + JSCallData jsCallData(scope, setter, 1); + jsCallData->args[0] = value; + jsCallData->thisObject = this; + setter->call(jsCallData); return !engine->hasException; } @@ -829,10 +829,10 @@ bool Object::internalPutIndexed(uint index, const Value &value) Scope scope(engine); ScopedFunctionObject setter(scope, *arrayIndex); - JSCallData jsCall(scope, setter, 1); - jsCall->args[0] = value; - jsCall->thisObject = this; - jsCall.call(); + JSCallData jsCallData(scope, setter, 1); + jsCallData->args[0] = value; + jsCallData->thisObject = this; + setter->call(jsCallData); return !engine->hasException; } diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 73bcd76edf..198d7d285e 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -479,9 +479,9 @@ ReturnedValue ObjectPrototype::method_toLocaleString(const BuiltinFunction *b, C ScopedFunctionObject f(scope, o->get(scope.engine->id_toString())); if (!f) THROW_TYPE_ERROR(); - JSCallData jsCall(scope, f); - jsCall->thisObject = o; - return jsCall.call(); + JSCallData jsCallData(scope, f); + jsCallData->thisObject = o; + return f->call(jsCallData); } ReturnedValue ObjectPrototype::method_valueOf(const BuiltinFunction *b, CallData *callData) diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 8ac31cdfd0..a6c0218c2b 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -816,18 +816,18 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase QV4::Scope scope(v4); QV4::ScopedFunctionObject f(scope, This->function.value()); - QV4::JSCallData jsCall(scope, f, argCount); - jsCall->thisObject = This->thisObject.isUndefined() ? v4->globalObject->asReturnedValue() : This->thisObject.value(); + QV4::JSCallData jsCallData(scope, f, argCount); + jsCallData->thisObject = This->thisObject.isUndefined() ? v4->globalObject->asReturnedValue() : This->thisObject.value(); for (int ii = 0; ii < argCount; ++ii) { int type = argsTypes[ii + 1]; if (type == qMetaTypeId<QVariant>()) { - jsCall->args[ii] = v4->fromVariant(*((QVariant *)metaArgs[ii + 1])); + jsCallData->args[ii] = v4->fromVariant(*((QVariant *)metaArgs[ii + 1])); } else { - jsCall->args[ii] = v4->fromVariant(QVariant(type, metaArgs[ii + 1])); + jsCallData->args[ii] = v4->fromVariant(QVariant(type, metaArgs[ii + 1])); } } - jsCall.call(); + f->call(jsCallData); if (scope.hasException()) { QQmlError error = v4->catchExceptionAsQmlError(); if (error.description().isEmpty()) { diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 2a046da346..d9c898a357 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -426,16 +426,17 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeH qSwap(meth1, meth2); Scope scope(engine); + ScopedValue result(scope); ScopedValue conv(scope, object->get(meth1)); - JSCallData jsCall(scope, nullptr, 0); - jsCall->thisObject = *object; + JSCallData jsCallData(scope, nullptr, 0); + jsCallData->thisObject = *object; if (FunctionObject *o = conv->as<FunctionObject>()) { - jsCall->function = o; - jsCall->accumulator = jsCall.call(); - if (jsCall->accumulator.isPrimitive()) - return jsCall->accumulator.asReturnedValue(); + jsCallData->function = o; + result = o->call(jsCallData); + if (result->isPrimitive()) + return result->asReturnedValue(); } if (engine->hasException) @@ -443,10 +444,10 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeH conv = object->get(meth2); if (FunctionObject *o = conv->as<FunctionObject>()) { - jsCall->function = o; - jsCall->accumulator = jsCall.call(); - if (jsCall->accumulator.isPrimitive()) - return jsCall->accumulator.asReturnedValue(); + jsCallData->function = o; + result = o->call(jsCallData); + if (result->isPrimitive()) + return result->asReturnedValue(); } return engine->throwTypeError(); diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index eb6eabed6d..818711fc99 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -420,11 +420,11 @@ public: ScopedFunctionObject compare(scope, m_compareFn); if (!compare) return m_v4->throwTypeError(); - JSCallData jsCall(scope, compare, 2); - jsCall->args[0] = convertElementToValue(m_v4, lhs); - jsCall->args[1] = convertElementToValue(m_v4, rhs); - jsCall->thisObject = m_v4->globalObject; - QV4::ScopedValue result(scope, jsCall.call()); + JSCallData jsCallData(scope, compare, 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)); return result->toNumber() < 0; } diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index b7aefd3742..11fdcae6f8 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -583,8 +583,8 @@ ReturnedValue StringPrototype::method_replace(const BuiltinFunction *b, CallData if (!!searchCallback) { result.reserve(string.length() + 10*numStringMatches); ScopedValue entry(scope); - JSCallData jsCall(scope, searchCallback, numCaptures + 2); - jsCall->thisObject = Primitive::undefinedValue(); + JSCallData jsCallData(scope, searchCallback, numCaptures + 2); + jsCallData->thisObject = Primitive::undefinedValue(); int lastEnd = 0; for (int i = 0; i < numStringMatches; ++i) { for (int k = 0; k < numCaptures; ++k) { @@ -594,15 +594,15 @@ ReturnedValue StringPrototype::method_replace(const BuiltinFunction *b, CallData entry = Primitive::undefinedValue(); if (start != JSC::Yarr::offsetNoMatch && end != JSC::Yarr::offsetNoMatch) entry = scope.engine->newString(string.mid(start, end - start)); - jsCall->args[k] = entry; + jsCallData->args[k] = entry; } uint matchStart = matchOffsets[i * numCaptures * 2]; Q_ASSERT(matchStart >= static_cast<uint>(lastEnd)); uint matchEnd = matchOffsets[i * numCaptures * 2 + 1]; - jsCall->args[numCaptures] = Primitive::fromUInt32(matchStart); - jsCall->args[numCaptures + 1] = scope.engine->newString(string); + jsCallData->args[numCaptures] = Primitive::fromUInt32(matchStart); + jsCallData->args[numCaptures + 1] = scope.engine->newString(string); - replacement = jsCall.call(); + replacement = searchCallback->call(jsCallData); result += string.midRef(lastEnd, matchStart - lastEnd); result += replacement->toQString(); lastEnd = matchEnd; @@ -644,9 +644,9 @@ ReturnedValue StringPrototype::method_search(const BuiltinFunction *b, CallData RegExpObject *regExp = regExpObj->as<RegExpObject>(); if (!regExp) { - JSCallData jsCallData(scope, scope.engine->regExpCtor(), 1); - jsCallData->args[0] = regExpObj; - regExpObj = scope.engine->regExpCtor()->callAsConstructor(jsCallData); + JSCallData jsCallDataData(scope, scope.engine->regExpCtor(), 1); + jsCallDataData->args[0] = regExpObj; + regExpObj = scope.engine->regExpCtor()->callAsConstructor(jsCallDataData); if (scope.engine->hasException) return QV4::Encode::undefined(); diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 5611bed2c3..e64d72a5ca 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1547,10 +1547,10 @@ void QV4::QmlIncubatorObject::statusChanged(QQmlIncubator::Status s) QV4::ScopedFunctionObject f(scope, d()->statusChanged); if (f) { - QV4::JSCallData jsCall(scope, f, 1); - jsCall->thisObject = this; - jsCall->args[0] = QV4::Primitive::fromUInt32(s); - jsCall.call(); + QV4::JSCallData jsCallData(scope, f, 1); + jsCallData->thisObject = this; + jsCallData->args[0] = QV4::Primitive::fromUInt32(s); + f->call(jsCallData); if (scope.hasException()) { QQmlError error = scope.engine->catchExceptionAsQmlError(); QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error); diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index e8e13ee352..9d570f18b0 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -67,14 +67,14 @@ void QQmlDelayedCallQueue::DelayedFunctionCall::execute(QV4::ExecutionEngine *en const QV4::FunctionObject *callback = m_function.as<QV4::FunctionObject>(); Q_ASSERT(callback); const int argCount = array ? array->getLength() : 0; - QV4::JSCallData jsCall(scope, callback, argCount); - jsCall->thisObject = QV4::Encode::undefined(); + QV4::JSCallData jsCallData(scope, callback, argCount); + jsCallData->thisObject = QV4::Encode::undefined(); for (int i = 0; i < argCount; i++) { - jsCall->args[i] = array->getIndexed(i); + jsCallData->args[i] = array->getIndexed(i); } - jsCall.call(); + callback->call(jsCallData); if (scope.engine->hasException) { QQmlError error = scope.engine->catchExceptionAsQmlError(); diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index d6f7b18744..efd67bc446 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -950,13 +950,13 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * } const unsigned int parameterCount = function->formalParameterCount(); - QV4::JSCallData jsCall(scope, function, parameterCount); - jsCall->thisObject = ep->v8engine()->global(); + QV4::JSCallData jsCallData(scope, function, parameterCount); + jsCallData->thisObject = ep->v8engine()->global(); for (uint ii = 0; ii < parameterCount; ++ii) - jsCall->args[ii] = scope.engine->fromVariant(*(QVariant *)a[ii + 1]); + jsCallData->args[ii] = scope.engine->fromVariant(*(QVariant *)a[ii + 1]); - QV4::ScopedValue result(scope, jsCall.call()); + QV4::ScopedValue result(scope, function->call(jsCallData)); if (scope.hasException()) { QQmlError error = scope.engine->catchExceptionAsQmlError(); if (error.isValid()) diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index b22fe7b5ea..35c6d2f0b7 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1576,7 +1576,8 @@ void QQmlXMLHttpRequest::dispatchCallback(Object *thisObj, QQmlContextData *cont return; } - QV4::JSCallData(scope, callback).call(); + QV4::JSCallData jsCallData(scope, callback); + callback->call(jsCallData); if (scope.engine->hasException) { QQmlError error = scope.engine->catchExceptionAsQmlError(); diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 8cabf062df..64949ef5ae 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -248,10 +248,10 @@ void QQuickWorkerScriptEnginePrivate::WorkerEngine::init() QV4::ScopedString name(scope, m_v4Engine->newString(QStringLiteral("sendMessage"))); QV4::ScopedValue function(scope, QV4::BuiltinFunction::create(globalContext, name, QQuickWorkerScriptEnginePrivate::method_sendMessage)); - QV4::JSCallData jsCall(scope, createsendconstructor, 1); - jsCall->args[0] = function; - jsCall->thisObject = global(); - createsend.set(scope.engine, jsCall.call()); + QV4::JSCallData jsCallData(scope, createsendconstructor, 1); + jsCallData->args[0] = function; + jsCallData->thisObject = global(); + createsend.set(scope.engine, createsendconstructor->call(jsCallData)); } // Requires handle and context scope @@ -265,10 +265,10 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(i QV4::ScopedFunctionObject f(scope, createsend.value()); QV4::ScopedValue v(scope); - QV4::JSCallData jsCall(scope, f, 1); - jsCall->args[0] = QV4::Primitive::fromInt32(id); - jsCall->thisObject = global(); - v = jsCall.call(); + QV4::JSCallData jsCallData(scope, f, 1); + jsCallData->args[0] = QV4::Primitive::fromInt32(id); + jsCallData->thisObject = global(); + v = f->call(jsCallData); if (scope.hasException()) v = scope.engine->catchException(); return v->asReturnedValue(); @@ -366,11 +366,11 @@ void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &d QV4::Scoped<QV4::QmlContext> qmlContext(scope, script->qmlContext.value()); Q_ASSERT(!!qmlContext); - QV4::JSCallData jsCall(scope, f, 2); - jsCall->thisObject = workerEngine->global(); - jsCall->args[0] = qmlContext->d()->qml(); // ### - jsCall->args[1] = value; - jsCall.call(); + QV4::JSCallData jsCallData(scope, f, 2); + jsCallData->thisObject = workerEngine->global(); + jsCallData->args[0] = qmlContext->d()->qml(); // ### + jsCallData->args[1] = value; + f->call(jsCallData); if (scope.hasException()) { QQmlError error = scope.engine->catchExceptionAsQmlError(); reportScriptException(script, error); diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 14bf328f5a..206d08e4e9 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -2349,10 +2349,10 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::Value &o, const scope.engine->catchException(); return true; } - QV4::JSCallData jsCall(scope, function, 1); - jsCall->args[0] = o; - jsCall->thisObject = engine->global(); - jsCall.call(); + QV4::JSCallData jsCallData(scope, function, 1); + jsCallData->args[0] = o; + jsCallData->thisObject = engine->global(); + function->call(jsCallData); if (scope.engine->hasException) { scope.engine->catchException(); return true; @@ -2379,10 +2379,10 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::Value &o, return false; QV4::ScopedValue value(scope); - QV4::JSCallData jsCall(scope, function, 1); - jsCall->args[0] = o; - jsCall->thisObject = engine->global(); - value = jsCall.call(); + QV4::JSCallData jsCallData(scope, function, 1); + jsCallData->args[0] = o; + jsCallData->thisObject = engine->global(); + value = function->call(jsCallData); if (scope.engine->hasException) { scope.engine->catchException(); return false; @@ -2408,10 +2408,10 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::Value &o } if (!function) return QV4::Encode::undefined(); - QV4::JSCallData jsCall(scope, function, 1); - jsCall->args[0] = o; - jsCall->thisObject = engine->global(); - QV4::ScopedValue result(scope, jsCall.call()); + QV4::JSCallData jsCallData(scope, function, 1); + jsCallData->args[0] = o; + jsCallData->thisObject = engine->global(); + QV4::ScopedValue result(scope, function->call(jsCallData)); if (scope.engine->hasException) { scope.engine->catchException(); return QV4::Encode::undefined(); |