diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-27 10:03:57 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-28 11:23:55 +0000 |
commit | 45d998ea98e0487102fcb73d4e6c6651cd78cbd2 (patch) | |
tree | 0084f89a12c0a1a01cfe2a5c3ea228439108f8f0 | |
parent | de70d32b36622d14dea980cd70ed646200a2f8d8 (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
Change-Id: I06520f4747d02f2b3e86f90c09220d82e91f95ff
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit 418f43f7011281bd2d78f2aa43bb6b3cc666220d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
4 files changed, 23 insertions, 14 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index 8e5b3811b..abb8f8794 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -48,6 +48,10 @@ <!-- <function signature="qChecksum(QByteArrayView data, Qt::ChecksumType)"/> --> + <extra-includes> + <include file-name="signalmanager.h" location="global"/> + </extra-includes> + <function signature="qFastCos(qreal)" since="4.6"/> <function signature="qFastSin(qreal)" since="4.6"/> <function signature="qFuzzyCompare(double,double)"/> @@ -178,10 +182,7 @@ <primitive-type name="signed long int"/> <primitive-type name="long"/> <primitive-type name="unsigned long int"/> - <primitive-type name="unsigned long"> - <!-- FIXME APIExtractor or shiboken do not support multiple includes by primitive type --> - <include file-name="signalmanager.h" location="global"/> - </primitive-type> + <primitive-type name="unsigned long"/> <primitive-type name="int8_t"/> <primitive-type name="uint8_t"/> <primitive-type name="int16_t"/> diff --git a/sources/shiboken6/doc/typesystem_solving_compilation.rst b/sources/shiboken6/doc/typesystem_solving_compilation.rst index cca511d5b..4b8a05447 100644 --- a/sources/shiboken6/doc/typesystem_solving_compilation.rst +++ b/sources/shiboken6/doc/typesystem_solving_compilation.rst @@ -26,8 +26,8 @@ extra-includes ^^^^^^^^^^^^^^ The ``extra-includes`` node contains declarations of additional include files, - and it can be a child of the :ref:`namespace`, :ref:`value-type` and - :ref:`object-type` nodes. + and it can be a child of the :ref:`namespace`, :ref:`value-type`, + :ref:`object-type` and :ref:`typesystem` and nodes. The generator automatically tries to read the global header for each type but sometimes it is required to include extra files in the generated C++ code to @@ -48,6 +48,10 @@ extra-includes *local* means that the file is in a local directory and will be included using #include "...". + When specified as a child of the :ref:`typesystem` node, the include + directives are added to the module source file which contains + the type converter and registration code. It can be used to specify + additional includes required for the converter code snippets. include ^^^^^^^ diff --git a/sources/shiboken6/doc/typesystem_specifying_types.rst b/sources/shiboken6/doc/typesystem_specifying_types.rst index 5fe88d167..a78226141 100644 --- a/sources/shiboken6/doc/typesystem_specifying_types.rst +++ b/sources/shiboken6/doc/typesystem_specifying_types.rst @@ -32,7 +32,7 @@ typesystem This is the root node containing all the type system information. It may contain :ref:`add-function`, :ref:`container-type`, - :ref:`custom-type`, :ref:`enum-type`, :ref:`function`, + :ref:`custom-type`, :ref:`enum-type`, :ref:`extra-includes`, :ref:`function`, :ref:`load-typesystem`, :ref:`namespace`, :ref:`object-type`, :ref:`primitive-type`, :ref:`rejection`, :ref:`smart-pointer-type`, :ref:`suppress-warning`, :ref:`template`, :ref:`system_include`, 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" |