From ed9a71b85849a653a3cc710e59b885002fc6f506 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sat, 29 Mar 2014 10:05:09 +0100 Subject: Make it possible to supply compilation units from plugins This also cleans up the script and type initialization in the type loader, for example by getting rid of the m_irUnit member for scripts. Change-Id: I207afeb21c0bae9091d3c7b4cac2e80e9aae0ea3 Reviewed-by: Lars Knoll --- src/qml/qml/qqmlmetatype.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/qml/qml/qqmlmetatype.cpp') diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 90d3ca3308..96894919a3 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -106,6 +106,7 @@ struct QQmlMetaTypeData QBitArray lists; QList parentFunctions; + QQmlPrivate::QmlUnitCacheLookupFunction lookupCachedQmlUnit; QSet protectedNamespaces; @@ -142,6 +143,7 @@ static uint qHash(const QQmlMetaTypeData::VersionedUri &v) } QQmlMetaTypeData::QQmlMetaTypeData() + : lookupCachedQmlUnit(0) { } @@ -1344,6 +1346,15 @@ int registerCompositeType(const QQmlPrivate::RegisterCompositeType &type) return index; } +int registerQmlUnitCacheHook(const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration) +{ + if (hookRegistration.version > 0) + qFatal("qmlRegisterType(): Cannot mix incompatible QML versions."); + QWriteLocker lock(metaTypeDataLock()); + QQmlMetaTypeData *data = metaTypeData(); + data->lookupCachedQmlUnit = hookRegistration.lookupCachedQmlUnit; + return 0; +} /* This method is "over generalized" to allow us to (potentially) register more types of things in @@ -1363,6 +1374,8 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data) return registerCompositeType(*reinterpret_cast(data)); } else if (type == CompositeSingletonRegistration) { return registerCompositeSingletonType(*reinterpret_cast(data)); + } else if (type == QmlUnitCacheHookRegistration) { + return registerQmlUnitCacheHook(*reinterpret_cast(data)); } return -1; } @@ -1887,4 +1900,13 @@ bool QQmlMetaType::QQuickAnchorLineCompare(const void *p1, const void *p2) return anchorLineCompareFunction(p1, p2); } +const QQmlPrivate::CachedQmlUnit *QQmlMetaType::findCachedCompilationUnit(const QUrl &uri) +{ + QReadLocker lock(metaTypeDataLock()); + QQmlMetaTypeData *data = metaTypeData(); + if (data->lookupCachedQmlUnit) + return data->lookupCachedQmlUnit(uri); + return 0; +} + QT_END_NAMESPACE -- cgit v1.2.3