pysideutils.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright (C) 2021 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. #ifndef PYSIDEUTILS_H
  4. #define PYSIDEUTILS_H
  5. #include <sbkpython.h>
  6. #include <pysidemacros.h>
  7. #include <QtCore/qtclasshelpermacros.h>
  8. QT_FORWARD_DECLARE_CLASS(QDebug)
  9. QT_FORWARD_DECLARE_CLASS(QString)
  10. QT_FORWARD_DECLARE_CLASS(QStringView)
  11. namespace PySide
  12. {
  13. /// Check if self inherits from class_name
  14. /// \param self Python object
  15. /// \param class_name strict with the class name
  16. /// \return Returns true if self object inherits from class_name, otherwise returns false
  17. PYSIDE_API bool inherits(PyTypeObject *self, const char *class_name);
  18. /// Given A PyObject representing Unicode data, returns an equivalent QString.
  19. PYSIDE_API QString pyUnicodeToQString(PyObject *str);
  20. /// Given a QString, return the PyObject repeesenting Unicode data.
  21. PYSIDE_API PyObject *qStringToPyUnicode(QStringView s);
  22. /// Given A PyObject representing ASCII or Unicode data, returns an equivalent QString.
  23. PYSIDE_API QString pyStringToQString(PyObject *str);
  24. /// Provide an efficient, correct PathLike interface.
  25. PYSIDE_API QString pyPathToQString(PyObject *path);
  26. /// Returns whether \a method is a compiled method (Nuitka).
  27. /// \sa Shiboken::isCompiledMethod()
  28. PYSIDE_API bool isCompiledMethod(PyObject *callback);
  29. struct debugPyTypeObject
  30. {
  31. PYSIDE_API explicit debugPyTypeObject(PyTypeObject *o) noexcept;
  32. PyTypeObject *m_object;
  33. };
  34. PYSIDE_API QDebug operator<<(QDebug debug, const debugPyTypeObject &o);
  35. struct debugPyObject
  36. {
  37. PYSIDE_API explicit debugPyObject(PyObject *o) noexcept;
  38. PyObject *m_object;
  39. };
  40. PYSIDE_API QDebug operator<<(QDebug debug, const debugPyObject &o);
  41. #if !defined(Py_LIMITED_API) || Py_LIMITED_API >= 0x030B0000
  42. struct debugPyBuffer
  43. {
  44. PYSIDE_API explicit debugPyBuffer(Py_buffer *b) noexcept;
  45. Py_buffer *m_buffer;
  46. };
  47. PYSIDE_API QDebug operator<<(QDebug debug, const debugPyBuffer &b);
  48. #endif // !Py_LIMITED_API || >= 3.11
  49. } //namespace PySide
  50. #endif // PYSIDESTRING_H