summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-11-24 15:15:56 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-11-24 15:37:48 -0200
commit91030433ced8aa59000de1465635dab528dbb36d (patch)
treed6e46087890d5fa8619ea63827f06a24a16bf4e3
parent47aa7189789b43be6c7fee10affc83966fbbab07 (diff)
Fix bug#496 - "No binary read/write methods in QDataStream"
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Renato Ara├║jo <renato.filho@openbossa.org>
-rw-r--r--PySide/QtCore/typesystem_core.xml26
-rw-r--r--tests/QtCore/qdatastream_test.py12
2 files changed, 35 insertions, 3 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index 22c6be31..6da4f64c 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -2222,10 +2222,30 @@
</inject-code>
</add-function>
- <modify-function signature="readRawData(char*,int)" remove="all"/>
+ <modify-function signature="readRawData(char*,int)">
+ <modify-argument index="1">
+ <remove-argument />
+ </modify-argument>
+ <inject-code class="target">
+ QByteArray data;
+ data.resize(%2);
+ %CPPSELF.%FUNCTION_NAME(data.data(), data.size());
+ %PYARG_0 = PyString_FromStringAndSize(data.constData(), data.size());
+ </inject-code>
+ </modify-function>
+ <!-- deprecated method -->
<modify-function signature="readBytes(char*&amp;,uint&amp;)" remove="all"/>
- <modify-function signature="writeRawData(const char*,int)" remove="all"/>
- <modify-function signature="writeBytes(const char*,uint)" remove="all"/>
+ <modify-function signature="writeRawData(const char*,int)">
+ <modify-argument index="2">
+ <remove-argument />
+ </modify-argument>
+ <inject-code class="target">
+ int r = %CPPSELF.%FUNCTION_NAME(%1, PyString_Size(%PYARG_1));
+ %PYARG_0 = %CONVERTTOPYTHON[int](r);
+ </inject-code>
+ </modify-function>
+ <!-- deprecated method -->
+ <modify-function signature="writeBytes(const char*,uint)" remove="all" />
<!-- Extra functions for primitive type handling -->
diff --git a/tests/QtCore/qdatastream_test.py b/tests/QtCore/qdatastream_test.py
index b634a7e3..1a75f793 100644
--- a/tests/QtCore/qdatastream_test.py
+++ b/tests/QtCore/qdatastream_test.py
@@ -308,6 +308,18 @@ class QDataStreamShiftBitArray(unittest.TestCase):
self._check_bitarray(data)
+class QDataStreamShiftBitArray(unittest.TestCase):
+ def testRawData(self):
+ data = QDataStream()
+ self.assertEqual(data.readRawData(4), '\x00\x00\x00\x00')
+
+ ba = QByteArray()
+ data = QDataStream(ba, QIODevice.WriteOnly)
+ data.writeRawData('ABC')
+ self.assertEqual(ba, 'ABC')
+
+ data = QDataStream(ba)
+ self.assertEqual(data.readRawData(4), 'ABC\x00')
if __name__ == '__main__':
unittest.main()