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++.
This commit is contained in:
BlackAngelTV committed 2026-11-18 08:48:05 +01:00
1 parent a06bad1b0e
commit ff9d380846
4 files changed
+141

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
-- Demo module that requires another compiled module (demo.todo).
local todo = require("demo.todo")
local M = {}
function M.summary()
return string.format(
"todo v%s : %d element(s), %d en attente",
todo.version(), todo.count(), todo.pending()
)
end
function M.render()
local lines = {}
for _, item in ipairs(todo.list()) do
lines[#lines + 1] = string.format(
"[%s] #%d %s (p%d)",
item.done and "x" or " ", item.id, item.text, item.priority
)
end
return table.concat(lines, "\n")
end
function M.stats()
local total = todo.count()
local finished = 0
for _, item in ipairs(todo.list()) do
if item.done then
finished = finished + 1
end
end
return {
total = total,
finished = finished,
ratio = total > 0 and finished / total or 0,
}
end
return M