forked from qt-creator/qt-creator
Parse the types registered with qmlRegisterUncreatableMetaObject()
Fixes: QTCREATORBUG-20569 Change-Id: I65fe8843b09aa127f0c564942b5b4e10a51342ba Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -87,7 +87,9 @@ public:
|
|||||||
QmlRegisterSingletonTypeUrl,
|
QmlRegisterSingletonTypeUrl,
|
||||||
// template<typename T> int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
|
// template<typename T> int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
|
||||||
// or template<typename T, int metaObjectRevision> int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
|
// or template<typename T, int metaObjectRevision> int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
|
||||||
QmlRegisterUncreatableType
|
QmlRegisterUncreatableType,
|
||||||
|
// int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaObject, const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString &reason)
|
||||||
|
QmlRegisterUncreatableMetaObject
|
||||||
};
|
};
|
||||||
|
|
||||||
FindExportsVisitor(CPlusPlus::Document::Ptr doc)
|
FindExportsVisitor(CPlusPlus::Document::Ptr doc)
|
||||||
@@ -189,6 +191,8 @@ protected:
|
|||||||
registrationFunction = QmlRegisterType5;
|
registrationFunction = QmlRegisterType5;
|
||||||
else if (fName == "qmlRegisterSingletonType")
|
else if (fName == "qmlRegisterSingletonType")
|
||||||
registrationFunction = QmlRegisterSingletonTypeCallback2;
|
registrationFunction = QmlRegisterSingletonTypeCallback2;
|
||||||
|
else if (fName == "qmlRegisterUncreatableMetaObject")
|
||||||
|
registrationFunction = QmlRegisterUncreatableMetaObject;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -215,6 +219,12 @@ protected:
|
|||||||
|| !ast->expression_list->next->next->next->next->value
|
|| !ast->expression_list->next->next->next->next->value
|
||||||
|| ast->expression_list->next->next->next->next->next)
|
|| ast->expression_list->next->next->next->next->next)
|
||||||
return false;
|
return false;
|
||||||
|
break;
|
||||||
|
case QmlRegisterUncreatableMetaObject:
|
||||||
|
if (!ast->expression_list->next->next->next->next->next
|
||||||
|
|| !ast->expression_list->next->next->next->next->next->value
|
||||||
|
|| ast->expression_list->next->next->next->next->next->next)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
ExpressionAST *uriExp = nullptr;
|
ExpressionAST *uriExp = nullptr;
|
||||||
ExpressionAST *majorVersionExp = nullptr;
|
ExpressionAST *majorVersionExp = nullptr;
|
||||||
@@ -235,6 +245,11 @@ protected:
|
|||||||
majorVersionExp = ast->expression_list->next->next->value;
|
majorVersionExp = ast->expression_list->next->next->value;
|
||||||
minorVersionExp = ast->expression_list->next->next->next->value;
|
minorVersionExp = ast->expression_list->next->next->next->value;
|
||||||
nameExp = ast->expression_list->next->next->next->next->value;
|
nameExp = ast->expression_list->next->next->next->next->value;
|
||||||
|
} else if (registrationFunction == QmlRegisterUncreatableMetaObject) {
|
||||||
|
uriExp = ast->expression_list->next->value;
|
||||||
|
majorVersionExp = ast->expression_list->next->next->value;
|
||||||
|
minorVersionExp = ast->expression_list->next->next->next->value;
|
||||||
|
nameExp = ast->expression_list->next->next->next->next->value;
|
||||||
} else {
|
} else {
|
||||||
uriExp = ast->expression_list->value;
|
uriExp = ast->expression_list->value;
|
||||||
majorVersionExp = ast->expression_list->next->value;
|
majorVersionExp = ast->expression_list->next->value;
|
||||||
@@ -331,7 +346,8 @@ protected:
|
|||||||
|| registrationFunction == QmlRegisterSingletonTypeCallback2
|
|| registrationFunction == QmlRegisterSingletonTypeCallback2
|
||||||
|| registrationFunction == QmlRegisterSingletonTypeUrl;
|
|| registrationFunction == QmlRegisterSingletonTypeUrl;
|
||||||
exportedType.isCreatable = !exportedType.isSingleton
|
exportedType.isCreatable = !exportedType.isSingleton
|
||||||
&& registrationFunction != QmlRegisterUncreatableType;
|
&& registrationFunction != QmlRegisterUncreatableType
|
||||||
|
&& registrationFunction != QmlRegisterUncreatableMetaObject;
|
||||||
exportedType.typeName = QString::fromUtf8(nameLit->chars(), nameLit->size());
|
exportedType.typeName = QString::fromUtf8(nameLit->chars(), nameLit->size());
|
||||||
exportedType.packageName = packageName;
|
exportedType.packageName = packageName;
|
||||||
if (majorLit && minorLit && majorLit->isInt() && minorLit->isInt()) {
|
if (majorLit && minorLit && majorLit->isInt() && minorLit->isInt()) {
|
||||||
@@ -363,6 +379,8 @@ protected:
|
|||||||
exportedType.url = QString::fromUtf8(urlLit->chars(), urlLit->size());
|
exportedType.url = QString::fromUtf8(urlLit->chars(), urlLit->size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (registrationFunction == QmlRegisterUncreatableMetaObject) {
|
||||||
|
// Anything to do here?
|
||||||
} else {
|
} else {
|
||||||
qCWarning(QmlJS::qmljsLog()) << "missing template type for registrationFunction " << registrationFunction;
|
qCWarning(QmlJS::qmljsLog()) << "missing template type for registrationFunction " << registrationFunction;
|
||||||
}
|
}
|
||||||
@@ -900,6 +918,7 @@ bool FindExportedCppTypes::maybeExportsTypes(const CPlusPlus::Document::Ptr &doc
|
|||||||
const QByteArray qmlRegisterSingletonTypeToken("qmlRegisterType");
|
const QByteArray qmlRegisterSingletonTypeToken("qmlRegisterType");
|
||||||
const QByteArray qmlRegisterTypeToken("qmlRegisterSingletonType");
|
const QByteArray qmlRegisterTypeToken("qmlRegisterSingletonType");
|
||||||
const QByteArray qmlRegisterUncreatableTypeToken("qmlRegisterUncreatableType");
|
const QByteArray qmlRegisterUncreatableTypeToken("qmlRegisterUncreatableType");
|
||||||
|
const QByteArray qmlRegisterUncreatableMetaObjectToken("qmlRegisterUncreatableMetaObject");
|
||||||
const QByteArray setContextPropertyToken("setContextProperty");
|
const QByteArray setContextPropertyToken("setContextProperty");
|
||||||
if (document->control()->findIdentifier(
|
if (document->control()->findIdentifier(
|
||||||
qmlRegisterTypeToken.constData(), qmlRegisterTypeToken.size())) {
|
qmlRegisterTypeToken.constData(), qmlRegisterTypeToken.size())) {
|
||||||
@@ -917,6 +936,10 @@ bool FindExportedCppTypes::maybeExportsTypes(const CPlusPlus::Document::Ptr &doc
|
|||||||
setContextPropertyToken.constData(), setContextPropertyToken.size())) {
|
setContextPropertyToken.constData(), setContextPropertyToken.size())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (document->control()->findIdentifier(
|
||||||
|
qmlRegisterUncreatableMetaObjectToken.constData(), qmlRegisterUncreatableMetaObjectToken.size())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user