From 5bc38a50308665bdc185eb96dbcc9ba7948ab4e0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 19 May 2017 12:39:52 +0200 Subject: Get rid of the old way of defining builtin functions The old calling convention used for builtin functions is very inefficient. It was still being used in a few places. Clean those up and convert them to the new and much more effiecient calling convention. Change-Id: I6b769c6185df7e9be1e80709330fc1ca868576c1 Reviewed-by: Robin Burchell --- src/qml/util/qqmladaptormodel.cpp | 44 ++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'src/qml/util') 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 o(scope, ctx->thisObject().as()); + QV4::Scoped o(scope, callData->thisObject.as()); 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 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 o(scope, ctx->thisObject().as()); + QV4::Scoped o(scope, callData->thisObject.as()); 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(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 o(scope, ctx->thisObject().as()); + QV4::Scoped o(scope, callData->thisObject.as()); 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(o->d()->item)->cachedData); + RETURN_RESULT(scope.engine->fromVariant(static_cast(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 o(scope, ctx->thisObject().as()); + QV4::Scoped o(scope, callData->thisObject.as()); 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(o->d()->item)->setModelData(scope.engine->toVariant(ctx->args()[0], QVariant::Invalid)); - return QV4::Encode::undefined(); + static_cast(o->d()->item)->setModelData(scope.engine->toVariant(callData->args[0], QVariant::Invalid)); + RETURN_RESULT(QV4::Encode::undefined()); } QV4::ReturnedValue get() -- cgit v1.2.3