This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> While trying to wrap ncurses, I wonder if it is necessary to define > the struct WINDOW as scheme object. The library functions themselves > only call and return pointers to WINDOW -objects. My first approach > is to hide that struct from the interface at all and just cast > pointers into integers and back before applying libguile's > conversion functions, or let g-wrap do that for me. This is a bad idea, Scheme code would then be able to forge pointers by passing made up ints instead of ints that represent struct WINDOW objects. User scheme code should not cause a segfault when passing 0 instead of a window structure, just a tyoe error. Also, your suggested wrapping would make it impossible to garbage-collect window structs. You're not thinking of making scheme code free them explicitly, are you? > But I know that the SCM-ncurses-interface of J.Leveling creates > windows as scheme objects. So is there a flaw in the former naive > approach which hides structs that are called by reference only from > the interface-file ? It's not that hard to wrap C structs as Scheme objects, especially if they are only ever accessed by reference. Do you want some sample code? - Maciej Stachowiak