public int score( LuaValue value ) { switch ( value.type() ) { case LuaValue.TBOOLEAN: return 0; } return 1; }
public int score( LuaValue value ) { switch ( value.type() ) { case LuaValue.TBOOLEAN: return 0; } return 1; }
protected static boolean isLargeKey(LuaValue key) { switch (key.type()) { case TSTRING: return key.rawlen() > LuaString.RECENT_STRINGS_MAX_LENGTH; case TNUMBER: case TBOOLEAN: return false; default: return true; } }
protected static boolean isLargeKey(LuaValue key) { switch (key.type()) { case TSTRING: return key.rawlen() > LuaString.RECENT_STRINGS_MAX_LENGTH; case TNUMBER: case TBOOLEAN: return false; default: return true; } }
/** Gets the type of argument {@code i} * @param i the index of the argument to convert, 1 is the first argument * @return int value corresponding to one of the LuaValue integer type values * @see LuaValue#TNIL * @see LuaValue#TBOOLEAN * @see LuaValue#TNUMBER * @see LuaValue#TSTRING * @see LuaValue#TTABLE * @see LuaValue#TFUNCTION * @see LuaValue#TUSERDATA * @see LuaValue#TTHREAD * */ public int type(int i) { return arg(i).type(); }
public static boolean handleCCToObject(LuaValue value) { if (value.type() != LuaValue.TTABLE) { return false; } if (!(value instanceof LPLuaTable)) { return false; } LPLuaTable table = (LPLuaTable) value; return table.wrapper.getObject() != null; }
protected static boolean isLargeKey(LuaValue key) { switch (key.type()) { case TSTRING: return key.rawlen() > LuaString.RECENT_STRINGS_MAX_LENGTH; case TNUMBER: case TBOOLEAN: return false; default: return true; } }
/** Gets the type of argument {@code i} * @param i the index of the argument to convert, 1 is the first argument * @return int value corresponding to one of the LuaValue integer type values * @see LuaValue#TNIL * @see LuaValue#TBOOLEAN * @see LuaValue#TNUMBER * @see LuaValue#TSTRING * @see LuaValue#TTABLE * @see LuaValue#TFUNCTION * @see LuaValue#TUSERDATA * @see LuaValue#TTHREAD * */ public int type(int i) { return arg(i).type(); }
/** Gets the type of argument {@code i} * @param i the index of the argument to convert, 1 is the first argument * @return int value corresponding to one of the LuaValue integer type values * @see LuaValue.TNIL * @see LuaValue.TBOOLEAN * @see LuaValue.TNUMBER * @see LuaValue.TSTRING * @see LuaValue.TTABLE * @see LuaValue.TFUNCTION * @see LuaValue.TUSERDATA * @see LuaValue.TTHREAD * */ public int type(int i) { return arg(i).type(); }
static void printValue( PrintStream ps, LuaValue v ) { switch ( v.type() ) { case LuaValue.TSTRING: printString( ps, (LuaString) v ); break; default: ps.print( v.tojstring() ); } }
static void printValue( PrintStream ps, LuaValue v ) { switch ( v.type() ) { case LuaValue.TSTRING: printString( ps, (LuaString) v ); break; default: ps.print( v.tojstring() ); } }
public int score(LuaValue value) { switch ( value.type() ) { case LuaValue.TSTRING: return value.checkstring().isValidUtf8()? (targetType==TARGET_TYPE_STRING? 0: 1): (targetType==TARGET_TYPE_BYTES? 0: SCORE_WRONG_TYPE); case LuaValue.TNIL: return SCORE_NULL_VALUE; default: return targetType == TARGET_TYPE_STRING? SCORE_WRONG_TYPE: SCORE_UNCOERCIBLE; } } public Object coerce(LuaValue value) {
public int score(LuaValue value) { switch ( value.type() ) { case LuaValue.TSTRING: return value.checkstring().isValidUtf8()? (targetType==TARGET_TYPE_STRING? 0: 1): (targetType==TARGET_TYPE_BYTES? 0: SCORE_WRONG_TYPE); case LuaValue.TNIL: return SCORE_NULL_VALUE; default: return targetType == TARGET_TYPE_STRING? SCORE_WRONG_TYPE: SCORE_UNCOERCIBLE; } } public Object coerce(LuaValue value) {
public LuaValue call(LuaValue value, LuaValue table) { LuaValue mt = table.opttable(null); switch ( value.type() ) { case TNIL: LuaNil.s_metatable = mt; break; case TNUMBER: LuaNumber.s_metatable = mt; break; case TBOOLEAN: LuaBoolean.s_metatable = mt; break; case TSTRING: LuaString.s_metatable = mt; break; case TFUNCTION: LuaFunction.s_metatable = mt; break; case TTHREAD: LuaThread.s_metatable = mt; break; default: value.setmetatable( mt ); } return value; } }
public LuaValue call(LuaValue value, LuaValue table) { LuaValue mt = table.opttable(null); switch ( value.type() ) { case TNIL: LuaNil.s_metatable = mt; break; case TNUMBER: LuaNumber.s_metatable = mt; break; case TBOOLEAN: LuaBoolean.s_metatable = mt; break; case TSTRING: LuaString.s_metatable = mt; break; case TFUNCTION: LuaFunction.s_metatable = mt; break; case TTHREAD: LuaThread.s_metatable = mt; break; default: value.setmetatable( mt ); } return value; } }
public int score(LuaValue value) { switch ( value.type() ) { case LuaValue.TTABLE: return value.length()==0? 0: componentCoercion.score( value.get(1) ); case LuaValue.TUSERDATA: return inheritanceLevels( componentType, value.touserdata().getClass().getComponentType() ); case LuaValue.TNIL: return SCORE_NULL_VALUE; default: return SCORE_UNCOERCIBLE; } } public Object coerce(LuaValue value) {
public int score(LuaValue value) { switch ( value.type() ) { case LuaValue.TTABLE: return value.length()==0? 0: componentCoercion.score( value.get(1) ); case LuaValue.TUSERDATA: return inheritanceLevels( componentType, value.touserdata().getClass().getComponentType() ); case LuaValue.TNIL: return SCORE_NULL_VALUE; default: return SCORE_UNCOERCIBLE; } } public Object coerce(LuaValue 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 ); } }
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 ); } }