Paste: clay xcb

Author: elrood
Mode: text
Date: Sun, 5 Sep 2010 17:39:23
Plain Text |
record xcb_screen_t (
		root : UInt,
		default_colormap : UInt,
		white_pixel : UInt,
		black_pixel : UInt,
		current_input_masks : UInt,
		width_in_pixels : UShort,
		height_in_pixels : UShort,
		width_in_millimeters : UShort,
		height_in_millimeters : UShort,
		min_installed_maps : UShort,
		max_installed_maps : UShort,
		root_visual : UInt,
		backing_stores : CUChar,
		save_unders : CUChar,
		root_depth : CUChar,
		allowed_depths_len : CUChar,
		);

record xcb_screen_iterator_t (
		data : Pointer[xcb_screen_t],
		rem : Int,
		index : Int,
		);

record xcb_setup_t (
		status : CUChar,
		pad0 : CUChar,
		protocol_major_version : UShort,
		protocol_minor_version : UShort,
		length : UShort,
		release_number : UInt,
		resource_id_base : UInt,
		resource_id_mask : UInt,
		motion_buffer_size : UInt,
		vendor_len : UShort,
		maximum_request_length : UShort,
		roots_len : CUChar,
		pixmap_formats_len : CUChar,
		image_byte_order : CUChar,
		bitmap_format_bit_order : CUChar,
		bitmap_format_scanline_unit : CUChar,
		bitmap_format_scanline_pad : CUChar,
		min_keycode : CUChar,
		max_keycode : CUChar,
		pad1 : Array[CUChar,4],
		);

alias xcb_connection_t = Opaque;

external xcb_connect(
		displayname : Pointer[CChar],
		screenp : Pointer[Int]) Pointer[xcb_connection_t];

external xcb_connection_has_error(
		c : Pointer[xcb_connection_t]) Int;

external xcb_get_setup(
		c : Pointer[xcb_connection_t]) Pointer[xcb_setup_t];

external xcb_setup_roots_iterator(
		R : Pointer[xcb_setup_t]) xcb_screen_iterator_t;

external xcb_disconnect(
		c : Pointer[xcb_connection_t]);


main() {
	var c = xcb_connect(Pointer[CChar](0), Pointer[Int](0));
	if (xcb_connection_has_error(c) > 0) {
		println("cannot open display");
		return;
	}
	var s = xcb_setup_roots_iterator( xcb_get_setup(c) ).data;
	println(s^.root); // segfault
	xcb_disconnect(c);
}

/* equivalent foo.c
#include <stdio.h>
#include <xcb/xcb.h>

int main(int argc, char **argv) {
	xcb_connection_t *c = xcb_connect(0, 0);
	xcb_screen_t *s = xcb_setup_roots_iterator( xcb_get_setup(c) ).data;
	printf("%d", s->root);
	xcb_disconnect(c);
        return 0;
}
*/

Annotation: workaround

Author: kssreeram
Mode: patch
Date: Mon, 6 Sep 2010 06:11:59
Plain Text |
--- test_xcb_orig.clay	2010-09-06 11:40:56.892595738 +0530
+++ test_xcb.clay	2010-09-06 11:41:02.857814317 +0530
@@ -22,8 +22,7 @@
 
 record xcb_screen_iterator_t (
         data : Pointer[xcb_screen_t],
-        rem : Int,
-        index : Int,
+        rem_index : Int64,
         );
 
 record xcb_setup_t (

New Annotation

Summary:
Author:
Mode:
Body: