sbkbindingutils.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (C) 2025 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 SBK_BINDINGUTILS
  4. #define SBK_BINDINGUTILS
  5. #include "sbkpython.h"
  6. #include "shibokenmacros.h"
  7. namespace Shiboken {
  8. struct AutoDecRef;
  9. /// Maps a keyword argument by name to its parameter index
  10. struct ArgumentNameIndexMapping
  11. {
  12. const char *name;
  13. int index;
  14. };
  15. /// Function binding helper: Parse the keyword arguments in dict \a kwds
  16. /// according to \a mapping (name->index) and store them in array \a pyArgs
  17. /// under their index. Fails if an entry is missing or duplicate entries
  18. /// occur.
  19. LIBSHIBOKEN_API bool
  20. parseKeywordArguments(PyObject *kwds,
  21. const ArgumentNameIndexMapping *mapping, size_t size,
  22. Shiboken::AutoDecRef &errInfo, PyObject **pyArgs);
  23. /// Function binding helper: Parse the keyword arguments of a QObject constructor
  24. /// in dict \a kwds according to \a mapping (name->index) and store them in array
  25. /// \a pyArgs under their index. Fails if duplicate entries occur. Unmapped entries
  26. /// (QObject properties) are stored in a dict in errInfo for further processing.
  27. LIBSHIBOKEN_API bool
  28. parseConstructorKeywordArguments(PyObject *kwds,
  29. const ArgumentNameIndexMapping *mapping, size_t size,
  30. Shiboken::AutoDecRef &errInfo, PyObject **pyArgs);
  31. /// Returns whether we are running in compiled mode (Nuitka).
  32. LIBSHIBOKEN_API bool isCompiled();
  33. } // namespace Shiboken
  34. #endif // SBK_BINDINGUTILS