aboutsummaryrefslogtreecommitdiffstats
path: root/PySide
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-04-06 16:04:55 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:08 -0300
commitccf8ddf75b0e5342f8e927b20d3f355456e44099 (patch)
treeee8e7231c674859f9bc6a4fc53bfc417d06ece7b /PySide
parente3b24c2204fedb0141ddd949e4f556d345780df1 (diff)
Implemented support to pyton iterator in QTextFrame::iterator.
Fixes bug #688. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'PySide')
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml35
-rw-r--r--PySide/typesystem_templates.xml15
2 files changed, 41 insertions, 9 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 7194e643c..711993940 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -509,25 +509,25 @@
The iterator methods (__iter__, next) replace this functionality. -->
<modify-function signature="operator++()" remove="all"/>
<modify-function signature="operator--()" remove="all"/>
- <modify-function signature="operator++(int)" remove="all"/>
- <modify-function signature="operator--(int)" remove="all"/>
<!-- ### -->
<add-function signature="__iter__()" return-type="PyObject*">
<inject-code class="target" position="beginning">
- Py_INCREF(%PYSELF);
- %PYARG_0 = %PYSELF;
+ <insert-template name="__iter__" />
</inject-code>
</add-function>
<add-function signature="__next__()" return-type="PyObject*">
<inject-code class="target" position="beginning">
- if (!%CPPSELF.atEnd())
- %PYARG_0 = %CONVERTTOPYTHON[QTextBlock::iterator]((*%CPPSELF)++);
+ <insert-template name="__next__">
+ <replace from="%CPPSELF_TYPE" to="QTextBlock::iterator" />
+ </insert-template>
</inject-code>
</add-function>
</value-type>
<add-function signature="__iter__()" return-type="PyObject*">
<inject-code class="target" position="beginning">
- %PYARG_0 = %CONVERTTOPYTHON[QTextBlock::iterator](%CPPSELF.begin());
+ <insert-template name="__iter_parent__">
+ <replace from="%CPPSELF_TYPE" to="QTextBlock::iterator" />
+ </insert-template>
</inject-code>
</add-function>
<modify-function signature="setUserData(QTextBlockUserData*)">
@@ -3917,12 +3917,29 @@
<!-- ### These operators where removed because they don't make sense in Python.
Instead iterator methods (__iter__, next) should be implemented.
See bug 688 -->
- <modify-function signature="operator++(int)" remove="all"/>
- <modify-function signature="operator--(int)" remove="all"/>
<modify-function signature="operator++()" remove="all"/>
<modify-function signature="operator--()" remove="all"/>
<!-- ### -->
+ <add-function signature="__iter__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="__iter__" />
+ </inject-code>
+ </add-function>
+ <add-function signature="__next__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="__next__">
+ <replace from="%CPPSELF_TYPE" to="QTextFrame::iterator" />
+ </insert-template>
+ </inject-code>
+ </add-function>
</value-type>
+ <add-function signature="__iter__()" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="__iter_parent__">
+ <replace from="%CPPSELF_TYPE" to="QTextFrame::iterator" />
+ </insert-template>
+ </inject-code>
+ </add-function>
</object-type>
<object-type name="QImageIOHandler">
<extra-includes>
diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml
index 24c531e96..81aa2eaca 100644
--- a/PySide/typesystem_templates.xml
+++ b/PySide/typesystem_templates.xml
@@ -320,5 +320,20 @@
%PYARG_0 = %PYARG_#;
</template>
+ <!-- Iterator -->
+ <template name="__iter__">
+ Py_INCREF(%PYSELF);
+ %PYARG_0 = %PYSELF;
+ </template>
+
+ <template name="__iter_parent__">
+ %PYARG_0 = %CONVERTTOPYTHON[%CPPSELF_TYPE](%CPPSELF.begin());
+ </template>
+
+ <template name="__next__">
+ if (!%CPPSELF.atEnd())
+ %PYARG_0 = %CONVERTTOPYTHON[%CPPSELF_TYPE]((*%CPPSELF)++);
+ </template>
+
</typesystem>