aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-12-28 16:41:50 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-01-04 15:58:39 -0200
commit7729b390d0b8ca82192158cae3865e31b0365573 (patch)
treed15881b78e309f0fba4b1422f4051cd7d5a4a380
parent85048bbd6c5d4231f71852cab18fd581c5068141 (diff)
Fixes type system templates for methods with bool* as parameter.
Template functions like "fix_bool*" were converting the bool "ok" value to various types except bool, and "fix_bool*,arg" was using the wrong C++ argument. Tests were also added. Reviewed by Hugo Parente <hugo.lima@openbossa.org>
-rw-r--r--PySide/typesystem_templates.xml10
-rw-r--r--tests/qtcore/qstring_test.py15
2 files changed, 20 insertions, 5 deletions
diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml
index cc283e9f1..b8f1981f3 100644
--- a/PySide/typesystem_templates.xml
+++ b/PySide/typesystem_templates.xml
@@ -5,22 +5,22 @@
<template name="fix_bool*">
bool ok_;
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_);
- %PYARG_0 = PyTuple_Pack(2, %CONVERTTOPYTHON[%RETURN_TYPE](retval_), %CONVERTTOPYTHON[%RETURN_TYPE](ok_));
+ %PYARG_0 = PyTuple_Pack(2, %CONVERTTOPYTHON[%RETURN_TYPE](retval_), %CONVERTTOPYTHON[bool](ok_));
</template>
<template name="fix_args,bool*">
bool ok_;
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &amp;ok_);
- %PYARG_0 = PyTuple_Pack(2, %CONVERTTOPYTHON[%RETURN_TYPE](retval_), %CONVERTTOPYTHON[%RETURN_TYPE](ok_));
+ %PYARG_0 = PyTuple_Pack(2, %CONVERTTOPYTHON[%RETURN_TYPE](retval_), %CONVERTTOPYTHON[bool](ok_));
</template>
<template name="fix_arg,bool*,arg">
bool ok_;
%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, &amp;ok_, %3);
- %PYARG_0 = PyTuple_Pack(2, %CONVERTTOPYTHON[%RETURN_TYPE](retval_), %CONVERTTOPYTHON[%RETURN_TYPE](ok_));
+ %PYARG_0 = PyTuple_Pack(2, %CONVERTTOPYTHON[%RETURN_TYPE](retval_), %CONVERTTOPYTHON[bool](ok_));
</template>
<template name="fix_bool*,arg">
bool ok_;
- %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_, %1);
- %PYARG_0 = PyTuple_Pack(2, %CONVERTTOPYTHON[%RETURN_TYPE](retval_), %CONVERTTOPYTHON[%RETURN_TYPE](ok_));
+ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&amp;ok_, %2);
+ %PYARG_0 = PyTuple_Pack(2, %CONVERTTOPYTHON[%RETURN_TYPE](retval_), %CONVERTTOPYTHON[bool](ok_));
</template>
<template name="get_slice">
%TYPE* sequence;
diff --git a/tests/qtcore/qstring_test.py b/tests/qtcore/qstring_test.py
index 35863a16b..d9152447d 100644
--- a/tests/qtcore/qstring_test.py
+++ b/tests/qtcore/qstring_test.py
@@ -9,10 +9,25 @@ import sys
from PySide.QtCore import QString, QByteArray
class QStringToNumber(unittest.TestCase):
+ def testReturnValueTypes(self):
+ obj = QString('37')
+ val, ok = obj.toInt()
+ self.assertEqual(type(val), int)
+ self.assertEqual(type(ok), bool)
+
def testToNumberInt(self):
obj = QString('37')
self.assertEqual(37, obj.toInt()[0])
+ def testToNumberIntUsingHex(self):
+ obj = QString('2A')
+ self.assertEquals((0, False), obj.toInt())
+ self.assertEqual((int(str(obj), 16), True), obj.toInt(16))
+
+ def testToNumberIntUsingHex(self):
+ obj = QString('101010')
+ self.assertEqual((int(str(obj), 2), True), obj.toInt(2))
+
def testToNumberFloat(self):
obj = QString('37.109')
self.assertEqual(ctypes.c_float(37.109).value,