[SimpleType] ?

On Sun, 2009-02-15 at 20:41 -0500, Michael B. Trausch wrote:
> I am trying to create a small Xlib binding for Vala, with a little bit
> of difficulty.  I think I just don't understand what it is that I am
> doing fully.
> 
> Starting with what Frederik gave as an initial set of code, I have so
> far come up with:
> 
> [CCode(cprefix = "X", cheader_filename = "X11/Xlib.h")]
> namespace XLib {
>       [Compact]
>       [CCode(cname = "Display", free_function = "XCloseDisplay")]
>       public class Display {
>               [CCode(cname = "XOpenDisplay")]
>               public Display(string? display_name = null);
> 
>               [CCode(cname = "XDefaultScreen")]
>               public int get_default_screen();
> 
>               [CCode(cname = "XBlackPixel")]
>               public long get_black_pixel(int screen_number);
> 
>               [CCode(cname = "XWhitePixel")]
>               public long get_white_pixel(int screen_number);
> 
>               [CCode(cname = "XConnectionNumber")]
>               public int get_connection_number();
> 
>               [CCode(cname = "XDefaultColormap")]
>               public ColorMap get_default_colormap(int screen_number);
> 
>               [CCode(cname = "XAllPlanes")]
>               public static long get_all_planes();
>       }
> }
> 
> Now, the problem is the return value for XDefaultColormap.  This is
> really a typedef to XID, which itself is a typedef to CARD32, which is
> in turn a typedef to "unsigned long".  I could just declare it to be an
> ulong, but it'd seem that there should be some way to do this in a
> type-safe manner.  Is there something simple that I am just not getting?
> 
> Also, in the above example, there is the public class Display.  Now, it
> has fields, though they are for the purpose of this implementation and
> the Xlib manual private fields.  However, assuming for a second that
> they weren't, and they were expected to be exposed to the user, how
> would that be done whilst preserving the order of the items in the C
> struct?
> 
>       --- Mike
> 

_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to