Package com.prineside.luaj
Class LuaFunction
java.lang.Object
com.prineside.luaj.Varargs
com.prineside.luaj.LuaValue
com.prineside.luaj.LuaFunction
- Direct Known Subclasses:
JavaMethod.Overload
,LibFunction
,LuaClosure
Base class for functions implemented in Java.
Direct subclass include org.luaj.vm2.lib.LibFunction
which is the base class for
all built-in library functions coded in Java,
and LuaClosure
, which represents a lua closure
whose bytecode is interpreted when the function is invoked.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.prineside.luaj.LuaValue
LuaValue.NillableSerializer, LuaValue.None
Nested classes/interfaces inherited from class com.prineside.luaj.Varargs
Varargs.ArrayVarargs
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic LuaValue
Shared static metatable for all functions and closures.Fields inherited from class com.prineside.luaj.LuaValue
ADD, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILLABLE_SERIALIZER, NILS, NONE, NOVALS, ONE, POW, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, ZERO
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCheck that the value is a function , or throwLuaError
if notReturn the last part of the class name, to be used as a function name in tojstring and elsewhere.Get the metatable for thisLuaValue
boolean
Check ifthis
is afunction
name()
Return a human-readable name for this function.optfunction
(LuaFunction defval) Check that optional argument is a function and return asLuaFunction
strvalue()
Convert to human readable String for any type.int
type()
Get the enumeration value for the type of this value.typename()
Get the String name of the type of this value.Methods inherited from class com.prineside.luaj.LuaValue
add, add, add, and, arg, arg1, argerror, assert_, buffer, call, call, call, call, call, cBool, cDouble, cFloat, checkboolean, checkclosure, checkdouble, checkglobals, checkint, checkjstring, checklong, checknotnil, checknumber, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, cInt, cNcDouble, cNcFloat, cNcInt, cObject, comparemt, concat, concat, concatmt, concatTo, concatTo, concatTo, cRegObject, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, div, div, div, divInto, eq, eq_b, eqmtcall, equals, error, get, get, get, gt, gt, gt, gt_b, gt_b, gt_b, gteq, gteq, gteq, gteq_b, gteq_b, gteq_b, inext, initupvalue1, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isint, isinttype, islong, isnil, isnumber, isRegObject, isstring, istable, isthread, isuserdata, isuserdata, isvalidkey, len, length, listOf, listOf, load, lt, lt, lt, lt_b, lt_b, lt_b, lteq, lteq, lteq, lteq_b, lteq_b, lteq_b, markAsConst, metatag, method, method, method, method, method, method, mod, mod, mod, modFrom, mul, mul, mul, narg, neg, neq, neq_b, next, not, onInvoke, optboolean, optclosure, optdouble, optint, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, or, pow, pow, pow, powWith, powWith, presize, raweq, raweq, raweq, raweq, raweq, rawget, rawget, rawget, rawlen, rawset, rawset, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, set, set, setmetatable, strcmp, strcmp, strongvalue, sub, sub, sub, subargs, subFrom, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, toboolean, tobyte, tochar, todouble, tofloat, toint, tolong, tonumber, toshort, tostring, toString, touserdata, touserdata, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf
Methods inherited from class com.prineside.luaj.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, dealias, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type
-
Field Details
-
s_metatable
Shared static metatable for all functions and closures.
-
-
Constructor Details
-
LuaFunction
public LuaFunction()
-
-
Method Details
-
type
public int type()Description copied from class:LuaValue
Get the enumeration value for the type of this value.- Specified by:
type
in classLuaValue
- Returns:
- value for this type, one of
LuaValue.TNIL
,LuaValue.TBOOLEAN
,LuaValue.TNUMBER
,LuaValue.TSTRING
,LuaValue.TTABLE
,LuaValue.TFUNCTION
,LuaValue.TUSERDATA
,LuaValue.TTHREAD
- See Also:
-
typename
Description copied from class:LuaValue
Get the String name of the type of this value.- Specified by:
typename
in classLuaValue
- Returns:
- name from type name list
LuaValue.TYPE_NAMES
corresponding to the type of this value: "nil", "boolean", "number", "string", "table", "function", "userdata", "thread" - See Also:
-
isfunction
public boolean isfunction()Description copied from class:LuaValue
Check ifthis
is afunction
- Overrides:
isfunction
in classLuaValue
- Returns:
- true if this is a
function
, otherwise false - See Also:
-
checkfunction
Description copied from class:LuaValue
Check that the value is a function , or throwLuaError
if notA
LuaFunction
may either be a Java function that implements functionality directly in Java, or aLuaClosure
which is aLuaFunction
that executes lua bytecode.- Overrides:
checkfunction
in classLuaValue
- Returns:
this
if it is a lua function or closure- See Also:
-
optfunction
Description copied from class:LuaValue
Check that optional argument is a function and return asLuaFunction
A
LuaFunction
may either be a Java function that implements functionality directly in Java, or aLuaClosure
which is aLuaFunction
that executes lua bytecode.- Overrides:
optfunction
in classLuaValue
- Parameters:
defval
-LuaFunction
to return ifthis
is nil or none- Returns:
this
cast toLuaFunction
if a function,defval
if nil or none, throwsLuaError
otherwise- See Also:
-
getmetatable
Description copied from class:LuaValue
Get the metatable for thisLuaValue
For
LuaTable
andLuaUserdata
instances, the metatable returned is this instance metatable. For all other types, the class metatable value will be returned.- Overrides:
getmetatable
in classLuaValue
- Returns:
- metatable, or null if it there is none
-
tojstring
Description copied from class:LuaValue
Convert to human readable String for any type. -
strvalue
Description copied from class:LuaValue
-
classnamestub
Return the last part of the class name, to be used as a function name in tojstring and elsewhere.- Returns:
- String naming the last part of the class name after the last dot (.) or dollar sign ($). If the first character is '_', it is skipped.
-
name
Return a human-readable name for this function. Returns the last part of the class name by default. Is overridden by LuaClosure to return the source file and line, and by LibFunctions to return the name.- Returns:
- common name for this function.
-