aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v4
diff options
context:
space:
mode:
authorGlenn Watson <glenn.watson@nokia.com>2012-07-24 11:41:50 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-08 07:55:19 +0200
commit6ebf215fdaf2d757ab90ae4d46c4b938e978e2dc (patch)
tree515da352f1cc4d5567b6d93f0b19952b2e27d705 /src/qml/qml/v4
parent92562eacbc3c614a83a734f1108ed7df02415eae (diff)
Add type name to singleton (module api) implementations.
This change renames the previous module api implementation to singleton types. When a singleton type is registered, a type name must be provided that is used when accessing the API from QML. This makes the implementation more consistent with the rest of QML. Task-number: QTBUG-26549 Change-Id: Iab0bb1ccf516bd3ae20aee562a64d22976e0aecd Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/qml/qml/v4')
-rw-r--r--src/qml/qml/v4/qv4bindings.cpp16
-rw-r--r--src/qml/qml/v4/qv4compiler.cpp2
-rw-r--r--src/qml/qml/v4/qv4irbuilder.cpp14
3 files changed, 16 insertions, 16 deletions
diff --git a/src/qml/qml/v4/qv4bindings.cpp b/src/qml/qml/v4/qv4bindings.cpp
index c0e0f22fad..9b74c2aa72 100644
--- a/src/qml/qml/v4/qv4bindings.cpp
+++ b/src/qml/qml/v4/qv4bindings.cpp
@@ -949,15 +949,15 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
reg.cleanupString();
if (r.isValid() && r.importNamespace) {
- QQmlMetaType::ModuleApiInstance *moduleApi = context->imports->moduleApi(r.importNamespace);
- if (moduleApi) {
- if (moduleApi->qobjectCallback) {
- moduleApi->qobjectApi = moduleApi->qobjectCallback(context->engine, context->engine);
- moduleApi->qobjectCallback = 0;
- moduleApi->scriptCallback = 0;
+ QQmlMetaType::SingletonInstance *singletonType = context->imports->singletonType(r.importNamespace);
+ if (singletonType) {
+ if (singletonType->qobjectCallback) {
+ singletonType->qobjectApi = singletonType->qobjectCallback(context->engine, context->engine);
+ singletonType->qobjectCallback = 0;
+ singletonType->scriptCallback = 0;
}
- if (moduleApi->qobjectApi)
- reg.setQObject(moduleApi->qobjectApi);
+ if (singletonType->qobjectApi)
+ reg.setQObject(singletonType->qobjectApi);
}
}
}
diff --git a/src/qml/qml/v4/qv4compiler.cpp b/src/qml/qml/v4/qv4compiler.cpp
index 8f87583a94..b697204839 100644
--- a/src/qml/qml/v4/qv4compiler.cpp
+++ b/src/qml/qml/v4/qv4compiler.cpp
@@ -334,7 +334,7 @@ void QV4CompilerPrivate::visitName(IR::Name *e)
/*
Existing module object lookup methods include:
1. string -> module object (search via importCache->query(name))
- 2. QQmlMetaType::ModuleApi -> module object (via QQmlEnginePrivate::moduleApiInstance() cache)
+ 2. QQmlMetaType::SingletonType -> module object (via QQmlEnginePrivate::singletonTypeInstance() cache)
We currently use 1, which is not ideal for performance
*/
_subscribeName << *e->id;
diff --git a/src/qml/qml/v4/qv4irbuilder.cpp b/src/qml/qml/v4/qv4irbuilder.cpp
index 79090b4269..93c552173f 100644
--- a/src/qml/qml/v4/qv4irbuilder.cpp
+++ b/src/qml/qml/v4/qv4irbuilder.cpp
@@ -446,15 +446,15 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast)
if (r.type) {
_expr.code = _block->ATTACH_TYPE(name, r.type, IR::Name::ScopeStorage, line, column);
} else if (r.importNamespace) {
- QQmlMetaType::ModuleApiInstance *moduleApi = m_expression->importCache->moduleApi(r.importNamespace);
- if (moduleApi && moduleApi->instanceMetaObject) {
- // Note: we don't need to check moduleApi->qobjectCallback here, since
- // we did that check in registerModuleApi() in qqmlmetatype.cpp.
- // We cannot create the QObject Module Api Instance here,
+ QQmlMetaType::SingletonInstance *singletonType = m_expression->importCache->singletonType(r.importNamespace);
+ if (singletonType && singletonType->instanceMetaObject) {
+ // Note: we don't need to check singletonType->qobjectCallback here, since
+ // we did that check in registerSingletonType() in qqmlmetatype.cpp.
+ // We cannot create the QObject Singleton Type Instance here,
// as we might be running in a loader thread.
- // Thus, V4 can only handle bindings which use Module APIs which
+ // Thus, V4 can only handle bindings which use Singleton Types which
// were registered with the templated registration function.
- _expr.code = _block->MODULE_OBJECT(name, moduleApi->instanceMetaObject, IR::Name::MemberStorage, line, column);
+ _expr.code = _block->MODULE_OBJECT(name, singletonType->instanceMetaObject, IR::Name::MemberStorage, line, column);
}
}
// We don't support anything else