From fb1c0f204e09ba29fa3d360d72231d4ed468c1e4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 12 Oct 2020 09:23:49 +0200 Subject: shiboken2: Add location to error messages about added functions Change-Id: I39210642a96e98328d193f4e81ecad82b496d6c9 Reviewed-by: Cristian Maureira-Fredes --- sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | 6 ++++-- sources/shiboken2/ApiExtractor/messages.cpp | 10 ++++++++-- sources/shiboken2/ApiExtractor/messages.h | 6 ++++-- 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'sources') diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index dd3e3fac0..b6e68bfde 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -1537,7 +1537,8 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu qCWarning(lcShiboken, "%s", qPrintable(msgAddedFunctionInvalidReturnType(addedFunc->name(), addedFunc->returnType().name, - errorMessage))); + errorMessage, + metaClass))); return nullptr; } @@ -1553,7 +1554,8 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu qCWarning(lcShiboken, "%s", qPrintable(msgAddedFunctionInvalidArgType(addedFunc->name(), typeInfo.name, i + 1, - errorMessage))); + errorMessage, + metaClass))); delete metaFunction; return nullptr; } diff --git a/sources/shiboken2/ApiExtractor/messages.cpp b/sources/shiboken2/ApiExtractor/messages.cpp index a660f7e76..ab03a0102 100644 --- a/sources/shiboken2/ApiExtractor/messages.cpp +++ b/sources/shiboken2/ApiExtractor/messages.cpp @@ -112,20 +112,26 @@ static void msgFormatEnumType(Stream &str, QString msgAddedFunctionInvalidArgType(const QString &addedFuncName, const QString &typeName, - int pos, const QString &why) + int pos, const QString &why, + const AbstractMetaClass *context) { QString result; QTextStream str(&result); + if (context) + str << context->typeEntry()->sourceLocation(); str << "Unable to translate type \"" << typeName << "\" of argument " << pos << " of added function \"" << addedFuncName << "\": " << why; return result; } QString msgAddedFunctionInvalidReturnType(const QString &addedFuncName, - const QString &typeName, const QString &why) + const QString &typeName, const QString &why, + const AbstractMetaClass *context) { QString result; QTextStream str(&result); + if (context) + str << context->typeEntry()->sourceLocation(); str << "Unable to translate return type \"" << typeName << "\" of added function \"" << addedFuncName << "\": " << why; diff --git a/sources/shiboken2/ApiExtractor/messages.h b/sources/shiboken2/ApiExtractor/messages.h index 55481270c..1e58a7fad 100644 --- a/sources/shiboken2/ApiExtractor/messages.h +++ b/sources/shiboken2/ApiExtractor/messages.h @@ -49,10 +49,12 @@ QT_FORWARD_DECLARE_CLASS(QXmlStreamReader) QString msgAddedFunctionInvalidArgType(const QString &addedFuncName, const QString &typeName, - int pos, const QString &why); + int pos, const QString &why, + const AbstractMetaClass *context = nullptr); QString msgAddedFunctionInvalidReturnType(const QString &addedFuncName, - const QString &typeName, const QString &why); + const QString &typeName, const QString &why, + const AbstractMetaClass *context = nullptr); QString msgNoFunctionForModification(const AbstractMetaClass *klass, const QString &signature, -- cgit v1.2.3