summaryrefslogtreecommitdiffstats
path: root/gio
diff options
context:
space:
mode:
authorGian Mario Tagliaretti <gianmt@gnome.org>2009-06-08 11:45:11 +0200
committerGian Mario Tagliaretti <gianmt@gnome.org>2009-06-09 00:10:08 +0200
commitdfbdf23633a772e78b47b0e7b0c3e3b87855d9ff (patch)
tree415a9a91458c5d592ba80b4bdc450b4caadbdeab /gio
parentfcc3cb0e167789746a1a9db0cba54ea7a97c7259 (diff)
downloadpygobject-dfbdf23633a772e78b47b0e7b0c3e3b87855d9ff.tar.gz
pygobject-dfbdf23633a772e78b47b0e7b0c3e3b87855d9ff.tar.xz
pygobject-dfbdf23633a772e78b47b0e7b0c3e3b87855d9ff.zip
Wrap gio.memory_input_stream_new_from_data
Add the wrapper for gio.memory_input_stream_new_from_data including docs and a test.
Diffstat (limited to 'gio')
-rw-r--r--gio/Makefile.am1
-rw-r--r--gio/ginputstream.override34
-rw-r--r--gio/gio.override1
-rw-r--r--gio/gmemoryinputstream.override91
4 files changed, 93 insertions, 34 deletions
diff --git a/gio/Makefile.am b/gio/Makefile.am
index 1fd193a..ae1613e 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -48,6 +48,7 @@ GIO_OVERRIDES = \
gfileoutputstream.override \
gicon.override \
ginputstream.override \
+ gmemoryinputstream.override \
gmount.override \
goutputstream.override \
gvolume.override \
diff --git a/gio/ginputstream.override b/gio/ginputstream.override
index 075a20c..762a47a 100644
--- a/gio/ginputstream.override
+++ b/gio/ginputstream.override
@@ -293,40 +293,6 @@ _wrap_g_input_stream_close_async(PyGObject *self,
return NULL;
}
%%
-override g_memory_input_stream_add_data kwargs
-static PyObject *
-_wrap_g_memory_input_stream_add_data(PyGObject *self,
- PyObject *args,
- PyObject *kwargs)
-{
- static char *kwlist[] = { "data", NULL };
- PyObject *data;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:gio.MemoryInputStream.add_data",
- kwlist, &data))
- return NULL;
-
- if (data != Py_None) {
- char *copy;
- int length;
-
- if (!PyString_Check(data)) {
- PyErr_SetString(PyExc_TypeError, "data must be a string or None");
- return NULL;
- }
-
- length = PyString_Size(data);
- copy = g_malloc(length);
- memcpy(copy, PyString_AsString(data), length);
-
- g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(self->obj),
- copy, length, (GDestroyNotify) g_free);
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-%%
override g_input_stream_skip_async kwargs
static PyObject *
_wrap_g_input_stream_skip_async(PyGObject *self,
diff --git a/gio/gio.override b/gio/gio.override
index a175760..ac0515e 100644
--- a/gio/gio.override
+++ b/gio/gio.override
@@ -239,6 +239,7 @@ include
gfileinputstream.override
gfileoutputstream.override
gicon.override
+ gmemoryinputstream.override
gmount.override
ginputstream.override
goutputstream.override
diff --git a/gio/gmemoryinputstream.override b/gio/gmemoryinputstream.override
new file mode 100644
index 0000000..0495338
--- /dev/null
+++ b/gio/gmemoryinputstream.override
@@ -0,0 +1,91 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * pygobject - Python bindings for GObject
+ * Copyright (C) 2008 Johan Dahlin
+ * Copyright (C) 2009 Gian Mario Tagliaretti
+ *
+ * gmemoryinputstream.override: module overrides for GMemoryInputStream
+ *
+ * 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_memory_input_stream_add_data kwargs
+static PyObject *
+_wrap_g_memory_input_stream_add_data(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "data", NULL };
+ PyObject *data;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:gio.MemoryInputStream.add_data",
+ kwlist, &data))
+ return NULL;
+
+ if (data != Py_None) {
+ char *copy;
+ int length;
+
+ if (!PyString_Check(data)) {
+ PyErr_SetString(PyExc_TypeError, "data must be a string or None");
+ return NULL;
+ }
+
+ length = PyString_Size(data);
+ copy = g_malloc(length);
+ memcpy(copy, PyString_AsString(data), length);
+
+ g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(self->obj),
+ copy, length, (GDestroyNotify) g_free);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override g_memory_input_stream_new_from_data kwargs
+static PyObject *
+_wrap_g_memory_input_stream_new_from_data(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "data", NULL };
+ PyObject *data;
+ GInputStream *stream = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:gio.memory_input_stream_new_from_data",
+ kwlist, &data))
+ return NULL;
+
+ if (data != Py_None) {
+ char *copy;
+ int length;
+
+ if (!PyString_Check(data)) {
+ PyErr_SetString(PyExc_TypeError, "data must be a string or None");
+ return NULL;
+ }
+
+ length = PyString_Size(data);
+ copy = g_malloc(length);
+ memcpy(copy, PyString_AsString(data), length);
+
+ stream = g_memory_input_stream_new_from_data(copy, length,
+ (GDestroyNotify) g_free);
+ }
+
+ return pygobject_new((GObject *)stream);
+}