|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.luaj.vm2.Varargs org.luaj.vm2.LuaValue
public abstract class LuaValue
Base class for all concrete lua type values.
Establishes base implementations for all the operations on lua types.
This allows Java clients to deal essentially with one type for all Java values, namely LuaValue
.
Constructors are provided as static methods for common Java types, such as
valueOf(int)
or valueOf(String)
to allow for instance pooling.
Constants are defined for the lua values
NIL
, TRUE
, and FALSE
.
A constant NONE
is defined which is a Varargs
list having no values.
Operations are performed on values directly via their Java methods. For example, the following code divides two numbers:
LuaValue a = LuaValue.valueOf( 5 );
LuaValue b = LuaValue.valueOf( 4 );
LuaValue c = a.div(b);
Note that in this example, c will be a LuaDouble
, but would be a LuaInteger
if the value of a were changed to 8, say.
In general the value of c in practice will vary depending on both the types and values of a and b
as well as any metatable/metatag processing that occurs.
Field access and function calls are similar, with common overloads to simplify Java usage:
LuaValue globals = JsePlatform.standardGlobals();
LuaValue sqrt = globals.get("math").get("sqrt");
LuaValue print = globals.get("print");
LuaValue d = sqrt.call( a );
print.call( LuaValue.valueOf("sqrt(5):"), a );
To supply variable arguments or get multiple return values, use
invoke(Varargs)
or invokemethod(LuaValue, Varargs)
methods:
LuaValue modf = globals.get("math").get("modf");
Varargs r = modf.invoke( d );
print.call( r.arg(1), r.arg(2) );
To load and run a script, LoadState
is used:
LoadState.load( new FileInputStream("main.lua"), "main.lua", globals ).call();
although require
could also be used:
globals.get("require").call(LuaValue.valueOf("main"));
For this to work the file must be in the current directory, or in the class path,
dependening on the platform.
See JsePlatform
and JmePlatform
for details.
In general a LuaError
may be thrown on any operation when the
types supplied to any operation are illegal from a lua perspective.
Examples could be attempting to concatenate a NIL value, or attempting arithmetic
on values that are not number.
There are several methods for preinitializing tables, such as:
listOf(LuaValue[])
for unnamed elementstableOf(LuaValue[])
for named elementstableOf(LuaValue[], LuaValue[], Varargs)
for mixtures
Predefined constants exist for the standard lua type constants
TNIL
, TBOOLEAN
, TLIGHTUSERDATA
, TNUMBER
, TSTRING
,
TTABLE
, TFUNCTION
, TUSERDATA
, TTHREAD
,
and extended lua type constants
TINT
, TNONE
, TVALUE
Predefined constants exist for all strings used as metatags:
INDEX
, NEWINDEX
, CALL
, MODE
, METATABLE
,
ADD
, SUB
, DIV
, MUL
, POW
,
MOD
, UNM
, LEN
, EQ
, LT
,
LE
, TOSTRING
, and CONCAT
.
JsePlatform
,
JmePlatform
,
LoadState
,
Varargs
Field Summary | |
---|---|
static LuaString |
ADD
LuaString constant with value "__add" for use as metatag |
static LuaString |
CALL
LuaString constant with value "__call" for use as metatag |
static LuaString |
CONCAT
LuaString constant with value "__concat" for use as metatag |
static LuaString |
DIV
LuaString constant with value "__div" for use as metatag |
static LuaString |
EMPTYSTRING
LuaString constant with value "" |
static LuaString |
EQ
LuaString constant with value "__eq" for use as metatag |
static LuaBoolean |
FALSE
LuaBoolean constant corresponding to lua false |
static LuaString |
INDEX
LuaString constant with value "__index" for use as metatag |
static LuaString |
LE
LuaString constant with value "__le" for use as metatag |
static LuaString |
LEN
LuaString constant with value "__len" for use as metatag |
static LuaString |
LT
LuaString constant with value "__lt" for use as metatag |
static LuaString |
METATABLE
LuaString constant with value "__metatable" for use as metatag |
static LuaNumber |
MINUSONE
LuaValue number constant equal to -1 |
static LuaString |
MOD
LuaString constant with value "__mod" for use as metatag |
static LuaString |
MODE
LuaString constant with value "__mode" for use as metatag |
static LuaString |
MUL
LuaString constant with value "__mul" for use as metatag |
static LuaString |
NEWINDEX
LuaString constant with value "__newindex" for use as metatag |
static LuaValue |
NIL
LuaValue constant corresponding to lua nil |
static LuaValue[] |
NILS
Array of NIL values to optimize filling stacks using System.arraycopy(). |
static LuaValue |
NONE
LuaValue constant corresponding to a Varargs list of no values |
static LuaValue[] |
NOVALS
LuaValue array constant with no values |
static LuaNumber |
ONE
LuaValue number constant equal to 1 |
static LuaString |
POW
LuaString constant with value "__pow" for use as metatag |
static LuaString |
SUB
LuaString constant with value "__sub" for use as metatag |
static int |
TBOOLEAN
Type enumeration constant for lua booleans |
static int |
TFUNCTION
Type enumeration constant for lua functions |
static int |
TINT
Type enumeration constant for lua numbers that are ints, for compatibility with lua 5.1 number patch only |
static int |
TLIGHTUSERDATA
Type enumeration constant for lua light userdata, for compatibility with C-based lua only |
static int |
TNIL
Type enumeration constant for lua nil |
static int |
TNONE
Type enumeration constant for lua values that have no type, for example weak table entries |
static int |
TNUMBER
Type enumeration constant for lua numbers |
static LuaString |
TOSTRING
LuaString constant with value "__tostring" for use as metatag |
static LuaBoolean |
TRUE
LuaBoolean constant corresponding to lua true |
static int |
TSTRING
Type enumeration constant for lua strings |
static int |
TTABLE
Type enumeration constant for lua tables |
static int |
TTHREAD
Type enumeration constant for lua threads |
static int |
TUSERDATA
Type enumeration constant for lua userdatas |
static int |
TVALUE
Type enumeration constant for unknown values, for compatibility with C-based lua only |
static java.lang.String[] |
TYPE_NAMES
String array constant containing names of each of the lua value types |
static LuaString |
UNM
LuaString constant with value "__unm" for use as metatag |
static LuaNumber |
ZERO
LuaValue number constant equal to 0 |
Constructor Summary | |
---|---|
LuaValue()
|
Method Summary | |
---|---|
LuaValue |
add(double rhs)
Add: Perform numeric add operation with another value of double type with metatag processing |
LuaValue |
add(int rhs)
Add: Perform numeric add operation with another value of int type with metatag processing |
LuaValue |
add(LuaValue rhs)
Add: Perform numeric add operation with another value including metatag processing. |
LuaValue |
and(LuaValue rhs)
Perform boolean and with another operand, based on lua rules for boolean evaluation. |
LuaValue |
arg(int index)
Get the n-th argument value (1-based). |
LuaValue |
arg1()
Get the first argument in the list. |
static LuaValue |
argerror(int iarg,
java.lang.String msg)
Throw a LuaError indicating an invalid argument was supplied to a function |
protected LuaValue |
argerror(java.lang.String expected)
Throw a LuaError indicating an invalid argument was supplied to a function |
protected LuaValue |
aritherror()
Throw a LuaError based on an arithmetic error such as add, or pow,
typically due to an invalid operand type |
protected LuaValue |
aritherror(java.lang.String fun)
Throw a LuaError based on an arithmetic error such as add, or pow,
typically due to an invalid operand type |
protected LuaValue |
arithmt(LuaValue tag,
LuaValue op2)
Perform metatag processing for arithmetic operations. |
protected LuaValue |
arithmtwith(LuaValue tag,
double op1)
Perform metatag processing for arithmetic operations when the left-hand-side is a number. |
static void |
assert_(boolean b,
java.lang.String msg)
Assert a condition is true, or throw a LuaError if not |
Buffer |
buffer()
Convert the value to a Buffer for more efficient concatenation of
multiple strings. |
LuaValue |
call()
Call this with 0 arguments, including metatag processing,
and return only the first return value. |
LuaValue |
call(LuaValue arg)
Call this with 1 argument, including metatag processing,
and return only the first return value. |
LuaValue |
call(LuaValue arg1,
LuaValue arg2)
Call this with 2 arguments, including metatag processing,
and return only the first return value. |
LuaValue |
call(LuaValue arg1,
LuaValue arg2,
LuaValue arg3)
Call this with 3 arguments, including metatag processing,
and return only the first return value. |
protected LuaValue |
callmt()
Get the metatag value for the CALL metatag, if it exists. |
boolean |
checkboolean()
Check that the value is a LuaBoolean ,
or throw LuaError if not |
LuaClosure |
checkclosure()
Check that the value is a LuaClosure ,
or throw LuaError if not |
double |
checkdouble()
Check that the value is numeric and return the value as a double, or throw LuaError if not numeric |
LuaValue |
checkfunction()
Check that the value is a function , or throw LuaError if not |
int |
checkint()
Check that the value is numeric, and convert and cast value to int, or throw LuaError if not numeric |
LuaInteger |
checkinteger()
Check that the value is numeric, and convert and cast value to int, or throw LuaError if not numeric |
java.lang.String |
checkjstring()
Convert this value to a Java String. |
long |
checklong()
Check that the value is numeric, and convert and cast value to long, or throw LuaError if not numeric |
protected LuaValue |
checkmetatag(LuaValue tag,
java.lang.String reason)
Get particular metatag, or throw LuaError if it doesn't exist |
LuaValue |
checknotnil()
Check that this is not the value NIL , or throw LuaError if it is |
LuaNumber |
checknumber()
Check that the value is numeric, and return as a LuaNumber if so, or throw LuaError |
LuaNumber |
checknumber(java.lang.String msg)
Check that the value is numeric, and return as a LuaNumber if so, or throw LuaError |
LuaString |
checkstring()
Check that this is a lua string, or throw LuaError if it is not. |
LuaTable |
checktable()
Check that this is a LuaTable , or throw LuaError if it is not |
LuaThread |
checkthread()
Check that this is a LuaThread , or throw LuaError if it is not |
java.lang.Object |
checkuserdata()
Check that this is a LuaUserdata , or throw LuaError if it is not |
java.lang.Object |
checkuserdata(java.lang.Class c)
Check that this is a LuaUserdata , or throw LuaError if it is not |
LuaValue |
checkvalidkey()
Check that this is a valid key in a table index operation, or throw LuaError if not |
protected LuaValue |
compareerror(LuaValue rhs)
Throw a LuaError based on a comparison error such as greater-than or less-than,
typically due to an invalid operand type |
protected LuaValue |
compareerror(java.lang.String rhs)
Throw a LuaError based on a comparison error such as greater-than or less-than,
typically due to an invalid operand type |
LuaValue |
comparemt(LuaValue tag,
LuaValue op1)
Perform metatag processing for comparison operations. |
Buffer |
concat(Buffer rhs)
Concatenate a Buffer onto this value and return the result
using rules of lua string concatenation including metatag processing. |
LuaValue |
concat(LuaValue rhs)
Concatenate another value onto this value and return the result using rules of lua string concatenation including metatag processing. |
LuaValue |
concatmt(LuaValue rhs)
Perform metatag processing for concatenation operations. |
LuaValue |
concatTo(LuaNumber lhs)
Reverse-concatenation: concatenate this value onto another value known to be a LuaNumber
and return the result using rules of lua string concatenation including
metatag processing. |
LuaValue |
concatTo(LuaString lhs)
Reverse-concatenation: concatenate this value onto another value known to be a LuaString
and return the result using rules of lua string concatenation including
metatag processing. |
LuaValue |
concatTo(LuaValue lhs)
Reverse-concatenation: concatenate this value onto another value whose type is unknwon and return the result using rules of lua string concatenation including metatag processing. |
LuaValue |
div(double rhs)
Divide: Perform numeric divide operation by another value of double type without metatag processing |
LuaValue |
div(int rhs)
Divide: Perform numeric divide operation by another value of int type without metatag processing |
LuaValue |
div(LuaValue rhs)
Divide: Perform numeric divide operation by another value of unknown type, including metatag processing. |
LuaValue |
divInto(double lhs)
Reverse-divide: Perform numeric divide operation into another value with metatag processing |
boolean |
eq_b(LuaValue val)
Equals: Perform equality comparison with another value including metatag processing using EQ ,
and return java boolean |
LuaValue |
eq(LuaValue val)
Equals: Perform equality comparison with another value including metatag processing using EQ . |
static boolean |
eqmtcall(LuaValue lhs,
LuaValue lhsmt,
LuaValue rhs,
LuaValue rhsmt)
Perform equality testing metatag processing |
boolean |
equals(java.lang.Object obj)
|
static LuaValue |
error(java.lang.String message)
Throw a LuaError with a particular message |
LuaValue |
get(int key)
Get a value in a table including metatag processing using INDEX . |
LuaValue |
get(LuaValue key)
Get a value in a table including metatag processing using INDEX . |
LuaValue |
get(java.lang.String key)
Get a value in a table including metatag processing using INDEX . |
LuaValue |
getfenv()
Get the environemnt for an instance. |
LuaValue |
getmetatable()
Get the metatable for this LuaValue |
LuaValue |
getn()
Implementation of lua 5.0 getn() function. |
protected static LuaValue |
gettable(LuaValue t,
LuaValue key)
get value from metatable operations, or NIL if not defined by metatables |
boolean |
gt_b(double rhs)
Greater than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean. |
boolean |
gt_b(int rhs)
Greater than: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean. |
boolean |
gt_b(LuaValue rhs)
Greater than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean. |
LuaValue |
gt(double rhs)
Greater than: Perform numeric comparison with another value of double type, including metatag processing, and returning LuaValue . |
LuaValue |
gt(int rhs)
Greater than: Perform numeric comparison with another value of int type, including metatag processing, and returning LuaValue . |
LuaValue |
gt(LuaValue rhs)
Greater than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning LuaValue . |
boolean |
gteq_b(double rhs)
Greater than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returning java boolean. |
boolean |
gteq_b(int rhs)
Greater than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean. |
boolean |
gteq_b(LuaValue rhs)
Greater than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean. |
LuaValue |
gteq(double rhs)
Greater than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returning LuaValue . |
LuaValue |
gteq(int rhs)
Greater than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returning LuaValue . |
LuaValue |
gteq(LuaValue rhs)
Greater than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning LuaValue . |
protected LuaValue |
illegal(java.lang.String op,
java.lang.String typename)
Throw a LuaError indicating an illegal operation occurred,
typically involved in managing weak references |
Varargs |
inext(LuaValue index)
Find the next integer-key,value pair if this is a table,
return NIL if there are no more, or throw a LuaError if not a table. |
Varargs |
invoke()
Call this with 0 arguments, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invoke(LuaValue[] args)
Call this with variable arguments, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invoke(LuaValue[] args,
Varargs varargs)
Call this with variable arguments, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invoke(LuaValue arg1,
LuaValue arg2,
Varargs varargs)
Call this with variable arguments, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invoke(LuaValue arg,
Varargs varargs)
Call this with variable arguments, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invoke(Varargs args)
Call this with variable arguments, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invokemethod(LuaValue name)
Call named method on this with 0 arguments, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invokemethod(LuaValue name,
LuaValue[] args)
Call named method on this with variable arguments, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invokemethod(LuaValue name,
Varargs args)
Call named method on this with variable arguments, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invokemethod(java.lang.String name)
Call named method on this with 0 arguments, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invokemethod(java.lang.String name,
LuaValue[] args)
Call named method on this with 1 argument, including metatag processing,
and retain all return values in a Varargs . |
Varargs |
invokemethod(java.lang.String name,
Varargs args)
Call named method on this with 1 argument, including metatag processing,
and retain all return values in a Varargs . |
boolean |
isboolean()
Check if this is a boolean |
boolean |
isclosure()
Check if this is a function that is a closure,
meaning interprets lua bytecode for its execution |
boolean |
isfunction()
Check if this is a function |
boolean |
isint()
Check if this is a number and is representable by java int
without rounding or truncation |
boolean |
isinttype()
Check if this is a LuaInteger |
boolean |
islong()
Check if this is a number and is representable by java long
without rounding or truncation |
boolean |
isnil()
Check if this is nil |
boolean |
isnumber()
Check if this is a number |
boolean |
isstring()
Check if this is a string |
boolean |
istable()
Check if this is a table |
boolean |
isthread()
Check if this is a thread |
boolean |
isuserdata()
Check if this is a userdata |
boolean |
isuserdata(java.lang.Class c)
Check if this is a userdata of type c |
boolean |
isweaknil()
Test if this is a weak reference and its value no longer is referenced. |
LuaValue |
len()
Length operator: return lua length of object (#this) including metatag processing as java int |
protected LuaValue |
lenerror()
Throw a LuaError based on the len operator,
typically due to an invalid operand type |
int |
length()
Length operator: return lua length of object (#this) including metatag processing as java int |
static LuaTable |
listOf(LuaValue[] unnamedValues)
Construct a LuaTable initialized with supplied array values. |
static LuaTable |
listOf(LuaValue[] unnamedValues,
Varargs lastarg)
Construct a LuaTable initialized with supplied array values. |
LuaValue |
load(LuaValue library)
Load a library instance by setting its environment to this
and calling it, which should iniitalize the library instance and
install itself into this instance. |
boolean |
lt_b(double rhs)
Less than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean. |
boolean |
lt_b(int rhs)
Less than: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean. |
boolean |
lt_b(LuaValue rhs)
Less than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean. |
LuaValue |
lt(double rhs)
Less than: Perform numeric comparison with another value of double type, including metatag processing, and returning LuaValue . |
LuaValue |
lt(int rhs)
Less than: Perform numeric comparison with another value of int type, including metatag processing, and returning LuaValue . |
LuaValue |
lt(LuaValue rhs)
Less than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning LuaValue . |
boolean |
lteq_b(double rhs)
Less than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returning java boolean. |
boolean |
lteq_b(int rhs)
Less than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean. |
boolean |
lteq_b(LuaValue rhs)
Less than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean. |
LuaValue |
lteq(double rhs)
Less than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returning LuaValue . |
LuaValue |
lteq(int rhs)
Less than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returning LuaValue . |
LuaValue |
lteq(LuaValue rhs)
Less than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning LuaValue . |
LuaValue |
metatag(LuaValue tag)
Get particular metatag, or return NIL if it doesn't exist |
LuaValue |
method(LuaValue name)
Call named method on this with 0 arguments, including metatag processing,
and return only the first return value. |
LuaValue |
method(LuaValue name,
LuaValue arg)
Call named method on this with 1 argument, including metatag processing,
and return only the first return value. |
LuaValue |
method(LuaValue name,
LuaValue arg1,
LuaValue arg2)
Call named method on this with 2 arguments, including metatag processing,
and return only the first return value. |
LuaValue |
method(java.lang.String name)
Call named method on this with 0 arguments, including metatag processing,
and return only the first return value. |
LuaValue |
method(java.lang.String name,
LuaValue arg)
Call named method on this with 1 argument, including metatag processing,
and return only the first return value. |
LuaValue |
method(java.lang.String name,
LuaValue arg1,
LuaValue arg2)
Call named method on this with 2 arguments, including metatag processing,
and return only the first return value. |
LuaValue |
mod(double rhs)
Modulo: Perform numeric modulo operation with another value of double type without metatag processing |
LuaValue |
mod(int rhs)
Modulo: Perform numeric modulo operation with another value of int type without metatag processing |
LuaValue |
mod(LuaValue rhs)
Modulo: Perform numeric modulo operation with another value of unknown type, including metatag processing. |
LuaValue |
modFrom(double lhs)
Reverse-modulo: Perform numeric modulo operation from another value with metatag processing |
LuaValue |
mul(double rhs)
Multiply: Perform numeric multiply operation with another value of double type with metatag processing |
LuaValue |
mul(int rhs)
Multiply: Perform numeric multiply operation with another value of int type with metatag processing |
LuaValue |
mul(LuaValue rhs)
Multiply: Perform numeric multiply operation with another value of unknown type, including metatag processing. |
int |
narg()
Get the number of arguments, or 0 if there are none. |
LuaValue |
neg()
Unary minus: return negative value (-this) as defined by lua unary minus operator |
boolean |
neq_b(LuaValue val)
Notquals: Perform inequality comparison with another value including metatag processing using EQ . |
LuaValue |
neq(LuaValue val)
Notquals: Perform inequality comparison with another value including metatag processing using EQ . |
Varargs |
next(LuaValue index)
Find the next key,value pair if this is a table,
return NIL if there are no more, or throw a LuaError if not a table. |
LuaValue |
not()
Unary not: return inverse boolean value (~this) as defined by lua not operator |
Varargs |
onInvoke(Varargs args)
Callback used during tail call processing to invoke the function once. |
boolean |
optboolean(boolean defval)
Check that optional argument is a boolean and return its boolean value |
LuaClosure |
optclosure(LuaClosure defval)
Check that optional argument is a closure and return as LuaClosure |
double |
optdouble(double defval)
Check that optional argument is a number or string convertible to number and return as double |
LuaFunction |
optfunction(LuaFunction defval)
Check that optional argument is a function and return as LuaFunction |
int |
optint(int defval)
Check that optional argument is a number or string convertible to number and return as int |
LuaInteger |
optinteger(LuaInteger defval)
Check that optional argument is a number or string convertible to number and return as LuaInteger |
java.lang.String |
optjstring(java.lang.String defval)
Check that optional argument is a string or number and return as Java String |
long |
optlong(long defval)
Check that optional argument is a number or string convertible to number and return as long |
LuaNumber |
optnumber(LuaNumber defval)
Check that optional argument is a number or string convertible to number and return as LuaNumber |
LuaString |
optstring(LuaString defval)
Check that optional argument is a string or number and return as LuaString |
LuaTable |
opttable(LuaTable defval)
Check that optional argument is a table and return as LuaTable |
LuaThread |
optthread(LuaThread defval)
Check that optional argument is a thread and return as LuaThread |
java.lang.Object |
optuserdata(java.lang.Class c,
java.lang.Object defval)
Check that optional argument is a userdata whose instance is of a type and return the Object instance |
java.lang.Object |
optuserdata(java.lang.Object defval)
Check that optional argument is a userdata and return the Object instance |
LuaValue |
optvalue(LuaValue defval)
Perform argument check that this is not nil or none. |
LuaValue |
or(LuaValue rhs)
Perform boolean or with another operand, based on lua rules for boolean evaluation. |
LuaValue |
pow(double rhs)
Raise to power: Raise this value to a power of double type with metatag processing |
LuaValue |
pow(int rhs)
Raise to power: Raise this value to a power of int type with metatag processing |
LuaValue |
pow(LuaValue rhs)
Raise to power: Raise this value to a power including metatag processing. |
LuaValue |
powWith(double lhs)
Reverse-raise to power: Raise another value of double type to this power with metatag processing |
LuaValue |
powWith(int lhs)
Reverse-raise to power: Raise another value of double type to this power with metatag processing |
void |
presize(int i)
Preallocate the array part of a table to be a certain size, |
boolean |
raweq(double val)
Equals: Perform direct equality comparison with a double value without metatag processing. |
boolean |
raweq(int val)
Equals: Perform direct equality comparison with a int value without metatag processing. |
boolean |
raweq(LuaString val)
Equals: Perform direct equality comparison with a LuaString value
without metatag processing. |
boolean |
raweq(LuaUserdata val)
Equals: Perform direct equality comparison with a LuaUserdata value
without metatag processing. |
boolean |
raweq(LuaValue val)
Equals: Perform direct equality comparison with another value without metatag processing. |
LuaValue |
rawget(int key)
Get a value in a table without metatag processing. |
LuaValue |
rawget(LuaValue key)
Get a value in a table without metatag processing. |
LuaValue |
rawget(java.lang.String key)
Get a value in a table without metatag processing. |
void |
rawset(int key,
LuaValue value)
Set a value in a table without metatag processing. |
void |
rawset(int key,
java.lang.String value)
Set a value in a table without metatag processing. |
void |
rawset(LuaValue key,
LuaValue value)
Set a value in a table without metatag processing. |
void |
rawset(java.lang.String key,
double value)
Set a value in a table without metatag processing. |
void |
rawset(java.lang.String key,
int value)
Set a value in a table without metatag processing. |
void |
rawset(java.lang.String key,
LuaValue value)
Set a value in a table without metatag processing. |
void |
rawset(java.lang.String key,
java.lang.String value)
Set a value in a table without metatag processing. |
void |
rawsetlist(int key0,
Varargs values)
Set list values in a table without invoking metatag processing |
void |
set(int key,
LuaValue value)
Set a value in a table without metatag processing using NEWINDEX . |
void |
set(int key,
java.lang.String value)
Set a value in a table without metatag processing using NEWINDEX . |
void |
set(LuaValue key,
LuaValue value)
Set a value in a table without metatag processing using NEWINDEX . |
void |
set(java.lang.String key,
double value)
Set a value in a table without metatag processing using NEWINDEX . |
void |
set(java.lang.String key,
int value)
Set a value in a table without metatag processing using NEWINDEX . |
void |
set(java.lang.String key,
LuaValue value)
Set a value in a table without metatag processing using NEWINDEX . |
void |
set(java.lang.String key,
java.lang.String value)
Set a value in a table without metatag processing using NEWINDEX . |
void |
setfenv(LuaValue env)
Set the environment on an object. |
LuaValue |
setmetatable(LuaValue metatable)
Set the metatable for this LuaValue |
protected static boolean |
settable(LuaValue t,
LuaValue key,
LuaValue value)
Perform field assignment including metatag processing. |
int |
strcmp(LuaString rhs)
Perform string comparison with another value known to be a LuaString
using string comparison based on byte values. |
int |
strcmp(LuaValue rhs)
Perform string comparison with another value of any type using string comparison based on byte values. |
LuaValue |
strongkey()
Return the key part of this value if it is a weak table entry, or NIL if it was weak and is no longer referenced. |
LuaValue |
strongvalue()
Return this value as a strong reference, or NIL if it was weak and is no longer referenced. |
LuaString |
strvalue()
Convert this value to a string if it is a LuaString or LuaNumber ,
or throw a LuaError if it is not |
LuaValue |
sub(double rhs)
Subtract: Perform numeric subtract operation with another value of double type with metatag processing |
LuaValue |
sub(int rhs)
Subtract: Perform numeric subtract operation with another value of int type with metatag processing |
LuaValue |
sub(LuaValue rhs)
Subtract: Perform numeric subtract operation with another value of unknown type, including metatag processing. |
LuaValue |
subFrom(double lhs)
Reverse-subtract: Perform numeric subtract operation from an int value with metatag processing |
LuaValue |
subFrom(int lhs)
Reverse-subtract: Perform numeric subtract operation from a double value without metatag processing |
static LuaTable |
tableOf()
Construct an empty LuaTable . |
static LuaTable |
tableOf(int narray,
int nhash)
Construct an empty LuaTable preallocated to hold array and hashed elements |
static LuaTable |
tableOf(LuaValue[] namedValues)
Construct a LuaTable initialized with supplied named values. |
static LuaTable |
tableOf(LuaValue[] namedValues,
LuaValue[] unnamedValues)
Construct a LuaTable initialized with supplied named values and sequential elements. |
static LuaTable |
tableOf(LuaValue[] namedValues,
LuaValue[] unnamedValues,
Varargs lastarg)
Construct a LuaTable initialized with supplied named values and sequential elements in an array part and as varargs. |
static LuaTable |
tableOf(Varargs varargs,
int firstarg)
Construct a LuaTable initialized with supplied array values. |
static Varargs |
tailcallOf(LuaValue func,
Varargs args)
Construct a TailcallVarargs around a function and arguments. |
boolean |
testfor_b(LuaValue limit,
LuaValue step)
Perform end-condition test in for-loop processing. |
boolean |
toboolean()
Convert to boolean false if NIL or FALSE , true if anything else |
byte |
tobyte()
Convert to byte if numeric, or 0 if not. |
char |
tochar()
Convert to char if numeric, or 0 if not. |
double |
todouble()
Convert to double if numeric, or 0 if not. |
float |
tofloat()
Convert to float if numeric, or 0 if not. |
int |
toint()
Convert to int if numeric, or 0 if not. |
java.lang.String |
tojstring()
Convert to human readable String for any type. |
long |
tolong()
Convert to long if numeric, or 0 if not. |
LuaValue |
tonumber()
Conditionally convert to lua number without throwing errors. |
short |
toshort()
Convert to short if numeric, or 0 if not. |
LuaValue |
tostring()
Conditionally convert to lua string without throwing errors. |
java.lang.String |
toString()
Convert the value to a human readable string using tojstring() |
java.lang.Object |
touserdata()
Convert to userdata instance, or null. |
java.lang.Object |
touserdata(java.lang.Class c)
Convert to userdata instance if specific type, or null. |
abstract int |
type()
Get the enumeration value for the type of this value. |
abstract java.lang.String |
typename()
Get the String name of the type of this value. |
protected LuaValue |
typerror(java.lang.String expected)
Throw a LuaError indicating an invalid type was supplied to a function |
protected LuaValue |
unimplemented(java.lang.String fun)
Throw a LuaError indicating an operation is not implemented |
static LuaUserdata |
userdataOf(java.lang.Object o)
Construct a LuaUserdata for an object. |
static LuaUserdata |
userdataOf(java.lang.Object o,
LuaValue metatable)
Construct a LuaUserdata for an object with a user supplied metatable. |
static LuaBoolean |
valueOf(boolean b)
Convert java boolean to a LuaValue . |
static LuaString |
valueOf(byte[] bytes)
Convert bytes in an array to a LuaValue . |
static LuaString |
valueOf(byte[] bytes,
int off,
int len)
Convert bytes in an array to a LuaValue . |
static LuaNumber |
valueOf(double d)
Convert java double to a LuaValue . |
static LuaInteger |
valueOf(int i)
Convert java int to a LuaValue . |
static LuaString |
valueOf(java.lang.String s)
Convert java string to a LuaValue . |
static Varargs |
varargsOf(LuaValue[] v)
Construct a Varargs around an array of LuaValue s. |
static Varargs |
varargsOf(LuaValue[] v,
int offset,
int length)
Construct a Varargs around an array of LuaValue s. |
static Varargs |
varargsOf(LuaValue[] v,
int offset,
int length,
Varargs more)
Construct a Varargs around an array of LuaValue s. |
static Varargs |
varargsOf(LuaValue[] v,
Varargs r)
Construct a Varargs around an array of LuaValue s. |
static Varargs |
varargsOf(LuaValue v1,
LuaValue v2,
Varargs v3)
Construct a Varargs around a set of 3 or more LuaValue s. |
static Varargs |
varargsOf(LuaValue v,
Varargs r)
Construct a Varargs around a set of 2 or more LuaValue s. |
Methods inherited from class org.luaj.vm2.Varargs |
---|
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, subargs, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int TINT
public static final int TNONE
public static final int TNIL
public static final int TBOOLEAN
public static final int TLIGHTUSERDATA
public static final int TNUMBER
public static final int TSTRING
public static final int TTABLE
public static final int TFUNCTION
public static final int TUSERDATA
public static final int TTHREAD
public static final int TVALUE
public static final java.lang.String[] TYPE_NAMES
type()
,
typename()
public static final LuaValue NIL
nil
public static final LuaBoolean TRUE
true
public static final LuaBoolean FALSE
false
public static final LuaValue NONE
Varargs
list of no values
public static final LuaNumber ZERO
public static final LuaNumber ONE
public static final LuaNumber MINUSONE
public static final LuaValue[] NOVALS
public static final LuaString INDEX
public static final LuaString NEWINDEX
public static final LuaString CALL
public static final LuaString MODE
public static final LuaString METATABLE
public static final LuaString ADD
public static final LuaString SUB
public static final LuaString DIV
public static final LuaString MUL
public static final LuaString POW
public static final LuaString MOD
public static final LuaString UNM
public static final LuaString LEN
public static final LuaString EQ
public static final LuaString LT
public static final LuaString LE
public static final LuaString TOSTRING
public static final LuaString CONCAT
public static final LuaString EMPTYSTRING
public static final LuaValue[] NILS
NIL
values to optimize filling stacks using System.arraycopy().
Must not be modified.
Constructor Detail |
---|
public LuaValue()
Method Detail |
---|
public abstract int type()
TNIL
,
TBOOLEAN
,
TNUMBER
,
TSTRING
,
TTABLE
,
TFUNCTION
,
TUSERDATA
,
TTHREAD
typename()
public abstract java.lang.String typename()
TYPE_NAMES
corresponding to the type of this value:
"nil", "boolean", "number", "string",
"table", "function", "userdata", "thread"type()
public boolean isboolean()
this
is a boolean
boolean
, otherwise falseisboolean()
,
toboolean()
,
checkboolean()
,
optboolean(boolean)
,
#TOBOLEAN
public boolean isclosure()
this
is a function
that is a closure,
meaning interprets lua bytecode for its execution
closure
, otherwise falseisfunction()
,
checkclosure()
,
optclosure(LuaClosure)
,
TFUNCTION
public boolean isfunction()
this
is a function
function
, otherwise falseisclosure()
,
checkfunction()
,
#optfunciton(LuaFunction)
,
TFUNCTION
public boolean isint()
this
is a number
and is representable by java int
without rounding or truncation
number
meaning derives from LuaNumber
or derives from LuaString
and is convertible to a number,
and can be represented by int,
otherwise falseisinttype()
,
islong()
,
tonumber()
,
checkint()
,
optint(int)
,
TNUMBER
public boolean isinttype()
this
is a LuaInteger
No attempt to convert from string will be made by this call.
LuaInteger
,
otherwise falseisint()
,
isnumber()
,
tonumber()
,
TNUMBER
public boolean islong()
this
is a number
and is representable by java long
without rounding or truncation
number
meaning derives from LuaNumber
or derives from LuaString
and is convertible to a number,
and can be represented by long,
otherwise falsetonumber()
,
checklong()
,
optlong(long)
,
TNUMBER
public boolean isnil()
this
is nil
nil
, otherwise falseNIL
,
NONE
,
checknotnil()
,
optvalue(LuaValue)
,
Varargs.isnoneornil(int)
,
TNIL
,
TNONE
public boolean isnumber()
this
is a number
number
,
meaning derives from LuaNumber
or derives from LuaString
and is convertible to a number,
otherwise falsetonumber()
,
checknumber()
,
optnumber(LuaNumber)
,
TNUMBER
public boolean isstring()
this
is a string
string
,
meaning derives from LuaString
or LuaNumber
,
otherwise falsetostring()
,
checkstring()
,
optstring(LuaString)
,
TSTRING
public boolean isthread()
this
is a thread
thread
, otherwise falsecheckthread()
,
optthread(LuaThread)
,
TTHREAD
public boolean istable()
this
is a table
table
, otherwise falsechecktable()
,
opttable(LuaTable)
,
TTABLE
public boolean isuserdata()
this
is a userdata
userdata
, otherwise falseisuserdata(Class)
,
touserdata()
,
checkuserdata()
,
optuserdata(Object)
,
TUSERDATA
public boolean isuserdata(java.lang.Class c)
this
is a userdata
of type c
c
- Class to test instance against
userdata
and the instance is assignable to c
,
otherwise falseisuserdata()
,
touserdata(Class)
,
checkuserdata(Class)
,
#optuserdata(Object,Class)
,
TUSERDATA
public boolean toboolean()
NIL
or FALSE
, true if anything else
optboolean(boolean)
,
checkboolean()
,
isboolean()
,
TBOOLEAN
public byte tobyte()
toint()
,
todouble()
,
#optbyte(byte)
,
checknumber()
,
isnumber()
,
TNUMBER
public char tochar()
toint()
,
todouble()
,
#optchar(char)
,
checknumber()
,
isnumber()
,
TNUMBER
public double todouble()
toint()
,
tobyte()
,
tochar()
,
toshort()
,
tolong()
,
tofloat()
,
optdouble(double)
,
checknumber()
,
isnumber()
,
TNUMBER
public float tofloat()
toint()
,
todouble()
,
#optfloat(float)
,
checknumber()
,
isnumber()
,
TNUMBER
public int toint()
tobyte()
,
tochar()
,
toshort()
,
tolong()
,
tofloat()
,
todouble()
,
optint(int)
,
checknumber()
,
isnumber()
,
TNUMBER
public long tolong()
isint()
,
isinttype()
,
toint()
,
todouble()
,
optlong(long)
,
checknumber()
,
isnumber()
,
TNUMBER
public short toshort()
toint()
,
todouble()
,
#optshort(short)
,
checknumber()
,
isnumber()
,
TNUMBER
public java.lang.String tojstring()
tojstring
in class Varargs
tostring()
,
optjstring(String)
,
checkjstring()
,
isstring()
,
TSTRING
public java.lang.Object touserdata()
LuaUserdata
optuserdata(Object)
,
checkuserdata()
,
isuserdata()
,
TUSERDATA
public java.lang.Object touserdata(java.lang.Class c)
c
,
or null if not LuaUserdata
optuserdata(Class,Object)
,
checkuserdata(Class)
,
isuserdata(Class)
,
TUSERDATA
public java.lang.String toString()
tojstring()
toString
in class Varargs
tostring()
,
tojstring()
,
optstring(LuaString)
,
checkstring()
,
toString()
public LuaValue tonumber()
In lua all numbers are strings, but not all strings are numbers.
This function will return
the LuaValue
this
if it is a number
or a string convertible to a number,
and NIL
for all other cases.
This allows values to be tested for their "numeric-ness" without the penalty of throwing exceptions, nor the cost of converting the type and creating storage for it.
this
if it is a LuaNumber
or LuaString
that can be converted to a number,
otherwise NIL
tostring()
,
optnumber(LuaNumber)
,
checknumber()
,
toint()
,
todouble()
public LuaValue tostring()
In lua all numbers are strings, so this function will return
the LuaValue
this
if it is a string or number,
and NIL
for all other cases.
This allows values to be tested for their "string-ness" without the penalty of throwing exceptions.
this
if it is a LuaString
or LuaNumber
,
otherwise NIL
tonumber()
,
tojstring()
,
optstring(LuaString)
,
checkstring()
,
toString()
public boolean optboolean(boolean defval)
defval
- boolean value to return if this
is nil or none
this
cast to boolean if a ,
defval
if nil or none,
throws LuaError
otherwise
LuaError
- if was not a boolean or nil or none.checkboolean()
,
isboolean()
,
TBOOLEAN
public LuaClosure optclosure(LuaClosure defval)
LuaClosure
A LuaClosure
is a that executes lua byteccode.
defval
- LuaClosure
to return if this
is nil or none
this
cast to LuaClosure
if a function,
defval
if nil or none,
throws LuaError
otherwise
LuaError
- if was not a closure or nil or none.checkclosure()
,
isclosure()
,
TFUNCTION
public double optdouble(double defval)
defval
- double to return if this
is nil or none
this
cast to double if numeric,
defval
if nil or none,
throws LuaError
otherwise
LuaError
- if was not numeric or nil or none.optint(int)
,
optinteger(LuaInteger)
,
checkdouble()
,
todouble()
,
tonumber()
,
isnumber()
,
TNUMBER
public LuaFunction optfunction(LuaFunction defval)
LuaFunction
A LuaFunction
may either be a Java function that implements
functionality directly in Java,
or a LuaClosure
which is a LuaFunction
that executes lua bytecode.
defval
- LuaFunction
to return if this
is nil or none
this
cast to LuaFunction
if a function,
defval
if nil or none,
throws LuaError
otherwise
LuaError
- if was not a function or nil or none.checkfunction()
,
isfunction()
,
TFUNCTION
public int optint(int defval)
defval
- int to return if this
is nil or none
this
cast to int if numeric,
defval
if nil or none,
throws LuaError
otherwise
LuaError
- if was not numeric or nil or none.optdouble(double)
,
optlong(long)
,
optinteger(LuaInteger)
,
checkint()
,
toint()
,
tonumber()
,
isnumber()
,
TNUMBER
public LuaInteger optinteger(LuaInteger defval)
LuaInteger
defval
- LuaInteger
to return if this
is nil or none
this
converted and wrapped in LuaInteger
if numeric,
defval
if nil or none,
throws LuaError
otherwise
LuaError
- if was not numeric or nil or none.optdouble(double)
,
optint(int)
,
checkint()
,
toint()
,
tonumber()
,
isnumber()
,
TNUMBER
public long optlong(long defval)
defval
- long to return if this
is nil or none
this
cast to long if numeric,
defval
if nil or none,
throws LuaError
otherwise
LuaError
- if was not numeric or nil or none.optdouble(double)
,
optint(int)
,
checkint()
,
toint()
,
tonumber()
,
isnumber()
,
TNUMBER
public LuaNumber optnumber(LuaNumber defval)
LuaNumber
defval
- LuaNumber
to return if this
is nil or none
this
cast to LuaNumber
if numeric,
defval
if nil or none,
throws LuaError
otherwise
LuaError
- if was not numeric or nil or none.optdouble(double)
,
optlong(long)
,
optint(int)
,
checkint()
,
toint()
,
tonumber()
,
isnumber()
,
TNUMBER
public java.lang.String optjstring(java.lang.String defval)
defval
- LuaString
to return if this
is nil or none
this
converted to String if a string or number,
defval
if nil or none,
throws LuaError
if some other type
LuaError
- if was not a string or number or nil or none.tojstring()
,
optstring(LuaString)
,
checkjstring()
,
toString()
,
TSTRING
public LuaString optstring(LuaString defval)
LuaString
defval
- LuaString
to return if this
is nil or none
this
converted to LuaString
if a string or number,
defval
if nil or none,
throws LuaError
if some other type
LuaError
- if was not a string or number or nil or none.tojstring()
,
optjstring(String)
,
checkstring()
,
toString()
,
TSTRING
public LuaTable opttable(LuaTable defval)
LuaTable
defval
- LuaTable
to return if this
is nil or none
this
cast to LuaTable
if a table,
defval
if nil or none,
throws LuaError
if some other type
LuaError
- if was not a table or nil or none.checktable()
,
istable()
,
TTABLE
public LuaThread optthread(LuaThread defval)
LuaThread
defval
- LuaThread
to return if this
is nil or none
this
cast to LuaTable
if a thread,
defval
if nil or none,
throws LuaError
if some other type
LuaError
- if was not a thread or nil or none.checkthread()
,
isthread()
,
TTHREAD
public java.lang.Object optuserdata(java.lang.Object defval)
defval
- Object to return if this
is nil or none
LuaUserdata
,
defval
if nil or none,
throws LuaError
if some other type
LuaError
- if was not a userdata or nil or none.checkuserdata()
,
isuserdata()
,
optuserdata(Class, Object)
,
TUSERDATA
public java.lang.Object optuserdata(java.lang.Class c, java.lang.Object defval)
c
- Class to test userdata instance againstdefval
- Object to return if this
is nil or none
LuaUserdata
and instance is assignable to c
,
defval
if nil or none,
throws LuaError
if some other type
LuaError
- if was not a userdata whose instance is assignable to c
or nil or none.checkuserdata(Class)
,
isuserdata(Class)
,
optuserdata(Object)
,
TUSERDATA
public LuaValue optvalue(LuaValue defval)
defval
- LuaValue
to return if this
is nil or none
this
if not nil or none, else defval
NIL
,
NONE
,
isnil()
,
Varargs.isnoneornil(int)
,
TNIL
,
TNONE
public boolean checkboolean()
LuaBoolean
,
or throw LuaError
if not
this
if it is a LuaBoolean
LuaError
- if not a LuaBoolean
optboolean(boolean)
,
TBOOLEAN
public LuaClosure checkclosure()
LuaClosure
,
or throw LuaError
if not
LuaClosure
is a subclass of that interprets lua bytecode.
this
cast as LuaClosure
LuaError
- if not a LuaClosure
checkfunction()
,
optclosure(LuaClosure)
,
isclosure()
,
TFUNCTION
public double checkdouble()
LuaError
if not numeric
Values that are LuaNumber
and values that are LuaString
that can be converted to a number will be converted to double.
LuaError
- if not a LuaNumber
or is a LuaString
that can't be converted to numbercheckint()
,
checkinteger()
,
checklong()
,
optdouble(double)
,
TNUMBER
public LuaValue checkfunction()
LuaError
if not
A function is considered anything whose type()
returns TFUNCTION
.
In practice it will be either a built-in Java function, typically deriving from
LuaFunction
or a LuaClosure
which represents lua source compiled
into lua bytecode.
this
if if a lua function or closure
LuaError
- if not a functioncheckclosure()
public int checkint()
LuaError
if not numeric
Values that are LuaNumber
will be cast to int and may lose precision.
Values that are LuaString
that can be converted to a number will be converted,
then cast to int, so may also lose precision.
LuaError
- if not a LuaNumber
or is a LuaString
that can't be converted to numbercheckinteger()
,
checklong()
,
checkdouble()
,
optint(int)
,
TNUMBER
public LuaInteger checkinteger()
LuaError
if not numeric
Values that are LuaNumber
will be cast to int and may lose precision.
Values that are LuaString
that can be converted to a number will be converted,
then cast to int, so may also lose precision.
LuaInteger
if numeric
LuaError
- if not a LuaNumber
or is a LuaString
that can't be converted to numbercheckint()
,
checklong()
,
checkdouble()
,
optinteger(LuaInteger)
,
TNUMBER
public long checklong()
LuaError
if not numeric
Values that are LuaNumber
will be cast to long and may lose precision.
Values that are LuaString
that can be converted to a number will be converted,
then cast to long, so may also lose precision.
LuaError
- if not a LuaNumber
or is a LuaString
that can't be converted to numbercheckint()
,
checkinteger()
,
checkdouble()
,
optlong(long)
,
TNUMBER
public LuaNumber checknumber()
LuaError
Values that are LuaString
that can be converted to a number will be converted and returned.
LuaNumber
if numeric
LuaError
- if not a LuaNumber
or is a LuaString
that can't be converted to numbercheckint()
,
checkinteger()
,
checkdouble()
,
checklong()
,
optnumber(LuaNumber)
,
TNUMBER
public LuaNumber checknumber(java.lang.String msg)
LuaError
Values that are LuaString
that can be converted to a number will be converted and returned.
msg
- String message to supply if conversion fails
LuaNumber
if numeric
LuaError
- if not a LuaNumber
or is a LuaString
that can't be converted to numbercheckint()
,
checkinteger()
,
checkdouble()
,
checklong()
,
optnumber(LuaNumber)
,
TNUMBER
public java.lang.String checkjstring()
The string representations here will roughly match what is produced by the C lua distribution, however hash codes have no relationship, and there may be differences in number formatting.
checkstring()
,
optjstring(String)
,
tojstring()
,
isstring()
,
TSTRING
public LuaString checkstring()
LuaError
if it is not.
In lua all numbers are strings, so this will succeed for
anything that derives from LuaString
or LuaNumber
.
Numbers will be converted to LuaString
.
LuaString
representation of the value if it is a LuaString
or LuaNumber
LuaError
- if this
is not a LuaTable
checkjstring()
,
optstring(LuaString)
,
tostring()
,
isstring()
,
TSTRING
public LuaTable checktable()
LuaTable
, or throw LuaError
if it is not
this
if it is a LuaTable
LuaError
- if this
is not a LuaTable
istable()
,
opttable(LuaTable)
,
TTABLE
public LuaThread checkthread()
LuaThread
, or throw LuaError
if it is not
this
if it is a LuaThread
LuaError
- if this
is not a LuaThread
isthread()
,
optthread(LuaThread)
,
TTHREAD
public java.lang.Object checkuserdata()
LuaUserdata
, or throw LuaError
if it is not
this
if it is a LuaUserdata
LuaError
- if this
is not a LuaUserdata
isuserdata()
,
optuserdata(Object)
,
checkuserdata(Class)
,
TUSERDATA
public java.lang.Object checkuserdata(java.lang.Class c)
LuaUserdata
, or throw LuaError
if it is not
this
if it is a LuaUserdata
LuaError
- if this
is not a LuaUserdata
isuserdata(Class)
,
optuserdata(Class, Object)
,
checkuserdata()
,
TUSERDATA
public LuaValue checknotnil()
NIL
, or throw LuaError
if it is
this
if it is not NIL
LuaError
- if this
is NIL
optvalue(LuaValue)
public LuaValue checkvalidkey()
LuaError
if not
this
if valid as a table key
LuaError
- if not valid as a table keyisnil()
,
isinttype()
public static LuaValue error(java.lang.String message)
LuaError
with a particular message
message
- String providing message details
LuaError
- in all casespublic static void assert_(boolean b, java.lang.String msg)
LuaError
if not
b
- condition to test
LuaError
- if b is not trueprotected LuaValue argerror(java.lang.String expected)
LuaError
indicating an invalid argument was supplied to a function
expected
- String naming the type that was expected
LuaError
- in all casespublic static LuaValue argerror(int iarg, java.lang.String msg)
LuaError
indicating an invalid argument was supplied to a function
iarg
- index of the argument that was invalid, first index is 1msg
- String providing information about the invalid argument
LuaError
- in all casesprotected LuaValue typerror(java.lang.String expected)
LuaError
indicating an invalid type was supplied to a function
expected
- String naming the type that was expected
LuaError
- in all casesprotected LuaValue unimplemented(java.lang.String fun)
LuaError
indicating an operation is not implemented
LuaError
- in all casesprotected LuaValue illegal(java.lang.String op, java.lang.String typename)
LuaError
indicating an illegal operation occurred,
typically involved in managing weak references
LuaError
- in all casesprotected LuaValue lenerror()
LuaError
based on the len operator,
typically due to an invalid operand type
LuaError
- in all casesprotected LuaValue aritherror()
LuaError
based on an arithmetic error such as add, or pow,
typically due to an invalid operand type
LuaError
- in all casesprotected LuaValue aritherror(java.lang.String fun)
LuaError
based on an arithmetic error such as add, or pow,
typically due to an invalid operand type
fun
- String description of the function that was attempted
LuaError
- in all casesprotected LuaValue compareerror(java.lang.String rhs)
LuaError
based on a comparison error such as greater-than or less-than,
typically due to an invalid operand type
rhs
- String description of what was on the right-hand-side of the comparison that resulted in the error.
LuaError
- in all casesprotected LuaValue compareerror(LuaValue rhs)
LuaError
based on a comparison error such as greater-than or less-than,
typically due to an invalid operand type
rhs
- Right-hand-side of the comparison that resulted in the error.
LuaError
- in all casespublic LuaValue get(LuaValue key)
INDEX
.
key
- the key to look up, must not be NIL
or null
LuaValue
for that key, or NIL
if not found and no metatag
LuaError
- if this
is not a table,
or there is no INDEX
metatag,
or key is NIL
get(int)
,
get(String)
,
rawget(LuaValue)
public LuaValue get(int key)
INDEX
.
key
- the key to look up
LuaValue
for that key, or NIL
if not found
LuaError
- if this
is not a table,
or there is no INDEX
metatagget(LuaValue)
,
rawget(int)
public LuaValue get(java.lang.String key)
INDEX
.
key
- the key to look up, must not be null
LuaValue
for that key, or NIL
if not found
LuaError
- if this
is not a table,
or there is no INDEX
metatagget(LuaValue)
,
rawget(String)
public void set(LuaValue key, LuaValue value)
NEWINDEX
.
key
- the key to use, must not be NIL
or nullvalue
- the value to use, can be NIL
, must not be null
LuaError
- if this
is not a table,
or key is NIL
,
or there is no NEWINDEX
metatagpublic void set(int key, LuaValue value)
NEWINDEX
.
key
- the key to usevalue
- the value to use, can be NIL
, must not be null
LuaError
- if this
is not a table,
or there is no NEWINDEX
metatagpublic void set(int key, java.lang.String value)
NEWINDEX
.
key
- the key to usevalue
- the value to use, must not be null
LuaError
- if this
is not a table,
or there is no NEWINDEX
metatagpublic void set(java.lang.String key, LuaValue value)
NEWINDEX
.
key
- the key to use, must not be NIL
or nullvalue
- the value to use, can be NIL
, must not be null
LuaError
- if this
is not a table,
or there is no NEWINDEX
metatagpublic void set(java.lang.String key, double value)
NEWINDEX
.
key
- the key to use, must not be nullvalue
- the value to use
LuaError
- if this
is not a table,
or there is no NEWINDEX
metatagpublic void set(java.lang.String key, int value)
NEWINDEX
.
key
- the key to use, must not be nullvalue
- the value to use
LuaError
- if this
is not a table,
or there is no NEWINDEX
metatagpublic void set(java.lang.String key, java.lang.String value)
NEWINDEX
.
key
- the key to use, must not be nullvalue
- the value to use, must not be null
LuaError
- if this
is not a table,
or there is no NEWINDEX
metatagpublic LuaValue rawget(LuaValue key)
key
- the key to look up, must not be NIL
or null
LuaValue
for that key, or NIL
if not found
LuaError
- if this
is not a table, or key is NIL
public LuaValue rawget(int key)
key
- the key to look up
LuaValue
for that key, or NIL
if not found
LuaError
- if this
is not a tablepublic LuaValue rawget(java.lang.String key)
key
- the key to look up, must not be null
LuaValue
for that key, or NIL
if not found
LuaError
- if this
is not a tablepublic void rawset(LuaValue key, LuaValue value)
key
- the key to use, must not be NIL
or nullvalue
- the value to use, can be NIL
, must not be null
LuaError
- if this
is not a table, or key is NIL
public void rawset(int key, LuaValue value)
key
- the key to usevalue
- the value to use, can be NIL
, must not be null
LuaError
- if this
is not a tablepublic void rawset(int key, java.lang.String value)
key
- the key to usevalue
- the value to use, can be NIL
, must not be null
LuaError
- if this
is not a tablepublic void rawset(java.lang.String key, LuaValue value)
key
- the key to use, must not be nullvalue
- the value to use, can be NIL
, must not be null
LuaError
- if this
is not a tablepublic void rawset(java.lang.String key, double value)
key
- the key to use, must not be nullvalue
- the value to use
LuaError
- if this
is not a tablepublic void rawset(java.lang.String key, int value)
key
- the key to use, must not be nullvalue
- the value to use
LuaError
- if this
is not a tablepublic void rawset(java.lang.String key, java.lang.String value)
key
- the key to use, must not be nullvalue
- the value to use, must not be null
LuaError
- if this
is not a tablepublic void rawsetlist(int key0, Varargs values)
Primarily used internally in response to a SETLIST bytecode.
key0
- the first key to set in the tablevalues
- the list of values to set
LuaError
- if this is not a table.public void presize(int i)
Primarily used internally in response to a SETLIST bytecode.
i
- the number of array slots to preallocate in the table.
LuaError
- if this is not a table.public Varargs next(LuaValue index)
this
is a table,
return NIL
if there are no more, or throw a LuaError
if not a table.
To iterate over all key-value pairs in a table you can use
LuaValue k = LuaValue.NIL;
while ( true ) {
Varargs n = table.next(k);
if ( (k = n.arg1()).isnil() )
break;
LuaValue v = n.arg(2)
process( k, v )
}
index
- LuaInteger
value identifying a key to start from,
or NIL
to start at the beginning
Varargs
containing {key,value} for the next entry,
or NIL
if there are no more.
LuaError
- if this
is not a table, or the supplied key is invalid.LuaTable
,
#inext()
,
valueOf(int)
,
Varargs.arg1()
,
Varargs.arg(int)
,
isnil()
public Varargs inext(LuaValue index)
this
is a table,
return NIL
if there are no more, or throw a LuaError
if not a table.
To iterate over integer keys in a table you can use
LuaValue k = LuaValue.NIL;
while ( true ) {
Varargs n = table.inext(k);
if ( (k = n.arg1()).isnil() )
break;
LuaValue v = n.arg(2)
process( k, v )
}
index
- LuaInteger
value identifying a key to start from,
or NIL
to start at the beginning
Varargs
containing (key,value)
for the next entry,
or NONE
if there are no more.
LuaError
- if this
is not a table, or the supplied key is invalid.LuaTable
,
#next()
,
valueOf(int)
,
Varargs.arg1()
,
Varargs.arg(int)
,
isnil()
public LuaValue load(LuaValue library)
this
and calling it, which should iniitalize the library instance and
install itself into this instance.
library
- The callable LuaValue
to load into this
LuaValue
containing the result of the initialization call.public LuaValue arg(int index)
Varargs
arg
in class Varargs
index
- the index of the argument to get, 1 is the first argument
Varargs.arg1()
,
NIL
public int narg()
Varargs
narg
in class Varargs
public LuaValue arg1()
Varargs
arg1
in class Varargs
Varargs.arg(int)
,
NIL
public LuaValue getmetatable()
LuaValue
For LuaTable
and LuaUserdata
instances,
the metatable returned is this instance metatable.
For all other types, the class metatable value will be returned.
LuaBoolean.s_metatable
,
LuaNumber.s_metatable
,
LuaNil.s_metatable
,
LuaFunction.s_metatable
,
LuaThread.s_metatable
public LuaValue setmetatable(LuaValue metatable)
LuaValue
For LuaTable
and LuaUserdata
instances, the metatable is per instance.
For all other types, there is one metatable per type that can be set directly from java
metatable
- LuaValue
instance to serve as the metatable, or null to reset it.
this
to allow chaining of Java function callsLuaBoolean.s_metatable
,
LuaNumber.s_metatable
,
LuaNil.s_metatable
,
LuaFunction.s_metatable
,
LuaThread.s_metatable
public LuaValue getfenv()
LuaValue
currently set as the instances environent.public void setfenv(LuaValue env)
Typically the environment is created once per application via a platform
helper method such as JsePlatform.standardGlobals()
However, any object can serve as an environment if it contains suitable metatag
values to implement get(LuaValue)
to provide the environment values.
env
- LuaValue
(typically a LuaTable
) containing the environment.JmePlatform
,
JsePlatform
public LuaValue call()
this
with 0 arguments, including metatag processing,
and return only the first return value.
If this
is a LuaFunction
, call it,
and return only its first return value, dropping any others.
Otherwise, look for the CALL
metatag and call that.
If the return value is a Varargs
, only the 1st value will be returned.
To get multiple values, use invoke()
instead.
To call this
as a method call, use method(LuaValue)
instead.
(this())
, or NIL
if there were none.
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call(LuaValue)
,
call(LuaValue,LuaValue)
,
call(LuaValue, LuaValue, LuaValue)
,
invoke()
,
method(String)
,
method(LuaValue)
public LuaValue call(LuaValue arg)
this
with 1 argument, including metatag processing,
and return only the first return value.
If this
is a LuaFunction
, call it,
and return only its first return value, dropping any others.
Otherwise, look for the CALL
metatag and call that.
If the return value is a Varargs
, only the 1st value will be returned.
To get multiple values, use invoke()
instead.
To call this
as a method call, use method(LuaValue)
instead.
arg
- First argument to supply to the called function
(this(arg))
, or NIL
if there were none.
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
call(LuaValue,LuaValue)
,
call(LuaValue, LuaValue, LuaValue)
,
#invoke(LuaValue)
,
method(String,LuaValue)
,
method(LuaValue,LuaValue)
public LuaValue call(LuaValue arg1, LuaValue arg2)
this
with 2 arguments, including metatag processing,
and return only the first return value.
If this
is a LuaFunction
, call it,
and return only its first return value, dropping any others.
Otherwise, look for the CALL
metatag and call that.
If the return value is a Varargs
, only the 1st value will be returned.
To get multiple values, use invoke()
instead.
To call this
as a method call, use method(LuaValue)
instead.
arg1
- First argument to supply to the called functionarg2
- Second argument to supply to the called function
(this(arg1,arg2))
, or NIL
if there were none.
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
call(LuaValue)
,
call(LuaValue, LuaValue, LuaValue)
,
#invoke(LuaValue,LuaValue)
,
method(String,LuaValue,LuaValue)
,
method(LuaValue,LuaValue,LuaValue)
public LuaValue call(LuaValue arg1, LuaValue arg2, LuaValue arg3)
this
with 3 arguments, including metatag processing,
and return only the first return value.
If this
is a LuaFunction
, call it,
and return only its first return value, dropping any others.
Otherwise, look for the CALL
metatag and call that.
If the return value is a Varargs
, only the 1st value will be returned.
To get multiple values, use invoke()
instead.
To call this
as a method call, use method(LuaValue)
instead.
arg1
- First argument to supply to the called functionarg2
- Second argument to supply to the called functionarg3
- Second argument to supply to the called function
(this(arg1,arg2,arg3))
, or NIL
if there were none.
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
call(LuaValue)
,
call(LuaValue, LuaValue)
,
#invoke(LuaValue,LuaValue, LuaValue)
,
invokemethod(String,Varargs)
,
invokemethod(LuaValue,Varargs)
public LuaValue method(java.lang.String name)
this
with 0 arguments, including metatag processing,
and return only the first return value.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument.
and return only its first return value, dropping any others.
Otherwise, look for the CALL
metatag and call that.
If the return value is a Varargs
, only the 1st value will be returned.
To get multiple values, use invoke()
instead.
To call this
as a plain call, use call()
instead.
name
- Name of the method to look up for invocation
this:name()
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
invoke()
,
method(LuaValue)
,
method(String,LuaValue)
,
method(String,LuaValue,LuaValue)
public LuaValue method(LuaValue name)
this
with 0 arguments, including metatag processing,
and return only the first return value.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return only its first return value, dropping any others.
Otherwise, look for the CALL
metatag and call that.
If the return value is a Varargs
, only the 1st value will be returned.
To get multiple values, use invoke()
instead.
To call this
as a plain call, use call()
instead.
name
- Name of the method to look up for invocation
this:name()
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
invoke()
,
method(String)
,
method(LuaValue,LuaValue)
,
method(LuaValue,LuaValue,LuaValue)
public LuaValue method(java.lang.String name, LuaValue arg)
this
with 1 argument, including metatag processing,
and return only the first return value.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return only its first return value, dropping any others.
Otherwise, look for the CALL
metatag and call that.
If the return value is a Varargs
, only the 1st value will be returned.
To get multiple values, use invoke()
instead.
To call this
as a plain call, use call(LuaValue)
instead.
name
- Name of the method to look up for invocationarg
- Argument to supply to the method
this:name(arg)
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call(LuaValue)
,
#invoke(LuaValue)
,
method(LuaValue,LuaValue)
,
method(String)
,
method(String,LuaValue,LuaValue)
public LuaValue method(LuaValue name, LuaValue arg)
this
with 1 argument, including metatag processing,
and return only the first return value.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return only its first return value, dropping any others.
Otherwise, look for the CALL
metatag and call that.
If the return value is a Varargs
, only the 1st value will be returned.
To get multiple values, use invoke()
instead.
To call this
as a plain call, use call(LuaValue)
instead.
name
- Name of the method to look up for invocationarg
- Argument to supply to the method
this:name(arg)
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call(LuaValue)
,
#invoke(LuaValue)
,
method(String,LuaValue)
,
method(LuaValue)
,
method(LuaValue,LuaValue,LuaValue)
public LuaValue method(java.lang.String name, LuaValue arg1, LuaValue arg2)
this
with 2 arguments, including metatag processing,
and return only the first return value.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return only its first return value, dropping any others.
Otherwise, look for the CALL
metatag and call that.
If the return value is a Varargs
, only the 1st value will be returned.
To get multiple values, use invoke()
instead.
To call this
as a plain call, use call(LuaValue,LuaValue)
instead.
name
- Name of the method to look up for invocationarg1
- First argument to supply to the methodarg2
- Second argument to supply to the method
this:name(arg1,arg2)
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call(LuaValue,LuaValue)
,
invoke(LuaValue,Varargs)
,
method(String,LuaValue)
,
method(LuaValue,LuaValue,LuaValue)
public LuaValue method(LuaValue name, LuaValue arg1, LuaValue arg2)
this
with 2 arguments, including metatag processing,
and return only the first return value.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return only its first return value, dropping any others.
Otherwise, look for the CALL
metatag and call that.
If the return value is a Varargs
, only the 1st value will be returned.
To get multiple values, use invoke()
instead.
To call this
as a plain call, use call(LuaValue,LuaValue)
instead.
name
- Name of the method to look up for invocationarg1
- First argument to supply to the methodarg2
- Second argument to supply to the method
this:name(arg1,arg2)
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call(LuaValue,LuaValue)
,
invoke(LuaValue,Varargs)
,
method(LuaValue,LuaValue)
,
method(String,LuaValue,LuaValue)
public Varargs invoke()
this
with 0 arguments, including metatag processing,
and retain all return values in a Varargs
.
If this
is a LuaFunction
, call it, and return all values.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a method call, use invokemethod(LuaValue)
instead.
Varargs
instance.
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
invoke(Varargs)
,
invokemethod(String)
,
invokemethod(LuaValue)
public Varargs invoke(Varargs args)
this
with variable arguments, including metatag processing,
and retain all return values in a Varargs
.
If this
is a LuaFunction
, call it, and return all values.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a method call, use invokemethod(LuaValue)
instead.
args
- Varargs containing the arguments to supply to the called function
Varargs
instance.
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
varargsOf(LuaValue[])
,
call(LuaValue)
,
invoke()
,
invoke(LuaValue,Varargs)
,
invokemethod(String,Varargs)
,
invokemethod(LuaValue,Varargs)
public Varargs invoke(LuaValue arg, Varargs varargs)
this
with variable arguments, including metatag processing,
and retain all return values in a Varargs
.
If this
is a LuaFunction
, call it, and return all values.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a method call, use invokemethod(LuaValue,Varargs)
instead.
arg
- The first argument to supply to the called functionvarargs
- Varargs containing the remaining arguments to supply to the called function
Varargs
instance.
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
varargsOf(LuaValue[])
,
call(LuaValue,LuaValue)
,
invoke(LuaValue,Varargs)
,
invokemethod(String,Varargs)
,
invokemethod(LuaValue,Varargs)
public Varargs invoke(LuaValue arg1, LuaValue arg2, Varargs varargs)
this
with variable arguments, including metatag processing,
and retain all return values in a Varargs
.
If this
is a LuaFunction
, call it, and return all values.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a method call, use invokemethod(LuaValue,Varargs)
instead.
arg1
- The first argument to supply to the called functionarg2
- The second argument to supply to the called functionvarargs
- Varargs containing the remaining arguments to supply to the called function
Varargs
instance.
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
varargsOf(LuaValue[])
,
call(LuaValue,LuaValue,LuaValue)
,
invoke(LuaValue,LuaValue,Varargs)
,
invokemethod(String,Varargs)
,
invokemethod(LuaValue,Varargs)
public Varargs invoke(LuaValue[] args)
this
with variable arguments, including metatag processing,
and retain all return values in a Varargs
.
If this
is a LuaFunction
, call it, and return all values.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a method call, use invokemethod(LuaValue,Varargs)
instead.
args
- Array of arguments to supply to the called function
Varargs
instance.
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
varargsOf(LuaValue[])
,
call(LuaValue,LuaValue,LuaValue)
,
invoke(LuaValue,LuaValue,Varargs)
,
invokemethod(String,LuaValue[])
,
invokemethod(LuaValue,LuaValue[])
public Varargs invoke(LuaValue[] args, Varargs varargs)
this
with variable arguments, including metatag processing,
and retain all return values in a Varargs
.
If this
is a LuaFunction
, call it, and return all values.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a method call, use invokemethod(LuaValue,Varargs)
instead.
args
- Array of arguments to supply to the called functionvarargs
- Varargs containing additional arguments to supply to the called function
Varargs
instance.
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
varargsOf(LuaValue[])
,
call(LuaValue,LuaValue,LuaValue)
,
invoke(LuaValue,LuaValue,Varargs)
,
invokemethod(String,LuaValue[])
,
invokemethod(LuaValue,LuaValue[])
,
invokemethod(String,Varargs)
,
invokemethod(LuaValue,Varargs)
public Varargs invokemethod(java.lang.String name)
this
with 0 arguments, including metatag processing,
and retain all return values in a Varargs
.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return all return values as a Varargs
instance.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a plain call, use invoke()
instead.
name
- Name of the method to look up for invocation
this:name()
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
invoke()
,
method(String)
,
invokemethod(LuaValue)
,
#invokemethod(String,LuaValue)
public Varargs invokemethod(LuaValue name)
this
with 0 arguments, including metatag processing,
and retain all return values in a Varargs
.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return all return values as a Varargs
instance.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a plain call, use invoke()
instead.
name
- Name of the method to look up for invocation
this:name()
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
invoke()
,
method(LuaValue)
,
invokemethod(String)
,
#invokemethod(LuaValue,LuaValue)
public Varargs invokemethod(java.lang.String name, Varargs args)
this
with 1 argument, including metatag processing,
and retain all return values in a Varargs
.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return all return values as a Varargs
instance.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a plain call, use invoke(Varargs)
instead.
name
- Name of the method to look up for invocationargs
- Varargs
containing arguments to supply to the called function after this
this:name(args)
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
invoke(Varargs)
,
method(String)
,
invokemethod(LuaValue,Varargs)
,
invokemethod(String,LuaValue[])
public Varargs invokemethod(LuaValue name, Varargs args)
this
with variable arguments, including metatag processing,
and retain all return values in a Varargs
.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return all return values as a Varargs
instance.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a plain call, use invoke(Varargs)
instead.
name
- Name of the method to look up for invocationargs
- Varargs
containing arguments to supply to the called function after this
this:name(args)
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
invoke(Varargs)
,
method(String)
,
invokemethod(String,Varargs)
,
invokemethod(LuaValue,LuaValue[])
public Varargs invokemethod(java.lang.String name, LuaValue[] args)
this
with 1 argument, including metatag processing,
and retain all return values in a Varargs
.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return all return values as a Varargs
instance.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a plain call, use invoke(Varargs)
instead.
name
- Name of the method to look up for invocationargs
- Array of LuaValue
containing arguments to supply to the called function after this
this:name(args)
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
invoke(Varargs)
,
method(String)
,
invokemethod(LuaValue,LuaValue[])
,
invokemethod(String,Varargs)
,
varargsOf(LuaValue[])
public Varargs invokemethod(LuaValue name, LuaValue[] args)
this
with variable arguments, including metatag processing,
and retain all return values in a Varargs
.
Look up this[name]
and if it is a LuaFunction
,
call it inserting this
as an additional first argument,
and return all return values as a Varargs
instance.
Otherwise, look for the CALL
metatag and call that.
To get a particular return value, us Varargs.arg(int)
To call this
as a plain call, use invoke(Varargs)
instead.
name
- Name of the method to look up for invocationargs
- Array of LuaValue
containing arguments to supply to the called function after this
this:name(args)
as a Varargs
instance
LuaError
- if not a function and CALL
is not defined,
or the invoked function throws a LuaError
or the invoked closure throw a lua error
call()
,
invoke(Varargs)
,
method(String)
,
invokemethod(String,LuaValue[])
,
invokemethod(LuaValue,Varargs)
,
varargsOf(LuaValue[])
protected LuaValue callmt()
CALL
metatag, if it exists.
LuaValue
value if metatag is defined
LuaError
- if CALL
metatag is not defined.public LuaValue not()
(~this)
as defined by lua not operator
TRUE
if NIL
or FALSE
, otherwise FALSE
public LuaValue neg()
(-this)
as defined by lua unary minus operator
LuaBoolean
if boolean or nil,
numeric inverse as if numeric,
or metatag processing result if UNM
metatag is defined
LuaError
- if this
is not a table or string, and has no UNM
metatagpublic LuaValue len()
(#this)
including metatag processing as java int
LuaError
- if this
is not a table or string, and has no LEN
metatagpublic int length()
(#this)
including metatag processing as java int
toint()
LuaError
- if this
is not a table or string, and has no LEN
metatagpublic LuaValue getn()
this
is a LuaTable
LuaError
- if this
is not a LuaTable
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public LuaValue eq(LuaValue val)
EQ
.
val
- The value to compare with.
TRUE
if values are comparable and (this == rhs)
,
FALSE
if comparable but not equal,
LuaValue
if metatag processing occurs.eq_b(LuaValue)
,
raweq(LuaValue)
,
neq(LuaValue)
,
eqmtcall(LuaValue, LuaValue, LuaValue, LuaValue)
,
EQ
public boolean eq_b(LuaValue val)
EQ
,
and return java boolean
val
- The value to compare with.
(this == rhs)
,
false if comparable but not equal,
result converted to java boolean if metatag processing occurs.eq(LuaValue)
,
raweq(LuaValue)
,
neq_b(LuaValue)
,
eqmtcall(LuaValue, LuaValue, LuaValue, LuaValue)
,
EQ
public LuaValue neq(LuaValue val)
EQ
.
val
- The value to compare with.
TRUE
if values are comparable and (this != rhs)
,
FALSE
if comparable but equal,
inverse of LuaValue
converted to LuaBoolean
if metatag processing occurs.eq(LuaValue)
,
raweq(LuaValue)
,
eqmtcall(LuaValue, LuaValue, LuaValue, LuaValue)
,
EQ
public boolean neq_b(LuaValue val)
EQ
.
val
- The value to compare with.
(this != rhs)
,
false if comparable but equal,
inverse of result converted to boolean if metatag processing occurs.eq_b(LuaValue)
,
raweq(LuaValue)
,
eqmtcall(LuaValue, LuaValue, LuaValue, LuaValue)
,
EQ
public boolean raweq(LuaValue val)
val
- The value to compare with.
(this == rhs)
, false otherwiseeq(LuaValue)
,
raweq(LuaUserdata)
,
raweq(LuaString)
,
raweq(double)
,
raweq(int)
,
EQ
public boolean raweq(LuaUserdata val)
LuaUserdata
value
without metatag processing.
val
- The LuaUserdata
to compare with.
this
is userdata
and their metatables are the same using ==
and their instances are equal using equals(Object)
,
otherwise falseeq(LuaValue)
,
raweq(LuaValue)
public boolean raweq(LuaString val)
LuaString
value
without metatag processing.
val
- The LuaString
to compare with.
this
is a LuaString
and their byte sequences match,
otherwise falsepublic boolean raweq(double val)
val
- The double value to compare with.
this
is a LuaNumber
whose value equals val,
otherwise falsepublic boolean raweq(int val)
val
- The double value to compare with.
this
is a LuaNumber
whose value equals val,
otherwise falsepublic static final boolean eqmtcall(LuaValue lhs, LuaValue lhsmt, LuaValue rhs, LuaValue rhsmt)
lhs
- left-hand-side of equality expressionlhsmt
- metatag value for left-hand-siderhs
- right-hand-side of equality expressionrhsmt
- metatag value for right-hand-side
NIL
or FALSE
LuaError
- if metatag was not defined for either operandequals(Object)
,
eq(LuaValue)
,
raweq(LuaValue)
,
EQ
public LuaValue add(LuaValue rhs)
Each operand must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the add with
(this + rhs)
if both are numeric,
or LuaValue
if metatag processing occurs
LuaError
- if either operand is not a number or string convertible to number,
and neither has the ADD
metatag definedarithmt(LuaValue, LuaValue)
public LuaValue add(double rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the add with
(this + rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numberadd(LuaValue)
public LuaValue add(int rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the add with
(this + rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numberadd(LuaValue)
public LuaValue sub(LuaValue rhs)
Each operand must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the subtract with
(this - rhs)
if both are numeric,
or LuaValue
if metatag processing occurs
LuaError
- if either operand is not a number or string convertible to number,
and neither has the SUB
metatag definedarithmt(LuaValue, LuaValue)
public LuaValue sub(double rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the subtract with
(this - rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numbersub(LuaValue)
public LuaValue sub(int rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the subtract with
(this - rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numbersub(LuaValue)
public LuaValue subFrom(double lhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
lhs
- The left-hand-side value from which to perform the subtraction
(lhs - this)
if this is numeric
LuaError
- if this
is not a number or string convertible to numbersub(LuaValue)
,
sub(double)
,
sub(int)
public LuaValue subFrom(int lhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
For metatag processing sub(LuaValue)
must be used
lhs
- The left-hand-side value from which to perform the subtraction
(lhs - this)
if this is numeric
LuaError
- if this
is not a number or string convertible to numbersub(LuaValue)
,
sub(double)
,
sub(int)
public LuaValue mul(LuaValue rhs)
Each operand must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the multiply with
(this * rhs)
if both are numeric,
or LuaValue
if metatag processing occurs
LuaError
- if either operand is not a number or string convertible to number,
and neither has the MUL
metatag definedarithmt(LuaValue, LuaValue)
public LuaValue mul(double rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the multiply with
(this * rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numbermul(LuaValue)
public LuaValue mul(int rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the multiply with
(this * rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numbermul(LuaValue)
public LuaValue pow(LuaValue rhs)
Each operand must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The power to raise this value to
(this ^ rhs)
if both are numeric,
or LuaValue
if metatag processing occurs
LuaError
- if either operand is not a number or string convertible to number,
and neither has the POW
metatag definedarithmt(LuaValue, LuaValue)
public LuaValue pow(double rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The power to raise this value to
(this ^ rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numberpow(LuaValue)
public LuaValue pow(int rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The power to raise this value to
(this ^ rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numberpow(LuaValue)
public LuaValue powWith(double lhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
lhs
- The left-hand-side value which will be raised to this power
(lhs ^ this)
if this is numeric
LuaError
- if this
is not a number or string convertible to numberpow(LuaValue)
,
pow(double)
,
pow(int)
public LuaValue powWith(int lhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
lhs
- The left-hand-side value which will be raised to this power
(lhs ^ this)
if this is numeric
LuaError
- if this
is not a number or string convertible to numberpow(LuaValue)
,
pow(double)
,
pow(int)
public LuaValue div(LuaValue rhs)
Each operand must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the divulo with
(this / rhs)
if both are numeric,
or LuaValue
if metatag processing occurs
LuaError
- if either operand is not a number or string convertible to number,
and neither has the DIV
metatag definedarithmt(LuaValue, LuaValue)
public LuaValue div(double rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
For metatag processing div(LuaValue)
must be used
rhs
- The right-hand-side value to perform the divulo with
(this / rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numberdiv(LuaValue)
public LuaValue div(int rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
For metatag processing div(LuaValue)
must be used
rhs
- The right-hand-side value to perform the divulo with
(this / rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numberdiv(LuaValue)
public LuaValue divInto(double lhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
lhs
- The left-hand-side value which will be divided by this
(lhs / this)
if this is numeric
LuaError
- if this
is not a number or string convertible to numberdiv(LuaValue)
,
div(double)
,
div(int)
public LuaValue mod(LuaValue rhs)
Each operand must derive from LuaNumber
or derive from LuaString
and be convertible to a number
rhs
- The right-hand-side value to perform the modulo with
(this % rhs)
if both are numeric,
or LuaValue
if metatag processing occurs
LuaError
- if either operand is not a number or string convertible to number,
and neither has the MOD
metatag definedarithmt(LuaValue, LuaValue)
public LuaValue mod(double rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
For metatag processing mod(LuaValue)
must be used
rhs
- The right-hand-side value to perform the modulo with
(this % rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numbermod(LuaValue)
public LuaValue mod(int rhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
For metatag processing mod(LuaValue)
must be used
rhs
- The right-hand-side value to perform the modulo with
(this % rhs)
if this is numeric
LuaError
- if this
is not a number or string convertible to numbermod(LuaValue)
public LuaValue modFrom(double lhs)
this
must derive from LuaNumber
or derive from LuaString
and be convertible to a number
lhs
- The left-hand-side value which will be modulo'ed by this
(lhs % this)
if this is numeric
LuaError
- if this
is not a number or string convertible to numbermod(LuaValue)
,
mod(double)
,
mod(int)
protected LuaValue arithmt(LuaValue tag, LuaValue op2)
Finds the supplied metatag value for this
or op2
and invokes it,
or throws LuaError
if neither is defined.
tag
- The metatag to look upop2
- The other operand value to perform the operation with
LuaValue
resulting from metatag processing
LuaError
- if metatag was not defined for either operandadd(LuaValue)
,
sub(LuaValue)
,
mul(LuaValue)
,
pow(LuaValue)
,
div(LuaValue)
,
mod(LuaValue)
,
ADD
,
SUB
,
MUL
,
POW
,
DIV
,
MOD
protected LuaValue arithmtwith(LuaValue tag, double op1)
Finds the supplied metatag value for this
and invokes it,
or throws LuaError
if neither is defined.
tag
- The metatag to look upop1
- The value of the left-hand-side to perform the operation with
LuaValue
resulting from metatag processing
LuaError
- if metatag was not defined for either operandadd(LuaValue)
,
sub(LuaValue)
,
mul(LuaValue)
,
pow(LuaValue)
,
div(LuaValue)
,
mod(LuaValue)
,
ADD
,
SUB
,
MUL
,
POW
,
DIV
,
MOD
public LuaValue lt(LuaValue rhs)
LuaValue
.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this < rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if either both operands are not a strings or both are not numbers
and no LT
metatag is defined.gteq_b(LuaValue)
,
comparemt(LuaValue, LuaValue)
public LuaValue lt(double rhs)
LuaValue
.
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this < rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if this is not a number
and no LT
metatag is defined.gteq_b(double)
,
comparemt(LuaValue, LuaValue)
public LuaValue lt(int rhs)
LuaValue
.
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this < rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if this is not a number
and no LT
metatag is defined.gteq_b(int)
,
comparemt(LuaValue, LuaValue)
public boolean lt_b(LuaValue rhs)
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this < rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if either both operands are not a strings or both are not numbers
and no LT
metatag is defined.gteq(LuaValue)
,
comparemt(LuaValue, LuaValue)
public boolean lt_b(int rhs)
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this < rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if this is not a number
and no LT
metatag is defined.gteq(int)
,
comparemt(LuaValue, LuaValue)
public boolean lt_b(double rhs)
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this < rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if either both operands are not a strings or both are not numbers
and no LT
metatag is defined.gteq(LuaValue)
,
comparemt(LuaValue, LuaValue)
public LuaValue lteq(LuaValue rhs)
LuaValue
.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this <= rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if either both operands are not a strings or both are not numbers
and no LE
metatag is defined.gteq_b(LuaValue)
,
comparemt(LuaValue, LuaValue)
public LuaValue lteq(double rhs)
LuaValue
.
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this <= rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if this is not a number
and no LE
metatag is defined.gteq_b(double)
,
comparemt(LuaValue, LuaValue)
public LuaValue lteq(int rhs)
LuaValue
.
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this <= rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if this is not a number
and no LE
metatag is defined.gteq_b(int)
,
comparemt(LuaValue, LuaValue)
public boolean lteq_b(LuaValue rhs)
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this <= rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if either both operands are not a strings or both are not numbers
and no LE
metatag is defined.gteq(LuaValue)
,
comparemt(LuaValue, LuaValue)
public boolean lteq_b(int rhs)
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this <= rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if this is not a number
and no LE
metatag is defined.gteq(int)
,
comparemt(LuaValue, LuaValue)
public boolean lteq_b(double rhs)
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this <= rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if this is not a number
and no LE
metatag is defined.gteq(double)
,
comparemt(LuaValue, LuaValue)
public LuaValue gt(LuaValue rhs)
LuaValue
.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this > rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if either both operands are not a strings or both are not numbers
and no LE
metatag is defined.gteq_b(LuaValue)
,
comparemt(LuaValue, LuaValue)
public LuaValue gt(double rhs)
LuaValue
.
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this > rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if this is not a number
and no LE
metatag is defined.gteq_b(double)
,
comparemt(LuaValue, LuaValue)
public LuaValue gt(int rhs)
LuaValue
.
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this > rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if this is not a number
and no LE
metatag is defined.gteq_b(int)
,
comparemt(LuaValue, LuaValue)
public boolean gt_b(LuaValue rhs)
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this > rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if either both operands are not a strings or both are not numbers
and no LE
metatag is defined.gteq(LuaValue)
,
comparemt(LuaValue, LuaValue)
public boolean gt_b(int rhs)
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this > rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if this is not a number
and no LE
metatag is defined.gteq(int)
,
comparemt(LuaValue, LuaValue)
public boolean gt_b(double rhs)
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this > rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if either both operands are not a strings or both are not numbers
and no LE
metatag is defined.gteq(LuaValue)
,
comparemt(LuaValue, LuaValue)
public LuaValue gteq(LuaValue rhs)
LuaValue
.
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this >= rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if either both operands are not a strings or both are not numbers
and no LT
metatag is defined.gteq_b(LuaValue)
,
comparemt(LuaValue, LuaValue)
public LuaValue gteq(double rhs)
LuaValue
.
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this >= rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if this is not a number
and no LT
metatag is defined.gteq_b(double)
,
comparemt(LuaValue, LuaValue)
public LuaValue gteq(int rhs)
LuaValue
.
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
TRUE
if (this >= rhs)
, FALSE
if not,
or LuaValue
if metatag processing occurs
LuaError
- if this is not a number
and no LT
metatag is defined.gteq_b(int)
,
comparemt(LuaValue, LuaValue)
public boolean gteq_b(LuaValue rhs)
To be comparable, both operands must derive from LuaString
or both must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this >= rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if either both operands are not a strings or both are not numbers
and no LT
metatag is defined.gteq(LuaValue)
,
comparemt(LuaValue, LuaValue)
public boolean gteq_b(int rhs)
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this >= rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if this is not a number
and no LT
metatag is defined.gteq(int)
,
comparemt(LuaValue, LuaValue)
public boolean gteq_b(double rhs)
To be comparable, this must derive from LuaNumber
.
rhs
- The right-hand-side value to perform the comparison with
(this >= rhs)
, false if not,
and boolean interpreation of result if metatag processing occurs.
LuaError
- if this is not a number
and no LT
metatag is defined.gteq(double)
,
comparemt(LuaValue, LuaValue)
public LuaValue comparemt(LuaValue tag, LuaValue op1)
Finds the supplied metatag value and invokes it,
or throws LuaError
if none applies.
tag
- The metatag to look uprhs
- The right-hand-side value to perform the operation with
LuaValue
resulting from metatag processing
LuaError
- if metatag was not defined for either operand,
or if the operands are not the same type,
or the metatag values for the two operands are different.gt(LuaValue)
,
gteq(LuaValue)
,
lt(LuaValue)
,
lteq(LuaValue)
public int strcmp(LuaValue rhs)
Only strings can be compared, meaning
each operand must derive from LuaString
.
rhs
- The right-hand-side value to perform the comparison with
LuaError
- if either operand is not a stringpublic int strcmp(LuaString rhs)
LuaString
using string comparison based on byte values.
Only strings can be compared, meaning
each operand must derive from LuaString
.
rhs
- The right-hand-side value to perform the comparison with
LuaError
- if this is not a stringpublic LuaValue concat(LuaValue rhs)
Only strings and numbers as represented can be concatenated, meaning
each operand must derive from LuaString
or LuaNumber
.
rhs
- The right-hand-side value to perform the operation with
LuaError
- if either operand is not of an appropriate type,
such as nil or a tablepublic LuaValue concatTo(LuaValue lhs)
Only strings and numbers as represented can be concatenated, meaning
each operand must derive from LuaString
or LuaNumber
.
lhs
- The left-hand-side value onto which this will be concatenated
LuaError
- if either operand is not of an appropriate type,
such as nil or a tableconcat(LuaValue)
public LuaValue concatTo(LuaNumber lhs)
LuaNumber
and return the result using rules of lua string concatenation including
metatag processing.
Only strings and numbers as represented can be concatenated, meaning
each operand must derive from LuaString
or LuaNumber
.
lhs
- The left-hand-side value onto which this will be concatenated
LuaError
- if either operand is not of an appropriate type,
such as nil or a tableconcat(LuaValue)
public LuaValue concatTo(LuaString lhs)
LuaString
and return the result using rules of lua string concatenation including
metatag processing.
Only strings and numbers as represented can be concatenated, meaning
each operand must derive from LuaString
or LuaNumber
.
lhs
- The left-hand-side value onto which this will be concatenated
LuaError
- if either operand is not of an appropriate type,
such as nil or a tableconcat(LuaValue)
public Buffer buffer()
Buffer
for more efficient concatenation of
multiple strings.
public Buffer concat(Buffer rhs)
Buffer
onto this value and return the result
using rules of lua string concatenation including metatag processing.
Only strings and numbers as represented can be concatenated, meaning
each operand must derive from LuaString
or LuaNumber
.
rhs
- The right-hand-side Buffer
to perform the operation with
(this .. rhs)
LuaError
- if either operand is not of an appropriate type,
such as nil or a tablepublic LuaValue concatmt(LuaValue rhs)
Finds the CONCAT
metatag value and invokes it,
or throws LuaError
if it doesn't exist.
rhs
- The right-hand-side value to perform the operation with
LuaValue
resulting from metatag processing for CONCAT
metatag.
LuaError
- if metatag was not defined for either operandpublic LuaValue and(LuaValue rhs)
and
with another operand, based on lua rules for boolean evaluation.
This returns either this
or rhs
depending on the boolean value for this
.
rhs
- The right-hand-side value to perform the operation with
this
if this.toboolean()
is false, rhs
otherwise.public LuaValue or(LuaValue rhs)
or
with another operand, based on lua rules for boolean evaluation.
This returns either this
or rhs
depending on the boolean value for this
.
rhs
- The right-hand-side value to perform the operation with
this
if this.toboolean()
is true, rhs
otherwise.public boolean testfor_b(LuaValue limit, LuaValue step)
Used in lua-bytecode to Java-bytecode conversion.
limit
- the numerical limit to complete the for loopstep
- the numberical step size to use.
public LuaString strvalue()
LuaString
or LuaNumber
,
or throw a LuaError
if it is not
LuaString
corresponding to the value if a string or number
LuaError
- if not a string or numberpublic LuaValue strongkey()
NIL
if it was weak and is no longer referenced.
LuaValue
key, or NIL
if it was weak and is no longer referenced.WeakTable
public LuaValue strongvalue()
NIL
if it was weak and is no longer referenced.
LuaValue
referred to, or NIL
if it was weak and is no longer referenced.WeakTable
public boolean isweaknil()
WeakTable
public static LuaBoolean valueOf(boolean b)
LuaValue
.
b
- boolean value to convert
TRUE
if not or FALSE
if falsepublic static LuaInteger valueOf(int i)
LuaValue
.
i
- int value to convert
LuaInteger
instance, possibly pooled, whose value is ipublic static LuaNumber valueOf(double d)
LuaValue
.
This may return a LuaInteger
or LuaDouble
depending
on the value supplied.
d
- double value to convert
LuaNumber
instance, possibly pooled, whose value is dpublic static LuaString valueOf(java.lang.String s)
LuaValue
.
s
- String value to convert
LuaString
instance, possibly pooled, whose value is spublic static LuaString valueOf(byte[] bytes)
LuaValue
.
bytes
- byte array to convert
LuaString
instance, possibly pooled, whose bytes are those in the supplied arraypublic static LuaString valueOf(byte[] bytes, int off, int len)
LuaValue
.
bytes
- byte array to convertoff
- offset into the byte array, starting at 0len
- number of bytes to include in the LuaString
LuaString
instance, possibly pooled, whose bytes are those in the supplied arraypublic static LuaTable tableOf()
LuaTable
.
LuaTable
instance with no values and no metatable.public static LuaTable tableOf(Varargs varargs, int firstarg)
LuaTable
initialized with supplied array values.
varargs
- Varargs
containing the values to use in initializationfirstarg
- the index of the first argument to use from the varargs, 1 being the first.
LuaTable
instance with sequential elements coming from the varargs.public static LuaTable tableOf(int narray, int nhash)
LuaTable
preallocated to hold array and hashed elements
narray
- Number of array elements to preallocatenhash
- Number of hash elements to preallocate
LuaTable
instance with no values and no metatable, but preallocated for array and hashed elements.public static LuaTable listOf(LuaValue[] unnamedValues)
LuaTable
initialized with supplied array values.
unnamedValues
- array of LuaValue
containing the values to use in initialization
LuaTable
instance with sequential elements coming from the array.public static LuaTable listOf(LuaValue[] unnamedValues, Varargs lastarg)
LuaTable
initialized with supplied array values.
unnamedValues
- array of LuaValue
containing the first values to use in initializationlastarg
- Varargs
containing additional values to use in initialization
to be put after the last unnamedValues element
LuaTable
instance with sequential elements coming from the array and varargs.public static LuaTable tableOf(LuaValue[] namedValues)
LuaTable
initialized with supplied named values.
namedValues
- array of LuaValue
containing the keys and values to use in initialization
in order {key-a, value-a, key-b, value-b, ...}
LuaTable
instance with non-sequential keys coming from the supplied array.public static LuaTable tableOf(LuaValue[] namedValues, LuaValue[] unnamedValues)
LuaTable
initialized with supplied named values and sequential elements.
The named values will be assigned first, and the sequential elements will be assigned later,
possibly overwriting named values at the same slot if there are conflicts.
namedValues
- array of LuaValue
containing the keys and values to use in initialization
in order {key-a, value-a, key-b, value-b, ...}
unnamedValues
- array of LuaValue
containing the sequenctial elements to use in initialization
in order {value-1, value-2, ...}
, or null if there are none
LuaTable
instance with named and sequential values supplied.public static LuaTable tableOf(LuaValue[] namedValues, LuaValue[] unnamedValues, Varargs lastarg)
LuaTable
initialized with supplied named values and sequential elements in an array part and as varargs.
The named values will be assigned first, and the sequential elements will be assigned later,
possibly overwriting named values at the same slot if there are conflicts.
namedValues
- array of LuaValue
containing the keys and values to use in initialization
in order {key-a, value-a, key-b, value-b, ...}
unnamedValues
- array of LuaValue
containing the first sequenctial elements to use in initialization
in order {value-1, value-2, ...}
, or null if there are nonelastarg
- Varargs
containing additional values to use in the sequential part of the initialization,
to be put after the last unnamedValues element
LuaTable
instance with named and sequential values supplied.public static LuaUserdata userdataOf(java.lang.Object o)
o
- The java instance to be wrapped as userdata
LuaUserdata
value wrapping the java instance.public static LuaUserdata userdataOf(java.lang.Object o, LuaValue metatable)
o
- The java instance to be wrapped as userdatametatable
- The metatble to associate with the userdata instance.
LuaUserdata
value wrapping the java instance.protected static LuaValue gettable(LuaValue t, LuaValue key)
protected static boolean settable(LuaValue t, LuaValue key, LuaValue value)
t
- LuaValue
on which value is being set, typically a table or something with the metatag NEWINDEX
definedkey
- LuaValue
naming the field to assignvalue
- LuaValue
the new value to assign to key
LuaError
- if there is a loop in metatag processingpublic LuaValue metatag(LuaValue tag)
NIL
if it doesn't exist
tag
- Metatag name to look up, typically a string such as
INDEX
or NEWINDEX
reason
- Description of error when tag lookup fails.
LuaValue
for tag reason
, or NIL
protected LuaValue checkmetatag(LuaValue tag, java.lang.String reason)
LuaError
if it doesn't exist
tag
- Metatag name to look up, typically a string such as
INDEX
or NEWINDEX
reason
- Description of error when tag lookup fails.
LuaValue
that can be called
LuaError
- when the lookup fails.public static Varargs varargsOf(LuaValue[] v)
Varargs
around an array of LuaValue
s.
v
- The array of LuaValue
smore
- Varargs
contain values to include at the end
Varargs
wrapping the supplied values.varargsOf(LuaValue, Varargs)
,
varargsOf(LuaValue[], int, int)
public static Varargs varargsOf(LuaValue[] v, Varargs r)
Varargs
around an array of LuaValue
s.
v
- The array of LuaValue
smore
- Varargs
contain values to include at the end
Varargs
wrapping the supplied values.varargsOf(LuaValue[])
,
varargsOf(LuaValue[], int, int, Varargs)
public static Varargs varargsOf(LuaValue[] v, int offset, int length)
Varargs
around an array of LuaValue
s.
v
- The array of LuaValue
soffset
- number of initial values to skip in the arraylength
- number of values to include from the array
Varargs
wrapping the supplied values.varargsOf(LuaValue[])
,
varargsOf(LuaValue[], int, int, Varargs)
public static Varargs varargsOf(LuaValue[] v, int offset, int length, Varargs more)
Varargs
around an array of LuaValue
s.
v
- The array of LuaValue
soffset
- number of initial values to skip in the arraylength
- number of values to include from the arraymore
- Varargs
contain values to include at the end
Varargs
wrapping the supplied values.varargsOf(LuaValue[], Varargs)
,
varargsOf(LuaValue[], int, int)
public static Varargs varargsOf(LuaValue v, Varargs r)
Varargs
around a set of 2 or more LuaValue
s.
This can be used to wrap exactly 2 values, or a list consisting of 1 initial value followed by another variable list of remaining values.
v1
- First LuaValue
in the Varargs
v2
- LuaValue
supplying the 2rd value,
or Varargs
s supplying all values beyond the first
Varargs
wrapping the supplied values.public static Varargs varargsOf(LuaValue v1, LuaValue v2, Varargs v3)
Varargs
around a set of 3 or more LuaValue
s.
This can be used to wrap exactly 3 values, or a list consisting of 2 initial values followed by another variable list of remaining values.
v1
- First LuaValue
in the Varargs
v2
- Second LuaValue
in the Varargs
v3
- LuaValue
supplying the 3rd value,
or Varargs
s supplying all values beyond the second
Varargs
wrapping the supplied values.public static Varargs tailcallOf(LuaValue func, Varargs args)
TailcallVarargs
around a function and arguments.
The tail call is not yet called or processing until the client invokes
TailcallVarargs.eval()
which performs the tail call processing.
This method is typically not used directly by client code. Instead use one of the function invocation methods.
func
- LuaValue
to be called as a tail callargs
- Varargs
containing the arguments to the call
TailcallVarargs
to be used in tailcall oprocessing.call()
,
invoke()
,
method(LuaValue)
,
invokemethod(LuaValue)
public Varargs onInvoke(Varargs args)
This may return a TailcallVarargs
to be evaluated by the client.
This should not be called directly, instead use on of the call invocation functions.
args
- the arguments to the call invocation.
call()
,
invoke()
,
method(LuaValue)
,
invokemethod(LuaValue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |