From: Luis Lavena Date: 2008-11-05T01:58:34+09:00 Subject: Re: FFI 0.1.1 (Foreign Function Interface) for Ruby 1.8.6/7 and 1.9 On Nov 4, 12:51 pm, Sean O'Halpin wrote: > On Tue, Nov 4, 2008 at 3:10 PM, Nit Khair wrote: > > Sean O'halpin wrote: > >> On Tue, Nov 4, 2008 at 2:38 PM, Ken Bloom wrote: > > >> module NCursesFFI > >>  extend FFI::Library > >>  ffi_lib 'ncurses' > >>  attach_function 'clear', [], :int > >>  attach_function 'endwin', [], :int > >>  attach_function 'getch', [], :int > >>  attach_function 'initscr', [], :int > >>  attach_function 'printw', [ :string ], :int > >>  attach_function 'refresh', [], :int > >> end > > > Sean, > > Going by the above, and the samples of structs on the blog, for a medium > > sized library such as ncurses, there can be some effort in getting this > > module ready. Will there be some kind of repository of such modules, so > > we are not duplicating each others effort ? > > It's a fairly tedious (and largely thankless) task to convert a lib > like ncurses. However, I'm in the mood right now so expect a github > repo in the near future :) Your point about avoiding duplication of > effort is a good one. The main problem in tackling something like this > is fatigue setting in when you've got enough for your immediate > requirement and so ending up with a half-baked conversion (I speak > from experience). I believe another pitfall is trying to rubyify the > interface. I think it's better to provide a thin bridge and then > abstract on top of that. Then you get the benefit of being able to use > existing experience and documentation (with the usual translations) > and others can take or leave your abstraction as they see fit. (I do > think Ruby needs a portable console library but I'd rather build that > on top of ruby versions of ncurses and Win32 console than try to make > ncurses work on Windows. I'm hoping FFI will make that possible.) > Yeah, first layer of implementation and then abstraction (Rubify) is the way to go :-) > I'm wondering if it would be useful to have these FFI-enabled libs > under an ffi/ namespace, e.g. you'd require 'ffi/ncurses' and possibly > include FFI::NCurses. We could put shared structs, constants, etc. > under ffi/include. Any thoughts anyone? > Something like the win32utils team does: gem: win32-service gem win32-eventlog require 'win32/service' require 'win32/eventlog' All these live inside Win32 namespace I think these could be named ffi-ncourses but the name implies "FFI implementation of ncurses" where I will love to have "cross platform curses" (note the lack of 'n'). These should depend on ruby-ffi gem and we are set to go :-) My to cents -- Luis Lavena