Java Code Examples for org.luaj.vm2.Varargs#checktable()

The following examples show how to use org.luaj.vm2.Varargs#checktable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	LuaTable t = args.checktable(1);
	switch (args.narg()) {
	case 1: return t.unpack();
	case 2: return t.unpack(args.checkint(2));
	default: return t.unpack(args.checkint(2), args.checkint(3));
	}
}
 
Example 2
Source File: TableLib.java    From XPrivacyLua with GNU General Public License v3.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	LuaTable t = args.checktable(1);
	switch (args.narg()) {
	case 1: return t.unpack();
	case 2: return t.unpack(args.checkint(2));
	default: return t.unpack(args.checkint(2), args.checkint(3));
	}
}
 
Example 3
Source File: TableLib.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	LuaTable t = args.checktable(1);
	switch (args.narg()) {
	case 1: return t.unpack();
	case 2: return t.unpack(args.checkint(2));
	default: return t.unpack(args.checkint(2), args.checkint(3));
	}
}
 
Example 4
Source File: TableLib.java    From luaj with MIT License 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	LuaTable table = args.checktable(1);
	int size = table.length();
	int pos = args.optint(2, size);
	if (pos != size && (pos < 1 || pos > size + 1)) {
		argerror(2, "position out of bounds: " + pos + " not between 1 and " + (size + 1));
	}
	return table.remove(pos);
}
 
Example 5
Source File: TableLib.java    From luaj with MIT License 4 votes vote down vote up
public Varargs invoke(Varargs args) {
	LuaTable t = args.checktable(1);
	// do not waste resource for calc rawlen if arg3 is not nil
	int len = args.arg(3).isnil() ? t.length() : 0;
	return t.unpack(args.optint(2, 1), args.optint(3, len));
}