|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.luaj.vm2.Varargs
org.luaj.vm2.LuaValue
org.luaj.vm2.LuaTable
org.luaj.vm2.Globals
public class Globals
Global environment used by luaj.
Contains the global variables referenced by lua libraries such as stdin and stdout, the resrouce finder which is used tolook up files in a platform independent way, the installed lua compiler, the math library in use, debugging calls stack, and so on.
In a multithreded server environment, each server thread should create one Globals instance, which will be logically distance and not interfere with each other, but share certain static immutable resources such as class data and string data.
Typically, this is constructed indirectly by a call to
JsePlatform.standardGlobasl()
or JmePlatform.standardGlobals()
,
and then used to load lua scripts for execution as in the following example.
Globals _G = JsePlatform.standardGlobals();
_G.compiler.load( new ByteArrayInputStream("print 'hello'".getBytes()), "main.lua", _G ).call();
LoadState.LuaCompiler
,
JsePlatform
,
JmePlatform
,
LuaValue
Field Summary | |
---|---|
BaseLib |
baselib
The BaseLib instance loaded into this Globals |
LoadState.LuaCompiler |
compiler
The installed compiler. |
DebugLib |
debuglib
The DebugLib instance loaded into this Globals, or null if debugging is not enabled |
LuaValue |
errorfunc
The current error handler for this Globals |
ResourceFinder |
FINDER
The installed ResourceFinder for looking files by name. |
PackageLib |
package_
The PackageLib instance loaded into this Globals |
LuaThread |
running
The currently running thread. |
java.io.PrintStream |
STDERR
The current default error stream. |
java.io.InputStream |
STDIN
The current default input stream. |
java.io.PrintStream |
STDOUT
The current default output stream. |
Fields inherited from class org.luaj.vm2.LuaTable |
---|
array, hash, hashEntries, m_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 | |
---|---|
Globals()
|
Method Summary | |
---|---|
Globals |
checkglobals()
Check that this object is a Globals object, and return it, otherwise throw an error. |
LuaValue |
loadFile(java.lang.String filename)
Convenience function for loading a file. |
LuaValue |
loadString(java.lang.String script,
java.lang.String chunkname)
Convenience function to load a string value as a script. |
Varargs |
yield(Varargs args)
Function which yields the current thread. |
Methods inherited from class org.luaj.vm2.LuaTable |
---|
arrayget, checktable, concat, defaultEntry, entry, eq_b, eq, get, get, getArrayLength, getHashLength, getmetatable, hashget, hashmod, hashpow2, hashset, hashSlot, inext, insert, isLargeKey, istable, keyCount, keys, len, length, next, opttable, presize, presize, rawget, rawget, rawlen, rawset, rawset, remove, set, set, setmetatable, sort, toLuaValue, type, typename, unpack, unpack, unpack, useWeakKeys, useWeakValues, wrap |
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 |
Field Detail |
---|
public java.io.InputStream STDIN
public java.io.PrintStream STDOUT
public java.io.PrintStream STDERR
public ResourceFinder FINDER
public LoadState.LuaCompiler compiler
public LuaThread running
public BaseLib baselib
public PackageLib package_
public DebugLib debuglib
public LuaValue errorfunc
Constructor Detail |
---|
public Globals()
Method Detail |
---|
public Globals checkglobals()
checkglobals
in class LuaValue
this
if if an instance fof public LuaValue loadFile(java.lang.String filename)
filename
- Name of the file to load.
LuaError
- if the file could not be loaded.public LuaValue loadString(java.lang.String script, java.lang.String chunkname)
script
- Contents of a lua script, such as "print 'hello, world.'"chunkname
- Name that will be used within the chunk as the source.
LuaError
- if the script could not be compiled.public Varargs yield(Varargs args)
args
- Arguments to supply as return values in the resume function of the resuming thread.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |