/** Tests if argument i is nil. * @param i the index of the argument to test, 1 is the first argument * @return true if the argument is nil or does not exist, false otherwise * @see LuaValue#TNIL * */ public boolean isnil(int i) { return arg(i).isnil(); }
/** Set an array element */ private boolean arrayset( int key, LuaValue value ) { if ( key>0 && key<=array.length ) { array[key - 1] = value.isnil() ? null : (m_metatable != null ? m_metatable.wrap(value) : value); return true; } return false; }
/** Set an array element */ private boolean arrayset( int key, LuaValue value ) { if ( key>0 && key<=array.length ) { array[key - 1] = value.isnil() ? null : (m_metatable != null ? m_metatable.wrap(value) : value); return true; } return false; }
@Override public LuaValue call(LuaValue page, LuaValue query) { if (query.isnil()) { return toLuaString(wgServer + pagePath(page)); } else { return toLuaString(wgServer + formatQuery(page, query)); } } };
/** Return true if there is no argument or nil at argument i. * @param i the index of the argument to test, 1 is the first argument * @return true if argument i contains either no argument or nil * */ public boolean isnoneornil(int i) { return i>narg() || arg(i).isnil(); }
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 Varargs invoke(Varargs args) { LuaString name = args.checkstring(1); LuaValue val = package_.get(_PRELOAD).get(name); return val.isnil()? valueOf("\n\tno field package.preload['"+name+"']"): val; } }
/** * Get the next element after a particular key in the * contiguous array part of a table * @return key,value or none */ public Varargs inext(LuaValue key) { int k = key.checkint() + 1; LuaValue v = rawget(k); return v.isnil()? NONE: varargsOf(LuaInteger.valueOf(k),v); }
public Varargs _io_close(LuaValue file) throws IOException { File f = file.isnil()? output(): checkfile(file); checkopen(f); return ioclose(f); }
public Varargs _io_close(LuaValue file) throws IOException { File f = file.isnil()? output(): checkfile(file); checkopen(f); return ioclose(f); }
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 Varargs _io_input(LuaValue file) { infile = file.isnil()? input(): file.isstring()? ioopenfile(FTYPE_NAMED, file.checkjstring(),"r"): checkfile(file); return infile; }
public Varargs _io_output(LuaValue filename) { outfile = filename.isnil()? output(): filename.isstring()? ioopenfile(FTYPE_NAMED, filename.checkjstring(),"w"): checkfile(filename); return outfile; }
public LuaValue call(LuaValue arg1, LuaValue arg2) { throw arg1.isnil()? new LuaError(null, arg2.optint(1)): arg1.isstring()? new LuaError(arg1.tojstring(), arg2.optint(1)): new LuaError(arg1); } }
public LuaValue call(LuaValue arg1, LuaValue arg2) { throw arg1.isnil() ? new LuaError(null, arg2.optint(1)) : arg1.isstring() ? new LuaError(arg1.tojstring(), arg2.optint(1)) : new LuaError(arg1); } }
/** caller must ensure key is not nil */ public void set( LuaValue key, LuaValue value ) { if (!key.isvalidkey() && !metatag(NEWINDEX).isfunction()) typerror("table index"); if ( m_metatable==null || ! rawget(key).isnil() || ! settable(this,key,value) ) rawset(key, value); }
LuaLocals(Globals globals) { this.presize(globals.length(), 0); Varargs entry = globals.next(LuaValue.NIL); while (!entry.arg1().isnil()) { LuaValue key = entry.arg1(); LuaValue value = entry.arg(2); super.rawset(key, value); entry = globals.next(entry.arg1()); } }