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

The following examples show how to use org.luaj.vm2.Varargs#argcheck() . 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 VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
    LuaValue ld = args.arg1();
    args.argcheck(ld.isstring() || ld.isfunction(), 1, "ld must be string or function");
    String source = args.optjstring(2, ld.isstring() ? ld.tojstring() : "=(load)");
    String mode = args.optjstring(3, "bt");
    LuaValue env = args.optvalue(4, globals);
    return loadStream(ld.isstring() ? ld.strvalue().toInputStream() :
            new StringInputStream(ld.checkfunction()), source, mode, env);
}
 
Example 2
Source File: BaseLib.java    From VideoOS-Android-SDK 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;
    String mode = args.optjstring(2, "bt");
    LuaValue env = args.optvalue(3, globals);
    return filename == null ?
            loadStream(globals.STDIN, "=stdin", mode, env) :
            loadFile(filename, mode, env);
}
 
Example 3
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 4
Source File: BaseLib.java    From XPrivacyLua with GNU General Public License v3.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	LuaValue ld = args.arg1();
	args.argcheck(ld.isstring() || ld.isfunction(), 1, "ld must be string or function");
	String source = args.optjstring(2, ld.isstring()? ld.tojstring(): "=(load)");
	String mode = args.optjstring(3, "bt");
	LuaValue env = args.optvalue(4, globals);
	return loadStream(ld.isstring()? ld.strvalue().toInputStream(): 
		new StringInputStream(ld.checkfunction()), source, mode, env);
}
 
Example 5
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;
	String mode = args.optjstring(2, "bt");
	LuaValue env = args.optvalue(3, globals);
	return filename == null? 
		loadStream( globals.STDIN, "=stdin", mode, env ):
		loadFile( filename, mode, env );
}
 
Example 6
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 7
Source File: BaseLib.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
    LuaValue ld = args.arg1();
    args.argcheck(ld.isstring() || ld.isfunction(), 1, "ld must be string or function");
    String source = args.optjstring(2, ld.isstring() ? ld.tojstring() : "=(load)");
    String mode = args.optjstring(3, "bt");
    LuaValue env = args.optvalue(4, globals);
    return loadStream(ld.isstring() ? ld.strvalue().toInputStream() : new
            StringInputStream(ld.checkfunction()), source, mode, env);
}
 
Example 8
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;
    String mode = args.optjstring(2, "bt");
    LuaValue env = args.optvalue(3, globals);
    return filename == null ? loadStream(globals.STDIN, "=stdin", mode, env) : loadFile
            (filename, mode, env);
}
 
Example 9
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();
}
 
Example 10
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;
	String mode = args.optjstring(2, "bt");
	LuaValue env = args.optvalue(3, globals);
	return filename == null?
		loadStream( globals.STDIN, "=stdin", mode, env ):
		loadFile( filename, mode, env );
}