diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-04 09:06:33 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-11 19:01:40 +0000 |
commit | 6f3f7d0aeeaa1ed813cbba07353312604464a92d (patch) | |
tree | 6acfb633d1941fc4ac834d7309773e77e97ca65c /sources | |
parent | bec70b8845b9d642dc2cd29b8c85e8d06b107ea3 (diff) |
shiboken: Improve error messages when rejecting functions
Pass up errors from translateType() to traverseFunction().
Remove the check for void type parameters since that
is not needed any more after 50dd4ae202d7afb3556335c056db003f5ef50532.
Task-number: PYSIDE-672
Change-Id: I82c095f027196361200b8854139b4bbc1fcc38c8
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside2/PySide2/QtCore/typesystem_core_common.xml | 4 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | 40 |
2 files changed, 14 insertions, 30 deletions
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml index cc63c0b7a..d23f90121 100644 --- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml @@ -4395,8 +4395,8 @@ s1.addTransition(button.clicked, s1h)</code> <suppress-warning text="enum 'PM_CbaIconHeight' does not have a type entry or is not an enum" /> <!-- TODO: this need be removed --> - <suppress-warning text="skipping function '*', unmatched return type '*'"/> - <suppress-warning text="skipping function '*', unmatched type '*"/> + <suppress-warning text="^skipping function '.*', unmatched return type '.*$"/> + <suppress-warning text="^skipping function '.*', unmatched type '.*$"/> <suppress-warning text="enum 'q_static_assert_result39' does not have a type entry or is not an enum"/> <suppress-warning text="horribly broken type ''"/> diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index 4c7077ae2..a4186da1a 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -1803,7 +1803,8 @@ static inline QString qualifiedFunctionSignatureWithType(const FunctionModelItem return result; } -static inline QString msgUnmatchedParameterType(const ArgumentModelItem &arg, int n) +static inline QString msgUnmatchedParameterType(const ArgumentModelItem &arg, int n, + const QString &why) { QString result; QTextStream str(&result); @@ -1811,23 +1812,16 @@ static inline QString msgUnmatchedParameterType(const ArgumentModelItem &arg, in << (n + 1); if (!arg->name().isEmpty()) str << " \"" << arg->name() << '"'; + str << ": " << why; return result; } -static inline QString msgUnmatchedReturnType(const FunctionModelItem &functionItem) +static inline QString msgUnmatchedReturnType(const FunctionModelItem &functionItem, + const QString &why) { return QLatin1String("unmatched return type '") - + functionItem->type().toString() + QLatin1Char('\''); -} - -static inline QString msgVoidParameterType(const ArgumentModelItem &arg, int n) -{ - QString result; - QTextStream str(&result); - str << "'void' encountered at parameter #" << (n + 1); - if (!arg->name().isEmpty()) - str << " \"" << arg->name() << '"'; - return result; + + functionItem->type().toString() + + QLatin1String("': ") + why; } static QString msgSkippingFunction(const FunctionModelItem &functionItem, @@ -1992,6 +1986,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(FunctionModel else *metaFunction += AbstractMetaAttributes::Protected; + QString errorMessage; switch (metaFunction->functionType()) { case AbstractMetaFunction::DestructorFunction: break; @@ -2010,9 +2005,9 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(FunctionModel AbstractMetaType *type = nullptr; if (!returnType.isVoid()) { - type = translateType(returnType); + type = translateType(returnType, true, &errorMessage); if (!type) { - const QString reason = msgUnmatchedReturnType(functionItem); + const QString reason = msgUnmatchedReturnType(functionItem, errorMessage); qCWarning(lcShiboken, "%s", qPrintable(msgSkippingFunction(functionItem, originalQualifiedSignatureWithReturn, reason))); m_rejectedFunctions.insert(originalQualifiedSignatureWithReturn, AbstractMetaBuilder::UnmatchedReturnType); @@ -2046,7 +2041,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(FunctionModel return nullptr; } - AbstractMetaType *metaType = translateType(arg->type()); + AbstractMetaType *metaType = translateType(arg->type(), true, &errorMessage); if (!metaType) { // If an invalid argument has a default value, simply remove it if (arg->defaultValue()) { @@ -2063,18 +2058,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(FunctionModel break; } Q_ASSERT(metaType == 0); - const QString reason = msgUnmatchedParameterType(arg, i); - qCWarning(lcShiboken, "%s", - qPrintable(msgSkippingFunction(functionItem, originalQualifiedSignatureWithReturn, reason))); - const QString rejectedFunctionSignature = originalQualifiedSignatureWithReturn - + QLatin1String(": ") + reason; - m_rejectedFunctions.insert(rejectedFunctionSignature, AbstractMetaBuilder::UnmatchedArgumentType); - delete metaFunction; - return nullptr; - } - - if (metaType == Q_NULLPTR) { - const QString reason = msgVoidParameterType(arg, i); + const QString reason = msgUnmatchedParameterType(arg, i, errorMessage); qCWarning(lcShiboken, "%s", qPrintable(msgSkippingFunction(functionItem, originalQualifiedSignatureWithReturn, reason))); const QString rejectedFunctionSignature = originalQualifiedSignatureWithReturn |