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.
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: