FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using X11 lib in D

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
Insomniak



Joined: 01 Sep 2007
Posts: 16

PostPosted: Wed Jan 16, 2008 8:25 am    Post subject: Using X11 lib in D Reply with quote

Hi Smile

I'm needing help about how to use X11 lib in D...

I saw in documentation that we can import C functions... But X11 is a bit too complicated, a lot of X11 functions are macros, who are macros of macros, who are macros calling functions...

I don't know how to port the "drawable" thing in D too...

Do i have to write structs like "Display" [they are only pointers...]... ?

Just this :

Code:
extern(C)
{
    struct Dislay;
    XQueryExtension(Display *display, char *name, int *major_opcode_return, int *first_event_return, int *first_error_return);
}


or this... ?

Code:
extern(C)
{
    struct Dislay
    {
         ... all members of Display struct
    }
    XQueryExtension(Display *display, char *name, int *major_opcode_return, int *first_event_return, int *first_error_return);
}


So, you understand, i need your help... Smile

(sorry for my bad english... :/)

Thanks in advance.
Back to top
View user's profile Send private message
miasma



Joined: 08 Feb 2007
Posts: 13

PostPosted: Tue Jan 22, 2008 6:35 pm    Post subject: Re: Using X11 lib in D Reply with quote

Insomniak wrote:
Hi Smile

I'm needing help about how to use X11 lib in D...

I saw in documentation that we can import C functions... But X11 is a bit too complicated, a lot of X11 functions are macros, who are macros of macros, who are macros calling functions...

I don't know how to port the "drawable" thing in D too...

Do i have to write structs like "Display" [they are only pointers...]... ?

Just this :

Code:
extern(C)
{
    struct Dislay;
    XQueryExtension(Display *display, char *name, int *major_opcode_return, int *first_event_return, int *first_error_return);
}


or this... ?

Code:
extern(C)
{
    struct Dislay
    {
         ... all members of Display struct
    }
    XQueryExtension(Display *display, char *name, int *major_opcode_return, int *first_event_return, int *first_error_return);
}


So, you understand, i need your help... Smile

(sorry for my bad english... :/)

Thanks in advance.


All C preprocessor macros can't be used directly. You need to either rewrite the macros in D (e.g. string mixins) or use wrapper functions.

I think if only pointers to structs are handled in D code, a simple pointer type suffices, but if you need to also access fields, the latter extern(C) block is needed.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group