This is the mail archive of the libffi-discuss@sources.redhat.com mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SWIG and callback wrappers


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/
 
"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) 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
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.

 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]