summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGian Mario Tagliaretti <gianmt@gnome.org>2009-05-04 23:40:28 +0200
committerGian Mario Tagliaretti <gianmt@gnome.org>2009-05-05 00:01:26 +0200
commitd58322b84d47da7905f95b43e9e0daf9f7c4b507 (patch)
tree7813dc892994566c4acc2857b631e904fdcde6eb
parent2311187824d1b48a996ee2620fd3c9a63e3edd66 (diff)
downloadpygobject-d58322b84d47da7905f95b43e9e0daf9f7c4b507.tar.gz
pygobject-d58322b84d47da7905f95b43e9e0daf9f7c4b507.tar.xz
pygobject-d58322b84d47da7905f95b43e9e0daf9f7c4b507.zip
Wrap gio.InputStream.skip_async()
wrap gio.InputStream.skip_async() and add a test.
-rw-r--r--gio/ginputstream.override50
-rw-r--r--tests/test_gio.py20
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,
+ &notify->callback,
+ &io_priority,
+ &pycancellable,
+ &notify->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()),