use of org.luaj.vm2.LuaFunction in project aerospike-client-java by aerospike.
the class LuaMap method merge.
public LuaMap merge(LuaMap map2, LuaFunction func) {
HashMap<LuaValue, LuaValue> target = new HashMap<LuaValue, LuaValue>(map.size() + map2.map.size());
target.putAll(map);
boolean hasFunc = !(func == null || func.isnil());
for (Entry<LuaValue, LuaValue> entry : map2.map.entrySet()) {
if (hasFunc) {
LuaValue value = map.get(entry.getKey());
if (value != null) {
Varargs ret = func.invoke(value, entry.getValue());
target.put(entry.getKey(), (LuaValue) ret);
continue;
}
}
target.put(entry.getKey(), entry.getValue());
}
return new LuaMap(instance, target);
}
use of org.luaj.vm2.LuaFunction in project LuaViewSDK by alibaba.
the class HttpMethodMapper method post.
/**
* pos 请求
*
* @param http
* @param varargs
* @return
*/
public LuaValue post(U http, Varargs varargs) {
final String url = LuaUtil.getString(varargs, 2);
final LuaTable params = LuaUtil.getTable(varargs, 3, 2);
final LuaFunction callback = LuaUtil.getFunction(varargs, 4, 3, 2);
return http.post(url, params, callback);
}
use of org.luaj.vm2.LuaFunction in project LuaViewSDK by alibaba.
the class BitmapMethodMapper method sprite.
// --------------------------------------- API --------------------------------------------------
/**
* 切割bitmap
*
* @param bitmap
* @param varargs
* @return
*/
public LuaValue sprite(U bitmap, Varargs varargs) {
final int x = DimenUtil.dpiToPx(varargs.arg(2));
final int y = DimenUtil.dpiToPx(varargs.arg(3));
final int width = DimenUtil.dpiToPx(varargs.arg(4));
final int height = DimenUtil.dpiToPx(varargs.arg(5));
final LuaFunction callback = LuaUtil.getFunction(varargs, 6);
return bitmap.sprite(x, y, width, height, callback);
}
use of org.luaj.vm2.LuaFunction 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.LuaFunction in project LuaViewSDK by alibaba.
the class UDHttp method initVarargs.
/**
* 初始化数据
*/
private void initVarargs() {
final LuaValue param1 = getInitParam1();
final LuaFunction callback = LuaUtil.getFunction(initParams, 2);
final String method = LuaUtil.getString(param1, "method");
final LuaTable params = LuaUtil.getTable(param1, "params");
setMethod(method);
setParams(params);
setCallback(callback);
disableConnectionReuseIfNecessary();
}
Aggregations