return className;
}
-/* All exported module APIs are collected into this list */
-class ModuleApi {
-public:
- QString uri;
- int majorVersion;
- int minorVersion;
- QByteArray objectId;
-};
-QList<ModuleApi> moduleApis;
-
QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine, const QList<QQmlType *> &skip = QList<QQmlType *>())
{
QSet<const QMetaObject *> metas;
continue;
inObjectInstantiation = tyName;
- QObject *object = ty->create();
+ QObject *object = 0;
+
+ if (ty->isSingleton()) {
+ QQmlType::SingletonInstanceInfo *siinfo = ty->singletonInstanceInfo();
+ if (siinfo->qobjectCallback) {
+ siinfo->init(engine);
+ collectReachableMetaObjects(object, &metas);
+ object = siinfo->qobjectApi(engine);
+ } else {
+ inObjectInstantiation.clear();
+ continue; // we don't handle QJSValue singleton types.
+ }
+ } else {
+ ty->create();
+ }
+
inObjectInstantiation.clear();
if (object)
qWarning() << "Could not create" << tyName;
}
- // extract exported module api
- QHashIterator<QString, QList<QQmlMetaType::ModuleApi> > moduleApiIt(QQmlMetaType::moduleApis());
- while (moduleApiIt.hasNext()) {
- moduleApiIt.next();
- foreach (const QQmlMetaType::ModuleApi &api, moduleApiIt.value()) {
- ModuleApi moduleApi;
- moduleApi.uri = moduleApiIt.key();
- moduleApi.majorVersion = api.major;
- moduleApi.minorVersion = api.minor;
-
- if (api.qobject) {
- if (QObject *object = (*api.qobject)(engine, engine)) {
- collectReachableMetaObjects(object, &metas);
- moduleApi.objectId = convertToId(object->metaObject()->className());
- delete object;
- }
- } else if (api.script) {
- qWarning() << "Can't dump the module api in " << moduleApi.uri << ". QJSValue based module API is not supported.";
-// QJSValue value = (*api.script)(engine, engine);
-// IdToObjectHash jsObjects;
-// collectReachableJSObjects(value, &jsObjects, &metas);
- }
-
- moduleApis += moduleApi;
- }
- }
-
return metas;
}
qml->writeEndObject();
}
- void dump(const ModuleApi &api)
- {
- qml->writeStartObject(QLatin1String("ModuleApi"));
- if (api.uri != relocatableModuleUri)
- qml->writeScriptBinding(QLatin1String("uri"), enquote(api.uri));
- qml->writeScriptBinding(QLatin1String("version"), QString("%1.%2").arg(
- QString::number(api.majorVersion),
- QString::number(api.minorVersion)));
- qml->writeScriptBinding(QLatin1String("name"), enquote(api.objectId));
- qml->writeEndObject();
- }
-
void writeEasingCurve()
{
qml->writeStartObject(QLatin1String("Component"));
&& !meth.revision()
&& meth.methodType() == QMetaMethod::Signal
&& meth.parameterNames().isEmpty()
- && typeName.isEmpty()) {
+ && typeName != QLatin1String("void")) {
// don't mention implicit signals
return;
}
qml->writeScriptBinding(QLatin1String("revision"), QString::number(revision));
#endif
- if (! typeName.isEmpty())
+ if (typeName != QLatin1String("void"))
qml->writeScriptBinding(QLatin1String("type"), enquote(typeName));
for (int i = 0; i < meth.parameterTypes().size(); ++i) {
// find all QMetaObjects reachable when the specified module is imported
if (action != Path) {
- importCode += QString("import %0 %1\n").arg(pluginImportUri, pluginImportVersion).toAscii();
+ importCode += QString("import %0 %1\n").arg(pluginImportUri, pluginImportVersion).toLatin1();
} else {
// pluginImportVersion can be empty
- importCode += QString("import \".\" %2\n").arg(pluginImportVersion).toAscii();
+ importCode += QString("import \".\" %2\n").arg(pluginImportVersion).toLatin1();
}
// create a component with these imports to make sure the imports are valid
qml.writeStartDocument();
qml.writeLibraryImport(QLatin1String("QtQuick.tooling"), 1, 1);
- qml.write("\n"
+ qml.write(QString("\n"
"// This file describes the plugin-supplied types contained in the library.\n"
"// It is used for QML tooling purposes only.\n"
- "\n");
+ "//\n"
+ "// This file was auto-generated with the command '%1'.\n"
+ "\n").arg(args.join(QLatin1String(" "))));
qml.writeStartObject("Module");
// put the metaobjects into a map so they are always dumped in the same order
if (pluginImportUri.isEmpty())
dumper.writeEasingCurve();
- // write out module api elements
- foreach (const ModuleApi &api, moduleApis) {
- dumper.dump(api);
- }
-
qml.writeEndObject();
qml.writeEndDocument();