|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.luaj.vm2.Varargs org.luaj.vm2.LuaValue org.luaj.vm2.LuaFunction
public abstract class LuaFunction
Base class for functions implemented in Java.
Direct subclass include 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.
LuaValue
,
LibFunction
,
LuaClosure
Field Summary | |
---|---|
protected LuaValue |
env
|
static LuaValue |
s_metatable
Shared static metatable for all functions and closures. |
Fields inherited from class org.luaj.vm2.LuaValue |
---|
ADD, CALL, CONCAT, DIV, EMPTYSTRING, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, 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 | |
---|---|
LuaFunction()
|
|
LuaFunction(LuaValue env)
|
Method Summary | |
---|---|
LuaValue |
checkfunction()
Check that the value is a function , or throw LuaError if not |
LuaValue |
getfenv()
Get the environemnt for an instance. |
LuaValue |
getmetatable()
Get the metatable for this LuaValue |
boolean |
isfunction()
Check if this is a function |
LuaFunction |
optfunction(LuaFunction defval)
Check that optional argument is a function and return as LuaFunction |
void |
setfenv(LuaValue env)
Set the environment on an object. |
int |
type()
Get the enumeration value for the type of this value. |
java.lang.String |
typename()
Get the String name of the type of this value. |
Methods inherited from class org.luaj.vm2.Varargs |
---|
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, 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, subargs, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static LuaValue s_metatable
protected LuaValue env
Constructor Detail |
---|
public LuaFunction()
public LuaFunction(LuaValue env)
Method Detail |
---|
public int type()
LuaValue
type
in class LuaValue
TNIL
,
TBOOLEAN
,
TNUMBER
,
TSTRING
,
TTABLE
,
TFUNCTION
,
TUSERDATA
,
TTHREAD
LuaValue.typename()
public java.lang.String typename()
LuaValue
typename
in class LuaValue
LuaValue.TYPE_NAMES
corresponding to the type of this value:
"nil", "boolean", "number", "string",
"table", "function", "userdata", "thread"LuaValue.type()
public boolean isfunction()
LuaValue
this
is a function
isfunction
in class LuaValue
function
, otherwise falseLuaValue.isclosure()
,
LuaValue.checkfunction()
,
#optfunciton(LuaFunction)
,
LuaValue.TFUNCTION
public LuaValue checkfunction()
LuaValue
LuaError
if not
A function is considered anything whose LuaValue.type()
returns TFUNCTION
.
In practice it will be either a built-in Java function, typically deriving from
LuaFunction
or a LuaClosure
which represents lua source compiled
into lua bytecode.
checkfunction
in class LuaValue
this
if if a lua function or closureLuaValue.checkclosure()
public LuaFunction optfunction(LuaFunction defval)
LuaValue
LuaFunction
A LuaFunction
may either be a Java function that implements
functionality directly in Java,
or a LuaClosure
which is a LuaFunction
that executes lua bytecode.
optfunction
in class LuaValue
defval
- LuaFunction
to return if this
is nil or none
this
cast to LuaFunction
if a function,
defval
if nil or none,
throws LuaError
otherwiseLuaValue.checkfunction()
,
LuaValue.isfunction()
,
LuaValue.TFUNCTION
public LuaValue getmetatable()
LuaValue
LuaValue
For LuaTable
and LuaUserdata
instances,
the metatable returned is this instance metatable.
For all other types, the class metatable value will be returned.
getmetatable
in class LuaValue
LuaBoolean.s_metatable
,
LuaNumber.s_metatable
,
LuaNil.s_metatable
,
s_metatable
,
LuaThread.s_metatable
public LuaValue getfenv()
LuaValue
getfenv
in class LuaValue
LuaValue
currently set as the instances environent.public void setfenv(LuaValue env)
LuaValue
Typically the environment is created once per application via a platform
helper method such as JsePlatform.standardGlobals()
However, any object can serve as an environment if it contains suitable metatag
values to implement LuaValue.get(LuaValue)
to provide the environment values.
setfenv
in class LuaValue
env
- LuaValue
(typically a LuaTable
) containing the environment.JmePlatform
,
JsePlatform
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |