Search in sources :

Example 46 with LuaTable

use of org.luaj.vm2.LuaTable in project love-android by hagish.

the class LuaUtils method getFromTableByPath.

public static LuaValue getFromTableByPath(LuaTable t, String path) {
    String[] pathParts = path.split("\\.");
    LuaValue cur = t;
    for (String part : pathParts) {
        LuaValue next = cur.get(part);
        if (next.equals(LuaValue.NIL)) {
            cur = next;
            break;
        } else {
            cur = next;
        }
    }
    return cur;
}
Also used : LuaString(org.luaj.vm2.LuaString) LuaValue(org.luaj.vm2.LuaValue)

Example 47 with LuaTable

use of org.luaj.vm2.LuaTable in project kitten by cloudera.

the class LuaWrapper method createTable.

public LuaWrapper createTable(String name) {
    LuaTable lt = new LuaTable();
    env.set(name, lt);
    return new LuaWrapper(lt);
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 48 with LuaTable

use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.

the class CustomError method initPanel.

@Override
public void initPanel() {
    Button button = new Button(getContext());
    button.setText("Error");
    LayoutParams relativeLayout = LuaViewUtil.createRelativeLayoutParamsWW();
    relativeLayout.addRule(RelativeLayout.CENTER_IN_PARENT);
    addView(button, relativeLayout);
    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            LuaTable table = new LuaTable();
            table.insert(1, LuaValue.valueOf(1.4));
            callLuaCallback("Message", "Error", 100, new Object(), table);
        }
    });
}
Also used : LuaTable(org.luaj.vm2.LuaTable) Button(android.widget.Button) View(android.view.View)

Example 49 with LuaTable

use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.

the class LuaViewManager method bind.

/**
     * bind lua functions using opcode
     *
     * @param factory
     * @param methods
     * @return
     */
public static LuaTable bind(Class<? extends LibFunction> factory, List<String> methods) {
    LuaTable env = new LuaTable();
    try {
        if (methods != null) {
            for (int i = 0; i < methods.size(); i++) {
                LibFunction f = factory.newInstance();
                f.opcode = i;
                f.method = null;
                f.name = methods.get(i);
                env.set(f.name, f);
            }
        }
    } catch (Exception e) {
        throw new LuaError("[Bind Failed] " + e);
    } finally {
        return env;
    }
}
Also used : LuaTable(org.luaj.vm2.LuaTable) LuaError(org.luaj.vm2.LuaError) LibFunction(org.luaj.vm2.lib.LibFunction)

Example 50 with LuaTable

use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.

the class HttpMethodMapper method get.

/**
     * get请求
     *
     * @param http
     * @param varargs
     * @return
     */
public LuaValue get(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.get(url, params, callback);
}
Also used : LuaTable(org.luaj.vm2.LuaTable) LuaFunction(org.luaj.vm2.LuaFunction)

Aggregations

LuaTable (org.luaj.vm2.LuaTable)54 LuaValue (org.luaj.vm2.LuaValue)19 Varargs (org.luaj.vm2.Varargs)16 VarArgFunction (org.luaj.vm2.lib.VarArgFunction)15 LuaError (org.luaj.vm2.LuaError)5 LuaFunction (org.luaj.vm2.LuaFunction)4 View (android.view.View)3 JSONObject (org.json.JSONObject)3 LibFunction (org.luaj.vm2.lib.LibFunction)3 BaseLuaTable (com.taobao.luaview.userdata.base.BaseLuaTable)2 UDView (com.taobao.luaview.userdata.ui.UDView)2 ILVView (com.taobao.luaview.view.interfaces.ILVView)2 List (java.util.List)2 LuanObjImage (net.schattenkind.androidLove.luan.obj.LuanObjImage)2 LuaString (org.luaj.vm2.LuaString)2 Paint (android.graphics.Paint)1 Sensor (android.hardware.Sensor)1 SoundPool (android.media.SoundPool)1 MotionEvent (android.view.MotionEvent)1 ViewGroup (android.view.ViewGroup)1