Re: FFI to conveniently export Lua functions as a DLL?
ppp vvv <[email protected]>
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
There is already luaL_dostring in lua.dll that allows to call lua code from C, but you would need to handle arguments and return values manually. With some preprocessor magic / C++ templates, you could automatically generate code to call corresponding lua_pushXXX() functions to pass arguments to Lua function before lua_pcall, and then lua_toXXX to get result so it would look like a C function. Also alien.callback could convert Lua function into C function pointer. And there is another but primitive FFI for Lua https://github.com/pavel212/uffi (sysV a bit broken, but windows should be ok). given Lua function could be placed in LUA_REGISTRYINDEX, and then function make_cb (https://github.com/pavel212/uffi/blob/11967d07e0fcb2ca8758b410dbae2702a812893e/src/win64.c#L112) would convert it into C function. It would generate binary code, that could be called then as a C function pointer, and it would get/convert arguments according to provided signature, pass it to lua function, call lua function and return the result pretending it is just a C function. суббота, 28 марта 2026 г. в 21:24:52 UTC+1, Björn Buckwalter: > Hi all, > > The LuaJIT FFI library[1] and Alien[2] make it very convenient to call > external (C) libraries, by providing C declarations from header files > verbatim. Is there similar tooling but for exporting Lua functions as a DLL > based? > > Thanks, > Bjorn > > [1]: https://luajit.org/ext_ffi.html > [2]: https://github.com/mascarenhas/alien > -- You received this message because you are subscribed to the Google Groups "lua-l" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/lua-l/a6318ed2-989e-405e-b1b7-aacd191889a8n%40googlegroups.com.