diff options
Diffstat (limited to 'PySide/typesystem_templates.xml')
-rw-r--r-- | PySide/typesystem_templates.xml | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 959fe7e20..576343473 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -181,11 +181,62 @@ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5); %PYARG_0 = Shiboken::makeTuple(retval_, %4); </template> - <template name="set_qapp_parent_for_orphan"> Shiboken::SbkBaseWrapper* _pySelf = reinterpret_cast<Shiboken::SbkBaseWrapper*>(%PYARG_0); if (!_pySelf->parentInfo) Shiboken::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_0); </template> + <!-- templates for __reduce__ --> + <template name="reduce_code"> + PyObject *type = PyObject_Type(%PYSELF); + PyObject *args = NULL; + args = Py_BuildValue("%REDUCE_FORMAT", %REDUCE_ARGS); + %PYARG_0 = Py_BuildValue("(NN)", type, args); + </template> + <template name="reduce_code_matrix"> + QList< %MATRIX_TYPE > cppArgs; + %MATRIX_TYPE data[%MATRIX_SIZE]; + %CPPSELF.copyDataTo(data); + int matrixSize = %MATRIX_SIZE; + for(int size=0; size < matrixSize; size++) + cppArgs.append(data[size]); + + PyObject *type = PyObject_Type(%PYSELF); + PyObject *args = Py_BuildValue("(N)", %CONVERTTOPYTHON[QList<%MATRIX_TYPE> ](cppArgs)); + %PYARG_0 = Py_BuildValue("(NN)", type, args); + </template> + + <!-- Matrix Aux functions --> + <template name="matrix_constructor"> + if (PySequence_Size(%PYARG_1) == %SIZE) { + Shiboken::AutoDecRef fast(PySequence_Fast(%PYARG_1, "Fail to parse sequnce on %TYPE constructor.")); + qreal values[%SIZE]; + for(int i=0; i < %SIZE; i++) { + PyObject *pv = PySequence_Fast_GET_ITEM(fast.object(), i); + values[i] = %CONVERTTOCPP[qreal](pv); + } + %0 = new %TYPE(values); + } + </template> + + <template name="matrix_data_function"> + const qreal* data = %CPPSELF.constData(); + PyObject *pyData = PyTuple_New(%MATRIX_SIZE); + if (data) { + for(int i=0; i < %MATRIX_SIZE; i++) + PyTuple_SET_ITEM(pyData, i, %CONVERTTOPYTHON[qreal](data[i])); + } + return pyData; + </template> + + <template name="matrix_fill_function"> + qreal value = %CONVERTTOCPP[qreal](%PYARG_1); + %CPPSELF.fill(value); + </template> + + <template name="matrix_transposed_function"> + return %CONVERTTOPYTHON[%TRANSPOSED_TYPE](%CPPSELF.transposed()); + </template> + </typesystem> |