diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-27 10:03:57 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-28 08:58:48 +0000 |
commit | 418f43f7011281bd2d78f2aa43bb6b3cc666220d (patch) | |
tree | dc245e14ed811944f7740c642962a875ef18b2d1 /sources/shiboken6/generator/shiboken/cppgenerator.cpp | |
parent | 6abe3188a1aeb5eaff79a77b7eb39abc99b3aab8 (diff) |
Properly specify extra include for Qt core module source file
Replace the hack adding the include to a primitive by an extra-include
element. This is actually implemented in code, but not documented.
As a drive-by fix the code to only write the comment when includes
are present.
Adapt the documentation accordingly.
Task-number: PYSIDE-1660
Pick-to: 6.2
Change-Id: I06520f4747d02f2b3e86f90c09220d82e91f95ff
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/generator/shiboken/cppgenerator.cpp')
-rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 0b9ad6636..c7fa2126a 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -6185,16 +6185,20 @@ bool CppGenerator::finishGeneration() const TypeSystemTypeEntry *moduleEntry = typeDb->defaultTypeSystemType(); Q_ASSERT(moduleEntry); - //Extra includes - s << '\n' << "// Extra includes\n"; + s << '\n'; + // Extra includes QList<Include> extraIncludes = moduleEntry->extraIncludes(); for (const AbstractMetaEnum &cppEnum : qAsConst(globalEnums)) extraIncludes.append(cppEnum.typeEntry()->extraIncludes()); - std::sort(extraIncludes.begin(), extraIncludes.end()); - for (const Include &inc : qAsConst(extraIncludes)) - s << inc; - s << '\n' - << "// Current module's type array.\n" + if (!extraIncludes.isEmpty()) { + s << "// Extra includes\n"; + std::sort(extraIncludes.begin(), extraIncludes.end()); + for (const Include &inc : qAsConst(extraIncludes)) + s << inc; + s << '\n'; + } + + s << "// Current module's type array.\n" << "PyTypeObject **" << cppApiVariableName() << " = nullptr;\n" << "// Current module's PyObject pointer.\n" << "PyObject *" << pythonModuleObjectName() << " = nullptr;\n" |