/** Tests if a value exists at argument i. * @param i the index of the argument to test, 1 is the first argument * @return true if the argument exists, false otherwise * */ public boolean isvalue(int i) { return i>0 && i<=narg(); }
/** Tests if a value exists at argument i. * @param i the index of the argument to test, 1 is the first argument * @return true if the argument exists, false otherwise * */ public boolean isvalue(int i) { return i>0 && i<=narg(); }
/** Return argument i as a LuaValue if it exists, or {@code defval}. * @param i the index of the argument to test, 1 is the first argument * @return LuaValue value if the argument exists, defval if not * @exception LuaError if the argument does not exist. * */ public LuaValue optvalue(int i, LuaValue defval) { return i>0 && i<=narg()? arg(i): defval; }
public int narg() { if (result == null) eval(); return result.narg(); }
static Varargs bor( Varargs args ) { int result = 0; for ( int i = 1; i <= args.narg(); i++ ) { result |= args.checkint(i); } return bitsToValue( result ); }
static Varargs bxor( Varargs args ) { int result = 0; for ( int i = 1; i <= args.narg(); i++ ) { result ^= args.checkint(i); } return bitsToValue( result ); }
static Varargs band( Varargs args ) { int result = -1; for ( int i = 1; i <= args.narg(); i++ ) { result &= args.checkint(i); } return bitsToValue( result ); }
private static Varargs iowrite(File f, Varargs args) throws IOException { for ( int i=1, n=args.narg(); i<=n; i++ ) f.write( args.checkstring(i) ); return f; }
/** Return argument i as a LuaValue if it exists, or throw an error. * @param i the index of the argument to test, 1 is the first argument * @return LuaValue value if the argument exists * @exception LuaError if the argument does not exist. * */ public LuaValue checkvalue(int i) { return i<=narg()? arg(i): LuaValue.argerror(i,"value expected"); }
static Varargs btest( Varargs args ) { int bits = -1; for ( int i = 1; i <= args.narg(); i++ ) { bits &= args.checkint(i); } return valueOf( bits != 0 ); }
static Varargs bor( Varargs args ) { int result = 0; for ( int i = 1; i <= args.narg(); i++ ) { result |= args.checkint(i); } return bitsToValue( result ); }
static Varargs band( Varargs args ) { int result = -1; for ( int i = 1; i <= args.narg(); i++ ) { result &= args.checkint(i); } return bitsToValue( result ); }
private void execute(String when, MethodHookParam param) { Log.i(TAG, "Dynamic invoke " + param.method); List<LuaValue> values = new ArrayList<>(); values.add(LuaValue.valueOf(when)); values.add(CoerceJavaToLua.coerce(new XParam(context, param, settings))); for (int i = 4; i <= args.narg(); i++) values.add(args.arg(i)); args.arg(3).invoke(values.toArray(new LuaValue[0])); } });
public Varargs invoke(Varargs args) { double m = args.checkdouble(1); for ( int i=2,n=args.narg(); i<=n; ++i ) m = Math.min(m,args.checkdouble(i)); return valueOf(m); } }
public Varargs invoke(Varargs args) { double m = args.checkdouble(1); for ( int i=2,n=args.narg(); i<=n; ++i ) m = Math.max(m,args.checkdouble(i)); return valueOf(m); } }
public Varargs invoke(Varargs args) { LuaValue tostring = globals.get("tostring"); for ( int i=1, n=args.narg(); i<=n; i++ ) { if ( i>1 ) globals.STDOUT.print( '\t' ); LuaString s = tostring.call( args.arg(i) ).strvalue(); globals.STDOUT.print(s.tojstring()); } globals.STDOUT.println(); return NONE; } }
public Varargs invoke(Varargs args) { int n = args.narg(); byte[] bytes = new byte[n]; for ( int i=0, a=1; i<n; i++, a++ ) { int c = args.checkint(a); if (c<0 || c>=256) argerror(a, "invalid value"); bytes[i] = (byte) c; } return LuaString.valueUsing( bytes ); } }
public Varargs invoke(Varargs args) { int n = args.narg()-1; if ( args.arg1().equals(valueOf("#")) ) return valueOf(n); int i = args.checkint(1); if ( i == 0 || i < -n ) argerror(1,"index out of range"); return args.subargs(i<0? n+i+2: i+1); } }
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)); } } }
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)); } } }