From: Sean O'Halpin Date: 2008-11-18T23:52:43+09:00 Subject: Re: FFI 0.1.1 (Foreign Function Interface) for Ruby 1.8.6/7 and 1.9 On Wed, Nov 5, 2008 at 5:11 PM, Nit Khair wrote: > > Eagerly awaiting your ncurses port... > > Is it possible for you to document the procedure, how you go about doing > it, so one can follow that for another port, rather than be totally > lost. Hi, I've just uploaded the ~very raw~ initial port of the core ncurses lib to ruby-ffi. You can find it at: git://github.com/seanohalpin/ffi-ncurses.git This works with ffi-0.0.2 (which I got from the kenai project) - 0.0.1 left out typedefs for short ints. To use: require 'rubygems' require 'ffi' require 'ffi-ncurses notes: - example.rb shows basic usage - to access stdscr, use the return value from NCurses.initscr - I have not implemented any variadic functions (not supported by libffi AFAIK) - there's also a wrapper for libdl called dlfcn.rb - there's an experimental script (ex01-ffi-dl-stdscr.rb) which uses dlfcn.rb to access the exported variables from the ncurses shared lib (stdscr, curscr, etc.). This also shows how to access values returned through pointers (see NCurses.wattr_get). There are some rambling notes on implementation in notes-on-ffi-curses.org. I'll tidy these up when I get some spare time. Basically, I wrote a script (generate-ffi-ncurses-function-signatures.rb) that mechanically recovered the function signatures from the ncurses.h on my machine and added some constants. I wasted a lot of time figuring out how to access exported variables. I've only just done a final test on OS X Tiger - haven't checked Linux yet (should work but...) I have not set up a project for this yet so please send any bug reports, questions, etc. directly to me for the moment. There are no tests - I wonder if anyone has any ideas how best to write specs/tests for checking this kind of output? Regards, Sean