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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations