aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/generator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-09-11 09:45:24 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-09-12 04:49:50 +0000
commit9f7532987dfcebb195fc46a9349975e00ab4ea62 (patch)
tree38bdcf08eb9ece938b7017d704ecc85839536381 /sources/shiboken2/generator/generator.cpp
parent253553022f1ea1692795a28efe3a62b39b4f6bb9 (diff)
shiboken: Store null enum values
If an enum has a null value, store that on the EnumTypeEntry for use in Generator::minimalConstructor() as a default value. Fully qualify scoped enum value type entries for this purpose. The value can then be used for default values instead of an ugly static_cast<EnumType>(0). Task-number: PYSIDE-62 Change-Id: I42cb2ca63fb1da6c795df630ab30bded66aac901 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/generator/generator.cpp')
-rw-r--r--sources/shiboken2/generator/generator.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp
index 7cf93edc5..9cf26b52f 100644
--- a/sources/shiboken2/generator/generator.cpp
+++ b/sources/shiboken2/generator/generator.cpp
@@ -608,8 +608,12 @@ QString Generator::minimalConstructor(const TypeEntry* type) const
? QLatin1String("false") : name + QLatin1String("(0)");
}
- if (type->isEnum())
+ if (type->isEnum()) {
+ const auto enumEntry = static_cast<const EnumTypeEntry *>(type);
+ if (const auto *nullValue = enumEntry->nullValue())
+ return nullValue->name();
return QLatin1String("static_cast< ::") + type->qualifiedCppName() + QLatin1String(">(0)");
+ }
if (type->isFlags())
return type->qualifiedCppName() + QLatin1String("(0)");