| Well, I finally added to the git the FFI stuff I worked on recently. It is mainly based on mzscheme's FFI, with an Arcish feeling. It only deals with C-Arc communication. I defined a few more symbols (see ffi.scm) that defines mainly the C types : cint, cuint, cbyte, clong, cfloat, cdouble, cvoid, cptr (equivalent of void ), ... You can tell you want to use a .so file (or .dll under windows) by using the w/ffi* macro. Its parameters are : a string (the filename minus the extension), and cdef declarations. A cdef declaration defines a new Arc function taken from the FFI. It has the following arguments : the newly defined symbol, a string indicating the C name of the function, a return type (or cvoid) and a list of parameter types. (w/ffi "matrix"
(cdef zeros "zeros" cptr (cint cint))
(cdef add "add" cptr (cptr cptr))
(cdef del "delete" cvoid (cptr)))
(= m (zeros 100 200))
...
Finally, I defined a macro called w/inline. It is equivalent to w/ffi, except that its first argument is not the name of a preexisting lib file, but raw C code that gets compiled as a shared library and then can be used as a pre-existing lib. Probably not working under windows, sorry... :( (w/inline "int add (int a, int b) { return a + b; }"
(cdef plus "add" cint (cint cint)))
(plus 1 2)
-> 3
It is quite uncomplete as for now, but already useable. |