summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qlibrary_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2012-02-06 23:36:17 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-15 17:27:37 +0100
commit7184456f9a26a9c07a689c15b415ddf82eb000b7 (patch)
tree076d42ad3fd6f08a1cbef21ee6811a3fa951850b /src/corelib/plugin/qlibrary_p.h
parent556dd0228aca07dfe8443fd99e9f2ead4e13ab22 (diff)
Implement new plugin mechanism
moc can now embed meta information about the plugin inside the plugin itself. This information can be queried by Qt without having to load the plugin. Source compatibility with the old plugin loading mechanism is still there, but will be removed before Qt 5.0. Change-Id: I03e4196ddfed07d0fe94acca40d5de8a6ce7f920 Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/plugin/qlibrary_p.h')
-rw-r--r--src/corelib/plugin/qlibrary_p.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h
index a5f366070c..604a5fbdde 100644
--- a/src/corelib/plugin/qlibrary_p.h
+++ b/src/corelib/plugin/qlibrary_p.h
@@ -58,6 +58,9 @@
#include "QtCore/qstringlist.h"
#include "QtCore/qplugin.h"
#include "QtCore/qsharedpointer.h"
+#include "QtCore/qjsonobject.h"
+#include "QtCore/qjsondocument.h"
+#include "QtCore/qendian.h"
#ifdef Q_OS_WIN
# include "QtCore/qt_windows.h"
#endif
@@ -90,16 +93,26 @@ public:
static QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version = QString());
+ static QVector<QStaticPlugin> staticPlugins();
+
+
QWeakPointer<QObject> inst;
QtPluginInstanceFunction instance;
- uint qt_version;
- QString lastModified;
+ QJsonObject metaData;
+ bool compatPlugin;
QString errorString;
QLibrary::LoadHints loadHints;
bool isPlugin();
+ static inline QJsonDocument fromRawMetaData(const char *raw) {
+ raw += strlen("QTMETADATA ");
+ // the size of the embedded JSON object can be found 8 bytes into the data (see qjson_p.h),
+ // but doesn't include the size of the header (8 bytes)
+ QByteArray json(raw, qFromLittleEndian<uint>(*(uint *)(raw + 8)) + 8);
+ return QJsonDocument::fromBinaryData(json);
+ }
private:
explicit QLibraryPrivate(const QString &canonicalFileName, const QString &version);
@@ -112,7 +125,7 @@ private:
QAtomicInt libraryRefCount;
QAtomicInt libraryUnloadCount;
- enum {IsAPlugin, IsNotAPlugin, MightBeAPlugin } pluginState;
+ enum { IsAPlugin, IsNotAPlugin, MightBeAPlugin } pluginState;
friend class QLibraryPrivateHasFriends;
};