aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-04-05 08:22:07 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-04-09 17:41:20 +0000
commit3eb00f3808793b32595e931f85d541393c55c2f8 (patch)
tree5b00c7047ee77a49ea9ecfb8056de76fc87f8784
parent95bc24faa583f69ead0d46b036faadc1f9eaf0dc (diff)
shiboken6: Split out the part writing a Python override
Task-number: PYSIDE-2602 Change-Id: Id810e37a29b246339acc97a09f890d82e2c0d4f6 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> (cherry picked from commit 80fac314f15b202b20ff439c278500c35c44e0ae) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp11
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.h4
2 files changed, 14 insertions, 1 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index d8089ab0a..46f83436e 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -1201,6 +1201,14 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s,
returnStatement, true);
s << outdent << "}\n\n"; //WS
+ writeVirtualMethodPythonOverride(s, func, snips, returnStatement);
+}
+
+void CppGenerator::writeVirtualMethodPythonOverride(TextStream &s,
+ const AbstractMetaFunctionCPtr &func,
+ const CodeSnipList &snips,
+ const QString &returnStatement) const
+{
writeConversionRule(s, func, TypeSystem::TargetLangCode, false);
bool invalidateReturn = false;
@@ -1223,7 +1231,7 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s,
auto arguments = func->arguments();
auto removedEnd = std::stable_partition(arguments.begin(), arguments.end(),
isArgumentNotRemoved);
- if (isAbstract) { // Base function is not called, indicate unused arguments.
+ if (func->isAbstract()) { // Base function is not called, indicate unused arguments.
for (auto it = removedEnd; it != arguments.end(); ++it)
s << sbkUnusedVariableCast(it->name());
}
@@ -1381,6 +1389,7 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s,
if (!func->isVoid()) {
s << "return ";
+ TypeEntryCPtr retType = func->type().typeEntry();
if (avoidProtectedHack() && retType->isEnum()) {
auto metaEnum = api().findAbstractMetaEnum(retType);
bool isProtectedEnum = metaEnum.has_value() && metaEnum->isProtected();
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.h b/sources/shiboken6/generator/shiboken/cppgenerator.h
index 2c35b6f1d..f69a57249 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.h
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.h
@@ -76,6 +76,10 @@ private:
void writeVirtualMethodNative(TextStream &s,
const AbstractMetaFunctionCPtr &func,
int cacheIndex) const;
+ void writeVirtualMethodPythonOverride(TextStream &s,
+ const AbstractMetaFunctionCPtr &func,
+ const CodeSnipList &snips,
+ const QString &returnStatement) const;
void writeVirtualMethodCppCall(TextStream &s, const AbstractMetaFunctionCPtr &func,
const QString &funcName, const QList<CodeSnip> &snips,
const AbstractMetaArgument *lastArg, const TypeEntryCPtr &retType,