Files
BlackAngelTV fbdb3e73ba refactor(demo): keep the demo Lua-only
Calling the compiled modules required a CMake project and a C++ main, which
contradicted the point of the compiler. A Lua entry script now prints the same
report, and the modules sit next to it so require resolves without any flag.
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