Java Code Examples for org.luaj.vm2.Varargs#tojstring()
The following examples show how to use
org.luaj.vm2.Varargs#tojstring() .
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: LuaJavaCoercionTest.java From luaj with MIT License | 6 votes |
public void testBigNum() { String script = "bigNumA = luajava.newInstance('java.math.BigDecimal','12345678901234567890');\n" + "bigNumB = luajava.newInstance('java.math.BigDecimal','12345678901234567890');\n" + "bigNumC = bigNumA:multiply(bigNumB);\n" + //"print(bigNumA:toString())\n" + //"print(bigNumB:toString())\n" + //"print(bigNumC:toString())\n" + "return bigNumA:toString(), bigNumB:toString(), bigNumC:toString()"; Varargs chunk = globals.get("load").call(LuaValue.valueOf(script)); if ( ! chunk.arg1().toboolean() ) fail( chunk.arg(2).toString() ); Varargs results = chunk.arg1().invoke(); int nresults = results.narg(); String sa = results.tojstring(1); String sb = results.tojstring(2); String sc = results.tojstring(3); assertEquals( 3, nresults ); assertEquals( "12345678901234567890", sa ); assertEquals( "12345678901234567890", sb ); assertEquals( "152415787532388367501905199875019052100", sc ); }
Example 2
Source File: BaseLib.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
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 |
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 |
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 5
Source File: BaseLib.java From HtmlNative with Apache License 2.0 | 5 votes |
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 6
Source File: BaseLib.java From HtmlNative with Apache License 2.0 | 5 votes |
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 7
Source File: BaseLib.java From luaj with MIT License | 5 votes |
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 8
Source File: BaseLib.java From luaj with MIT License | 5 votes |
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 ); }