aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/messages.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-09-14 13:52:14 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-10-01 11:24:55 +0200
commit2edf0042bb23fa8528dfb964377dae5bd35ee932 (patch)
treecafc76b224135aef870fe60e3215c18eb3ded1b0 /sources/shiboken6/ApiExtractor/messages.cpp
parent6c62738a9a051c4e06444c6d37c766f7ccc696c8 (diff)
shiboken6: Refactor modified types of functions
Remove AbstractMetaFunction::typeReplaced(), which returned the modified type of an argument or the return type as a string. Instead, for function arguments, for which modified types must always be valid AbstractMetaTypes, add a getter modifiedType() returning an AbstractMetaType to AbstractMetaArgument. This fixes a number of potential bugs when accessing typeReplaced(int) with the wrong position due to removed arguments. The modified argument types are parsed from the XML strings in early on in AbstractMetaClass::fixFunctions() with proper error reporting. For return types, for which modified types need to be valid only when generating a type check for virtual method return in the C++ wrapper, add a function modifiedTypeName() to AbstractMetaFunction. Adapt the client code accordingly. Split apart CppGenerator::writeTypeCheck() into one overload taking an AbstractMetaType and one taking a string. Task-number: PYSIDE-1660 Change-Id: Id95379892b40ae2632ca33ed27263bada0ec015d Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/messages.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/messages.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/sources/shiboken6/ApiExtractor/messages.cpp b/sources/shiboken6/ApiExtractor/messages.cpp
index ff4a9fa42..b7a1e9091 100644
--- a/sources/shiboken6/ApiExtractor/messages.cpp
+++ b/sources/shiboken6/ApiExtractor/messages.cpp
@@ -77,6 +77,33 @@ QString msgNoFunctionForModification(const AbstractMetaClass *klass,
return result;
}
+QString msgTypeModificationFailed(const QString &type, int n,
+ const AbstractMetaFunction *func,
+ const QString &why)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Unable to modify the ";
+ if (n == 0)
+ str << "return type";
+ else
+ str << "type of argument " << n;
+
+ str << " of ";
+ if (auto *c = func->ownerClass())
+ str << c->name() << "::";
+ str << func->signature() << " to \"" << type << "\": " << why;
+ return result;
+}
+
+QString msgArgumentOutOfRange(int number, int minValue, int maxValue)
+{
+ QString result;
+ QTextStream(&result) << "Argument number " << number
+ << " out of range " << minValue << ".." << maxValue << '.';
+ return result;
+}
+
template <class Stream>
static void msgFormatEnumType(Stream &str,
const EnumModelItem &enumItem,