diff options
-rw-r--r-- | src/imports/localstorage/plugin.cpp | 97 | ||||
-rw-r--r-- | src/particles/qquickv4particledata.cpp | 107 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 36 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 40 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 4 | ||||
-rw-r--r-- | src/qml/util/qqmladaptormodel.cpp | 44 | ||||
-rw-r--r-- | tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp | 8 |
9 files changed, 118 insertions, 233 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 40682dd6a8..a7d95cc295 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -73,8 +73,8 @@ QT_BEGIN_NAMESPACE QV4::ScopedString v(scope, scope.engine->newString(desc)); \ QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \ - ctx->engine()->throwError(ex); \ - return Encode::undefined(); \ + scope.engine->throwError(ex); \ + RETURN_UNDEFINED(); \ } #define V4THROW_SQL2(error, desc) { \ @@ -87,8 +87,8 @@ QT_BEGIN_NAMESPACE #define V4THROW_REFERENCE(string) { \ QV4::ScopedString v(scope, scope.engine->newString(string)); \ - ctx->engine()->throwReferenceError(v); \ - return Encode::undefined(); \ + scope.engine->throwReferenceError(v); \ + RETURN_UNDEFINED(); \ } @@ -164,20 +164,18 @@ DEFINE_OBJECT_VTABLE(QV4::QQmlSqlDatabaseWrapper); -static ReturnedValue qmlsqldatabase_version(CallContext *ctx) +static void qmlsqldatabase_version(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->thisObject().as<QQmlSqlDatabaseWrapper>()); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); - return Encode(scope.engine->newString(*r->d()->version)); + RETURN_RESULT(Encode(scope.engine->newString(*r->d()->version))); } -static ReturnedValue qmlsqldatabase_rows_length(CallContext *ctx) +static void qmlsqldatabase_rows_length(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->thisObject().as<QQmlSqlDatabaseWrapper>()); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); @@ -190,29 +188,27 @@ static ReturnedValue qmlsqldatabase_rows_length(CallContext *ctx) s = 0; } } - return Encode(s); + RETURN_RESULT(Encode(s)); } -static ReturnedValue qmlsqldatabase_rows_forwardOnly(CallContext *ctx) +static void qmlsqldatabase_rows_forwardOnly(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->thisObject().as<QQmlSqlDatabaseWrapper>()); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - return Encode(r->d()->sqlQuery->isForwardOnly()); + RETURN_RESULT(Encode(r->d()->sqlQuery->isForwardOnly())); } -static ReturnedValue qmlsqldatabase_rows_setForwardOnly(CallContext *ctx) +static void qmlsqldatabase_rows_setForwardOnly(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->thisObject().as<QQmlSqlDatabaseWrapper>()); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - if (ctx->argc() < 1) - return ctx->engine()->throwTypeError(); + if (callData->argc < 1) + RETURN_RESULT(scope.engine->throwTypeError()); - r->d()->sqlQuery->setForwardOnly(ctx->args()[0].toBoolean()); - return Encode::undefined(); + r->d()->sqlQuery->setForwardOnly(callData->args[0].toBoolean()); + RETURN_UNDEFINED(); } QQmlSqlDatabaseData::~QQmlSqlDatabaseData() @@ -253,14 +249,13 @@ ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(const Managed *m, uint index, b return qmlsqldatabase_rows_index(r, r->engine(), index, hasProperty); } -static ReturnedValue qmlsqldatabase_rows_item(CallContext *ctx) +static void qmlsqldatabase_rows_item(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->thisObject().as<QQmlSqlDatabaseWrapper>()); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - return qmlsqldatabase_rows_index(r, scope.engine, ctx->argc() ? ctx->args()[0].toUInt32() : 0); + RETURN_RESULT(qmlsqldatabase_rows_index(r, scope.engine, callData->argc ? callData->args[0].toUInt32() : 0)); } static QVariant toSqlVariant(QV4::ExecutionEngine *engine, const QV4::ScopedValue &value) @@ -272,10 +267,9 @@ static QVariant toSqlVariant(QV4::ExecutionEngine *engine, const QV4::ScopedValu return engine->toVariant(value, /*typehint*/-1); } -static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) +static void qmlsqldatabase_executeSql(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->thisObject().as<QQmlSqlDatabaseWrapper>()); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Query) V4THROW_REFERENCE("Not a SQLDatabase::Query object"); @@ -284,7 +278,7 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) QSqlDatabase db = *r->d()->database; - QString sql = ctx->argc() ? ctx->args()[0].toQString() : QString(); + QString sql = callData->argc ? callData->args[0].toQString() : QString(); if (r->d()->readonly && !sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) { V4THROW_SQL(SQLEXCEPTION_SYNTAX_ERR, QQmlEngine::tr("Read-only Transaction")); @@ -296,8 +290,8 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) ScopedValue result(scope, Primitive::undefinedValue()); if (query.prepare(sql)) { - if (ctx->argc() > 1) { - ScopedValue values(scope, ctx->args()[1]); + if (callData->argc > 1) { + ScopedValue values(scope, callData->args[1]); if (values->as<ArrayObject>()) { ScopedArrayObject array(scope, values); quint32 size = array->getLength(); @@ -351,7 +345,7 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx) if (err) V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,query.lastError().text()); - return result->asReturnedValue(); + RETURN_RESULT(result->asReturnedValue()); } struct TransactionRollback { @@ -383,21 +377,19 @@ struct TransactionRollback { }; -static ReturnedValue qmlsqldatabase_changeVersion(CallContext *ctx) +static void qmlsqldatabase_changeVersion(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - if (ctx->argc() < 2) - return Encode::undefined(); - - Scope scope(ctx); + if (callData->argc < 2) + RETURN_UNDEFINED(); - Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->thisObject()); + Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); QSqlDatabase db = *r->d()->database; - QString from_version = ctx->args()[0].toQString(); - QString to_version = ctx->args()[1].toQString(); - ScopedFunctionObject callback(scope, ctx->argument(2)); + QString from_version = callData->args[0].toQString(); + QString to_version = callData->args[1].toQString(); + ScopedFunctionObject callback(scope, callData->argc > 2 ? callData->args[2] : Primitive::undefinedValue()); if (from_version != *r->d()->version) V4THROW_SQL(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(*r->d()->version)); @@ -438,17 +430,16 @@ static ReturnedValue qmlsqldatabase_changeVersion(CallContext *ctx) #endif } - return Encode::undefined(); + RETURN_UNDEFINED(); } -static ReturnedValue qmlsqldatabase_transaction_shared(CallContext *ctx, bool readOnly) +static void qmlsqldatabase_transaction_shared(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData, bool readOnly) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->thisObject().as<QQmlSqlDatabaseWrapper>()); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, callData->thisObject.as<QQmlSqlDatabaseWrapper>()); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); - const FunctionObject *callback = ctx->argc() ? ctx->args()[0].as<FunctionObject>() : 0; + const FunctionObject *callback = callData->argc ? callData->args[0].as<FunctionObject>() : 0; if (!callback) V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR, QQmlEngine::tr("transaction: missing callback")); @@ -475,17 +466,17 @@ static ReturnedValue qmlsqldatabase_transaction_shared(CallContext *ctx, bool re db.rollback(); } - return Encode::undefined(); + RETURN_UNDEFINED(); } -static ReturnedValue qmlsqldatabase_transaction(CallContext *ctx) +static void qmlsqldatabase_transaction(const QV4::BuiltinFunction *f, QV4::Scope &scope, QV4::CallData *callData) { - return qmlsqldatabase_transaction_shared(ctx, false); + qmlsqldatabase_transaction_shared(f, scope, callData, false); } -static ReturnedValue qmlsqldatabase_read_transaction(CallContext *ctx) +static void qmlsqldatabase_read_transaction(const QV4::BuiltinFunction *f, QV4::Scope &scope, QV4::CallData *callData) { - return qmlsqldatabase_transaction_shared(ctx, true); + qmlsqldatabase_transaction_shared(f, scope, callData, true); } QQmlSqlDatabaseData::QQmlSqlDatabaseData(ExecutionEngine *v4) diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp index 967652f31a..e8376f1c27 100644 --- a/src/particles/qquickv4particledata.cpp +++ b/src/particles/qquickv4particledata.cpp @@ -296,123 +296,112 @@ public: QV4::PersistentValue proto; }; -static QV4::ReturnedValue particleData_discard(QV4::CallContext *ctx) +static void particleData_discard(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); if (!r || !r->d()->datum) - return ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); r->d()->datum->lifeSpan = 0; //Don't kill(), because it could still be in the middle of being created - return QV4::Encode::undefined(); + RETURN_RESULT(QV4::Encode::undefined()); } -static QV4::ReturnedValue particleData_lifeLeft(QV4::CallContext *ctx) +static void particleData_lifeLeft(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); if (!r || !r->d()->datum) - return ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); - return QV4::Encode(r->d()->datum->lifeLeft(r->d()->particleSystem)); + RETURN_RESULT(QV4::Encode(r->d()->datum->lifeLeft(r->d()->particleSystem))); } -static QV4::ReturnedValue particleData_curSize(QV4::CallContext *ctx) +static void particleData_curSize(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); if (!r || !r->d()->datum) - return ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); - return QV4::Encode(r->d()->datum->curSize(r->d()->particleSystem)); + RETURN_RESULT(QV4::Encode(r->d()->datum->curSize(r->d()->particleSystem))); } -#define COLOR_GETTER_AND_SETTER(VAR, NAME) static QV4::ReturnedValue particleData_get_ ## NAME (QV4::CallContext *ctx) \ +#define COLOR_GETTER_AND_SETTER(VAR, NAME) static void particleData_get_ ## NAME (const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) \ { \ - QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); \ + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); \ if (!r || !r->d()->datum) \ - ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); \ + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); \ \ - return QV4::Encode((r->d()->datum->color. VAR )/255.0);\ + RETURN_RESULT(QV4::Encode((r->d()->datum->color. VAR )/255.0));\ }\ \ -static QV4::ReturnedValue particleData_set_ ## NAME (QV4::CallContext *ctx)\ +static void particleData_set_ ## NAME (const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)\ {\ - QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); \ + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); \ if (!r || !r->d()->datum)\ - ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\ + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));\ \ - double d = ctx->argc() ? ctx->args()[0].toNumber() : 0; \ + double d = callData->argc ? callData->args[0].toNumber() : 0; \ r->d()->datum->color. VAR = qMin(255, qMax(0, (int)::floor(d * 255.0)));\ - return QV4::Encode::undefined(); \ + RETURN_UNDEFINED(); \ } -#define SEMIBOOL_GETTER_AND_SETTER(VARIABLE) static QV4::ReturnedValue particleData_get_ ## VARIABLE (QV4::CallContext *ctx) \ +#define SEMIBOOL_GETTER_AND_SETTER(VARIABLE) static void particleData_get_ ## VARIABLE (const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) \ { \ - QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); \ + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); \ if (!r || !r->d()->datum) \ - ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); \ + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); \ \ - return QV4::Encode(r->d()->datum-> VARIABLE);\ + RETURN_RESULT(QV4::Encode(r->d()->datum-> VARIABLE));\ }\ \ -static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\ +static void particleData_set_ ## VARIABLE (const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)\ {\ - QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); \ + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); \ if (!r || !r->d()->datum)\ - ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\ + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));\ \ - r->d()->datum-> VARIABLE = (ctx->argc() && ctx->args()[0].toBoolean()) ? 1.0 : 0.0;\ - return QV4::Encode::undefined(); \ + r->d()->datum-> VARIABLE = (callData->argc && callData->args[0].toBoolean()) ? 1.0 : 0.0;\ + RETURN_UNDEFINED(); \ } -#define FLOAT_GETTER_AND_SETTER(VARIABLE) static QV4::ReturnedValue particleData_get_ ## VARIABLE (QV4::CallContext *ctx) \ +#define FLOAT_GETTER_AND_SETTER(VARIABLE) static void particleData_get_ ## VARIABLE (const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) \ { \ - QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); \ + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); \ if (!r || !r->d()->datum) \ - ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); \ + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); \ \ - return QV4::Encode(r->d()->datum-> VARIABLE);\ + RETURN_RESULT(QV4::Encode(r->d()->datum-> VARIABLE));\ }\ \ -static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\ +static void particleData_set_ ## VARIABLE (const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)\ {\ - QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); \ + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); \ if (!r || !r->d()->datum)\ - ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\ + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));\ \ - r->d()->datum-> VARIABLE = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan();\ - return QV4::Encode::undefined(); \ + r->d()->datum-> VARIABLE = callData->argc ? callData->args[0].toNumber() : qt_qnan();\ + RETURN_UNDEFINED(); \ } -#define FAKE_FLOAT_GETTER_AND_SETTER(VARIABLE, GETTER, SETTER) static QV4::ReturnedValue particleData_get_ ## VARIABLE (QV4::CallContext *ctx) \ +#define FAKE_FLOAT_GETTER_AND_SETTER(VARIABLE, GETTER, SETTER) static void particleData_get_ ## VARIABLE (const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) \ { \ - QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); \ + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); \ if (!r || !r->d()->datum) \ - ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object")); \ + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object"))); \ \ - return QV4::Encode(r->d()->datum-> GETTER (r->d()->particleSystem));\ + RETURN_RESULT(QV4::Encode(r->d()->datum-> GETTER (r->d()->particleSystem)));\ }\ \ -static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\ +static void particleData_set_ ## VARIABLE (const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)\ {\ - QV4::Scope scope(ctx); \ - QV4::Scoped<QV4ParticleData> r(scope, ctx->thisObject()); \ + QV4::Scoped<QV4ParticleData> r(scope, callData->thisObject); \ if (!r || !r->d()->datum)\ - ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\ + RETURN_RESULT(scope.engine->throwError(QStringLiteral("Not a valid ParticleData object")));\ \ - r->d()->datum-> SETTER (ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(), r->d()->particleSystem);\ - return QV4::Encode::undefined(); \ + r->d()->datum-> SETTER (callData->argc ? callData->args[0].toNumber() : qt_qnan(), r->d()->particleSystem);\ + RETURN_UNDEFINED(); \ } #define REGISTER_ACCESSOR(PROTO, ENGINE, VARIABLE, NAME) \ diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index daab7ad279..cb666451bb 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -109,9 +109,9 @@ using namespace QV4; static QBasicAtomicInt engineSerial = Q_BASIC_ATOMIC_INITIALIZER(1); -static ReturnedValue throwTypeError(CallContext *ctx) +void throwTypeError(const BuiltinFunction *, Scope &scope, CallData *) { - return ctx->engine()->throwTypeError(); + scope.result = scope.engine->throwTypeError(); } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 4be14c09ba..bd6eb17bb4 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -460,42 +460,6 @@ InternalClass *ScriptFunction::classForConstructor() const } - -DEFINE_OBJECT_VTABLE(OldBuiltinFunction); - -void Heap::OldBuiltinFunction::init(QV4::ExecutionContext *scope, QV4::String *name, ReturnedValue (*code)(QV4::CallContext *)) -{ - Heap::FunctionObject::init(scope, name); - this->code = code; -} - -void OldBuiltinFunction::construct(const Managed *f, Scope &scope, CallData *) -{ - scope.result = static_cast<const OldBuiltinFunction *>(f)->internalClass()->engine->throwTypeError(); -} - -void OldBuiltinFunction::call(const Managed *that, Scope &scope, CallData *callData) -{ - const OldBuiltinFunction *f = static_cast<const OldBuiltinFunction *>(that); - ExecutionEngine *v4 = scope.engine; - if (v4->hasException) { - scope.result = Encode::undefined(); - return; - } - CHECK_STACK_LIMITS(v4, scope); - - ExecutionContextSaver ctxSaver(scope); - - CallContext::Data *ctx = v4->memoryManager->allocSimpleCallContext(v4); - ctx->strictMode = f->scope()->strictMode; // ### needed? scope or parent context? - ctx->callData = callData; - v4->pushContext(ctx); - Q_ASSERT(v4->current == ctx); - - scope.result = f->d()->code(static_cast<QV4::CallContext *>(v4->currentContext)); - v4->memoryManager->freeSimpleCallContext(); -} - DEFINE_OBJECT_VTABLE(BuiltinFunction); void Heap::BuiltinFunction::init(QV4::ExecutionContext *scope, QV4::String *name, void (*code)(const QV4::BuiltinFunction *, Scope &, CallData *)) diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 354f6b2e3f..d691b869fe 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -192,21 +192,10 @@ struct FunctionPrototype: FunctionObject static void method_bind(const BuiltinFunction *, Scope &scope, CallData *callData); }; -struct Q_QML_EXPORT OldBuiltinFunction : FunctionObject { - V4_OBJECT2(OldBuiltinFunction, FunctionObject) - - static void construct(const Managed *, Scope &scope, CallData *); - static void call(const Managed *that, Scope &scope, CallData *callData); -}; - struct Q_QML_EXPORT BuiltinFunction : FunctionObject { V4_OBJECT2(BuiltinFunction, FunctionObject) V4_INTERNALCLASS(BuiltinFunction) - static Heap::OldBuiltinFunction *create(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)) - { - return scope->engine()->memoryManager->allocObject<OldBuiltinFunction>(scope, name, code); - } static Heap::BuiltinFunction *create(ExecutionContext *scope, String *name, void (*code)(const BuiltinFunction *, Scope &, CallData *)) { return scope->engine()->memoryManager->allocObject<BuiltinFunction>(scope, name, code); diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index cac9d8ad7d..04336d4f88 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -162,17 +162,6 @@ void Object::defineDefaultProperty(const QString &name, const Value &value) defineDefaultProperty(s, value); } -void Object::defineDefaultProperty(const QString &name, ReturnedValue (*code)(CallContext *), int argumentCount) -{ - ExecutionEngine *e = engine(); - Scope scope(e); - ScopedString s(scope, e->newIdentifier(name)); - ExecutionContext *global = e->rootContext(); - ScopedFunctionObject function(scope, BuiltinFunction::create(global, s, code)); - function->defineReadonlyProperty(e->id_length(), Primitive::fromInt32(argumentCount)); - defineDefaultProperty(s, function); -} - void Object::defineDefaultProperty(const QString &name, void (*code)(const BuiltinFunction *, Scope &, CallData *), int argumentCount) { ExecutionEngine *e = engine(); @@ -184,16 +173,6 @@ void Object::defineDefaultProperty(const QString &name, void (*code)(const Built defineDefaultProperty(s, function); } -void Object::defineDefaultProperty(String *name, ReturnedValue (*code)(CallContext *), int argumentCount) -{ - ExecutionEngine *e = engine(); - Scope scope(e); - ExecutionContext *global = e->rootContext(); - ScopedFunctionObject function(scope, BuiltinFunction::create(global, name, code)); - function->defineReadonlyProperty(e->id_length(), Primitive::fromInt32(argumentCount)); - defineDefaultProperty(name, function); -} - void Object::defineDefaultProperty(String *name, void (*code)(const BuiltinFunction *, Scope &, CallData *), int argumentCount) { ExecutionEngine *e = engine(); @@ -204,25 +183,6 @@ void Object::defineDefaultProperty(String *name, void (*code)(const BuiltinFunct defineDefaultProperty(name, function); } -void Object::defineAccessorProperty(const QString &name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)) -{ - ExecutionEngine *e = engine(); - Scope scope(e); - ScopedString s(scope, e->newIdentifier(name)); - defineAccessorProperty(s, getter, setter); -} - -void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)) -{ - ExecutionEngine *v4 = engine(); - QV4::Scope scope(v4); - ScopedProperty p(scope); - ExecutionContext *global = v4->rootContext(); - p->setGetter(ScopedFunctionObject(scope, (getter ? BuiltinFunction::create(global, name, getter) : 0))); - p->setSetter(ScopedFunctionObject(scope, (setter ? BuiltinFunction::create(global, name, setter) : 0))); - insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); -} - void Object::defineAccessorProperty(const QString &name, void (*getter)(const BuiltinFunction *, Scope &, CallData *), void (*setter)(const BuiltinFunction *, Scope &, CallData *)) { diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index cf04a84175..a9afe14129 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -255,12 +255,8 @@ struct Q_QML_EXPORT Object: Managed { insertMember(name, value, Attr_Data|Attr_NotEnumerable); } void defineDefaultProperty(const QString &name, const Value &value); - void defineDefaultProperty(const QString &name, ReturnedValue (*code)(CallContext *), int argumentCount = 0); void defineDefaultProperty(const QString &name, void (*code)(const BuiltinFunction *, Scope &, CallData *), int argumentCount = 0); - void defineDefaultProperty(String *name, ReturnedValue (*code)(CallContext *), int argumentCount = 0); void defineDefaultProperty(String *name, void (*code)(const BuiltinFunction *, Scope &, CallData *), int argumentCount = 0); - void defineAccessorProperty(const QString &name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)); - void defineAccessorProperty(String *name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *)); void defineAccessorProperty(const QString &name, void (*getter)(const BuiltinFunction *, Scope &, CallData *), void (*setter)(const BuiltinFunction *, Scope &, CallData *)); void defineAccessorProperty(String *name, void (*getter)(const BuiltinFunction *, Scope &, CallData *), diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index b9d312d41f..d4aa2e19ed 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -61,14 +61,13 @@ public: V4_DEFINE_EXTENSION(QQmlAdaptorModelEngineData, engineData) -static QV4::ReturnedValue get_index(QV4::CallContext *ctx) +static void get_index(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) - return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); + RETURN_RESULT(scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object"))); - return QV4::Encode(o->d()->item->index); + RETURN_RESULT(QV4::Encode(o->d()->item->index)); } template <typename T, typename M> static void setModelDataType(QMetaObjectBuilder *builder, M *metaType) @@ -195,19 +194,18 @@ public: dataType->watchedRoles += newRoles; } - static QV4::ReturnedValue get_hasModelChildren(QV4::CallContext *ctx) + static void get_hasModelChildren(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) - return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); + RETURN_RESULT(scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object"))); const QQmlAdaptorModel *const model = static_cast<QQmlDMCachedModelData *>(o->d()->item)->type->model; if (o->d()->item->index >= 0 && *model) { const QAbstractItemModel * const aim = model->aim(); - return QV4::Encode(aim->hasChildren(aim->index(o->d()->item->index, 0, model->rootIndex))); + RETURN_RESULT(QV4::Encode(aim->hasChildren(aim->index(o->d()->item->index, 0, model->rootIndex)))); } else { - return QV4::Encode(false); + RETURN_RESULT(QV4::Encode(false)); } } @@ -583,27 +581,25 @@ public: } } - static QV4::ReturnedValue get_modelData(QV4::CallContext *ctx) + static void get_modelData(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) - return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); + RETURN_RESULT(scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object"))); - return scope.engine->fromVariant(static_cast<QQmlDMListAccessorData *>(o->d()->item)->cachedData); + RETURN_RESULT(scope.engine->fromVariant(static_cast<QQmlDMListAccessorData *>(o->d()->item)->cachedData)); } - static QV4::ReturnedValue set_modelData(QV4::CallContext *ctx) + static void set_modelData(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData) { - QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, callData->thisObject.as<QQmlDelegateModelItemObject>()); if (!o) - return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!ctx->argc()) - return ctx->engine()->throwTypeError(); + RETURN_RESULT(scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object"))); + if (!callData->argc) + RETURN_RESULT(scope.engine->throwTypeError()); - static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(scope.engine->toVariant(ctx->args()[0], QVariant::Invalid)); - return QV4::Encode::undefined(); + static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(scope.engine->toVariant(callData->args[0], QVariant::Invalid)); + RETURN_RESULT(QV4::Encode::undefined()); } QV4::ReturnedValue get() diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index 584bd10151..441f8c113f 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -46,7 +46,7 @@ using namespace QV4; using namespace QV4::Debugging; -typedef QV4::ReturnedValue (*InjectedFunction)(QV4::CallContext*); +typedef void (*InjectedFunction)(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData); Q_DECLARE_METATYPE(InjectedFunction) static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) @@ -438,11 +438,11 @@ void tst_qv4debugger::addBreakPointWhilePaused() QCOMPARE(state.lineNumber, 2); } -static QV4::ReturnedValue someCall(QV4::CallContext *ctx) +static void someCall(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *) { - static_cast<QV4Debugger *>(ctx->d()->engine->debugger()) + static_cast<QV4Debugger *>(scope.engine->debugger()) ->removeBreakPoint("removeBreakPointForNextInstruction", 2); - return QV4::Encode::undefined(); + RETURN_UNDEFINED(); } void tst_qv4debugger::removeBreakPointForNextInstruction() |