http://cffi.readthedocs.org/en/latest/overview.html#simple-e...
And, under IPython (python3) on Windows (I already had ms visual studio installed):
import pip
pip.main("install cffi".split())
> (...)
> Successfully installed cffi-1.0.3 pycparser-2.13
from cffi import FFI
ffi = FFI()
ffi.cdef("""int printf(const char *format, ...);
""")
C = ffi.dlopen(None)
arg = ffi.new("char[]", b"world")
C.printf(b"Hi there, %s!\n", arg)
> Hi there, world!
> 17
So a lot of this is tooling, integration and documentation.If one might whip up something similar for rust that works cross platform, and results in code that is reasonably easy to distribute via pypi (and similar for gems for ruby etc) -- that'd be great.
So, I meant that for a novice, that wants to, say write a compiled extension/wrapper for python/ruby whatever -- a bit of C and the standard docs go a long way now.
Obviously there's a lot of work to get to the point of C (it's been ubiquitous for a while...) -- but if some parts could be made similarly accessible; interfacing with rustc, if rustc is in path/installed "properly", some magic on the host-language side etc -- that would be very good, I think.
I'll have a look when I find the time - but this is a great start!
Yeah, things like "what do I do about more complex types" needs tons of more docs in general. We will get there. I'm also pretty convinced that a dedicated individual could create pretty awesome automatic binding generators for any language, especially since bindgen works pretty well for C... but we'll see how it shakes out.
Don't hesitate to email me or post in the forums if you play around with this and get stuck :)
Can you expand on why that is, maybe?