From 2c7c791e3f0d801a8c1051b7da7b53cb4e50a017 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 7 May 2014 15:36:38 +0200 Subject: [PATCH] Remove the less often used Ref classes Change-Id: I9ee531c903317a0f324671d98af1f967b684915c Reviewed-by: Simon Hausmann --- src/imports/localstorage/plugin.cpp | 3 +-- src/qml/jsruntime/qv4engine.cpp | 4 ++-- src/qml/jsruntime/qv4engine_p.h | 4 ++-- src/qml/jsruntime/qv4functionobject.cpp | 2 +- src/qml/jsruntime/qv4functionobject_p.h | 4 +--- src/qml/jsruntime/qv4global_p.h | 3 --- src/qml/jsruntime/qv4jsonobject.cpp | 10 +++++----- src/qml/jsruntime/qv4jsonobject_p.h | 4 ++-- src/qml/jsruntime/qv4object_p.h | 2 -- src/qml/jsruntime/qv4qobjectwrapper.cpp | 4 ++-- src/qml/jsruntime/qv4qobjectwrapper_p.h | 2 -- src/qml/jsruntime/qv4regexpobject.cpp | 2 +- src/qml/jsruntime/qv4regexpobject_p.h | 4 +--- src/qml/jsruntime/qv4scopedvalue_p.h | 1 - src/qml/jsruntime/qv4sequenceobject.cpp | 2 +- src/qml/jsruntime/qv4variantobject_p.h | 2 -- src/qml/qml/qqmlvmemetaobject.cpp | 2 +- src/qml/qml/v8/qv8engine.cpp | 3 +-- src/qml/qml/v8/qv8engine_p.h | 4 ++-- src/quick/items/context2d/qquickcontext2d.cpp | 12 +++++------- 20 files changed, 28 insertions(+), 46 deletions(-) diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 03175fd..143c129 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -149,7 +149,6 @@ public: } }; -DEFINE_REF(QQmlSqlDatabaseWrapper, Object); DEFINE_OBJECT_VTABLE(QQmlSqlDatabaseWrapper); static ReturnedValue qmlsqldatabase_version(CallContext *ctx) @@ -225,7 +224,7 @@ static QString qmlsqldatabase_databaseFile(const QString& connectionName, QV8Eng return qmlsqldatabase_databasesPath(engine) + QDir::separator() + connectionName; } -static ReturnedValue qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapperRef r, ExecutionEngine *v4, quint32 index, bool *hasProperty = 0) +static ReturnedValue qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, ExecutionEngine *v4, quint32 index, bool *hasProperty = 0) { Scope scope(v4); QV8Engine *v8 = v4->v8Engine; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index a1c2b20..148e4fc 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -487,7 +487,7 @@ Returned *ExecutionEngine::newBuiltinFunction(ExecutionContext * return f->asReturned(); } -Returned *ExecutionEngine::newBoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const Members &boundArgs) +Returned *ExecutionEngine::newBoundFunction(ExecutionContext *scope, FunctionObject *target, const ValueRef boundThis, const Members &boundArgs) { Q_ASSERT(target); @@ -590,7 +590,7 @@ Returned *ExecutionEngine::newRegExpObject(const QString &pattern, return newRegExpObject(re, global); } -Returned *ExecutionEngine::newRegExpObject(RegExpRef re, bool global) +Returned *ExecutionEngine::newRegExpObject(RegExp *re, bool global) { RegExpObject *object = new (memoryManager) RegExpObject(this, re, global); return object->asReturned(); diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 6ff10ae..3ad25c0 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -308,7 +308,7 @@ public: ExecutionContext *popContext(); Returned *newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)); - Returned *newBoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QV4::Members &boundArgs); + Returned *newBoundFunction(ExecutionContext *scope, FunctionObject *target, const ValueRef boundThis, const QV4::Members &boundArgs); Returned *newObject(); Returned *newObject(InternalClass *internalClass); @@ -328,7 +328,7 @@ public: Returned *newDateObject(const QDateTime &dt); Returned *newRegExpObject(const QString &pattern, int flags); - Returned *newRegExpObject(RegExpRef re, bool global); + Returned *newRegExpObject(RegExp *re, bool global); Returned *newRegExpObject(const QRegExp &re); Returned *newErrorObject(const ValueRef value); diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index bc6cd45..571a85d 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -609,7 +609,7 @@ DEFINE_OBJECT_VTABLE(IndexedBuiltinFunction); DEFINE_OBJECT_VTABLE(BoundFunction); -BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const Members &boundArgs) +BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObject *target, const ValueRef boundThis, const Members &boundArgs) : FunctionObject(scope, QStringLiteral("__bound function__")) { d()->target = target; diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index ad1ebb4..181125a 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -166,8 +166,6 @@ inline FunctionObject *value_cast(const Value &v) { return v.asFunctionObject(); } -DEFINE_REF(FunctionObject, Object); - struct FunctionCtor: FunctionObject { V4_OBJECT @@ -268,7 +266,7 @@ struct BoundFunction: FunctionObject { Value boundThis() const { return d()->boundThis; } Members boundArgs() const { return d()->boundArgs; } - BoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const Members &boundArgs); + BoundFunction(ExecutionContext *scope, FunctionObject *target, const ValueRef boundThis, const Members &boundArgs); ~BoundFunction() {} static ReturnedValue construct(Managed *, CallData *d); diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 105ad93..331b9a7 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -165,9 +165,6 @@ typedef Returned ReturnedObject; typedef Returned ReturnedFunctionObject; struct ManagedRef; struct ObjectRef; -struct ArrayObjectRef; -struct FunctionObjectRef; -struct RegExpRef; struct PersistentValuePrivate; class PersistentValue; diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index f0f7152..752d647 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -656,7 +656,7 @@ struct Stringify Stringify(ExecutionContext *ctx) : ctx(ctx), replacerFunction(0) {} QString Str(const QString &key, ValueRef v); - QString JA(ArrayObjectRef a); + QString JA(ArrayObject *a); QString JO(ObjectRef o); QString makeMember(const QString &key, ValueRef v); @@ -837,9 +837,9 @@ QString Stringify::JO(ObjectRef o) return result; } -QString Stringify::JA(ArrayObjectRef a) +QString Stringify::JA(ArrayObject *a) { - if (stack.contains(a.getPointer())) { + if (stack.contains(a)) { ctx->throwTypeError(); return QString(); } @@ -847,7 +847,7 @@ QString Stringify::JA(ArrayObjectRef a) Scope scope(a->engine()); QString result; - stack.push(a.getPointer()); + stack.push(a); QString stepback = indent; indent += gap; @@ -1061,7 +1061,7 @@ QV4::ReturnedValue JsonObject::fromJsonArray(ExecutionEngine *engine, const QJso return a.asReturnedValue(); } -QJsonArray JsonObject::toJsonArray(ArrayObjectRef a, V4ObjectSet &visitedObjects) +QJsonArray JsonObject::toJsonArray(ArrayObject *a, V4ObjectSet &visitedObjects) { QJsonArray result; if (!a) diff --git a/src/qml/jsruntime/qv4jsonobject_p.h b/src/qml/jsruntime/qv4jsonobject_p.h index 34a4f4d..b42c63a 100644 --- a/src/qml/jsruntime/qv4jsonobject_p.h +++ b/src/qml/jsruntime/qv4jsonobject_p.h @@ -69,13 +69,13 @@ public: { V4ObjectSet visitedObjects; return toJsonValue(value, visitedObjects); } static inline QJsonObject toJsonObject(QV4::ObjectRef o) { V4ObjectSet visitedObjects; return toJsonObject(o, visitedObjects); } - static inline QJsonArray toJsonArray(QV4::ArrayObjectRef a) + static inline QJsonArray toJsonArray(QV4::ArrayObject *a) { V4ObjectSet visitedObjects; return toJsonArray(a, visitedObjects); } private: static QJsonValue toJsonValue(const QV4::ValueRef value, V4ObjectSet &visitedObjects); static QJsonObject toJsonObject(QV4::ObjectRef o, V4ObjectSet &visitedObjects); - static QJsonArray toJsonArray(QV4::ArrayObjectRef a, V4ObjectSet &visitedObjects); + static QJsonArray toJsonArray(ArrayObject *a, V4ObjectSet &visitedObjects); }; diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 3be5039..b9a95c6 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -468,8 +468,6 @@ struct ObjectRef : public ManagedRef } }; -DEFINE_REF(ArrayObject, Object); - } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 791ea0e..aa3347a 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -87,7 +87,7 @@ QT_BEGIN_NAMESPACE using namespace QV4; -static QPair extractQtMethod(QV4::FunctionObjectRef function) +static QPair extractQtMethod(QV4::FunctionObject *function) { QV4::ExecutionEngine *v4 = function->engine(); if (v4) { @@ -1737,7 +1737,7 @@ QV4::ReturnedValue CallArgument::toValue(QV8Engine *engine) } else if (type == -1 || type == qMetaTypeId()) { QVariant value = *qvariantPtr; QV4::ScopedValue rv(scope, engine->fromVariant(value)); - QV4::QObjectWrapperRef qobjectWrapper = rv; + QV4::Scoped qobjectWrapper(scope, rv); if (!!qobjectWrapper) { if (QObject *object = qobjectWrapper->object()) QQmlData::get(object, true)->setImplicitDestructible(); diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index 3164eb7..bc89dca 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -214,8 +214,6 @@ private Q_SLOTS: void removeDestroyedObject(QObject*); }; -DEFINE_REF(QObjectWrapper, Object); - } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index ab51ac7..5c6c067 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -80,7 +80,7 @@ RegExpObject::RegExpObject(InternalClass *ic) init(ic->engine); } -RegExpObject::RegExpObject(ExecutionEngine *engine, RegExpRef value, bool global) +RegExpObject::RegExpObject(ExecutionEngine *engine, RegExp *value, bool global) : Object(engine->regExpClass) { d()->value = value; diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index 96519f6..90827c1 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -93,7 +93,7 @@ struct RegExpObject: Object { RegExp *value() const { return d()->value; } bool global() const { return d()->global; } - RegExpObject(ExecutionEngine *engine, RegExpRef value, bool global); + RegExpObject(ExecutionEngine *engine, RegExp *value, bool global); RegExpObject(ExecutionEngine *engine, const QRegExp &re); void init(ExecutionEngine *engine); @@ -109,8 +109,6 @@ protected: static void markObjects(Managed *that, ExecutionEngine *e); }; -DEFINE_REF(RegExp, Object); - struct RegExpCtor: FunctionObject { struct Data : FunctionObject::Data { diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 97ad97b..82f7e1f 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -383,7 +383,6 @@ struct ScopedCallData { struct ObjectRef; -struct FunctionObjectRef; template inline Scoped::Scoped(const Scope &scope, const ValueRef &v) diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 6c964ad..9842c06 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -479,7 +479,7 @@ public: QVariant toVariant() const { return QVariant::fromValue(d()->container); } - static QVariant toVariant(QV4::ArrayObjectRef array) + static QVariant toVariant(QV4::ArrayObject *array) { QV4::Scope scope(array->engine()); Container result; diff --git a/src/qml/jsruntime/qv4variantobject_p.h b/src/qml/jsruntime/qv4variantobject_p.h index e02b921..926aec1 100644 --- a/src/qml/jsruntime/qv4variantobject_p.h +++ b/src/qml/jsruntime/qv4variantobject_p.h @@ -90,8 +90,6 @@ struct VariantObject : Object static bool isEqualTo(Managed *m, Managed *other); }; -DEFINE_REF(VariantObject, Object); - struct VariantPrototype : VariantObject { public: diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 1ff95a2..2f04984 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -1087,7 +1087,7 @@ void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value) // And, if the new value is a scarce resource, we need to ensure that it does not get // automatically released by the engine until no other references to it exist. QV4::ScopedValue newv(scope, QQmlEnginePrivate::get(ctxt->engine)->v8engine()->fromVariant(value)); - QV4::VariantObjectRef v = newv; + QV4::Scoped v(scope, newv); if (!!v) v->addVmePropertyReference(); diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 5dcbae6..a8a4f6a 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -560,8 +560,7 @@ QV4::ReturnedValue QV8Engine::variantListToJS(const QVariantList &lst) // The result is a QVariantList with length equal to the length // of the JS Array, and elements being the JS Array's elements // converted to QVariants, recursively. -QVariantList QV8Engine::variantListFromJS(QV4::ArrayObjectRef a, - V8ObjectSet &visitedObjects) +QVariantList QV8Engine::variantListFromJS(QV4::ArrayObject *a, V8ObjectSet &visitedObjects) { QVariantList result; if (!a) diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h index 1295e67..dfdce45 100644 --- a/src/qml/qml/v8/qv8engine_p.h +++ b/src/qml/qml/v8/qv8engine_p.h @@ -228,7 +228,7 @@ public: void setExtensionData(int, Deletable *); QV4::ReturnedValue variantListToJS(const QVariantList &lst); - inline QVariantList variantListFromJS(QV4::ArrayObjectRef array) + inline QVariantList variantListFromJS(QV4::ArrayObject *array) { V8ObjectSet visitedObjects; return variantListFromJS(array, visitedObjects); } QV4::ReturnedValue variantMapToJS(const QVariantMap &vmap); @@ -280,7 +280,7 @@ protected: void initializeGlobal(); private: - QVariantList variantListFromJS(QV4::ArrayObjectRef array, V8ObjectSet &visitedObjects); + QVariantList variantListFromJS(QV4::ArrayObject *array, V8ObjectSet &visitedObjects); QVariantMap variantMapFromJS(QV4::ObjectRef object, V8ObjectSet &visitedObjects); QVariant variantFromJS(const QV4::ValueRef value, V8ObjectSet &visitedObjects); diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 059123e..d14f593 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -937,8 +937,6 @@ struct QQuickJSContext2DImageData : public QV4::Object } }; -DEFINE_REF(QQuickJSContext2DImageData, QV4::Object); - DEFINE_OBJECT_VTABLE(QQuickJSContext2DImageData); static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV8Engine* engine, const QImage& image) @@ -2089,7 +2087,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_path(QV4::CallContext *ctx) QV4::ScopedValue value(scope, ctx->argument(0)); r->d()->context->beginPath(); - QV4::QObjectWrapperRef qobjectWrapper = value; + QV4::Scoped qobjectWrapper(scope, value); if (!!qobjectWrapper) { if (QQuickPath *path = qobject_cast(qobjectWrapper->object())) r->d()->context->m_path = path->path(); @@ -2950,7 +2948,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::CallContext pixmap = r->d()->context->createPixmap(url); } else if (arg->isObject()) { - QV4::QObjectWrapperRef qobjectWrapper = arg; + QV4::Scoped qobjectWrapper(scope, arg); if (!!qobjectWrapper) { if (QQuickImage *imageItem = qobject_cast(qobjectWrapper->object())) { pixmap = r->d()->context->createPixmap(imageItem->source()); @@ -2962,7 +2960,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::CallContext V4THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch"); } } else { - QQuickJSContext2DImageDataRef imageData = arg; + QV4::Scoped imageData(scope, arg); if (!!imageData) { QV4::Scoped pix(scope, imageData->d()->pixelData.as()); if (pix && !pix->d()->image.isNull()) { @@ -3232,7 +3230,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::CallC if (ctx->d()->callData->argc == 1) { QV4::ScopedValue arg0(scope, ctx->d()->callData->args[0]); - QQuickJSContext2DImageDataRef imgData = arg0; + QV4::Scoped imgData(scope, arg0); if (!!imgData) { QV4::Scoped pa(scope, imgData->d()->pixelData.as()); if (pa) { @@ -3310,7 +3308,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::CallCont if (!qIsFinite(dx) || !qIsFinite(dy)) V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments"); - QQuickJSContext2DImageDataRef imageData = arg0; + QV4::Scoped imageData(scope, arg0); if (!imageData) return ctx->d()->callData->thisObject.asReturnedValue(); -- 2.7.4