qpymultimedia_qlist.sip 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. // This is the SIP interface definition for the QList based mapped types
  2. // specific to the QtMultimedia 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. %If (Qt_6_2_0 -)
  21. %MappedType QList<QAudioFormat::SampleFormat>
  22. /TypeHintIn="Iterable[QAudioFormat.SampleFormat]",
  23. TypeHintOut="List[QAudioFormat.SampleFormat]", TypeHintValue="[]"/
  24. {
  25. %TypeHeaderCode
  26. #include <qaudioformat.h>
  27. %End
  28. %ConvertFromTypeCode
  29. PyObject *l = PyList_New(sipCpp->size());
  30. if (!l)
  31. return 0;
  32. for (int i = 0; i < sipCpp->size(); ++i)
  33. {
  34. PyObject *eobj = sipConvertFromEnum(sipCpp->at(i),
  35. sipType_QAudioFormat_SampleFormat);
  36. if (!eobj)
  37. {
  38. Py_DECREF(l);
  39. return 0;
  40. }
  41. PyList_SetItem(l, i, eobj);
  42. }
  43. return l;
  44. %End
  45. %ConvertToTypeCode
  46. PyObject *iter = PyObject_GetIter(sipPy);
  47. if (!sipIsErr)
  48. {
  49. PyErr_Clear();
  50. Py_XDECREF(iter);
  51. return (iter && !PyBytes_Check(sipPy) && !PyUnicode_Check(sipPy));
  52. }
  53. if (!iter)
  54. {
  55. *sipIsErr = 1;
  56. return 0;
  57. }
  58. QList<QAudioFormat::SampleFormat> *ql = new QList<QAudioFormat::SampleFormat>;
  59. for (Py_ssize_t i = 0; ; ++i)
  60. {
  61. PyErr_Clear();
  62. PyObject *itm = PyIter_Next(iter);
  63. if (!itm)
  64. {
  65. if (PyErr_Occurred())
  66. {
  67. delete ql;
  68. Py_DECREF(iter);
  69. *sipIsErr = 1;
  70. return 0;
  71. }
  72. break;
  73. }
  74. int v = sipConvertToEnum(itm, sipType_QAudioFormat_SampleFormat);
  75. if (PyErr_Occurred())
  76. {
  77. PyErr_Format(PyExc_TypeError,
  78. "index %zd has type '%s' but 'QAudioFormat.SampleFormat' is expected",
  79. i, sipPyTypeName(Py_TYPE(itm)));
  80. Py_DECREF(itm);
  81. delete ql;
  82. Py_DECREF(iter);
  83. *sipIsErr = 1;
  84. return 0;
  85. }
  86. ql->append(static_cast<QAudioFormat::SampleFormat>(v));
  87. Py_DECREF(itm);
  88. }
  89. Py_DECREF(iter);
  90. *sipCppPtr = ql;
  91. return sipGetState(sipTransferObj);
  92. %End
  93. };
  94. %MappedType QList<QImageCapture::FileFormat>
  95. /TypeHintIn="Iterable[QImageCapture.FileFormat]",
  96. TypeHintOut="List[QImageCapture.FileFormat]", TypeHintValue="[]"/
  97. {
  98. %TypeHeaderCode
  99. #include <qaudioformat.h>
  100. %End
  101. %ConvertFromTypeCode
  102. PyObject *l = PyList_New(sipCpp->size());
  103. if (!l)
  104. return 0;
  105. for (int i = 0; i < sipCpp->size(); ++i)
  106. {
  107. PyObject *eobj = sipConvertFromEnum(sipCpp->at(i),
  108. sipType_QImageCapture_FileFormat);
  109. if (!eobj)
  110. {
  111. Py_DECREF(l);
  112. return 0;
  113. }
  114. PyList_SetItem(l, i, eobj);
  115. }
  116. return l;
  117. %End
  118. %ConvertToTypeCode
  119. PyObject *iter = PyObject_GetIter(sipPy);
  120. if (!sipIsErr)
  121. {
  122. PyErr_Clear();
  123. Py_XDECREF(iter);
  124. return (iter && !PyBytes_Check(sipPy) && !PyUnicode_Check(sipPy));
  125. }
  126. if (!iter)
  127. {
  128. *sipIsErr = 1;
  129. return 0;
  130. }
  131. QList<QImageCapture::FileFormat> *ql = new QList<QImageCapture::FileFormat>;
  132. for (Py_ssize_t i = 0; ; ++i)
  133. {
  134. PyErr_Clear();
  135. PyObject *itm = PyIter_Next(iter);
  136. if (!itm)
  137. {
  138. if (PyErr_Occurred())
  139. {
  140. delete ql;
  141. Py_DECREF(iter);
  142. *sipIsErr = 1;
  143. return 0;
  144. }
  145. break;
  146. }
  147. int v = sipConvertToEnum(itm, sipType_QImageCapture_FileFormat);
  148. if (PyErr_Occurred())
  149. {
  150. PyErr_Format(PyExc_TypeError,
  151. "index %zd has type '%s' but 'QImageCapture.FileFormat' is expected",
  152. i, sipPyTypeName(Py_TYPE(itm)));
  153. Py_DECREF(itm);
  154. delete ql;
  155. Py_DECREF(iter);
  156. *sipIsErr = 1;
  157. return 0;
  158. }
  159. ql->append(static_cast<QImageCapture::FileFormat>(v));
  160. Py_DECREF(itm);
  161. }
  162. Py_DECREF(iter);
  163. *sipCppPtr = ql;
  164. return sipGetState(sipTransferObj);
  165. %End
  166. };
  167. %MappedType QList<QMediaFormat::FileFormat>
  168. /TypeHintIn="Iterable[QMediaFormat.FileFormat]",
  169. TypeHintOut="List[QMediaFormat.FileFormat]", TypeHintValue="[]"/
  170. {
  171. %TypeHeaderCode
  172. #include <qaudioformat.h>
  173. %End
  174. %ConvertFromTypeCode
  175. PyObject *l = PyList_New(sipCpp->size());
  176. if (!l)
  177. return 0;
  178. for (int i = 0; i < sipCpp->size(); ++i)
  179. {
  180. PyObject *eobj = sipConvertFromEnum(sipCpp->at(i),
  181. sipType_QMediaFormat_FileFormat);
  182. if (!eobj)
  183. {
  184. Py_DECREF(l);
  185. return 0;
  186. }
  187. PyList_SetItem(l, i, eobj);
  188. }
  189. return l;
  190. %End
  191. %ConvertToTypeCode
  192. PyObject *iter = PyObject_GetIter(sipPy);
  193. if (!sipIsErr)
  194. {
  195. PyErr_Clear();
  196. Py_XDECREF(iter);
  197. return (iter && !PyBytes_Check(sipPy) && !PyUnicode_Check(sipPy));
  198. }
  199. if (!iter)
  200. {
  201. *sipIsErr = 1;
  202. return 0;
  203. }
  204. QList<QMediaFormat::FileFormat> *ql = new QList<QMediaFormat::FileFormat>;
  205. for (Py_ssize_t i = 0; ; ++i)
  206. {
  207. PyErr_Clear();
  208. PyObject *itm = PyIter_Next(iter);
  209. if (!itm)
  210. {
  211. if (PyErr_Occurred())
  212. {
  213. delete ql;
  214. Py_DECREF(iter);
  215. *sipIsErr = 1;
  216. return 0;
  217. }
  218. break;
  219. }
  220. int v = sipConvertToEnum(itm, sipType_QMediaFormat_FileFormat);
  221. if (PyErr_Occurred())
  222. {
  223. PyErr_Format(PyExc_TypeError,
  224. "index %zd has type '%s' but 'QMediaFormat.FileFormat' is expected",
  225. i, sipPyTypeName(Py_TYPE(itm)));
  226. Py_DECREF(itm);
  227. delete ql;
  228. Py_DECREF(iter);
  229. *sipIsErr = 1;
  230. return 0;
  231. }
  232. ql->append(static_cast<QMediaFormat::FileFormat>(v));
  233. Py_DECREF(itm);
  234. }
  235. Py_DECREF(iter);
  236. *sipCppPtr = ql;
  237. return sipGetState(sipTransferObj);
  238. %End
  239. };
  240. %MappedType QList<QMediaFormat::AudioCodec>
  241. /TypeHintIn="Iterable[QMediaFormat.AudioCodec]",
  242. TypeHintOut="List[QMediaFormat.AudioCodec]", TypeHintValue="[]"/
  243. {
  244. %TypeHeaderCode
  245. #include <qaudioformat.h>
  246. %End
  247. %ConvertFromTypeCode
  248. PyObject *l = PyList_New(sipCpp->size());
  249. if (!l)
  250. return 0;
  251. for (int i = 0; i < sipCpp->size(); ++i)
  252. {
  253. PyObject *eobj = sipConvertFromEnum(static_cast<int>(sipCpp->at(i)),
  254. sipType_QMediaFormat_AudioCodec);
  255. if (!eobj)
  256. {
  257. Py_DECREF(l);
  258. return 0;
  259. }
  260. PyList_SetItem(l, i, eobj);
  261. }
  262. return l;
  263. %End
  264. %ConvertToTypeCode
  265. PyObject *iter = PyObject_GetIter(sipPy);
  266. if (!sipIsErr)
  267. {
  268. PyErr_Clear();
  269. Py_XDECREF(iter);
  270. return (iter && !PyBytes_Check(sipPy) && !PyUnicode_Check(sipPy));
  271. }
  272. if (!iter)
  273. {
  274. *sipIsErr = 1;
  275. return 0;
  276. }
  277. QList<QMediaFormat::AudioCodec> *ql = new QList<QMediaFormat::AudioCodec>;
  278. for (Py_ssize_t i = 0; ; ++i)
  279. {
  280. PyErr_Clear();
  281. PyObject *itm = PyIter_Next(iter);
  282. if (!itm)
  283. {
  284. if (PyErr_Occurred())
  285. {
  286. delete ql;
  287. Py_DECREF(iter);
  288. *sipIsErr = 1;
  289. return 0;
  290. }
  291. break;
  292. }
  293. int v = sipConvertToEnum(itm, sipType_QMediaFormat_AudioCodec);
  294. if (PyErr_Occurred())
  295. {
  296. PyErr_Format(PyExc_TypeError,
  297. "index %zd has type '%s' but 'QMediaFormat.AudioCodec' is expected",
  298. i, sipPyTypeName(Py_TYPE(itm)));
  299. Py_DECREF(itm);
  300. delete ql;
  301. Py_DECREF(iter);
  302. *sipIsErr = 1;
  303. return 0;
  304. }
  305. ql->append(static_cast<QMediaFormat::AudioCodec>(v));
  306. Py_DECREF(itm);
  307. }
  308. Py_DECREF(iter);
  309. *sipCppPtr = ql;
  310. return sipGetState(sipTransferObj);
  311. %End
  312. };
  313. %MappedType QList<QMediaFormat::VideoCodec>
  314. /TypeHintIn="Iterable[QMediaFormat.VideoCodec]",
  315. TypeHintOut="List[QMediaFormat.VideoCodec]", TypeHintValue="[]"/
  316. {
  317. %TypeHeaderCode
  318. #include <qaudioformat.h>
  319. %End
  320. %ConvertFromTypeCode
  321. PyObject *l = PyList_New(sipCpp->size());
  322. if (!l)
  323. return 0;
  324. for (int i = 0; i < sipCpp->size(); ++i)
  325. {
  326. PyObject *eobj = sipConvertFromEnum(static_cast<int>(sipCpp->at(i)),
  327. sipType_QMediaFormat_VideoCodec);
  328. if (!eobj)
  329. {
  330. Py_DECREF(l);
  331. return 0;
  332. }
  333. PyList_SetItem(l, i, eobj);
  334. }
  335. return l;
  336. %End
  337. %ConvertToTypeCode
  338. PyObject *iter = PyObject_GetIter(sipPy);
  339. if (!sipIsErr)
  340. {
  341. PyErr_Clear();
  342. Py_XDECREF(iter);
  343. return (iter && !PyBytes_Check(sipPy) && !PyUnicode_Check(sipPy));
  344. }
  345. if (!iter)
  346. {
  347. *sipIsErr = 1;
  348. return 0;
  349. }
  350. QList<QMediaFormat::VideoCodec> *ql = new QList<QMediaFormat::VideoCodec>;
  351. for (Py_ssize_t i = 0; ; ++i)
  352. {
  353. PyErr_Clear();
  354. PyObject *itm = PyIter_Next(iter);
  355. if (!itm)
  356. {
  357. if (PyErr_Occurred())
  358. {
  359. delete ql;
  360. Py_DECREF(iter);
  361. *sipIsErr = 1;
  362. return 0;
  363. }
  364. break;
  365. }
  366. int v = sipConvertToEnum(itm, sipType_QMediaFormat_VideoCodec);
  367. if (PyErr_Occurred())
  368. {
  369. PyErr_Format(PyExc_TypeError,
  370. "index %zd has type '%s' but 'QMediaFormat.VideoCodec' is expected",
  371. i, sipPyTypeName(Py_TYPE(itm)));
  372. Py_DECREF(itm);
  373. delete ql;
  374. Py_DECREF(iter);
  375. *sipIsErr = 1;
  376. return 0;
  377. }
  378. ql->append(static_cast<QMediaFormat::VideoCodec>(v));
  379. Py_DECREF(itm);
  380. }
  381. Py_DECREF(iter);
  382. *sipCppPtr = ql;
  383. return sipGetState(sipTransferObj);
  384. %End
  385. };
  386. %End