forked from qt-creator/qt-creator
Qml/C++: Add finding C++ qmlRegisterUncreatableType calls.
Change-Id: I4e1b87cc247a04236a9c9f157d04b1fc817530d0 Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
committed by
Fawzi Mohamed
parent
79f238fb75
commit
fcb825d4f6
@@ -143,7 +143,12 @@ protected:
|
|||||||
if (!templateIdentifier)
|
if (!templateIdentifier)
|
||||||
return false;
|
return false;
|
||||||
const QString callName = QString::fromUtf8(templateIdentifier->chars());
|
const QString callName = QString::fromUtf8(templateIdentifier->chars());
|
||||||
if (callName != QLatin1String("qmlRegisterType"))
|
int argCount = 0;
|
||||||
|
if (callName == QLatin1String("qmlRegisterType"))
|
||||||
|
argCount = 4;
|
||||||
|
else if (callName == QLatin1String("qmlRegisterUncreatableType"))
|
||||||
|
argCount = 5;
|
||||||
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// must have a single typeid template argument
|
// must have a single typeid template argument
|
||||||
@@ -154,16 +159,21 @@ protected:
|
|||||||
if (!typeId)
|
if (!typeId)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// must have four arguments
|
// must have four arguments for qmlRegisterType and five for qmlRegisterUncreatableType
|
||||||
if (!ast->expression_list
|
if (!ast->expression_list
|
||||||
|| !ast->expression_list->value || !ast->expression_list->next
|
|| !ast->expression_list->value || !ast->expression_list->next
|
||||||
|| !ast->expression_list->next->value || !ast->expression_list->next->next
|
|| !ast->expression_list->next->value || !ast->expression_list->next->next
|
||||||
|| !ast->expression_list->next->next->value || !ast->expression_list->next->next->next
|
|| !ast->expression_list->next->next->value || !ast->expression_list->next->next->next
|
||||||
|| !ast->expression_list->next->next->next->value
|
|| !ast->expression_list->next->next->next->value)
|
||||||
|| ast->expression_list->next->next->next->next)
|
return false;
|
||||||
|
if (argCount == 4 && ast->expression_list->next->next->next->next)
|
||||||
|
return false;
|
||||||
|
if (argCount == 5 && (!ast->expression_list->next->next->next->next
|
||||||
|
|| !ast->expression_list->next->next->next->next->value
|
||||||
|
|| ast->expression_list->next->next->next->next->next))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// last argument must be a string literal
|
// 4th argument must be a string literal
|
||||||
const StringLiteral *nameLit = 0;
|
const StringLiteral *nameLit = 0;
|
||||||
if (StringLiteralAST *nameAst = skipStringCall(ast->expression_list->next->next->next->value)->asStringLiteral())
|
if (StringLiteralAST *nameAst = skipStringCall(ast->expression_list->next->next->next->value)->asStringLiteral())
|
||||||
nameLit = translationUnit()->stringLiteral(nameAst->literal_token);
|
nameLit = translationUnit()->stringLiteral(nameAst->literal_token);
|
||||||
@@ -748,11 +758,16 @@ bool FindExportedCppTypes::maybeExportsTypes(const Document::Ptr &document)
|
|||||||
if (!document->control())
|
if (!document->control())
|
||||||
return false;
|
return false;
|
||||||
const QByteArray qmlRegisterTypeToken("qmlRegisterType");
|
const QByteArray qmlRegisterTypeToken("qmlRegisterType");
|
||||||
|
const QByteArray qmlRegisterUncreatableTypeToken("qmlRegisterUncreatableType");
|
||||||
const QByteArray setContextPropertyToken("setContextProperty");
|
const QByteArray setContextPropertyToken("setContextProperty");
|
||||||
if (document->control()->findIdentifier(
|
if (document->control()->findIdentifier(
|
||||||
qmlRegisterTypeToken.constData(), qmlRegisterTypeToken.size())) {
|
qmlRegisterTypeToken.constData(), qmlRegisterTypeToken.size())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (document->control()->findIdentifier(
|
||||||
|
qmlRegisterUncreatableTypeToken.constData(), qmlRegisterUncreatableTypeToken.size())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (document->control()->findIdentifier(
|
if (document->control()->findIdentifier(
|
||||||
setContextPropertyToken.constData(), setContextPropertyToken.size())) {
|
setContextPropertyToken.constData(), setContextPropertyToken.size())) {
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user