diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-12-15 15:21:42 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-12-16 15:05:20 +0100 |
commit | 68db559785269770ca2e4ea4f10361fcea2829d8 (patch) | |
tree | 82806956bbcc2705f3dd02b356924db00fe839f7 | |
parent | d28159d435f91df438c10312c25a5ccffc946f50 (diff) |
PySide6: Expand template PyDateTime_ImportAndCheck
The duplicated static functions cause clashes in
CMake UNITY_BUILD (jumbo) builds.
Task-number: PYSIDE-2155
Change-Id: I01c07d37a0fa1fb228ca26457ad6a5e5bbaaaba9
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
4 files changed, 37 insertions, 27 deletions
diff --git a/sources/pyside6/PySide6/QtCore/glue/core_snippets.cpp b/sources/pyside6/PySide6/QtCore/glue/core_snippets.cpp index 4978387ff..13b9535fd 100644 --- a/sources/pyside6/PySide6/QtCore/glue/core_snippets.cpp +++ b/sources/pyside6/PySide6/QtCore/glue/core_snippets.cpp @@ -5,6 +5,9 @@ #include "pysideqobject.h" #include "shiboken.h" +#ifndef Py_LIMITED_API +# include <datetime.h> +#endif #include "basewrapper.h" #include "autodecref.h" @@ -237,3 +240,24 @@ QString qObjectTr(PyTypeObject *type, const char *sourceText, const char *disamb } return result; } + +bool PyDate_ImportAndCheck(PyObject *pyIn) +{ + if (!PyDateTimeAPI) + PyDateTime_IMPORT; + return PyDate_Check(pyIn); +} + +bool PyDateTime_ImportAndCheck(PyObject *pyIn) +{ + if (!PyDateTimeAPI) + PyDateTime_IMPORT; + return PyDateTime_Check(pyIn); +} + +bool PyTime_ImportAndCheck(PyObject *pyIn) +{ + if (!PyDateTimeAPI) + PyDateTime_IMPORT; + return PyTime_Check(pyIn); +} diff --git a/sources/pyside6/PySide6/QtCore/glue/core_snippets_p.h b/sources/pyside6/PySide6/QtCore/glue/core_snippets_p.h index 9a0a8c0ab..9beddf376 100644 --- a/sources/pyside6/PySide6/QtCore/glue/core_snippets_p.h +++ b/sources/pyside6/PySide6/QtCore/glue/core_snippets_p.h @@ -48,4 +48,8 @@ void qObjectFindChildren(const QObject *parent, const QRegularExpression &patter // Helpers for translation QString qObjectTr(PyTypeObject *type, const char *sourceText, const char *disambiguation, int n); +bool PyDate_ImportAndCheck(PyObject *pyIn); +bool PyDateTime_ImportAndCheck(PyObject *pyIn); +bool PyTime_ImportAndCheck(PyObject *pyIn); + #endif // CORE_SNIPPETS_P_H diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index d8e731076..bdad20892 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -792,16 +792,13 @@ <value-type name="QDate" hash-function="PySide::hash" > <extra-includes> <include file-name="pysideqhash.h" location="global"/> + <include file-name="glue/core_snippets_p.h" location="local"/> </extra-includes> - <inject-code class="native" position="beginning"> - <insert-template name="pydatetime_importandcheck_function"> - <replace from="$DATETIMETYPE" to="PyDate"/> - </insert-template> - </inject-code> <conversion-rule> <target-to-native> <add-conversion type="Py_None" file="../glue/qtcore.cpp" snippet="conversion-pynone"/> - <add-conversion type="PyDate" check="PyDateTime_ImportAndCheck(%in)" file="../glue/qtcore.cpp" snippet="conversion-qdate-pydate"/> + <add-conversion type="PyDate" check="PyDate_ImportAndCheck(%in)" + file="../glue/qtcore.cpp" snippet="conversion-qdate-pydate"/> </target-to-native> </conversion-rule> <extra-includes> @@ -855,17 +852,14 @@ <value-type name="QDateTime" hash-function="PySide::hash"> <extra-includes> <include file-name="pysideqhash.h" location="global"/> + <include file-name="glue/core_snippets_p.h" location="local"/> </extra-includes> <enum-type name="YearRange"/> - <inject-code class="native" position="beginning"> - <insert-template name="pydatetime_importandcheck_function"> - <replace from="$DATETIMETYPE" to="PyDateTime"/> - </insert-template> - </inject-code> <conversion-rule> <target-to-native> <add-conversion type="Py_None" file="../glue/qtcore.cpp" snippet="conversion-pynone"/> - <add-conversion type="PyDateTime" check="PyDateTime_ImportAndCheck(%in)" file="../glue/qtcore.cpp" snippet="conversion-qdatetime-pydatetime"/> + <add-conversion type="PyDateTime" check="PyDateTime_ImportAndCheck(%in)" + file="../glue/qtcore.cpp" snippet="conversion-qdatetime-pydatetime"/> </target-to-native> </conversion-rule> <extra-includes> @@ -1217,16 +1211,13 @@ <value-type name="QTime" hash-function="PySide::hash"> <extra-includes> <include file-name="pysideqhash.h" location="global"/> + <include file-name="glue/core_snippets_p.h" location="local"/> </extra-includes> - <inject-code class="native" position="beginning"> - <insert-template name="pydatetime_importandcheck_function"> - <replace from="$DATETIMETYPE" to="PyTime"/> - </insert-template> - </inject-code> <conversion-rule> <target-to-native> <add-conversion type="Py_None" file="../glue/qtcore.cpp" snippet="conversion-pynone"/> - <add-conversion type="PyTime" check="PyDateTime_ImportAndCheck(%in)" file="../glue/qtcore.cpp" snippet="conversion-qtime-pytime"/> + <add-conversion type="PyTime" check="PyTime_ImportAndCheck(%in)" + file="../glue/qtcore.cpp" snippet="conversion-qtime-pytime"/> </target-to-native> </conversion-rule> diff --git a/sources/pyside6/PySide6/templates/core_common.xml b/sources/pyside6/PySide6/templates/core_common.xml index 525e72643..07bafc6ff 100644 --- a/sources/pyside6/PySide6/templates/core_common.xml +++ b/sources/pyside6/PySide6/templates/core_common.xml @@ -284,13 +284,4 @@ } </template> - <template name="pydatetime_importandcheck_function"> - static bool PyDateTime_ImportAndCheck(PyObject *pyIn) - { - if (!PyDateTimeAPI) - PyDateTime_IMPORT; - return $DATETIMETYPE_Check(pyIn); - } - </template> - </typesystem> |