SWIG and callback wrappers

Sam Liddicott sam.liddicott@ananova.com
Mon Apr 29 02:32:00 GMT 2002


I have a problem to which the project ffi may be the answer.  The solution
is not core to ffi, but mostly provided already by ffi, I believe.
 
From: http://sources.redhat.com/libffi/ <http://sources.redhat.com/libffi/> 
 
"The libffi library really only provides the lowest, machine dependent layer
of a fully featured foreign function interface. A layer must exist above
libffi that handles type conversions for values passed between the two
languages. "
 
Luckily swig ( www.swig.org <http://www.swig.org> ) does all this.
The part where swig has a problem is where a scripting function or scripting
object-method must handle a callback from a C library.
The C function making the callback might not support void* pointers, or
other parameters that can be used to hack full references to the scripting
routing.
 
A solution I would like to draw on (and this is where libffi comes in) is
one I used under windows in Delphi. MakeObjectInstance would allocate a
short block of memory int  which was stuffed some crafted assembler which
JMP'd to the method address after fixing up a parameter for the object.
 
Possibly the libffi closure support will manage this? 
 
Do you think it will?
 
  _____  


Samuel Liddicott
Support Consultant
sam@ananova.com <mailto:sam@ananova.com>  
Direct Dial: +44 (0)113 367 4523
Fax: +44 (0)113 367 4680
Switchboard: +44 (0)113 367 4600

Ananova Limited
Marshall Mill
Marshall Street
Leeds
LS11 9YJ

http://www.ananova.com

Registered Office:
St James Court
Great Park Road
Almondsbury Park
Bradley Stoke
Bristol BS32 4QJ
Registered in England No.2858918

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you receive
this in error, please contact the sender and delete the material from any
computer.

 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourceware.org/pipermail/libffi-discuss/attachments/20020429/1b8c2356/attachment.htm>


More information about the Libffi-discuss mailing list