use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.
the class LuaView method create.
//---------------------------------------静态方法------------------------------------------------
/**
* create a luaview
*
* @param context
* @return
*/
public static LuaView create(final Context context) {
//初始化
init(context);
//create globals
final Globals globals = LuaViewManager.createGlobals();
//设置metaTable
return createLuaView(context, globals);
}
use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.
the class LuaViewManager method createGlobalsAsync.
/**
* 创建Globals
* 根据是否用lua-to-java bytecode来处理(如果使用LuaJC的话则会使用库bcel 533k)
*
* @return
*/
public static Globals createGlobalsAsync() {
if (sStaticGlobals != null) {
synchronized (sStaticGlobals) {
Globals result = sStaticGlobals;
sStaticGlobals = null;
return result;
}
} else {
final Globals globals = new Globals();
new SimpleTask<Globals>() {
@Override
public void doTask(Globals... params) {
setupGlobals(params != null && params.length > 0 ? params[0] : null);
}
}.executeSerial(//TODO 这里放到serial线程中执行,而不是executeInPool中执行,为了保证后续的执行时序列
globals);
return globals;
}
}
use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.
the class UDViewGroup method children.
/**
* 提供View的构造环境,注意,callback里面不能有异步操作,否则操作的时序上会混乱
*
* @param callback
* @return
*/
public UDViewGroup children(LuaFunction callback) {
if (getView() instanceof ViewGroup) {
Globals globals = getGlobals();
if (globals != null) {
globals.pushContainer(getView());
LuaUtil.callFunction(callback, this);
globals.popContainer();
}
}
return this;
}
use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.
the class GlobalsExtender method doLoad.
/**
* 真正加载一个库
*
* @param globals
* @param name
* @return
*/
public LuaValue doLoad(final Globals globals, final String name) {
if (mLazyLoadLibs != null && mLazyLoadLibs.containsKey(name)) {
final LuaValue lib = mLazyLoadLibs.get(name);
LuaValue result = globals.load(lib);
mLazyLoadLibs.remove(name);
return result;
}
return null;
}
use of org.luaj.vm2.Globals in project LuaViewSDK by alibaba.
the class GlobalsExtender method doLoad.
/**
* 真正地加载一个库
*
* @param globals
* @param p
*/
public boolean doLoad(final Globals globals, Prototype p) {
boolean isAnyLoaded = false;
if (p != null && p.k != null && p.k.length > 0) {
StringBuffer sb = new StringBuffer();
for (LuaValue name : p.k) {
if (LuaUtil.isString(name)) {
sb.append(name).append(" ");
isAnyLoaded = (doLoad(globals, name.checkjstring()) != null) || isAnyLoaded;
}
}
}
return isAnyLoaded;
}
Aggregations