Lunar allows to wrap C++ classes for use in Lua by automating large parts of the code creation through templates.
Lunar handles con- and destruction through several special methods (of which only T(L)
and ~T()
are required).
Function | When | Available data |
`T(L)` | upon construction | Lua state (C++ object) |
`oninit(L)` | upon calling `new()` in Lua, after calling the constructor | Lua state (Lua and C++ object) |
`onpush(L)` | on pushing objects into Lua from C++ and when calling `new()` in Lua | Lua state (Lua and C++ object) |
`ongc(L)` | upon garbage collection, before calling the destructor | Lua state (Lua and C++ object) |
`~T()` | code that needs just the C object | just C++ object |