diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-04-05 08:22:07 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-04-09 17:36:41 +0200 |
commit | 80fac314f15b202b20ff439c278500c35c44e0ae (patch) | |
tree | 460eb51f5807b2e0f4ed7047c9e218cce2071ab5 /sources/shiboken6/generator | |
parent | 83c4d9564067eae3f6eb59acc1a34c1b2a11faec (diff) |
shiboken6: Split out the part writing a Python override
Pick-to: 6.7
Task-number: PYSIDE-2602
Change-Id: Id810e37a29b246339acc97a09f890d82e2c0d4f6
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/generator')
-rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 11 | ||||
-rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.h | 4 |
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, |