[libgsf] Introspection fixes.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] Introspection fixes.
- Date: Mon, 25 Feb 2013 00:40:11 +0000 (UTC)
commit e6a0255ed33a1c5bd9792060f0462b326249260f
Author: Morten Welinder <terra gnome org>
Date: Sun Feb 24 19:39:04 2013 -0500
Introspection fixes.
gsf/gsf-infile.c | 9 ++++-----
gsf/gsf-input.c | 48 +++++++++++++++++++++++++++++++++++++++++++-----
gsf/gsf-input.h | 4 ++++
gsf/gsf-output.c | 5 +++--
4 files changed, 54 insertions(+), 12 deletions(-)
---
diff --git a/gsf/gsf-infile.c b/gsf/gsf-infile.c
index 8ad1a10..eb928b0 100644
--- a/gsf/gsf-infile.c
+++ b/gsf/gsf-infile.c
@@ -44,13 +44,12 @@ gsf_infile_num_children (GsfInfile *infile)
/**
* gsf_infile_name_by_index:
- * @infile:
- * @i:
+ * @infile: An #GsfInfile
+ * @i: zero-based index of child to find.
*
- * Returns: the utf8 encoded name of the @i-th child
- * <emphasis>DO NOT FREE THE STRING.</emphasis>
+ * Returns: (transfer none) the utf8 encoded name of the @i-th child
**/
-char const *
+const gchar *
gsf_infile_name_by_index (GsfInfile *infile, int i)
{
g_return_val_if_fail (infile != NULL, NULL);
diff --git a/gsf/gsf-input.c b/gsf/gsf-input.c
index 9d20d05..b89c9bd 100644
--- a/gsf/gsf-input.c
+++ b/gsf/gsf-input.c
@@ -166,7 +166,8 @@ GSF_CLASS_ABSTRACT (GsfInput, gsf_input,
*
* The name of the input stream.
*
- * Returns: @input's name in utf8 form, or %NULL if it has no name.
+ * Returns: (transfer none) @input's name in utf8 form, or %NULL if it
+ * has no name.
**/
char const *
gsf_input_name (GsfInput *input)
@@ -285,18 +286,19 @@ gsf_input_eof (GsfInput *input)
}
/**
- * gsf_input_read:
+ * gsf_input_read: (skip)
* @input: the input stream
* @num_bytes: number of bytes to read
- * @optional_buffer: %NULL, or pointer to destination memory area
+ * @optional_buffer: Pointer to destination memory area
*
* Read at least @num_bytes. Does not change the current position if there
* is an error. Will only read if the entire amount can be read. Invalidates
* the buffer associated with previous calls to gsf_input_read.
*
- * Returns: pointer to the buffer or %NULL if there is an error or 0 bytes are
- * requested.
+ * Returns: pointer to the buffer or %NULL if there is an error or 0
+ * bytes are requested.
**/
+
guint8 const *
gsf_input_read (GsfInput *input, size_t num_bytes, guint8 *optional_buffer)
{
@@ -316,6 +318,42 @@ gsf_input_read (GsfInput *input, size_t num_bytes, guint8 *optional_buffer)
}
/**
+ * gsf_input_read0:
+ * @input: the input stream
+ * @num_bytes: (in) number of bytes to read
+ * @bytes_read: (out) copy of @num_bytes
+ *
+ * Read @num_bytes. Does not change the current position if there
+ * is an error. Will only read if the entire amount can be read.
+ *
+ * Returns: (array length=bytes_read) (element-type guint8) (transfer full)
+ * the data read.
+ *
+ * Rename to: gsf_input_read
+ **/
+
+guint8 *
+gsf_input_read0 (GsfInput *input, size_t num_bytes, size_t *bytes_read)
+{
+ guint8 *res;
+
+ g_return_val_if_fail (input != NULL, FALSE);
+ g_return_val_if_fail (bytes_read != NULL, FALSE);
+
+ *bytes_read = num_bytes;
+
+ if (num_bytes > (size_t)gsf_input_remaining (input))
+ return NULL;
+
+ res = g_new (guint8, num_bytes);
+ if (gsf_input_read (input, num_bytes, res))
+ return res;
+
+ g_free (res);
+ return NULL;
+}
+
+/**
* gsf_input_remaining:
* @input: the input stream
*
diff --git a/gsf/gsf-input.h b/gsf/gsf-input.h
index 66cb41d..969dc3c 100644
--- a/gsf/gsf-input.h
+++ b/gsf/gsf-input.h
@@ -43,6 +43,10 @@ gsf_off_t gsf_input_size (GsfInput *input);
gboolean gsf_input_eof (GsfInput *input);
guint8 const *gsf_input_read (GsfInput *input, size_t num_bytes,
guint8 *optional_buffer);
+/* For bindings _only_! */
+guint8 * gsf_input_read0 (GsfInput *input, size_t num_bytes,
+ size_t *bytes_read);
+
gsf_off_t gsf_input_remaining (GsfInput *input);
gsf_off_t gsf_input_tell (GsfInput *input);
gboolean gsf_input_seek (GsfInput *input,
diff --git a/gsf/gsf-output.c b/gsf/gsf-output.c
index 55491c3..05b85e4 100644
--- a/gsf/gsf-output.c
+++ b/gsf/gsf-output.c
@@ -168,7 +168,8 @@ GSF_CLASS_ABSTRACT (GsfOutput, gsf_output,
*
* Give the name of @output.
*
- * Returns: @output's name in utf8 form, DO NOT FREE THIS STRING
+ * Returns: (transfer none) @output's name in utf8 form, DO NOT FREE
+ * THIS STRING
**/
char const *
gsf_output_name (GsfOutput const *output)
@@ -334,7 +335,7 @@ gsf_output_inc_cur_offset (GsfOutput *output, gsf_off_t num_bytes)
* gsf_output_write:
* @output: Output stream
* @num_bytes: Number of bytes to write
- * @data: Data to write.
+ * @data: (in) (array length=num_bytes): Data to write.
*
* Write @num_bytes of @data to @output.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]