-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap gio.memory_input_stream_new_from_data
Add the wrapper for gio.memory_input_stream_new_from_data including docs and a test.
- Loading branch information
Showing
8 changed files
with
252 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<?xml version="1.0" standalone="no"?> | ||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" | ||
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> | ||
|
||
<refentry id="class-giomemoryinputstream"> | ||
<refnamediv> | ||
<refname>gio.MemoryInputStream</refname> | ||
<refpurpose>Base class for implementing streaming input</refpurpose> | ||
</refnamediv> | ||
|
||
<refsect1> | ||
<title>Synopsis</title> | ||
|
||
<classsynopsis language="python"> | ||
<ooclass><classname>gio.MemoryInputStream</classname></ooclass> | ||
<ooclass><classname><link linkend="class-gioinputstream">gio.InputStream</link></classname></ooclass> | ||
|
||
<constructorsynopsis language="python"> | ||
<methodname><link linkend="constructor-giomemoryinputstream">gio.MemoryInputStream</link></methodname> | ||
<methodparam></methodparam> | ||
</constructorsynopsis> | ||
|
||
|
||
<methodsynopsis language="python"> | ||
<methodname><link linkend="method-giomemoryinputstream--add-data">add_data</link></methodname> | ||
<methodparam><parameter role="keyword">data</parameter></methodparam> | ||
</methodsynopsis> | ||
|
||
</classsynopsis> | ||
|
||
<programlisting> | ||
<emphasis role="bold">Functions</emphasis> | ||
|
||
<methodsynopsis language="python"> | ||
<methodname><link linkend="function-gio--memory-input-stream-new-from-data">gio.memory_input_stream_new_from_data</link></methodname> | ||
<methodparam><parameter role="keyword">data</parameter></methodparam> | ||
</methodsynopsis></programlisting> | ||
|
||
</refsect1> | ||
|
||
<refsect1> | ||
<title>Ancestry</title> | ||
|
||
<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link> | ||
+-- <link linkend="class-gioinputstream">gio.InputStream</link> | ||
+-- <link linkend="class-giomemoryinputstream">gio.MemoryInputStream</link> | ||
</synopsis> | ||
|
||
</refsect1> | ||
|
||
<refsect1> | ||
<title>Implemented Interfaces</title> | ||
<para> | ||
<link linkend="class-giomemoryinputstream"><classname>gio.MemoryInputStream</classname></link> | ||
implements | ||
<link linkend="class-gioseekable"><classname>gio.Seekable</classname></link> | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1> | ||
<title>Description</title> | ||
|
||
<para> | ||
<link linkend="class-giomemoryinputstream"><classname>gio.MemoryInputStream</classname></link> | ||
is a class for using arbitrary memory chunks as input for GIO streaming input operations. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 id="constructor-giomemoryinputstream"> | ||
<title>Constructor</title> | ||
|
||
<programlisting><constructorsynopsis language="python"> | ||
<methodname>gio.MemoryInputStream</methodname> | ||
<methodparam><parameter role="keyword">icon</parameter></methodparam> | ||
</constructorsynopsis></programlisting> | ||
<variablelist> | ||
<varlistentry> | ||
<term><emphasis>Returns</emphasis> :</term> | ||
<listitem><simpara>a new | ||
<link linkend="class-giomemoryinputstream"><classname>gio.MemoryInputStream</classname></link>. | ||
</simpara></listitem> | ||
</varlistentry> | ||
</variablelist> | ||
|
||
<para> | ||
Creates an empty | ||
<link linkend="class-giomemoryinputstream"><classname>gio.MemoryInputStream</classname></link>. | ||
</para> | ||
|
||
</refsect1> | ||
|
||
<refsect1> | ||
<title>Methods</title> | ||
|
||
<refsect2 id="method-giomemoryinputstream--add-data"> | ||
<title>gio.MemoryInputStream.add_data</title> | ||
|
||
<programlisting><methodsynopsis language="python"> | ||
<methodname>add_data</methodname> | ||
<methodparam><parameter role="keyword">data</parameter></methodparam> | ||
</methodsynopsis></programlisting> | ||
|
||
<variablelist> | ||
<varlistentry> | ||
<term><parameter role="keyword">data</parameter> :</term> | ||
<listitem><simpara>input data. | ||
</simpara></listitem> | ||
</varlistentry> | ||
</variablelist> | ||
|
||
<para> | ||
The <methodname>add_data</methodname>() method appends data to data | ||
that can be read from the input stream | ||
</para> | ||
</refsect2> | ||
</refsect1> | ||
|
||
<refsect1> | ||
<title>Functions</title> | ||
|
||
<refsect2 id="function-gio--memory-input-stream-new-from-data"> | ||
<title>gio.memory_input_stream_new_from_data</title> | ||
|
||
<programlisting><methodsynopsis language="python"> | ||
<methodname>memory_input_stream_new_from_data</methodname> | ||
<methodparam><parameter role="keyword">data</parameter></methodparam> | ||
</methodsynopsis></programlisting> | ||
|
||
<variablelist> | ||
<varlistentry> | ||
<term><parameter>data</parameter> :</term> | ||
<listitem><simpara>input data. | ||
</simpara></listitem> | ||
</varlistentry> | ||
<varlistentry> | ||
<term><emphasis>Returns</emphasis> :</term> | ||
<listitem><simpara>A new | ||
<link linkend="class-giomemoryinputstream"><classname>gio.MemoryInputStream</classname></link> | ||
read from data | ||
</simpara></listitem> | ||
</varlistentry> | ||
</variablelist> | ||
|
||
<para> | ||
The <methodname>memory_input_stream_new_from_data</methodname>() function creates | ||
a new <link linkend="class-giomemoryinputstream"><classname>gio.MemoryInputStream</classname></link> | ||
with data in memory. | ||
</para> | ||
</refsect2> | ||
</refsect1> | ||
</refentry> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters