public final class Metatables extends Object
Modifier and Type | Field and Description |
---|---|
static ByteString |
MT_ADD
The metatable key
"__add" . |
static ByteString |
MT_BAND
The metatable key
"__band" . |
static ByteString |
MT_BNOT
The metatable key
"__bnot" . |
static ByteString |
MT_BOR
The metatable key
"__bor" . |
static ByteString |
MT_BXOR
The metatable key
"__bxor" . |
static ByteString |
MT_CALL
The metatable key
"__call" . |
static ByteString |
MT_CONCAT
The metatable key
"__concat" . |
static ByteString |
MT_DIV
The metatable key
"__div" . |
static ByteString |
MT_EQ
The metatable key
"__eq" . |
static ByteString |
MT_IDIV
The metatable key
"__idiv" . |
static ByteString |
MT_INDEX
The metatable key
"__index" . |
static ByteString |
MT_LE
The metatable key
"__le" . |
static ByteString |
MT_LEN
The metatable key
"__len" . |
static ByteString |
MT_LT
The metatable key
"__lt" . |
static ByteString |
MT_MOD
The metatable key
"__mod" . |
static ByteString |
MT_MODE
The metatable key
"__mode" . |
static ByteString |
MT_MUL
The metatable key
"__mul" . |
static ByteString |
MT_NEWINDEX
The metatable key
"__newindex" . |
static ByteString |
MT_POW
The metatable key
"__pow" . |
static ByteString |
MT_SHL
The metatable key
"__shl" . |
static ByteString |
MT_SHR
The metatable key
"__shr" . |
static ByteString |
MT_SUB
The metatable key
"__sub" . |
static ByteString |
MT_UNM
The metatable key
"__unm" . |
Modifier and Type | Method and Description |
---|---|
static Object |
binaryHandlerFor(MetatableProvider metatableProvider,
ByteString event,
Object a,
Object b)
Returns the metatable entry
event for a or in b , or null
if neither a nor b has such an entry in their metatable. |
static Object |
getMetamethod(ByteString event,
LuaObject o)
|
static Object |
getMetamethod(MetatableProvider metatableProvider,
ByteString event,
Object o)
Returns the entry with the key
event of the metatable of the object o . |
public static final ByteString MT_ADD
"__add"
. When defined, customises the behaviour of
the Lua addition operator (+
).public static final ByteString MT_SUB
"__sub"
. When defined, customises the behaviour of
the Lua subtraction operator (binary -
).public static final ByteString MT_MUL
"__mul"
. When defined, customises the behaviour of
the Lua multiplication operator (*
).public static final ByteString MT_DIV
"__div"
. When defined, customises the behaviour of
the Lua division operator (/
).public static final ByteString MT_MOD
"__mod"
. When defined, customises the behaviour of
the Lua modulo operator (%
).public static final ByteString MT_POW
"__pow"
. When defined, customises the behaviour of
the Lua exponentiation operator (^
).public static final ByteString MT_UNM
"__unm"
. When defined, customises the behaviour of
the Lua unary minus operator (unary -
).public static final ByteString MT_IDIV
"__idiv"
. When defined, customises the behaviour of
the Lua floor division (//
).public static final ByteString MT_BAND
"__band"
. When defined, customises the behaviour of
the Lua bitwise AND operator (&
).public static final ByteString MT_BOR
"__bor"
. When defined, customises the behaviour of
the Lua bitwise OR operator (|
).public static final ByteString MT_BXOR
"__bxor"
. When defined, customises the behaviour of
the Lua bitwise XOR operator (binary ~
).public static final ByteString MT_BNOT
"__bnot"
. When defined, customises the behaviour of
the Lua bitwise NOT operator (unary ~
).public static final ByteString MT_SHL
"__shl"
. When defined, customises the behaviour of
the Lua bitwise left shift operator (<<
).public static final ByteString MT_SHR
"__shr"
. When defined, customises the behaviour of
the Lua bitwise right shift operator (>>
).public static final ByteString MT_CONCAT
"__concat"
. When defined, customises the behaviour of
the Lua concatenation operator (..
).public static final ByteString MT_LEN
"__len"
. When defined, customises the behaviour of
the Lua length operator (#
).public static final ByteString MT_EQ
"__eq"
. When defined, customises the behaviour of
the Lua equality operator (==
).public static final ByteString MT_LT
"__lt"
. When defined, customises the behaviour of
the Lua lesser-than operator (<
).public static final ByteString MT_LE
"__le"
. When defined, customises the behaviour of
the Lua lesser-than-or-equal-to operator (<=
).public static final ByteString MT_INDEX
"__index"
. When defined, customises the behaviour of
the (non-assignment) Lua table access operator (t[k]
).public static final ByteString MT_NEWINDEX
"__newindex"
. When defined, customises the behaviour of
Lua table assignment (t[k] = v
).public static final ByteString MT_CALL
"__call"
. When defined, customises the behaviour of
the Lua call operator (f(args)
).public static final ByteString MT_MODE
"__mode"
. Used to control the weakness of table keys
and values.public static Object getMetamethod(ByteString event, LuaObject o)
event
of the metatable of the LuaObject
o
. If o
does not have a metatable or event
does not exist in it as
a key, returns null
.
The access of the metatable is raw (i.e. uses Table.rawget(Object)
).
This method differs from getMetamethod(MetatableProvider, ByteString, Object)
in that it does not require a metatable provider as the object in question is known
to have metatables attached on a per-instance basis.
event
- the key to look up in the metatable, must not be null
o
- the object in question, must not be null
null
value if event
is a key in o
's metatable;
null
otherwiseNullPointerException
- if o
or event
is null
public static Object getMetamethod(MetatableProvider metatableProvider, ByteString event, Object o)
event
of the metatable of the object o
.
If o
does not have a metatable or event
does not exist in it as
a key, returns null
.
The access of the metatable is raw (i.e. uses Table.rawget(Object)
).
metatableProvider
- the metatable provider, must not be null
event
- the key to look up in the metatable, must not be null
o
- the object in question, may be null
null
value if event
is a key in o
's metatable;
null
otherwiseNullPointerException
- if metatableProvider
or event
is null
public static Object binaryHandlerFor(MetatableProvider metatableProvider, ByteString event, Object a, Object b)
event
for a
or in b
, or null
if neither a
nor b
has such an entry in their metatable.
This method is similar to getMetamethod(MetatableProvider, ByteString, Object)
,
but first looks up the entry event
in a
, and if this fails (by
returning null
), tries to look event
up in b
.
metatableProvider
- the metatable provider, must not be null
event
- the key to look up in the metatable, must not be null
a
- the first object to try, may be null
b
- the second object to try, may be null
null
value if event
is a key in a
's or b
's
metatable (in this order); null
otherwiseNullPointerException
- if metatableProvider
or event
is null
Copyright © 2016. All rights reserved.