Search in sources :

Example 16 with 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) {
    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;
}
Also used : CoroutineLib(org.luaj.vm2.lib.CoroutineLib) TableLib(org.luaj.vm2.lib.TableLib) Bit32Lib(org.luaj.vm2.lib.Bit32Lib) StringLib(org.luaj.vm2.lib.StringLib) PackageLib(org.luaj.vm2.lib.PackageLib)

Example 17 with 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;
}
Also used : DebugLib(org.luaj.vm2.lib.DebugLib)

Example 18 with 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;
}
Also used : Globals(org.luaj.vm2.Globals) CoroutineLib(org.luaj.vm2.lib.CoroutineLib) TableLib(org.luaj.vm2.lib.TableLib) Bit32Lib(org.luaj.vm2.lib.Bit32Lib) StringLib(org.luaj.vm2.lib.StringLib) PackageLib(org.luaj.vm2.lib.PackageLib)

Example 19 with 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;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 20 with Globals

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;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Aggregations

Globals (org.luaj.vm2.Globals)9 LuaTable (org.luaj.vm2.LuaTable)5 LuaValue (org.luaj.vm2.LuaValue)3 LuaClosure (org.luaj.vm2.LuaClosure)2 Prototype (org.luaj.vm2.Prototype)2 Bit32Lib (org.luaj.vm2.lib.Bit32Lib)2 CoroutineLib (org.luaj.vm2.lib.CoroutineLib)2 DebugLib (org.luaj.vm2.lib.DebugLib)2 PackageLib (org.luaj.vm2.lib.PackageLib)2 StringLib (org.luaj.vm2.lib.StringLib)2 TableLib (org.luaj.vm2.lib.TableLib)2 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 HorizontalScrollView (android.widget.HorizontalScrollView)1 LuaView (com.taobao.luaview.global.LuaView)1 UDLuaTable (com.taobao.luaview.userdata.base.UDLuaTable)1 UDView (com.taobao.luaview.userdata.ui.UDView)1 UDViewGroup (com.taobao.luaview.userdata.ui.UDViewGroup)1 LVViewGroup (com.taobao.luaview.view.LVViewGroup)1 ILVView (com.taobao.luaview.view.interfaces.ILVView)1