]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
xcb: Add helper methods for GetPropertyReply
authorRobert Ancell <robert.ancell@canonical.com>
Fri, 16 May 2014 04:51:19 +0000 (16:51 +1200)
committerRobert Ancell <robert.ancell@canonical.com>
Sun, 1 Jun 2014 10:21:31 +0000 (18:21 +0800)
Add helper methods for GetPropertyReply so you don't have to access a void
pointer.

https://bugzilla.gnome.org/show_bug.cgi?id=730230

vapi/xcb.vapi

index 6466d827e71d3445526d9a4f2388019ac3a2f901..7542a3684391dc2837782aed903b38bbad91e5a3 100644 (file)
@@ -1251,6 +1251,38 @@ namespace Xcb {
                }
        }
 
+       [CCode (cname = "xcb_get_property_reply_t", ref_function = "", unref_function = "free")]
+       public class GetPropertyReply {
+               public uint8 format;
+               public Atom type;
+               public uint32 bytes_after;
+               private uint32 value_len;
+               [CCode (cname = "xcb_get_property_value")]
+               public unowned void *value ();
+               public string value_as_string () {
+                       GLib.assert (format == 8);
+                       return "%.*s".printf (value_len, value ());
+               }
+               public unowned uint8[] value_as_uint8_array () {
+                       GLib.assert (format == 8);
+                       unowned uint8[] res = (uint8[]) value ();
+                       res.length = (int) value_len;
+                       return res;
+               }
+               public unowned uint16[] value_as_uint16_array () {
+                       GLib.assert (format == 16);
+                       unowned uint16[] res = (uint16[]) value ();
+                       res.length = (int) value_len;
+                       return res;
+               }
+               public unowned uint32[] value_as_uint32_array () {
+                       GLib.assert (format == 32);
+                       unowned uint32[] res = (uint32[]) value ();
+                       res.length = (int) value_len;
+                       return res;
+               }
+       }
+
        [SimpleType]
        [IntegerType (rank = 9)]
        [CCode (cname = "xcb_list_fonts_with_info_cookie_t", has_type_id = false)]