diff options
Diffstat (limited to 'sources/pyside6/PySide6/templates/core_common.xml')
-rw-r--r-- | sources/pyside6/PySide6/templates/core_common.xml | 206 |
1 files changed, 40 insertions, 166 deletions
diff --git a/sources/pyside6/PySide6/templates/core_common.xml b/sources/pyside6/PySide6/templates/core_common.xml index e8fbb083b..07bafc6ff 100644 --- a/sources/pyside6/PySide6/templates/core_common.xml +++ b/sources/pyside6/PySide6/templates/core_common.xml @@ -1,43 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt for Python. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only --> <typesystem> @@ -114,35 +78,52 @@ <insert-template name="tuple_retval_ok"/> </template> + <!-- QInputDialog: these should allow threads --> <template name="fix_arg,arg,arg,arg,arg,arg,arg,bool*,arg"> bool ok_; - %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, %7, &ok_, %9); + %RETURN_TYPE retval_; + Py_BEGIN_ALLOW_THREADS + retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, %7, &ok_, %9); + Py_END_ALLOW_THREADS <insert-template name="tuple_retval_ok"/> </template> <template name="fix_arg,arg,arg,arg,arg,arg,arg,bool*,arg,arg"> bool ok_; - %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, %7, &ok_, %9, %10); + %RETURN_TYPE retval_; + Py_BEGIN_ALLOW_THREADS + retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, %7, &ok_, %9, %10); + Py_END_ALLOW_THREADS <insert-template name="tuple_retval_ok"/> </template> <template name="fix_arg,arg,arg,arg,arg,arg,bool*,arg"> bool ok_; - %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, &ok_, %8); + %RETURN_TYPE retval_; + Py_BEGIN_ALLOW_THREADS + retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, &ok_, %8); + Py_END_ALLOW_THREADS <insert-template name="tuple_retval_ok"/> </template> <template name="fix_arg,arg,arg,arg,arg,bool*,arg"> bool ok_; - %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, &ok_, %7); + %RETURN_TYPE retval_; + Py_BEGIN_ALLOW_THREADS + retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, &ok_, %7); + Py_END_ALLOW_THREADS <insert-template name="tuple_retval_ok"/> </template> <template name="fix_arg,arg,arg,arg,bool*,arg,arg"> bool ok_; - %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, &ok_, %6, %7); + %RETURN_TYPE retval_; + Py_BEGIN_ALLOW_THREADS + retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, &ok_, %6, %7); + Py_END_ALLOW_THREADS <insert-template name="tuple_retval_ok"/> </template> + <!-- End of QInputDialog templates --> <template name="fix_char*"> char val_{}; @@ -176,10 +157,10 @@ PyObject* _obj = %PYARG_0.object(); if (!PySequence_Check(_obj) || PySequence_Fast_GET_SIZE(_obj) != 4 - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 0)) - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 1)) - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 2)) - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 3))) { + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 0)) + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 1)) + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 2)) + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 3))) { PyErr_SetString(PyExc_TypeError, "Sequence of 4 numbers expected"); } else { *%1 = %CONVERTTOCPP[$TYPE](PySequence_Fast_GET_ITEM(_obj, 0)); @@ -232,6 +213,18 @@ %PYARG_0 = Shiboken::String::fromCString(qPrintable(format)); </template> + <template name="repr_qdebug"> + QString result; + QDebug(&result).nospace() << "<PySide6.MODULE." << %CPPSELF << '>'; + %PYARG_0 = Shiboken::String::fromCString(qPrintable(result)); + </template> + + <template name="repr_qdebug_gui"> + <insert-template name="repr_qdebug"> + <replace from="MODULE" to="QtGui"/> + </insert-template> + </template> + <template name="return_internal_pointer"> %PYARG_0 = reinterpret_cast<PyObject*>(%CPPSELF.%FUNCTION_NAME()); if (!%PYARG_0) @@ -284,38 +277,6 @@ %PYARG_0 = Py_BuildValue("%TT_FORMAT", %TT_ARGS); </template> - <template name="cpplist_to_pylist_conversion"> - PyObject *%out = PyList_New(Py_ssize_t(%in.size())); - Py_ssize_t idx = 0; - for (auto it = %in.cbegin(), end = %in.cend(); it != end; ++it, ++idx) { - const auto &cppItem = *it; - PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem)); - } - return %out; - </template> - - <template name="pyseq_to_cpplist_conversion"> - // PYSIDE-795: Turn all sequences into iterables. - if (PyList_Check(%in)) { - const Py_ssize_t size = PySequence_Size(%in); - if (size > 10) - (%out).reserve(size); - } - - Shiboken::AutoDecRef it(PyObject_GetIter(%in)); - PyObject *(*iternext)(PyObject *) = *Py_TYPE(it)->tp_iternext; - for (;;) { - Shiboken::AutoDecRef pyItem(iternext(it)); - if (pyItem.isNull()) { - if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) - PyErr_Clear(); - break; - } - %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem); - %out << cppItem; - } - </template> - <template name="checkPyCapsuleOrPyCObject_func"> static bool checkPyCapsuleOrPyCObject(PyObject* pyObj) { @@ -323,91 +284,4 @@ } </template> - <template name="cppmap_to_pymap_conversion"> - PyObject *%out = PyDict_New(); - for (auto it = %in.cbegin(), end = %in.cend(); it != end; ++it) { - const auto &key = it.key(); - const auto &value = it.value(); - PyObject *pyKey = %CONVERTTOPYTHON[%INTYPE_0](key); - PyObject *pyValue = %CONVERTTOPYTHON[%INTYPE_1](value); - PyDict_SetItem(%out, pyKey, pyValue); - Py_DECREF(pyKey); - Py_DECREF(pyValue); - } - return %out; - </template> - - <template name="pydict_to_cppmap_conversion"> - PyObject *key; - PyObject *value; - Py_ssize_t pos = 0; - while (PyDict_Next(%in, &pos, &key, &value)) { - %OUTTYPE_0 cppKey = %CONVERTTOCPP[%OUTTYPE_0](key); - %OUTTYPE_1 cppValue = %CONVERTTOCPP[%OUTTYPE_1](value); - %out.insert(cppKey, cppValue); - } - </template> - - <template name="cppmultimap_to_pymap_conversion"> - PyObject *%out = PyDict_New(); - for (auto it = %in.cbegin(), end = %in.cend(); it != end; ) { - const auto &key = it.key(); - PyObject *pyKey = %CONVERTTOPYTHON[%INTYPE_0](key); - %INTYPE::const_iterator keyEnd = %in.upperBound(key); - const auto count = Py_ssize_t(std::distance(it, keyEnd)); - PyObject *pyValues = PyList_New(count); - Py_ssize_t idx = 0; - for ( ; it != keyEnd; ++it, ++idx) { - const auto &cppItem = it.value(); - PyList_SET_ITEM(pyValues, idx, %CONVERTTOPYTHON[%INTYPE_1](cppItem)); - } - PyDict_SetItem(%out, pyKey, pyValues); - Py_DECREF(pyKey); - } - return %out; - </template> - - <template name="cppmultihash_to_pymap_conversion"> - PyObject *%out = PyDict_New(); - for (auto kit = %in.keyBegin(), end = %in.keyEnd(); kit != end; ++kit) { - const auto &key = *kit; - PyObject *pyKey = %CONVERTTOPYTHON[%INTYPE_0](key); - auto range = %in.equal_range(key); - const auto count = Py_ssize_t(std::distance(range.first, range.second)); - PyObject *pyValues = PyList_New(count); - Py_ssize_t idx = 0; - for (auto it = range.first; it != range.second; ++it, ++idx) { - const auto &cppItem = it.value(); - PyList_SET_ITEM(pyValues, idx, %CONVERTTOPYTHON[%INTYPE_1](cppItem)); - } - PyDict_SetItem(%out, pyKey, pyValues); - Py_DECREF(pyKey); - } - return %out; - </template> - - <template name="pydict_to_cppmultimap_conversion"> - PyObject *key; - PyObject *values; - Py_ssize_t pos = 0; - while (PyDict_Next(%in, &pos, &key, &values)) { - %OUTTYPE_0 cppKey = %CONVERTTOCPP[%OUTTYPE_0](key); - const Py_ssize_t size = PySequence_Size(values); - for (Py_ssize_t i = 0; i < size; ++i) { - Shiboken::AutoDecRef value(PySequence_GetItem(values, i)); - %OUTTYPE_1 cppValue = %CONVERTTOCPP[%OUTTYPE_1](value); - %out.insert(cppKey, cppValue); - } - } - </template> - - <template name="pydatetime_importandcheck_function"> - static bool PyDateTime_ImportAndCheck(PyObject *pyIn) - { - if (!PyDateTimeAPI) - PyDateTime_IMPORT; - return $DATETIMETYPE_Check(pyIn); - } - </template> - </typesystem> |