On Fri, October 28, 2005 2:22 pm, Nick Glencross said: > Guys, > > As mentioned on the list yesterday I started evaluating ffcall as a way > of providing NCI functionality. > > http://www.haible.de/bruno/packages-ffcall.html
I am a SWIG (www.swig.org) developer, and I recently started looking at what it will take to add a parrot module to SWIG. I will post some of the issues I ran into, but I was wondering if there would be any interest for SWIG to become one of the official way to do NCI? SWIG has a whole bunch of other benefits which I won't list here. The main issue resolves around the problem that there isn't a standard way to just register a function as callable from parrot (that I can see). perl5 allowed XS() and then calling the newXS function. SWIG would prefer to use the best representation/match to the internal interpreter... SWIG can easily generate functions of the form void* _wrap_foo(Interp* interpreter, PMC* pmc, void * next) one for each function being wrapped. Can we inject that function directly into the vtable somehow? Or just create a class that passes on the invoke function? One of the existing SWIG modules (CHICKEN) deals with a continuation passing language, so SWIG can deal with continuation-aware languages. > Pros: > > * Makes any prototype possible, not just those in call_list.txt > > * Probably won't initially make code much smaller, but would over time > (stripped nci_ffcall.o & library is currently < 1/6 size of nci.o) > > * Callbacks can have any prototype as well, not just a data/user data > pair > > * Callbacks no longer require user data to be managed by the 3rd party > library (this is a biggy) > > * Callbacks will be able to support a return type > > Cons: > > * Reliance on a library, although NCI may be an optional feature SWIG does not require any code besides what it generates... think lex or yacc... > > * Performance? There are a few additional loops and switches, but I > can't see this being a real issue > > * NCI would only be available on platforms which support the library > we use; from what I've seen dynamic function calls is not easy to do > cross-platform SWIG works on pretty much every platform and every compiler... > > * Possibly incompatible 3rd party licensing SWIG uses a BSD like license, so no problem at all... can even include SWIG directly in the parrot code... It is something to think about... John