Commit d4c2c3f2 authored by Aurindam Jana's avatar Aurindam Jana
Browse files

QmlJSInterpreter: QML Plugin types



A Component in .qmltypes can have an array of exports which
may differ in type names and versions.
Consider the type names to be aliases and create a CppComponentValue
for each of the alias corresponding to the best available version.

Change-Id: I759ae0c68441e805b0502bf2d203c524bf1a7a7c
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@nokia.com>
parent 72bf41b4
...@@ -1365,19 +1365,20 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri ...@@ -1365,19 +1365,20 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
// make new exported objects // make new exported objects
foreach (const FakeMetaObject::ConstPtr &fmo, _fakeMetaObjectsByPackage.value(package)) { foreach (const FakeMetaObject::ConstPtr &fmo, _fakeMetaObjectsByPackage.value(package)) {
// find the highest-version export // find the highest-version export for each alias
FakeMetaObject::Export bestExport; QHash<QString, FakeMetaObject::Export> bestExports;
QList<QString> aliases;
foreach (const FakeMetaObject::Export &exp, fmo->exports()) { foreach (const FakeMetaObject::Export &exp, fmo->exports()) {
// Store all aliases
if (!exp.type.isEmpty() && !aliases.contains(exp.type))
aliases.append(exp.type);
if (exp.package != package || (version.isValid() && exp.version > version)) if (exp.package != package || (version.isValid() && exp.version > version))
continue; continue;
if (!bestExport.isValid() || exp.version > bestExport.version)
bestExport = exp; if (bestExports.contains(exp.type)) {
if (exp.version > bestExports.value(exp.type).version)
bestExports.insert(exp.type, exp);
} else {
bestExports.insert(exp.type, exp);
}
} }
if (!bestExport.isValid()) if (bestExports.isEmpty())
continue; continue;
// if it already exists, skip // if it already exists, skip
...@@ -1385,34 +1386,24 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri ...@@ -1385,34 +1386,24 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
if (_objectsByQualifiedName.contains(key)) if (_objectsByQualifiedName.contains(key))
continue; continue;
QString name = bestExport.type; foreach (const FakeMetaObject::Export &bestExport, bestExports) {
bool exported = true; QString name = bestExport.type;
if (name.isEmpty()) { bool exported = true;
exported = false; if (name.isEmpty()) {
name = fmo->className(); exported = false;
} name = fmo->className();
}
CppComponentValue *newComponent = new CppComponentValue( CppComponentValue *newComponent = new CppComponentValue(
fmo, name, package, bestExport.version, version, fmo, name, package, bestExport.version, version,
bestExport.metaObjectRevision, _valueOwner); bestExport.metaObjectRevision, _valueOwner);
// use package.cppname importversion as key
_objectsByQualifiedName.insert(key, newComponent);
// Create CppComponentValues for all the aliases
// TODO: Show warning for deprecated ones
aliases.removeOne(name);
QList<const CppComponentValue *> newComponents;
newComponents.append(newComponent);
foreach (const QString &alias, aliases) {
newComponents.append(new CppComponentValue(
fmo, alias, package, bestExport.version, version,
bestExport.metaObjectRevision, _valueOwner));
}
if (exported) // use package.cppname importversion as key
exportedObjects += newComponents; _objectsByQualifiedName.insert(key, newComponent);
newObjects += newComponents; if (exported)
exportedObjects += newComponent;
newObjects += newComponent;
}
} }
// set their prototypes, creating them if necessary // set their prototypes, creating them if necessary
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment