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

The following examples show how to use org.luaj.vm2.Varargs#isnil() . 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: BaseLib.java    From XPrivacyLua with GNU General Public License v3.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	args.argcheck(args.isstring(1) || args.isnil(1), 1, "filename must be string or nil");
	String filename = args.isstring(1)? args.tojstring(1): null;
	Varargs v = filename == null? 
			loadStream( globals.STDIN, "=stdin", "bt", globals ):
			loadFile( args.checkjstring(1), "bt", globals );
	return v.isnil(1)? error(v.tojstring(2)): v.arg1().invoke();			
}
 
Example 2
Source File: BaseLib.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
    args.argcheck(args.isstring(1) || args.isnil(1), 1, "filename must be string or nil");
    String filename = args.isstring(1) ? args.tojstring(1) : null;
    Varargs v = filename == null ? loadStream(globals.STDIN, "=stdin", "bt", globals) :
            loadFile(args.checkjstring(1), "bt", globals);
    return v.isnil(1) ? error(v.tojstring(2)) : v.arg1().invoke();
}
 
Example 3
Source File: IoLib.java    From luaj with MIT License 5 votes vote down vote up
public Varargs _lines_iter(LuaValue file, boolean toclose, Varargs args) throws IOException {
	File f = optfile(file);
	if ( f == null ) argerror(1, "not a file: " + file);
	if ( f.isclosed() )	error("file is already closed");
	Varargs ret = ioread(f, args);
	if (toclose && ret.isnil(1) && f.eof()) f.close();
	return ret;
}
 
Example 4
Source File: BaseLib.java    From luaj with MIT License 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	args.argcheck(args.isstring(1) || args.isnil(1), 1, "filename must be string or nil");
	String filename = args.isstring(1)? args.tojstring(1): null;
	Varargs v = filename == null?
			loadStream( globals.STDIN, "=stdin", "bt", globals ):
			loadFile( args.checkjstring(1), "bt", globals );
	return v.isnil(1)? error(v.tojstring(2)): v.arg1().invoke();
}