[pygobject] Wrap gio.InputStream.skip_async()
- From: Gian Mario Tagliaretti <gianmt src gnome org>
- To: svn-commits-list gnome org
- Subject: [pygobject] Wrap gio.InputStream.skip_async()
- Date: Mon, 4 May 2009 18:01:45 -0400 (EDT)
commit d58322b84d47da7905f95b43e9e0daf9f7c4b507
Author: Gian Mario Tagliaretti <gianmt gnome org>
Date: Mon May 4 23:40:28 2009 +0200
Wrap gio.InputStream.skip_async()
wrap gio.InputStream.skip_async() and add a test.
---
gio/ginputstream.override | 50 ++++++++++++++++++++++++++++++++++++++++++++-
tests/test_gio.py | 20 ++++++++++++++++++
2 files changed, 69 insertions(+), 1 deletions(-)
diff --git a/gio/ginputstream.override b/gio/ginputstream.override
index 4a0878c..13ec37f 100644
--- a/gio/ginputstream.override
+++ b/gio/ginputstream.override
@@ -391,4 +391,52 @@ _wrap_g_memory_input_stream_add_data(PyGObject *self,
Py_INCREF(Py_None);
return Py_None;
}
-/* GInputStream.skip_async: No ArgType for GAsyncReadyCallback */
+%%
+override g_input_stream_skip_async kwargs
+static PyObject *
+_wrap_g_input_stream_skip_async(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "count", "callback", "io_priority",
+ "cancellable", "user_data", NULL };
+ long count = -1;
+ int io_priority = G_PRIORITY_DEFAULT;
+ PyGObject *pycancellable = NULL;
+ GCancellable *cancellable;
+ PyGIONotify *notify;
+
+ notify = pygio_notify_new();
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "lO|iOO:InputStream.skip_async",
+ kwlist,
+ &count,
+ ¬ify->callback,
+ &io_priority,
+ &pycancellable,
+ ¬ify->data))
+ goto error;
+
+ if (!pygio_notify_callback_is_valid(notify))
+ goto error;
+
+ if (!pygio_check_cancellable(pycancellable, &cancellable))
+ goto error;
+
+ pygio_notify_reference_callback(notify);
+
+ g_input_stream_skip_async(G_INPUT_STREAM(self->obj),
+ notify->buffer_size,
+ io_priority,
+ cancellable,
+ (GAsyncReadyCallback) async_result_callback_marshal,
+ notify);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+
+ error:
+ pygio_notify_free(notify);
+ return NULL;
+}
diff --git a/tests/test_gio.py b/tests/test_gio.py
index 7534ac0..d36c213 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -580,6 +580,26 @@ class TestInputStream(unittest.TestCase):
50),
some_data)
+ def testSkip(self):
+ self.stream.skip(2)
+ res = self.stream.read()
+ self.assertEqual(res, "sting")
+
+ def testSkipAsync(self):
+ def callback(stream, result):
+ try:
+ size = stream.skip_finish(result)
+ self.assertEqual(size, 2)
+ res = stream.read()
+ self.assertEqual(res, "sting")
+ finally:
+ loop.quit()
+
+ self.stream.skip_async(2, callback)
+
+ loop = glib.MainLoop()
+ loop.run()
+
def test_read_part(self):
self.assertEquals(self._read_in_loop(self.stream,
lambda: self.stream.read_part()),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]