Search in sources :

Example 11 with Varargs

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;
}
Also used : LuaTable(org.luaj.vm2.LuaTable) Varargs(org.luaj.vm2.Varargs) VarArgFunction(org.luaj.vm2.lib.VarArgFunction)

Example 12 with Varargs

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;
}
Also used : Varargs(org.luaj.vm2.Varargs)

Example 13 with Varargs

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;
}
Also used : LuaValue(org.luaj.vm2.LuaValue) LuaViewApi(com.taobao.luaview.fun.mapper.LuaViewApi)

Example 14 with Varargs

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));
    }
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 15 with Varargs

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);
}
Also used : LuaTable(org.luaj.vm2.LuaTable) LuaFunction(org.luaj.vm2.LuaFunction)

Aggregations

Varargs (org.luaj.vm2.Varargs)24 LuaTable (org.luaj.vm2.LuaTable)22 LuaValue (org.luaj.vm2.LuaValue)20 VarArgFunction (org.luaj.vm2.lib.VarArgFunction)16 LuaString (org.luaj.vm2.LuaString)10 LuaFunction (org.luaj.vm2.LuaFunction)5 LuaViewApi (com.taobao.luaview.fun.mapper.LuaViewApi)2 UDView (com.taobao.luaview.userdata.ui.UDView)2 List (java.util.List)2 LuanObjImage (net.schattenkind.androidLove.luan.obj.LuanObjImage)2 Buffer (org.luaj.vm2.Buffer)2 LuaThread (org.luaj.vm2.LuaThread)2 Point (android.graphics.Point)1 Sensor (android.hardware.Sensor)1 SoundPool (android.media.SoundPool)1 UDBitmap (com.taobao.luaview.userdata.kit.UDBitmap)1 UDData (com.taobao.luaview.userdata.kit.UDData)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1