Files
Lua-compilateur/Demo/lua/todo.lua
T
BlackAngelTV 732347c70b feat(demo): add a standalone project exercising compiled modules
A separate CMake project using the compiler as a subproject shows the real
workflow: namespaced facades, require between compiled modules and dynamic
access from C++.
2026-11-18 08:48:05 +01:00

52 lines
764 B
Lua

-- Small demo package: a toy todo list, compiled into the C++ package demo::todo.
local M = {}
local items = {}
local next_id = 0
function M.add(text, priority)
next_id = next_id + 1
local item = {
id = next_id,
text = text,
done = false,
priority = priority or 2,
}
items[#items + 1] = item
return item.id
end
function M.done(id)
for _, item in ipairs(items) do
if item.id == id then
item.done = true
return true
end
end
return false
end
function M.count()
return #items
end
function M.pending()
local n = 0
for _, item in ipairs(items) do
if not item.done then
n = n + 1
end
end
return n
end
function M.list()
return items
end
function M.version()
return "1.0"
end
return M