/** Return argument i as a LuaString if a string or number, or throw an error if any other type * @param i the index of the argument to test, 1 is the first argument * @return LuaString value if argument i is a string or number * @exception LuaError if the argument is not a string or number * */ public LuaString checkstring(int i) { return arg(i).checkstring(); }
/** Return argument i as a LuaString if a string or number, or throw an error if any other type * @param i the index of the argument to test, 1 is the first argument * @return LuaString value if argument i is a string or number * @exception LuaError if the argument is not a string or number * */ public LuaString checkstring(int i) { return arg(i).checkstring(); }
@Override public LuaValue call(LuaValue storage, LuaValue path, LuaValue value) { try { self.setValue(path.checkstring(), value); return LuaValue.TRUE; } catch (StorageObjectException e) { return LuaValue.FALSE; } } });
@Override public LuaValue call(LuaValue storage, LuaValue path) { try { return self.clearVaule(path.checkstring()); } catch (StorageObjectException e) { return LuaValue.NIL; } } });
/** * string.len (s) * * Receives a string and returns its length. The empty string "" has length 0. * Embedded zeros are counted, so "a\000bc\000" has length 5. */ static LuaValue len( LuaValue arg ) { return arg.checkstring().len(); }
public LuaValue call(LuaValue arg) { return arg.checkstring().len(); } }
/** Return argument i as a LuaString if a string or number, or throw an error if any other type * @param i the index of the argument to test, 1 is the first argument * @return LuaString value if argument i is a string or number * @exception LuaError if the argument is not a string or number * */ public LuaString checkstring(int i) { return arg(i).checkstring(); }
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) {
protected String executeFunctionChunk(LuaValue luaFunction, Frame frame) { assertFunction(luaFunction); try { currentFrame = frame; LuaValue executeFunction = globals.get("mw").get("executeFunction"); logger.trace("executing "+luaFunction); final LuaString result = executeFunction.call(luaFunction).checkstring(); return new String(result.m_bytes, result.m_offset, result.m_length, UTF8); } finally { currentFrame = null; } }
public LuaValue call(LuaValue arg) { LuaString s = arg.checkstring(); int n = s.length(); byte[] b = new byte[n]; for ( int i=0, j=n-1; i<n; i++, j-- ) b[j] = (byte) s.luaByte(i); return LuaString.valueUsing( b ); } }
public LuaValue call(LuaValue arg) { LuaString s = arg.checkstring(); int n = s.length(); byte[] b = new byte[n]; for ( int i=0, j=n-1; i<n; i++, j-- ) b[j] = (byte) s.luaByte(i); return LuaString.valueUsing( b ); } }
public Object coerce(LuaValue value) { if ( value.isnil() ) return null; if ( targetType == TARGET_TYPE_STRING ) return value.tojstring(); LuaString s = value.checkstring(); byte[] b = new byte[s.m_length]; s.copyInto(0, b, 0, b.length); return b; } }
public Object coerce(LuaValue value) { if ( value.isnil() ) return null; if ( targetType == TARGET_TYPE_STRING ) return value.tojstring(); LuaString s = value.checkstring(); byte[] b = new byte[s.m_length]; s.copyInto(0, b, 0, b.length); return b; } }
@Override public LuaValue call(LuaValue list, LuaValue sep) { return list.checktable().concat(sep.checkstring(),1,list.length()); } @Override
@Override public LuaValue call(LuaValue list, LuaValue sep, LuaValue i) { return list.checktable().concat(sep.checkstring(),i.checkint(),list.length()); } @Override
public LuaValue call(LuaValue list, LuaValue sep, LuaValue i) { return list.checktable().concat(sep.checkstring(),i.checkint(),list.length()); } public LuaValue call(LuaValue list, LuaValue sep, LuaValue i, LuaValue j) {
@Override public LuaValue call(LuaValue list, LuaValue sep, LuaValue i, LuaValue j) { return list.checktable().concat(sep.checkstring(),i.checkint(),j.checkint()); } }
public LuaValue call(LuaValue e, LuaValue base) { if (base.isnil()) return e.tonumber(); final int b = base.checkint(); if ( b < 2 || b > 36 ) argerror(2, "base out of range"); return e.checkstring().tonumber(b); } }
public LuaValue call(LuaValue e, LuaValue base) { if (base.isnil()) { return e.tonumber(); } final int b = base.checkint(); if (b < 2 || b > 36) { argerror(2, "base out of range"); } return e.checkstring().tonumber(b); } }
@Override public LuaValue call(LuaValue e, LuaValue base) { if (base.isnil()) return e.tonumber(); final int b = base.checkint(); if ( b < 2 || b > 36 ) argerror(2, "base out of range"); return e.checkstring().tonumber(b); } }