Search in sources :

Example 6 with LuaValue

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

the class LuaMapLib method call.

public LuaValue call(LuaValue env) {
    LuaTable meta = new LuaTable(0, 2);
    meta.set("__call", new create(instance));
    LuaTable table = new LuaTable(0, 11);
    table.setmetatable(meta);
    table.set("create", new create(instance));
    new mapcode(table, 0, "size");
    new mapcode(table, 4, "pairs");
    new mapcode(table, 5, "keys");
    new mapcode(table, 6, "values");
    new mapcode(table, 7, "remove");
    new mapcode(table, 8, "clone");
    new mapcode(table, 9, "merge");
    new mapcode(table, 10, "diff");
    instance.registerPackage("map", table);
    return table;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 7 with LuaValue

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

the class LuaStreamLib method call.

public LuaValue call(LuaValue env) {
    LuaTable meta = new LuaTable(0, 1);
    meta.set("__tostring", new tostring());
    LuaTable table = new LuaTable(0, 10);
    table.setmetatable(meta);
    table.set("read", new read());
    table.set("readable", new readable());
    table.set("writeable", new writeable());
    table.set("write", new write());
    instance.registerPackage("stream", table);
    return table;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 8 with LuaValue

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

the class QueryAggregateExecutor method runThreads.

public void runThreads() throws AerospikeException {
    try {
        // Start thread queries to each node.
        startThreads();
        lua.loadPackage(statement);
        LuaValue[] args = new LuaValue[4 + statement.getFunctionArgs().length];
        args[0] = lua.getFunction(statement.getFunctionName());
        args[1] = LuaInteger.valueOf(2);
        args[2] = new LuaInputStream(inputQueue);
        args[3] = new LuaOutputStream(resultSet);
        int count = 4;
        for (Value value : statement.getFunctionArgs()) {
            args[count++] = value.getLuaValue(lua);
        }
        lua.call("apply_stream", args);
    } finally {
        // Send end command to user's result set.
        // If query was already cancelled, this put will be ignored.
        resultSet.put(ResultSet.END);
    }
}
Also used : LuaInputStream(com.aerospike.client.lua.LuaInputStream) LuaOutputStream(com.aerospike.client.lua.LuaOutputStream) LuaValue(org.luaj.vm2.LuaValue) Value(com.aerospike.client.Value) LuaValue(org.luaj.vm2.LuaValue)

Example 9 with LuaValue

use of org.luaj.vm2.LuaValue in project pixel-dungeon-remix by NYRDS.

the class LuaEngine method module.

@Nullable
public static LuaTable module(String module, String fallback) {
    LuaValue luaModule = getEngine().call("require", module);
    if (luaModule.istable()) {
        return luaModule.checktable();
    }
    EventCollector.logEvent("LuaError", "failed to load lua module:", module);
    luaModule = getEngine().call("require", fallback);
    if (luaModule.istable()) {
        return luaModule.checktable();
    }
    EventCollector.logEvent("LuaError", "failed to load fallback lua module:", fallback);
    return null;
}
Also used : LuaValue(org.luaj.vm2.LuaValue) Nullable(android.support.annotation.Nullable)

Example 10 with LuaValue

use of org.luaj.vm2.LuaValue in project pixel-dungeon-remix by NYRDS.

the class LuaEngine method call.

public LuaValue call(String method, Object arg1, Object arg2) {
    try {
        LuaValue methodForData = globals.get(method);
        methodForData.call(CoerceJavaToLua.coerce(arg1), CoerceJavaToLua.coerce(arg2));
    } catch (LuaError err) {
        reportLuaError(err);
    }
    return LuaValue.NIL;
}
Also used : LuaError(org.luaj.vm2.LuaError) 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