On Sat, 18 Feb 2017 14:59:14 +0100
luigi scarso
On Sat, Feb 18, 2017 at 2:27 PM, Henri Menke
wrote: On 02/18/2017 09:42 AM, luigi scarso wrote:
On Sat, Feb 18, 2017 at 9:11 AM, Henri Menke
wrote: On 02/17/2017 08:57 PM, luigi scarso wrote: How can I use the FFI? There is nothing in the latest docs. Thanks for all the efforts! luatex ffi is beyond the "experimental state", and aims to be compatible with luatexjit ffi.
So it has the same interface? There seems to be no documentation about it in the most recent manual from luatex.org yes, "aims to be compatible" means same interface and functionality, but there is still lot of work to do, apart the dynamic loading of the library and the C parser. But it's usable for testing.
Luigi has shown me a simple and useful application of ffi: \startluacode ffi=require("ffi") ffi.cdef[[ double j0(double x); double j1(double x); double jn(double x); -- ... ]] \stopluacode These libm functions can then be used in lua as: ffi.C.j0(x) for example. In my case, I pass them to MetaPost as: \startMPdefinitions vardef jzero primary x = scantokens(lua("mp.quoted(ffi.C.j0(" & decimal x & "))")) enddef ; \stopMPdefinitions This experimental code appears to work quite well. Thank you Luigi and Hans! Alan