luastatic icon indicating copy to clipboard operation
luastatic copied to clipboard

Lua to C-modules

Open JlnWntr opened this issue 7 years ago • 2 comments

Is it possible to do use luastatic for modular programming?

Usecase-example: Let's take

  1. a string.c-file which contains some helper functions concerning strings and
  2. the actual main.c which forms the standalone program and which calls functions from string.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.

JlnWntr avatar Feb 28 '19 11:02 JlnWntr

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

ers35 avatar Mar 01 '19 11:03 ers35

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.

JlnWntr avatar Mar 26 '19 18:03 JlnWntr