aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/generator/shiboken/cppgenerator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-12-10 17:49:55 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-12-10 18:05:32 +0000
commit14c4883b7996a8835950d7122079a1bd7f07dda1 (patch)
treed4f3d6da2bbb76403aea2472b0a0fb5248836b27 /sources/shiboken6/generator/shiboken/cppgenerator.cpp
parent0b1fe169232252c506104003a09f0e5c01085909 (diff)
shiboken6: Fix enumeration/flag reference parameters
For functions like QDataStream &operator>>(QDataStream &, [enum] QCborSimpleType &), the QCborSimpleType argument was treated like an object. Add a check to treat it like a value. Pick-to: 6.0 Change-Id: Ic2bb8a806b7fe941d8eab3543f21afa0577dd1a0 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/generator/shiboken/cppgenerator.cpp')
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index e03aa6feb..3debd7609 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -2505,10 +2505,14 @@ void CppGenerator::writePythonToCppTypeConversion(TextStream &s,
QString cppOutAux = cppOut + QLatin1String("_local");
+ const bool isEnum = typeEntry->isEnum();
+ const bool isFlags = typeEntry->isFlags();
bool treatAsPointer = isValueTypeWithCopyConstructorOnly(type);
bool isPointerOrObjectType = (type.isObjectType() || type.isPointer())
- && !type.isUserPrimitive() && !type.isExtendedCppPrimitive();
- bool isNotContainerEnumOrFlags = !typeEntry->isContainer() && !typeEntry->isEnum() && !typeEntry->isFlags();
+ && !type.isUserPrimitive() && !type.isExtendedCppPrimitive()
+ && !isEnum && !isFlags;
+ const bool isNotContainerEnumOrFlags = !typeEntry->isContainer()
+ && !isEnum && !isFlags;
bool mayHaveImplicitConversion = type.referenceType() == LValueReference
&& !type.isUserPrimitive()
&& !type.isExtendedCppPrimitive()
@@ -2528,7 +2532,7 @@ void CppGenerator::writePythonToCppTypeConversion(TextStream &s,
s << typeName << ' ' << cppOutAux;
writeMinimalConstructorExpression(s, type, defaultValue);
s << ";\n";
- } else if (avoidProtectedHack() && type.typeEntry()->isEnum()) {
+ } else if (avoidProtectedHack() && isEnum) {
auto metaEnum = findAbstractMetaEnum(type);
if (metaEnum.has_value() && metaEnum->isProtected()) {
typeName = QLatin1String("long");
@@ -2562,7 +2566,7 @@ void CppGenerator::writePythonToCppTypeConversion(TextStream &s,
s << "0";
else
s << "(long)" << defaultValue;
- } else if (type.isUserPrimitive() || typeEntry->isEnum() || typeEntry->isFlags()) {
+ } else if (type.isUserPrimitive() || isEnum || isFlags) {
writeMinimalConstructorExpression(s, typeEntry, defaultValue);
} else if (!type.isContainer() && !type.isSmartPointer()) {
writeMinimalConstructorExpression(s, type, defaultValue);