#include <Pt/Lua/Context.h>
Lua state with a bound type catalog. More...
Public Member Functions | |
| Context (Pt::Reflex::TypeManager &tm) | |
| Creates a Lua state and binds tm. | |
| ~Context () | |
| Closes the Lua state. | |
| lua_State * | state () const |
| Returns the Lua state of this context. | |
| Pt::Reflex::TypeManager & | typeManager () |
| Returns the type manager this context bound. | |
| void | reset () |
| Removes script-created globals and collects garbage. | |
Context is the bind step of the runtime model. It opens a Lua state, loads the standard libraries, and installs globals for every eligible type and asynchronous function in tm, including a parent type manager. The manager is not owned; it must outlive the context, together with every type and function registered on it.
A type becomes a Lua class when it has a constructor, a method, or a property. The type name is a callable global. An instance is userdata that Lua owns. Methods use the Lua method syntax, properties are fields, and selected Reflex operator names map to metamethods. Scalar values convert in both directions. A returned object is copy-constructed into userdata; a type without a copy constructor cannot be returned by value.
A free function is bound only when it returns AsyncCall*. Two different types or functions that share a name, or a name that is already a standard Lua global, throw std::logic_error. Binding the same object twice is ignored.
state() is the Lua state, for Result and for the Lua C API. reset() drops script-created globals and collects garbage; the bindings remain. Destroy the Script first. The context is not copyable.
|
explicit |
| %std::logic_error | if a name is already bound. |
| %std::bad_alloc | if the Lua state cannot be created. |