summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGian Mario Tagliaretti <gianmt@gnome.org>2009-06-09 00:08:21 +0200
committerGian Mario Tagliaretti <gianmt@gnome.org>2009-06-09 00:10:09 +0200
commit407b0e909056f15960e6a4e549896d786ce0a0b2 (patch)
treebe0d917549f33fb281fa7df07c84bfe10694235a
parentb7c96b41b287685fe57504e0add3a6f16e649975 (diff)
downloadpygobject-407b0e909056f15960e6a4e549896d786ce0a0b2.tar.gz
pygobject-407b0e909056f15960e6a4e549896d786ce0a0b2.tar.xz
pygobject-407b0e909056f15960e6a4e549896d786ce0a0b2.zip
Wrap gio.BufferedInputStream.fill_async
Wrap the method gio.BufferedInputStream.fill_async and add a test
-rw-r--r--gio/Makefile.am1
-rw-r--r--gio/gbufferedinputstream.override70
-rw-r--r--gio/gio.override1
-rw-r--r--tests/test_gio.py25
4 files changed, 97 insertions, 0 deletions
diff --git a/gio/Makefile.am b/gio/Makefile.am
index ccb8000..53f5024 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -38,6 +38,7 @@ GIO_OVERRIDES = \
gio.override \
gappinfo.override \
gapplaunchcontext.override \
+ gbufferedinputstream.override \
gdatainputstream.override \
gdrive.override \
gfile.override \
diff --git a/gio/gbufferedinputstream.override b/gio/gbufferedinputstream.override
new file mode 100644
index 0000000..cb76da4
--- /dev/null
+++ b/gio/gbufferedinputstream.override
@@ -0,0 +1,70 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * pygobject - Python bindings for GObject
+ * Copyright (C) 2009 Gian Mario Tagliaretti
+ *
+ * gbufferedinputstream.override: module overrides for GBufferedInputStream
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+%%
+override g_buffered_input_stream_fill_async kwargs
+static PyObject *
+_wrap_g_buffered_input_stream_fill_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:gio.BufferedInputStream.fill_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_buffered_input_stream_fill_async(G_INPUT_STREAM(self->obj),
+ count,
+ 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/gio/gio.override b/gio/gio.override
index 3363a0f..78d3688 100644
--- a/gio/gio.override
+++ b/gio/gio.override
@@ -230,6 +230,7 @@ async_result_callback_marshal(GObject *source_object,
include
gappinfo.override
gapplaunchcontext.override
+ gbufferedinputstream.override
gdatainputstream.override
gdrive.override
gfile.override
diff --git a/tests/test_gio.py b/tests/test_gio.py
index de5409f..1578d58 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -1042,3 +1042,28 @@ class TestFileOutputStream(unittest.TestCase):
loop = glib.MainLoop()
loop.run()
+
+class TestBufferedInputStream(unittest.TestCase):
+ def setUp(self):
+ self._f = open("buffer.txt", "w+")
+ self._f.write("testing")
+ self._f.seek(0)
+ stream = gio.unix.InputStream(self._f.fileno(), False)
+ self.buffered = gio.BufferedInputStream(stream)
+
+ def tearDown(self):
+ self._f.close()
+ os.unlink("buffer.txt")
+
+ def test_fill_async(self):
+ def callback(stream, result):
+ try:
+ size = stream.fill_finish(result)
+ self.failUnlessEqual(size, 4)
+ finally:
+ loop.quit()
+
+ self.buffered.fill_async(4, callback)
+
+ loop = glib.MainLoop()
+ loop.run()