diff options
34 files changed, 1123 insertions, 1086 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 739d37bb39..4ca0222cf4 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -127,8 +127,7 @@ DEFINE_MANAGED_VTABLE(QQmlSqlDatabaseWrapper); static ReturnedValue qmlsqldatabase_version(SimpleCallContext *ctx) { QV4::Scope scope(ctx); - - QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->type != QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); @@ -138,8 +137,7 @@ static ReturnedValue qmlsqldatabase_version(SimpleCallContext *ctx) static ReturnedValue qmlsqldatabase_rows_length(SimpleCallContext *ctx) { QV4::Scope scope(ctx); - - QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->type != QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); @@ -158,8 +156,7 @@ static ReturnedValue qmlsqldatabase_rows_length(SimpleCallContext *ctx) static ReturnedValue qmlsqldatabase_rows_forwardOnly(SimpleCallContext *ctx) { QV4::Scope scope(ctx); - - QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->type != QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); return Encode(r->sqlQuery.isForwardOnly()); @@ -168,14 +165,13 @@ static ReturnedValue qmlsqldatabase_rows_forwardOnly(SimpleCallContext *ctx) static ReturnedValue qmlsqldatabase_rows_setForwardOnly(SimpleCallContext *ctx) { QV4::Scope scope(ctx); - - QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->type != QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - if (ctx->argumentCount < 1) + if (ctx->callData->argc < 1) ctx->throwTypeError(); - r->sqlQuery.setForwardOnly(ctx->arguments[0].toBoolean()); + r->sqlQuery.setForwardOnly(ctx->callData->args[0].toBoolean()); return Encode::undefined(); } @@ -199,7 +195,7 @@ static QString qmlsqldatabase_databaseFile(const QString& connectionName, QV8Eng return qmlsqldatabase_databasesPath(engine) + QDir::separator() + connectionName; } -static ReturnedValue qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, ExecutionEngine *v4, quint32 index, bool *hasProperty = 0) +static ReturnedValue qmlsqldatabase_rows_index(QV4::Referenced<QQmlSqlDatabaseWrapper> r, ExecutionEngine *v4, quint32 index, bool *hasProperty = 0) { Scope scope(v4); QV8Engine *v8 = v4->v8Engine; @@ -226,7 +222,8 @@ static ReturnedValue qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, Execut ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(Managed *m, uint index, bool *hasProperty) { - QQmlSqlDatabaseWrapper *r = m->as<QQmlSqlDatabaseWrapper>(); + QV4::Scope scope(m->engine()); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, m->as<QQmlSqlDatabaseWrapper>()); if (!r || r->type != QQmlSqlDatabaseWrapper::Rows) return Object::getIndexed(m, index, hasProperty); @@ -236,17 +233,17 @@ ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(Managed *m, uint index, bool *h static ReturnedValue qmlsqldatabase_rows_item(SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->type != QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - return qmlsqldatabase_rows_index(r, ctx->engine, ctx->argumentCount ? ctx->arguments[0].toUInt32() : 0); + return qmlsqldatabase_rows_index(r, ctx->engine, ctx->callData->argc ? ctx->callData->args[0].toUInt32() : 0); } static ReturnedValue qmlsqldatabase_executeSql(SimpleCallContext *ctx) { QV4::Scope scope(ctx); - Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->thisObject); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->type != QQmlSqlDatabaseWrapper::Query) V4THROW_REFERENCE("Not a SQLDatabase::Query object"); @@ -257,7 +254,7 @@ static ReturnedValue qmlsqldatabase_executeSql(SimpleCallContext *ctx) QSqlDatabase db = r->database; - QString sql = ctx->argumentCount ? ctx->arguments[0].toQString() : QString(); + QString sql = ctx->callData->argc ? ctx->callData->args[0].toQString() : QString(); if (r->readonly && !sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) { V4THROW_SQL(SQLEXCEPTION_SYNTAX_ERR, QQmlEngine::tr("Read-only Transaction")); @@ -269,8 +266,8 @@ static ReturnedValue qmlsqldatabase_executeSql(SimpleCallContext *ctx) ScopedValue result(scope, Value::undefinedValue()); if (query.prepare(sql)) { - if (ctx->argumentCount > 1) { - ScopedValue values(scope, ctx->arguments[1]); + if (ctx->callData->argc > 1) { + ScopedValue values(scope, ctx->callData->args[1]); if (ArrayObject *array = values->asArrayObject()) { quint32 size = array->arrayLength(); QV4::ScopedValue v(scope); @@ -327,20 +324,20 @@ static ReturnedValue qmlsqldatabase_executeSql(SimpleCallContext *ctx) static ReturnedValue qmlsqldatabase_changeVersion(SimpleCallContext *ctx) { - if (ctx->argumentCount < 2) + if (ctx->callData->argc < 2) return Encode::undefined(); Scope scope(ctx); - Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->thisObject); + Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject); if (!r || r->type != QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); QV8Engine *engine = ctx->engine->v8Engine; QSqlDatabase db = r->database; - QString from_version = ctx->arguments[0].toQString(); - QString to_version = ctx->arguments[1].toQString(); + QString from_version = ctx->callData->args[0].toQString(); + QString to_version = ctx->callData->args[1].toQString(); Scoped<FunctionObject> callback(scope, ctx->argument(2)); if (from_version != r->version) @@ -392,13 +389,13 @@ static ReturnedValue qmlsqldatabase_changeVersion(SimpleCallContext *ctx) static ReturnedValue qmlsqldatabase_transaction_shared(SimpleCallContext *ctx, bool readOnly) { QV4::Scope scope(ctx); - QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->type != QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); QV8Engine *engine = ctx->engine->v8Engine; - FunctionObject *callback = ctx->argumentCount ? ctx->arguments[0].asFunctionObject() : 0; + FunctionObject *callback = ctx->callData->argc ? ctx->callData->args[0].asFunctionObject() : 0; if (!callback) V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR, QQmlEngine::tr("transaction: missing callback")); diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp index 71ca4d31d0..ac19e025f6 100644 --- a/src/particles/qquickv4particledata.cpp +++ b/src/particles/qquickv4particledata.cpp @@ -300,7 +300,8 @@ public: static QV4::ReturnedValue particleData_discard(QV4::SimpleCallContext *ctx) { - QV4ParticleData *r = ctx->thisObject.as<QV4ParticleData>(); + QV4::Scope scope(ctx); + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); if (!r || !r->datum) ctx->throwError(QStringLiteral("Not a valid ParticleData object")); @@ -311,7 +312,9 @@ static QV4::ReturnedValue particleData_discard(QV4::SimpleCallContext *ctx) static QV4::ReturnedValue particleData_lifeLeft(QV4::SimpleCallContext *ctx) { - QV4ParticleData *r = ctx->thisObject.as<QV4ParticleData>(); + QV4::Scope scope(ctx); + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); + if (!r || !r->datum) ctx->throwError(QStringLiteral("Not a valid ParticleData object")); @@ -320,7 +323,9 @@ static QV4::ReturnedValue particleData_lifeLeft(QV4::SimpleCallContext *ctx) static QV4::ReturnedValue particleData_curSize(QV4::SimpleCallContext *ctx) { - QV4ParticleData *r = ctx->thisObject.as<QV4ParticleData>(); + QV4::Scope scope(ctx); + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); + if (!r || !r->datum) ctx->throwError(QStringLiteral("Not a valid ParticleData object")); @@ -329,7 +334,7 @@ static QV4::ReturnedValue particleData_curSize(QV4::SimpleCallContext *ctx) #define COLOR_GETTER_AND_SETTER(VAR, NAME) static QV4::ReturnedValue particleData_get_ ## NAME (QV4::SimpleCallContext *ctx) \ { \ QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject); \ + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \ if (!r || !r->datum) \ ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \ \ @@ -339,11 +344,11 @@ static QV4::ReturnedValue particleData_curSize(QV4::SimpleCallContext *ctx) static QV4::ReturnedValue particleData_set_ ## NAME (QV4::SimpleCallContext *ctx)\ {\ QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject); \ + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \ if (!r || !r->datum)\ ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\ \ - double d = ctx->argumentCount ? ctx->arguments[0].toNumber() : 0; \ + double d = ctx->callData->argc ? ctx->callData->args[0].toNumber() : 0; \ r->datum->color. VAR = qMin(255, qMax(0, (int)floor(d * 255.0)));\ return QV4::Encode::undefined(); \ } @@ -352,7 +357,7 @@ static QV4::ReturnedValue particleData_set_ ## NAME (QV4::SimpleCallContext *ctx #define SEMIBOOL_GETTER_AND_SETTER(VARIABLE) static QV4::ReturnedValue particleData_get_ ## VARIABLE (QV4::SimpleCallContext *ctx) \ { \ QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject); \ + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \ if (!r || !r->datum) \ ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \ \ @@ -362,18 +367,18 @@ static QV4::ReturnedValue particleData_set_ ## NAME (QV4::SimpleCallContext *ctx static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::SimpleCallContext *ctx)\ {\ QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject); \ + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \ if (!r || !r->datum)\ ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\ \ - r->datum-> VARIABLE = (ctx->argumentCount && ctx->arguments[0].toBoolean()) ? 1.0 : 0.0;\ + r->datum-> VARIABLE = (ctx->callData->argc && ctx->callData->args[0].toBoolean()) ? 1.0 : 0.0;\ return QV4::Encode::undefined(); \ } #define FLOAT_GETTER_AND_SETTER(VARIABLE) static QV4::ReturnedValue particleData_get_ ## VARIABLE (QV4::SimpleCallContext *ctx) \ { \ QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject); \ + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \ if (!r || !r->datum) \ ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \ \ @@ -383,18 +388,18 @@ static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::SimpleCallContext static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::SimpleCallContext *ctx)\ {\ QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject); \ + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \ if (!r || !r->datum)\ ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\ \ - r->datum-> VARIABLE = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN();\ + r->datum-> VARIABLE = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();\ return QV4::Encode::undefined(); \ } #define FAKE_FLOAT_GETTER_AND_SETTER(VARIABLE, GETTER, SETTER) static QV4::ReturnedValue particleData_get_ ## VARIABLE (QV4::SimpleCallContext *ctx) \ { \ QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject); \ + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \ if (!r || !r->datum) \ ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \ \ @@ -404,11 +409,11 @@ static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::SimpleCallContext static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::SimpleCallContext *ctx)\ {\ QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject); \ + QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \ if (!r || !r->datum)\ ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\ \ - r->datum-> SETTER (ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN());\ + r->datum-> SETTER (ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN());\ return QV4::Encode::undefined(); \ } diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp index aded593671..41da2c7c3b 100644 --- a/src/qml/compiler/qv4isel_masm.cpp +++ b/src/qml/compiler/qv4isel_masm.cpp @@ -279,8 +279,8 @@ Assembler::Pointer Assembler::loadTempAddress(RegisterID reg, V4IR::Temp *t) switch (t->kind) { case V4IR::Temp::Formal: case V4IR::Temp::ScopedFormal: { - loadPtr(Address(context, qOffsetOf(CallContext, arguments)), reg); - offset = t->index * sizeof(Value); + loadPtr(Address(context, qOffsetOf(CallContext, callData)), reg); + offset = sizeof(CallData) + (t->index - 1) * sizeof(Value); } break; case V4IR::Temp::Local: case V4IR::Temp::ScopedLocal: { @@ -952,12 +952,13 @@ void InstructionSelection::callValue(V4IR::Temp *value, V4IR::ExprList *args, V4 void InstructionSelection::loadThisObject(V4IR::Temp *temp) { + _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(CallContext, callData)), Assembler::ScratchRegister); #if defined(VALUE_FITS_IN_REGISTER) - _as->load64(Pointer(Assembler::ContextRegister, qOffsetOf(ExecutionContext, thisObject)), + _as->load64(Pointer(Assembler::ScratchRegister, qOffsetOf(CallData, thisObject)), Assembler::ReturnValueRegister); _as->storeReturnValue(temp); #else - _as->copyValue(temp, Pointer(Assembler::ContextRegister, qOffsetOf(ExecutionContext, thisObject))); + _as->copyValue(temp, Pointer(Assembler::ScratchRegister, qOffsetOf(CallData, thisObject))); #endif } diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index be4fbe60b8..34ccd0af49 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -64,28 +64,28 @@ ArgumentsObject::ArgumentsObject(CallContext *context) memberData[CalleePropertyIndex] = pd; memberData[CallerPropertyIndex] = pd; - arrayReserve(context->argumentCount); - for (unsigned int i = 0; i < context->argumentCount; ++i) - arrayData[i].value = context->arguments[i]; - arrayDataLen = context->argumentCount; + arrayReserve(context->callData->argc); + for (unsigned int i = 0; i < context->callData->argc; ++i) + arrayData[i].value = context->callData->args[i]; + arrayDataLen = context->callData->argc; } else { internalClass = engine()->argumentsObjectClass; Q_ASSERT(CalleePropertyIndex == internalClass->find(context->engine->id_callee)); memberData[CalleePropertyIndex].value = Value::fromObject(context->function); isNonStrictArgumentsObject = true; - uint numAccessors = qMin(context->function->formalParameterCount, context->realArgumentCount); - uint argCount = qMin((uint)context->realArgumentCount, context->argumentCount); + uint numAccessors = qMin((int)context->function->formalParameterCount, context->realArgumentCount); + uint argCount = qMin(context->realArgumentCount, context->callData->argc); arrayReserve(argCount); ensureArrayAttributes(); context->engine->requireArgumentsAccessors(numAccessors); for (uint i = 0; i < (uint)numAccessors; ++i) { - mappedArguments.append(context->arguments[i]); + mappedArguments.append(context->callData->args[i]); arrayData[i] = context->engine->argumentsAccessors.at(i); arrayAttributes[i] = Attr_Accessor; } for (uint i = numAccessors; i < argCount; ++i) { - arrayData[i] = Property::fromValue(context->arguments[i]); + arrayData[i] = Property::fromValue(context->callData->args[i]); arrayAttributes[i] = Attr_Data; } arrayDataLen = argCount; @@ -155,7 +155,7 @@ ReturnedValue ArgumentsGetterFunction::call(Managed *getter, CallData *callData) if (!o) getter->engine()->current->throwTypeError(); - assert(g->index < o->context->argumentCount); + assert(g->index < o->context->callData->argc); return o->context->argument(g->index); } @@ -171,8 +171,8 @@ ReturnedValue ArgumentsSetterFunction::call(Managed *setter, CallData *callData) if (!o) setter->engine()->current->throwTypeError(); - assert(s->index < o->context->argumentCount); - o->context->arguments[s->index] = callData->argc ? callData->args[0] : Value::undefinedValue(); + assert(s->index < o->context->callData->argc); + o->context->callData->args[s->index] = callData->argc ? callData->args[0] : Value::undefinedValue(); return Value::undefinedValue().asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 44687463e2..2c5670ef92 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -131,19 +131,19 @@ uint ArrayPrototype::getLength(ExecutionContext *ctx, Object *o) ReturnedValue ArrayPrototype::method_isArray(SimpleCallContext *ctx) { - bool isArray = ctx->argumentCount ? ctx->arguments[0].asArrayObject() : false; + bool isArray = ctx->callData->argc ? ctx->callData->args[0].asArrayObject() : false; return Encode(isArray); } ReturnedValue ArrayPrototype::method_toString(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->thisObject, ScopedObject::Convert); + ScopedObject o(scope, ctx->callData->thisObject, ScopedObject::Convert); ScopedString s(scope, ctx->engine->newString("join")); ScopedFunctionObject f(scope, o->get(s)); if (!!f) { ScopedCallData d(scope, 0); - d->thisObject = ctx->thisObject; + d->thisObject = ctx->callData->thisObject; return f->call(d); } return ObjectPrototype::method_toString(ctx); @@ -159,7 +159,7 @@ ReturnedValue ArrayPrototype::method_concat(SimpleCallContext *ctx) Scope scope(ctx); Scoped<ArrayObject> result(scope, ctx->engine->newArrayObject()); - ScopedObject thisObject(scope, ctx->thisObject.toObject(ctx)); + ScopedObject thisObject(scope, ctx->callData->thisObject.toObject(ctx)); ScopedArrayObject instance(scope, thisObject); if (instance) { result->copyArrayData(instance.getPointer()); @@ -168,12 +168,12 @@ ReturnedValue ArrayPrototype::method_concat(SimpleCallContext *ctx) } ScopedArrayObject elt(scope); - for (uint i = 0; i < ctx->argumentCount; ++i) { - elt = ctx->arguments[i]; + for (uint i = 0; i < ctx->callData->argc; ++i) { + elt = ctx->callData->args[i]; if (elt) result->arrayConcat(elt.getPointer()); else - result->arraySet(getLength(ctx, result.getPointer()), ctx->arguments[i]); + result->arraySet(getLength(ctx, result.getPointer()), ctx->callData->args[i]); } return result.asReturnedValue(); @@ -190,7 +190,7 @@ ReturnedValue ArrayPrototype::method_join(SimpleCallContext *ctx) else r4 = arg->toQString(); - ScopedObject self(scope, ctx->thisObject); + ScopedObject self(scope, ctx->callData->thisObject); ScopedValue length(scope, self->get(ctx->engine->id_length)); const quint32 r2 = length->isUndefined() ? 0 : length->toUInt32(); @@ -237,7 +237,7 @@ ReturnedValue ArrayPrototype::method_join(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_pop(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); if (!len) { @@ -259,18 +259,18 @@ ReturnedValue ArrayPrototype::method_pop(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_push(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); - if (len + ctx->argumentCount < len) { + if (len + ctx->callData->argc < len) { // ughh... double l = len; ScopedString s(scope); - for (int i = 0; i < ctx->argumentCount; ++i) { + for (int i = 0; i < ctx->callData->argc; ++i) { s = Value::fromDouble(l + i).toString(ctx); - instance->put(s, ctx->arguments[i]); + instance->put(s, ctx->callData->args[i]); } - double newLen = l + ctx->argumentCount; + double newLen = l + ctx->callData->argc; if (!instance->isArrayObject()) instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(newLen))); else @@ -279,24 +279,24 @@ ReturnedValue ArrayPrototype::method_push(SimpleCallContext *ctx) } if (!instance->protoHasArray() && instance->arrayDataLen <= len) { - for (uint i = 0; i < ctx->argumentCount; ++i) { + for (uint i = 0; i < ctx->callData->argc; ++i) { if (!instance->sparseArray) { if (len >= instance->arrayAlloc) instance->arrayReserve(len + 1); - instance->arrayData[len].value = ctx->arguments[i]; + instance->arrayData[len].value = ctx->callData->args[i]; if (instance->arrayAttributes) instance->arrayAttributes[len] = Attr_Data; instance->arrayDataLen = len + 1; } else { - uint i = instance->allocArrayValue(ctx->arguments[i]); + uint i = instance->allocArrayValue(ctx->callData->args[i]); instance->sparseArray->push_back(i, len); } ++len; } } else { - for (uint i = 0; i < ctx->argumentCount; ++i) - instance->putIndexed(len + i, ctx->arguments[i]); - len += ctx->argumentCount; + for (uint i = 0; i < ctx->callData->argc; ++i) + instance->putIndexed(len + i, ctx->callData->args[i]); + len += ctx->callData->argc; } if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len); @@ -309,7 +309,7 @@ ReturnedValue ArrayPrototype::method_push(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_reverse(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); uint length = getLength(ctx, instance.getPointer()); int lo = 0, hi = length - 1; @@ -335,7 +335,7 @@ ReturnedValue ArrayPrototype::method_reverse(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_shift(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); if (!len) { @@ -389,7 +389,7 @@ ReturnedValue ArrayPrototype::method_shift(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_slice(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->thisObject.toObject(ctx)); + ScopedObject o(scope, ctx->callData->thisObject.toObject(ctx)); Scoped<ArrayObject> result(scope, ctx->engine->newArrayObject()); uint len = getLength(ctx, o.getPointer()); @@ -402,8 +402,8 @@ ReturnedValue ArrayPrototype::method_slice(SimpleCallContext *ctx) else start = (uint) s; uint end = len; - if (ctx->argumentCount > 1 && !ctx->arguments[1].isUndefined()) { - double e = ctx->arguments[1].toInteger(); + if (ctx->callData->argc > 1 && !ctx->callData->args[1].isUndefined()) { + double e = ctx->callData->args[1].toInteger(); if (e < 0) end = (uint)qMax(len + e, 0.); else if (e > len) @@ -428,19 +428,19 @@ ReturnedValue ArrayPrototype::method_slice(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_sort(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<Object> instance(scope, ctx->thisObject.toObject(ctx)); + Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); ScopedValue comparefn(scope, ctx->argument(0)); instance->arraySort(ctx, instance, comparefn, len); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } ReturnedValue ArrayPrototype::method_splice(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); Scoped<ArrayObject> newArray(scope, ctx->engine->newArrayObject()); @@ -461,7 +461,7 @@ ReturnedValue ArrayPrototype::method_splice(SimpleCallContext *ctx) } newArray->setArrayLengthUnchecked(deleteCount); - uint itemCount = ctx->argumentCount < 2 ? 0 : ctx->argumentCount - 2; + uint itemCount = ctx->callData->argc < 2 ? 0 : ctx->callData->argc - 2; ScopedValue v(scope); if (itemCount < deleteCount) { @@ -489,7 +489,7 @@ ReturnedValue ArrayPrototype::method_splice(SimpleCallContext *ctx) } for (uint i = 0; i < itemCount; ++i) - instance->putIndexed(start + i, ctx->arguments[i + 2]); + instance->putIndexed(start + i, ctx->callData->args[i + 2]); ctx->strictMode = true; instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(len - deleteCount + itemCount))); @@ -500,12 +500,12 @@ ReturnedValue ArrayPrototype::method_splice(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_unshift(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); ScopedValue v(scope); if (!instance->protoHasArray() && instance->arrayDataLen <= len) { - for (int i = ctx->argumentCount - 1; i >= 0; --i) { + for (int i = ctx->callData->argc - 1; i >= 0; --i) { v = ctx->argument(i); if (!instance->sparseArray) { @@ -530,15 +530,15 @@ ReturnedValue ArrayPrototype::method_unshift(SimpleCallContext *ctx) bool exists; v = instance->getIndexed(k - 1, &exists); if (exists) - instance->putIndexed(k + ctx->argumentCount - 1, v); + instance->putIndexed(k + ctx->callData->argc - 1, v); else - instance->deleteIndexedProperty(k + ctx->argumentCount - 1); + instance->deleteIndexedProperty(k + ctx->callData->argc - 1); } - for (uint i = 0; i < ctx->argumentCount; ++i) - instance->putIndexed(i, ctx->arguments[i]); + for (uint i = 0; i < ctx->callData->argc; ++i) + instance->putIndexed(i, ctx->callData->args[i]); } - uint newLen = len + ctx->argumentCount; + uint newLen = len + ctx->callData->argc; if (instance->isArrayObject()) instance->setArrayLengthUnchecked(newLen); else @@ -551,7 +551,7 @@ ReturnedValue ArrayPrototype::method_indexOf(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); if (!len) return Value::fromInt32(-1).asReturnedValue(); @@ -559,13 +559,13 @@ ReturnedValue ArrayPrototype::method_indexOf(SimpleCallContext *ctx) ScopedValue searchValue(scope); uint fromIndex = 0; - if (ctx->argumentCount >= 1) - searchValue = ctx->arguments[0]; + if (ctx->callData->argc >= 1) + searchValue = ctx->callData->args[0]; else searchValue = Value::undefinedValue(); - if (ctx->argumentCount >= 2) { - double f = ctx->arguments[1].toInteger(); + if (ctx->callData->argc >= 2) { + double f = ctx->callData->args[1].toInteger(); if (f >= len) return Encode(-1); if (f < 0) @@ -591,7 +591,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); if (!len) return Value::fromInt32(-1).asReturnedValue(); @@ -599,13 +599,13 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(SimpleCallContext *ctx) ScopedValue searchValue(scope); uint fromIndex = len; - if (ctx->argumentCount >= 1) + if (ctx->callData->argc >= 1) searchValue = ctx->argument(0); else searchValue = Value::undefinedValue(); - if (ctx->argumentCount >= 2) { - double f = ctx->arguments[1].toInteger(); + if (ctx->callData->argc >= 2) { + double f = ctx->callData->args[1].toInteger(); if (f > 0) f = qMin(f, (double)(len - 1)); else if (f < 0) { @@ -630,7 +630,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_every(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<Object> instance(scope, ctx->thisObject.toObject(ctx)); + Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); @@ -662,7 +662,7 @@ ReturnedValue ArrayPrototype::method_every(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_some(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<Object> instance(scope, ctx->thisObject.toObject(ctx)); + Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); @@ -693,7 +693,7 @@ ReturnedValue ArrayPrototype::method_some(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_forEach(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<Object> instance(scope, ctx->thisObject.toObject(ctx)); + Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); @@ -722,7 +722,7 @@ ReturnedValue ArrayPrototype::method_forEach(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_map(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<Object> instance(scope, ctx->thisObject.toObject(ctx)); + Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); @@ -757,7 +757,7 @@ ReturnedValue ArrayPrototype::method_map(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_filter(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<Object> instance(scope, ctx->thisObject.toObject(ctx)); + Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); @@ -796,7 +796,7 @@ ReturnedValue ArrayPrototype::method_filter(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_reduce(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<Object> instance(scope, ctx->thisObject.toObject(ctx)); + Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); @@ -808,7 +808,7 @@ ReturnedValue ArrayPrototype::method_reduce(SimpleCallContext *ctx) ScopedValue acc(scope); ScopedValue v(scope); - if (ctx->argumentCount > 1) { + if (ctx->callData->argc > 1) { acc = ctx->argument(1); } else { bool kPresent = false; @@ -844,7 +844,7 @@ ReturnedValue ArrayPrototype::method_reduce(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_reduceRight(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<Object> instance(scope, ctx->thisObject.toObject(ctx)); + Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx)); uint len = getLength(ctx, instance.getPointer()); @@ -853,7 +853,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(SimpleCallContext *ctx) ctx->throwTypeError(); if (len == 0) { - if (ctx->argumentCount == 1) + if (ctx->callData->argc == 1) ctx->throwTypeError(); return ctx->argument(1); } @@ -861,7 +861,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(SimpleCallContext *ctx) uint k = len; ScopedValue acc(scope); ScopedValue v(scope); - if (ctx->argumentCount > 1) { + if (ctx->callData->argc > 1) { acc = ctx->argument(1); } else { bool kPresent = false; diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp index be801a67c2..7e0831232c 100644 --- a/src/qml/jsruntime/qv4booleanobject.cpp +++ b/src/qml/jsruntime/qv4booleanobject.cpp @@ -77,10 +77,10 @@ void BooleanPrototype::init(ExecutionEngine *engine, const Value &ctor) ReturnedValue BooleanPrototype::method_toString(SimpleCallContext *ctx) { bool result; - if (ctx->thisObject.isBoolean()) { - result = ctx->thisObject.booleanValue(); + if (ctx->callData->thisObject.isBoolean()) { + result = ctx->callData->thisObject.booleanValue(); } else { - BooleanObject *thisObject = ctx->thisObject.asBooleanObject(); + BooleanObject *thisObject = ctx->callData->thisObject.asBooleanObject(); if (!thisObject) ctx->throwTypeError(); result = thisObject->value.booleanValue(); @@ -91,7 +91,7 @@ ReturnedValue BooleanPrototype::method_toString(SimpleCallContext *ctx) ReturnedValue BooleanPrototype::method_valueOf(SimpleCallContext *ctx) { - BooleanObject *thisObject = ctx->thisObject.asBooleanObject(); + BooleanObject *thisObject = ctx->callData->thisObject.asBooleanObject(); if (!thisObject) ctx->throwTypeError(); diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 8d07c5220a..ae9a72d760 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -51,7 +51,7 @@ using namespace QV4; -CallContext *ExecutionContext::newCallContext(void *stackSpace, FunctionObject *function, CallData *callData) +CallContext *ExecutionContext::newCallContext(void *stackSpace, Value *locals, FunctionObject *function, CallData *callData) { CallContext *c = (CallContext *)stackSpace; #ifndef QT_NO_DEBUG @@ -63,11 +63,8 @@ CallContext *ExecutionContext::newCallContext(void *stackSpace, FunctionObject * c->initBaseContext(Type_CallContext, engine, this); c->function = function; - // ### - c->arguments = const_cast<SafeValue *>(callData->args); + c->callData = callData; c->realArgumentCount = callData->argc; - c->argumentCount = callData->argc; - c->thisObject = callData->thisObject; c->strictMode = function->strictMode; c->marked = false; @@ -85,7 +82,7 @@ CallContext *ExecutionContext::newCallContext(void *stackSpace, FunctionObject * c->runtimeStrings = c->compilationUnit->runtimeStrings; } - c->locals = (Value *)(c + 1); + c->locals = locals; if (function->varCount) std::fill(c->locals, c->locals + function->varCount, Value::undefinedValue()); @@ -94,8 +91,8 @@ CallContext *ExecutionContext::newCallContext(void *stackSpace, FunctionObject * #ifndef QT_NO_DEBUG Q_ASSERT(function->formalParameterCount <= QV4::Global::ReservedArgumentCount); #endif - std::fill(c->arguments + callData->argc, c->arguments + function->formalParameterCount, Value::undefinedValue()); - c->argumentCount = function->formalParameterCount; + std::fill(c->callData->args + callData->argc, c->callData->args + function->formalParameterCount, Value::undefinedValue()); + c->callData->argc = function->formalParameterCount; } return c; @@ -111,7 +108,6 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData c->function = function; c->realArgumentCount = callData->argc; - c->thisObject = callData->thisObject; c->strictMode = function->strictMode; c->marked = false; @@ -134,12 +130,11 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData if (function->varCount) std::fill(c->locals, c->locals + function->varCount, Value::undefinedValue()); - c->argumentCount = qMax((uint)callData->argc, function->formalParameterCount); - c->arguments = static_cast<SafeValue *>(c->locals + function->varCount); - if (callData->argc) - ::memcpy(c->arguments, callData->args, callData->argc * sizeof(Value)); + c->callData = reinterpret_cast<CallData *>(c->locals + function->varCount); + ::memcpy(c->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(Value)); if (callData->argc < function->formalParameterCount) - std::fill(c->arguments + callData->argc, c->arguments + function->formalParameterCount, Value::undefinedValue()); + std::fill(c->callData->args + c->callData->argc, c->callData->args + function->formalParameterCount, Value::undefinedValue()); + c->callData->argc = qMax((uint)callData->argc, function->formalParameterCount); return c; } @@ -222,14 +217,17 @@ unsigned int ExecutionContext::variableCount() const void GlobalContext::initGlobalContext(ExecutionEngine *eng) { initBaseContext(Type_GlobalContext, eng, /*parentContext*/0); - thisObject = Value::fromObject(eng->globalObject); + callData = reinterpret_cast<CallData *>(this + 1); + callData->tag = QV4::Value::Integer_Type; + callData->argc = 0; + callData->thisObject = Value::fromObject(eng->globalObject); global = 0; } void WithContext::initWithContext(ExecutionContext *p, Object *with) { initBaseContext(Type_WithContext, p->engine, p); - thisObject = p->thisObject; + callData = p->callData; outer = p; lookups = p->lookups; runtimeStrings = p->runtimeStrings; @@ -243,7 +241,7 @@ void CatchContext::initCatchContext(ExecutionContext *p, String *exceptionVarNam { initBaseContext(Type_CatchContext, p->engine, p); strictMode = p->strictMode; - thisObject = p->thisObject; + callData = p->callData; outer = p; lookups = p->lookups; runtimeStrings = p->runtimeStrings; @@ -259,9 +257,10 @@ void CallContext::initQmlContext(ExecutionContext *parentContext, Object *qml, F initBaseContext(Type_QmlContext, parentContext->engine, parentContext); this->function = function; - this->arguments = 0; - this->argumentCount = 0; - this->thisObject = Value::undefinedValue(); + this->callData = reinterpret_cast<CallData *>(this + 1); + this->callData->tag = QV4::Value::Integer_Type; + this->callData->argc = 0; + this->callData->thisObject = Value::undefinedValue(); strictMode = true; marked = false; @@ -326,7 +325,7 @@ bool ExecutionContext::deleteProperty(const StringRef name) bool CallContext::needsOwnArguments() const { - return function->needsActivation || argumentCount < function->formalParameterCount; + return function->needsActivation || callData->argc < function->formalParameterCount; } void ExecutionContext::mark() @@ -338,19 +337,17 @@ void ExecutionContext::mark() if (type != Type_SimpleCallContext && outer) outer->mark(); - thisObject.mark(); + callData->thisObject.mark(); + for (unsigned arg = 0; arg < callData->argc; ++arg) + callData->args[arg].mark(); - if (type >= Type_SimpleCallContext) { + if (type >= Type_CallContext) { QV4::CallContext *c = static_cast<CallContext *>(this); - for (unsigned arg = 0, lastArg = c->argumentCount; arg < lastArg; ++arg) - c->arguments[arg].mark(); - if (type >= Type_CallContext) { - for (unsigned local = 0, lastLocal = c->variableCount(); local < lastLocal; ++local) - c->locals[local].mark(); - if (c->activation) - c->activation->mark(); - c->function->mark(); - } + for (unsigned local = 0, lastLocal = c->variableCount(); local < lastLocal; ++local) + c->locals[local].mark(); + if (c->activation) + c->activation->mark(); + c->function->mark(); } else if (type == Type_WithContext) { WithContext *w = static_cast<WithContext *>(this); w->withObject->mark(); @@ -389,7 +386,7 @@ void ExecutionContext::setProperty(const StringRef name, const ValueRef value) } for (int i = (int)c->function->formalParameterCount - 1; i >= 0; --i) if (c->function->formalParameterList[i]->isEqualTo(name)) { - c->arguments[i] = *value; + c->callData->args[i] = *value; return; } activation = c->activation; @@ -417,7 +414,7 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name) name->makeIdentifier(); if (name->isEqualTo(engine->id_this)) - return thisObject.asReturnedValue(); + return callData->thisObject.asReturnedValue(); bool hasWith = false; bool hasCatchScope = false; @@ -449,7 +446,7 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name) return c->locals[i].asReturnedValue(); for (int i = (int)f->formalParameterCount - 1; i >= 0; --i) if (f->formalParameterList[i]->isEqualTo(name)) - return c->arguments[i].asReturnedValue(); + return c->callData->args[i].asReturnedValue(); } if (c->activation) { bool hasProperty = false; @@ -482,7 +479,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(const StringRef name) name->makeIdentifier(); if (name->isEqualTo(engine->id_this)) - return thisObject.asReturnedValue(); + return callData->thisObject.asReturnedValue(); bool hasWith = false; bool hasCatchScope = false; @@ -514,7 +511,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(const StringRef name) return c->locals[i].asReturnedValue(); for (int i = (int)f->formalParameterCount - 1; i >= 0; --i) if (f->formalParameterList[i]->isEqualTo(name)) - return c->arguments[i].asReturnedValue(); + return c->callData->args[i].asReturnedValue(); } if (c->activation) { bool hasProperty = false; @@ -546,7 +543,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, Object name->makeIdentifier(); if (name->isEqualTo(engine->id_this)) - return thisObject.asReturnedValue(); + return callData->thisObject.asReturnedValue(); bool hasWith = false; bool hasCatchScope = false; @@ -579,7 +576,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, Object return c->locals[i].asReturnedValue(); for (int i = (int)f->formalParameterCount - 1; i >= 0; --i) if (f->formalParameterList[i]->isEqualTo(name)) - return c->arguments[i].asReturnedValue(); + return c->callData->args[i].asReturnedValue(); } if (c->activation) { bool hasProperty = false; @@ -695,6 +692,4 @@ void SimpleCallContext::initSimpleCallContext(ExecutionEngine *engine) { initBaseContext(Type_SimpleCallContext, engine, engine->current); function = 0; - arguments = 0; - argumentCount = 0; } diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index f216746212..efa7a07c1d 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -80,7 +80,7 @@ struct Q_QML_EXPORT ExecutionContext bool strictMode; bool marked; - Value thisObject; + CallData *callData; ExecutionEngine *engine; ExecutionContext *parent; @@ -105,7 +105,6 @@ struct Q_QML_EXPORT ExecutionContext this->type = type; strictMode = false; marked = false; - thisObject = Value::undefinedValue(); this->engine = engine; parent = parentContext; outer = 0; @@ -117,7 +116,7 @@ struct Q_QML_EXPORT ExecutionContext interpreterInstructionPointer = 0; } - CallContext *newCallContext(void *stackSpace, FunctionObject *f, CallData *callData); + CallContext *newCallContext(void *stackSpace, Value *locals, FunctionObject *f, CallData *callData); CallContext *newCallContext(FunctionObject *f, CallData *callData); WithContext *newWithContext(Object *with); CatchContext *newCatchContext(String* exceptionVarName, const QV4::Value &exceptionValue); @@ -158,13 +157,9 @@ struct SimpleCallContext : public ExecutionContext { void initSimpleCallContext(ExecutionEngine *engine); FunctionObject *function; - SafeValue *arguments; - unsigned int realArgumentCount; - unsigned int argumentCount; + int realArgumentCount; - ReturnedValue argument(uint i) { - return i < argumentCount ? arguments[i].asReturnedValue() : Value::undefinedValue().asReturnedValue(); - } + inline ReturnedValue argument(int i); }; struct CallContext : public SimpleCallContext @@ -210,9 +205,9 @@ inline const CallContext *ExecutionContext::asCallContext() const /* Function *f, int argc */ #define requiredMemoryForExecutionContect(f, argc) \ - sizeof(CallContext) + sizeof(Value) * (f->varCount + qMax((uint)argc, f->formalParameterCount)) + sizeof(CallContext) + sizeof(Value) * (f->varCount + qMax((uint)argc, f->formalParameterCount)) + sizeof(CallData) #define requiredMemoryForExecutionContectSimple(f) \ - sizeof(CallContext) + sizeof(Value) * f->varCount + sizeof(CallContext) #define requiredMemoryForQmlExecutionContect(f) \ sizeof(CallContext) + sizeof(Value) * (f->locals.size()) #define stackContextSize (sizeof(CallContext) + 32*sizeof(Value)) diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 8bc92c6c4e..05d4b6ee7f 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -762,7 +762,7 @@ void DatePrototype::init(ExecutionEngine *engine, const Value &ctor) double DatePrototype::getThisDate(ExecutionContext *ctx) { - if (DateObject *thisObject = ctx->thisObject.asDateObject()) + if (DateObject *thisObject = ctx->callData->thisObject.asDateObject()) return thisObject->value.asDouble(); else { ctx->throwTypeError(); @@ -772,22 +772,22 @@ double DatePrototype::getThisDate(ExecutionContext *ctx) ReturnedValue DatePrototype::method_parse(SimpleCallContext *ctx) { - if (!ctx->argumentCount) + if (!ctx->callData->argc) return Encode(qSNaN()); - return Encode(ParseString(ctx->arguments[0].toString(ctx)->toQString())); + return Encode(ParseString(ctx->callData->args[0].toString(ctx)->toQString())); } ReturnedValue DatePrototype::method_UTC(SimpleCallContext *ctx) { - const int numArgs = ctx->argumentCount; + const int numArgs = ctx->callData->argc; if (numArgs >= 2) { - double year = ctx->arguments[0].toNumber(); - double month = ctx->arguments[1].toNumber(); - double day = numArgs >= 3 ? ctx->arguments[2].toNumber() : 1; - double hours = numArgs >= 4 ? ctx->arguments[3].toNumber() : 0; - double mins = numArgs >= 5 ? ctx->arguments[4].toNumber() : 0; - double secs = numArgs >= 6 ? ctx->arguments[5].toNumber() : 0; - double ms = numArgs >= 7 ? ctx->arguments[6].toNumber() : 0; + double year = ctx->callData->args[0].toNumber(); + double month = ctx->callData->args[1].toNumber(); + double day = numArgs >= 3 ? ctx->callData->args[2].toNumber() : 1; + double hours = numArgs >= 4 ? ctx->callData->args[3].toNumber() : 0; + double mins = numArgs >= 5 ? ctx->callData->args[4].toNumber() : 0; + double secs = numArgs >= 6 ? ctx->callData->args[5].toNumber() : 0; + double ms = numArgs >= 7 ? ctx->callData->args[6].toNumber() : 0; if (year >= 0 && year <= 99) year += 1900; double t = MakeDate(MakeDay(year, month, day), @@ -999,11 +999,11 @@ ReturnedValue DatePrototype::method_getTimezoneOffset(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setTime(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<DateObject> self(scope, ctx->thisObject); + Scoped<DateObject> self(scope, ctx->callData->thisObject); if (!self) ctx->throwTypeError(); - double t = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); + double t = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); self->value.setDouble(TimeClip(t)); return self->value.asReturnedValue(); } @@ -1011,37 +1011,37 @@ ReturnedValue DatePrototype::method_setTime(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setMilliseconds(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<DateObject> self(scope, ctx->thisObject); + Scoped<DateObject> self(scope, ctx->callData->thisObject); if (!self) ctx->throwTypeError(); double t = LocalTime(self->value.asDouble()); - double ms = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); + double ms = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); self->value.setDouble(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms))))); return self->value.asReturnedValue(); } ReturnedValue DatePrototype::method_setUTCMilliseconds(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = self->value.asDouble(); - double ms = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); + double ms = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); self->value.setDouble(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms))))); return self->value.asReturnedValue(); } ReturnedValue DatePrototype::method_setSeconds(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = LocalTime(self->value.asDouble()); - double sec = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); - double ms = (ctx->argumentCount < 2) ? msFromTime(t) : ctx->arguments[1].toNumber(); + double sec = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double ms = (ctx->callData->argc < 2) ? msFromTime(t) : ctx->callData->args[1].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1049,13 +1049,13 @@ ReturnedValue DatePrototype::method_setSeconds(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setUTCSeconds(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = self->value.asDouble(); - double sec = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); - double ms = (ctx->argumentCount < 2) ? msFromTime(t) : ctx->arguments[1].toNumber(); + double sec = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double ms = (ctx->callData->argc < 2) ? msFromTime(t) : ctx->callData->args[1].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1063,14 +1063,14 @@ ReturnedValue DatePrototype::method_setUTCSeconds(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setMinutes(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = LocalTime(self->value.asDouble()); - double min = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); - double sec = (ctx->argumentCount < 2) ? SecFromTime(t) : ctx->arguments[1].toNumber(); - double ms = (ctx->argumentCount < 3) ? msFromTime(t) : ctx->arguments[2].toNumber(); + double min = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double sec = (ctx->callData->argc < 2) ? SecFromTime(t) : ctx->callData->args[1].toNumber(); + double ms = (ctx->callData->argc < 3) ? msFromTime(t) : ctx->callData->args[2].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1078,14 +1078,14 @@ ReturnedValue DatePrototype::method_setMinutes(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setUTCMinutes(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = self->value.asDouble(); - double min = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); - double sec = (ctx->argumentCount < 2) ? SecFromTime(t) : ctx->arguments[1].toNumber(); - double ms = (ctx->argumentCount < 3) ? msFromTime(t) : ctx->arguments[2].toNumber(); + double min = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double sec = (ctx->callData->argc < 2) ? SecFromTime(t) : ctx->callData->args[1].toNumber(); + double ms = (ctx->callData->argc < 3) ? msFromTime(t) : ctx->callData->args[2].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1093,15 +1093,15 @@ ReturnedValue DatePrototype::method_setUTCMinutes(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setHours(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = LocalTime(self->value.asDouble()); - double hour = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); - double min = (ctx->argumentCount < 2) ? MinFromTime(t) : ctx->arguments[1].toNumber(); - double sec = (ctx->argumentCount < 3) ? SecFromTime(t) : ctx->arguments[2].toNumber(); - double ms = (ctx->argumentCount < 4) ? msFromTime(t) : ctx->arguments[3].toNumber(); + double hour = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double min = (ctx->callData->argc < 2) ? MinFromTime(t) : ctx->callData->args[1].toNumber(); + double sec = (ctx->callData->argc < 3) ? SecFromTime(t) : ctx->callData->args[2].toNumber(); + double ms = (ctx->callData->argc < 4) ? msFromTime(t) : ctx->callData->args[3].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1109,15 +1109,15 @@ ReturnedValue DatePrototype::method_setHours(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setUTCHours(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = self->value.asDouble(); - double hour = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); - double min = (ctx->argumentCount < 2) ? MinFromTime(t) : ctx->arguments[1].toNumber(); - double sec = (ctx->argumentCount < 3) ? SecFromTime(t) : ctx->arguments[2].toNumber(); - double ms = (ctx->argumentCount < 4) ? msFromTime(t) : ctx->arguments[3].toNumber(); + double hour = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double min = (ctx->callData->argc < 2) ? MinFromTime(t) : ctx->callData->args[1].toNumber(); + double sec = (ctx->callData->argc < 3) ? SecFromTime(t) : ctx->callData->args[2].toNumber(); + double ms = (ctx->callData->argc < 4) ? msFromTime(t) : ctx->callData->args[3].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1125,12 +1125,12 @@ ReturnedValue DatePrototype::method_setUTCHours(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setDate(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = LocalTime(self->value.asDouble()); - double date = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); + double date = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1138,12 +1138,12 @@ ReturnedValue DatePrototype::method_setDate(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setUTCDate(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = self->value.asDouble(); - double date = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); + double date = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1151,13 +1151,13 @@ ReturnedValue DatePrototype::method_setUTCDate(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setMonth(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = LocalTime(self->value.asDouble()); - double month = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); - double date = (ctx->argumentCount < 2) ? DateFromTime(t) : ctx->arguments[1].toNumber(); + double month = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double date = (ctx->callData->argc < 2) ? DateFromTime(t) : ctx->callData->args[1].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1165,13 +1165,13 @@ ReturnedValue DatePrototype::method_setMonth(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setUTCMonth(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = self->value.asDouble(); - double month = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); - double date = (ctx->argumentCount < 2) ? DateFromTime(t) : ctx->arguments[1].toNumber(); + double month = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double date = (ctx->callData->argc < 2) ? DateFromTime(t) : ctx->callData->args[1].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1179,7 +1179,7 @@ ReturnedValue DatePrototype::method_setUTCMonth(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setYear(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); @@ -1188,7 +1188,7 @@ ReturnedValue DatePrototype::method_setYear(SimpleCallContext *ctx) t = 0; else t = LocalTime(t); - double year = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); + double year = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); double r; if (std::isnan(year)) { r = qSNaN(); @@ -1205,14 +1205,14 @@ ReturnedValue DatePrototype::method_setYear(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setUTCFullYear(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = self->value.asDouble(); - double year = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); - double month = (ctx->argumentCount < 2) ? MonthFromTime(t) : ctx->arguments[1].toNumber(); - double date = (ctx->argumentCount < 3) ? DateFromTime(t) : ctx->arguments[2].toNumber(); + double year = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double month = (ctx->callData->argc < 2) ? MonthFromTime(t) : ctx->callData->args[1].toNumber(); + double date = (ctx->callData->argc < 3) ? DateFromTime(t) : ctx->callData->args[2].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1220,16 +1220,16 @@ ReturnedValue DatePrototype::method_setUTCFullYear(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_setFullYear(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = LocalTime(self->value.asDouble()); if (std::isnan(t)) t = 0; - double year = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); - double month = (ctx->argumentCount < 2) ? MonthFromTime(t) : ctx->arguments[1].toNumber(); - double date = (ctx->argumentCount < 3) ? DateFromTime(t) : ctx->arguments[2].toNumber(); + double year = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double month = (ctx->callData->argc < 2) ? MonthFromTime(t) : ctx->callData->args[1].toNumber(); + double date = (ctx->callData->argc < 3) ? DateFromTime(t) : ctx->callData->args[2].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t)))); self->value.setDouble(t); return self->value.asReturnedValue(); @@ -1237,7 +1237,7 @@ ReturnedValue DatePrototype::method_setFullYear(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_toUTCString(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); @@ -1260,13 +1260,13 @@ static void addZeroPrefixedInt(QString &str, int num, int nDigits) ReturnedValue DatePrototype::method_toISOString(SimpleCallContext *ctx) { - DateObject *self = ctx->thisObject.asDateObject(); + DateObject *self = ctx->callData->thisObject.asDateObject(); if (!self) ctx->throwTypeError(); double t = self->value.asDouble(); if (!std::isfinite(t)) - ctx->throwRangeError(ctx->thisObject); + ctx->throwRangeError(ctx->callData->thisObject); QString result; int year = (int)YearFromTime(t); @@ -1299,7 +1299,7 @@ ReturnedValue DatePrototype::method_toISOString(SimpleCallContext *ctx) ReturnedValue DatePrototype::method_toJSON(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedValue O(scope, __qmljs_to_object(ctx, ValueRef(&ctx->thisObject))); + ScopedValue O(scope, __qmljs_to_object(ctx, ValueRef(&ctx->callData->thisObject))); ScopedValue tv(scope, __qmljs_to_primitive(O, NUMBER_HINT)); if (tv->isNumber() && !std::isfinite(tv->toNumber())) @@ -1313,7 +1313,7 @@ ReturnedValue DatePrototype::method_toJSON(SimpleCallContext *ctx) ctx->throwTypeError(); ScopedCallData callData(scope, 0); - callData->thisObject = ctx->thisObject; + callData->thisObject = ctx->callData->thisObject; return toIso->call(callData); } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 363f0a45c0..62738c23bf 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -260,7 +260,7 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) // globalObject = newObject()->getPointer(); rootContext->global = globalObject; - rootContext->thisObject = Value::fromObject(globalObject); + rootContext->callData->thisObject = Value::fromObject(globalObject); globalObject->defineDefaultProperty(QStringLiteral("Object"), objectCtor); globalObject->defineDefaultProperty(QStringLiteral("String"), stringCtor); @@ -335,7 +335,7 @@ void ExecutionEngine::enableDebugger() void ExecutionEngine::initRootContext() { - rootContext = static_cast<GlobalContext *>(memoryManager->allocContext(sizeof(GlobalContext))); + rootContext = static_cast<GlobalContext *>(memoryManager->allocContext(sizeof(GlobalContext) + sizeof(CallData))); current = rootContext; current->parent = 0; rootContext->initGlobalContext(this); diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index 7ffc4feb9e..c4870e13bb 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -140,7 +140,7 @@ ErrorObject::ErrorObject(InternalClass *ic, const QString &message, const QStrin ReturnedValue ErrorObject::method_get_stack(SimpleCallContext *ctx) { - ErrorObject *This = ctx->thisObject.asErrorObject(); + ErrorObject *This = ctx->callData->thisObject.asErrorObject(); if (!This) ctx->throwTypeError(); if (!This->stack) { @@ -341,7 +341,7 @@ ReturnedValue ErrorPrototype::method_toString(SimpleCallContext *ctx) { Scope scope(ctx); - Object *o = ctx->thisObject.asObject(); + Object *o = ctx->callData->thisObject.asObject(); if (!o) ctx->throwTypeError(); diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 6c60a9964a..7f4c419ddc 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -309,7 +309,7 @@ void FunctionPrototype::init(ExecutionEngine *engine, const Value &ctor) ReturnedValue FunctionPrototype::method_toString(SimpleCallContext *ctx) { - FunctionObject *fun = ctx->thisObject.asFunctionObject(); + FunctionObject *fun = ctx->callData->thisObject.asFunctionObject(); if (!fun) ctx->throwTypeError(); @@ -319,7 +319,7 @@ ReturnedValue FunctionPrototype::method_toString(SimpleCallContext *ctx) ReturnedValue FunctionPrototype::method_apply(SimpleCallContext *ctx) { Scope scope(ctx); - FunctionObject *o = ctx->thisObject.asFunctionObject(); + FunctionObject *o = ctx->callData->thisObject.asFunctionObject(); if (!o) ctx->throwTypeError(); @@ -361,14 +361,14 @@ ReturnedValue FunctionPrototype::method_call(SimpleCallContext *ctx) { Scope scope(ctx); - FunctionObject *o = ctx->thisObject.asFunctionObject(); + FunctionObject *o = ctx->callData->thisObject.asFunctionObject(); if (!o) ctx->throwTypeError(); - ScopedCallData callData(scope, ctx->argumentCount ? ctx->argumentCount - 1 : 0); - if (ctx->argumentCount) { - std::copy(ctx->arguments + 1, - ctx->arguments + ctx->argumentCount, callData->args); + ScopedCallData callData(scope, ctx->callData->argc ? ctx->callData->argc - 1 : 0); + if (ctx->callData->argc) { + std::copy(ctx->callData->args + 1, + ctx->callData->args + ctx->callData->argc, callData->args); } callData->thisObject = ctx->argument(0); return o->call(callData); @@ -377,14 +377,14 @@ ReturnedValue FunctionPrototype::method_call(SimpleCallContext *ctx) ReturnedValue FunctionPrototype::method_bind(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<FunctionObject> target(scope, ctx->thisObject); + Scoped<FunctionObject> target(scope, ctx->callData->thisObject); if (!target) ctx->throwTypeError(); ScopedValue boundThis(scope, ctx->argument(0)); QVector<Value> boundArgs; - for (uint i = 1; i < ctx->argumentCount; ++i) - boundArgs += ctx->arguments[i]; + for (uint i = 1; i < ctx->callData->argc; ++i) + boundArgs += ctx->callData->args[i]; return ctx->engine->newBoundFunction(ctx->engine->rootContext, target.getPointer(), boundThis, boundArgs)->asReturnedValue(); } @@ -469,9 +469,9 @@ ReturnedValue ScriptFunction::call(Managed *that, CallData *callData) if (!f->strictMode && !callData->thisObject.isObject()) { if (callData->thisObject.isNullOrUndefined()) { - ctx->thisObject = Value::fromObject(f->engine()->globalObject); + ctx->callData->thisObject = Value::fromObject(f->engine()->globalObject); } else { - ctx->thisObject = Value::fromObject(callData->thisObject.toObject(context)); + ctx->callData->thisObject = Value::fromObject(callData->thisObject.toObject(context)); } } @@ -541,7 +541,7 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData) ExecutionContext *context = v4->current; void *stackSpace = alloca(requiredMemoryForExecutionContectSimple(f)); callData->thisObject = obj; - ExecutionContext *ctx = context->newCallContext(stackSpace, f.getPointer(), callData); + ExecutionContext *ctx = context->newCallContext(stackSpace, scope.alloc(f->varCount), f.getPointer(), callData); try { Scoped<Object> result(scope, f->function->code(ctx, f->function->codeData)); @@ -558,17 +558,19 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData) ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData) { - SimpleScriptFunction *f = static_cast<SimpleScriptFunction *>(that); + ExecutionEngine *v4 = that->engine(); + Scope scope(v4); + Scoped<SimpleScriptFunction> f(scope, static_cast<SimpleScriptFunction *>(that)); + void *stackSpace = alloca(requiredMemoryForExecutionContectSimple(f)); - ExecutionContext *context = f->engine()->current; - Scope scope(context); - ExecutionContext *ctx = context->newCallContext(stackSpace, f, callData); + ExecutionContext *context = v4->current; + ExecutionContext *ctx = context->newCallContext(stackSpace, scope.alloc(f->varCount), f.getPointer(), callData); if (!f->strictMode && !callData->thisObject.isObject()) { if (callData->thisObject.isNullOrUndefined()) { - ctx->thisObject = Value::fromObject(f->engine()->globalObject); + ctx->callData->thisObject = Value::fromObject(f->engine()->globalObject); } else { - ctx->thisObject = Value::fromObject(callData->thisObject.toObject(context)); + ctx->callData->thisObject = Value::fromObject(callData->thisObject.toObject(context)); } } @@ -614,10 +616,7 @@ ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData) SimpleCallContext ctx; ctx.initSimpleCallContext(f->scope->engine); ctx.strictMode = f->scope->strictMode; // ### needed? scope or parent context? - ctx.thisObject = callData->thisObject; - // ### const_cast - ctx.arguments = const_cast<SafeValue *>(callData->args); - ctx.argumentCount = callData->argc; + ctx.callData = callData; v4->pushContext(&ctx); ScopedValue result(scope); @@ -642,10 +641,7 @@ ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData) SimpleCallContext ctx; ctx.initSimpleCallContext(f->scope->engine); ctx.strictMode = f->scope->strictMode; // ### needed? scope or parent context? - ctx.thisObject = callData->thisObject; - // ### const_cast - ctx.arguments = const_cast<SafeValue *>(callData->args); - ctx.argumentCount = callData->argc; + ctx.callData = callData; v4->pushContext(&ctx); ScopedValue result(scope); diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index ae91b11991..f6f59b2f05 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -393,7 +393,7 @@ ReturnedValue EvalFunction::evalCall(Value /*thisObject*/, Value *args, int argc if (strictMode) { FunctionObject *e = FunctionObject::creatScriptFunction(ctx, function); ScopedCallData callData(scope, 0); - callData->thisObject = ctx->thisObject; + callData->thisObject = ctx->callData->thisObject; return e->call(callData); } @@ -573,38 +573,38 @@ ReturnedValue GlobalFunctions::method_parseFloat(SimpleCallContext *ctx) /// isNaN [15.1.2.4] ReturnedValue GlobalFunctions::method_isNaN(SimpleCallContext *ctx) { - if (!ctx->argumentCount) + if (!ctx->callData->argc) // undefined gets converted to NaN return Encode(true); - if (ctx->arguments[0].integerCompatible()) + if (ctx->callData->args[0].integerCompatible()) return Encode(false); - double d = ctx->arguments[0].toNumber(); + double d = ctx->callData->args[0].toNumber(); return Encode((bool)std::isnan(d)); } /// isFinite [15.1.2.5] ReturnedValue GlobalFunctions::method_isFinite(SimpleCallContext *ctx) { - if (!ctx->argumentCount) + if (!ctx->callData->argc) // undefined gets converted to NaN return Encode(false); - if (ctx->arguments[0].integerCompatible()) + if (ctx->callData->args[0].integerCompatible()) return Encode(true); - double d = ctx->arguments[0].toNumber(); + double d = ctx->callData->args[0].toNumber(); return Encode((bool)std::isfinite(d)); } /// decodeURI [15.1.3.1] ReturnedValue GlobalFunctions::method_decodeURI(SimpleCallContext *context) { - if (context->argumentCount == 0) + if (context->callData->argc == 0) return Encode::undefined(); - QString uriString = context->arguments[0].toString(context)->toQString(); + QString uriString = context->callData->args[0].toString(context)->toQString(); bool ok; QString out = decode(uriString, DecodeNonReserved, &ok); if (!ok) @@ -616,10 +616,10 @@ ReturnedValue GlobalFunctions::method_decodeURI(SimpleCallContext *context) /// decodeURIComponent [15.1.3.2] ReturnedValue GlobalFunctions::method_decodeURIComponent(SimpleCallContext *context) { - if (context->argumentCount == 0) + if (context->callData->argc == 0) return Encode::undefined(); - QString uriString = context->arguments[0].toString(context)->toQString(); + QString uriString = context->callData->args[0].toString(context)->toQString(); bool ok; QString out = decode(uriString, DecodeAll, &ok); if (!ok) @@ -631,10 +631,10 @@ ReturnedValue GlobalFunctions::method_decodeURIComponent(SimpleCallContext *cont /// encodeURI [15.1.3.3] ReturnedValue GlobalFunctions::method_encodeURI(SimpleCallContext *context) { - if (context->argumentCount == 0) + if (context->callData->argc == 0) return Encode::undefined(); - QString uriString = context->arguments[0].toString(context)->toQString(); + QString uriString = context->callData->args[0].toString(context)->toQString(); bool ok; QString out = encode(uriString, uriUnescapedReserved, &ok); if (!ok) @@ -646,10 +646,10 @@ ReturnedValue GlobalFunctions::method_encodeURI(SimpleCallContext *context) /// encodeURIComponent [15.1.3.4] ReturnedValue GlobalFunctions::method_encodeURIComponent(SimpleCallContext *context) { - if (context->argumentCount == 0) + if (context->callData->argc == 0) return Encode::undefined(); - QString uriString = context->arguments[0].toString(context)->toQString(); + QString uriString = context->callData->args[0].toString(context)->toQString(); bool ok; QString out = encode(uriString, uriUnescaped, &ok); if (!ok) @@ -660,18 +660,18 @@ ReturnedValue GlobalFunctions::method_encodeURIComponent(SimpleCallContext *cont ReturnedValue GlobalFunctions::method_escape(SimpleCallContext *context) { - if (!context->argumentCount) + if (!context->callData->argc) return Value::fromString(context, QStringLiteral("undefined")).asReturnedValue(); - QString str = context->arguments[0].toString(context)->toQString(); + QString str = context->callData->args[0].toString(context)->toQString(); return Value::fromString(context, escape(str)).asReturnedValue(); } ReturnedValue GlobalFunctions::method_unescape(SimpleCallContext *context) { - if (!context->argumentCount) + if (!context->callData->argc) return Value::fromString(context, QStringLiteral("undefined")).asReturnedValue(); - QString str = context->arguments[0].toString(context)->toQString(); + QString str = context->callData->args[0].toString(context)->toQString(); return Value::fromString(context, unescape(str)).asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index d6f01bf369..bde9c23e6b 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -181,7 +181,7 @@ void QV4Include::finished() */ QV4::ReturnedValue QV4Include::method_include(QV4::SimpleCallContext *ctx) { - if (!ctx->argumentCount) + if (!ctx->callData->argc) return QV4::Encode::undefined(); QV4::ExecutionEngine *v4 = ctx->engine; @@ -192,11 +192,11 @@ QV4::ReturnedValue QV4Include::method_include(QV4::SimpleCallContext *ctx) if (!context || !context->isJSContext) V4THROW_ERROR("Qt.include(): Can only be called from JavaScript files"); - QUrl url(ctx->engine->resolvedUrl(ctx->arguments[0].toQStringNoThrow())); + QUrl url(ctx->engine->resolvedUrl(ctx->callData->args[0].toQStringNoThrow())); QV4::Value callbackFunction = QV4::Value::undefinedValue(); - if (ctx->argumentCount >= 2 && ctx->arguments[1].asFunctionObject()) - callbackFunction = ctx->arguments[1]; + if (ctx->callData->argc >= 2 && ctx->callData->args[1].asFunctionObject()) + callbackFunction = ctx->callData->args[1]; QString localFile = QQmlFile::urlToLocalFileOrQrc(url); diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 3d57b5fb2f..57a84d008a 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -98,15 +98,15 @@ static double copySign(double x, double y) ReturnedValue MathObject::method_abs(SimpleCallContext *context) { - if (!context->argumentCount) + if (!context->callData->argc) return Encode(qSNaN()); - if (context->arguments[0].isInteger()) { - int i = context->arguments[0].integerValue(); + if (context->callData->args[0].isInteger()) { + int i = context->callData->args[0].integerValue(); return Encode(i < 0 ? - i : i); } - double v = context->arguments[0].toNumber(); + double v = context->callData->args[0].toNumber(); if (v == 0) // 0 | -0 return Encode(0); @@ -115,7 +115,7 @@ ReturnedValue MathObject::method_abs(SimpleCallContext *context) ReturnedValue MathObject::method_acos(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : 2; + double v = context->callData->argc ? context->callData->args[0].toNumber() : 2; if (v > 1) return Encode(qSNaN()); @@ -124,7 +124,7 @@ ReturnedValue MathObject::method_acos(SimpleCallContext *context) ReturnedValue MathObject::method_asin(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : 2; + double v = context->callData->argc ? context->callData->args[0].toNumber() : 2; if (v > 1) return Encode(qSNaN()); else @@ -133,7 +133,7 @@ ReturnedValue MathObject::method_asin(SimpleCallContext *context) ReturnedValue MathObject::method_atan(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); + double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); if (v == 0.0) return Encode(v); else @@ -142,8 +142,8 @@ ReturnedValue MathObject::method_atan(SimpleCallContext *context) ReturnedValue MathObject::method_atan2(SimpleCallContext *context) { - double v1 = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); - double v2 = context->argumentCount > 1 ? context->arguments[1].toNumber() : qSNaN(); + double v1 = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v2 = context->callData->argc > 1 ? context->callData->args[1].toNumber() : qSNaN(); if ((v1 < 0) && qIsFinite(v1) && qIsInf(v2) && (copySign(1.0, v2) == 1.0)) return Encode(copySign(0, -1.0)); @@ -160,7 +160,7 @@ ReturnedValue MathObject::method_atan2(SimpleCallContext *context) ReturnedValue MathObject::method_ceil(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); + double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); if (v < 0.0 && v > -1.0) return Encode(copySign(0, -1.0)); else @@ -169,13 +169,13 @@ ReturnedValue MathObject::method_ceil(SimpleCallContext *context) ReturnedValue MathObject::method_cos(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); + double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); return Encode(::cos(v)); } ReturnedValue MathObject::method_exp(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); + double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); if (qIsInf(v)) { if (copySign(1.0, v) == -1.0) return Encode(0); @@ -188,13 +188,13 @@ ReturnedValue MathObject::method_exp(SimpleCallContext *context) ReturnedValue MathObject::method_floor(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); + double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); return Encode(::floor(v)); } ReturnedValue MathObject::method_log(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); + double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); if (v < 0) return Encode(qSNaN()); else @@ -204,8 +204,8 @@ ReturnedValue MathObject::method_log(SimpleCallContext *context) ReturnedValue MathObject::method_max(SimpleCallContext *context) { double mx = -qInf(); - for (unsigned i = 0; i < context->argumentCount; ++i) { - double x = context->arguments[i].toNumber(); + for (unsigned i = 0; i < context->callData->argc; ++i) { + double x = context->callData->args[i].toNumber(); if (x > mx || std::isnan(x)) mx = x; } @@ -215,8 +215,8 @@ ReturnedValue MathObject::method_max(SimpleCallContext *context) ReturnedValue MathObject::method_min(SimpleCallContext *context) { double mx = qInf(); - for (unsigned i = 0; i < context->argumentCount; ++i) { - double x = context->arguments[i].toNumber(); + for (unsigned i = 0; i < context->callData->argc; ++i) { + double x = context->callData->args[i].toNumber(); if ((x == 0 && mx == x && copySign(1.0, x) == -1.0) || (x < mx) || std::isnan(x)) { mx = x; @@ -227,8 +227,8 @@ ReturnedValue MathObject::method_min(SimpleCallContext *context) ReturnedValue MathObject::method_pow(SimpleCallContext *context) { - double x = context->argumentCount > 0 ? context->arguments[0].toNumber() : qSNaN(); - double y = context->argumentCount > 1 ? context->arguments[1].toNumber() : qSNaN(); + double x = context->callData->argc > 0 ? context->callData->args[0].toNumber() : qSNaN(); + double y = context->callData->argc > 1 ? context->callData->args[1].toNumber() : qSNaN(); if (std::isnan(y)) return Encode(qSNaN()); @@ -282,26 +282,26 @@ ReturnedValue MathObject::method_random(SimpleCallContext *) ReturnedValue MathObject::method_round(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); + double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); v = copySign(::floor(v + 0.5), v); return Encode(v); } ReturnedValue MathObject::method_sin(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); + double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); return Encode(::sin(v)); } ReturnedValue MathObject::method_sqrt(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); + double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); return Encode(::sqrt(v)); } ReturnedValue MathObject::method_tan(SimpleCallContext *context) { - double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN(); + double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); if (v == 0.0) return Encode(v); else diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index f946b3180a..bc5e225f9b 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -100,9 +100,9 @@ void NumberPrototype::init(ExecutionEngine *engine, const Value &ctor) inline Value thisNumberValue(ExecutionContext *ctx) { - if (ctx->thisObject.isNumber()) - return ctx->thisObject; - NumberObject *n = ctx->thisObject.asNumberObject(); + if (ctx->callData->thisObject.isNumber()) + return ctx->callData->thisObject; + NumberObject *n = ctx->callData->thisObject.asNumberObject(); if (!n) ctx->throwTypeError(); return n->value; @@ -112,8 +112,8 @@ ReturnedValue NumberPrototype::method_toString(SimpleCallContext *ctx) { double num = thisNumberValue(ctx).asDouble(); - if (ctx->argumentCount && !ctx->arguments[0].isUndefined()) { - int radix = ctx->arguments[0].toInt32(); + if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) { + int radix = ctx->callData->args[0].toInt32(); if (radix < 2 || radix > 36) { ctx->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix") .arg(radix)); @@ -180,14 +180,14 @@ ReturnedValue NumberPrototype::method_toFixed(SimpleCallContext *ctx) double fdigits = 0; - if (ctx->argumentCount > 0) - fdigits = ctx->arguments[0].toInteger(); + if (ctx->callData->argc > 0) + fdigits = ctx->callData->args[0].toInteger(); if (std::isnan(fdigits)) fdigits = 0; if (fdigits < 0 || fdigits > 20) - ctx->throwRangeError(ctx->thisObject); + ctx->throwRangeError(ctx->callData->thisObject); QString str; if (std::isnan(v)) @@ -207,8 +207,8 @@ ReturnedValue NumberPrototype::method_toExponential(SimpleCallContext *ctx) int fdigits = -1; - if (ctx->argumentCount && !ctx->arguments[0].isUndefined()) { - int fdigits = ctx->arguments[0].toInt32(); + if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) { + int fdigits = ctx->callData->args[0].toInt32(); if (fdigits < 0 || fdigits > 20) { String *error = ctx->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")); ctx->throwRangeError(Value::fromString(error)); @@ -229,10 +229,10 @@ ReturnedValue NumberPrototype::method_toPrecision(SimpleCallContext *ctx) ScopedValue v(scope, thisNumberValue(ctx)); - if (!ctx->argumentCount || ctx->arguments[0].isUndefined()) + if (!ctx->callData->argc || ctx->callData->args[0].isUndefined()) return __qmljs_to_string(v, ctx); - double precision = ctx->arguments[0].toInt32(); + double precision = ctx->callData->args[0].toInt32(); if (precision < 1 || precision > 21) { String *error = ctx->engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range")); ctx->throwRangeError(Value::fromString(error)); diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index befc01936d..96426cabfb 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -169,7 +169,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyNames(SimpleCallContext *con if (!O) context->throwTypeError(); - ScopedArrayObject array(scope, getOwnPropertyNames(context->engine, context->arguments[0])); + ScopedArrayObject array(scope, getOwnPropertyNames(context->engine, context->callData->args[0])); return array.asReturnedValue(); } @@ -183,8 +183,8 @@ ReturnedValue ObjectPrototype::method_create(SimpleCallContext *ctx) Scoped<Object> newObject(scope, ctx->engine->newObject()); newObject->setPrototype(O->asObject()); - if (ctx->argumentCount > 1 && !ctx->arguments[1].isUndefined()) { - ctx->arguments[0] = newObject.asValue(); + if (ctx->callData->argc > 1 && !ctx->callData->args[1].isUndefined()) { + ctx->callData->args[0] = newObject.asValue(); return method_defineProperties(ctx); } @@ -387,12 +387,12 @@ ReturnedValue ObjectPrototype::method_keys(SimpleCallContext *ctx) ReturnedValue ObjectPrototype::method_toString(SimpleCallContext *ctx) { Scope scope(ctx); - if (ctx->thisObject.isUndefined()) { + if (ctx->callData->thisObject.isUndefined()) { return Value::fromString(ctx, QStringLiteral("[object Undefined]")).asReturnedValue(); - } else if (ctx->thisObject.isNull()) { + } else if (ctx->callData->thisObject.isNull()) { return Value::fromString(ctx, QStringLiteral("[object Null]")).asReturnedValue(); } else { - ScopedObject obj(scope, __qmljs_to_object(ctx, ValueRef(&ctx->thisObject))); + ScopedObject obj(scope, __qmljs_to_object(ctx, ValueRef(&ctx->callData->thisObject))); QString className = obj->className(); return Value::fromString(ctx, QString::fromUtf8("[object %1]").arg(className)).asReturnedValue(); } @@ -401,7 +401,7 @@ ReturnedValue ObjectPrototype::method_toString(SimpleCallContext *ctx) ReturnedValue ObjectPrototype::method_toLocaleString(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->thisObject.toObject(ctx)); + ScopedObject o(scope, ctx->callData->thisObject.toObject(ctx)); Scoped<FunctionObject> f(scope, o->get(ctx->engine->id_toString)); if (!f) ctx->throwTypeError(); @@ -412,14 +412,14 @@ ReturnedValue ObjectPrototype::method_toLocaleString(SimpleCallContext *ctx) ReturnedValue ObjectPrototype::method_valueOf(SimpleCallContext *ctx) { - return Value::fromObject(ctx->thisObject.toObject(ctx)).asReturnedValue(); + return Value::fromObject(ctx->callData->thisObject.toObject(ctx)).asReturnedValue(); } ReturnedValue ObjectPrototype::method_hasOwnProperty(SimpleCallContext *ctx) { Scope scope(ctx); Scoped<String> P(scope, ctx->argument(0), Scoped<String>::Convert); - Scoped<Object> O(scope, ctx->thisObject, Scoped<Object>::Convert); + Scoped<Object> O(scope, ctx->callData->thisObject, Scoped<Object>::Convert); bool r = O->__getOwnProperty__(P) != 0; if (!r) r = !O->query(P).isEmpty(); @@ -433,7 +433,7 @@ ReturnedValue ObjectPrototype::method_isPrototypeOf(SimpleCallContext *ctx) if (!V) return Encode(false); - Scoped<Object> O(scope, ctx->thisObject, Scoped<Object>::Convert); + Scoped<Object> O(scope, ctx->callData->thisObject, Scoped<Object>::Convert); Scoped<Object> proto(scope, V->prototype()); while (proto) { if (O.getPointer() == proto.getPointer()) @@ -448,7 +448,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(SimpleCallContext *ct Scope scope(ctx); Scoped<String> p(scope, ctx->argument(0), Scoped<String>::Convert); - Scoped<Object> o(scope, ctx->thisObject, Scoped<Object>::Convert); + Scoped<Object> o(scope, ctx->callData->thisObject, Scoped<Object>::Convert); PropertyAttributes attrs; o->__getOwnProperty__(p, &attrs); return Encode(attrs.isEnumerable()); @@ -456,7 +456,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(SimpleCallContext *ct ReturnedValue ObjectPrototype::method_defineGetter(SimpleCallContext *ctx) { - if (ctx->argumentCount < 2) + if (ctx->callData->argc < 2) ctx->throwTypeError(); Scope scope(ctx); @@ -466,9 +466,9 @@ ReturnedValue ObjectPrototype::method_defineGetter(SimpleCallContext *ctx) if (!f) ctx->throwTypeError(); - Scoped<Object> o(scope, ctx->thisObject); + Scoped<Object> o(scope, ctx->callData->thisObject); if (!o) { - if (!ctx->thisObject.isUndefined()) + if (!ctx->callData->thisObject.isUndefined()) return Encode::undefined(); o = ctx->engine->globalObject; } @@ -480,7 +480,7 @@ ReturnedValue ObjectPrototype::method_defineGetter(SimpleCallContext *ctx) ReturnedValue ObjectPrototype::method_defineSetter(SimpleCallContext *ctx) { - if (ctx->argumentCount < 2) + if (ctx->callData->argc < 2) ctx->throwTypeError(); Scope scope(ctx); @@ -490,9 +490,9 @@ ReturnedValue ObjectPrototype::method_defineSetter(SimpleCallContext *ctx) if (!f) ctx->throwTypeError(); - Scoped<Object> o(scope, ctx->thisObject); + Scoped<Object> o(scope, ctx->callData->thisObject); if (!o) { - if (!ctx->thisObject.isUndefined()) + if (!ctx->callData->thisObject.isUndefined()) return Encode::undefined(); o = ctx->engine->globalObject; } @@ -505,7 +505,7 @@ ReturnedValue ObjectPrototype::method_defineSetter(SimpleCallContext *ctx) ReturnedValue ObjectPrototype::method_get_proto(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->thisObject.asObject()); + ScopedObject o(scope, ctx->callData->thisObject.asObject()); if (!o) ctx->throwTypeError(); @@ -515,16 +515,16 @@ ReturnedValue ObjectPrototype::method_get_proto(SimpleCallContext *ctx) ReturnedValue ObjectPrototype::method_set_proto(SimpleCallContext *ctx) { Scope scope(ctx); - Scoped<Object> o(scope, ctx->thisObject); - if (!o || !ctx->argumentCount) + Scoped<Object> o(scope, ctx->callData->thisObject); + if (!o || !ctx->callData->argc) ctx->throwTypeError(); - if (ctx->arguments[0].isNull()) { + if (ctx->callData->args[0].isNull()) { o->setPrototype(0); return Encode::undefined(); } - Scoped<Object> p(scope, ctx->arguments[0]); + Scoped<Object> p(scope, ctx->callData->args[0]); bool ok = false; if (!!p) { if (o->prototype() == p.getPointer()) { diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index b7a696cc33..876bda3163 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -788,10 +788,10 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase ReturnedValue QObjectWrapper::method_connect(SimpleCallContext *ctx) { - if (ctx->argumentCount == 0) + if (ctx->callData->argc == 0) V4THROW_ERROR("Function.prototype.connect: no arguments given"); - QPair<QObject *, int> signalInfo = extractQtSignal(ctx->thisObject); + QPair<QObject *, int> signalInfo = extractQtSignal(ctx->callData->thisObject); QObject *signalObject = signalInfo.first; int signalIndex = signalInfo.second; @@ -808,11 +808,11 @@ ReturnedValue QObjectWrapper::method_connect(SimpleCallContext *ctx) QV4::ScopedFunctionObject f(scope); QV4::ScopedValue thisObject (scope, QV4::Encode::undefined()); - if (ctx->argumentCount == 1) { - f = ctx->arguments[0]; - } else if (ctx->argumentCount >= 2) { - thisObject = ctx->arguments[0]; - f = ctx->arguments[1]; + if (ctx->callData->argc == 1) { + f = ctx->callData->args[0]; + } else if (ctx->callData->argc >= 2) { + thisObject = ctx->callData->args[0]; + f = ctx->callData->args[1]; } if (!f) @@ -834,10 +834,10 @@ ReturnedValue QObjectWrapper::method_connect(SimpleCallContext *ctx) ReturnedValue QObjectWrapper::method_disconnect(SimpleCallContext *ctx) { - if (ctx->argumentCount == 0) + if (ctx->callData->argc == 0) V4THROW_ERROR("Function.prototype.disconnect: no arguments given"); - QPair<QObject *, int> signalInfo = extractQtSignal(ctx->thisObject); + QPair<QObject *, int> signalInfo = extractQtSignal(ctx->callData->thisObject); QObject *signalObject = signalInfo.first; int signalIndex = signalInfo.second; @@ -853,11 +853,11 @@ ReturnedValue QObjectWrapper::method_disconnect(SimpleCallContext *ctx) QV4::Value functionValue = QV4::Value::undefinedValue(); QV4::Value functionThisValue = QV4::Value::undefinedValue(); - if (ctx->argumentCount == 1) { - functionValue = ctx->arguments[0]; - } else if (ctx->argumentCount >= 2) { - functionThisValue = ctx->arguments[0]; - functionValue = ctx->arguments[1]; + if (ctx->callData->argc == 1) { + functionValue = ctx->callData->args[0]; + } else if (ctx->callData->argc >= 2) { + functionThisValue = ctx->callData->args[0]; + functionValue = ctx->callData->args[1]; } if (!functionValue.asFunctionObject()) diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 3f58f28b4b..fee66d9d09 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -303,8 +303,7 @@ void RegExpPrototype::init(ExecutionEngine *engine, const Value &ctor) ReturnedValue RegExpPrototype::method_exec(SimpleCallContext *ctx) { Scope scope(ctx); - - RegExpObject *r = ctx->thisObject.as<RegExpObject>(); + Scoped<RegExpObject> r(scope, ctx->callData->thisObject.as<RegExpObject>()); if (!r) ctx->throwTypeError(); @@ -355,7 +354,8 @@ ReturnedValue RegExpPrototype::method_test(SimpleCallContext *ctx) ReturnedValue RegExpPrototype::method_toString(SimpleCallContext *ctx) { - RegExpObject *r = ctx->thisObject.as<RegExpObject>(); + Scope scope(ctx); + Scoped<RegExpObject> r(scope, ctx->callData->thisObject.as<RegExpObject>()); if (!r) ctx->throwTypeError(); @@ -365,12 +365,12 @@ ReturnedValue RegExpPrototype::method_toString(SimpleCallContext *ctx) ReturnedValue RegExpPrototype::method_compile(SimpleCallContext *ctx) { Scope scope(ctx); - RegExpObject *r = ctx->thisObject.as<RegExpObject>(); + Scoped<RegExpObject> r(scope, ctx->callData->thisObject.as<RegExpObject>()); if (!r) ctx->throwTypeError(); - ScopedCallData callData(scope, ctx->argumentCount); - memcpy(callData->args, ctx->arguments, ctx->argumentCount*sizeof(Value)); + ScopedCallData callData(scope, ctx->callData->argc); + memcpy(callData->args, ctx->callData->args, ctx->callData->argc*sizeof(Value)); RegExpObject *re = Value::fromReturnedValue(ctx->engine->regExpCtor.asFunctionObject()->construct(callData)).as<RegExpObject>(); r->value = re->value; diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index a8e18dac78..30a9aa8b38 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -60,13 +60,13 @@ struct Scope { , size(0) #endif { - mark = ctx->engine->jsStackTop; + mark = engine->jsStackTop; } explicit Scope(ExecutionEngine *e) : engine(e) { - mark = e->jsStackTop; + mark = engine->jsStackTop; } ~Scope() { @@ -77,6 +77,15 @@ struct Scope { engine->jsStackTop = mark; } + Value *alloc(int nValues) { + Value *ptr = engine->jsStackTop; + engine->jsStackTop += nValues; +#ifndef QT_NO_DEBUG + size += nValues; +#endif + return ptr; + } + ExecutionEngine *engine; Value *mark; #ifndef QT_NO_DEBUG @@ -683,6 +692,10 @@ inline WeakValue &WeakValue::operator=(Returned<T> *obj) return operator=(QV4::Value::fromManaged(obj->getPointer()).asReturnedValue()); } +inline ReturnedValue SimpleCallContext::argument(int i) { + return i < callData->argc ? callData->args[i].asReturnedValue() : Value::undefinedValue().asReturnedValue(); +} + } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index e8ba80de35..6ad13efbdd 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -376,8 +376,8 @@ public: loadReference(); } - if (ctx->argumentCount == 1 && ctx->arguments[0].asFunctionObject()) { - QV4::Value compareFn = ctx->arguments[0]; + if (ctx->callData->argc == 1 && ctx->callData->args[0].asFunctionObject()) { + QV4::Value compareFn = ctx->callData->args[0]; CompareFunctor cf(ctx, compareFn); std::sort(m_container.begin(), m_container.end(), cf); } else { @@ -391,7 +391,8 @@ public: static QV4::ReturnedValue method_get_length(QV4::SimpleCallContext *ctx) { - QQmlSequence<Container> *This = ctx->thisObject.as<QQmlSequence<Container> >(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->callData->thisObject.as<QQmlSequence<Container> >()); if (!This) ctx->throwTypeError(); @@ -405,11 +406,12 @@ public: static QV4::ReturnedValue method_set_length(QV4::SimpleCallContext* ctx) { - QQmlSequence<Container> *This = ctx->thisObject.as<QQmlSequence<Container> >(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->callData->thisObject.as<QQmlSequence<Container> >()); if (!This) ctx->throwTypeError(); - quint32 newLength = ctx->arguments[0].toUInt32(); + quint32 newLength = ctx->callData->args[0].toUInt32(); /* Qt containers have int (rather than uint) allowable indexes. */ if (newLength > INT_MAX) { generateWarning(ctx, QLatin1String("Index out of range during length set")); @@ -542,12 +544,12 @@ void SequencePrototype::init() QV4::ReturnedValue SequencePrototype::method_sort(QV4::SimpleCallContext *ctx) { - QV4::Object *o = ctx->thisObject.asObject(); + QV4::Object *o = ctx->callData->thisObject.asObject(); if (!o || !o->isListType()) ctx->throwTypeError(); - if (ctx->argumentCount >= 2) - return ctx->thisObject.asReturnedValue(); + if (ctx->callData->argc >= 2) + return ctx->callData->thisObject.asReturnedValue(); #define CALL_SORT(SequenceElementType, SequenceElementTypeName, SequenceType, DefaultValue) \ if (QQml##SequenceElementTypeName##List *s = o->as<QQml##SequenceElementTypeName##List>()) { \ @@ -557,7 +559,7 @@ QV4::ReturnedValue SequencePrototype::method_sort(QV4::SimpleCallContext *ctx) FOREACH_QML_SEQUENCE_TYPE(CALL_SORT) #undef CALL_SORT - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } #define IS_SEQUENCE(unused1, unused2, SequenceType, unused3) \ diff --git a/src/qml/jsruntime/qv4sequenceobject_p.h b/src/qml/jsruntime/qv4sequenceobject_p.h index ca58b11090..a743bac247 100644 --- a/src/qml/jsruntime/qv4sequenceobject_p.h +++ b/src/qml/jsruntime/qv4sequenceobject_p.h @@ -71,7 +71,7 @@ struct SequencePrototype : public QV4::Object static ReturnedValue method_valueOf(QV4::SimpleCallContext *ctx) { - return QV4::Value::fromString(ctx->thisObject.toString(ctx)).asReturnedValue(); + return QV4::Value::fromString(ctx->callData->thisObject.toString(ctx)).asReturnedValue(); } static ReturnedValue method_sort(QV4::SimpleCallContext *ctx); diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index a7343bc8c1..05a1ef4100 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -218,7 +218,7 @@ void StringPrototype::init(ExecutionEngine *engine, const Value &ctor) static QString getThisString(ExecutionContext *ctx) { Scope scope(ctx); - ScopedValue t(scope, ctx->thisObject); + ScopedValue t(scope, ctx->callData->thisObject); if (t->isString()) return t->stringValue()->toQString(); if (StringObject *thisString = t->asStringObject()) @@ -230,10 +230,10 @@ static QString getThisString(ExecutionContext *ctx) ReturnedValue StringPrototype::method_toString(SimpleCallContext *context) { - if (context->thisObject.isString()) - return context->thisObject.asReturnedValue(); + if (context->callData->thisObject.isString()) + return context->callData->thisObject.asReturnedValue(); - StringObject *o = context->thisObject.asStringObject(); + StringObject *o = context->callData->thisObject.asStringObject(); if (!o) context->throwTypeError(); return o->value.asReturnedValue(); @@ -244,8 +244,8 @@ ReturnedValue StringPrototype::method_charAt(SimpleCallContext *context) const QString str = getThisString(context); int pos = 0; - if (context->argumentCount > 0) - pos = (int) context->arguments[0].toInteger(); + if (context->callData->argc > 0) + pos = (int) context->callData->args[0].toInteger(); QString result; if (pos >= 0 && pos < str.length()) @@ -259,8 +259,8 @@ ReturnedValue StringPrototype::method_charCodeAt(SimpleCallContext *context) const QString str = getThisString(context); int pos = 0; - if (context->argumentCount > 0) - pos = (int) context->arguments[0].toInteger(); + if (context->callData->argc > 0) + pos = (int) context->callData->args[0].toInteger(); if (pos >= 0 && pos < str.length()) @@ -276,8 +276,8 @@ ReturnedValue StringPrototype::method_concat(SimpleCallContext *context) QString value = getThisString(context); ScopedValue v(scope); - for (int i = 0; i < context->argumentCount; ++i) { - v = __qmljs_to_string(ValueRef(&context->arguments[i]), context); + for (int i = 0; i < context->callData->argc; ++i) { + v = __qmljs_to_string(ValueRef(&context->callData->args[i]), context); assert(v->isString()); value += v->stringValue()->toQString(); } @@ -290,12 +290,12 @@ ReturnedValue StringPrototype::method_indexOf(SimpleCallContext *context) QString value = getThisString(context); QString searchString; - if (context->argumentCount) - searchString = context->arguments[0].toString(context)->toQString(); + if (context->callData->argc) + searchString = context->callData->args[0].toString(context)->toQString(); int pos = 0; - if (context->argumentCount > 1) - pos = (int) context->arguments[1].toInteger(); + if (context->callData->argc > 1) + pos = (int) context->callData->args[1].toInteger(); int index = -1; if (! value.isEmpty()) @@ -311,8 +311,8 @@ ReturnedValue StringPrototype::method_lastIndexOf(SimpleCallContext *context) const QString value = getThisString(context); QString searchString; - if (context->argumentCount) - searchString = context->arguments[0].toQString(); + if (context->callData->argc) + searchString = context->callData->args[0].toQString(); ScopedValue posArg(scope, context->argument(1)); double position = __qmljs_to_number(posArg); @@ -333,19 +333,19 @@ ReturnedValue StringPrototype::method_lastIndexOf(SimpleCallContext *context) ReturnedValue StringPrototype::method_localeCompare(SimpleCallContext *context) { const QString value = getThisString(context); - const QString that = (context->argumentCount ? context->arguments[0] : Value::undefinedValue()).toQString(); + const QString that = (context->callData->argc ? context->callData->args[0] : Value::undefinedValue()).toQString(); return Encode(QString::localeAwareCompare(value, that)); } ReturnedValue StringPrototype::method_match(SimpleCallContext *context) { - if (context->thisObject.isUndefined() || context->thisObject.isNull()) + if (context->callData->thisObject.isUndefined() || context->callData->thisObject.isNull()) context->throwTypeError(); Scope scope(context); - ScopedString s(scope, context->thisObject.toString(context)); + ScopedString s(scope, context->callData->thisObject.toString(context)); - ScopedValue regexp(scope, context->argumentCount ? context->arguments[0] : Value::undefinedValue()); + ScopedValue regexp(scope, context->callData->argc ? context->callData->args[0] : Value::undefinedValue()); Scoped<RegExpObject> rx(scope, regexp); if (!rx) { ScopedCallData callData(scope, 1); @@ -451,10 +451,10 @@ ReturnedValue StringPrototype::method_replace(SimpleCallContext *ctx) { Scope scope(ctx); QString string; - if (StringObject *thisString = ctx->thisObject.asStringObject()) + if (StringObject *thisString = ctx->callData->thisObject.asStringObject()) string = thisString->value.stringValue()->toQString(); else - string = ctx->thisObject.toString(ctx)->toQString(); + string = ctx->callData->thisObject.toString(ctx)->toQString(); int numCaptures = 0; int numStringMatches = 0; @@ -585,9 +585,9 @@ ReturnedValue StringPrototype::method_slice(SimpleCallContext *ctx) const QString text = getThisString(ctx); const double length = text.length(); - double start = ctx->argumentCount ? ctx->arguments[0].toInteger() : 0; - double end = (ctx->argumentCount < 2 || ctx->arguments[1].isUndefined()) - ? length : ctx->arguments[1].toInteger(); + double start = ctx->callData->argc ? ctx->callData->args[0].toInteger() : 0; + double end = (ctx->callData->argc < 2 || ctx->callData->args[1].isUndefined()) + ? length : ctx->callData->args[1].toInteger(); if (start < 0) start = qMax(length + start, 0.); @@ -690,12 +690,12 @@ ReturnedValue StringPrototype::method_substr(SimpleCallContext *context) const QString value = getThisString(context); double start = 0; - if (context->argumentCount > 0) - start = context->arguments[0].toInteger(); + if (context->callData->argc > 0) + start = context->callData->args[0].toInteger(); double length = +qInf(); - if (context->argumentCount > 1) - length = context->arguments[1].toInteger(); + if (context->callData->argc > 1) + length = context->callData->args[1].toInteger(); double count = value.length(); if (start < 0) @@ -716,8 +716,8 @@ ReturnedValue StringPrototype::method_substring(SimpleCallContext *context) double start = 0; double end = length; - if (context->argumentCount > 0) - start = context->arguments[0].toInteger(); + if (context->callData->argc > 0) + start = context->callData->args[0].toInteger(); Scope scope(context); ScopedValue endValue(scope, context->argument(1)); @@ -771,10 +771,10 @@ ReturnedValue StringPrototype::method_toLocaleUpperCase(SimpleCallContext *ctx) ReturnedValue StringPrototype::method_fromCharCode(SimpleCallContext *context) { - QString str(context->argumentCount, Qt::Uninitialized); + QString str(context->callData->argc, Qt::Uninitialized); QChar *ch = str.data(); - for (int i = 0; i < context->argumentCount; ++i) { - *ch = QChar(context->arguments[i].toUInt16()); + for (int i = 0; i < context->callData->argc; ++i) { + *ch = QChar(context->callData->args[i].toUInt16()); ++ch; } return Value::fromString(context, str).asReturnedValue(); diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp index de72de2f07..720e4fa3a6 100644 --- a/src/qml/jsruntime/qv4variantobject.cpp +++ b/src/qml/jsruntime/qv4variantobject.cpp @@ -155,7 +155,8 @@ void VariantPrototype::init() QV4::ReturnedValue VariantPrototype::method_preserve(SimpleCallContext *ctx) { - VariantObject *o = ctx->thisObject.as<QV4::VariantObject>(); + Scope scope(ctx); + Scoped<VariantObject> o(scope, ctx->callData->thisObject.as<QV4::VariantObject>()); if (o && o->isScarce()) o->node.remove(); return Encode::undefined(); @@ -163,7 +164,8 @@ QV4::ReturnedValue VariantPrototype::method_preserve(SimpleCallContext *ctx) QV4::ReturnedValue VariantPrototype::method_destroy(SimpleCallContext *ctx) { - VariantObject *o = ctx->thisObject.as<QV4::VariantObject>(); + Scope scope(ctx); + Scoped<VariantObject> o(scope, ctx->callData->thisObject.as<QV4::VariantObject>()); if (o) { if (o->isScarce()) o->node.remove(); @@ -174,7 +176,8 @@ QV4::ReturnedValue VariantPrototype::method_destroy(SimpleCallContext *ctx) QV4::ReturnedValue VariantPrototype::method_toString(SimpleCallContext *ctx) { - VariantObject *o = ctx->thisObject.as<QV4::VariantObject>(); + Scope scope(ctx); + Scoped<VariantObject> o(scope, ctx->callData->thisObject.as<QV4::VariantObject>()); if (!o) return Encode::undefined(); QString result = o->data.toString(); @@ -185,7 +188,8 @@ QV4::ReturnedValue VariantPrototype::method_toString(SimpleCallContext *ctx) QV4::ReturnedValue VariantPrototype::method_valueOf(SimpleCallContext *ctx) { - VariantObject *o = ctx->thisObject.as<QV4::VariantObject>(); + Scope scope(ctx); + Scoped<VariantObject> o(scope, ctx->callData->thisObject.as<QV4::VariantObject>()); if (o) { QVariant v = o->data; switch (v.type()) { @@ -204,7 +208,7 @@ QV4::ReturnedValue VariantPrototype::method_valueOf(SimpleCallContext *ctx) break; } } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 868158717c..ce2f76042f 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -170,9 +170,9 @@ static inline QV4::Value *getValueRef(QV4::ExecutionContext *context, QV4::CallContext *cc = static_cast<QV4::CallContext *>(c); const unsigned arg = param.index; Q_ASSERT(arg >= 0); - Q_ASSERT((unsigned) arg < cc->argumentCount); - Q_ASSERT(cc->arguments); - return cc->arguments + arg; + Q_ASSERT((unsigned) arg < cc->callData->argc); + Q_ASSERT(cc->callData->args); + return cc->callData->args + arg; } else if (param.isLocal()) { VMSTATS(paramIsLocal); const unsigned index = param.index; @@ -546,7 +546,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, MOTH_END_INSTR(Ret) MOTH_BEGIN_INSTR(LoadThis) - VALUE(instr.result) = context->thisObject; + VALUE(instr.result) = context->callData->thisObject; MOTH_END_INSTR(LoadThis) MOTH_BEGIN_INSTR(InplaceElementOp) diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 692d40b418..de1114a15e 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1424,7 +1424,8 @@ QQmlComponentExtension::QQmlComponentExtension(QV8Engine *engine) QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::SimpleCallContext *ctx) { - QmlIncubatorObject *o = ctx->thisObject.as<QmlIncubatorObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>()); if (!o) ctx->throwTypeError(); @@ -1433,7 +1434,8 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::SimpleCallContext QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::SimpleCallContext *ctx) { - QmlIncubatorObject *o = ctx->thisObject.as<QmlIncubatorObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>()); if (!o) ctx->throwTypeError(); @@ -1444,7 +1446,8 @@ QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::SimpleCallCon QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::SimpleCallContext *ctx) { - QmlIncubatorObject *o = ctx->thisObject.as<QmlIncubatorObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>()); if (!o) ctx->throwTypeError(); @@ -1453,7 +1456,8 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::SimpleCallContext QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::SimpleCallContext *ctx) { - QmlIncubatorObject *o = ctx->thisObject.as<QmlIncubatorObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>()); if (!o) ctx->throwTypeError(); @@ -1462,11 +1466,12 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::SimpleCallC QV4::ReturnedValue QmlIncubatorObject::method_set_statusChanged(QV4::SimpleCallContext *ctx) { - QmlIncubatorObject *o = ctx->thisObject.as<QmlIncubatorObject>(); - if (!o || ctx->argumentCount < 1) + QV4::Scope scope(ctx); + QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>()); + if (!o || ctx->callData->argc < 1) ctx->throwTypeError(); - o->m_statusChanged = ctx->arguments[0]; + o->m_statusChanged = ctx->callData->args[0]; return QV4::Encode::undefined(); } diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 7610b6a9d9..400ef9f940 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -68,7 +68,7 @@ public: QLocale locale; static QLocale &getThisLocale(QV4::SimpleCallContext *ctx) { - QQmlLocaleData *thisObject = ctx->thisObject.asObject()->as<QQmlLocaleData>(); + QQmlLocaleData *thisObject = ctx->callData->thisObject.asObject()->as<QQmlLocaleData>(); if (!thisObject) ctx->throwTypeError(); return thisObject->locale; @@ -137,36 +137,36 @@ void QQmlDateExtension::registerExtension(QV4::ExecutionEngine *engine) QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount > 2) + if (ctx->callData->argc > 2) return QV4::DatePrototype::method_toLocaleString(ctx); QV4::Scope scope(ctx); - QV4::DateObject *date = ctx->thisObject.asDateObject(); + QV4::DateObject *date = ctx->callData->thisObject.asDateObject(); if (!date) return QV4::DatePrototype::method_toLocaleString(ctx); QDateTime dt = date->toQDateTime(); - if (ctx->argumentCount == 0) { + if (ctx->callData->argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; return QV4::Value::fromString(ctx, locale.toString(dt)).asReturnedValue(); } - if (!isLocaleObject(ctx->arguments[0])) + if (!isLocaleObject(ctx->callData->args[0])) return QV4::DatePrototype::method_toLocaleString(ctx); // Use the default Date toLocaleString() - GET_LOCALE_DATA_RESOURCE(ctx->arguments[0]); + GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedDt; - if (ctx->argumentCount == 2) { - if (ctx->arguments[1].isString()) { - QString format = ctx->arguments[1].stringValue()->toQString(); + if (ctx->callData->argc == 2) { + if (ctx->callData->args[1].isString()) { + QString format = ctx->callData->args[1].stringValue()->toQString(); formattedDt = r->locale.toString(dt, format); - } else if (ctx->arguments[1].isNumber()) { - quint32 intFormat = ctx->arguments[1].toNumber(); + } else if (ctx->callData->args[1].isNumber()) { + quint32 intFormat = ctx->callData->args[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedDt = r->locale.toString(dt, format); } else { @@ -181,37 +181,37 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::SimpleCallConte QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount > 2) + if (ctx->callData->argc > 2) return QV4::DatePrototype::method_toLocaleTimeString(ctx); QV4::Scope scope(ctx); - QV4::DateObject *date = ctx->thisObject.asDateObject(); + QV4::DateObject *date = ctx->callData->thisObject.asDateObject(); if (!date) return QV4::DatePrototype::method_toLocaleTimeString(ctx); QDateTime dt = date->toQDateTime(); QTime time = dt.time(); - if (ctx->argumentCount == 0) { + if (ctx->callData->argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; return QV4::Value::fromString(ctx, locale.toString(time)).asReturnedValue(); } - if (!isLocaleObject(ctx->arguments[0])) + if (!isLocaleObject(ctx->callData->args[0])) return QV4::DatePrototype::method_toLocaleTimeString(ctx); // Use the default Date toLocaleTimeString() - GET_LOCALE_DATA_RESOURCE(ctx->arguments[0]); + GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedTime; - if (ctx->argumentCount == 2) { - if (ctx->arguments[1].isString()) { - QString format = ctx->arguments[1].stringValue()->toQString(); + if (ctx->callData->argc == 2) { + if (ctx->callData->args[1].isString()) { + QString format = ctx->callData->args[1].stringValue()->toQString(); formattedTime = r->locale.toString(time, format); - } else if (ctx->arguments[1].isNumber()) { - quint32 intFormat = ctx->arguments[1].toNumber(); + } else if (ctx->callData->args[1].isNumber()) { + quint32 intFormat = ctx->callData->args[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedTime = r->locale.toString(time, format); } else { @@ -226,37 +226,37 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::SimpleCallC QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount > 2) + if (ctx->callData->argc > 2) return QV4::DatePrototype::method_toLocaleDateString(ctx); QV4::Scope scope(ctx); - QV4::DateObject *dateObj = ctx->thisObject.asDateObject(); + QV4::DateObject *dateObj = ctx->callData->thisObject.asDateObject(); if (!dateObj) return QV4::DatePrototype::method_toLocaleDateString(ctx); QDateTime dt = dateObj->toQDateTime(); QDate date = dt.date(); - if (ctx->argumentCount == 0) { + if (ctx->callData->argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; return QV4::Value::fromString(ctx, locale.toString(date)).asReturnedValue(); } - if (!isLocaleObject(ctx->arguments[0])) + if (!isLocaleObject(ctx->callData->args[0])) return QV4::DatePrototype::method_toLocaleDateString(ctx); // Use the default Date toLocaleDateString() - GET_LOCALE_DATA_RESOURCE(ctx->arguments[0]); + GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedDate; - if (ctx->argumentCount == 2) { - if (ctx->arguments[1].isString()) { - QString format = ctx->arguments[1].stringValue()->toQString(); + if (ctx->callData->argc == 2) { + if (ctx->callData->args[1].isString()) { + QString format = ctx->callData->args[1].stringValue()->toQString(); formattedDate = r->locale.toString(date, format); - } else if (ctx->arguments[1].isNumber()) { - quint32 intFormat = ctx->arguments[1].toNumber(); + } else if (ctx->callData->args[1].isNumber()) { + quint32 intFormat = ctx->callData->args[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedDate = r->locale.toString(date, format); } else { @@ -272,29 +272,29 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::SimpleCallC QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::SimpleCallContext *ctx) { QV4::ExecutionEngine * const engine = ctx->engine; - if (ctx->argumentCount == 1 && ctx->arguments[0].isString()) { + if (ctx->callData->argc == 1 && ctx->callData->args[0].isString()) { QLocale locale; - QString dateString = ctx->arguments[0].stringValue()->toQString(); + QString dateString = ctx->callData->args[0].stringValue()->toQString(); QDateTime dt = locale.toDateTime(dateString); return QV4::Encode(engine->newDateObject(dt)); } QV4::Scope scope(ctx); - if (ctx->argumentCount < 1 || ctx->argumentCount > 3 || !isLocaleObject(ctx->arguments[0])) + if (ctx->callData->argc < 1 || ctx->callData->argc > 3 || !isLocaleObject(ctx->callData->args[0])) V4THROW_ERROR("Locale: Date.fromLocaleString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(ctx->arguments[0]); + GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QDateTime dt; - QString dateString = ctx->arguments[1].toQStringNoThrow(); - if (ctx->argumentCount == 3) { - if (ctx->arguments[2].isString()) { - QString format = ctx->arguments[2].stringValue()->toQString(); + QString dateString = ctx->callData->args[1].toQStringNoThrow(); + if (ctx->callData->argc == 3) { + if (ctx->callData->args[2].isString()) { + QString format = ctx->callData->args[2].stringValue()->toQString(); dt = r->locale.toDateTime(dateString, format); - } else if (ctx->arguments[2].isNumber()) { - quint32 intFormat = ctx->arguments[2].toNumber(); + } else if (ctx->callData->args[2].isNumber()) { + quint32 intFormat = ctx->callData->args[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); dt = r->locale.toDateTime(dateString, format); } else { @@ -311,31 +311,31 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::SimpleCal { QV4::ExecutionEngine * const engine = ctx->engine; - if (ctx->argumentCount == 1 && ctx->arguments[0].isString()) { + if (ctx->callData->argc == 1 && ctx->callData->args[0].isString()) { QLocale locale; - QString timeString = ctx->arguments[0].stringValue()->toQString(); + QString timeString = ctx->callData->args[0].stringValue()->toQString(); QTime time = locale.toTime(timeString); QDateTime dt = QDateTime::currentDateTime(); dt.setTime(time); return QV4::Encode(engine->newDateObject(dt)); } - if (ctx->argumentCount < 1 || ctx->argumentCount > 3 || !isLocaleObject(ctx->arguments[0])) + if (ctx->callData->argc < 1 || ctx->callData->argc > 3 || !isLocaleObject(ctx->callData->args[0])) V4THROW_ERROR("Locale: Date.fromLocaleTimeString(): Invalid arguments"); QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->arguments[0]); + GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QTime tm; - QString dateString = ctx->arguments[1].toQStringNoThrow(); - if (ctx->argumentCount == 3) { - if (ctx->arguments[2].isString()) { - QString format = ctx->arguments[2].stringValue()->toQString(); + QString dateString = ctx->callData->args[1].toQStringNoThrow(); + if (ctx->callData->argc == 3) { + if (ctx->callData->args[2].isString()) { + QString format = ctx->callData->args[2].stringValue()->toQString(); tm = r->locale.toTime(dateString, format); - } else if (ctx->arguments[2].isNumber()) { - quint32 intFormat = ctx->arguments[2].toNumber(); + } else if (ctx->callData->args[2].isNumber()) { + quint32 intFormat = ctx->callData->args[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); tm = r->locale.toTime(dateString, format); } else { @@ -355,29 +355,29 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::SimpleCal { QV4::ExecutionEngine * const engine = ctx->engine; - if (ctx->argumentCount == 1 && ctx->arguments[0].isString()) { + if (ctx->callData->argc == 1 && ctx->callData->args[0].isString()) { QLocale locale; - QString dateString = ctx->arguments[0].stringValue()->toQString(); + QString dateString = ctx->callData->args[0].stringValue()->toQString(); QDate date = locale.toDate(dateString); return QV4::Encode(engine->newDateObject(QDateTime(date))); } - if (ctx->argumentCount < 1 || ctx->argumentCount > 3 || !isLocaleObject(ctx->arguments[0])) + if (ctx->callData->argc < 1 || ctx->callData->argc > 3 || !isLocaleObject(ctx->callData->args[0])) V4THROW_ERROR("Locale: Date.fromLocaleDateString(): Invalid arguments"); QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->arguments[0]); + GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QDate dt; - QString dateString = ctx->arguments[1].toQStringNoThrow(); - if (ctx->argumentCount == 3) { - if (ctx->arguments[2].isString()) { - QString format = ctx->arguments[2].stringValue()->toQString(); + QString dateString = ctx->callData->args[1].toQStringNoThrow(); + if (ctx->callData->argc == 3) { + if (ctx->callData->args[2].isString()) { + QString format = ctx->callData->args[2].stringValue()->toQString(); dt = r->locale.toDate(dateString, format); - } else if (ctx->arguments[2].isNumber()) { - quint32 intFormat = ctx->arguments[2].toNumber(); + } else if (ctx->callData->args[2].isNumber()) { + quint32 intFormat = ctx->callData->args[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); dt = r->locale.toDate(dateString, format); } else { @@ -392,7 +392,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::SimpleCal QV4::ReturnedValue QQmlDateExtension::method_timeZoneUpdated(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 0) + if (ctx->callData->argc != 0) V4THROW_ERROR("Locale: Date.timeZoneUpdated(): Invalid arguments"); QV4::DatePrototype::timezoneUpdated(); @@ -412,37 +412,37 @@ void QQmlNumberExtension::registerExtension(QV4::ExecutionEngine *engine) QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount > 3) + if (ctx->callData->argc > 3) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - double number = ctx->thisObject.toNumber(); + double number = ctx->callData->thisObject.toNumber(); - if (ctx->argumentCount == 0) { + if (ctx->callData->argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; return QV4::Value::fromString(ctx, locale.toString(number)).asReturnedValue(); } - if (!isLocaleObject(ctx->arguments[0])) + if (!isLocaleObject(ctx->callData->args[0])) return QV4::NumberPrototype::method_toLocaleString(ctx); // Use the default Number toLocaleString() QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->arguments[0]); + GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); quint16 format = 'f'; - if (ctx->argumentCount > 1) { - if (!ctx->arguments[1].isString()) + if (ctx->callData->argc > 1) { + if (!ctx->callData->args[1].isString()) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - QV4::String *fs = ctx->arguments[1].toString(ctx); + QV4::String *fs = ctx->callData->args[1].toString(ctx); if (!fs->isEmpty()) format = fs->toQString().at(0).unicode(); } int prec = 2; - if (ctx->argumentCount > 2) { - if (!ctx->arguments[2].isNumber()) + if (ctx->callData->argc > 2) { + if (!ctx->callData->args[2].isNumber()) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - prec = ctx->arguments[2].toInt32(); + prec = ctx->callData->args[2].toInt32(); } return QV4::Value::fromString(ctx, r->locale.toString(number, (char)format, prec)).asReturnedValue(); @@ -450,29 +450,29 @@ QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::SimpleCallCon QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount > 2) + if (ctx->callData->argc > 2) V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments"); - double number = ctx->thisObject.toNumber(); + double number = ctx->callData->thisObject.toNumber(); - if (ctx->argumentCount == 0) { + if (ctx->callData->argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; return QV4::Value::fromString(ctx, locale.toString(number)).asReturnedValue(); } - if (!isLocaleObject(ctx->arguments[0])) + if (!isLocaleObject(ctx->callData->args[0])) V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments"); QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->arguments[0]); + GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); QString symbol; - if (ctx->argumentCount > 1) { - if (!ctx->arguments[1].isString()) + if (ctx->callData->argc > 1) { + if (!ctx->callData->args[1].isString()) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - symbol = ctx->arguments[1].toQStringNoThrow(); + symbol = ctx->callData->args[1].toQStringNoThrow(); } return QV4::Value::fromString(ctx, r->locale.toCurrencyString(number, symbol)).asReturnedValue(); @@ -480,7 +480,7 @@ QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::Simpl QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount < 1 || ctx->argumentCount > 2) + if (ctx->callData->argc < 1 || ctx->callData->argc > 2) V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments"); int numberIdx = 0; @@ -488,17 +488,17 @@ QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::SimpleCallC QV4::Scope scope(ctx); - if (ctx->argumentCount == 2) { - if (!isLocaleObject(ctx->arguments[0])) + if (ctx->callData->argc == 2) { + if (!isLocaleObject(ctx->callData->args[0])) V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(ctx->arguments[0]); + GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); locale = r->locale; numberIdx = 1; } - QV4::String *ns = ctx->arguments[numberIdx].toString(ctx); + QV4::String *ns = ctx->callData->args[numberIdx].toString(ctx); if (ns->isEmpty()) return QV4::Encode(Q_QNAN); @@ -575,12 +575,12 @@ QV4::ReturnedValue QQmlLocaleData::method_get_uiLanguages(QV4::SimpleCallContext QV4::ReturnedValue QQmlLocaleData::method_currencySymbol(QV4::SimpleCallContext *ctx) { QLocale locale = getThisLocale(ctx); - if (ctx->argumentCount > 1) + if (ctx->callData->argc > 1) V4THROW_ERROR("Locale: currencySymbol(): Invalid arguments"); QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol; - if (ctx->argumentCount == 1) { - quint32 intFormat = ctx->arguments[0].toNumber(); + if (ctx->callData->argc == 1) { + quint32 intFormat = ctx->callData->args[0].toNumber(); format = QLocale::CurrencySymbolFormat(intFormat); } @@ -590,11 +590,11 @@ QV4::ReturnedValue QQmlLocaleData::method_currencySymbol(QV4::SimpleCallContext #define LOCALE_FORMAT(FUNC) \ QV4::ReturnedValue QQmlLocaleData::method_ ##FUNC (QV4::SimpleCallContext *ctx) { \ QLocale locale = getThisLocale(ctx); \ - if (ctx->argumentCount > 1) \ + if (ctx->callData->argc > 1) \ V4THROW_ERROR("Locale: " #FUNC "(): Invalid arguments"); \ QLocale::FormatType format = QLocale::LongFormat;\ - if (ctx->argumentCount == 1) { \ - quint32 intFormat = ctx->arguments[0].toUInt32(); \ + if (ctx->callData->argc == 1) { \ + quint32 intFormat = ctx->callData->args[0].toUInt32(); \ format = QLocale::FormatType(intFormat); \ } \ return QV4::Value::fromString(ctx, locale. FUNC (format)).asReturnedValue(); \ @@ -608,16 +608,16 @@ LOCALE_FORMAT(dateFormat) #define LOCALE_FORMATTED_MONTHNAME(VARIABLE) \ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *ctx) {\ QLocale locale = getThisLocale(ctx); \ - if (ctx->argumentCount < 1 || ctx->argumentCount > 2) \ + if (ctx->callData->argc < 1 || ctx->callData->argc > 2) \ V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \ QLocale::FormatType enumFormat = QLocale::LongFormat; \ - int idx = ctx->arguments[0].toInt32() + 1; \ + int idx = ctx->callData->args[0].toInt32() + 1; \ if (idx < 1 || idx > 12) \ V4THROW_ERROR("Locale: Invalid month"); \ QString name; \ - if (ctx->argumentCount == 2) { \ - if (ctx->arguments[1].isNumber()) { \ - quint32 intFormat = ctx->arguments[1].toUInt32(); \ + if (ctx->callData->argc == 2) { \ + if (ctx->callData->args[1].isNumber()) { \ + quint32 intFormat = ctx->callData->args[1].toUInt32(); \ QLocale::FormatType format = QLocale::FormatType(intFormat); \ name = locale. VARIABLE(idx, format); \ } else { \ @@ -633,17 +633,17 @@ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext * #define LOCALE_FORMATTED_DAYNAME(VARIABLE) \ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *ctx) {\ QLocale locale = getThisLocale(ctx); \ - if (ctx->argumentCount < 1 || ctx->argumentCount > 2) \ + if (ctx->callData->argc < 1 || ctx->callData->argc > 2) \ V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \ QLocale::FormatType enumFormat = QLocale::LongFormat; \ - int idx = ctx->arguments[0].toInt32(); \ + int idx = ctx->callData->args[0].toInt32(); \ if (idx < 0 || idx > 7) \ V4THROW_ERROR("Locale: Invalid day"); \ if (idx == 0) idx = 7; \ QString name; \ - if (ctx->argumentCount == 2) { \ - if (ctx->arguments[1].isNumber()) { \ - quint32 intFormat = ctx->arguments[1].toUInt32(); \ + if (ctx->callData->argc == 2) { \ + if (ctx->callData->args[1].isNumber()) { \ + quint32 intFormat = ctx->callData->args[1].toUInt32(); \ QLocale::FormatType format = QLocale::FormatType(intFormat); \ name = locale. VARIABLE(idx, format); \ } else { \ @@ -851,14 +851,14 @@ void QQmlLocale::registerStringLocaleCompare(QV4::ExecutionEngine *engine) QV4::ReturnedValue QQmlLocale::method_localeCompare(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 1 || (!ctx->arguments[0].isString() && !ctx->arguments[0].asStringObject())) + if (ctx->callData->argc != 1 || (!ctx->callData->args[0].isString() && !ctx->callData->args[0].asStringObject())) return QV4::StringPrototype::method_localeCompare(ctx); - if (!ctx->thisObject.isString() && !ctx->thisObject.asStringObject()) + if (!ctx->callData->thisObject.isString() && !ctx->callData->thisObject.asStringObject()) return QV4::StringPrototype::method_localeCompare(ctx); - QString thisString = ctx->thisObject.toQStringNoThrow(); - QString thatString = ctx->arguments[0].toQStringNoThrow(); + QString thisString = ctx->callData->thisObject.toQStringNoThrow(); + QString thatString = ctx->callData->args[0].toQStringNoThrow(); return QV4::Encode(QString::localeAwareCompare(thisString, thatString)); } diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 2740d9b269..31c3ba0fac 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -242,7 +242,7 @@ bool QmlValueTypeWrapper::isEqual(const QVariant& value) ReturnedValue QmlValueTypeWrapper::method_toString(SimpleCallContext *ctx) { - Object *o = ctx->thisObject.asObject(); + Object *o = ctx->callData->thisObject.asObject(); if (!o) ctx->throwTypeError(); QmlValueTypeWrapper *w = o->as<QmlValueTypeWrapper>(); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 04ecda6422..c0ebe04563 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -415,7 +415,8 @@ void NodeImpl::release() ReturnedValue NodePrototype::method_get_nodeName(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) ctx->throwTypeError(); @@ -439,7 +440,8 @@ ReturnedValue NodePrototype::method_get_nodeName(SimpleCallContext *ctx) ReturnedValue NodePrototype::method_get_nodeValue(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) ctx->throwTypeError(); @@ -457,7 +459,8 @@ ReturnedValue NodePrototype::method_get_nodeValue(SimpleCallContext *ctx) ReturnedValue NodePrototype::method_get_nodeType(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) ctx->throwTypeError(); @@ -466,7 +469,8 @@ ReturnedValue NodePrototype::method_get_nodeType(SimpleCallContext *ctx) ReturnedValue NodePrototype::method_get_parentNode(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) ctx->throwTypeError(); @@ -480,7 +484,8 @@ ReturnedValue NodePrototype::method_get_parentNode(SimpleCallContext *ctx) ReturnedValue NodePrototype::method_get_childNodes(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) ctx->throwTypeError(); @@ -491,7 +496,8 @@ ReturnedValue NodePrototype::method_get_childNodes(SimpleCallContext *ctx) ReturnedValue NodePrototype::method_get_firstChild(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) ctx->throwTypeError(); @@ -505,7 +511,8 @@ ReturnedValue NodePrototype::method_get_firstChild(SimpleCallContext *ctx) ReturnedValue NodePrototype::method_get_lastChild(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) ctx->throwTypeError(); @@ -519,7 +526,8 @@ ReturnedValue NodePrototype::method_get_lastChild(SimpleCallContext *ctx) ReturnedValue NodePrototype::method_get_previousSibling(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) ctx->throwTypeError(); @@ -542,7 +550,8 @@ ReturnedValue NodePrototype::method_get_previousSibling(SimpleCallContext *ctx) ReturnedValue NodePrototype::method_get_nextSibling(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) ctx->throwTypeError(); @@ -565,7 +574,8 @@ ReturnedValue NodePrototype::method_get_nextSibling(SimpleCallContext *ctx) ReturnedValue NodePrototype::method_get_attributes(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) ctx->throwTypeError(); @@ -655,7 +665,8 @@ Value Attr::prototype(ExecutionEngine *engine) ReturnedValue Attr::method_name(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; @@ -665,7 +676,8 @@ ReturnedValue Attr::method_name(SimpleCallContext *ctx) ReturnedValue Attr::method_value(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; @@ -675,7 +687,8 @@ ReturnedValue Attr::method_value(SimpleCallContext *ctx) ReturnedValue Attr::method_ownerElement(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; @@ -685,7 +698,8 @@ ReturnedValue Attr::method_ownerElement(SimpleCallContext *ctx) ReturnedValue CharacterData::method_length(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; @@ -710,7 +724,8 @@ Value CharacterData::prototype(ExecutionEngine *v4) ReturnedValue Text::method_isElementContentWhitespace(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) return Encode::undefined(); return Encode(r->d->data.trimmed().isEmpty()); @@ -718,7 +733,8 @@ ReturnedValue Text::method_isElementContentWhitespace(SimpleCallContext *ctx) ReturnedValue Text::method_wholeText(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; @@ -969,7 +985,8 @@ Value NodeList::create(QV8Engine *engine, NodeImpl *data) ReturnedValue Document::method_documentElement(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r || r->d->type != NodeImpl::Document) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; @@ -979,7 +996,8 @@ ReturnedValue Document::method_documentElement(SimpleCallContext *ctx) ReturnedValue Document::method_xmlStandalone(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r || r->d->type != NodeImpl::Document) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; @@ -989,7 +1007,8 @@ ReturnedValue Document::method_xmlStandalone(SimpleCallContext *ctx) ReturnedValue Document::method_xmlVersion(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r || r->d->type != NodeImpl::Document) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; @@ -999,7 +1018,8 @@ ReturnedValue Document::method_xmlVersion(SimpleCallContext *ctx) ReturnedValue Document::method_xmlEncoding(SimpleCallContext *ctx) { - Node *r = ctx->thisObject.as<Node>(); + Scope scope(ctx); + Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>()); if (!r || r->d->type != NodeImpl::Document) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; @@ -1686,18 +1706,18 @@ void QQmlXMLHttpRequestCtor::setupProto() ReturnedValue QQmlXMLHttpRequestCtor::method_open(SimpleCallContext *ctx) { Scope scope(ctx); - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; - if (ctx->argumentCount < 2 || ctx->argumentCount > 5) + if (ctx->callData->argc < 2 || ctx->callData->argc > 5) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); QV8Engine *engine = ctx->engine->v8Engine; // Argument 0 - Method - QString method = ctx->arguments[0].toQStringNoThrow().toUpper(); + QString method = ctx->callData->args[0].toQStringNoThrow().toUpper(); if (method != QLatin1String("GET") && method != QLatin1String("PUT") && method != QLatin1String("HEAD") && @@ -1706,21 +1726,21 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(SimpleCallContext *ctx) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Unsupported HTTP method type"); // Argument 1 - URL - QUrl url = QUrl(ctx->arguments[1].toQStringNoThrow()); + QUrl url = QUrl(ctx->callData->args[1].toQStringNoThrow()); if (url.isRelative()) url = engine->callingContext()->resolvedUrl(url); // Argument 2 - async (optional) - if (ctx->argumentCount > 2 && !ctx->arguments[2].booleanValue()) + if (ctx->callData->argc > 2 && !ctx->callData->args[2].booleanValue()) V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Synchronous XMLHttpRequest calls are not supported"); // Argument 3/4 - user/pass (optional) QString username, password; - if (ctx->argumentCount > 3) - username = ctx->arguments[3].toQStringNoThrow(); - if (ctx->argumentCount > 4) - password = ctx->arguments[4].toQStringNoThrow(); + if (ctx->callData->argc > 3) + username = ctx->callData->args[3].toQStringNoThrow(); + if (ctx->callData->argc > 4) + password = ctx->callData->args[4].toQStringNoThrow(); // Clear the fragment (if any) url.setFragment(QString()); @@ -1729,27 +1749,26 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(SimpleCallContext *ctx) if (!username.isNull()) url.setUserName(username); if (!password.isNull()) url.setPassword(password); - ScopedValue meObject(scope, constructMeObject(ctx->thisObject, engine)); + ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, engine)); return r->open(meObject, method, url); } ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(SimpleCallContext *ctx) { Scope scope(ctx); - - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; - if (ctx->argumentCount != 2) + if (ctx->callData->argc != 2) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Opened || r->sendFlag()) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); - QString name = ctx->arguments[0].toQStringNoThrow(); - QString value = ctx->arguments[1].toQStringNoThrow(); + QString name = ctx->callData->args[0].toQStringNoThrow(); + QString value = ctx->callData->args[1].toQStringNoThrow(); // ### Check that name and value are well formed @@ -1784,8 +1803,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(SimpleCallContext ReturnedValue QQmlXMLHttpRequestCtor::method_send(SimpleCallContext *ctx) { Scope scope(ctx); - - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; @@ -1797,38 +1815,36 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_send(SimpleCallContext *ctx) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); QByteArray data; - if (ctx->argumentCount > 0) - data = ctx->arguments[0].toQStringNoThrow().toUtf8(); + if (ctx->callData->argc > 0) + data = ctx->callData->args[0].toQStringNoThrow().toUtf8(); - ScopedValue meObject(scope, constructMeObject(ctx->thisObject, engine)); + ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, engine)); return r->send(meObject, data); } ReturnedValue QQmlXMLHttpRequestCtor::method_abort(SimpleCallContext *ctx) { Scope scope(ctx); - - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; - ScopedValue meObject(scope, constructMeObject(ctx->thisObject, ctx->engine->v8Engine)); + ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, ctx->engine->v8Engine)); return r->abort(meObject); } ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(SimpleCallContext *ctx) { Scope scope(ctx); - - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; QV8Engine *engine = ctx->engine->v8Engine; - if (ctx->argumentCount != 1) + if (ctx->callData->argc != 1) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Loading && @@ -1836,21 +1852,20 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(SimpleCallContext r->readyState() != QQmlXMLHttpRequest::HeadersReceived) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); - return engine->toString(r->header(ctx->arguments[0].toQStringNoThrow())); + return engine->toString(r->header(ctx->callData->args[0].toQStringNoThrow())); } ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(SimpleCallContext *ctx) { Scope scope(ctx); - - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; QV8Engine *engine = ctx->engine->v8Engine; - if (ctx->argumentCount != 0) + if (ctx->callData->argc != 0) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Loading && @@ -1865,8 +1880,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(SimpleCallCon ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(SimpleCallContext *ctx) { Scope scope(ctx); - - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; @@ -1877,8 +1891,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(SimpleCallContext *c ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(SimpleCallContext *ctx) { Scope scope(ctx); - - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; @@ -1896,8 +1909,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(SimpleCallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(SimpleCallContext *ctx) { Scope scope(ctx); - - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; @@ -1917,8 +1929,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(SimpleCallContext *c ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(SimpleCallContext *ctx) { Scope scope(ctx); - - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; @@ -1935,8 +1946,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(SimpleCallContext ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(SimpleCallContext *ctx) { Scope scope(ctx); - - QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->request; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index cd90ed770f..691c8bd9df 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -159,10 +159,10 @@ Returns true if \c object is a valid reference to a Qt or QML object, otherwise */ ReturnedValue QtObject::method_isQtObject(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount == 0) + if (ctx->callData->argc == 0) return QV4::Encode(false); - return QV4::Encode(ctx->arguments[0].as<QV4::QObjectWrapper>() != 0); + return QV4::Encode(ctx->callData->args[0].as<QV4::QObjectWrapper>() != 0); } /*! @@ -173,14 +173,14 @@ All components should be in the range 0-1 inclusive. */ ReturnedValue QtObject::method_rgba(QV4::SimpleCallContext *ctx) { - int argCount = ctx->argumentCount; + int argCount = ctx->callData->argc; if (argCount < 3 || argCount > 4) V4THROW_ERROR("Qt.rgba(): Invalid arguments"); - double r = ctx->arguments[0].toNumber(); - double g = ctx->arguments[1].toNumber(); - double b = ctx->arguments[2].toNumber(); - double a = (argCount == 4) ? ctx->arguments[3].toNumber() : 1; + double r = ctx->callData->args[0].toNumber(); + double g = ctx->callData->args[1].toNumber(); + double b = ctx->callData->args[2].toNumber(); + double a = (argCount == 4) ? ctx->callData->args[3].toNumber() : 1; if (r < 0.0) r=0.0; if (r > 1.0) r=1.0; @@ -202,14 +202,14 @@ All components should be in the range 0-1 inclusive. */ ReturnedValue QtObject::method_hsla(QV4::SimpleCallContext *ctx) { - int argCount = ctx->argumentCount; + int argCount = ctx->callData->argc; if (argCount < 3 || argCount > 4) V4THROW_ERROR("Qt.hsla(): Invalid arguments"); - double h = ctx->arguments[0].toNumber(); - double s = ctx->arguments[1].toNumber(); - double l = ctx->arguments[2].toNumber(); - double a = (argCount == 4) ? ctx->arguments[3].toNumber() : 1; + double h = ctx->callData->args[0].toNumber(); + double s = ctx->callData->args[1].toNumber(); + double l = ctx->callData->args[2].toNumber(); + double a = (argCount == 4) ? ctx->callData->args[3].toNumber() : 1; if (h < 0.0) h=0.0; if (h > 1.0) h=1.0; @@ -233,14 +233,14 @@ basic type. */ ReturnedValue QtObject::method_colorEqual(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 2) + if (ctx->callData->argc != 2) V4THROW_ERROR("Qt.colorEqual(): Invalid arguments"); bool ok = false; QV8Engine *v8engine = ctx->engine->v8Engine; - QVariant lhs = v8engine->toVariant(ctx->arguments[0], -1); + QVariant lhs = v8engine->toVariant(ctx->callData->args[0], -1); if (lhs.userType() == QVariant::String) { lhs = QQmlStringConverters::colorFromString(lhs.toString(), &ok); if (!ok) { @@ -250,7 +250,7 @@ ReturnedValue QtObject::method_colorEqual(QV4::SimpleCallContext *ctx) V4THROW_ERROR("Qt.colorEqual(): Invalid arguments"); } - QVariant rhs = v8engine->toVariant(ctx->arguments[1], -1); + QVariant rhs = v8engine->toVariant(ctx->callData->args[1], -1); if (rhs.userType() == QVariant::String) { rhs = QQmlStringConverters::colorFromString(rhs.toString(), &ok); if (!ok) { @@ -273,13 +273,13 @@ The returned object has \c x, \c y, \c width and \c height attributes with the g */ ReturnedValue QtObject::method_rect(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 4) + if (ctx->callData->argc != 4) V4THROW_ERROR("Qt.rect(): Invalid arguments"); - double x = ctx->arguments[0].toNumber(); - double y = ctx->arguments[1].toNumber(); - double w = ctx->arguments[2].toNumber(); - double h = ctx->arguments[3].toNumber(); + double x = ctx->callData->args[0].toNumber(); + double y = ctx->callData->args[1].toNumber(); + double w = ctx->callData->args[2].toNumber(); + double h = ctx->callData->args[3].toNumber(); return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QRectF(x, y, w, h))); } @@ -290,11 +290,11 @@ Returns a Point with the specified \c x and \c y coordinates. */ ReturnedValue QtObject::method_point(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 2) + if (ctx->callData->argc != 2) V4THROW_ERROR("Qt.point(): Invalid arguments"); - double x = ctx->arguments[0].toNumber(); - double y = ctx->arguments[1].toNumber(); + double x = ctx->callData->args[0].toNumber(); + double y = ctx->callData->args[1].toNumber(); return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QPointF(x, y))); } @@ -305,11 +305,11 @@ Returns a Size with the specified \c width and \c height. */ ReturnedValue QtObject::method_size(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 2) + if (ctx->callData->argc != 2) V4THROW_ERROR("Qt.size(): Invalid arguments"); - double w = ctx->arguments[0].toNumber(); - double h = ctx->arguments[1].toNumber(); + double w = ctx->callData->args[0].toNumber(); + double h = ctx->callData->args[1].toNumber(); return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QSizeF(w, h))); } @@ -324,12 +324,12 @@ Invalid keys will be ignored. */ ReturnedValue QtObject::method_font(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 1 || !ctx->arguments[0].isObject()) + if (ctx->callData->argc != 1 || !ctx->callData->args[0].isObject()) V4THROW_ERROR("Qt.font(): Invalid arguments"); QV8Engine *v8engine = ctx->engine->v8Engine; bool ok = false; - QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(ctx->arguments[0]), v8engine, &ok); + QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(ctx->callData->args[0]), v8engine, &ok); if (!ok) V4THROW_ERROR("Qt.font(): Invalid argument: no valid font subproperties specified"); return v8engine->fromVariant(v); @@ -343,12 +343,12 @@ Returns a Vector2D with the specified \c x and \c y. */ ReturnedValue QtObject::method_vector2d(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 2) + if (ctx->callData->argc != 2) V4THROW_ERROR("Qt.vector2d(): Invalid arguments"); float xy[3]; // qvector2d uses float internally - xy[0] = ctx->arguments[0].toNumber(); - xy[1] = ctx->arguments[1].toNumber(); + xy[0] = ctx->callData->args[0].toNumber(); + xy[1] = ctx->callData->args[1].toNumber(); const void *params[] = { xy }; QV8Engine *v8engine = ctx->engine->v8Engine; @@ -361,13 +361,13 @@ Returns a Vector3D with the specified \c x, \c y and \c z. */ ReturnedValue QtObject::method_vector3d(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 3) + if (ctx->callData->argc != 3) V4THROW_ERROR("Qt.vector3d(): Invalid arguments"); float xyz[3]; // qvector3d uses float internally - xyz[0] = ctx->arguments[0].toNumber(); - xyz[1] = ctx->arguments[1].toNumber(); - xyz[2] = ctx->arguments[2].toNumber(); + xyz[0] = ctx->callData->args[0].toNumber(); + xyz[1] = ctx->callData->args[1].toNumber(); + xyz[2] = ctx->callData->args[2].toNumber(); const void *params[] = { xyz }; QV8Engine *v8engine = ctx->engine->v8Engine; @@ -380,14 +380,14 @@ Returns a Vector4D with the specified \c x, \c y, \c z and \c w. */ ReturnedValue QtObject::method_vector4d(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 4) + if (ctx->callData->argc != 4) V4THROW_ERROR("Qt.vector4d(): Invalid arguments"); float xyzw[4]; // qvector4d uses float internally - xyzw[0] = ctx->arguments[0].toNumber(); - xyzw[1] = ctx->arguments[1].toNumber(); - xyzw[2] = ctx->arguments[2].toNumber(); - xyzw[3] = ctx->arguments[3].toNumber(); + xyzw[0] = ctx->callData->args[0].toNumber(); + xyzw[1] = ctx->callData->args[1].toNumber(); + xyzw[2] = ctx->callData->args[2].toNumber(); + xyzw[3] = ctx->callData->args[3].toNumber(); const void *params[] = { xyzw }; QV8Engine *v8engine = ctx->engine->v8Engine; @@ -400,14 +400,14 @@ Returns a Quaternion with the specified \c scalar, \c x, \c y, and \c z. */ ReturnedValue QtObject::method_quaternion(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 4) + if (ctx->callData->argc != 4) V4THROW_ERROR("Qt.quaternion(): Invalid arguments"); qreal sxyz[4]; // qquaternion uses qreal internally - sxyz[0] = ctx->arguments[0].toNumber(); - sxyz[1] = ctx->arguments[1].toNumber(); - sxyz[2] = ctx->arguments[2].toNumber(); - sxyz[3] = ctx->arguments[3].toNumber(); + sxyz[0] = ctx->callData->args[0].toNumber(); + sxyz[1] = ctx->callData->args[1].toNumber(); + sxyz[2] = ctx->callData->args[2].toNumber(); + sxyz[3] = ctx->callData->args[3].toNumber(); const void *params[] = { sxyz }; QV8Engine *v8engine = ctx->engine->v8Engine; @@ -425,34 +425,34 @@ ReturnedValue QtObject::method_matrix4x4(QV4::SimpleCallContext *ctx) { QV8Engine *v8engine = ctx->engine->v8Engine; - if (ctx->argumentCount == 1 && ctx->arguments[0].isObject()) { + if (ctx->callData->argc == 1 && ctx->callData->args[0].isObject()) { bool ok = false; - QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(ctx->arguments[0]), v8engine, &ok); + QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(ctx->callData->args[0]), v8engine, &ok); if (!ok) V4THROW_ERROR("Qt.matrix4x4(): Invalid argument: not a valid matrix4x4 values array"); return v8engine->fromVariant(v); } - if (ctx->argumentCount != 16) + if (ctx->callData->argc != 16) V4THROW_ERROR("Qt.matrix4x4(): Invalid arguments"); qreal vals[16]; // qmatrix4x4 uses qreal internally - vals[0] = ctx->arguments[0].toNumber(); - vals[1] = ctx->arguments[1].toNumber(); - vals[2] = ctx->arguments[2].toNumber(); - vals[3] = ctx->arguments[3].toNumber(); - vals[4] = ctx->arguments[4].toNumber(); - vals[5] = ctx->arguments[5].toNumber(); - vals[6] = ctx->arguments[6].toNumber(); - vals[7] = ctx->arguments[7].toNumber(); - vals[8] = ctx->arguments[8].toNumber(); - vals[9] = ctx->arguments[9].toNumber(); - vals[10] = ctx->arguments[10].toNumber(); - vals[11] = ctx->arguments[11].toNumber(); - vals[12] = ctx->arguments[12].toNumber(); - vals[13] = ctx->arguments[13].toNumber(); - vals[14] = ctx->arguments[14].toNumber(); - vals[15] = ctx->arguments[15].toNumber(); + vals[0] = ctx->callData->args[0].toNumber(); + vals[1] = ctx->callData->args[1].toNumber(); + vals[2] = ctx->callData->args[2].toNumber(); + vals[3] = ctx->callData->args[3].toNumber(); + vals[4] = ctx->callData->args[4].toNumber(); + vals[5] = ctx->callData->args[5].toNumber(); + vals[6] = ctx->callData->args[6].toNumber(); + vals[7] = ctx->callData->args[7].toNumber(); + vals[8] = ctx->callData->args[8].toNumber(); + vals[9] = ctx->callData->args[9].toNumber(); + vals[10] = ctx->callData->args[10].toNumber(); + vals[11] = ctx->callData->args[11].toNumber(); + vals[12] = ctx->callData->args[12].toNumber(); + vals[13] = ctx->callData->args[13].toNumber(); + vals[14] = ctx->callData->args[14].toNumber(); + vals[15] = ctx->callData->args[15].toNumber(); const void *params[] = { vals }; return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 1, params)); @@ -474,11 +474,11 @@ If \c factor is not supplied, returns a color 50% lighter than \c baseColor (fac */ ReturnedValue QtObject::method_lighter(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 1 && ctx->argumentCount != 2) + if (ctx->callData->argc != 1 && ctx->callData->argc != 2) V4THROW_ERROR("Qt.lighter(): Invalid arguments"); QV8Engine *v8engine = ctx->engine->v8Engine; - QVariant v = v8engine->toVariant(ctx->arguments[0], -1); + QVariant v = v8engine->toVariant(ctx->callData->args[0], -1); if (v.userType() == QVariant::String) { bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); @@ -490,8 +490,8 @@ ReturnedValue QtObject::method_lighter(QV4::SimpleCallContext *ctx) } qreal factor = 1.5; - if (ctx->argumentCount == 2) - factor = ctx->arguments[1].toNumber(); + if (ctx->callData->argc == 2) + factor = ctx->callData->args[1].toNumber(); return v8engine->fromVariant(QQml_colorProvider()->lighter(v, factor)); } @@ -513,11 +513,11 @@ If \c factor is not supplied, returns a color 50% darker than \c baseColor (fact */ ReturnedValue QtObject::method_darker(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 1 && ctx->argumentCount != 2) + if (ctx->callData->argc != 1 && ctx->callData->argc != 2) V4THROW_ERROR("Qt.darker(): Invalid arguments"); QV8Engine *v8engine = ctx->engine->v8Engine; - QVariant v = v8engine->toVariant(ctx->arguments[0], -1); + QVariant v = v8engine->toVariant(ctx->callData->args[0], -1); if (v.userType() == QVariant::String) { bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); @@ -529,8 +529,8 @@ ReturnedValue QtObject::method_darker(QV4::SimpleCallContext *ctx) } qreal factor = 2.0; - if (ctx->argumentCount == 2) - factor = ctx->arguments[1].toNumber(); + if (ctx->callData->argc == 2) + factor = ctx->callData->args[1].toNumber(); return v8engine->fromVariant(QQml_colorProvider()->darker(v, factor)); } @@ -561,13 +561,13 @@ ReturnedValue QtObject::method_darker(QV4::SimpleCallContext *ctx) */ ReturnedValue QtObject::method_tint(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 2) + if (ctx->callData->argc != 2) V4THROW_ERROR("Qt.tint(): Invalid arguments"); QV8Engine *v8engine = ctx->engine->v8Engine; // base color - QVariant v1 = v8engine->toVariant(ctx->arguments[0], -1); + QVariant v1 = v8engine->toVariant(ctx->callData->args[0], -1); if (v1.userType() == QVariant::String) { bool ok = false; v1 = QQmlStringConverters::colorFromString(v1.toString(), &ok); @@ -579,7 +579,7 @@ ReturnedValue QtObject::method_tint(QV4::SimpleCallContext *ctx) } // tint color - QVariant v2 = v8engine->toVariant(ctx->arguments[1], -1); + QVariant v2 = v8engine->toVariant(ctx->callData->args[1], -1); if (v2.userType() == QVariant::String) { bool ok = false; v2 = QQmlStringConverters::colorFromString(v2.toString(), &ok); @@ -611,20 +611,20 @@ If \a format is not specified, \a date is formatted using */ ReturnedValue QtObject::method_formatDate(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount < 1 || ctx->argumentCount > 2) + if (ctx->callData->argc < 1 || ctx->callData->argc > 2) V4THROW_ERROR("Qt.formatDate(): Invalid arguments"); QV8Engine *v8engine = ctx->engine->v8Engine; Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; - QDate date = v8engine->toVariant(ctx->arguments[0], -1).toDateTime().date(); + QDate date = v8engine->toVariant(ctx->callData->args[0], -1).toDateTime().date(); QString formattedDate; - if (ctx->argumentCount == 2) { - if (String *s = ctx->arguments[1].asString()) { + if (ctx->callData->argc == 2) { + if (String *s = ctx->callData->args[1].asString()) { QString format = s->toQString(); formattedDate = date.toString(format); - } else if (ctx->arguments[1].isNumber()) { - quint32 intFormat = ctx->arguments[1].asDouble(); + } else if (ctx->callData->args[1].isNumber()) { + quint32 intFormat = ctx->callData->args[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedDate = date.toString(format); } else { @@ -654,26 +654,26 @@ If \a format is not specified, \a time is formatted using */ ReturnedValue QtObject::method_formatTime(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount < 1 || ctx->argumentCount > 2) + if (ctx->callData->argc < 1 || ctx->callData->argc > 2) V4THROW_ERROR("Qt.formatTime(): Invalid arguments"); QV8Engine *v8engine = ctx->engine->v8Engine; - QVariant argVariant = v8engine->toVariant(ctx->arguments[0], -1); + QVariant argVariant = v8engine->toVariant(ctx->callData->args[0], -1); QTime time; - if (ctx->arguments[0].asDateObject() || (argVariant.type() == QVariant::String)) + if (ctx->callData->args[0].asDateObject() || (argVariant.type() == QVariant::String)) time = argVariant.toDateTime().time(); else // if (argVariant.type() == QVariant::Time), or invalid. time = argVariant.toTime(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; QString formattedTime; - if (ctx->argumentCount == 2) { - if (String *s = ctx->arguments[1].asString()) { + if (ctx->callData->argc == 2) { + if (String *s = ctx->callData->args[1].asString()) { QString format = s->toQString(); formattedTime = time.toString(format); - } else if (ctx->arguments[1].isNumber()) { - quint32 intFormat = ctx->arguments[1].asDouble(); + } else if (ctx->callData->args[1].isNumber()) { + quint32 intFormat = ctx->callData->args[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedTime = time.toString(format); } else { @@ -778,20 +778,20 @@ with the \a format values below to produce the following results: */ ReturnedValue QtObject::method_formatDateTime(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount < 1 || ctx->argumentCount > 2) + if (ctx->callData->argc < 1 || ctx->callData->argc > 2) V4THROW_ERROR("Qt.formatDateTime(): Invalid arguments"); QV8Engine *v8engine = ctx->engine->v8Engine; Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; - QDateTime dt = v8engine->toVariant(ctx->arguments[0], -1).toDateTime(); + QDateTime dt = v8engine->toVariant(ctx->callData->args[0], -1).toDateTime(); QString formattedDt; - if (ctx->argumentCount == 2) { - if (String *s = ctx->arguments[1].asString()) { + if (ctx->callData->argc == 2) { + if (String *s = ctx->callData->args[1].asString()) { QString format = s->toQString(); formattedDt = dt.toString(format); - } else if (ctx->arguments[1].isNumber()) { - quint32 intFormat = ctx->arguments[1].asDouble(); + } else if (ctx->callData->args[1].isNumber()) { + quint32 intFormat = ctx->callData->args[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedDt = dt.toString(format); } else { @@ -810,7 +810,7 @@ Attempts to open the specified \c target url in an external application, based o */ ReturnedValue QtObject::method_openUrlExternally(QV4::SimpleCallContext *ctx) { - if (ctx->argumentCount != 1) + if (ctx->callData->argc != 1) return QV4::Encode(false); QV8Engine *v8engine = ctx->engine->v8Engine; @@ -827,7 +827,7 @@ ReturnedValue QtObject::method_resolvedUrl(QV4::SimpleCallContext *ctx) { QV8Engine *v8engine = ctx->engine->v8Engine; - QUrl url = v8engine->toVariant(ctx->arguments[0], -1).toUrl(); + QUrl url = v8engine->toVariant(ctx->callData->args[0], -1).toUrl(); QQmlEngine *e = v8engine->engine(); QQmlEnginePrivate *p = 0; if (e) p = QQmlEnginePrivate::get(e); @@ -848,7 +848,7 @@ Returns a list of the font families available to the application. */ ReturnedValue QtObject::method_fontFamilies(SimpleCallContext *ctx) { - if (ctx->argumentCount != 0) + if (ctx->callData->argc != 0) V4THROW_ERROR("Qt.fontFamilies(): Invalid arguments"); QV8Engine *v8engine = ctx->engine->v8Engine; @@ -861,10 +861,10 @@ Returns a hex string of the md5 hash of \c data. */ ReturnedValue QtObject::method_md5(SimpleCallContext *ctx) { - if (ctx->argumentCount != 1) + if (ctx->callData->argc != 1) V4THROW_ERROR("Qt.md5(): Invalid arguments"); - QByteArray data = ctx->arguments[0].toQStringNoThrow().toUtf8(); + QByteArray data = ctx->callData->args[0].toQStringNoThrow().toUtf8(); QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5); return Value::fromString(ctx, QLatin1String(result.toHex())).asReturnedValue(); } @@ -875,10 +875,10 @@ Binary to ASCII - this function returns a base64 encoding of \c data. */ ReturnedValue QtObject::method_btoa(SimpleCallContext *ctx) { - if (ctx->argumentCount != 1) + if (ctx->callData->argc != 1) V4THROW_ERROR("Qt.btoa(): Invalid arguments"); - QByteArray data = ctx->arguments[0].toQStringNoThrow().toUtf8(); + QByteArray data = ctx->callData->args[0].toQStringNoThrow().toUtf8(); return Value::fromString(ctx, QLatin1String(data.toBase64())).asReturnedValue(); } @@ -889,10 +889,10 @@ ASCII to binary - this function returns a base64 decoding of \c data. */ ReturnedValue QtObject::method_atob(SimpleCallContext *ctx) { - if (ctx->argumentCount != 1) + if (ctx->callData->argc != 1) V4THROW_ERROR("Qt.atob(): Invalid arguments"); - QByteArray data = ctx->arguments[0].toQStringNoThrow().toLatin1(); + QByteArray data = ctx->callData->args[0].toQStringNoThrow().toLatin1(); return Value::fromString(ctx, QString::fromUtf8(QByteArray::fromBase64(data))).asReturnedValue(); } @@ -939,7 +939,7 @@ See \l {Dynamic QML Object Creation from JavaScript} for more information on usi ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx) { Scope scope(ctx); - if (ctx->argumentCount < 2 || ctx->argumentCount > 3) + if (ctx->callData->argc < 2 || ctx->callData->argc > 3) V4THROW_ERROR("Qt.createQmlObject(): Invalid arguments"); struct Error { @@ -979,13 +979,13 @@ ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx) effectiveContext = context->asQQmlContext(); Q_ASSERT(context && effectiveContext); - QString qml = ctx->arguments[0].toQStringNoThrow(); + QString qml = ctx->callData->args[0].toQStringNoThrow(); if (qml.isEmpty()) return QV4::Encode::null(); QUrl url; - if (ctx->argumentCount > 2) - url = QUrl(ctx->arguments[2].toQStringNoThrow()); + if (ctx->callData->argc > 2) + url = QUrl(ctx->callData->args[2].toQStringNoThrow()); else url = QUrl(QLatin1String("inline")); @@ -993,7 +993,7 @@ ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx) url = context->resolvedUrl(url); QObject *parentArg = 0; - QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, ctx->arguments[1]); + QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, ctx->callData->args[1]); if (!!qobjectWrapper) parentArg = qobjectWrapper->object(); if (!parentArg) @@ -1073,7 +1073,7 @@ ReturnedValue QtObject::method_createComponent(SimpleCallContext *ctx) { const QString invalidArgs = QStringLiteral("Qt.createComponent(): Invalid arguments"); const QString invalidParent = QStringLiteral("Qt.createComponent(): Invalid parent object"); - if (ctx->argumentCount < 1 || ctx->argumentCount > 3) + if (ctx->callData->argc < 1 || ctx->callData->argc > 3) ctx->throwError(invalidArgs); QV8Engine *v8engine = ctx->engine->v8Engine; @@ -1085,7 +1085,7 @@ ReturnedValue QtObject::method_createComponent(SimpleCallContext *ctx) effectiveContext = 0; Q_ASSERT(context); - QString arg = ctx->arguments[0].toQStringNoThrow(); + QString arg = ctx->callData->args[0].toQStringNoThrow(); if (arg.isEmpty()) return QV4::Encode::null(); @@ -1093,23 +1093,23 @@ ReturnedValue QtObject::method_createComponent(SimpleCallContext *ctx) QObject *parentArg = 0; int consumedCount = 1; - if (ctx->argumentCount > 1) { - Value lastArg = ctx->arguments[ctx->argumentCount-1]; + if (ctx->callData->argc > 1) { + Value lastArg = ctx->callData->args[ctx->callData->argc-1]; // The second argument could be the mode enum - if (ctx->arguments[1].isInteger()) { - int mode = ctx->arguments[1].integerValue(); + if (ctx->callData->args[1].isInteger()) { + int mode = ctx->callData->args[1].integerValue(); if (mode != int(QQmlComponent::PreferSynchronous) && mode != int(QQmlComponent::Asynchronous)) ctx->throwError(invalidArgs); compileMode = QQmlComponent::CompilationMode(mode); consumedCount += 1; } else { // The second argument could be the parent only if there are exactly two args - if ((ctx->argumentCount != 2) || !(lastArg.isObject() || lastArg.isNull())) + if ((ctx->callData->argc != 2) || !(lastArg.isObject() || lastArg.isNull())) ctx->throwError(invalidArgs); } - if (consumedCount < ctx->argumentCount) { + if (consumedCount < ctx->callData->argc) { if (lastArg.isObject()) { if (QV4::QObjectWrapper *qobjectWrapper = lastArg.as<QV4::QObjectWrapper>()) parentArg = qobjectWrapper->object(); @@ -1155,14 +1155,14 @@ ReturnedValue QtObject::method_createComponent(SimpleCallContext *ctx) ReturnedValue QtObject::method_locale(SimpleCallContext *ctx) { QString code; - if (ctx->argumentCount > 1) + if (ctx->callData->argc > 1) V4THROW_ERROR("locale() requires 0 or 1 argument"); - if (ctx->argumentCount == 1 && !ctx->arguments[0].isString()) + if (ctx->callData->argc == 1 && !ctx->callData->args[0].isString()) V4THROW_TYPE("locale(): argument (locale code) must be a string"); QV8Engine *v8engine = ctx->engine->v8Engine; - if (ctx->argumentCount == 1) - code = ctx->arguments[0].toQStringNoThrow(); + if (ctx->callData->argc == 1) + code = ctx->callData->args[0].toQStringNoThrow(); return QQmlLocale::locale(v8engine, code); } @@ -1248,9 +1248,9 @@ DEFINE_MANAGED_VTABLE(BindingFunction); */ ReturnedValue QtObject::method_binding(SimpleCallContext *ctx) { - if (ctx->argumentCount != 1) + if (ctx->callData->argc != 1) V4THROW_ERROR("binding() requires 1 argument"); - QV4::FunctionObject *f = ctx->arguments[0].asFunctionObject(); + QV4::FunctionObject *f = ctx->callData->args[0].asFunctionObject(); if (!f) V4THROW_TYPE("binding(): argument (binding expression) must be a function"); @@ -1261,7 +1261,7 @@ ReturnedValue QtObject::method_binding(SimpleCallContext *ctx) ReturnedValue QtObject::method_get_platform(SimpleCallContext *ctx) { // ### inefficient. Should be just a value based getter - Object *o = ctx->thisObject.asObject(); + Object *o = ctx->callData->thisObject.asObject(); if (!o) ctx->throwTypeError(); QtObject *qt = o->as<QtObject>(); @@ -1278,7 +1278,7 @@ ReturnedValue QtObject::method_get_platform(SimpleCallContext *ctx) ReturnedValue QtObject::method_get_application(SimpleCallContext *ctx) { // ### inefficient. Should be just a value based getter - Object *o = ctx->thisObject.asObject(); + Object *o = ctx->callData->thisObject.asObject(); if (!o) ctx->throwTypeError(); QtObject *qt = o->as<QtObject>(); @@ -1360,11 +1360,11 @@ static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, SimpleCallCont QString result; QV4::ExecutionEngine *v4 = ctx->engine; - for (int i = 0; i < ctx->argumentCount; ++i) { + for (int i = 0; i < ctx->callData->argc; ++i) { if (i != 0) result.append(QLatin1Char(' ')); - QV4::Value value = ctx->arguments[i]; + QV4::Value value = ctx->callData->args[i]; if (value.asArrayObject()) result.append(QStringLiteral("[") + value.toQStringNoThrow() + QStringLiteral("]")); else @@ -1458,24 +1458,24 @@ QV4::ReturnedValue ConsoleObject::method_profileEnd(SimpleCallContext *ctx) QV4::ReturnedValue ConsoleObject::method_time(SimpleCallContext *ctx) { - if (ctx->argumentCount != 1) + if (ctx->callData->argc != 1) V4THROW_ERROR("console.time(): Invalid arguments"); QV8Engine *v8engine = ctx->engine->v8Engine; - QString name = ctx->arguments[0].toQStringNoThrow(); + QString name = ctx->callData->args[0].toQStringNoThrow(); v8engine->startTimer(name); return QV4::Encode::undefined(); } QV4::ReturnedValue ConsoleObject::method_timeEnd(SimpleCallContext *ctx) { - if (ctx->argumentCount != 1) + if (ctx->callData->argc != 1) V4THROW_ERROR("console.time(): Invalid arguments"); QV8Engine *v8engine = ctx->engine->v8Engine; - QString name = ctx->arguments[0].toQStringNoThrow(); + QString name = ctx->callData->args[0].toQStringNoThrow(); bool wasRunning; qint64 elapsed = v8engine->stopTimer(name, &wasRunning); if (wasRunning) { @@ -1488,8 +1488,8 @@ QV4::ReturnedValue ConsoleObject::method_count(SimpleCallContext *ctx) { // first argument: name to print. Ignore any additional arguments QString name; - if (ctx->argumentCount > 0) - name = ctx->arguments[0].toQStringNoThrow(); + if (ctx->callData->argc > 0) + name = ctx->callData->args[0].toQStringNoThrow(); QV4::ExecutionEngine *v4 = ctx->engine; QV8Engine *v8engine = ctx->engine->v8Engine; @@ -1509,7 +1509,7 @@ QV4::ReturnedValue ConsoleObject::method_count(SimpleCallContext *ctx) QV4::ReturnedValue ConsoleObject::method_trace(SimpleCallContext *ctx) { - if (ctx->argumentCount != 0) + if (ctx->callData->argc != 0) V4THROW_ERROR("console.trace(): Invalid arguments"); QV4::ExecutionEngine *v4 = ctx->engine; @@ -1530,18 +1530,18 @@ QV4::ReturnedValue ConsoleObject::method_warn(SimpleCallContext *ctx) QV4::ReturnedValue ConsoleObject::method_assert(SimpleCallContext *ctx) { - if (ctx->argumentCount == 0) + if (ctx->callData->argc == 0) V4THROW_ERROR("console.assert(): Missing argument"); QV4::ExecutionEngine *v4 = ctx->engine; - if (!ctx->arguments[0].toBoolean()) { + if (!ctx->callData->args[0].toBoolean()) { QString message; - for (int i = 1; i < ctx->argumentCount; ++i) { + for (int i = 1; i < ctx->callData->argc; ++i) { if (i != 1) message.append(QLatin1Char(' ')); - message.append(ctx->arguments[i].toQStringNoThrow()); + message.append(ctx->callData->args[i].toQStringNoThrow()); } QString stack = jsStack(v4); @@ -1556,7 +1556,7 @@ QV4::ReturnedValue ConsoleObject::method_assert(SimpleCallContext *ctx) QV4::ReturnedValue ConsoleObject::method_exception(SimpleCallContext *ctx) { - if (ctx->argumentCount == 0) + if (ctx->callData->argc == 0) V4THROW_ERROR("console.exception(): Missing argument"); writeToConsole(Error, ctx, true); @@ -1614,29 +1614,29 @@ void QV4::GlobalExtensions::init(QQmlEngine *qmlEngine, Object *globalObject) */ ReturnedValue GlobalExtensions::method_qsTranslate(SimpleCallContext *ctx) { - if (ctx->argumentCount < 2) + if (ctx->callData->argc < 2) V4THROW_ERROR("qsTranslate() requires at least two arguments"); - if (!ctx->arguments[0].isString()) + if (!ctx->callData->args[0].isString()) V4THROW_ERROR("qsTranslate(): first argument (context) must be a string"); - if (!ctx->arguments[1].isString()) + if (!ctx->callData->args[1].isString()) V4THROW_ERROR("qsTranslate(): second argument (sourceText) must be a string"); - if ((ctx->argumentCount > 2) && !ctx->arguments[2].isString()) + if ((ctx->callData->argc > 2) && !ctx->callData->args[2].isString()) V4THROW_ERROR("qsTranslate(): third argument (disambiguation) must be a string"); - QString context = ctx->arguments[0].toQStringNoThrow(); - QString text = ctx->arguments[1].toQStringNoThrow(); + QString context = ctx->callData->args[0].toQStringNoThrow(); + QString text = ctx->callData->args[1].toQStringNoThrow(); QString comment; - if (ctx->argumentCount > 2) comment = ctx->arguments[2].toQStringNoThrow(); + if (ctx->callData->argc > 2) comment = ctx->callData->args[2].toQStringNoThrow(); int i = 3; - if (ctx->argumentCount > i && ctx->arguments[i].isString()) { + if (ctx->callData->argc > i && ctx->callData->args[i].isString()) { qWarning("qsTranslate(): specifying the encoding as fourth argument is deprecated"); ++i; } int n = -1; - if (ctx->argumentCount > i) - n = ctx->arguments[i].toInt32(); + if (ctx->callData->argc > i) + n = ctx->callData->args[i].toInt32(); QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(), @@ -1670,9 +1670,9 @@ ReturnedValue GlobalExtensions::method_qsTranslate(SimpleCallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTranslateNoOp(SimpleCallContext *ctx) { - if (ctx->argumentCount < 2) + if (ctx->callData->argc < 2) return QV4::Encode::undefined(); - return ctx->arguments[1].asReturnedValue(); + return ctx->callData->args[1].asReturnedValue(); } /*! @@ -1694,13 +1694,13 @@ ReturnedValue GlobalExtensions::method_qsTranslateNoOp(SimpleCallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTr(SimpleCallContext *ctx) { - if (ctx->argumentCount < 1) + if (ctx->callData->argc < 1) V4THROW_ERROR("qsTr() requires at least one argument"); - if (!ctx->arguments[0].isString()) + if (!ctx->callData->args[0].isString()) V4THROW_ERROR("qsTr(): first argument (sourceText) must be a string"); - if ((ctx->argumentCount > 1) && !ctx->arguments[1].isString()) + if ((ctx->callData->argc > 1) && !ctx->callData->args[1].isString()) V4THROW_ERROR("qsTr(): second argument (disambiguation) must be a string"); - if ((ctx->argumentCount > 2) && !ctx->arguments[2].isNumber()) + if ((ctx->callData->argc > 2) && !ctx->callData->args[2].isNumber()) V4THROW_ERROR("qsTr(): third argument (n) must be a number"); QV8Engine *v8engine = ctx->engine->v8Engine; @@ -1710,13 +1710,13 @@ ReturnedValue GlobalExtensions::method_qsTr(SimpleCallContext *ctx) int lastSlash = path.lastIndexOf(QLatin1Char('/')); QString context = (lastSlash > -1) ? path.mid(lastSlash + 1, path.length()-lastSlash-5) : QString(); - QString text = ctx->arguments[0].toQStringNoThrow(); + QString text = ctx->callData->args[0].toQStringNoThrow(); QString comment; - if (ctx->argumentCount > 1) - comment = ctx->arguments[1].toQStringNoThrow(); + if (ctx->callData->argc > 1) + comment = ctx->callData->args[1].toQStringNoThrow(); int n = -1; - if (ctx->argumentCount > 2) - n = ctx->arguments[2].toInt32(); + if (ctx->callData->argc > 2) + n = ctx->callData->args[2].toInt32(); QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(), comment.toUtf8().constData(), n); @@ -1748,9 +1748,9 @@ ReturnedValue GlobalExtensions::method_qsTr(SimpleCallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTrNoOp(SimpleCallContext *ctx) { - if (ctx->argumentCount < 1) + if (ctx->callData->argc < 1) return QV4::Encode::undefined(); - return ctx->arguments[0].asReturnedValue(); + return ctx->callData->args[0].asReturnedValue(); } /*! @@ -1785,18 +1785,18 @@ ReturnedValue GlobalExtensions::method_qsTrNoOp(SimpleCallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTrId(SimpleCallContext *ctx) { - if (ctx->argumentCount < 1) + if (ctx->callData->argc < 1) V4THROW_ERROR("qsTrId() requires at least one argument"); - if (!ctx->arguments[0].isString()) + if (!ctx->callData->args[0].isString()) V4THROW_TYPE("qsTrId(): first argument (id) must be a string"); - if (ctx->argumentCount > 1 && !ctx->arguments[1].isNumber()) + if (ctx->callData->argc > 1 && !ctx->callData->args[1].isNumber()) V4THROW_TYPE("qsTrId(): second argument (n) must be a number"); int n = -1; - if (ctx->argumentCount > 1) - n = ctx->arguments[1].toInt32(); + if (ctx->callData->argc > 1) + n = ctx->callData->args[1].toInt32(); - return Value::fromString(ctx, qtTrId(ctx->arguments[0].toQStringNoThrow().toUtf8().constData(), n)).asReturnedValue(); + return Value::fromString(ctx, qtTrId(ctx->callData->args[0].toQStringNoThrow().toUtf8().constData(), n)).asReturnedValue(); } /*! @@ -1817,9 +1817,9 @@ ReturnedValue GlobalExtensions::method_qsTrId(SimpleCallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTrIdNoOp(SimpleCallContext *ctx) { - if (ctx->argumentCount < 1) + if (ctx->callData->argc < 1) return QV4::Encode::undefined(); - return ctx->arguments[0].asReturnedValue(); + return ctx->callData->args[0].asReturnedValue(); } #endif // QT_NO_TRANSLATION @@ -1835,11 +1835,11 @@ QV4::ReturnedValue GlobalExtensions::method_gc(SimpleCallContext *ctx) ReturnedValue GlobalExtensions::method_string_arg(SimpleCallContext *ctx) { - QString value = ctx->thisObject.toQStringNoThrow(); - if (ctx->argumentCount != 1) + QString value = ctx->callData->thisObject.toQStringNoThrow(); + if (ctx->callData->argc != 1) V4THROW_ERROR("String.arg(): Invalid arguments"); - QV4::Value arg = ctx->arguments[0]; + QV4::Value arg = ctx->callData->args[0]; if (arg.isInteger()) return Value::fromString(ctx, value.arg(arg.integerValue())).asReturnedValue(); else if (arg.isDouble()) diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 148332c4bd..130ed291c5 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1702,7 +1702,8 @@ int QQmlDelegateModelItemMetaType::parseGroups(const QV4::Value &groups) const QV4::ReturnedValue QQmlDelegateModelItem::get_model(QV4::SimpleCallContext *ctx) { - QQmlDelegateModelItemObject *o = ctx->thisObject.as<QQmlDelegateModelItemObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); if (!o->item->metaType->model) @@ -1713,7 +1714,8 @@ QV4::ReturnedValue QQmlDelegateModelItem::get_model(QV4::SimpleCallContext *ctx) QV4::ReturnedValue QQmlDelegateModelItem::get_groups(QV4::SimpleCallContext *ctx) { - QQmlDelegateModelItemObject *o = ctx->thisObject.as<QQmlDelegateModelItemObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -1728,17 +1730,18 @@ QV4::ReturnedValue QQmlDelegateModelItem::get_groups(QV4::SimpleCallContext *ctx QV4::ReturnedValue QQmlDelegateModelItem::set_groups(QV4::SimpleCallContext *ctx) { - QQmlDelegateModelItemObject *o = ctx->thisObject.as<QQmlDelegateModelItemObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!ctx->argumentCount) + if (!ctx->callData->argc) ctx->throwTypeError(); if (!o->item->metaType->model) return QV4::Encode::undefined(); QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(o->item->metaType->model); - const int groupFlags = model->m_cacheMetaType->parseGroups(ctx->arguments[0]); + const int groupFlags = model->m_cacheMetaType->parseGroups(ctx->callData->args[0]); const int cacheIndex = model->m_cache.indexOf(o->item); Compositor::iterator it = model->m_compositor.find(Compositor::Cache, cacheIndex); model->setGroups(it, 1, Compositor::Cache, groupFlags); @@ -3132,19 +3135,22 @@ struct QQmlDelegateModelGroupChange : QV4::Object } static QV4::ReturnedValue method_get_index(QV4::SimpleCallContext *ctx) { - QQmlDelegateModelGroupChange *that = ctx->thisObject.as<QQmlDelegateModelGroupChange>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->callData->thisObject.as<QQmlDelegateModelGroupChange>()); if (!that) ctx->throwTypeError(); return QV4::Encode(that->change.index); } static QV4::ReturnedValue method_get_count(QV4::SimpleCallContext *ctx) { - QQmlDelegateModelGroupChange *that = ctx->thisObject.as<QQmlDelegateModelGroupChange>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->callData->thisObject.as<QQmlDelegateModelGroupChange>()); if (!that) ctx->throwTypeError(); return QV4::Encode(that->change.count); } static QV4::ReturnedValue method_get_moveId(QV4::SimpleCallContext *ctx) { - QQmlDelegateModelGroupChange *that = ctx->thisObject.as<QQmlDelegateModelGroupChange>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->callData->thisObject.as<QQmlDelegateModelGroupChange>()); if (!that) ctx->throwTypeError(); if (that->change.moveId < 0) diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index a96a8ee71d..c666372739 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -286,9 +286,9 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::method_sendMessage(QV4::Simp { WorkerEngine *engine = (WorkerEngine*)ctx->engine->v8Engine; - int id = ctx->argumentCount > 1 ? ctx->arguments[1].toInt32() : 0; + int id = ctx->callData->argc > 1 ? ctx->callData->args[1].toInt32() : 0; - QByteArray data = QV4::Serialize::serialize(ctx->argumentCount > 2 ? ctx->arguments[2] : QV4::Value::undefinedValue(), engine); + QByteArray data = QV4::Serialize::serialize(ctx->callData->argc > 2 ? ctx->callData->args[2] : QV4::Value::undefinedValue(), engine); QMutexLocker locker(&engine->p->m_lock); WorkerScript *script = engine->p->workers.value(id); diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index c4ba42c84a..39ebd6bd4c 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -65,7 +65,8 @@ V8_DEFINE_EXTENSION(QQmlAdaptorModelEngineData, engineData) static QV4::ReturnedValue get_index(QV4::SimpleCallContext *ctx) { - QQmlDelegateModelItemObject *o = ctx->thisObject.as<QQmlDelegateModelItemObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -196,7 +197,8 @@ public: static QV4::ReturnedValue get_hasModelChildren(QV4::SimpleCallContext *ctx) { - QQmlDelegateModelItemObject *o = ctx->thisObject.as<QQmlDelegateModelItemObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -339,7 +341,8 @@ bool QQmlDMCachedModelData::resolveIndex(const QQmlAdaptorModel &, int idx) QV4::ReturnedValue QQmlDMCachedModelData::get_property(QV4::SimpleCallContext *ctx, uint propertyId) { - QQmlDelegateModelItemObject *o = ctx->thisObject.as<QQmlDelegateModelItemObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -358,20 +361,21 @@ QV4::ReturnedValue QQmlDMCachedModelData::get_property(QV4::SimpleCallContext *c QV4::ReturnedValue QQmlDMCachedModelData::set_property(QV4::SimpleCallContext *ctx, uint propertyId) { - QQmlDelegateModelItemObject *o = ctx->thisObject.as<QQmlDelegateModelItemObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!ctx->argumentCount) + if (!ctx->callData->argc) ctx->throwTypeError(); if (o->item->index == -1) { QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->item); if (!modelData->cachedData.isEmpty()) { if (modelData->cachedData.count() > 1) { - modelData->cachedData[propertyId] = ctx->engine->v8Engine->toVariant(ctx->arguments[0], QVariant::Invalid); + modelData->cachedData[propertyId] = ctx->engine->v8Engine->toVariant(ctx->callData->args[0], QVariant::Invalid); QMetaObject::activate(o->item, o->item->metaObject(), propertyId, 0); } else if (modelData->cachedData.count() == 1) { - modelData->cachedData[0] = ctx->engine->v8Engine->toVariant(ctx->arguments[0], QVariant::Invalid); + modelData->cachedData[0] = ctx->engine->v8Engine->toVariant(ctx->callData->args[0], QVariant::Invalid); QMetaObject::activate(o->item, o->item->metaObject(), 0, 0); QMetaObject::activate(o->item, o->item->metaObject(), 1, 0); } @@ -577,7 +581,8 @@ public: static QV4::ReturnedValue get_modelData(QV4::SimpleCallContext *ctx) { - QQmlDelegateModelItemObject *o = ctx->thisObject.as<QQmlDelegateModelItemObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -586,13 +591,14 @@ public: static QV4::ReturnedValue set_modelData(QV4::SimpleCallContext *ctx) { - QQmlDelegateModelItemObject *o = ctx->thisObject.as<QQmlDelegateModelItemObject>(); + QV4::Scope scope(ctx); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!ctx->argumentCount) + if (!ctx->callData->argc) ctx->throwTypeError(); - static_cast<QQmlDMListAccessorData *>(o->item)->setModelData(ctx->engine->v8Engine->toVariant(ctx->arguments[0], QVariant::Invalid)); + static_cast<QQmlDMListAccessorData *>(o->item)->setModelData(ctx->engine->v8Engine->toVariant(ctx->callData->args[0], QVariant::Invalid)); return QV4::Encode::undefined(); } diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 4b6f074354..655632c662 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -945,7 +945,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_get_canvas(QV4::SimpleCall { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) return QV4::QObjectWrapper::wrap(ctx->engine, r->context->canvas()); @@ -961,11 +961,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_restore(QV4::SimpleCallCon { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) r->context->popState(); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -976,12 +976,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_reset(QV4::SimpleCallConte { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) r->context->reset(); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -1018,12 +1018,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_save(QV4::SimpleCallContex { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) r->context->pushState(); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } // transformations @@ -1048,12 +1048,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_rotate(QV4::SimpleCallCont { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) - if (ctx->argumentCount == 1) - r->context->rotate(ctx->arguments[0].toNumber()); - return ctx->thisObject.asReturnedValue(); + if (ctx->callData->argc == 1) + r->context->rotate(ctx->callData->args[0].toNumber()); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -1077,13 +1077,13 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_scale(QV4::SimpleCallConte { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) - if (ctx->argumentCount == 2) - r->context->scale(ctx->arguments[0].toNumber(), ctx->arguments[1].toNumber()); - return ctx->thisObject.asReturnedValue(); + if (ctx->callData->argc == 2) + r->context->scale(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber()); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -1123,19 +1123,19 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_setTransform(QV4::SimpleCa { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) - if (ctx->argumentCount == 6) - r->context->setTransform( ctx->arguments[0].toNumber() - , ctx->arguments[1].toNumber() - , ctx->arguments[2].toNumber() - , ctx->arguments[3].toNumber() - , ctx->arguments[4].toNumber() - , ctx->arguments[5].toNumber()); + if (ctx->callData->argc == 6) + r->context->setTransform( ctx->callData->args[0].toNumber() + , ctx->callData->args[1].toNumber() + , ctx->callData->args[2].toNumber() + , ctx->callData->args[3].toNumber() + , ctx->callData->args[4].toNumber() + , ctx->callData->args[5].toNumber()); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -1153,19 +1153,18 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_transform(QV4::SimpleCallC { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) + if (ctx->callData->argc == 6) + r->context->transform( ctx->callData->args[0].toNumber() + , ctx->callData->args[1].toNumber() + , ctx->callData->args[2].toNumber() + , ctx->callData->args[3].toNumber() + , ctx->callData->args[4].toNumber() + , ctx->callData->args[5].toNumber()); - if (ctx->argumentCount == 6) - r->context->transform( ctx->arguments[0].toNumber() - , ctx->arguments[1].toNumber() - , ctx->arguments[2].toNumber() - , ctx->arguments[3].toNumber() - , ctx->arguments[4].toNumber() - , ctx->arguments[5].toNumber()); - - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -1179,13 +1178,14 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_transform(QV4::SimpleCallC */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_translate(QV4::SimpleCallContext *ctx) { - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::ExecutionEngine *v4 = ctx->engine; + QV4::Scope scope(v4); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) - - if (ctx->argumentCount == 2) - r->context->translate(ctx->arguments[0].toNumber(), ctx->arguments[1].toNumber()); - return ctx->thisObject.asReturnedValue(); + if (ctx->callData->argc == 2) + r->context->translate(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber()); + return ctx->callData->thisObject.asReturnedValue(); } @@ -1201,12 +1201,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_resetTransform(QV4::Simple { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) r->context->setTransform(1, 0, 0, 1, 0, 0); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } @@ -1220,13 +1220,13 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_shear(QV4::SimpleCallConte { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) - if (ctx->argumentCount == 2) - r->context->shear(ctx->arguments[0].toNumber(), ctx->arguments[1].toNumber()); + if (ctx->callData->argc == 2) + r->context->shear(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber()); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } // compositing @@ -1239,7 +1239,9 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_shear(QV4::SimpleCallConte */ QV4::ReturnedValue QQuickJSContext2D::method_get_globalAlpha(QV4::SimpleCallContext *ctx) { - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::ExecutionEngine *v4 = ctx->engine; + QV4::Scope scope(v4); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) return QV4::Encode(r->context->state.globalAlpha); @@ -1249,10 +1251,10 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_globalAlpha(QV4::SimpleCallCont { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT_SETTER(r) - double globalAlpha = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); + double globalAlpha = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); if (!qIsFinite(globalAlpha)) return QV4::Encode::undefined(); @@ -1294,7 +1296,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_globalCompositeOperation(QV4::S { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) return QV4::Value::fromString(ctx->engine->newString(qt_composite_mode_to_string(r->context->state.globalCompositeOperation))).asReturnedValue(); @@ -1304,13 +1306,13 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_globalCompositeOperation(QV4::S { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT_SETTER(r) - if (!ctx->argumentCount) + if (!ctx->callData->argc) ctx->throwTypeError(); - QString mode = ctx->arguments[0].toQString(); + QString mode = ctx->callData->args[0].toQString(); QPainter::CompositionMode cm = qt_composite_mode_from_string(mode); if (cm == QPainter::CompositionMode_SourceOver && mode != QStringLiteral("source-over")) return QV4::Encode::undefined(); @@ -1349,7 +1351,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_fillStyle(QV4::SimpleCallContex { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) QColor color = r->context->state.fillStyle.color(); @@ -1371,7 +1373,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_fillStyle(QV4::SimpleCallContex { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT_SETTER(r) QV4::ScopedValue value(scope, ctx->argument(0)); @@ -1419,7 +1421,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_fillRule(QV4::SimpleCallContext { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) QV8Engine *engine = ctx->engine->v8Engine; @@ -1430,7 +1432,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_fillRule(QV4::SimpleCallContext { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT_SETTER(r) QV4::ScopedValue value(scope, ctx->argument(0)); @@ -1464,7 +1466,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_strokeStyle(QV4::SimpleCallCont { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) QColor color = r->context->state.strokeStyle.color(); @@ -1486,7 +1488,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(QV4::SimpleCallCont { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT_SETTER(r) QV8Engine *engine = ctx->engine->v8Engine; @@ -1541,17 +1543,17 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(QV4:: { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) QV8Engine *engine = ctx->engine->v8Engine; - if (ctx->argumentCount == 4) { - qreal x0 = ctx->arguments[0].toNumber(); - qreal y0 = ctx->arguments[1].toNumber(); - qreal x1 = ctx->arguments[2].toNumber(); - qreal y1 = ctx->arguments[3].toNumber(); + if (ctx->callData->argc == 4) { + qreal x0 = ctx->callData->args[0].toNumber(); + qreal y0 = ctx->callData->args[1].toNumber(); + qreal x1 = ctx->callData->args[2].toNumber(); + qreal y1 = ctx->callData->args[3].toNumber(); if (!qIsFinite(x0) || !qIsFinite(y0) @@ -1568,7 +1570,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(QV4:: return gradient.asReturnedValue(); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -1588,19 +1590,19 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(QV4:: { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) QV8Engine *engine = ctx->engine->v8Engine; - if (ctx->argumentCount == 6) { - qreal x0 = ctx->arguments[0].toNumber(); - qreal y0 = ctx->arguments[1].toNumber(); - qreal r0 = ctx->arguments[2].toNumber(); - qreal x1 = ctx->arguments[3].toNumber(); - qreal y1 = ctx->arguments[4].toNumber(); - qreal r1 = ctx->arguments[5].toNumber(); + if (ctx->callData->argc == 6) { + qreal x0 = ctx->callData->args[0].toNumber(); + qreal y0 = ctx->callData->args[1].toNumber(); + qreal r0 = ctx->callData->args[2].toNumber(); + qreal x1 = ctx->callData->args[3].toNumber(); + qreal y1 = ctx->callData->args[4].toNumber(); + qreal r1 = ctx->callData->args[5].toNumber(); if (!qIsFinite(x0) || !qIsFinite(y0) @@ -1623,7 +1625,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(QV4:: return gradient.asReturnedValue(); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -1643,16 +1645,16 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createConicalGradient(QV4: { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) QV8Engine *engine = ctx->engine->v8Engine; - if (ctx->argumentCount == 6) { - qreal x = ctx->arguments[0].toNumber(); - qreal y = ctx->arguments[1].toNumber(); - qreal angle = DEGREES(ctx->arguments[2].toNumber()); + if (ctx->callData->argc == 6) { + qreal x = ctx->callData->args[0].toNumber(); + qreal y = ctx->callData->args[1].toNumber(); + qreal angle = DEGREES(ctx->callData->args[2].toNumber()); if (!qIsFinite(x) || !qIsFinite(y)) { V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createConicalGradient(): Incorrect arguments"); } @@ -1670,7 +1672,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createConicalGradient(QV4: return gradient.asReturnedValue(); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! \qmlmethod variant QtQuick2::Context2D::createPattern(color color, enumeration patternMode) @@ -1719,17 +1721,17 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::SimpleC { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) QV8Engine *engine = ctx->engine->v8Engine; - if (ctx->argumentCount == 2) { + if (ctx->callData->argc == 2) { QV4::Scoped<QQuickContext2DStyle> pattern(scope, new (v4->memoryManager) QQuickContext2DStyle(v4)); - QColor color = engine->toVariant(ctx->arguments[0], qMetaTypeId<QColor>()).value<QColor>(); + QColor color = engine->toVariant(ctx->callData->args[0], qMetaTypeId<QColor>()).value<QColor>(); if (color.isValid()) { - int patternMode = ctx->arguments[1].toInt32(); + int patternMode = ctx->callData->args[1].toInt32(); Qt::BrushStyle style = Qt::SolidPattern; if (patternMode >= 0 && patternMode < Qt::LinearGradientPattern) { style = static_cast<Qt::BrushStyle>(patternMode); @@ -1738,20 +1740,20 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::SimpleC } else { QImage patternTexture; - if (QV4::Object *o = ctx->arguments[0].asObject()) { + if (QV4::Object *o = ctx->callData->args[0].asObject()) { QV4::ScopedString s(scope, ctx->engine->newString(QStringLiteral("data"))); QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, o->get(s)); if (!!pixelData) { patternTexture = pixelData->image; } } else { - patternTexture = r->context->createPixmap(QUrl(ctx->arguments[0].toQStringNoThrow()))->image(); + patternTexture = r->context->createPixmap(QUrl(ctx->callData->args[0].toQStringNoThrow()))->image(); } if (!patternTexture.isNull()) { pattern->brush.setTextureImage(patternTexture); - QString repetition = ctx->arguments[1].toQStringNoThrow(); + QString repetition = ctx->callData->args[1].toQStringNoThrow(); if (repetition == QStringLiteral("repeat") || repetition.isEmpty()) { pattern->patternRepeatX = true; pattern->patternRepeatY = true; @@ -1791,7 +1793,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_lineCap(QV4::SimpleCallContext { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) switch (r->context->state.lineCap) { @@ -1810,10 +1812,10 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_lineCap(QV4::SimpleCallContext { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) - QString lineCap = ctx->arguments[0].toQString(); + QString lineCap = ctx->callData->args[0].toQString(); Qt::PenCapStyle cap; if (lineCap == QStringLiteral("round")) cap = Qt::RoundCap; @@ -1849,7 +1851,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_lineJoin(QV4::SimpleCallContext { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) switch (r->context->state.lineJoin) { @@ -1868,13 +1870,13 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_lineJoin(QV4::SimpleCallContext { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) - if (!ctx->argumentCount) + if (!ctx->callData->argc) ctx->throwTypeError(); - QString lineJoin = ctx->arguments[0].toQString(); + QString lineJoin = ctx->callData->args[0].toQString(); Qt::PenJoinStyle join; if (lineJoin == QStringLiteral("round")) join = Qt::RoundJoin; @@ -1900,7 +1902,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_lineWidth(QV4::SimpleCallContex { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) return QV4::Encode(r->context->state.lineWidth); @@ -1910,10 +1912,10 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_lineWidth(QV4::SimpleCallContex { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) - qreal w = ctx->argumentCount ? ctx->arguments[0].toNumber() : -1; + qreal w = ctx->callData->argc ? ctx->callData->args[0].toNumber() : -1; if (w > 0 && qIsFinite(w) && w != r->context->state.lineWidth) { r->context->state.lineWidth = w; @@ -1931,7 +1933,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_miterLimit(QV4::SimpleCallConte { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) return QV4::Encode(r->context->state.miterLimit); @@ -1941,10 +1943,10 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_miterLimit(QV4::SimpleCallConte { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) - qreal ml = ctx->argumentCount ? ctx->arguments[0].toNumber() : -1; + qreal ml = ctx->callData->argc ? ctx->callData->args[0].toNumber() : -1; if (ml > 0 && qIsFinite(ml) && ml != r->context->state.miterLimit) { r->context->state.miterLimit = ml; @@ -1962,7 +1964,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_shadowBlur(QV4::SimpleCallConte { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) return QV4::Encode(r->context->state.shadowBlur); @@ -1972,10 +1974,10 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_shadowBlur(QV4::SimpleCallConte { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) - qreal blur = ctx->argumentCount ? ctx->arguments[0].toNumber() : -1; + qreal blur = ctx->callData->argc ? ctx->callData->args[0].toNumber() : -1; if (blur > 0 && qIsFinite(blur) && blur != r->context->state.shadowBlur) { r->context->state.shadowBlur = blur; @@ -1992,7 +1994,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_shadowColor(QV4::SimpleCallCont { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) return QV4::Value::fromString(ctx->engine->newString(r->context->state.shadowColor.name())).asReturnedValue(); @@ -2002,12 +2004,12 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_shadowColor(QV4::SimpleCallCont { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) QColor color; - if (ctx->argumentCount) - color = qt_color_from_string(ctx->arguments[0]); + if (ctx->callData->argc) + color = qt_color_from_string(ctx->callData->args[0]); if (color.isValid() && color != r->context->state.shadowColor) { r->context->state.shadowColor = color; @@ -2027,7 +2029,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_shadowOffsetX(QV4::SimpleCallCo { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) return QV4::Encode(r->context->state.shadowOffsetX); @@ -2037,10 +2039,10 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetX(QV4::SimpleCallCo { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) - qreal offsetX = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); + qreal offsetX = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); if (qIsFinite(offsetX) && offsetX != r->context->state.shadowOffsetX) { r->context->state.shadowOffsetX = offsetX; r->context->buffer()->setShadowOffsetX(offsetX); @@ -2057,7 +2059,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_shadowOffsetY(QV4::SimpleCallCo { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) return QV4::Encode(r->context->state.shadowOffsetY); @@ -2067,10 +2069,10 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetY(QV4::SimpleCallCo { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) - qreal offsetY = ctx->argumentCount ? ctx->arguments[0].toNumber() : qSNaN(); + qreal offsetY = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); if (qIsFinite(offsetY) && offsetY != r->context->state.shadowOffsetY) { r->context->state.shadowOffsetY = offsetY; r->context->buffer()->setShadowOffsetY(offsetY); @@ -2082,7 +2084,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_path(QV4::SimpleCallContext *ct { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) return r->context->m_v4path.value(); @@ -2092,7 +2094,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_path(QV4::SimpleCallContext *ct { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) QV4::ScopedValue value(scope, ctx->argument(0)); @@ -2117,17 +2119,17 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_clearRect(QV4::SimpleCallC { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 4) - r->context->clearRect(ctx->arguments[0].toNumber(), - ctx->arguments[1].toNumber(), - ctx->arguments[2].toNumber(), - ctx->arguments[3].toNumber()); + if (ctx->callData->argc == 4) + r->context->clearRect(ctx->callData->args[0].toNumber(), + ctx->callData->args[1].toNumber(), + ctx->callData->args[2].toNumber(), + ctx->callData->args[3].toNumber()); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! \qmlmethod object QtQuick2::Context2D::fillRect(real x, real y, real w, real h) @@ -2139,12 +2141,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillRect(QV4::SimpleCallCo { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 4) - r->context->fillRect(ctx->arguments[0].toNumber(), ctx->arguments[1].toNumber(), ctx->arguments[2].toNumber(), ctx->arguments[3].toNumber()); - return ctx->thisObject.asReturnedValue(); + if (ctx->callData->argc == 4) + r->context->fillRect(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber(), ctx->callData->args[2].toNumber(), ctx->callData->args[3].toNumber()); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2161,13 +2163,13 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeRect(QV4::SimpleCall { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 4) - r->context->strokeRect(ctx->arguments[0].toNumber(), ctx->arguments[1].toNumber(), ctx->arguments[2].toNumber(), ctx->arguments[3].toNumber()); + if (ctx->callData->argc == 4) + r->context->strokeRect(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber(), ctx->callData->args[2].toNumber(), ctx->callData->args[3].toNumber()); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } // Complex shapes (paths) API @@ -2195,29 +2197,29 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_arc(QV4::SimpleCallContext { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount >= 5) { + if (ctx->callData->argc >= 5) { bool antiClockwise = false; - if (ctx->argumentCount == 6) - antiClockwise = ctx->arguments[5].toBoolean(); + if (ctx->callData->argc == 6) + antiClockwise = ctx->callData->args[5].toBoolean(); - qreal radius = ctx->arguments[2].toNumber(); + qreal radius = ctx->callData->args[2].toNumber(); if (qIsFinite(radius) && radius < 0) V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius"); - r->context->arc(ctx->arguments[0].toNumber(), - ctx->arguments[1].toNumber(), + r->context->arc(ctx->callData->args[0].toNumber(), + ctx->callData->args[1].toNumber(), radius, - ctx->arguments[3].toNumber(), - ctx->arguments[4].toNumber(), + ctx->callData->args[3].toNumber(), + ctx->callData->args[4].toNumber(), antiClockwise); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2247,23 +2249,23 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_arcTo(QV4::SimpleCallConte { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 5) { - qreal radius = ctx->arguments[4].toNumber(); + if (ctx->callData->argc == 5) { + qreal radius = ctx->callData->args[4].toNumber(); if (qIsFinite(radius) && radius < 0) V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius"); - r->context->arcTo(ctx->arguments[0].toNumber(), - ctx->arguments[1].toNumber(), - ctx->arguments[2].toNumber(), - ctx->arguments[3].toNumber(), + r->context->arcTo(ctx->callData->args[0].toNumber(), + ctx->callData->args[1].toNumber(), + ctx->callData->args[2].toNumber(), + ctx->callData->args[3].toNumber(), radius); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2275,12 +2277,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(QV4::SimpleCallC { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) r->context->beginPath(); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2306,25 +2308,25 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_bezierCurveTo(QV4::SimpleC { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 6) { - qreal cp1x = ctx->arguments[0].toNumber(); - qreal cp1y = ctx->arguments[1].toNumber(); - qreal cp2x = ctx->arguments[2].toNumber(); - qreal cp2y = ctx->arguments[3].toNumber(); - qreal x = ctx->arguments[4].toNumber(); - qreal y = ctx->arguments[5].toNumber(); + if (ctx->callData->argc == 6) { + qreal cp1x = ctx->callData->args[0].toNumber(); + qreal cp1y = ctx->callData->args[1].toNumber(); + qreal cp2x = ctx->callData->args[2].toNumber(); + qreal cp2y = ctx->callData->args[3].toNumber(); + qreal x = ctx->callData->args[4].toNumber(); + qreal y = ctx->callData->args[5].toNumber(); if (!qIsFinite(cp1x) || !qIsFinite(cp1y) || !qIsFinite(cp2x) || !qIsFinite(cp2y) || !qIsFinite(x) || !qIsFinite(y)) - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); r->context->bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2355,11 +2357,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_clip(QV4::SimpleCallContex { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) r->context->clip(); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2373,13 +2375,13 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_closePath(QV4::SimpleCallC { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) r->context->closePath(); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2395,10 +2397,10 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fill(QV4::SimpleCallContex { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r); r->context->fill(); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2409,21 +2411,21 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fill(QV4::SimpleCallContex QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 2) { - qreal x = ctx->arguments[0].toNumber(); - qreal y = ctx->arguments[1].toNumber(); + if (ctx->callData->argc == 2) { + qreal x = ctx->callData->args[0].toNumber(); + qreal y = ctx->callData->args[1].toNumber(); if (!qIsFinite(x) || !qIsFinite(y)) - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); r->context->lineTo(x, y); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2434,18 +2436,18 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(QV4::SimpleCallCont QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 2) { - qreal x = ctx->arguments[0].toNumber(); - qreal y = ctx->arguments[1].toNumber(); + if (ctx->callData->argc == 2) { + qreal x = ctx->callData->args[0].toNumber(); + qreal y = ctx->callData->args[1].toNumber(); if (!qIsFinite(x) || !qIsFinite(y)) - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); r->context->moveTo(x, y); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2458,22 +2460,22 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(QV4::SimpleCallCont QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 4) { - qreal cpx = ctx->arguments[0].toNumber(); - qreal cpy = ctx->arguments[1].toNumber(); - qreal x = ctx->arguments[2].toNumber(); - qreal y = ctx->arguments[3].toNumber(); + if (ctx->callData->argc == 4) { + qreal cpx = ctx->callData->args[0].toNumber(); + qreal cpy = ctx->callData->args[1].toNumber(); + qreal x = ctx->callData->args[2].toNumber(); + qreal y = ctx->callData->args[3].toNumber(); if (!qIsFinite(cpx) || !qIsFinite(cpy) || !qIsFinite(x) || !qIsFinite(y)) - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); r->context->quadraticCurveTo(cpx, cpy, x, y); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2484,12 +2486,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(QV4::Simp QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 4) - r->context->rect(ctx->arguments[0].toNumber(), ctx->arguments[1].toNumber(), ctx->arguments[2].toNumber(), ctx->arguments[3].toNumber()); - return ctx->thisObject.asReturnedValue(); + if (ctx->callData->argc == 4) + r->context->rect(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber(), ctx->callData->args[2].toNumber(), ctx->callData->args[3].toNumber()); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2501,17 +2503,17 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(QV4::SimpleCallContex QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 6) - r->context->roundedRect(ctx->arguments[0].toNumber() - , ctx->arguments[1].toNumber() - , ctx->arguments[2].toNumber() - , ctx->arguments[3].toNumber() - , ctx->arguments[4].toNumber() - , ctx->arguments[5].toNumber()); - return ctx->thisObject.asReturnedValue(); + if (ctx->callData->argc == 6) + r->context->roundedRect(ctx->callData->args[0].toNumber() + , ctx->callData->args[1].toNumber() + , ctx->callData->args[2].toNumber() + , ctx->callData->args[3].toNumber() + , ctx->callData->args[4].toNumber() + , ctx->callData->args[5].toNumber()); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2525,14 +2527,14 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(QV4::SimpleCal QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 4) - r->context->ellipse(ctx->arguments[0].toNumber(), ctx->arguments[1].toNumber(), ctx->arguments[2].toNumber(), ctx->arguments[3].toNumber()); + if (ctx->callData->argc == 4) + r->context->ellipse(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber(), ctx->callData->args[2].toNumber(), ctx->callData->args[3].toNumber()); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2544,18 +2546,18 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(QV4::SimpleCallCon QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 3) { - qreal x = ctx->arguments[1].toNumber(); - qreal y = ctx->arguments[2].toNumber(); + if (ctx->callData->argc == 3) { + qreal x = ctx->callData->args[1].toNumber(); + qreal y = ctx->callData->args[2].toNumber(); if (!qIsFinite(x) || !qIsFinite(y)) - return ctx->thisObject.asReturnedValue(); - r->context->text(ctx->arguments[0].toQStringNoThrow(), x, y); + return ctx->callData->thisObject.asReturnedValue(); + r->context->text(ctx->callData->args[0].toQStringNoThrow(), x, y); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2570,11 +2572,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(QV4::SimpleCallContex QV4::ReturnedValue QQuickJSContext2DPrototype::method_stroke(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) r->context->stroke(); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2588,12 +2590,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_isPointInPath(QV4::SimpleC { QV4::ExecutionEngine *v4 = ctx->engine; QV4::Scope scope(v4); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) bool pointInPath = false; - if (ctx->argumentCount == 2) - pointInPath = r->context->isPointInPath(ctx->arguments[0].toNumber(), ctx->arguments[1].toNumber()); + if (ctx->callData->argc == 2) + pointInPath = r->context->isPointInPath(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber()); return QV4::Value::fromBoolean(pointInPath).asReturnedValue(); } @@ -2644,7 +2646,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_caretBlinkRate(QV4::Simple QV4::ReturnedValue QQuickJSContext2D::method_get_font(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) return QV4::Value::fromString(ctx->engine->newString(r->context->state.font.toString())).asReturnedValue(); @@ -2653,7 +2655,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_font(QV4::SimpleCallContext *ct QV4::ReturnedValue QQuickJSContext2D::method_set_font(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) QV4::Scoped<QV4::String> s(scope, ctx->argument(0), QV4::Scoped<QV4::String>::Convert); @@ -2681,7 +2683,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_font(QV4::SimpleCallContext *ct QV4::ReturnedValue QQuickJSContext2D::method_get_textAlign(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) switch (r->context->state.textAlign) { @@ -2703,7 +2705,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_textAlign(QV4::SimpleCallContex QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) QV4::Scoped<QV4::String> s(scope, ctx->argument(0), QV4::Scoped<QV4::String>::Convert); @@ -2747,7 +2749,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(QV4::SimpleCallContex QV4::ReturnedValue QQuickJSContext2D::method_get_textBaseline(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) switch (r->context->state.textBaseline) { @@ -2769,7 +2771,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_textBaseline(QV4::SimpleCallCon QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT_SETTER(r) QV4::Scoped<QV4::String> s(scope, ctx->argument(0), QV4::Scoped<QV4::String>::Convert); QString textBaseline = s->toQString(); @@ -2805,18 +2807,18 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(QV4::SimpleCallCon QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillText(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 3) { - qreal x = ctx->arguments[1].toNumber(); - qreal y = ctx->arguments[2].toNumber(); + if (ctx->callData->argc == 3) { + qreal x = ctx->callData->args[1].toNumber(); + qreal y = ctx->callData->args[2].toNumber(); if (!qIsFinite(x) || !qIsFinite(y)) - return ctx->thisObject.asReturnedValue(); - QPainterPath textPath = r->context->createTextGlyphs(x, y, ctx->arguments[0].toQStringNoThrow()); + return ctx->callData->thisObject.asReturnedValue(); + QPainterPath textPath = r->context->createTextGlyphs(x, y, ctx->callData->args[0].toQStringNoThrow()); r->context->buffer()->fill(textPath); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! \qmlmethod object QtQuick2::Context2D::strokeText(text, x, y) @@ -2829,12 +2831,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillText(QV4::SimpleCallCo QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeText(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 3) - r->context->drawText(ctx->arguments[0].toQStringNoThrow(), ctx->arguments[1].toNumber(), ctx->arguments[2].toNumber(), false); - return ctx->thisObject.asReturnedValue(); + if (ctx->callData->argc == 3) + r->context->drawText(ctx->callData->args[0].toQStringNoThrow(), ctx->callData->args[1].toNumber(), ctx->callData->args[2].toNumber(), false); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -2864,12 +2866,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeText(QV4::SimpleCall QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) - if (ctx->argumentCount == 1) { + if (ctx->callData->argc == 1) { QFontMetrics fm(r->context->state.font); - uint width = fm.width(ctx->arguments[0].toQStringNoThrow()); + uint width = fm.width(ctx->callData->args[0].toQStringNoThrow()); QV4::Scoped<QV4::Object> tm(scope, ctx->engine->newObject()); tm->put(QV4::ScopedString(scope, ctx->engine->newIdentifier(QStringLiteral("width"))), QV4::ScopedValue(scope, QV4::Value::fromDouble(width))); @@ -2940,21 +2942,21 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(QV4::SimpleCal QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject); CHECK_CONTEXT(r) qreal sx, sy, sw, sh, dx, dy, dw, dh; - if (!ctx->argumentCount) - return ctx->thisObject.asReturnedValue(); + if (!ctx->callData->argc) + return ctx->callData->thisObject.asReturnedValue(); //FIXME:This function should be moved to QQuickContext2D::drawImage(...) if (!r->context->state.invertibleCTM) - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); QQmlRefPointer<QQuickCanvasPixmap> pixmap; - QV4::ScopedValue arg(scope, ctx->arguments[0]); + QV4::ScopedValue arg(scope, ctx->callData->args[0]); if (arg->isString()) { QUrl url(arg->toQString()); if (!url.isValid()) @@ -2991,37 +2993,37 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::SimpleCallC } if (pixmap.isNull() || !pixmap->isValid()) - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); - if (ctx->argumentCount == 3) { - dx = ctx->arguments[1].toNumber(); - dy = ctx->arguments[2].toNumber(); + if (ctx->callData->argc == 3) { + dx = ctx->callData->args[1].toNumber(); + dy = ctx->callData->args[2].toNumber(); sx = 0; sy = 0; sw = pixmap->width(); sh = pixmap->height(); dw = sw; dh = sh; - } else if (ctx->argumentCount == 5) { + } else if (ctx->callData->argc == 5) { sx = 0; sy = 0; sw = pixmap->width(); sh = pixmap->height(); - dx = ctx->arguments[1].toNumber(); - dy = ctx->arguments[2].toNumber(); - dw = ctx->arguments[3].toNumber(); - dh = ctx->arguments[4].toNumber(); - } else if (ctx->argumentCount == 9) { - sx = ctx->arguments[1].toNumber(); - sy = ctx->arguments[2].toNumber(); - sw = ctx->arguments[3].toNumber(); - sh = ctx->arguments[4].toNumber(); - dx = ctx->arguments[5].toNumber(); - dy = ctx->arguments[6].toNumber(); - dw = ctx->arguments[7].toNumber(); - dh = ctx->arguments[8].toNumber(); + dx = ctx->callData->args[1].toNumber(); + dy = ctx->callData->args[2].toNumber(); + dw = ctx->callData->args[3].toNumber(); + dh = ctx->callData->args[4].toNumber(); + } else if (ctx->callData->argc == 9) { + sx = ctx->callData->args[1].toNumber(); + sy = ctx->callData->args[2].toNumber(); + sw = ctx->callData->args[3].toNumber(); + sh = ctx->callData->args[4].toNumber(); + dx = ctx->callData->args[5].toNumber(); + dy = ctx->callData->args[6].toNumber(); + dw = ctx->callData->args[7].toNumber(); + dh = ctx->callData->args[8].toNumber(); } else { - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } if (!qIsFinite(sx) @@ -3032,7 +3034,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::SimpleCallC || !qIsFinite(dy) || !qIsFinite(dw) || !qIsFinite(dh)) - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); if (sx < 0 || sy < 0 @@ -3046,7 +3048,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::SimpleCallC r->context->buffer()->drawPixmap(pixmap, QRectF(sx, sy, sw, sh), QRectF(dx, dy, dw, dh)); - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } // pixel manipulation @@ -3076,10 +3078,10 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::SimpleCallC QV4::ReturnedValue QQuickJSContext2DImageData::method_get_width(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2DImageData *imageData = ctx->thisObject.as<QQuickJSContext2DImageData>(); + QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->callData->thisObject); if (!imageData) ctx->throwTypeError(); - QQuickJSContext2DPixelData *r = imageData->pixelData.as<QQuickJSContext2DPixelData>(); + QV4::Scoped<QQuickJSContext2DPixelData> r(scope, imageData->pixelData.as<QQuickJSContext2DPixelData>()); if (!r) return QV4::Encode(0); return QV4::Encode(r->image.width()); @@ -3092,10 +3094,10 @@ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_width(QV4::SimpleCallC QV4::ReturnedValue QQuickJSContext2DImageData::method_get_height(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2DImageData *imageData = ctx->thisObject.as<QQuickJSContext2DImageData>(); + QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->callData->thisObject); if (!imageData) ctx->throwTypeError(); - QQuickJSContext2DPixelData *r = imageData->pixelData.as<QQuickJSContext2DPixelData>(); + QV4::Scoped<QQuickJSContext2DPixelData> r(scope, imageData->pixelData.as<QQuickJSContext2DPixelData>()); if (!r) return QV4::Encode(0); return QV4::Encode(r->image.height()); @@ -3108,7 +3110,7 @@ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_height(QV4::SimpleCall QV4::ReturnedValue QQuickJSContext2DImageData::method_get_data(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2DImageData *imageData = ctx->thisObject.as<QQuickJSContext2DImageData>(); + QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->callData->thisObject); if (!imageData) ctx->throwTypeError(); return imageData->pixelData.asReturnedValue(); @@ -3135,7 +3137,7 @@ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_data(QV4::SimpleCallCo QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2DPixelData *r = ctx->thisObject.as<QQuickJSContext2DPixelData>(); + QV4::Scoped<QQuickJSContext2DPixelData> r(scope, ctx->callData->thisObject.as<QQuickJSContext2DPixelData>()); if (!r || r->image.isNull()) return QV4::Encode::undefined(); @@ -3146,7 +3148,7 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint { QV4::ExecutionEngine *v4 = m->engine(); QV4::Scope scope(v4); - QQuickJSContext2DPixelData *r = m->as<QQuickJSContext2DPixelData>(); + QV4::Scoped<QQuickJSContext2DPixelData> r(scope, m->as<QQuickJSContext2DPixelData>()); if (!m) m->engine()->current->throwTypeError(); @@ -3230,13 +3232,13 @@ void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const Q QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) QV8Engine *engine = ctx->engine->v8Engine; - if (ctx->argumentCount == 1) { - QV4::ScopedValue arg0(scope, ctx->arguments[0]); + if (ctx->callData->argc == 1) { + QV4::ScopedValue arg0(scope, ctx->callData->args[0]); if (QQuickJSContext2DImageData *imgData = arg0->as<QQuickJSContext2DImageData>()) { QQuickJSContext2DPixelData *pa = imgData->pixelData.as<QQuickJSContext2DPixelData>(); if (pa) { @@ -3248,9 +3250,9 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::Simpl QImage image = r->context->createPixmap(QUrl(arg0->toQStringNoThrow()))->image(); return qt_create_image_data(image.width(), image.height(), engine, image).asReturnedValue(); } - } else if (ctx->argumentCount == 2) { - qreal w = ctx->arguments[0].toNumber(); - qreal h = ctx->arguments[1].toNumber(); + } else if (ctx->callData->argc == 2) { + qreal w = ctx->callData->args[0].toNumber(); + qreal h = ctx->callData->args[1].toNumber(); if (!qIsFinite(w) || !qIsFinite(h)) V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createImageData(): invalid arguments"); @@ -3270,15 +3272,15 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::Simpl QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) QV8Engine *engine = ctx->engine->v8Engine; - if (ctx->argumentCount == 4) { - qreal x = ctx->arguments[0].toNumber(); - qreal y = ctx->arguments[1].toNumber(); - qreal w = ctx->arguments[2].toNumber(); - qreal h = ctx->arguments[3].toNumber(); + if (ctx->callData->argc == 4) { + qreal x = ctx->callData->args[0].toNumber(); + qreal y = ctx->callData->args[1].toNumber(); + qreal w = ctx->callData->args[2].toNumber(); + qreal h = ctx->callData->args[3].toNumber(); if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(w)) V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "getImageData(): Invalid arguments"); @@ -3300,17 +3302,17 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(QV4::SimpleCa QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); + QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>()); CHECK_CONTEXT(r) - if (ctx->argumentCount != 3 && ctx->argumentCount != 7) + if (ctx->callData->argc != 3 && ctx->callData->argc != 7) return QV4::Encode::undefined(); - QV4::ScopedValue arg0(scope, ctx->arguments[0]); + QV4::ScopedValue arg0(scope, ctx->callData->args[0]); if (!arg0->isObject()) V4THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "Context2D::putImageData, the image data type mismatch"); - qreal dx = ctx->arguments[1].toNumber(); - qreal dy = ctx->arguments[2].toNumber(); + qreal dx = ctx->callData->args[1].toNumber(); + qreal dy = ctx->callData->args[2].toNumber(); qreal w, h, dirtyX, dirtyY, dirtyWidth, dirtyHeight; if (!qIsFinite(dx) || !qIsFinite(dy)) @@ -3318,18 +3320,18 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::SimpleCa QQuickJSContext2DImageData *imageData = arg0->as<QQuickJSContext2DImageData>(); if (!imageData) - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); QQuickJSContext2DPixelData *pixelArray = imageData->pixelData.as<QQuickJSContext2DPixelData>(); if (pixelArray) { w = pixelArray->image.width(); h = pixelArray->image.height(); - if (ctx->argumentCount == 7) { - dirtyX = ctx->arguments[3].toNumber(); - dirtyY = ctx->arguments[4].toNumber(); - dirtyWidth = ctx->arguments[5].toNumber(); - dirtyHeight = ctx->arguments[6].toNumber(); + if (ctx->callData->argc == 7) { + dirtyX = ctx->callData->args[3].toNumber(); + dirtyY = ctx->callData->args[4].toNumber(); + dirtyWidth = ctx->callData->args[5].toNumber(); + dirtyHeight = ctx->callData->args[6].toNumber(); if (!qIsFinite(dirtyX) || !qIsFinite(dirtyY) || !qIsFinite(dirtyWidth) || !qIsFinite(dirtyHeight)) V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments"); @@ -3364,7 +3366,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::SimpleCa } if (dirtyWidth <=0 || dirtyHeight <= 0) - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } else { dirtyX = 0; dirtyY = 0; @@ -3375,7 +3377,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::SimpleCa QImage image = pixelArray->image.copy(dirtyX, dirtyY, dirtyWidth, dirtyHeight); r->context->buffer()->drawImage(image, QRectF(dirtyX, dirtyY, dirtyWidth, dirtyHeight), QRectF(dx, dy, dirtyWidth, dirtyHeight)); } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } /*! @@ -3401,24 +3403,24 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::SimpleCa QV4::ReturnedValue QQuickContext2DStyle::gradient_proto_addColorStop(QV4::SimpleCallContext *ctx) { QV4::Scope scope(ctx); - QQuickContext2DStyle *style = ctx->thisObject.as<QQuickContext2DStyle>(); + QV4::Scoped<QQuickContext2DStyle> style(scope, ctx->callData->thisObject.as<QQuickContext2DStyle>()); if (!style) V4THROW_ERROR("Not a CanvasGradient object"); QV8Engine *engine = ctx->engine->v8Engine; - if (ctx->argumentCount == 2) { + if (ctx->callData->argc == 2) { if (!style->brush.gradient()) V4THROW_ERROR("Not a valid CanvasGradient object, can't get the gradient information"); QGradient gradient = *(style->brush.gradient()); - qreal pos = ctx->arguments[0].toNumber(); + qreal pos = ctx->callData->args[0].toNumber(); QColor color; - if (ctx->arguments[1].asObject()) { - color = engine->toVariant(ctx->arguments[1], qMetaTypeId<QColor>()).value<QColor>(); + if (ctx->callData->args[1].asObject()) { + color = engine->toVariant(ctx->callData->args[1], qMetaTypeId<QColor>()).value<QColor>(); } else { - color = qt_color_from_string(ctx->arguments[1]); + color = qt_color_from_string(ctx->callData->args[1]); } if (pos < 0.0 || pos > 1.0 || !qIsFinite(pos)) { V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "CanvasGradient: parameter offset out of range"); @@ -3432,7 +3434,7 @@ QV4::ReturnedValue QQuickContext2DStyle::gradient_proto_addColorStop(QV4::Simple style->brush = gradient; } - return ctx->thisObject.asReturnedValue(); + return ctx->callData->thisObject.asReturnedValue(); } void QQuickContext2D::scale(qreal x, qreal y) |