namespace
mtcontains 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
__index
of the metatable. - auto newindex(const CallContext& ctx) -> CallResult -> auto
- Index into a Table or calls
__index
of the metatable. - auto add(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Add (binary
+
) operator. Will call metamethod__add
if necessary. - auto sub(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Sub (binary
-
) operator. Will call metamethod__sub
if necessary. - auto mul(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Mul (binary
*
) operator. Will call metamethod__mul
if necessary. - auto div(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Div (binary
/
) operator. Will call metamethod__div
if necessary. - auto mod(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Mod (binary
%
) operator. Will call metamethod__mod
if necessary. - auto pow(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Pow (binary
^
) operator. Will call metamethod__pow
if necessary. - auto idiv(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Floor division (binary
//
) operator. Will call metamethod__idiv
if necessary. - auto band(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise and (binary
&
) operator. Will call metamethod__band
if necessary. - auto bor(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise or (binary
|
) operator. Will call metamethod__bor
if necessary. - auto bxor(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise xor (binary
~
) operator. Will call metamethod__bxor
if necessary. - auto shl(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise left shift (binary
<<
) operator. Will call metamethod__shl
if necessary. - auto shr(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise right shift (binary
>>
) operator. Will call metamethod__shr
if necessary. - auto concat(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Concatenation (binary
..
) operator. Will call metamethod__concat
if necessary. - auto eq(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Equal (binary
==
) operator. Will call metamethod__eq
if necessary. - auto lt(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Less than (binary
<
) operator. Will call metamethod__lt
if necessary. - auto le(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Less than (binary
<=
) operator. Will call metamethod__le
if necessary. - auto unm(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Negation (unary
-
) operator. Will call metamethod__unm
if necessary. - auto bnot(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Bitwise not (unary
~
) operator. Will call metamethod__bnot
if necessary. - auto len(const CallContext& ctx, std::optional<Range> location = std::nullopt) -> CallResult -> auto
- Length (unary
#
) operator. Will call metamethod__len
if necessary. - auto call(const CallContext& ctx) -> CallResult -> auto
- Call (
func(args)
) operator. Will call metamethod__call
if 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.