diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-09-29 08:51:58 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-09-30 13:08:46 +0200 |
commit | 433fbf103e96ba62eedcd563d5a8c71f4e5cd5a0 (patch) | |
tree | daacbd3c29207cd8e69c3fc72644af4e810ac3bd | |
parent | ff792fd2e6842b990aff61a4e953dab5efbd89ae (diff) |
shiboken2: Refactor global enum handling in HeaderGenerator
Generate the sbk-index values for enums in
writeTypeIndexValueLines(AbstractMetaClass *) for invisible
namespaces as well instead of adding them to the global
enum list. Remove checks for private/protected on global enums
as they originate from namespaces.
This removes one usage of
ShibokenGenerator::lookForFunctionsInClassesNotToBeGenerated()
which will be removed in a consecutive change.
Task-number: PYSIDE-1075
Change-Id: I9ee7aba20802e9794f371006f9fdbd7ab8d67cab
Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r-- | sources/shiboken2/generator/shiboken2/headergenerator.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp index e46f484fc..2d1b41443 100644 --- a/sources/shiboken2/generator/shiboken2/headergenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp @@ -340,14 +340,15 @@ void HeaderGenerator::writeTypeIndexValueLine(QTextStream &s, const TypeEntry *t void HeaderGenerator::writeTypeIndexValueLines(QTextStream &s, const AbstractMetaClass *metaClass) { auto typeEntry = metaClass->typeEntry(); - if (!typeEntry->generateCode() || !NamespaceTypeEntry::isVisibleScope(typeEntry)) + if (!typeEntry->generateCode()) return; - writeTypeIndexValueLine(s, metaClass->typeEntry()); + // enum indices are required for invisible namespaces as well. for (const AbstractMetaEnum *metaEnum : metaClass->enums()) { - if (metaEnum->isPrivate()) - continue; - writeTypeIndexValueLine(s, metaEnum->typeEntry()); + if (!metaEnum->isPrivate()) + writeTypeIndexValueLine(s, metaEnum->typeEntry()); } + if (NamespaceTypeEntry::isVisibleScope(typeEntry)) + writeTypeIndexValueLine(s, metaClass->typeEntry()); } // Format the typedefs for the typedef entries to be generated @@ -399,19 +400,16 @@ bool HeaderGenerator::finishGeneration() Indentation indent(INDENT); macrosStream << "// Type indices\nenum : int {\n"; - AbstractMetaEnumList globalEnums = this->globalEnums(); AbstractMetaClassList classList = classes(); std::sort(classList.begin(), classList.end(), [](AbstractMetaClass *a, AbstractMetaClass *b) { return a->typeEntry()->sbkIndex() < b->typeEntry()->sbkIndex(); }); - for (const AbstractMetaClass *metaClass : classList) { + for (const AbstractMetaClass *metaClass : classList) writeTypeIndexValueLines(macrosStream, metaClass); - lookForEnumsInClassesNotToBeGenerated(globalEnums, metaClass); - } - for (const AbstractMetaEnum *metaEnum : qAsConst(globalEnums)) + for (const AbstractMetaEnum *metaEnum : globalEnums()) writeTypeIndexValueLine(macrosStream, metaEnum->typeEntry()); // Write the smart pointer define indexes. @@ -486,12 +484,11 @@ bool HeaderGenerator::finishGeneration() typeFunctions << "QT_WARNING_PUSH\n"; typeFunctions << "QT_WARNING_DISABLE_DEPRECATED\n"; } - for (const AbstractMetaEnum *cppEnum : qAsConst(globalEnums)) { - if (cppEnum->isAnonymous() || cppEnum->isPrivate()) - continue; - includes << cppEnum->typeEntry()->include(); - writeProtectedEnumSurrogate(protEnumsSurrogates, cppEnum); - writeSbkTypeFunction(typeFunctions, cppEnum); + for (const AbstractMetaEnum *cppEnum : globalEnums()) { + if (!cppEnum->isAnonymous()) { + includes << cppEnum->typeEntry()->include(); + writeSbkTypeFunction(typeFunctions, cppEnum); + } } for (AbstractMetaClass *metaClass : classList) { |