Search in sources :

Example 26 with LuaTable

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

the class DestroyUtil method onDestroyClosure.

public static void onDestroyClosure(LuaClosure closure) {
    if (closure != null) {
        if (closure.upValues != null) {
            UpValue upValue = null;
            for (int i = 0; i < closure.upValues.length; i++) {
                upValue = closure.upValues[i];
                //                    if (upValue != null && upValue.array != null) {
                //                        for (LuaValue value : upValue.array) {//destroy upvalues
                //                            if (value instanceof BaseUserdata) {//userdata destory
                //                                ((BaseUserdata) value).onDestroy();
                //                            } else if (value instanceof LuaTable) {//destroy table
                //                                onDestroyTable((LuaTable) value);
                //                            }
                //                        }
                //                    }
                closure.upValues[i] = null;
            }
            closure.upValues = null;
        }
    }
}
Also used : UpValue(org.luaj.vm2.UpValue)

Example 27 with LuaTable

use of org.luaj.vm2.LuaTable 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 28 with LuaTable

use of org.luaj.vm2.LuaTable 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 29 with LuaTable

use of org.luaj.vm2.LuaTable 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 30 with LuaTable

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

the class TableLib method call.

public LuaValue call(LuaValue modname, LuaValue env) {
    LuaTable table = new LuaTable();
    table.set("concat", new concat());
    table.set("insert", new insert());
    table.set("pack", new pack());
    table.set("remove", new remove());
    table.set("sort", new sort());
    table.set("unpack", new unpack());
    //TODO yesong添加的函数
    table.set("getn", new getn());
    env.set("table", table);
    env.get("package").get("loaded").set("table", table);
    return NIL;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Aggregations

LuaTable (org.luaj.vm2.LuaTable)54 LuaValue (org.luaj.vm2.LuaValue)19 Varargs (org.luaj.vm2.Varargs)16 VarArgFunction (org.luaj.vm2.lib.VarArgFunction)15 LuaError (org.luaj.vm2.LuaError)5 LuaFunction (org.luaj.vm2.LuaFunction)4 View (android.view.View)3 JSONObject (org.json.JSONObject)3 LibFunction (org.luaj.vm2.lib.LibFunction)3 BaseLuaTable (com.taobao.luaview.userdata.base.BaseLuaTable)2 UDView (com.taobao.luaview.userdata.ui.UDView)2 ILVView (com.taobao.luaview.view.interfaces.ILVView)2 List (java.util.List)2 LuanObjImage (net.schattenkind.androidLove.luan.obj.LuanObjImage)2 LuaString (org.luaj.vm2.LuaString)2 Paint (android.graphics.Paint)1 Sensor (android.hardware.Sensor)1 SoundPool (android.media.SoundPool)1 MotionEvent (android.view.MotionEvent)1 ViewGroup (android.view.ViewGroup)1