mt namespace
contains the metatable events.
Contents
- Reference
That is everything that can be customized using a metamethod.
The functions have the same name as the metamethods (except without leading __). These names don't always match the method names on Value.
If the required metamethod is not present (or the value is not a table) these functions will simply call the corresponding functions on the Value.
Binary events first check the left value for the metamethod and if that is not present they check the right side.
Functions
- auto index(const CallContext& ctx) -> CallResult -> auto
- Index into a Table or calls
__indexof the metatable. - auto newindex(const CallContext& ctx) -> CallResult -> auto
- Index into a Table or calls
__indexof the metatable. - auto add(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Add (binary
+) operator. Will call metamethod__addif necessary. - auto sub(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Sub (binary
-) operator. Will call metamethod__subif necessary. - auto mul(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Mul (binary
*) operator. Will call metamethod__mulif necessary. - auto div(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Div (binary
/) operator. Will call metamethod__divif necessary. - auto mod(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Mod (binary
%) operator. Will call metamethod__modif necessary. - auto pow(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Pow (binary
^) operator. Will call metamethod__powif necessary. - auto idiv(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Floor division (binary
//) operator. Will call metamethod__idivif necessary. - auto band(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise and (binary
&) operator. Will call metamethod__bandif necessary. - auto bor(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise or (binary
|) operator. Will call metamethod__borif necessary. - auto bxor(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise xor (binary
~) operator. Will call metamethod__bxorif necessary. - auto shl(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise left shift (binary
<<) operator. Will call metamethod__shlif necessary. - auto shr(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise right shift (binary
>>) operator. Will call metamethod__shrif necessary. - auto concat(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Concatenation (binary
..) operator. Will call metamethod__concatif necessary. - auto eq(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Equal (binary
==) operator. Will call metamethod__eqif necessary. - auto lt(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Less than (binary
<) operator. Will call metamethod__ltif necessary. - auto le(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Less than (binary
<=) operator. Will call metamethod__leif necessary. - auto unm(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Negation (unary
-) operator. Will call metamethod__unmif necessary. - auto bnot(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise not (unary
~) operator. Will call metamethod__bnotif necessary. - auto len(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Length (unary
#) operator. Will call metamethod__lenif necessary. - auto call(const CallContext& ctx) -> CallResult -> auto
- Call (
func(args)) operator. Will call metamethod__callif necessary. - void gc(const CallContext& ctx)
- Called when a table is garbage collected. Will call metamethod
__gc.
Function documentation
auto minilua:: mt:: index(const CallContext& ctx) -> CallResult
Index into a Table or calls __index of the metatable.
The metatable is only used if the key is not present in the table.
auto minilua:: mt:: newindex(const CallContext& ctx) -> CallResult
Index into a Table or calls __index of the metatable.
auto minilua:: mt:: eq(const CallContext& ctx,
std::optional<Range> location = std::nullopt) -> CallResult
Equal (binary ==) operator. Will call metamethod __eq if necessary.
Lua will only try the metamethods if both values are the same type and not trivially equal.
The result is always converted to a bool.
auto minilua:: mt:: lt(const CallContext& ctx,
std::optional<Range> location = std::nullopt) -> CallResult
Less than (binary <) operator. Will call metamethod __lt if necessary.
The result is always converted to a bool.
auto minilua:: mt:: le(const CallContext& ctx,
std::optional<Range> location = std::nullopt) -> CallResult
Less than (binary <=) operator. Will call metamethod __le if necessary.
The lua spec also specifies that if the __le metamethod is not present it will try a __lt metamethod with reversed parameters. But it states that this behaviour might be removed in the future (this assumes that a <= b is equal to b < a).
The result is always converted to a bool.
auto minilua:: mt:: call(const CallContext& ctx) -> CallResult
Call (func(args)) operator. Will call metamethod __call if necessary.
The metamethod is only searched in func and it will get func and the arguments args as parameters.
This metamethod allows multiple results.
void minilua:: mt:: gc(const CallContext& ctx)
Called when a table is garbage collected. Will call metamethod __gc.
In our case the tables are all garbage collected at once when the lua program stops running.