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;
}
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations