[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] C unions and structs, how to access them ?
From: |
Pupeno |
Subject: |
[Chicken-users] C unions and structs, how to access them ? |
Date: |
Sun, 30 Oct 2005 17:11:47 -0300 |
User-agent: |
KMail/1.8.3 |
In the FFIs I am making I am encountering the need to access the members of
unions and structs. Untill now all I did was manage them as pointers and
apply functions to them, but that is changing, for example, I have this
function[1][2]:
XNextEvent(display, event_return)
Display *display;
XEvent *event_return;
to which I pass the display I made and an XEvent that will be over-writtend,
that is, on event_return I'll have the real return of the function.
I started by making an XEvent type[3]:
(define-foreign-type x-event c-pointer)
which is in fact an union of structs, but I am, untill now, handling it as
pointers.
So, when I try to wrap XNextEvent I end up with two procedures:
(define x-next-event-raw
(foreign-lambda void "XNextEvent" display x-event))
(define (x-next-event d)
(let ((e (foreign-value "malloc(sizeof(XEvent))" c-pointer)))
(x-next-event-raw d e)
e))
Is that the right way to do it ? If not, how should I do it ?
Now, the real question: How do I access XEvent's members and XEvent's members'
members ?
Thank you.
--
Pupeno <address@hidden> (http://pupeno.com)
[1] I know there's an xlib egg, but it doesn't have a clear license, all it
says is "All rights reserved" and I don't like that.
[2]
http://tronche.com/gui/x/xlib/event-handling/manipulating-event-queue/XNextEvent.html
[3] http://tronche.com/gui/x/xlib/events/structures.html#XEvent
pgpF9S60gHCMw.pgp
Description: PGP signature
- [Chicken-users] C unions and structs, how to access them ?,
Pupeno <=