aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorLars Knoll <[email protected]>2014-05-09 10:14:25 +0200
committerSimon Hausmann <[email protected]>2014-07-22 13:49:17 +0200
commitdc7a53d85685e7ed768cc2ec9f4e0374b6a137f5 (patch)
tree5b652f8f6c464aa827736173f31133779bbe3c0a /src/qml
parent45f7120d42f628e86ae2bf3bd2789fdb190490e0 (diff)
Convert construtors for QObjectWrapper
Change-Id: Ie35966670b8fdc0d924f05d77e03ad9ae0d5b4c2 Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp37
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h13
2 files changed, 22 insertions, 28 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index aa3347a5fb..f3f11e50e9 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -239,14 +239,11 @@ static QV4::ReturnedValue LoadProperty(QV8Engine *engine, QObject *object,
}
}
-QObjectWrapper::QObjectWrapper(ExecutionEngine *engine, QObject *object)
- : Object(engine)
+QObjectWrapper::Data::Data(ExecutionEngine *engine, QObject *object)
+ : Object::Data(engine)
+ , object(object)
{
- d()->object = object;
setVTable(staticVTable());
-
- Scope scope(engine);
- ScopedObject protectThis(scope, this);
}
void QObjectWrapper::initializeBindings(ExecutionEngine *engine)
@@ -348,7 +345,7 @@ ReturnedValue QObjectWrapper::getProperty(QObject *object, ExecutionContext *ctx
QV4::Scoped<QV4::Object> qmlcontextobject(scope, ctx->d()->engine->qmlContextObject());
return QV4::QObjectMethod::create(ctx->d()->engine->rootContext, object, property->coreIndex, qmlcontextobject);
} else if (property->isSignalHandler()) {
- QV4::Scoped<QV4::QmlSignalHandler> handler(scope, new (ctx->d()->engine->memoryManager) QV4::QmlSignalHandler(ctx->d()->engine, object, property->coreIndex));
+ QV4::Scoped<QV4::QmlSignalHandler> handler(scope, new (scope.engine) QV4::QmlSignalHandler::Data(ctx->d()->engine, object, property->coreIndex));
QV4::ScopedString connect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("connect")));
QV4::ScopedString disconnect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("disconnect")));
@@ -661,7 +658,7 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object)
QQmlEngine *qmlEngine = engine->v8Engine->engine();
if (qmlEngine)
QQmlData::ensurePropertyCache(qmlEngine, object);
- return (new (engine->memoryManager) QV4::QObjectWrapper(engine, object))->asReturnedValue();
+ return (new (engine) QV4::QObjectWrapper::Data(engine, object))->asReturnedValue();
}
QV4::ReturnedValue QObjectWrapper::get(Managed *m, String *name, bool *hasProperty)
@@ -1028,7 +1025,7 @@ void QObjectWrapper::destroy(Managed *that)
QObjectWrapper *This = static_cast<QObjectWrapper*>(that);
QPointer<QObject> object = This->d()->object;
ExecutionEngine *engine = This->engine();
- This->~QObjectWrapper();
+ This->d()->~Data();
This = 0;
if (!object)
return;
@@ -1750,17 +1747,17 @@ QV4::ReturnedValue CallArgument::toValue(QV8Engine *engine)
ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal)
{
- return (new (scope->d()->engine->memoryManager) QObjectMethod(scope, object, index, qmlGlobal))->asReturnedValue();
+ return (new (scope->d()->engine) QObjectMethod::Data(scope, object, index, qmlGlobal))->asReturnedValue();
}
-QObjectMethod::QObjectMethod(ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal)
- : FunctionObject(scope)
+QObjectMethod::Data::Data(ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal)
+ : FunctionObject::Data(scope)
+ , object(object)
+ , index(index)
+ , qmlGlobal(qmlGlobal)
{
- d()->object = object;
- d()->index = index;
setVTable(staticVTable());
- setSubtype(WrappedQtMethod);
- d()->qmlGlobal = qmlGlobal;
+ subtype = WrappedQtMethod;
}
QV4::ReturnedValue QObjectMethod::method_toString(QV4::ExecutionContext *ctx)
@@ -1888,11 +1885,11 @@ ReturnedValue QObjectMethod::callInternal(CallData *callData)
DEFINE_OBJECT_VTABLE(QObjectMethod);
-QmlSignalHandler::QmlSignalHandler(ExecutionEngine *engine, QObject *object, int signalIndex)
- : Object(engine)
+QmlSignalHandler::Data::Data(ExecutionEngine *engine, QObject *object, int signalIndex)
+ : Object::Data(engine)
+ , object(object)
+ , signalIndex(signalIndex)
{
- d()->object = object;
- d()->signalIndex = signalIndex;
setVTable(staticVTable());
}
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index bc89dcabf8..c342caf1be 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -78,6 +78,7 @@ struct QObjectSlotDispatcher;
struct Q_QML_EXPORT QObjectWrapper : public QV4::Object
{
struct Data : QV4::Object::Data {
+ Data(ExecutionEngine *engine, QObject *object);
QPointer<QObject> object;
};
struct {
@@ -113,8 +114,6 @@ private:
static ReturnedValue create(ExecutionEngine *engine, QObject *object);
- QObjectWrapper(ExecutionEngine *engine, QObject *object);
-
QQmlPropertyData *findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const;
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
@@ -131,6 +130,7 @@ private:
struct QObjectMethod : public QV4::FunctionObject
{
struct Data : QV4::FunctionObject::Data {
+ Data(QV4::ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal);
QPointer<QObject> object;
int index;
QV4::PersistentValue qmlGlobal;
@@ -150,9 +150,6 @@ struct QObjectMethod : public QV4::FunctionObject
int methodIndex() const { return d()->index; }
QObject *object() const { return d()->object.data(); }
-private:
- QObjectMethod(QV4::ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal);
-
QV4::ReturnedValue method_toString(QV4::ExecutionContext *ctx);
QV4::ReturnedValue method_destroy(QV4::ExecutionContext *ctx, const ValueRef args, int argc);
@@ -162,13 +159,14 @@ private:
static void destroy(Managed *that)
{
- static_cast<QObjectMethod *>(that)->~QObjectMethod();
+ static_cast<QObjectMethod *>(that)->d()->~Data();
}
};
struct QmlSignalHandler : public QV4::Object
{
struct Data : QV4::Object::Data {
+ Data(ExecutionEngine *engine, QObject *object, int signalIndex);
QPointer<QObject> object;
int signalIndex;
};
@@ -179,7 +177,6 @@ struct QmlSignalHandler : public QV4::Object
V4_OBJECT
- QmlSignalHandler(ExecutionEngine *engine, QObject *object, int signalIndex);
int signalIndex() const { return d()->signalIndex; }
QObject *object() const { return d()->object.data(); }
@@ -188,7 +185,7 @@ private:
static void destroy(Managed *that)
{
- static_cast<QmlSignalHandler *>(that)->~QmlSignalHandler();
+ static_cast<QmlSignalHandler *>(that)->d()->~Data();
}
};