Right now I'm working on a scripting language that doesn't yet have a FFI. I'd like to know what's the most convenient way to get it in, assuming that I'd like to write it like cool geeks do - I'd like to write the FFI in the scripting language itself.
The programming language I need to interface is C. So for basics I know that libdl.so is my best friend. Obviously it's not the only thing I'm going to need but the most important of them.
I only have slight ideas about what else do I need for it. I'd like to get similar behavior from the FFI as what python ctypes has.
What should I need to know in order to get this far? I know there's some serious magic with data structures I'll need to deal with. How do I manage it so that I could do most of that serious magic in the scripting language itself? I'd have use from such magic for much more than just the foreign function interface. For instance I might want to pass C-like binary data to files.