sbkpython.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (C) 2018 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 SBKPYTHON_H
  4. #define SBKPYTHON_H
  5. // PYSIDE-2701: This definition is needed for all Python formats with "#".
  6. #define PY_SSIZE_T_CLEAN
  7. // Qt's "slots" macro collides with the "slots" member variables
  8. // used in some Python structs. For compilers that support push_macro,
  9. // temporarily undefine it.
  10. #if defined(slots) && (defined(__GNUC__) || defined(_MSC_VER) || defined(__clang__))
  11. # pragma push_macro("slots")
  12. # undef slots
  13. extern "C" {
  14. # include <Python.h>
  15. }
  16. # include <structmember.h>
  17. # pragma pop_macro("slots")
  18. #else
  19. extern "C" {
  20. # include <Python.h>
  21. }
  22. # include <structmember.h>
  23. #endif
  24. // In Python 3, Py_TPFLAGS_DEFAULT contains Py_TPFLAGS_HAVE_VERSION_TAG,
  25. // which will trigger the attribute cache, which is not intended in Qt for Python.
  26. // Use a customized Py_TPFLAGS_DEFAULT by defining Py_TPFLAGS_HAVE_VERSION_TAG = 0.
  27. #undef Py_TPFLAGS_HAVE_VERSION_TAG
  28. #define Py_TPFLAGS_HAVE_VERSION_TAG (0)
  29. using SbkObjectType [[deprecated]] = PyTypeObject; // FIXME PYSIDE 7 remove
  30. #endif