Search in sources :

Example 6 with Globals

use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.

the class LVCustomViewPagerIndicator method createView.

/**
     * create view
     *
     * @param pos
     * @return
     */
private LuaValue createView(int pos, int currentItem) {
    Globals globals = this.mLuaUserdata.getGlobals();
    //View封装
    final LVViewGroup container = createCellLayout();
    final UDViewGroup cell = new UDViewGroup(container, globals, null);
    //对外数据封装,必须使用LuaTable
    final UDLuaTable cellData = new UDLuaTable(cell);
    //call init
    globals.saveContainer(container);
    //初始化
    this.mLuaUserdata.callCellInit(cellData, pos, currentItem);
    globals.restoreContainer();
    //set tag
    View view = cellData.getView();
    if (view != null) {
        view.setTag(Constants.RES_LV_TAG, cellData);
    }
    return cellData;
}
Also used : Globals(org.luaj.vm2.Globals) UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable) UDViewGroup(com.taobao.luaview.userdata.ui.UDViewGroup) LVViewGroup(com.taobao.luaview.view.LVViewGroup) ILVView(com.taobao.luaview.view.interfaces.ILVView) HorizontalScrollView(android.widget.HorizontalScrollView) UDView(com.taobao.luaview.userdata.ui.UDView) View(android.view.View)

Example 7 with Globals

use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.

the class OsLib method call.

public LuaValue call(LuaValue modname, LuaValue env) {
    globals = env.checkglobals();
    LuaTable os = new LuaTable();
    for (int i = 0; i < NAMES.length; ++i) os.set(NAMES[i], new OsLibFunc(i, NAMES[i]));
    env.set("os", os);
    env.get("package").get("loaded").set("os", os);
    return os;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 8 with Globals

use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.

the class PackageLib method call.

public LuaValue call(LuaValue modname, LuaValue env) {
    globals = env.checkglobals();
    globals.set("require", new require());
    package_ = new LuaTable();
    package_.set(_LOADED, new LuaTable());
    package_.set(_PRELOAD, new LuaTable());
    package_.set(_PATH, LuaValue.valueOf(DEFAULT_LUA_PATH));
    package_.set(_LOADLIB, new loadlib());
    package_.set(_SEARCHPATH, new searchpath());
    LuaTable searchers = new LuaTable();
    searchers.set(1, preload_searcher = new preload_searcher());
    searchers.set(2, lua_searcher = new lua_searcher());
    searchers.set(3, java_searcher = new java_searcher());
    package_.set(_SEARCHERS, searchers);
    package_.get(_LOADED).set("package", package_);
    env.set("package", package_);
    globals.package_ = this;
    return env;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 9 with Globals

use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.

the class DebugLib method call.

public LuaValue call(LuaValue modname, LuaValue env) {
    globals = env.checkglobals();
    globals.debuglib = this;
    LuaTable debug = new LuaTable();
    debug.set("debug", new debug());
    debug.set("gethook", new gethook());
    debug.set("getinfo", new getinfo());
    debug.set("getlocal", new getlocal());
    debug.set("getmetatable", new getmetatable());
    debug.set("getregistry", new getregistry());
    debug.set("getupvalue", new getupvalue());
    debug.set("getuservalue", new getuservalue());
    debug.set("sethook", new sethook());
    debug.set("setlocal", new setlocal());
    debug.set("setmetatable", new setmetatable());
    debug.set("setupvalue", new setupvalue());
    debug.set("setuservalue", new setuservalue());
    debug.set("traceback", new traceback());
    debug.set("upvalueid", new upvalueid());
    debug.set("upvaluejoin", new upvaluejoin());
    debug.set("traceback_count", new tracebackCount());
    //extend for luaview
    new com.taobao.luaview.vm.extend.DebugLib(this, globals).extend(debug);
    env.set("debug", debug);
    env.get("package").get("loaded").set("debug", debug);
    return debug;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 10 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.load(new DebugLib());
    return globals;
}
Also used : Globals(org.luaj.vm2.Globals) DebugLib(org.luaj.vm2.lib.DebugLib)

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