use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.
the class JsePlatform method standardGlobals.
/**
* Create a standard set of globals for JSE including all the libraries.
*
* @return Table of globals initialized with the standard JSE libraries
* @see #debugGlobals()
* @see JsePlatform
* @see JmePlatform
*/
public static Globals standardGlobals(Globals globals) {
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new CoroutineLib());
globals.load(new JseMathLib());
globals.load(new JseOsLib());
// globals.load(new JseIoLib());//安全考虑,删除for LuaView
// globals.load(new LuajavaLib());//安全考虑,删除for LuaView
LoadState.install(globals);
LuaC.install(globals);
return globals;
}
use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.
the class JsePlatform method debugGlobals.
/** Create standard globals including the {@link debug} library.
*
* @return Table of globals initialized with the standard JSE and debug libraries
* @see #standardGlobals()
* @see JsePlatform
* @see JmePlatform
* @see DebugLib
*/
public static Globals debugGlobals(Globals globals) {
standardGlobals(globals);
globals.load(new DebugLib());
return globals;
}
use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.
the class JsePlatform method standardGlobals.
/**
* Create a standard set of globals for JSE including all the libraries.
*
* @return Table of globals initialized with the standard JSE libraries
* @see #debugGlobals()
* @see JsePlatform
* @see JmePlatform
*/
public static Globals standardGlobals() {
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new Bit32Lib());
globals.load(new TableLib());
globals.load(new StringLib());
globals.load(new CoroutineLib());
globals.load(new JseMathLib());
globals.load(new JseOsLib());
// globals.load(new JseIoLib());//安全考虑,删除for LuaView
// globals.load(new LuajavaLib());//安全考虑,删除for LuaView
LoadState.install(globals);
LuaC.install(globals);
return globals;
}
use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.
the class CoroutineLib method call.
public LuaValue call(LuaValue modname, LuaValue env) {
globals = env.checkglobals();
LuaTable coroutine = new LuaTable();
coroutine.set("create", new create());
coroutine.set("resume", new resume());
coroutine.set("running", new running());
coroutine.set("status", new status());
coroutine.set("yield", new yield());
coroutine.set("wrap", new wrap());
env.set("coroutine", coroutine);
env.get("package").get("loaded").set("coroutine", coroutine);
return coroutine;
}
use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.
the class IoLib method call.
public LuaValue call(LuaValue modname, LuaValue env) {
globals = env.checkglobals();
// io lib functions
LuaTable t = new LuaTable();
bind(t, IoLibV.class, IO_NAMES);
// create file methods table
filemethods = new LuaTable();
bind(filemethods, IoLibV.class, FILE_NAMES, FILE_CLOSE);
// set up file metatable
LuaTable mt = new LuaTable();
bind(mt, IoLibV.class, new String[] { "__index" }, IO_INDEX);
t.setmetatable(mt);
// all functions link to library instance
setLibInstance(t);
setLibInstance(filemethods);
setLibInstance(mt);
// return the table
env.set("io", t);
env.get("package").get("loaded").set("io", t);
return t;
}
Aggregations