Skip to content

Commit aaeb5e7

Browse files
committed
Do not prepend enum class name for items of enum classes,
rather re-create enum class as a enum class, and later handle enum classes in PythonQt itself.
1 parent 788f758 commit aaeb5e7

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

generator/shellheadergenerator.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c
308308
}
309309

310310
for (AbstractMetaEnum * enum1 : enums) {
311-
s << "enum " << enum1->name() << "{" << endl;
311+
bool isEnumClass = enum1->typeEntry()->isEnumClass();
312+
s << "enum " << (isEnumClass ? "class " : "") << enum1->name() << "{" << endl;
312313
bool first = true;
313314
QString scope = enum1->wasProtected() ? promoterClassName(meta_class) : meta_class->qualifiedCppName();
314-
bool isEnumClass = enum1->typeEntry()->isEnumClass();
315315
if (isEnumClass) {
316316
scope += "::" + enum1->name();
317317
}
@@ -321,12 +321,7 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c
321321
else { s << ", "; }
322322
QString assignedValue = scope + "::" + value->name();
323323
if (isEnumClass) {
324-
// prepend value name with class name, the value name on itself could be a duplicate
325-
//
326-
// I thought about creating a enum class instead, and creating an Enum class in PythonQt for the wrapper
327-
// (QMetaEnum has a isScoped method to check for enum classes),
328-
// but the process seemed quite complicated.
329-
s << " " << enum1->name() << "_" << value->name() << " = " << "static_cast<int>(" << scope << "::" << value->name() << ")";
324+
s << " " << value->name() << " = " << "static_cast<int>(" << scope << "::" << value->name() << ")";
330325
}
331326
else {
332327
s << " " << value->name() << " = " << scope << "::" << value->name();

0 commit comments

Comments
 (0)