diff options
Diffstat (limited to 'sources/shiboken6/libshiboken/helper.h')
-rw-r--r-- | sources/shiboken6/libshiboken/helper.h | 70 |
1 files changed, 29 insertions, 41 deletions
diff --git a/sources/shiboken6/libshiboken/helper.h b/sources/shiboken6/libshiboken/helper.h index 8221d68b0..f226e8c24 100644 --- a/sources/shiboken6/libshiboken/helper.h +++ b/sources/shiboken6/libshiboken/helper.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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) 2016 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 #ifndef HELPER_H #define HELPER_H @@ -72,6 +36,10 @@ LIBSHIBOKEN_API bool listToArgcArgv(PyObject *argList, int *argc, char ***argv, */ LIBSHIBOKEN_API int *sequenceToIntArray(PyObject *obj, bool zeroTerminated = false); +/// Fix a type name returned by typeid(t).name(), depending on compiler. +/// \returns Fixed name (allocated). +LIBSHIBOKEN_API const char *typeNameOf(const char *typeIdName); + /** * Creates and automatically deallocates C++ arrays. */ @@ -84,8 +52,9 @@ class AutoArrayPointer AutoArrayPointer &operator=(const AutoArrayPointer &) = delete; AutoArrayPointer &operator=(AutoArrayPointer &&) = delete; - explicit AutoArrayPointer(ssize_t size) { data = new T[size]; } - T &operator[](ssize_t pos) { return data[pos]; } + + explicit AutoArrayPointer(Py_ssize_t size) { data = new T[size]; } + T &operator[](Py_ssize_t pos) { return data[pos]; } operator T *() const { return data; } ~AutoArrayPointer() { delete[] data; } private: @@ -96,6 +65,8 @@ using ThreadId = unsigned long long; LIBSHIBOKEN_API ThreadId currentThreadId(); LIBSHIBOKEN_API ThreadId mainThreadId(); +LIBSHIBOKEN_API int pyVerbose(); + /** * An utility function used to call PyErr_WarnEx with a formatted message. */ @@ -108,6 +79,13 @@ struct LIBSHIBOKEN_API debugPyObject PyObject *m_object; }; +struct LIBSHIBOKEN_API debugSbkObject +{ + explicit debugSbkObject(SbkObject *o); + + SbkObject *m_object; +}; + struct LIBSHIBOKEN_API debugPyTypeObject { explicit debugPyTypeObject(const PyTypeObject *o); @@ -122,10 +100,20 @@ struct LIBSHIBOKEN_API debugPyBuffer const Py_buffer &m_buffer; }; +struct debugPyArrayObject +{ + explicit debugPyArrayObject(PyObject *object) : m_object(object) {} + + PyObject *m_object; +}; + LIBSHIBOKEN_API std::ostream &operator<<(std::ostream &str, const debugPyObject &o); +LIBSHIBOKEN_API std::ostream &operator<<(std::ostream &str, const debugSbkObject &o); LIBSHIBOKEN_API std::ostream &operator<<(std::ostream &str, const debugPyTypeObject &o); LIBSHIBOKEN_API std::ostream &operator<<(std::ostream &str, const debugPyBuffer &b); - +LIBSHIBOKEN_API std::ostream &operator<<(std::ostream &str, const debugPyArrayObject &b); +LIBSHIBOKEN_API std::ios_base &debugVerbose(std::ios_base &s); +LIBSHIBOKEN_API std::ios_base &debugBrief(std::ios_base &s); } // namespace Shiboken |