4 ms·
The basic lua VM (not luajit) is only like 11kb compiled. You can't directly do FFI from lua, but you can set up the FFI functions from the C API
by connicpu 7y ago
The basic lua VM (not luajit) is only like 11kb compiled. You can't directly do FFI from lua, but you can set up the FFI functions from the C API
- SlowRobotAhead 7y agoAny examples of code or know where someone has done this?
- matheusmoreira 7y agoLua was made for this! Here's a simple example: https://gist.github.com/Vesnica/3672425 https://gist.github.com/Vesnica/3672425 It loads and runs a Lua source code file which calls the exported C function. Lua compiles the source code into byte code before running it but that can also be done ahead of time with the Lua compiler: https://www.lua.org/manual/5.3/luac.html https://www.lua.org/manual/5.3/luac.html It can also be done manually with the dump and load functions: https://www.lua.org/manual/5.3/manual.html#lua_dump https://www.lua.org/manual/5.3/manual.html#lua_dump https://www.lua.org/manual/5.3/manual.html#lua_load https://www.lua.org/manual/5.3/manual.html#lua_load