summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Dahlin <jdahlin@async.com.br>2008-04-11 15:37:29 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-04-11 15:37:29 +0000
commit74ffca1fdd1a30eff58cadf766d0f4f5a504e3db (patch)
tree776d409f4e428fa64e29419c559d0893aad4f279
parent5f743cddfc05aecf25b9713ae84259d2583b499e (diff)
downloadpygobject-74ffca1fdd1a30eff58cadf766d0f4f5a504e3db.tar.gz
pygobject-74ffca1fdd1a30eff58cadf766d0f4f5a504e3db.tar.xz
pygobject-74ffca1fdd1a30eff58cadf766d0f4f5a504e3db.zip
Move around the order of the callback argument to async methods, so it
2008-04-11 Johan Dahlin <jdahlin@async.com.br> * gio/gfile.override: * gio/ginputstream.override: * gio/goutputstream.override: * tests/test_gio.py: Move around the order of the callback argument to async methods, so it comes before priority and cancellable, which can have default values. svn path=/trunk/; revision=773
-rw-r--r--ChangeLog10
-rw-r--r--gio/gfile.override36
-rw-r--r--gio/ginputstream.override98
-rw-r--r--gio/goutputstream.override66
-rw-r--r--tests/test_gio.py16
5 files changed, 135 insertions, 91 deletions
diff --git a/ChangeLog b/ChangeLog
index a9063f0..6a202f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-04-11 Johan Dahlin <jdahlin@async.com.br>
+
+ * gio/gfile.override:
+ * gio/ginputstream.override:
+ * gio/goutputstream.override:
+ * tests/test_gio.py:
+ Move around the order of the callback argument to async methods,
+ so it comes before priority and cancellable, which can have default
+ values.
+
2008-04-08 Johan Dahlin <jdahlin@async.com.br>
* gio/Makefile.am:
diff --git a/gio/gfile.override b/gio/gfile.override
index e0280f4..f40271f 100644
--- a/gio/gfile.override
+++ b/gio/gfile.override
@@ -87,39 +87,31 @@ _wrap__file_init(PyGObject *self, PyObject *args, PyObject *kwargs)
%%
override g_file_read_async kwargs
static PyObject *
-_wrap_g_file_read_async(PyGObject *self, PyObject *args, PyObject *kwargs)
+_wrap_g_file_read_async(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
{
- static char *kwlist[] = { "io_priority", "cancellable", "callback",
- "user_data", NULL };
+ static char *kwlist[] = { "callback", "io_priority",
+ "cancellable", "user_data", NULL };
int io_priority = G_PRIORITY_DEFAULT;
- PyGObject *pycancellable;
+ PyGObject *pycancellable = NULL;
GCancellable *cancellable;
PyGAsyncRequestNotify *notify;
notify = g_slice_new0(PyGAsyncRequestNotify);
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "iOO|O:InputStream.read_async",
+ "O|iOO:InputStream.read_async",
kwlist,
+ &notify->callback,
&io_priority,
&pycancellable,
- &notify->callback,
&notify->data))
{
g_slice_free(PyGAsyncRequestNotify, notify);
return NULL;
}
- if ((PyObject*)pycancellable == Py_None)
- cancellable = NULL;
- else if (pygobject_check(pycancellable, &PyGCancellable_Type))
- cancellable = G_CANCELLABLE(pycancellable->obj);
- else
- {
- PyErr_SetString(PyExc_TypeError, "cancellable should be a gio.Cancellable");
- return NULL;
- }
-
if (!PyCallable_Check(notify->callback))
{
PyErr_SetString(PyExc_TypeError, "callback argument not callable");
@@ -129,6 +121,18 @@ _wrap_g_file_read_async(PyGObject *self, PyObject *args, PyObject *kwargs)
Py_INCREF(notify->callback);
Py_XINCREF(notify->data);
+ if (pycancellable == NULL || (PyObject*)pycancellable == Py_None)
+ cancellable = NULL;
+ else if (pygobject_check(pycancellable, &PyGCancellable_Type))
+ cancellable = G_CANCELLABLE(pycancellable->obj);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "cancellable should be a gio.Cancellable");
+ g_slice_free(PyGAsyncRequestNotify, notify);
+ return NULL;
+ }
+
g_file_read_async(G_FILE(self->obj),
io_priority,
cancellable,
diff --git a/gio/ginputstream.override b/gio/ginputstream.override
index 37f0225..0c21a12 100644
--- a/gio/ginputstream.override
+++ b/gio/ginputstream.override
@@ -81,21 +81,29 @@ _wrap_g_input_stream_read(PyGObject *self, PyObject *args, PyObject *kwargs)
static char *kwlist[] = { "count", "cancellable", NULL };
PyGObject *pycancellable = NULL;
PyObject *v;
-
GCancellable *cancellable;
long count = -1;
GError *error = NULL;
size_t bytesread, buffersize, chunksize;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "|lO!:InputStream.read",
+ "|lO:InputStream.read",
kwlist, &count,
- &PyGCancellable_Type, &pycancellable))
+ &pycancellable))
return NULL;
buffersize = BUFSIZE;
- cancellable = pycancellable ? G_CANCELLABLE(pycancellable->obj) : NULL;
+ if (pycancellable == NULL || (PyObject*)pycancellable == Py_None)
+ cancellable = NULL;
+ else if (pygobject_check(pycancellable, &PyGCancellable_Type))
+ cancellable = G_CANCELLABLE(pycancellable->obj);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "cancellable should be a gio.Cancellable");
+ return NULL;
+ }
v = PyString_FromStringAndSize((char *)NULL, buffersize);
if (v == NULL)
@@ -147,40 +155,33 @@ _wrap_g_input_stream_read(PyGObject *self, PyObject *args, PyObject *kwargs)
%%
override g_input_stream_read_async kwargs
static PyObject *
-_wrap_g_input_stream_read_async(PyGObject *self, PyObject *args, PyObject *kwargs)
+_wrap_g_input_stream_read_async(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
{
- static char *kwlist[] = { "count", "io_priority", "cancellable", "callback",
- "user_data", NULL };
+ static char *kwlist[] = { "callback", "count", "io_priority",
+ "cancellable", "user_data", NULL };
long count = -1;
int io_priority = G_PRIORITY_DEFAULT;
- PyGObject *pycancellable;
+ PyGObject *pycancellable = NULL;
GCancellable *cancellable;
PyGAsyncRequestNotifyRead *notify;
notify = g_slice_new0(PyGAsyncRequestNotifyRead);
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "liOO|O:InputStream.read_async",
- kwlist, &count,
+ "lO|iOO:InputStream.read_async",
+ kwlist,
+ &count,
+ &notify->callback,
&io_priority,
&pycancellable,
- &notify->callback,
&notify->data))
{
g_slice_free(PyGAsyncRequestNotifyRead, notify);
return NULL;
}
- if ((PyObject*)pycancellable == Py_None)
- cancellable = NULL;
- else if (pygobject_check(pycancellable, &PyGCancellable_Type))
- cancellable = G_CANCELLABLE(pycancellable->obj);
- else
- {
- PyErr_SetString(PyExc_TypeError, "cancellable should be a gio.Cancellable");
- return NULL;
- }
-
if (!PyCallable_Check(notify->callback))
{
PyErr_SetString(PyExc_TypeError, "callback argument not callable");
@@ -190,6 +191,18 @@ _wrap_g_input_stream_read_async(PyGObject *self, PyObject *args, PyObject *kwarg
Py_INCREF(notify->callback);
Py_XINCREF(notify->data);
+ if (pycancellable == NULL || (PyObject*)pycancellable == Py_None)
+ cancellable = NULL;
+ else if (pygobject_check(pycancellable, &PyGCancellable_Type))
+ cancellable = G_CANCELLABLE(pycancellable->obj);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "cancellable should be a gio.Cancellable");
+ g_slice_free(PyGAsyncRequestNotifyRead, notify);
+ return NULL;
+ }
+
notify->buffer = PyString_FromStringAndSize((char *)NULL, count);
if (notify->buffer == NULL)
return NULL;
@@ -208,7 +221,9 @@ _wrap_g_input_stream_read_async(PyGObject *self, PyObject *args, PyObject *kwarg
%%
override g_input_stream_read_finish kwargs
static PyObject *
-_wrap_g_input_stream_read_finish(PyGObject *self, PyObject *args, PyObject *kwargs)
+_wrap_g_input_stream_read_finish(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
{
static char *kwlist[] = { "result", NULL };
PyGObject *result;
@@ -225,7 +240,8 @@ _wrap_g_input_stream_read_finish(PyGObject *self, PyObject *args, PyObject *kwar
return NULL;
- g_input_stream_read_finish(G_INPUT_STREAM(self->obj), G_ASYNC_RESULT(result->obj), &error);
+ g_input_stream_read_finish(G_INPUT_STREAM(self->obj),
+ G_ASYNC_RESULT(result->obj), &error);
if (pyg_error_check(&error))
return NULL;
@@ -237,39 +253,31 @@ _wrap_g_input_stream_read_finish(PyGObject *self, PyObject *args, PyObject *kwar
%%
override g_input_stream_close_async kwargs
static PyObject *
-_wrap_g_input_stream_close_async(PyGObject *self, PyObject *args, PyObject *kwargs)
+_wrap_g_input_stream_close_async(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
{
- static char *kwlist[] = { "io_priority", "cancellable",
- "callback", "user_data", NULL };
+ static char *kwlist[] = { "callback", "io_priority", "cancellable",
+ "user_data", NULL };
int io_priority = G_PRIORITY_DEFAULT;
- PyGObject *pycancellable;
+ PyGObject *pycancellable = NULL;
GCancellable *cancellable;
PyGAsyncRequestNotify *notify;
notify = g_slice_new0(PyGAsyncRequestNotify);
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "iOO|O:InputStream.close_async",
+ "O|iOO:InputStream.close_async",
kwlist,
+ &notify->callback,
&io_priority,
&pycancellable,
- &notify->callback,
&notify->data))
{
g_slice_free(PyGAsyncRequestNotify, notify);
return NULL;
}
- if ((PyObject*)pycancellable == Py_None)
- cancellable = NULL;
- else if (pygobject_check(pycancellable, &PyGCancellable_Type))
- cancellable = G_CANCELLABLE(pycancellable->obj);
- else
- {
- PyErr_SetString(PyExc_TypeError, "cancellable should be a gio.Cancellable");
- return NULL;
- }
-
if (!PyCallable_Check(notify->callback))
{
PyErr_SetString(PyExc_TypeError, "callback argument not callable");
@@ -279,6 +287,18 @@ _wrap_g_input_stream_close_async(PyGObject *self, PyObject *args, PyObject *kwar
Py_INCREF(notify->callback);
Py_XINCREF(notify->data);
+ if (pycancellable == NULL || (PyObject*)pycancellable == Py_None)
+ cancellable = NULL;
+ else if (pygobject_check(pycancellable, &PyGCancellable_Type))
+ cancellable = G_CANCELLABLE(pycancellable->obj);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "cancellable should be a gio.Cancellable");
+ g_slice_free(PyGAsyncRequestNotify, notify);
+ return NULL;
+ }
+
g_input_stream_close_async(G_INPUT_STREAM(self->obj),
io_priority,
cancellable,
diff --git a/gio/goutputstream.override b/gio/goutputstream.override
index cbf4efc..1125909 100644
--- a/gio/goutputstream.override
+++ b/gio/goutputstream.override
@@ -22,7 +22,9 @@
%%
override g_output_stream_write kwargs
static PyObject *
-_wrap_g_output_stream_write(PyGObject *self, PyObject *args, PyObject *kwargs)
+_wrap_g_output_stream_write(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
{
static char *kwlist[] = { "buffer", "cancellable", NULL };
PyGObject *pycancellable = NULL;
@@ -38,13 +40,14 @@ _wrap_g_output_stream_write(PyGObject *self, PyObject *args, PyObject *kwargs)
&PyGCancellable_Type, &pycancellable))
return NULL;
- if (!pycancellable)
+ if (pycancellable == NULL || (PyObject*)pycancellable == Py_None)
cancellable = NULL;
else if (pygobject_check(pycancellable, &PyGCancellable_Type))
cancellable = G_CANCELLABLE(pycancellable->obj);
else
{
- PyErr_SetString(PyExc_TypeError, "cancellable should be a gio.Cancellable");
+ PyErr_SetString(PyExc_TypeError,
+ "cancellable should be a gio.Cancellable");
return NULL;
}
@@ -61,41 +64,34 @@ _wrap_g_output_stream_write(PyGObject *self, PyObject *args, PyObject *kwargs)
%%
override g_output_stream_write_async kwargs
static PyObject *
-_wrap_g_output_stream_write_async(PyGObject *self, PyObject *args, PyObject *kwargs)
+_wrap_g_output_stream_write_async(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
{
- static char *kwlist[] = { "buffer", "io_priority", "cancellable",
- "callback", "user_data", NULL };
+ static char *kwlist[] = { "buffer", "callback", "io_priority", "cancellable",
+ "user_data", NULL };
gchar *buffer;
long count = -1;
int io_priority = G_PRIORITY_DEFAULT;
- PyGObject *pycancellable;
+ PyGObject *pycancellable = NULL;
GCancellable *cancellable;
PyGAsyncRequestNotify *notify;
notify = g_slice_new0(PyGAsyncRequestNotify);
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "s#iOO|O:OutputStream.write_async",
- kwlist, &buffer, &count,
+ "s#O|iOO:OutputStream.write_async",
+ kwlist, &buffer,
+ &count,
+ &notify->callback,
&io_priority,
&pycancellable,
- &notify->callback,
&notify->data))
{
g_slice_free(PyGAsyncRequestNotify, notify);
return NULL;
}
- if ((PyObject*)pycancellable == Py_None)
- cancellable = NULL;
- else if (pygobject_check(pycancellable, &PyGCancellable_Type))
- cancellable = G_CANCELLABLE(pycancellable->obj);
- else
- {
- PyErr_SetString(PyExc_TypeError, "cancellable should be a gio.Cancellable");
- return NULL;
- }
-
if (!PyCallable_Check(notify->callback))
{
PyErr_SetString(PyExc_TypeError, "callback argument not callable");
@@ -105,6 +101,17 @@ _wrap_g_output_stream_write_async(PyGObject *self, PyObject *args, PyObject *kwa
Py_INCREF(notify->callback);
Py_XINCREF(notify->data);
+ if (pycancellable == NULL || (PyObject*)pycancellable == Py_None)
+ cancellable = NULL;
+ else if (pygobject_check(pycancellable, &PyGCancellable_Type))
+ cancellable = G_CANCELLABLE(pycancellable->obj);
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "cancellable should be a gio.Cancellable");
+ return NULL;
+ }
+
g_output_stream_write_async(G_OUTPUT_STREAM(self->obj),
buffer,
count,
@@ -119,36 +126,39 @@ _wrap_g_output_stream_write_async(PyGObject *self, PyObject *args, PyObject *kwa
%%
override g_output_stream_close_async kwargs
static PyObject *
-_wrap_g_output_stream_close_async(PyGObject *self, PyObject *args, PyObject *kwargs)
+_wrap_g_output_stream_close_async(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
{
- static char *kwlist[] = { "io_priority", "cancellable",
- "callback", "user_data", NULL };
+ static char *kwlist[] = { "callback", "io_priority",
+ "cancellable", "user_data", NULL };
int io_priority = G_PRIORITY_DEFAULT;
- PyGObject *pycancellable;
+ PyGObject *pycancellable = NULL;
GCancellable *cancellable;
PyGAsyncRequestNotify *notify;
notify = g_slice_new0(PyGAsyncRequestNotify);
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "iOO|O:OutputStream.close_async",
+ "O|iOO:OutputStream.close_async",
kwlist,
+ &notify->callback,
&io_priority,
&pycancellable,
- &notify->callback,
&notify->data))
{
g_slice_free(PyGAsyncRequestNotify, notify);
return NULL;
}
- if ((PyObject*)pycancellable == Py_None)
+ if (pycancellable == NULL || (PyObject*)pycancellable == Py_None)
cancellable = NULL;
else if (pygobject_check(pycancellable, &PyGCancellable_Type))
cancellable = G_CANCELLABLE(pycancellable->obj);
else
{
- PyErr_SetString(PyExc_TypeError, "cancellable should be a gio.Cancellable");
+ PyErr_SetString(PyExc_TypeError,
+ "cancellable should be a gio.Cancellable");
return NULL;
}
diff --git a/tests/test_gio.py b/tests/test_gio.py
index e06cbb0..95d5206 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -27,7 +27,7 @@ class TestFile(unittest.TestCase):
finally:
loop.quit()
- self.file.read_async(0, None, callback)
+ self.file.read_async(callback)
loop = gobject.MainLoop()
loop.run()
@@ -90,7 +90,7 @@ class TestInputStream(unittest.TestCase):
finally:
loop.quit()
- self.stream.read_async(7, 0, None, callback)
+ self.stream.read_async(7, callback)
loop = gobject.MainLoop()
loop.run()
@@ -106,8 +106,8 @@ class TestInputStream(unittest.TestCase):
finally:
loop.quit()
- self.stream.read_async(10240, 0, None, callback)
- self.stream.read_async(10240, 0, None, callback)
+ self.stream.read_async(10240, callback)
+ self.stream.read_async(10240, callback)
loop = gobject.MainLoop()
loop.run()
@@ -122,7 +122,7 @@ class TestInputStream(unittest.TestCase):
finally:
loop.quit()
- self.stream.close_async(0, None, callback)
+ self.stream.close_async(callback)
loop = gobject.MainLoop()
loop.run()
@@ -153,7 +153,7 @@ class TestOutputStream(unittest.TestCase):
finally:
loop.quit()
- self.stream.write_async("testing", 0, None, callback)
+ self.stream.write_async("testing", callback)
loop = gobject.MainLoop()
loop.run()
@@ -167,7 +167,7 @@ class TestOutputStream(unittest.TestCase):
loop.quit()
self.stream.close()
- self.stream.write_async("testing", 0, None, callback)
+ self.stream.write_async("testing", callback)
loop = gobject.MainLoop()
loop.run()
@@ -181,7 +181,7 @@ class TestOutputStream(unittest.TestCase):
finally:
loop.quit()
- self.stream.close_async(0, None, callback)
+ self.stream.close_async(callback)
loop = gobject.MainLoop()
loop.run()