aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-10-01 12:39:19 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-10-02 14:02:19 +0200
commitc512b506b565578770c671b11afb78427ca8d012 (patch)
tree77cff853888db902219029ad777553514e2312e4 /sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
parentbc85c54dadc02bd618f085c1fc55b7ba9d33c4c8 (diff)
shiboken6: Handle QT6_DECL_NEW_OVERLOAD_TAIL within shiboken6
Strip parameters of type Qt::Disambiguated_t similar to QPrivateSignal (see qtbase/0a3ff697380555538a0d035b768ddf10f772b55a). As this becomes more and more common, it saves the work of declaring those functions. Change-Id: I973b47ddcfa3ac40795885da0f4001a95ad108fd Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp46
1 files changed, 39 insertions, 7 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
index f07fb96c6..0b11f2fb4 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
@@ -1975,6 +1975,29 @@ void AbstractMetaBuilderPrivate::rejectFunction(const FunctionModelItem &functio
m_rejectedFunctions.insert({reason, signatureWithType, sortKey, rejectReason});
}
+// Check for special Qt argument types which should be ignored.
+enum class QtSpecialArgument
+{
+ None,
+ PrivateSignal,
+ Disambiguated // by QT6_DECL_NEW_OVERLOAD_TAIL
+};
+
+static QtSpecialArgument qtSpecialArgument(CodeModel::FunctionType functionType,
+ const ArgumentList &arguments)
+{
+ if (arguments.isEmpty())
+ return QtSpecialArgument::None;
+ const QStringList &lastArgumentType = arguments.constLast()->type().qualifiedName();
+ if (functionType == CodeModel::Signal && lastArgumentType.constLast() == "QPrivateSignal"_L1)
+ return QtSpecialArgument::PrivateSignal;
+ if (lastArgumentType.size() == 2 && lastArgumentType.constFirst() == "Qt"_L1
+ && lastArgumentType.constLast() == "Disambiguated_t"_L1) {
+ return QtSpecialArgument::Disambiguated;
+ }
+ return QtSpecialArgument::None;
+}
+
AbstractMetaFunctionPtr
AbstractMetaBuilderPrivate::traverseFunction(const FunctionModelItem &functionItem,
const AbstractMetaClassPtr &currentClass)
@@ -2107,13 +2130,22 @@ AbstractMetaFunctionPtr
}
ArgumentList arguments = functionItem->arguments();
- // Add private signals for documentation purposes
- if (!arguments.isEmpty()
- && m_apiExtractorFlags.testFlag(ApiExtractorFlag::UsePySideExtensions)
- && functionItem->functionType() == CodeModel::Signal
- && arguments.constLast()->type().qualifiedName().constLast() == u"QPrivateSignal") {
- flags.setFlag(AbstractMetaFunction::Flag::PrivateSignal);
- arguments.removeLast();
+ if (m_apiExtractorFlags.testFlag(ApiExtractorFlag::UsePySideExtensions)) {
+ switch (qtSpecialArgument(functionItem->functionType(), arguments)) {
+ case QtSpecialArgument::None:
+ break;
+ case QtSpecialArgument::PrivateSignal:
+ flags.setFlag(AbstractMetaFunction::Flag::PrivateSignal);
+ arguments.removeLast(); // Add private signals for documentation purposes
+ break;
+ case QtSpecialArgument::Disambiguated: {
+ const QString signature = qualifiedFunctionSignatureWithType(functionItem, className);
+ qCWarning(lcShiboken, "%s",
+ qPrintable(msgStrippingQtDisambiguatedArgument(functionItem, signature)));
+ arguments.removeLast(); // Strip QT6_DECL_NEW_OVERLOAD_TAIL
+ }
+ break;
+ }
}
if (arguments.size() == 1) {