/** Return argument i as a java double value or 0 if not a number. * @param i the index of the argument to convert, 1 is the first argument * @return double value if argument i is number, otherwise 0 * */ public double todouble(int i) { return arg(i).todouble(); }
/** Return argument i as a java double value or 0 if not a number. * @param i the index of the argument to convert, 1 is the first argument * @return double value if argument i is number, otherwise 0 * */ public double todouble(int i) { return arg(i).todouble(); }
/** Return argument i as a java double value or 0 if not a number. * @param i the index of the argument to convert, 1 is the first argument * @return double value if argument i is number, otherwise 0 * */ public double todouble(int i) { return arg(i).todouble(); }
/** Greater than or equals: Perform numeric comparison with another value * of int type, * including metatag processing, and returning {@link LuaValue}. * <p> * To be comparable, this must derive from {@link LuaNumber}. * * @param rhs The right-hand-side value to perform the comparison with * @return {@link #TRUE} if {@code (this >= rhs)}, {@link #FALSE} if not, * or {@link LuaValue} if metatag processing occurs * @throws LuaError if this is not a number * and no {@link #LT} metatag is defined. * @see #gteq_b(int) * @see #comparemt(LuaValue, LuaValue) */ public LuaValue gteq( int rhs ) { return valueOf(todouble() >= rhs); }
/** Greater than or equals: Perform numeric comparison with another value * of int type, * including metatag processing, and returning {@link LuaValue}. * <p> * To be comparable, this must derive from {@link LuaNumber}. * * @param rhs The right-hand-side value to perform the comparison with * @return {@link #TRUE} if {@code (this >= rhs)}, {@link #FALSE} if not, * or {@link LuaValue} if metatag processing occurs * @throws LuaError if this is not a number * and no {@link #LT} metatag is defined. * @see #gteq_b(int) * @see #comparemt(LuaValue, LuaValue) */ public LuaValue gteq( int rhs ) { return valueOf(todouble() >= rhs); }
public Object coerce(LuaValue value) { switch ( targetType ) { case TARGET_TYPE_BYTE: return new Byte( (byte) value.toint() ); case TARGET_TYPE_CHAR: return new Character( (char) value.toint() ); case TARGET_TYPE_SHORT: return new Short( (short) value.toint() ); case TARGET_TYPE_INT: return new Integer( (int) value.toint() ); case TARGET_TYPE_LONG: return new Long( (long) value.todouble() ); case TARGET_TYPE_FLOAT: return new Float( (float) value.todouble() ); case TARGET_TYPE_DOUBLE: return new Double( (double) value.todouble() ); default: return null; } } }
public double getDouble(String name) { return env.get(name).todouble(); }
public Object coerce(LuaValue value) { switch ( targetType ) { case TARGET_TYPE_BYTE: return new Byte( (byte) value.toint() ); case TARGET_TYPE_CHAR: return new Character( (char) value.toint() ); case TARGET_TYPE_SHORT: return new Short( (short) value.toint() ); case TARGET_TYPE_INT: return new Integer( (int) value.toint() ); case TARGET_TYPE_LONG: return new Long( (long) value.todouble() ); case TARGET_TYPE_FLOAT: return new Float( (float) value.todouble() ); case TARGET_TYPE_DOUBLE: return new Double( (double) value.todouble() ); default: return null; } } }
/** Greater than or equals: Perform numeric comparison with another value * of int type, * including metatag processing, and returning {@link LuaValue}. * <p> * To be comparable, this must derive from {@link LuaNumber}. * * @param rhs The right-hand-side value to perform the comparison with * @return {@link TRUE} if {@code (this >= rhs)}, {@link FALSE} if not, * or {@link LuaValue} if metatag processing occurs * @throws LuaError if this is not a number * and no {@link LT} metatag is defined. * @see #gteq_b(int) * @see #comparemt(LuaValue, LuaValue) */ public LuaValue gteq( int rhs ) { return valueOf(todouble() >= rhs); }
int numberK(LuaValue r) { if ( r instanceof LuaDouble ) { double d = r.todouble(); int i = (int) d; if ( d == (double) i ) r = LuaInteger.valueOf(i); } return this.addk(r); }
int numberK(LuaValue r) { if ( r instanceof LuaDouble ) { double d = r.todouble(); int i = (int) d; if ( d == (double) i ) r = LuaInteger.valueOf(i); } return this.addk(r); }
int numberK(LuaValue r) { if ( r instanceof LuaDouble ) { double d = r.todouble(); int i = (int) d; if ( d == (double) i ) r = LuaInteger.valueOf(i); } return this.addk(r); }
public Entry set(LuaValue value) { LuaValue n = value.tonumber(); if ( !n.isnil() ) { this.value = n.todouble(); return this; } else { return new NormalEntry( this.key, value ); } }
@Override public Entry set(LuaValue value) { LuaValue n = value.tonumber(); if ( !n.isnil() ) { this.value = n.todouble(); return this; } else { return new NormalEntry( this.key, value ); } }
public Entry set(LuaValue value) { LuaValue n = value.tonumber(); if ( !n.isnil() ) { this.value = n.todouble(); return this; } else { return new NormalEntry( this.key, value ); } }
public Object coerce(LuaValue value) { switch ( value.type() ) { case LuaValue.TNUMBER: return value.isint()? (Object)new Integer(value.toint()): (Object)new Double(value.todouble()); case LuaValue.TBOOLEAN: return value.toboolean()? Boolean.TRUE: Boolean.FALSE; case LuaValue.TSTRING: return value.tojstring(); case LuaValue.TUSERDATA: return value.optuserdata(targetType, null); case LuaValue.TNIL: return null; default: return value; } } }
private void println(LuaValue value) { System.out.println(value.tojstring()); System.out.println(value.toboolean()); System.out.println(value.toint()); System.out.println(value.todouble()); System.out.println(value.tofloat()); } }
protected static Entry defaultEntry(LuaValue key, LuaValue value) { if ( key.isinttype() ) { return new IntKeyEntry( key.toint(), value ); } else if (value.type() == TNUMBER) { return new NumberValueEntry( key, value.todouble() ); } else { return new NormalEntry( key, value ); } }
protected static Entry defaultEntry(LuaValue key, LuaValue value) { if ( key.isinttype() ) { return new IntKeyEntry( key.toint(), value ); } else if (value.type() == TNUMBER) { return new NumberValueEntry( key, value.todouble() ); } else { return new NormalEntry( key, value ); } }
protected static Entry defaultEntry(LuaValue key, LuaValue value) { if ( key.isinttype() ) { return new IntKeyEntry( key.toint(), value ); } else if (value.type() == TNUMBER) { return new NumberValueEntry( key, value.todouble() ); } else { return new NormalEntry( key, value ); } }