aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-05-08 21:45:11 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-07-22 13:49:16 +0200
commit4632c0bfff911fa84f00aab9721519427cfa9921 (patch)
treea8513cf53831c554ee45b720abdbde8ed67e4c9b /src/qml
parent20224f2152aca440e91ef11644356c9db8d929de (diff)
Convert context and list wrapper
Change-Id: Ida3ac10092e1fae53f57e2e664f58c6138a17a99 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp38
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h6
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp19
-rw-r--r--src/qml/qml/qqmllistwrapper_p.h7
4 files changed, 33 insertions, 37 deletions
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index f94d70f61a..53353f6f1a 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -61,22 +61,21 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(QmlContextWrapper);
-QmlContextWrapper::QmlContextWrapper(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext)
- : Object(QV8Engine::getV4(engine))
+QmlContextWrapper::Data::Data(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext)
+ : Object::Data(QV8Engine::getV4(engine))
+ , readOnly(true)
+ , ownsContext(ownsContext)
+ , isNullWrapper(false)
+ , context(context)
+ , scopeObject(scopeObject)
{
setVTable(staticVTable());
-
- d()->readOnly = true;
- d()->ownsContext = ownsContext;
- d()->isNullWrapper = false;
- d()->context = context;
- d()->scopeObject = scopeObject;
}
-QmlContextWrapper::~QmlContextWrapper()
+QmlContextWrapper::Data::~Data()
{
- if (d()->context && d()->ownsContext)
- d()->context->destroy();
+ if (context && ownsContext)
+ context->destroy();
}
ReturnedValue QmlContextWrapper::qmlScope(QV8Engine *v8, QQmlContextData *ctxt, QObject *scope)
@@ -84,7 +83,7 @@ ReturnedValue QmlContextWrapper::qmlScope(QV8Engine *v8, QQmlContextData *ctxt,
ExecutionEngine *v4 = QV8Engine::getV4(v8);
Scope valueScope(v4);
- Scoped<QmlContextWrapper> w(valueScope, new (v4->memoryManager) QmlContextWrapper(v8, ctxt, scope));
+ Scoped<QmlContextWrapper> w(valueScope, new (v4) QmlContextWrapper::Data(v8, ctxt, scope));
return w.asReturnedValue();
}
@@ -98,7 +97,7 @@ ReturnedValue QmlContextWrapper::urlScope(QV8Engine *v8, const QUrl &url)
context->isInternal = true;
context->isJSContext = true;
- Scoped<QmlContextWrapper> w(scope, new (v4->memoryManager) QmlContextWrapper(v8, context, 0, true));
+ Scoped<QmlContextWrapper> w(scope, new (v4) QmlContextWrapper::Data(v8, context, 0, true));
w->d()->isNullWrapper = true;
return w.asReturnedValue();
}
@@ -357,7 +356,7 @@ void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value)
void QmlContextWrapper::destroy(Managed *that)
{
- static_cast<QmlContextWrapper *>(that)->~QmlContextWrapper();
+ static_cast<QmlContextWrapper *>(that)->d()->~Data();
}
void QmlContextWrapper::markObjects(Managed *m, ExecutionEngine *engine)
@@ -415,7 +414,9 @@ ReturnedValue QmlContextWrapper::idObjectsArray()
{
if (!d()->idObjectsWrapper) {
ExecutionEngine *v4 = engine();
- d()->idObjectsWrapper = new (v4->memoryManager) QQmlIdObjectsArray(v4, this);
+ Scope scope(v4);
+ Scoped<QQmlIdObjectsArray> a(scope, new (v4) QQmlIdObjectsArray::Data(v4, this));
+ d()->idObjectsWrapper = a.getPointer();
}
return d()->idObjectsWrapper->asReturnedValue();
}
@@ -443,12 +444,11 @@ ReturnedValue QmlContextWrapper::qmlSingletonWrapper(QV8Engine *v8, String *name
DEFINE_OBJECT_VTABLE(QQmlIdObjectsArray);
-QQmlIdObjectsArray::QQmlIdObjectsArray(ExecutionEngine *engine, QmlContextWrapper *contextWrapper)
- : Object(engine)
+QQmlIdObjectsArray::Data::Data(ExecutionEngine *engine, QmlContextWrapper *contextWrapper)
+ : Object::Data(engine)
+ , contextWrapper(contextWrapper)
{
setVTable(staticVTable());
-
- d()->contextWrapper = contextWrapper;
}
ReturnedValue QQmlIdObjectsArray::getIndexed(Managed *m, uint index, bool *hasProperty)
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index 297d2d009f..a2cb0960d4 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -74,6 +74,8 @@ struct QQmlIdObjectsArray;
struct Q_QML_EXPORT QmlContextWrapper : Object
{
struct Data : Object::Data {
+ Data(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext = false);
+ ~Data();
bool readOnly;
bool ownsContext;
bool isNullWrapper;
@@ -93,8 +95,6 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
} __data;
V4_OBJECT
- QmlContextWrapper(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext = false);
- ~QmlContextWrapper();
static ReturnedValue qmlScope(QV8Engine *e, QQmlContextData *ctxt, QObject *scope);
static ReturnedValue urlScope(QV8Engine *e, const QUrl &);
@@ -123,6 +123,7 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
struct QQmlIdObjectsArray : public Object
{
struct Data : Object::Data {
+ Data(ExecutionEngine *engine, QmlContextWrapper *contextWrapper);
QmlContextWrapper *contextWrapper;
};
struct {
@@ -130,7 +131,6 @@ struct QQmlIdObjectsArray : public Object
} __data;
V4_OBJECT
- QQmlIdObjectsArray(ExecutionEngine *engine, QmlContextWrapper *contextWrapper);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
static void markObjects(Managed *that, ExecutionEngine *engine);
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 055fd3ee68..6897b045dd 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -52,19 +52,18 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(QmlListWrapper);
-QmlListWrapper::QmlListWrapper(QV8Engine *engine)
- : Object(QV8Engine::getV4(engine))
+QmlListWrapper::Data::Data(QV8Engine *engine)
+ : Object::Data(QV8Engine::getV4(engine))
+ , v8(engine)
{
setVTable(staticVTable());
- d()->v8 = engine;
QV4::Scope scope(QV8Engine::getV4(engine));
- QV4::ScopedObject protectThis(scope, this);
- Q_UNUSED(protectThis);
- setArrayType(ArrayData::Custom);
+ QV4::ScopedObject o(scope, this);
+ o->setArrayType(ArrayData::Custom);
}
-QmlListWrapper::~QmlListWrapper()
+QmlListWrapper::Data::~Data()
{
}
@@ -76,7 +75,7 @@ ReturnedValue QmlListWrapper::create(QV8Engine *v8, QObject *object, int propId,
ExecutionEngine *v4 = QV8Engine::getV4(v8);
Scope scope(v4);
- Scoped<QmlListWrapper> r(scope, new (v4->memoryManager) QmlListWrapper(v8));
+ Scoped<QmlListWrapper> r(scope, new (v4) QmlListWrapper::Data(v8));
r->d()->object = object;
r->d()->propertyType = propType;
void *args[] = { &r->d()->property, 0 };
@@ -89,7 +88,7 @@ ReturnedValue QmlListWrapper::create(QV8Engine *v8, const QQmlListProperty<QObje
ExecutionEngine *v4 = QV8Engine::getV4(v8);
Scope scope(v4);
- Scoped<QmlListWrapper> r(scope, new (v4->memoryManager) QmlListWrapper(v8));
+ Scoped<QmlListWrapper> r(scope, new (v4) QmlListWrapper::Data(v8));
r->d()->object = prop.object;
r->d()->property = prop;
r->d()->propertyType = propType;
@@ -159,7 +158,7 @@ void QmlListWrapper::put(Managed *m, String *name, const ValueRef value)
void QmlListWrapper::destroy(Managed *that)
{
QmlListWrapper *w = that->as<QmlListWrapper>();
- w->~QmlListWrapper();
+ w->d()->~Data();
}
void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h
index da8f990957..670321bcd7 100644
--- a/src/qml/qml/qqmllistwrapper_p.h
+++ b/src/qml/qml/qqmllistwrapper_p.h
@@ -70,6 +70,8 @@ namespace QV4 {
struct Q_QML_EXPORT QmlListWrapper : Object
{
struct Data : Object::Data {
+ Data(QV8Engine *engine);
+ ~Data();
QV8Engine *v8;
QPointer<QObject> object;
QQmlListProperty<QObject> property;
@@ -83,11 +85,6 @@ struct Q_QML_EXPORT QmlListWrapper : Object
} __data;
V4_OBJECT
-protected:
- QmlListWrapper(QV8Engine *engine);
- ~QmlListWrapper();
-
-public:
static ReturnedValue create(QV8Engine *v8, QObject *object, int propId, int propType);
static ReturnedValue create(QV8Engine *v8, const QQmlListProperty<QObject> &prop, int propType);