public abstract class Varargs extends Object
To construct varargs, use one of the static methods such as
LuaValue.varargsOf(LuaValue,LuaValue)
Any LuaValue can be used as a stand-in for Varargs, for both calls and return values. When doing so, nargs() will return 1 and arg1() or arg(1) will return this. This simplifies the case when calling or implementing varargs functions with only 1 argument or 1 return value.
Varargs can also be derived from other varargs by appending to the front with a call
such as LuaValue.varargsOf(LuaValue,Varargs)
or by taking a portion of the args using Varargs.subargs(int start)
| 构造器和说明 |
|---|
Varargs() |
| 限定符和类型 | 方法和说明 |
|---|---|
abstract LuaValue |
arg(int i)
Get the n-th argument value (1-based).
|
abstract LuaValue |
arg1()
Get the first argument in the list.
|
void |
argcheck(boolean test,
int i,
String msg)
Performs test on argument i as a LuaValue when a user-supplied assertion passes, or throw an error.
|
boolean |
checkboolean(int i)
Return argument i as a boolean value, or throw an error if any other type.
|
LuaClosure |
checkclosure(int i)
Return argument i as a closure, or throw an error if any other type.
|
double |
checkdouble(int i)
Return argument i as a double, or throw an error if it cannot be converted to one.
|
LuaFunction |
checkfunction(int i)
Return argument i as a function, or throw an error if an incompatible type.
|
int |
checkint(int i)
Return argument i as a java int value, discarding any fractional part, or throw an error if not a number.
|
LuaInteger |
checkinteger(int i)
Return argument i as a java int value, or throw an error if not a number or is not representable by a java int.
|
String |
checkjstring(int i)
Return argument i as a java String if a string or number, or throw an error if any other type
|
long |
checklong(int i)
Return argument i as a java long value, discarding any fractional part, or throw an error if not a number.
|
LuaValue |
checknotnil(int i)
Return argument i as a LuaValue if it is not nil, or throw an error if it is nil.
|
LuaNumber |
checknumber(int i)
Return argument i as a LuaNumber, or throw an error if not a number or string that can be converted to a number.
|
LuaString |
checkstring(int i)
Return argument i as a LuaString if a string or number, or throw an error if any other type
|
LuaTable |
checktable(int i)
Return argument i as a LuaTable if a lua table, or throw an error if any other type.
|
LuaThread |
checkthread(int i)
Return argument i as a LuaThread if a lua thread, or throw an error if any other type.
|
Object |
checkuserdata(int i)
Return argument i as a java Object if a userdata, or throw an error if any other type.
|
Object |
checkuserdata(int i,
Class c)
Return argument i as a java Object if it is a userdata whose instance Class c or a subclass,
or throw an error if any other type.
|
LuaValue |
checkvalue(int i)
Return argument i as a LuaValue if it exists, or throw an error.
|
Varargs |
dealias()
Return Varargs that cannot be using a shared array for the storage, and is flattened.
|
Varargs |
eval()
Evaluate any pending tail call and return result.
|
boolean |
isfunction(int i)
Tests if argument i is a function.
|
boolean |
isnil(int i)
Tests if argument i is nil.
|
boolean |
isnoneornil(int i)
Return true if there is no argument or nil at argument i.
|
boolean |
isnumber(int i)
Tests if argument i is a number.
|
boolean |
isstring(int i)
Tests if argument i is a string.
|
boolean |
istable(int i)
Tests if argument i is a table.
|
boolean |
isTailcall()
Return true if this is a TailcallVarargs
|
boolean |
isthread(int i)
Tests if argument i is a thread.
|
boolean |
isuserdata(int i)
Tests if argument i is a userdata.
|
boolean |
isvalue(int i)
Tests if a value exists at argument i.
|
abstract int |
narg()
Get the number of arguments, or 0 if there are none.
|
boolean |
optboolean(int i,
boolean defval)
Return argument i as a boolean value,
defval if nil, or throw a LuaError if any other type. |
LuaClosure |
optclosure(int i,
LuaClosure defval)
Return argument i as a closure,
defval if nil, or throw a LuaError if any other type. |
double |
optdouble(int i,
double defval)
Return argument i as a double,
defval if nil, or throw a LuaError if it cannot be converted to one. |
LuaFunction |
optfunction(int i,
LuaFunction defval)
Return argument i as a function,
defval if nil, or throw a LuaError if an incompatible type. |
int |
optint(int i,
int defval)
Return argument i as a java int value, discarding any fractional part,
defval if nil, or throw a LuaError if not a number. |
LuaInteger |
optinteger(int i,
LuaInteger defval)
Return argument i as a java int value,
defval if nil, or throw a LuaError if not a number or is not representable by a java int. |
String |
optjstring(int i,
String defval)
Return argument i as a java String if a string or number,
defval if nil, or throw a LuaError if any other type |
long |
optlong(int i,
long defval)
Return argument i as a java long value, discarding any fractional part,
defval if nil, or throw a LuaError if not a number. |
LuaNumber |
optnumber(int i,
LuaNumber defval)
Return argument i as a LuaNumber,
defval if nil, or throw a LuaError if not a number or string that can be converted to a number. |
LuaString |
optstring(int i,
LuaString defval)
Return argument i as a LuaString if a string or number,
defval if nil, or throw a LuaError if any other type |
LuaTable |
opttable(int i,
LuaTable defval)
Return argument i as a LuaTable if a lua table,
defval if nil, or throw a LuaError if any other type. |
LuaThread |
optthread(int i,
LuaThread defval)
Return argument i as a LuaThread if a lua thread,
defval if nil, or throw a LuaError if any other type. |
Object |
optuserdata(int i,
Class c,
Object defval)
Return argument i as a java Object if it is a userdata whose instance Class c or a subclass,
defval if nil, or throw a LuaError if any other type. |
Object |
optuserdata(int i,
Object defval)
Return argument i as a java Object if a userdata,
defval if nil, or throw a LuaError if any other type. |
LuaValue |
optvalue(int i,
LuaValue defval)
Return argument i as a LuaValue if it exists, or
defval. |
abstract Varargs |
subargs(int start)
Create a
Varargs instance containing arguments starting at index start |
boolean |
toboolean(int i)
Convert argument
i to java boolean based on lua rules for boolean evaluation. |
byte |
tobyte(int i)
Return argument i as a java byte value, discarding any fractional part and truncating,
or 0 if not a number.
|
char |
tochar(int i)
Return argument i as a java char value, discarding any fractional part and truncating,
or 0 if not a number.
|
double |
todouble(int i)
Return argument i as a java double value or 0 if not a number.
|
float |
tofloat(int i)
Return argument i as a java float value, discarding excess fractional part and truncating,
or 0 if not a number.
|
int |
toint(int i)
Return argument i as a java int value, discarding any fractional part and truncating,
or 0 if not a number.
|
String |
tojstring()
Convert the list of varargs values to a human readable java String.
|
String |
tojstring(int i)
Return argument i as a java String based on the type of the argument.
|
long |
tolong(int i)
Return argument i as a java long value, discarding any fractional part and truncating,
or 0 if not a number.
|
short |
toshort(int i)
Return argument i as a java short value, discarding any fractional part and truncating,
or 0 if not a number.
|
String |
toString()
Convert the value or values to a java String using Varargs.tojstring()
|
Object |
touserdata(int i)
Return argument i as a java Object if a userdata, or null.
|
Object |
touserdata(int i,
Class c)
Return argument i as a java Object if it is a userdata whose instance Class c or a subclass, or null.
|
int |
type(int i)
Gets the type of argument
i |
public abstract LuaValue arg(int i)
i - the index of the argument to get, 1 is the first argumentarg1(),
LuaValue.NILpublic abstract int narg()
public abstract LuaValue arg1()
arg(int),
LuaValue.NILpublic Varargs eval()
public boolean isTailcall()
public int type(int i)
ii - the index of the argument to convert, 1 is the first argumentLuaValue.TNIL,
LuaValue.TBOOLEAN,
LuaValue.TNUMBER,
LuaValue.TSTRING,
LuaValue.TTABLE,
LuaValue.TFUNCTION,
LuaValue.TUSERDATA,
LuaValue.TTHREADpublic boolean isnil(int i)
i - the index of the argument to test, 1 is the first argumentLuaValue.TNILpublic boolean isfunction(int i)
i - the index of the argument to test, 1 is the first argumentLuaValue.TFUNCTIONpublic boolean isnumber(int i)
i - the index of the argument to test, 1 is the first argumentLuaValue.TNUMBER,
LuaValue.TSTRINGpublic boolean isstring(int i)
i - the index of the argument to test, 1 is the first argumentLuaValue.TNUMBER,
LuaValue.TSTRINGpublic boolean istable(int i)
i - the index of the argument to test, 1 is the first argumentLuaValue.TTABLEpublic boolean isthread(int i)
i - the index of the argument to test, 1 is the first argumentLuaValue.TTHREADpublic boolean isuserdata(int i)
i - the index of the argument to test, 1 is the first argumentLuaValue.TUSERDATApublic boolean isvalue(int i)
i - the index of the argument to test, 1 is the first argumentpublic boolean optboolean(int i,
boolean defval)
defval if nil, or throw a LuaError if any other type.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a lua booleanpublic LuaClosure optclosure(int i, LuaClosure defval)
defval if nil, or throw a LuaError if any other type.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a lua closurepublic double optdouble(int i,
double defval)
defval if nil, or throw a LuaError if it cannot be converted to one.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a numberpublic LuaFunction optfunction(int i, LuaFunction defval)
defval if nil, or throw a LuaError if an incompatible type.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a lua function or closurepublic int optint(int i,
int defval)
defval if nil, or throw a LuaError if not a number.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a numberpublic LuaInteger optinteger(int i, LuaInteger defval)
defval if nil, or throw a LuaError if not a number or is not representable by a java int.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument cannot be represented by a java int valuepublic long optlong(int i,
long defval)
defval if nil, or throw a LuaError if not a number.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a numberpublic LuaNumber optnumber(int i, LuaNumber defval)
defval if nil, or throw a LuaError if not a number or string that can be converted to a number.i - the index of the argument to test, 1 is the first argument, or defval if not supplied or nilLuaError - if the argument is not a numberpublic String optjstring(int i, String defval)
defval if nil, or throw a LuaError if any other typei - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a string or numberpublic LuaString optstring(int i, LuaString defval)
defval if nil, or throw a LuaError if any other typei - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a string or numberpublic LuaTable opttable(int i, LuaTable defval)
defval if nil, or throw a LuaError if any other type.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a lua tablepublic LuaThread optthread(int i, LuaThread defval)
defval if nil, or throw a LuaError if any other type.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a lua threadpublic Object optuserdata(int i, Object defval)
defval if nil, or throw a LuaError if any other type.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a userdatapublic Object optuserdata(int i, Class c, Object defval)
defval if nil, or throw a LuaError if any other type.i - the index of the argument to test, 1 is the first argumentc - the class to which the userdata instance must be assignableLuaError - if the argument is not a userdata or from whose instance c is not assignablepublic LuaValue optvalue(int i, LuaValue defval)
defval.i - the index of the argument to test, 1 is the first argumentLuaError - if the argument does not exist.public boolean checkboolean(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a lua booleanpublic LuaClosure checkclosure(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a lua closurepublic double checkdouble(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a numberpublic LuaFunction checkfunction(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a lua function or closurepublic int checkint(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a numberpublic LuaInteger checkinteger(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument cannot be represented by a java int valuepublic long checklong(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a numberpublic LuaNumber checknumber(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a numberpublic String checkjstring(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a string or numberpublic LuaString checkstring(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a string or numberpublic LuaTable checktable(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a lua tablepublic LuaThread checkthread(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a lua threadpublic Object checkuserdata(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument is not a userdatapublic Object checkuserdata(int i, Class c)
i - the index of the argument to test, 1 is the first argumentc - the class to which the userdata instance must be assignableLuaError - if the argument is not a userdata or from whose instance c is not assignablepublic LuaValue checkvalue(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument does not exist.public LuaValue checknotnil(int i)
i - the index of the argument to test, 1 is the first argumentLuaError - if the argument doesn't exist or evaluates to nil.public void argcheck(boolean test,
int i,
String msg)
test is true, otherwise throws and argument error with
the supplied message, msg.test - user supplied assertion to test againsti - the index to report in any error messagemsg - the error message to use when the test failsLuaError - if the the value of test is falsepublic boolean isnoneornil(int i)
i - the index of the argument to test, 1 is the first argumentpublic boolean toboolean(int i)
i to java boolean based on lua rules for boolean evaluation.i - the index of the argument to convert, 1 is the first argumentfalse if argument i is nil or false, otherwise truepublic byte tobyte(int i)
i - the index of the argument to convert, 1 is the first argumentpublic char tochar(int i)
i - the index of the argument to convert, 1 is the first argumentpublic double todouble(int i)
i - the index of the argument to convert, 1 is the first argumentpublic float tofloat(int i)
i - the index of the argument to convert, 1 is the first argumentpublic int toint(int i)
i - the index of the argument to convert, 1 is the first argumentpublic long tolong(int i)
i - the index of the argument to convert, 1 is the first argumentpublic String tojstring(int i)
i - the index of the argument to convert, 1 is the first argumentpublic short toshort(int i)
i - the index of the argument to convert, 1 is the first argumentpublic Object touserdata(int i)
i - the index of the argument to convert, 1 is the first argumentpublic Object touserdata(int i, Class c)
i - the index of the argument to convert, 1 is the first argumentc - the class to which the userdata instance must be assignablepublic String tojstring()
public String toString()
toString 在类中 Objecttojstring()public abstract Varargs subargs(int start)
Varargs instance containing arguments starting at index startstart - the index from which to include arguments, where 1 is the first argument.public Varargs dealias()
Copyright © 2020. All rights reserved.