Fix bug#408 - "QIODevice.readData() and .readLineData() have output parameters in their signatures"
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
e7f280f745
commit
65022ffef6
3 changed files with 67 additions and 2 deletions
|
|
@ -1767,8 +1767,6 @@
|
||||||
<modify-function signature="waitForBytesWritten(int)" allow-thread="yes"/>
|
<modify-function signature="waitForBytesWritten(int)" allow-thread="yes"/>
|
||||||
<modify-function signature="peek(char *,qint64)" remove="all"/>
|
<modify-function signature="peek(char *,qint64)" remove="all"/>
|
||||||
<modify-function signature="read(char *,qint64)" remove="all"/>
|
<modify-function signature="read(char *,qint64)" remove="all"/>
|
||||||
<!-- Needed by QNetworkReply class on QtNetwork module -->
|
|
||||||
<!-- <modify-function signature="readData(char *,qint64)" remove="all"/> -->
|
|
||||||
<modify-function signature="readLine(char *,qint64)" remove="all"/>
|
<modify-function signature="readLine(char *,qint64)" remove="all"/>
|
||||||
<modify-function signature="write(const char *,qint64)" remove="all"/>
|
<modify-function signature="write(const char *,qint64)" remove="all"/>
|
||||||
<modify-function signature="getChar(char *)">
|
<modify-function signature="getChar(char *)">
|
||||||
|
|
@ -1780,6 +1778,44 @@
|
||||||
<insert-template name="fix_char*" />
|
<insert-template name="fix_char*" />
|
||||||
</inject-code>
|
</inject-code>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
|
<modify-function signature="readData(char *,qint64)">
|
||||||
|
<inject-code class="target">
|
||||||
|
QByteArray ba;
|
||||||
|
ba.resize(%2);
|
||||||
|
%CPPSELF.%FUNCTION_NAME(ba.data(), ba.size());
|
||||||
|
%PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba);
|
||||||
|
</inject-code>
|
||||||
|
<modify-argument index="1">
|
||||||
|
<remove-argument />
|
||||||
|
</modify-argument>
|
||||||
|
<modify-argument index="return">
|
||||||
|
<replace-type modified-type="QByteArray"/>
|
||||||
|
<conversion-rule class="native">
|
||||||
|
const QByteArray ba(%CONVERTTOCPP[QByteArray](%PYARG_0));
|
||||||
|
memcpy(data, ba.data(), ba.size());
|
||||||
|
long long %out = ba.size();
|
||||||
|
</conversion-rule>
|
||||||
|
</modify-argument>
|
||||||
|
</modify-function>
|
||||||
|
<modify-function signature="readLineData(char *,qint64)">
|
||||||
|
<inject-code class="target">
|
||||||
|
QByteArray ba;
|
||||||
|
ba.resize(%2);
|
||||||
|
%CPPSELF.%FUNCTION_NAME(ba.data(), ba.size());
|
||||||
|
%PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba);
|
||||||
|
</inject-code>
|
||||||
|
<modify-argument index="1">
|
||||||
|
<remove-argument />
|
||||||
|
</modify-argument>
|
||||||
|
<modify-argument index="return">
|
||||||
|
<replace-type modified-type="QByteArray"/>
|
||||||
|
<conversion-rule class="native">
|
||||||
|
const QByteArray ba(%CONVERTTOCPP[QByteArray](%PYARG_0));
|
||||||
|
memcpy(data, ba.data(), ba.size());
|
||||||
|
long long %out = ba.size();
|
||||||
|
</conversion-rule>
|
||||||
|
</modify-argument>
|
||||||
|
</modify-function>
|
||||||
</object-type>
|
</object-type>
|
||||||
<object-type name="QCryptographicHash">
|
<object-type name="QCryptographicHash">
|
||||||
<enum-type name="Algorithm"/>
|
<enum-type name="Algorithm"/>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
PYSIDE_TEST(bug_278_test.py)
|
PYSIDE_TEST(bug_278_test.py)
|
||||||
PYSIDE_TEST(bug_332.py)
|
PYSIDE_TEST(bug_332.py)
|
||||||
|
PYSIDE_TEST(bug_408.py)
|
||||||
PYSIDE_TEST(blocking_signals_test.py)
|
PYSIDE_TEST(blocking_signals_test.py)
|
||||||
PYSIDE_TEST(child_event_test.py)
|
PYSIDE_TEST(child_event_test.py)
|
||||||
PYSIDE_TEST(deepcopy_test.py)
|
PYSIDE_TEST(deepcopy_test.py)
|
||||||
|
|
|
||||||
28
tests/QtCore/bug_408.py
Normal file
28
tests/QtCore/bug_408.py
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from PySide.QtCore import *
|
||||||
|
|
||||||
|
class MyDevice(QIODevice):
|
||||||
|
def __init__(self, txt):
|
||||||
|
QIODevice.__init__(self)
|
||||||
|
self.txt = txt
|
||||||
|
self.ptr = 0
|
||||||
|
|
||||||
|
def readData(self, size):
|
||||||
|
size = min(len(self.txt) - self.ptr, size)
|
||||||
|
retval = self.txt[self.ptr:size]
|
||||||
|
self.ptr += size
|
||||||
|
return retval
|
||||||
|
|
||||||
|
class QIODeviceTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def testIt(self):
|
||||||
|
device = MyDevice("hello world\nhello again")
|
||||||
|
device.open(QIODevice.ReadOnly)
|
||||||
|
|
||||||
|
s = QTextStream(device)
|
||||||
|
self.assertEqual(s.readLine(), "hello world")
|
||||||
|
self.assertEqual(s.readLine(), "hello again")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue