Package com.prineside.luaj
Class LuaFunction
java.lang.Object
com.prineside.luaj.Varargs
com.prineside.luaj.LuaValue
com.prineside.luaj.LuaFunction
- Direct Known Subclasses:
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 -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic LuaValueShared 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 throwLuaErrorif notReturn the last part of the class name, to be used as a function name in tojstring and elsewhere.Get the metatable for thisLuaValuebooleanCheck ifthisis afunctionname()Return a human-readable name for this function.optfunction(LuaFunction defval) Check that optional argument is a function and return asLuaFunctionstrvalue()Convert to human readable String for any type.inttype()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, cachedDouble, cachedInt, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, cachedVarargsOf, call, call, call, call, call, checkboolean, checkclosure, checkdouble, checkglobals, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, comparemt, concat, concat, concatmt, concatTo, concatTo, concatTo, 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, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isint, isinttype, islong, isnil, isnumber, 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, 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, optinteger, 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, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOfMethods inherited from class com.prineside.luaj.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, 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, optinteger, 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:LuaValueGet the enumeration value for the type of this value.- Specified by:
typein 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:LuaValueGet the String name of the type of this value.- Specified by:
typenamein classLuaValue- Returns:
- name from type name list
LuaValue.TYPE_NAMEScorresponding to the type of this value: "nil", "boolean", "number", "string", "table", "function", "userdata", "thread" - See Also:
-
isfunction
public boolean isfunction()Description copied from class:LuaValueCheck ifthisis afunction- Overrides:
isfunctionin classLuaValue- Returns:
- true if this is a
function, otherwise false - See Also:
-
checkfunction
Description copied from class:LuaValueCheck that the value is a function , or throwLuaErrorif notA
LuaFunctionmay either be a Java function that implements functionality directly in Java, or aLuaClosurewhich is aLuaFunctionthat executes lua bytecode.- Overrides:
checkfunctionin classLuaValue- Returns:
thisif it is a lua function or closure- See Also:
-
optfunction
Description copied from class:LuaValueCheck that optional argument is a function and return asLuaFunctionA
LuaFunctionmay either be a Java function that implements functionality directly in Java, or aLuaClosurewhich is aLuaFunctionthat executes lua bytecode.- Overrides:
optfunctionin classLuaValue- Parameters:
defval-LuaFunctionto return ifthisis nil or none- Returns:
thiscast toLuaFunctionif a function,defvalif nil or none, throwsLuaErrorotherwise- See Also:
-
getmetatable
Description copied from class:LuaValueGet the metatable for thisLuaValueFor
LuaTableandLuaUserdatainstances, the metatable returned is this instance metatable. For all other types, the class metatable value will be returned.- Overrides:
getmetatablein classLuaValue- Returns:
- metatable, or null if it there is none
- See Also:
-
tojstring
Description copied from class:LuaValueConvert 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.
-