From 9f7532987dfcebb195fc46a9349975e00ab4ea62 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 11 Sep 2018 09:45:24 +0200 Subject: 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(0). Task-number: PYSIDE-62 Change-Id: I42cb2ca63fb1da6c795df630ab30bded66aac901 Reviewed-by: Christian Tismer --- sources/shiboken2/generator/generator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sources/shiboken2/generator') 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(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)"); -- cgit v1.2.3