aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2014-12-30 15:21:16 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2015-01-02 21:11:01 +0100
commit3d11162fba96fb59593108c336a152920ddcf912 (patch)
tree621bff0d1e9b70f507be413ecf2182140e345194 /src/qml/qml
parent545338b21cd4d96c1b7ea9cc5c647f9a9155a53b (diff)
Reduce v8engine dependency in the type wrapper
Change-Id: I3a50aa3c0929c14ad856463635bf2fb2188f5c9f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp8
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp33
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h7
3 files changed, 20 insertions, 28 deletions
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index bcab5c84d6..0b63849e54 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -175,8 +175,6 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
// context = context->parent
// }
- QV8Engine *engine = v4->v8Engine;
-
QObject *scopeObject = resource->getScopeObject();
if (context->imports && name->startsWithUpper()) {
@@ -190,9 +188,9 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
QV4::ScopedObject scripts(scope, context->importedScripts);
return scripts->getIndexed(r.scriptIndex);
} else if (r.type) {
- return QmlTypeWrapper::create(engine, scopeObject, r.type);
+ return QmlTypeWrapper::create(v4, scopeObject, r.type);
} else if (r.importNamespace) {
- return QmlTypeWrapper::create(engine, scopeObject, context->imports, r.importNamespace);
+ return QmlTypeWrapper::create(v4, scopeObject, context->imports, r.importNamespace);
}
Q_ASSERT(!"Unreachable");
}
@@ -200,7 +198,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
// Fall through
}
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine->engine());
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(v4->v8Engine->engine());
while (context) {
// Search context properties
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index df3a17f968..c0f9ca18f0 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -48,9 +48,8 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(QmlTypeWrapper);
-Heap::QmlTypeWrapper::QmlTypeWrapper(QV8Engine *engine)
- : Heap::Object(QV8Engine::getV4(engine))
- , v8(engine)
+Heap::QmlTypeWrapper::QmlTypeWrapper(ExecutionEngine *engine)
+ : Heap::Object(engine)
, mode(IncludeEnums)
{
setVTable(QV4::QmlTypeWrapper::staticVTable());
@@ -72,7 +71,7 @@ QObject* QmlTypeWrapper::singletonObject() const
if (!isSingleton())
return 0;
- QQmlEngine *e = d()->v8->engine();
+ QQmlEngine *e = engine()->v8Engine->engine();
QQmlType::SingletonInstanceInfo *siinfo = d()->type->singletonInstanceInfo();
siinfo->init(e);
return siinfo->qobjectApi(e);
@@ -81,7 +80,7 @@ QObject* QmlTypeWrapper::singletonObject() const
QVariant QmlTypeWrapper::toVariant() const
{
if (d()->type && d()->type->isSingleton()) {
- QQmlEngine *e = d()->v8->engine();
+ QQmlEngine *e = engine()->v8Engine->engine();
QQmlType::SingletonInstanceInfo *siinfo = d()->type->singletonInstanceInfo();
siinfo->init(e); // note: this will also create QJSValue singleton which isn't strictly required.
QObject *qobjectSingleton = siinfo->qobjectApi(e);
@@ -96,29 +95,27 @@ QVariant QmlTypeWrapper::toVariant() const
// Returns a type wrapper for type t on o. This allows access of enums, and attached properties.
-ReturnedValue QmlTypeWrapper::create(QV8Engine *v8, QObject *o, QQmlType *t,
+ReturnedValue QmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o, QQmlType *t,
Heap::QmlTypeWrapper::TypeNameMode mode)
{
Q_ASSERT(t);
- ExecutionEngine *v4 = QV8Engine::getV4(v8);
- Scope scope(v4);
+ Scope scope(engine);
- Scoped<QmlTypeWrapper> w(scope, v4->memoryManager->alloc<QmlTypeWrapper>(v8));
+ Scoped<QmlTypeWrapper> w(scope, engine->memoryManager->alloc<QmlTypeWrapper>(engine));
w->d()->mode = mode; w->d()->object = o; w->d()->type = t;
return w.asReturnedValue();
}
// Returns a type wrapper for importNamespace (of t) on o. This allows nested resolution of a type in a
// namespace.
-ReturnedValue QmlTypeWrapper::create(QV8Engine *v8, QObject *o, QQmlTypeNameCache *t, const void *importNamespace,
+ReturnedValue QmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o, QQmlTypeNameCache *t, const void *importNamespace,
Heap::QmlTypeWrapper::TypeNameMode mode)
{
Q_ASSERT(t);
Q_ASSERT(importNamespace);
- ExecutionEngine *v4 = QV8Engine::getV4(v8);
- Scope scope(v4);
+ Scope scope(engine);
- Scoped<QmlTypeWrapper> w(scope, v4->memoryManager->alloc<QmlTypeWrapper>(v8));
+ Scoped<QmlTypeWrapper> w(scope, engine->memoryManager->alloc<QmlTypeWrapper>(engine));
w->d()->mode = mode; w->d()->object = o; w->d()->typeNamespace = t; w->d()->importNamespace = importNamespace;
t->addref();
return w.asReturnedValue();
@@ -137,8 +134,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
if (hasProperty)
*hasProperty = true;
- QV8Engine *v8engine = w->d()->v8;
- QQmlContextData *context = v8engine->callingContext();
+ QQmlContextData *context = v4->v8Engine->callingContext();
QObject *object = w->d()->object;
@@ -147,7 +143,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
// singleton types are handled differently to other types.
if (type->isSingleton()) {
- QQmlEngine *e = v8engine->engine();
+ QQmlEngine *e = v4->v8Engine->engine();
QQmlType::SingletonInstanceInfo *siinfo = type->singletonInstanceInfo();
siinfo->init(e);
@@ -208,14 +204,13 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
QQmlTypeNameCache::Result r = w->d()->typeNamespace->query(name, w->d()->importNamespace);
if (r.isValid()) {
- QQmlContextData *context = v8engine->callingContext();
if (r.type) {
- return create(w->d()->v8, object, r.type, w->d()->mode);
+ return create(scope.engine, object, r.type, w->d()->mode);
} else if (r.scriptIndex != -1) {
QV4::ScopedObject scripts(scope, context->importedScripts);
return scripts->getIndexed(r.scriptIndex);
} else if (r.importNamespace) {
- return create(w->d()->v8, object, context->imports, r.importNamespace);
+ return create(scope.engine, object, context->imports, r.importNamespace);
}
return QV4::Encode::undefined();
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index aff1fc0916..321e0cf0ec 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -66,9 +66,8 @@ struct QmlTypeWrapper : Object {
ExcludeEnums
};
- QmlTypeWrapper(QV8Engine *engine);
+ QmlTypeWrapper(QV4::ExecutionEngine *engine);
~QmlTypeWrapper();
- QV8Engine *v8;
TypeNameMode mode;
QPointer<QObject> object;
@@ -89,9 +88,9 @@ struct Q_QML_EXPORT QmlTypeWrapper : Object
QVariant toVariant() const;
- static ReturnedValue create(QV8Engine *, QObject *, QQmlType *,
+ static ReturnedValue create(ExecutionEngine *, QObject *, QQmlType *,
Heap::QmlTypeWrapper::TypeNameMode = Heap::QmlTypeWrapper::IncludeEnums);
- static ReturnedValue create(QV8Engine *, QObject *, QQmlTypeNameCache *, const void *,
+ static ReturnedValue create(ExecutionEngine *, QObject *, QQmlTypeNameCache *, const void *,
Heap::QmlTypeWrapper::TypeNameMode = Heap::QmlTypeWrapper::IncludeEnums);