/** Tests if argument i is a number. * Since anywhere a number is required, a string can be used that * is a number, this will return true for both numbers and * strings that can be interpreted as numbers. * @param i the index of the argument to test, 1 is the first argument * @return true if the argument exists and is a number or * string that can be interpreted as a number, false otherwise * @see LuaValue.TNUMBER * @see LuaValue.TSTRING * */ public boolean isnumber(int i) { return arg(i).isnumber(); }
/** Tests if argument i is a number. * Since anywhere a number is required, a string can be used that * is a number, this will return true for both numbers and * strings that can be interpreted as numbers. * @param i the index of the argument to test, 1 is the first argument * @return true if the argument exists and is a number or * string that can be interpreted as a number, false otherwise * @see LuaValue#TNUMBER * @see LuaValue#TSTRING * */ public boolean isnumber(int i) { return arg(i).isnumber(); }
/** Tests if argument i is a number. * Since anywhere a number is required, a string can be used that * is a number, this will return true for both numbers and * strings that can be interpreted as numbers. * @param i the index of the argument to test, 1 is the first argument * @return true if the argument exists and is a number or * string that can be interpreted as a number, false otherwise * @see LuaValue#TNUMBER * @see LuaValue#TSTRING * */ public boolean isnumber(int i) { return arg(i).isnumber(); }
public Slot entry(LuaValue key, LuaValue value) { value = value.strongvalue(); if ( value == null ) return null; if ( weakkeys && !( key.isnumber() || key.isstring() || key.isboolean() )) { if ( weakvalues && !( value.isnumber() || value.isstring() || value.isboolean() )) { return new WeakKeyAndValueSlot( key, value, null ); } else { return new WeakKeySlot( key, value, null ); } } if ( weakvalues && ! (value.isnumber() || value.isstring() || value.isboolean() )) { return new WeakValueSlot( key, value, null ); } return LuaTable.defaultEntry( key, value ); }
public Slot entry(LuaValue key, LuaValue value) { value = value.strongvalue(); if ( value == null ) return null; if ( weakkeys && !( key.isnumber() || key.isstring() || key.isboolean() )) { if ( weakvalues && !( value.isnumber() || value.isstring() || value.isboolean() )) { return new WeakKeyAndValueSlot( key, value, null ); } else { return new WeakKeySlot( key, value, null ); } } if ( weakvalues && ! (value.isnumber() || value.isstring() || value.isboolean() )) { return new WeakValueSlot( key, value, null ); } return LuaTable.defaultEntry( key, value ); }
@Override public Slot entry(LuaValue key, LuaValue value) { value = value.strongvalue(); if ( value == null ) return null; if ( weakkeys && !( key.isnumber() || key.isstring() || key.isboolean() )) { if ( weakvalues && !( value.isnumber() || value.isstring() || value.isboolean() )) { return new WeakKeyAndValueSlot( key, value, null ); } else { return new WeakKeySlot( key, value, null ); } } if ( weakvalues && ! (value.isnumber() || value.isstring() || value.isboolean() )) { return new WeakValueSlot( key, value, null ); } return LuaTable.defaultEntry( key, value ); }
private String replace(String msg, LuaTable params) { for (int i=1; i<params.length()+1; i++) { LuaValue param = params.get(i); String actualParam; if (param.istable()) { if (!param.get("raw").isnil()) { actualParam = param.get("raw").checkjstring(); } else if (!param.get("num").isnil()) { if (param.get("num").isnumber()) { LuaNumber number = param.get("num").checknumber(); NumberFormat nf = NumberFormat.getInstance(Locale.forLanguageTag(lang)); actualParam = nf.format(number.todouble()); } else { actualParam = param.get("num").tojstring(); } } else { actualParam = "unknown"; } } else { actualParam = param.checkjstring(); } msg = msg.replace("$"+i, actualParam); } return msg; } }
public Var(LuaValue value){ if( value == null || value.isnil() ){ return; } if( value.isboolean() ){ set(value.toboolean()); return; } if( value.isstring() || value.isnumber() ){ set(value.toString()); return; } if( value.isuserdata() ){ set(value.touserdata()); return; } set(value); }
if ( func.isnumber() ) { frame = callstack.getCallFrame(func.toint()); if (frame == null)
if ( func.isnumber() ) { frame = callstack.getCallFrame(func.toint()); if (frame == null)
if ( func.isnumber() ) { frame = callstack.getCallFrame(func.toint()); if (frame == null)
default: return SCORE_WRONG_TYPE; } else if ( value.isnumber() ) { switch ( targetType ) { case TARGET_TYPE_BYTE: return SCORE_WRONG_TYPE;
/** * Gets the Java object from a LuaValue. * * @param value the LuaValue * @return the Java object */ public static Object getObjectFromLuavalue(LuaValue value) { if (value.istable()) { return convertTable(value.checktable()); } else if (value.isint()) { return value.checkint(); } else if (value.islong()) { return value.checklong(); } else if (value.isnumber()) { return value.checkdouble(); } else if (value.isstring()) { return value.checkjstring(); } else if (value.isboolean()) { return value.checkboolean(); } else if (value.isnil()) { return null; } else { return value.checkuserdata(); } }
default: return SCORE_WRONG_TYPE; } else if ( value.isnumber() ) { switch ( targetType ) { case TARGET_TYPE_BYTE: return SCORE_WRONG_TYPE;