Search in sources :

Example 1 with LuaValue

use of org.luaj.vm2.LuaValue in project aerospike-client-java by aerospike.

the class LuaAerospikeLib method call.

public LuaValue call(LuaValue env) {
    LuaTable meta = new LuaTable();
    meta.set("__index", new index());
    LuaTable table = new LuaTable();
    table.setmetatable(meta);
    instance.registerPackage("aerospike", table);
    return table;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 2 with LuaValue

use of org.luaj.vm2.LuaValue in project aerospike-client-java by aerospike.

the class LuaBytesLib method call.

public LuaValue call(LuaValue env) {
    LuaTable meta = new LuaTable(0, 2);
    meta.set("__call", new create(instance));
    LuaTable table = new LuaTable(0, 50);
    table.setmetatable(meta);
    new bytescode(table, 0, "size");
    new bytescode(table, 2, "get_byte");
    new bytescode(table, 3, "get_type");
    new bytescode(table, 4, "get_string");
    new bytescode(table, 5, "get_bytes");
    new bytescode(table, 6, "get_int16");
    new bytescode(table, 6, "get_int16_be");
    new bytescode(table, 7, "get_int16_le");
    new bytescode(table, 8, "get_int32");
    new bytescode(table, 8, "get_int32_be");
    new bytescode(table, 9, "get_int32_le");
    new bytescode(table, 10, "get_int64");
    new bytescode(table, 10, "get_int64_be");
    new bytescode(table, 11, "get_int64_le");
    new bytescode(table, 12, "get_var_int");
    new bytescode(table, 13, "set_var_int");
    new bytescode(table, 14, "append_var_int");
    new bytesbool(table, 0, "set_byte");
    new bytesbool(table, 1, "set_size");
    new bytesbool(table, 2, "set_type");
    new bytesbool(table, 3, "set_string");
    new bytesbool(table, 4, "set_bytes");
    new bytesbool(table, 5, "set_int16");
    new bytesbool(table, 5, "set_int16_be");
    new bytesbool(table, 6, "set_int16_le");
    new bytesbool(table, 7, "set_int32");
    new bytesbool(table, 7, "set_int32_be");
    new bytesbool(table, 8, "set_int32_le");
    new bytesbool(table, 9, "set_int64");
    new bytesbool(table, 9, "set_int64_be");
    new bytesbool(table, 10, "set_int64_le");
    new bytesbool(table, 11, "append_string");
    new bytesbool(table, 12, "append_bytes");
    new bytesbool(table, 13, "append_byte");
    new bytesbool(table, 14, "append_int16");
    new bytesbool(table, 14, "append_int16_be");
    new bytesbool(table, 15, "append_int16_le");
    new bytesbool(table, 16, "append_int32");
    new bytesbool(table, 16, "append_int32_be");
    new bytesbool(table, 17, "append_int32_le");
    new bytesbool(table, 18, "append_int64");
    new bytesbool(table, 18, "append_int64_be");
    new bytesbool(table, 19, "append_int64_le");
    instance.registerPackage("bytes", table);
    return table;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 3 with LuaValue

use of org.luaj.vm2.LuaValue in project aerospike-client-java by aerospike.

the class LuaList method luaToObject.

public Object luaToObject() {
    ArrayList<Object> target = new ArrayList<Object>(list.size());
    for (LuaValue luaValue : list) {
        Object obj = LuaUtil.luaToObject(luaValue);
        target.add(obj);
    }
    return target;
}
Also used : ArrayList(java.util.ArrayList) LuaValue(org.luaj.vm2.LuaValue)

Example 4 with LuaValue

use of org.luaj.vm2.LuaValue in project aerospike-client-java by aerospike.

the class LuaListLib method call.

public LuaValue call(LuaValue env) {
    LuaTable meta = new LuaTable(0, 2);
    meta.set("__call", new create(instance));
    LuaTable table = new LuaTable(0, 15);
    table.setmetatable(meta);
    table.set("create", new create(instance));
    new listcode(table, 0, "size");
    new listcode(table, 4, "iterator");
    new listcode(table, 5, "insert");
    new listcode(table, 6, "append");
    new listcode(table, 7, "prepend");
    new listcode(table, 8, "take");
    new listcode(table, 9, "remove");
    new listcode(table, 10, "drop");
    new listcode(table, 11, "trim");
    new listcode(table, 12, "clone");
    new listcode(table, 13, "concat");
    new listcode(table, 14, "merge");
    instance.registerPackage("list", table);
    return table;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 5 with LuaValue

use of org.luaj.vm2.LuaValue 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);
}
Also used : HashMap(java.util.HashMap) Varargs(org.luaj.vm2.Varargs) LuaValue(org.luaj.vm2.LuaValue)

Aggregations

LuaValue (org.luaj.vm2.LuaValue)55 LuaTable (org.luaj.vm2.LuaTable)37 Varargs (org.luaj.vm2.Varargs)12 LuaString (org.luaj.vm2.LuaString)9 VarArgFunction (org.luaj.vm2.lib.VarArgFunction)7 UDView (com.taobao.luaview.userdata.ui.UDView)6 LuaError (org.luaj.vm2.LuaError)6 LuaFunction (org.luaj.vm2.LuaFunction)6 View (android.view.View)4 Point (android.graphics.Point)3 ILVView (com.taobao.luaview.view.interfaces.ILVView)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 JSONObject (org.json.JSONObject)3 HorizontalScrollView (android.widget.HorizontalScrollView)2 AerospikeException (com.aerospike.client.AerospikeException)2 LuaViewApi (com.taobao.luaview.fun.mapper.LuaViewApi)2 UDLuaTable (com.taobao.luaview.userdata.base.UDLuaTable)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2