File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed
Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,10 @@ IF(PYQT4_VERSION_NUM LESS 264196) # 0x040804
125125 SET (SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} QLISTCONSTPTR_CONVERSION)
126126ENDIF (PYQT4_VERSION_NUM LESS 264196)
127127
128+ IF (NOT PYQT4_VERSION_NUM LESS 264453) # 0x040905
129+ SET (SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} QVECTORINT_CONVERSION)
130+ ENDIF (NOT PYQT4_VERSION_NUM LESS 264453)
131+
128132# core module
129133FILE (GLOB_RECURSE sip_files_core core/*.sip)
130134SET (SIP_EXTRA_FILES_DEPEND ${sip_files_core} )
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ which are not wrapped by PyQt:
2323%Feature QSETINT_CONVERSION
2424%Feature QSETTYPE_CONVERSION
2525%Feature QLISTCONSTPTR_CONVERSION
26+ %Feature QVECTORINT_CONVERSION
2627
2728%ModuleHeaderCode
2829
@@ -1512,3 +1513,55 @@ template <TYPE>
15121513 return sipGetState(sipTransferObj);
15131514%End
15141515};
1516+
1517+ %If (QVECTORINT_CONVERSION)
1518+ // QVector<int> is implemented as a Python list of integers.
1519+ %MappedType QVector<int> /DocType="list-of-int"/
1520+ {
1521+ %TypeHeaderCode
1522+ #include <qvector.h>
1523+ %End
1524+
1525+ %ConvertFromTypeCode
1526+ // Create the list.
1527+ PyObject *l;
1528+
1529+ if ((l = PyList_New(sipCpp->size())) == NULL)
1530+ return NULL;
1531+
1532+ // Set the list elements.
1533+ for (int i = 0; i < sipCpp->size(); ++i)
1534+ {
1535+ PyObject *pobj;
1536+
1537+ // Convert to a Python long to make sure it doesn't get interpreted as
1538+ // a signed value.
1539+ if ((pobj = SIPLong_FromLong(sipCpp->value(i))) == NULL)
1540+ {
1541+ Py_DECREF(l);
1542+
1543+ return NULL;
1544+ }
1545+
1546+ PyList_SET_ITEM(l, i, pobj);
1547+ }
1548+
1549+ return l;
1550+ %End
1551+
1552+ %ConvertToTypeCode
1553+ // Check the type if that is all that is required.
1554+ if (sipIsErr == NULL)
1555+ return PyList_Check(sipPy);
1556+
1557+ QVector<int> *qv = new QVector<int>;
1558+
1559+ for (SIP_SSIZE_T i = 0; i < PyList_GET_SIZE(sipPy); ++i)
1560+ qv->append(SIPLong_AsLong(PyList_GET_ITEM(sipPy, i)));
1561+
1562+ *sipCppPtr = qv;
1563+
1564+ return sipGetState(sipTransferObj);
1565+ %End
1566+ };
1567+ %Endif
You can’t perform that action at this time.
0 commit comments