summaryrefslogtreecommitdiff
path: root/gio/gmemoryoutputstream.override
blob: 7614045f823ab1f04c9e616568321c898f857aad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* -*- Mode: C; c-basic-offset: 4 -*-
 * pygobject - Python bindings for GObject
 * Copyright (C) 2008  Johan Dahlin
 *
 *   gmemoryoutputstream.override: module overrides for GMemoryOutputStream
 *
 * 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_output_stream_new noargs
static int
_wrap_g_memory_output_stream_new(PyGObject *self)
{
    self->obj = (GObject *)g_memory_output_stream_new(NULL, 0, g_realloc, g_free);

    if (!self->obj) {
        PyErr_SetString(PyExc_RuntimeError, "could not create gio.MemoryOutputStream object");
        return -1;
    }

    pygobject_register_wrapper((PyObject *)self);
    return 0;
}
%%
override g_memory_output_stream_get_data noargs
static PyObject *
_wrap_g_memory_output_stream_get_data(PyGObject *self)
{
    GMemoryOutputStream *stream = G_MEMORY_OUTPUT_STREAM(self->obj);
    return PyString_FromStringAndSize(g_memory_output_stream_get_data(stream),
				      g_seekable_tell(G_SEEKABLE(stream)));
}