qmlplugindump: Describe meta object revisions of exported types.
Adds the exportMetaObjectRevisions property to generated qmltypes files. Change-Id: Iafe2fe408c88bb6dd02cbb558404a5f654431248 Reviewed-on: http://codereview.qt-project.org/5311 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
parent
43ff44058d
commit
26e15e877f
|
@ -445,6 +445,13 @@ Module {
|
||||||
"QtQuick/Animation 1.0"
|
"QtQuick/Animation 1.0"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// The meta object revisions for the exports specified in 'exports'.
|
||||||
|
// Describes with revisioned properties will be visible in an export.
|
||||||
|
// The list must have exactly the same length as the 'exports' list.
|
||||||
|
// For example the 'animations' propery described below will only be
|
||||||
|
// available through the QtQuick/Animation 1.0 export.
|
||||||
|
exportMetaObjectRevisions: [0, 1]
|
||||||
|
|
||||||
Property {
|
Property {
|
||||||
name: "animations";
|
name: "animations";
|
||||||
type: "QDeclarativeAbstractAnimation"
|
type: "QDeclarativeAbstractAnimation"
|
||||||
|
@ -454,7 +461,7 @@ Module {
|
||||||
isPointer: true
|
isPointer: true
|
||||||
// defaults to false: whether the type actually is a QDeclarativeListProperty<type>
|
// defaults to false: whether the type actually is a QDeclarativeListProperty<type>
|
||||||
isList: true
|
isList: true
|
||||||
// defaults to 0: the minor version that introduced this property
|
// defaults to 0: the meta object revision that introduced this property
|
||||||
revision: 1
|
revision: 1
|
||||||
}
|
}
|
||||||
Property { name: "loops"; type: "int" }
|
Property { name: "loops"; type: "int" }
|
||||||
|
|
|
@ -256,30 +256,43 @@ public:
|
||||||
|
|
||||||
QSet<const QDeclarativeType *> qmlTypes = qmlTypesByCppName.value(meta->className());
|
QSet<const QDeclarativeType *> qmlTypes = qmlTypesByCppName.value(meta->className());
|
||||||
if (!qmlTypes.isEmpty()) {
|
if (!qmlTypes.isEmpty()) {
|
||||||
QStringList exports;
|
QHash<QString, const QDeclarativeType *> exports;
|
||||||
|
|
||||||
foreach (const QDeclarativeType *qmlTy, qmlTypes) {
|
foreach (const QDeclarativeType *qmlTy, qmlTypes) {
|
||||||
QString qmlTyName = qmlTy->qmlTypeName();
|
QString qmlTyName = qmlTy->qmlTypeName();
|
||||||
// some qmltype names are missing the actual names, ignore that import
|
|
||||||
if (qmlTyName.endsWith('/'))
|
|
||||||
continue;
|
|
||||||
if (qmlTyName.startsWith(relocatableModuleUri + QLatin1Char('/'))) {
|
if (qmlTyName.startsWith(relocatableModuleUri + QLatin1Char('/'))) {
|
||||||
qmlTyName.remove(0, relocatableModuleUri.size() + 1);
|
qmlTyName.remove(0, relocatableModuleUri.size() + 1);
|
||||||
}
|
}
|
||||||
if (qmlTyName.startsWith("./")) {
|
if (qmlTyName.startsWith("./")) {
|
||||||
qmlTyName.remove(0, 2);
|
qmlTyName.remove(0, 2);
|
||||||
}
|
}
|
||||||
exports += enquote(QString("%1 %2.%3").arg(
|
if (qmlTyName.startsWith("/")) {
|
||||||
|
qmlTyName.remove(0, 1);
|
||||||
|
}
|
||||||
|
const QString exportString = enquote(
|
||||||
|
QString("%1 %2.%3").arg(
|
||||||
qmlTyName,
|
qmlTyName,
|
||||||
QString::number(qmlTy->majorVersion()),
|
QString::number(qmlTy->majorVersion()),
|
||||||
QString::number(qmlTy->minorVersion())));
|
QString::number(qmlTy->minorVersion())));
|
||||||
|
exports.insert(exportString, qmlTy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure exports are sorted and don't change order when the plugin is dumped again
|
// ensure exports are sorted and don't change order when the plugin is dumped again
|
||||||
exports.removeDuplicates();
|
QStringList exportStrings = exports.keys();
|
||||||
qSort(exports);
|
qSort(exportStrings);
|
||||||
|
qml->writeArrayBinding(QLatin1String("exports"), exportStrings);
|
||||||
|
|
||||||
qml->writeArrayBinding(QLatin1String("exports"), exports);
|
// write meta object revisions unless they're all zero
|
||||||
|
QStringList metaObjectRevisions;
|
||||||
|
bool shouldWriteMetaObjectRevisions = false;
|
||||||
|
foreach (const QString &exportString, exportStrings) {
|
||||||
|
int metaObjectRevision = exports[exportString]->metaObjectRevision();
|
||||||
|
if (metaObjectRevision != 0)
|
||||||
|
shouldWriteMetaObjectRevisions = true;
|
||||||
|
metaObjectRevisions += QString::number(metaObjectRevision);
|
||||||
|
}
|
||||||
|
if (shouldWriteMetaObjectRevisions)
|
||||||
|
qml->writeArrayBinding(QLatin1String("exportMetaObjectRevisions"), metaObjectRevisions);
|
||||||
|
|
||||||
if (const QMetaObject *attachedType = (*qmlTypes.begin())->attachedPropertiesType()) {
|
if (const QMetaObject *attachedType = (*qmlTypes.begin())->attachedPropertiesType()) {
|
||||||
qml->writeScriptBinding(QLatin1String("attachedType"), enquote(
|
qml->writeScriptBinding(QLatin1String("attachedType"), enquote(
|
||||||
|
|
|
@ -110,6 +110,22 @@ void QmlStreamWriter::writeArrayBinding(const QString &name, const QStringList &
|
||||||
{
|
{
|
||||||
flushPotentialLinesWithNewlines();
|
flushPotentialLinesWithNewlines();
|
||||||
writeIndent();
|
writeIndent();
|
||||||
|
|
||||||
|
// try to use a single line
|
||||||
|
QString singleLine;
|
||||||
|
singleLine += QString("%1: [").arg(name);
|
||||||
|
for (int i = 0; i < elements.size(); ++i) {
|
||||||
|
singleLine += elements.at(i);
|
||||||
|
if (i != elements.size() - 1)
|
||||||
|
singleLine += QLatin1String(", ");
|
||||||
|
}
|
||||||
|
singleLine += QLatin1String("]\n");
|
||||||
|
if (singleLine.size() + m_indentDepth * 4 < 80) {
|
||||||
|
m_stream->write(singleLine.toUtf8());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// write multi-line
|
||||||
m_stream->write(QString("%1: [\n").arg(name).toUtf8());
|
m_stream->write(QString("%1: [\n").arg(name).toUtf8());
|
||||||
++m_indentDepth;
|
++m_indentDepth;
|
||||||
for (int i = 0; i < elements.size(); ++i) {
|
for (int i = 0; i < elements.size(); ++i) {
|
||||||
|
|
Loading…
Reference in New Issue