|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.luaj.vm2.Varargs
org.luaj.vm2.LuaValue
org.luaj.vm2.LuaFunction
org.luaj.vm2.lib.LibFunction
org.luaj.vm2.lib.TwoArgFunction
org.luaj.vm2.lib.BaseLib
org.luaj.vm2.lib.jse.JseBaseLib
public class JseBaseLib
Subclass of BaseLib
and LibFunction
which implements the lua basic library functions
and provides a directory based ResourceFinder
as the Globals.finder
.
Since JME has no file system by default, BaseLib
implements
ResourceFinder
using Class.getResource(String)
.
The JseBaseLib
implements Globals.finder
by scanning the current directory
first, then falling back to Class.getResource(String)
if that fails.
Otherwise, the behavior is the same as that of BaseLib
.
Typically, this library is included as part of a call to
JsePlatform.standardGlobals()
Globals globals = JsePlatform.standardGlobals();
globals.get("print").call(LuaValue.valueOf("hello, world"));
For special cases where the smallest possible footprint is desired,
a minimal set of libraries could be loaded
directly via LuaValue.load(LuaValue)
using code such as:
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.get("print").call(LuaValue.valueOf("hello, world"));
However, other libraries such as PackageLib are not loaded in this case.
This is a direct port of the corresponding library in C.
Globals
,
BaseLib
,
ResourceFinder
,
Globals.finder
,
LibFunction
,
JsePlatform
,
JmePlatform
,
Lua 5.2 Base Lib ReferenceField Summary |
---|
Fields inherited from class org.luaj.vm2.lib.LibFunction |
---|
name, opcode |
Fields inherited from class org.luaj.vm2.LuaFunction |
---|
s_metatable |
Fields inherited from class org.luaj.vm2.LuaValue |
---|
ADD, CALL, CONCAT, DIV, EMPTYSTRING, ENV, 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 | |
---|---|
JseBaseLib()
|
Method Summary | |
---|---|
LuaValue |
call(LuaValue modname,
LuaValue env)
Perform one-time initialization on the library by creating a table containing the library functions, adding that table to the supplied environment, adding the table to package.loaded, and returning table as the return value. |
java.io.InputStream |
findResource(java.lang.String filename)
Try to open a file in the current working directory, or fall back to base opener if not found. |
Methods inherited from class org.luaj.vm2.lib.BaseLib |
---|
loadFile, loadStream |
Methods inherited from class org.luaj.vm2.lib.TwoArgFunction |
---|
call, call, call, invoke |
Methods inherited from class org.luaj.vm2.lib.LibFunction |
---|
bind, bind, call, newupe, newupl, newupn, tojstring |
Methods inherited from class org.luaj.vm2.LuaFunction |
---|
checkfunction, classnamestub, getmetatable, isfunction, name, optfunction, strvalue, type, typename |
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, 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 |
Constructor Detail |
---|
public JseBaseLib()
Method Detail |
---|
public LuaValue call(LuaValue modname, LuaValue env)
Specifically, extend the library loading to set the default value for Globals.STDIN
call
in class BaseLib
modname
- the module name supplied if this is loaded via 'require'.env
- the environment to load into, which must be a Globals instance.
(this(arg1,arg2))
, or LuaValue.NIL
if there were none.LuaValue.call()
,
LuaValue.call(LuaValue)
,
LuaValue.call(LuaValue, LuaValue, LuaValue)
,
LuaValue.invoke(LuaValue, Varargs)
,
LuaValue.method(String,LuaValue,LuaValue)
,
LuaValue.method(LuaValue,LuaValue,LuaValue)
public java.io.InputStream findResource(java.lang.String filename)
findResource
in interface ResourceFinder
findResource
in class BaseLib
filename
-
BaseLib
,
ResourceFinder
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |