luastatic
luastatic copied to clipboard
Lua to C-modules
Is it possible to do use luastatic for modular programming?
Usecase-example: Let's take
- a
string.c-file which contains some helper functions concerning strings and - the actual
main.cwhich forms the standalone program and which calls functions fromstring.c.
Now the special thing about string.c is, that it actually consists of lua-code, which has been converted to C-code using luastatic.
This would be very exciting.
How about this? Can you give a more specific example?
-- string2.lua
local string2 = {}
function string2.hello()
return "hello"
end
return string2
-- main.lua
local string2 = require("string2")
print(string2.hello())
luastatic main.lua string2.lua /usr/lib/x86_64-linux-gnu/liblua5.3.a -I/usr/include/lua5.3
./main
This: https://github.com/JlnWntr/Lua-Adapter/blob/master/examples/static.cpp
It's getting interesting, when you don't need something like a main.lua anymore. If the main-application is normal C-code, while some used C-modules/routines are actually written in Lua, then your head explodes at all those possibilities.