use of org.luaj.vm2.Varargs in project love-android by hagish.
the class LuanObjFont method CreateMetaTable.
public static LuaTable CreateMetaTable(final LuanGraphics g) {
LuaTable mt = LuaValue.tableOf();
LuaTable t = LuaValue.tableOf();
mt.set("__index", t);
// / height = Font:getHeight( )
t.set("getHeight", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).font_h);
}
});
// / height = Font:getLineHeight( )
t.set("getLineHeight", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).line_h);
}
});
// / width = Font:getWidth( line )
t.set("getWidth", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).getLineW(args.checkjstring(2)));
}
});
// / Font:setLineHeight( height )
t.set("setLineHeight", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).line_h = (float) args.checkdouble(2);
return LuaValue.NONE;
}
});
// / Font:getWrap(text, width)
// / Returns how many lines text would be wrapped to. This function accounts for newlines correctly (i.e. '\n')
// / TODO:dummy
t.set("getWrap", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
g.vm.NotImplemented("Font:getWrap");
return LuaValue.valueOf(1);
}
});
// / type = Object:type() , e.g. "Image" or audio:"Source"
t.set("type", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf("Font");
}
});
// / b = Object:typeOf( name )
t.set("typeOf", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
String s = args.checkjstring(2);
return LuaValue.valueOf(s.equals("Object") || s.equals("Font"));
}
});
return mt;
}
use of org.luaj.vm2.Varargs in project LuaViewSDK by alibaba.
the class UIRecyclerViewMethodMapper method initParams.
@Override
public Varargs initParams(U view, Varargs varargs) {
Varargs ret = super.initParams(view, varargs);
this.reload(view, varargs);
return ret;
}
use of org.luaj.vm2.Varargs in project LuaViewSDK by alibaba.
the class UIRefreshLayoutViewMethodMapper method setRefreshingOffset.
@LuaViewApi(revisions = { "名称去掉set" })
public LuaValue setRefreshingOffset(U view, Varargs varargs) {
final LuaValue offset = varargs.optvalue(2, NIL);
view.setRefreshingOffset(offset.tofloat());
return this;
}
use of org.luaj.vm2.Varargs in project LuaViewSDK by alibaba.
the class VibratorMethodMapper method vibrate.
/**
* 开始震动
*
* @param vibrator
* @param varargs
* @return
*/
public LuaValue vibrate(U vibrator, Varargs varargs) {
if (varargs.narg() > 2 || (varargs.narg() > 1 && varargs.istable(2))) {
final LuaTable luaTable = LuaUtil.getTable(varargs, 2);
final Integer repeat = LuaUtil.toJavaInt(varargs.arg(3));
return vibrator.vibrate(luaTable, repeat);
} else {
final Double time = LuaUtil.getDouble(varargs, 2);
return vibrator.vibrate((long) (time != null ? time * DateUtil.ONE_SECOND : DateUtil.ONE_SECOND));
}
}
use of org.luaj.vm2.Varargs 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);
}
Aggregations