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 ea6fb41a48
commit 732347c70b
4 files changed
+141

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
// Demo program: uses Lua modules compiled into C++ packages.
#include <iostream>
#include <luacpp/rt.hpp>
#include "report.hpp"
#include "todo.hpp"
int main() {
luacpp::State state;
auto todo = demo::todo::bind(state);
auto report = demo::report::bind(state);
todo.add("Ecrire le compilateur Lua -> C++", 1);
todo.add("Compiler les modules en packages C++", 1);
todo.add("Ajouter les tests de conformite", 3);
todo.done(2);
std::cout << report.summary().as_string() << "\n\n";
std::cout << report.render().as_string() << "\n\n";
luacpp::Value stats = report.stats();
std::cout << "termines : " << stats.get("finished").to_string() << "/"
<< stats.get("total").to_string() << "\n";
// Dynamic access, without the generated facade.
luacpp::Value items = demo::todo::module(state).get("list").call();
std::cout << "premier item : " << items.at(1).get("text").as_string() << "\n";
return 0;
}