Fix bug 723 - "Missing QAbstractFileEngine.read and QAbstractFileEngine.readLine"
This commit is contained in:
parent
741bc56e4b
commit
1e149f3de4
3 changed files with 104 additions and 5 deletions
|
|
@ -2078,7 +2078,13 @@
|
||||||
</inject-code>
|
</inject-code>
|
||||||
</add-function>
|
</add-function>
|
||||||
</object-type>
|
</object-type>
|
||||||
<object-type name="QAbstractFileEngineHandler" />
|
<object-type name="QAbstractFileEngineHandler">
|
||||||
|
<modify-function signature="create(const QString↦)const">
|
||||||
|
<modify-argument index="return">
|
||||||
|
<define-ownership owner="c++"/>
|
||||||
|
</modify-argument>
|
||||||
|
</modify-function>
|
||||||
|
</object-type>
|
||||||
<!-- <object-type name="QAbstractFileEngine::MapExtensionOption" /> -->
|
<!-- <object-type name="QAbstractFileEngine::MapExtensionOption" /> -->
|
||||||
<!-- <object-type name="QAbstractFileEngine::MapExtensionReturn" /> -->
|
<!-- <object-type name="QAbstractFileEngine::MapExtensionReturn" /> -->
|
||||||
<!-- <object-type name="QAbstractFileEngine::UnMapExtensionOption" /> -->
|
<!-- <object-type name="QAbstractFileEngine::UnMapExtensionOption" /> -->
|
||||||
|
|
@ -2121,10 +2127,52 @@
|
||||||
</inject-code>
|
</inject-code>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
|
|
||||||
<!-- ### See bug 723 -->
|
<modify-function signature="read(char*, qint64)" allow-thread="yes">
|
||||||
<modify-function signature="read(char*, qint64)" allow-thread="yes" remove="all" />
|
<inject-code class="target">
|
||||||
<modify-function signature="readLine(char*, qint64)" allow-thread="yes" remove="all" />
|
QByteArray ba;
|
||||||
<!-- ### -->
|
ba.resize(%2);
|
||||||
|
%CPPSELF.%FUNCTION_NAME(ba.data(), ba.size());
|
||||||
|
%PYARG_0 = PyString_FromStringAndSize(ba.constData(), ba.size());
|
||||||
|
</inject-code>
|
||||||
|
<modify-argument index="1">
|
||||||
|
<remove-argument />
|
||||||
|
</modify-argument>
|
||||||
|
<modify-argument index="return">
|
||||||
|
<replace-type modified-type="PyObject"/>
|
||||||
|
<conversion-rule class="native">
|
||||||
|
%RETURN_TYPE %out;
|
||||||
|
if (!PyString_Check(%PYARG_0)) {
|
||||||
|
%out = -1;
|
||||||
|
} else {
|
||||||
|
%out = PyString_GET_SIZE((PyObject*)%PYARG_0);
|
||||||
|
qstrncpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out + 1);
|
||||||
|
}
|
||||||
|
</conversion-rule>
|
||||||
|
</modify-argument>
|
||||||
|
</modify-function>
|
||||||
|
<modify-function signature="readLine(char*, qint64)" allow-thread="yes">
|
||||||
|
<inject-code class="target">
|
||||||
|
QByteArray ba;
|
||||||
|
ba.resize(%2);
|
||||||
|
%CPPSELF.%FUNCTION_NAME(ba.data(), ba.size());
|
||||||
|
%PYARG_0 = PyString_FromStringAndSize(ba.constData(), ba.size());
|
||||||
|
</inject-code>
|
||||||
|
<modify-argument index="1">
|
||||||
|
<remove-argument />
|
||||||
|
</modify-argument>
|
||||||
|
<modify-argument index="return">
|
||||||
|
<replace-type modified-type="PyObject"/>
|
||||||
|
<conversion-rule class="native">
|
||||||
|
%RETURN_TYPE %out;
|
||||||
|
if (!PyString_Check(%PYARG_0)) {
|
||||||
|
%out = -1;
|
||||||
|
} else {
|
||||||
|
%out = PyString_GET_SIZE((PyObject*)%PYARG_0);
|
||||||
|
qstrncpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out + 1);
|
||||||
|
}
|
||||||
|
</conversion-rule>
|
||||||
|
</modify-argument>
|
||||||
|
</modify-function>
|
||||||
</object-type>
|
</object-type>
|
||||||
<object-type name="QProcess">
|
<object-type name="QProcess">
|
||||||
<enum-type name="ExitStatus"/>
|
<enum-type name="ExitStatus"/>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ PYSIDE_TEST(bug_515.py)
|
||||||
PYSIDE_TEST(bug_656.py)
|
PYSIDE_TEST(bug_656.py)
|
||||||
PYSIDE_TEST(bug_699.py)
|
PYSIDE_TEST(bug_699.py)
|
||||||
PYSIDE_TEST(bug_706.py)
|
PYSIDE_TEST(bug_706.py)
|
||||||
|
PYSIDE_TEST(bug_723.py)
|
||||||
PYSIDE_TEST(bug_724.py)
|
PYSIDE_TEST(bug_724.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)
|
||||||
|
|
|
||||||
50
tests/QtCore/bug_723.py
Normal file
50
tests/QtCore/bug_723.py
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
import unittest
|
||||||
|
from PySide.QtCore import *
|
||||||
|
|
||||||
|
class MyFileEngine (QAbstractFileEngine):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
QAbstractFileEngine.__init__(self)
|
||||||
|
self.contents = "Foo bar for the win!"
|
||||||
|
self.pos = 0
|
||||||
|
|
||||||
|
def open(self, mode):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def read(self, maxlen):
|
||||||
|
print "Reading... to return ", self.contents[self.pos:maxlen]
|
||||||
|
|
||||||
|
if self.pos > len(self.contents):
|
||||||
|
return -1
|
||||||
|
|
||||||
|
res = self.contents[self.pos:maxlen]
|
||||||
|
self.pos += len(res)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def readLine(self, maxlen):
|
||||||
|
return self.contents[self.pos:maxlen]
|
||||||
|
|
||||||
|
class MyFileEngineHandler (QAbstractFileEngineHandler):
|
||||||
|
|
||||||
|
def create(self, fileName):
|
||||||
|
print "hey ho: ", fileName
|
||||||
|
if fileName.startswith("foo:/"):
|
||||||
|
return MyFileEngine()
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class TestBug723 (unittest.TestCase):
|
||||||
|
|
||||||
|
def testIt(self):
|
||||||
|
fh = MyFileEngineHandler()
|
||||||
|
|
||||||
|
f = QFile("foo:/bar")
|
||||||
|
|
||||||
|
assert(f.open(QFile.ReadOnly | QFile.Text))
|
||||||
|
contents = f.readAll()
|
||||||
|
self.assertEqual(contents, "Foo bar for the win!")
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue