From: Evan Nemerson Date: Wed, 18 Jan 2012 01:09:02 +0000 (-0800) Subject: glib-2.0: add GByteArray bindings X-Git-Tag: 0.15.1~35 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=aa0b2bd959960e2a728d7ad67d22f9e1793e49ab;p=thirdparty%2Fvala.git glib-2.0: add GByteArray bindings --- diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index 5532d337f..290419c43 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -4101,6 +4101,43 @@ namespace GLib { private uint len; } + [Compact] + [CCode (cprefix = "g_bytes_", ref_function = "g_bytes_ref", unref_function = "g_bytes_unref", type_id = "G_TYPE_BYTES")] + public class Bytes { + public Bytes ([CCode (array_length_type = "gsize")] uint8[] data); + public Bytes.take ([CCode (array_length_type = "gsize")] owned uint8[] data); + public Bytes.static ([CCode (array_length_type = "gsize")] uint8[] data); + public Bytes.with_free_func ([CCode (array_length_type = "gsize")] owned uint8[] data, GLib.DestroyNotify? free_func = GLib.g_free); + public Bytes.from_bytes (GLib.Bytes bytes, size_t offset, size_t length); + + [CCode (array_length_type = "gsize")] + public unowned uint8[] get_data (); + public size_t get_size (); + public uint hash (); + public int compare (GLib.Bytes bytes2); + public static uint8[] unref_to_data (owned GLib.Bytes bytes); + public static GLib.ByteArray unref_to_array (owned GLib.Bytes bytes); + + [CCode (cname = "_vala_g_bytes_get")] + public uint8 get (int index) { + unowned uint8[] data = this.get_data (); + return data[index]; + } + + [CCode (cname = "_vala_g_bytes_slice")] + public GLib.Bytes slice (int start, int end) { + unowned uint8[] data = this.get_data (); + return new GLib.Bytes (data[start:end]); + } + + public int length { + [CCode (cname = "_vala_g_bytes_get_length")] + get { + return (int) this.get_size (); + } + } + } + /* Byte Arrays */ [Compact]