diff options
| author | Paul Pogonyshev <pogonyshev@gmx.net> | 2008-08-12 20:00:48 +0000 |
|---|---|---|
| committer | Paul Pogonyshev <paulp@src.gnome.org> | 2008-08-12 20:00:48 +0000 |
| commit | 9ecb2ef1203b8667f4c05798f5bf9306f599bbab (patch) | |
| tree | 0d5b2df37621c7e650ecd32b9da7e7af1133dfa2 /gio | |
| parent | ad7a6f15aafaf6d962ebbd2a8431fd17e6abfc30 (diff) | |
| download | pygobject-9ecb2ef1203b8667f4c05798f5bf9306f599bbab.tar.gz pygobject-9ecb2ef1203b8667f4c05798f5bf9306f599bbab.tar.xz pygobject-9ecb2ef1203b8667f4c05798f5bf9306f599bbab.zip | |
Bug 547484 – wrap gio.DataInputStream.read_line and ...read_until
2008-08-12 Paul Pogonyshev <pogonyshev@gmx.net>
Bug 547484 – wrap gio.DataInputStream.read_line and ...read_until
* tests/test_gio.py (TestDataInputStream): New test case.
* gio/ginputstream.override (_wrap_g_data_input_stream_read_line)
(_wrap_g_data_input_stream_read_until): New functions.
svn path=/trunk/; revision=946
Diffstat (limited to 'gio')
| -rw-r--r-- | gio/ginputstream.override | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/gio/ginputstream.override b/gio/ginputstream.override index d345d27..44378cd 100644 --- a/gio/ginputstream.override +++ b/gio/ginputstream.override @@ -286,6 +286,71 @@ _wrap_g_input_stream_close_async(PyGObject *self, return Py_None; } %% +override g_data_input_stream_read_line kwargs +static PyObject * +_wrap_g_data_input_stream_read_line(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "cancellable", NULL }; + PyGObject *pycancellable = NULL; + GCancellable *cancellable; + char *line; + gsize length; + PyObject *py_line; + GError *error = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O:gio.DataInputStream.read_line", + kwlist, &pycancellable)) + return NULL; + + if (!pygio_check_cancellable(pycancellable, &cancellable)) + return NULL; + + line = g_data_input_stream_read_line(G_DATA_INPUT_STREAM(self->obj), + &length, cancellable, &error); + if (pyg_error_check(&error)) + return NULL; + + py_line = PyString_FromStringAndSize(line, length); + g_free(line); + return py_line; +} +%% +override g_data_input_stream_read_until kwargs +static PyObject * +_wrap_g_data_input_stream_read_until(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "stop_chars", "cancellable", NULL }; + const char *stop_chars; + PyGObject *pycancellable = NULL; + GCancellable *cancellable; + char *line; + gsize length; + PyObject *py_line; + GError *error = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "s|O:gio.DataInputStream.read_line", + kwlist, &stop_chars, &pycancellable)) + return NULL; + + if (!pygio_check_cancellable(pycancellable, &cancellable)) + return NULL; + + line = g_data_input_stream_read_until(G_DATA_INPUT_STREAM(self->obj), + stop_chars, &length, cancellable, &error); + if (pyg_error_check(&error)) + return NULL; + + py_line = PyString_FromStringAndSize(line, length); + g_free(line); + return py_line; +} +%% override g_memory_input_stream_add_data kwargs static PyObject * _wrap_g_memory_input_stream_add_data(PyGObject *self, |
