qpyopengl_std_pair.sip 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // This is the SIP interface definition for the std::pair based mapped types
  2. // specific to the QtGui module.
  3. //
  4. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  5. //
  6. // This file is part of PyQt6.
  7. //
  8. // This file may be used under the terms of the GNU General Public License
  9. // version 3.0 as published by the Free Software Foundation and appearing in
  10. // the file LICENSE included in the packaging of this file. Please review the
  11. // following information to ensure the GNU General Public License version 3.0
  12. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  13. //
  14. // If you do not wish to use this file under the terms of the GPL version 3.0
  15. // then you may purchase a commercial license. For more information contact
  16. // info@riverbankcomputing.com.
  17. //
  18. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  19. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20. %MappedType std::pair<QOpenGLTexture::Filter, QOpenGLTexture::Filter>
  21. /TypeHint="Tuple[QOpenGLTexture.Filter, QOpenGLTexture.Filter]"/
  22. {
  23. %TypeHeaderCode
  24. #include <QOpenGLTexture>
  25. %End
  26. %ConvertFromTypeCode
  27. return sipBuildResult(NULL, "(FF)", sipCpp->first,
  28. sipType_QOpenGLTexture_Filter, sipCpp->second,
  29. sipType_QOpenGLTexture_Filter);
  30. %End
  31. %ConvertToTypeCode
  32. if (!sipIsErr)
  33. return (PySequence_Check(sipPy) && !PyUnicode_Check(sipPy));
  34. Py_ssize_t len = PySequence_Size(sipPy);
  35. if (len != 2)
  36. {
  37. // A negative length should only be an internal error so let the
  38. // original exception stand.
  39. if (len >= 0)
  40. PyErr_Format(PyExc_TypeError,
  41. "sequence has %zd elements but 2 elements are expected",
  42. len);
  43. *sipIsErr = 1;
  44. return 0;
  45. }
  46. PyObject *firstobj = PySequence_GetItem(sipPy, 0);
  47. if (!firstobj)
  48. {
  49. *sipIsErr = 1;
  50. return 0;
  51. }
  52. int firstv = sipConvertToEnum(firstobj, sipType_QOpenGLTexture_Filter);
  53. if (PyErr_Occurred())
  54. {
  55. PyErr_Format(PyExc_TypeError,
  56. "the first element has type '%s' but 'QOpenGLTexture.Filter' is expected",
  57. sipPyTypeName(Py_TYPE(firstobj)));
  58. *sipIsErr = 1;
  59. return 0;
  60. }
  61. PyObject *secondobj = PySequence_GetItem(sipPy, 1);
  62. if (!secondobj)
  63. {
  64. Py_DECREF(firstobj);
  65. *sipIsErr = 1;
  66. return 0;
  67. }
  68. int secondv = sipConvertToEnum(secondobj, sipType_QOpenGLTexture_Filter);
  69. if (PyErr_Occurred())
  70. {
  71. PyErr_Format(PyExc_TypeError,
  72. "the second element has type '%s' but 'QOpenGLTexture.Filter' is expected",
  73. sipPyTypeName(Py_TYPE(secondobj)));
  74. Py_DECREF(secondobj);
  75. Py_DECREF(firstobj);
  76. *sipIsErr = 1;
  77. return 0;
  78. }
  79. *sipCppPtr = new std::pair<QOpenGLTexture::Filter, QOpenGLTexture::Filter>(
  80. static_cast<QOpenGLTexture::Filter>(firstv),
  81. static_cast<QOpenGLTexture::Filter>(secondv));
  82. Py_DECREF(secondobj);
  83. Py_DECREF(firstobj);
  84. return sipGetState(sipTransferObj);
  85. %End
  86. };