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