Re: HToolkit 1.0 released
Krasimir Angelov <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.gui |
|---|---|
| Message-ID | <[email protected]> |
--- Wolfgang Jeltsch <[email protected]> wrote: [..] > The problem for creating Ada bindings is that there > is no standard mapping of > (void *) to an Ada type. But if you want to handle > pointers to values of > arbitrary type but not to functions, you can use > (char *) instead of (void *) > like malloc etc. do. Besides that this allows > portable Ada bindings, it has > the advantage that on some platforms the pointer may > take less space. If you > have, e.g, one code and one data segment, a function > pointer and a char > pointer each have to store only the offset address > while a void pointer has > to store also the kind of segment. HToolkit doesn't handle any function pointers. The C-level API uses only data pointers. When an event is raised then all parameters of the event are passed to its corresponding function. For example lets assume that we have "command" event. The only parameter for the event is a handle of the sender. The C code calls function named handleControlCommand with signature: void handleControlCommand(WindowHandle control). The WindowHandle is just data pointer (HWND under Windows and (GtkWidget *) under GTK). The handleControlCommand is written in Haskell and it is exported with "foreign export" declaration to C. The current Haskell implementation simple look at hash table for appropriate callback function in the Haskell level. The implementation for Ada can use similar solution. Krasimir __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com