aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlmetatype_p.h
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/qqmlmetatype_p.h
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/qqmlmetatype_p.h')
-rw-r--r--src/qml/qml/qqmlmetatype_p.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 6f76c95544..4e60c2d0d3 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -117,8 +117,8 @@ public:
static void setQQuickAnchorLineCompareFunction(CompareFunction);
static bool QQuickAnchorLineCompare(const void *p1, const void *p2);
- struct ModuleApiInstance {
- ModuleApiInstance()
+ struct SingletonInstance {
+ SingletonInstance()
: scriptCallback(0), qobjectCallback(0), qobjectApi(0), instanceMetaObject(0) {}
QJSValue (*scriptCallback)(QQmlEngine *, QJSEngine *);
@@ -128,17 +128,18 @@ public:
QJSValue scriptApi;
};
- struct ModuleApi {
- inline ModuleApi();
- inline bool operator==(const ModuleApi &) const;
+ struct SingletonType {
+ inline SingletonType();
+ inline bool operator==(const SingletonType &) const;
int major;
int minor;
+ QString typeName;
QObject *(*qobject)(QQmlEngine *, QJSEngine *);
const QMetaObject *instanceMetaObject;
QJSValue (*script)(QQmlEngine *, QJSEngine *);
};
- static ModuleApi moduleApi(const QString &, int, int);
- static QHash<QString, QList<ModuleApi> > moduleApis();
+ static SingletonType singletonType(const QString &, int, int);
+ static QHash<QString, QList<SingletonType> > singletonTypes();
static bool namespaceContainsRegistrations(const QString &);
@@ -232,7 +233,11 @@ public:
QQmlType *type(const QHashedV8String &, int);
private:
+ QQmlType *typeNoLock(const QString &name, int minor);
+
friend int registerType(const QQmlPrivate::RegisterType &);
+ friend struct QQmlMetaTypeData;
+
QQmlTypeModule();
~QQmlTypeModule();
QQmlTypeModulePrivate *d;
@@ -257,7 +262,7 @@ private:
int m_minor;
};
-QQmlMetaType::ModuleApi::ModuleApi()
+QQmlMetaType::SingletonType::SingletonType()
{
major = 0;
minor = 0;
@@ -266,12 +271,12 @@ QQmlMetaType::ModuleApi::ModuleApi()
script = 0;
}
-bool QQmlMetaType::ModuleApi::operator==(const ModuleApi &other) const
+bool QQmlMetaType::SingletonType::operator==(const SingletonType &other) const
{
return major == other.major && minor == other.minor && script == other.script && qobject == other.qobject;
}
-inline uint qHash(const QQmlMetaType::ModuleApi &import)
+inline uint qHash(const QQmlMetaType::SingletonType &import)
{
return import.major ^ import.minor ^ quintptr(import.script) ^ quintptr(import.qobject);
}