diff options
author | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2011-01-26 15:21:37 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:53:46 -0300 |
commit | 16c3baa45401a915713b0b6201edf4f5c72822ab (patch) | |
tree | 2c8ad631b3f8515f7f8bf9cba486c78325bee618 /PySide/typesystem_templates.xml | |
parent | 494828092bc5f7853b4e63a6f94dfed8253115b5 (diff) |
Implemented fuction __repr__ for base types.
Fixes bug #593
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'PySide/typesystem_templates.xml')
-rw-r--r-- | PySide/typesystem_templates.xml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 65a98b2ba..e13b78d9e 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -187,6 +187,29 @@ if (!Shiboken::Object::hasParentInfo(_pySelf)) Shiboken::Object::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_0); </template> + <!-- templates for __repr__ --> + <template name="repr_code"> + QString format = QString().sprintf("%s(%REPR_FORMAT)", ((PyObject*)%PYSELF)->ob_type->tp_name, %REPR_ARGS); + %PYARG_0 = PyString_FromString(qPrintable(format)); + </template> + <template name="repr_code_matrix"> + QString format= QString("%1((").arg(((PyObject*)%PYSELF)->ob_type->tp_name); + + QList< %MATRIX_TYPE > cppArgs; + %MATRIX_TYPE data[%MATRIX_SIZE]; + %CPPSELF.copyDataTo(data); + int matrixSize = %MATRIX_SIZE; + for(int size=0; size < matrixSize; size++) { + if (size > 0) + format += ", "; + format += QString::number(data[size]); + } + format += "))"; + + %PYARG_0 = PyString_FromString(qPrintable(format)); + </template> + + <!-- templates for __reduce__ --> <template name="reduce_code"> %PYARG_0 = Py_BuildValue("(N(%REDUCE_FORMAT))", PyObject_Type(%PYSELF), %REDUCE_ARGS); |