diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-08-01 13:42:42 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:41 -0300 |
commit | 609f6bc8898f0df4f789e834e2f2e5c97be9866d (patch) | |
tree | 5a17354d0c3ae5feda4ab5301ed05e36ce3062ab | |
parent | 151111bde2fcf7ab182495da16b3799fa2edf123 (diff) |
Created template code for added QObject's trUtf8 methods.
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Reviewed by Renato Araújo <renato.filho@openbossa.org>
-rw-r--r-- | PySide/QtCore/typesystem_core.xml | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 6ca205aea..bf066b938 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1430,6 +1430,18 @@ </inject-code> </add-function> + <template name="translate_utf8"> + if (QCoreApplication::instance()) { + Shiboken::AutoDecRef klass(PyObject_GetAttrString(%PYSELF, "__class__")); + Shiboken::AutoDecRef cname(PyObject_GetAttrString(klass, "__name__")); + $DEFINE_SECOND_VAR + QString result = QCoreApplication::instance()->translate(PyString_AS_STRING(cname.object()), $SECOND_VAR, %2, QCoreApplication::UnicodeUTF8, %3); + %PYARG_0 = %CONVERTTOPYTHON[QString](result); + } else { + Py_INCREF(%PYARG_1); + %PYARG_0 = %PYARG_1; + } + </template> <add-function signature="trUtf8(const char *, const char *, int)" return-type="QString"> <modify-argument index="2"> <replace-default-expression with="0"/> @@ -1438,18 +1450,12 @@ <replace-default-expression with="-1"/> </modify-argument> <inject-code class="target" position="beginning"> - if (QCoreApplication::instance()) { - Shiboken::AutoDecRef klass(PyObject_GetAttrString(%PYSELF, "__class__")); - Shiboken::AutoDecRef cname(PyObject_GetAttrString(klass, "__name__")); - QString result = QCoreApplication::instance()->translate(PyString_AS_STRING(cname.object()), %1, %2, QCoreApplication::UnicodeUTF8, %3); - %PYARG_0 = %CONVERTTOPYTHON[QString](result); - } else { - Py_INCREF(%PYARG_1); - %PYARG_0 = %PYARG_1; - } + <insert-template name="translate_utf8"> + <replace from="$DEFINE_SECOND_VAR" to="" /> + <replace from="$SECOND_VAR" to="%1" /> + </insert-template> </inject-code> </add-function> - <add-function signature="trUtf8(PyUnicode, const char *, int)" return-type="QString"> <modify-argument index="2"> <replace-default-expression with="0"/> @@ -1458,20 +1464,13 @@ <replace-default-expression with="-1"/> </modify-argument> <inject-code class="target" position="beginning"> - if (QCoreApplication::instance()) { - Shiboken::AutoDecRef klass(PyObject_GetAttrString(%PYSELF, "__class__")); - Shiboken::AutoDecRef cname(PyObject_GetAttrString(klass, "__name__")); - Shiboken::AutoDecRef str(PyUnicode_AsUTF8String(%1)); - QString result = QCoreApplication::instance()->translate(PyString_AS_STRING(cname.object()), PyString_AS_STRING(str.object()), %2, QCoreApplication::UnicodeUTF8, %3); - %PYARG_0 = %CONVERTTOPYTHON[QString](result); - } else { - Py_INCREF(%PYARG_1); - %PYARG_0 = %PYARG_1; - } + <insert-template name="translate_utf8"> + <replace from="$DEFINE_SECOND_VAR" to="Shiboken::AutoDecRef str(PyUnicode_AsUTF8String(%1));" /> + <replace from="$SECOND_VAR" to="PyString_AS_STRING(str.object())" /> + </insert-template> </inject-code> </add-function> - <modify-function signature="receivers(const char*) const"> <inject-code class="target" position="beginning"> // Avoid return +1 because SignalManager connect to "destroyed()" signal to control object timelife |