Class LuaValue
- Direct Known Subclasses:
LuaBoolean
,LuaFunction
,LuaNil
,LuaNumber
,LuaString
,LuaTable
,LuaUserdata
,WeakTable.WeakValue
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static final class
Varargs implemenation with no values.Nested classes/interfaces inherited from class com.prineside.luaj.Varargs
Varargs.ArrayVarargs
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LuaString
LuaString constant with value "__add" for use as metatagstatic final LuaString
LuaString constant with value "__call" for use as metatagstatic final LuaString
LuaString constant with value "__concat" for use as metatagstatic final LuaString
LuaString constant with value "__div" for use as metatagstatic final LuaString
LuaString constant with value ""static LuaString
The variable name of the environment.static final LuaString
LuaString constant with value "__eq" for use as metatagstatic final LuaBoolean
LuaBoolean constant corresponding to luafalse
static final LuaString
LuaString constant with value "__index" for use as metatagstatic final LuaString
LuaString constant with value "__ipairs" for use as metatagstatic final LuaString
LuaString constant with value "__le" for use as metatagstatic final LuaString
LuaString constant with value "__len" for use as metatagstatic final LuaString
LuaString constant with value "__lt" for use as metatagstatic final LuaString
LuaString constant with value "__metatable" for use as metatagstatic final LuaNumber
LuaValue number constant equal to -1static final LuaString
LuaString constant with value "__mod" for use as metatagstatic final LuaString
LuaString constant with value "__mode" for use as metatagstatic final LuaString
LuaString constant with value "__mul" for use as metatagstatic final LuaString
LuaString constant with value "__newindex" for use as metatagstatic final LuaValue
LuaValue constant corresponding to lua#NIL
static final LuaValue.NillableSerializer
static final LuaValue[]
Array ofNIL
values to optimize filling stacks using System.arraycopy().static final LuaValue
LuaValue constant corresponding to aVarargs
list of no valuesstatic final LuaValue[]
LuaValue array constant with no valuesstatic final LuaNumber
LuaValue number constant equal to 1static final LuaString
LuaString constant with value "__ipairs" for use as metatagstatic final LuaString
LuaString constant with value "__pow" for use as metatagstatic final LuaString
LuaString constant with value "__sub" for use as metatagstatic final int
Type enumeration constant for lua booleansstatic final int
Type enumeration constant for lua functionsstatic final int
Type enumeration constant for lua numbers that are ints, for compatibility with lua 5.1 number patch onlystatic final int
Type enumeration constant for lua light userdata, for compatibility with C-based lua onlystatic final int
Type enumeration constant for lua nilstatic final int
Type enumeration constant for lua values that have no type, for example weak table entriesstatic final int
Type enumeration constant for lua numbersstatic final LuaString
LuaString constant with value "__tostring" for use as metatagstatic final LuaBoolean
LuaBoolean constant corresponding to luatrue
static final int
Type enumeration constant for lua stringsstatic final int
Type enumeration constant for lua tablesstatic final int
Type enumeration constant for lua threadsstatic final int
Type enumeration constant for lua userdatasstatic final int
Type enumeration constant for unknown values, for compatibility with C-based lua onlystatic final String[]
String array constant containing names of each of the lua value typesstatic final LuaString
LuaString constant with value "__unm" for use as metatagstatic final LuaNumber
LuaValue number constant equal to 0 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(double rhs) Add: Perform numeric add operation with another value of double type with metatag processingadd
(int rhs) Add: Perform numeric add operation with another value of int type with metatag processingAdd: Perform numeric add operation with another value including metatag processing.Perform booleanand
with another operand, based on lua rules for boolean evaluation.arg
(int index) Get the n-th argument value (1-based).arg1()
Get the first argument in the list.static LuaValue
Throw aLuaError
indicating an invalid argument was supplied to a functionstatic void
Assert a condition is true, or throw aLuaError
if not Returns no value when b is true, throwserror(String)
withmsg
as argument and does not return if b is false.buffer()
Convert the value to aBuffer
for more efficient concatenation of multiple strings.call()
Callthis
with 0 arguments, including metatag processing, and return only the first return value.Callthis
with 1 argument, including metatag processing, and return only the first return value.Callthis
with 2 arguments, including metatag processing, and return only the first return value.Callthis
with 3 arguments, including metatag processing, and return only the first return value.Convenience function which calls a luavalue with a single, string argument.static LuaBoolean
cBool
(boolean val) static LuaNumber
cDouble
(double val) static LuaNumber
cFloat
(float val) boolean
Check that the value is aLuaBoolean
, or throwLuaError
if notCheck that the value is aLuaClosure
, or throwLuaError
if notdouble
Check that the value is numeric and return the value as a double, or throwLuaError
if not numericCheck that the value is a function , or throwLuaError
if notCheck that the value is a Globals instance, or throwLuaError
if notint
checkint()
Check that the value is numeric, and convert and cast value to int, or throwLuaError
if not numericConvert this value to a Java String.long
Check that the value is numeric, and convert and cast value to long, or throwLuaError
if not numericCheck that the value is numeric, and return as a LuaNumber if so, or throwLuaError
checknumber
(String msg) Check that the value is numeric, and return as a LuaNumber if so, or throwLuaError
Check that this is a lua string, or throwLuaError
if it is not.Check that this is aLuaUserdata
, or throwLuaError
if it is notCheck that this is aLuaUserdata
, or throwLuaError
if it is notstatic LuaNumber
cInt
(int val) static LuaNumber
cNcDouble
(double val) static LuaNumber
cNcFloat
(float val) static LuaNumber
cNcInt
(int val) static LuaValue
Perform metatag processing for comparison operations.Concatenate aBuffer
onto this value and return the result using rules of lua string concatenation including metatag processing.Concatenate another value onto this value and return the result using rules of lua string concatenation including metatag processing.Perform metatag processing for concatenation operations.Reverse-concatenation: concatenate this value onto another value known to be aLuaNumber
and return the result using rules of lua string concatenation including metatag processing.Reverse-concatenation: concatenate this value onto another value known to be aLuaString
and return the result using rules of lua string concatenation including metatag processing.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.static LuaValue
cRegObject
(Object val) For regular objects only.div
(double rhs) Divide: Perform numeric divide operation by another value of double type without metatag processingdiv
(int rhs) Divide: Perform numeric divide operation by another value of int type without metatag processingDivide: Perform numeric divide operation by another value of unknown type, including metatag processing.divInto
(double lhs) Reverse-divide: Perform numeric divide operation into another value with metatag processingEquals: Perform equality comparison with another value including metatag processing usingEQ
.boolean
Equals: Perform equality comparison with another value including metatag processing usingEQ
, and return java booleanstatic boolean
Perform equality testing metatag processingboolean
static LuaValue
Throw aLuaError
with a particular messageget
(int key) Get a value in a table including metatag processing usingINDEX
.Get a value in a table including metatag processing usingINDEX
.Get a value in a table including metatag processing usingINDEX
.Get the metatable for thisLuaValue
gt
(double rhs) Greater than: Perform numeric comparison with another value of double type, including metatag processing, and returningLuaValue
.gt
(int rhs) Greater than: Perform numeric comparison with another value of int type, including metatag processing, and returningLuaValue
.Greater than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returningLuaValue
.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
Greater than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.gteq
(double rhs) Greater than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returningLuaValue
.gteq
(int rhs) Greater than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returningLuaValue
.Greater than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returningLuaValue
.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
Greater than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.void
initupvalue1
(LuaValue env) Hook for implementations such as LuaJC to load the environment of the main chunk into the first upvalue location.invoke()
Callthis
with 0 arguments, including metatag processing, and retain all return values in aVarargs
.Callthis
with variable arguments, including metatag processing, and retain all return values in aVarargs
.Callthis
with variable arguments, including metatag processing, and retain all return values in aVarargs
.Should not return args (must be new varargs)invokemethod
(LuaValue name) Call named method onthis
with 0 arguments, including metatag processing, and retain all return values in aVarargs
.invokemethod
(LuaValue name, Varargs args) Call named method onthis
with variable arguments, including metatag processing, and retain all return values in aVarargs
.invokemethod
(String name) Call named method onthis
with 0 arguments, including metatag processing, and retain all return values in aVarargs
.invokemethod
(String name, Varargs args) Call named method onthis
with 1 argument, including metatag processing, and retain all return values in aVarargs
.boolean
Check ifthis
is aboolean
boolean
Check ifthis
is afunction
that is a closure, meaning interprets lua bytecode for its executionboolean
Check ifthis
is afunction
boolean
isint()
Check ifthis
is anumber
and is representable by java int without rounding or truncationboolean
Check ifthis
is an intboolean
islong()
Check ifthis
is anumber
and is representable by java long without rounding or truncationboolean
isnil()
Check ifthis
is#NIL
boolean
isnumber()
Check ifthis
is anumber
static boolean
isRegObject
(Class<?> clazz) boolean
isstring()
Check ifthis
is astring
boolean
istable()
Check ifthis
is atable
boolean
Check ifthis
is auserdata
boolean
isuserdata
(Class c) Check ifthis
is auserdata
of typec
boolean
Return true if this is a valid key in a table index operation.len()
Length operator: return lua length of object(#this)
including metatag processing as java intint
length()
Length operator: return lua length of object(#this)
including metatag processing as java intstatic LuaTable
Construct aLuaTable
initialized with supplied array values.static LuaTable
Construct aLuaTable
initialized with supplied array values.Load a library instance by calling it with and empty string as the modname, and this Globals as the environment.lt
(double rhs) Less than: Perform numeric comparison with another value of double type, including metatag processing, and returningLuaValue
.lt
(int rhs) Less than: Perform numeric comparison with another value of int type, including metatag processing, and returningLuaValue
.Less than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returningLuaValue
.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
Less than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.lteq
(double rhs) Less than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returningLuaValue
.lteq
(int rhs) Less than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returningLuaValue
.Less than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returningLuaValue
.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
Less than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.Get particular metatag, or returnNIL
if it doesn't existCall named method onthis
with 0 arguments, including metatag processing, and return only the first return value.Call named method onthis
with 1 argument, including metatag processing, and return only the first return value.Call named method onthis
with 2 arguments, including metatag processing, and return only the first return value.Call named method onthis
with 0 arguments, including metatag processing, and return only the first return value.Call named method onthis
with 1 argument, including metatag processing, and return only the first return value.Call named method onthis
with 2 arguments, including metatag processing, and return only the first return value.mod
(double rhs) Modulo: Perform numeric modulo operation with another value of double type without metatag processingmod
(int rhs) Modulo: Perform numeric modulo operation with another value of int type without metatag processingModulo: Perform numeric modulo operation with another value of unknown type, including metatag processing.modFrom
(double lhs) Reverse-modulo: Perform numeric modulo operation from another value with metatag processingmul
(double rhs) Multiply: Perform numeric multiply operation with another value of double type with metatag processingmul
(int rhs) Multiply: Perform numeric multiply operation with another value of int type with metatag processingMultiply: 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.neg()
Unary minus: return negative value(-this)
as defined by lua unary minus operatorNotquals: Perform inequality comparison with another value including metatag processing usingEQ
.boolean
Notquals: Perform inequality comparison with another value including metatag processing usingEQ
.not()
Unary not: return inverse boolean value(~this)
as defined by lua not operatorCallback 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 valueoptclosure
(LuaClosure defval) Check that optional argument is a closure and return asLuaClosure
double
optdouble
(double defval) Check that optional argument is a number or string convertible to number and return as doubleoptfunction
(LuaFunction defval) Check that optional argument is a function and return asLuaFunction
int
optint
(int defval) Check that optional argument is a number or string convertible to number and return as intoptjstring
(String defval) Check that optional argument is a string or number and return as Java Stringlong
optlong
(long defval) Check that optional argument is a number or string convertible to number and return as longCheck that optional argument is a number or string convertible to number and return asLuaNumber
Check that optional argument is a string or number and return asLuaString
Check that optional argument is a table and return asLuaTable
optuserdata
(Class c, Object defval) Check that optional argument is a userdata whose instance is of a type and return the Object instanceoptuserdata
(Object defval) Check that optional argument is a userdata and return the Object instancePerform argument check that this is not nil or none.Perform booleanor
with another operand, based on lua rules for boolean evaluation.pow
(double rhs) Raise to power: Raise this value to a power of double type with metatag processingpow
(int rhs) Raise to power: Raise this value to a power of int type with metatag processingRaise to power: Raise this value to a power including metatag processing.powWith
(double lhs) Reverse-raise to power: Raise another value of double type to this power with metatag processingpowWith
(int lhs) Reverse-raise to power: Raise another value of double type to this power with metatag processingvoid
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
Equals: Perform direct equality comparison with aLuaString
value without metatag processing.boolean
raweq
(LuaUserdata val) Equals: Perform direct equality comparison with aLuaUserdata
value without metatag processing.boolean
Equals: Perform direct equality comparison with another value without metatag processing.rawget
(int key) Get a value in a table without metatag processing.Get a value in a table without metatag processing.Get a value in a table without metatag processing.int
rawlen()
Get raw length of table or string without metatag processing.void
Set a value in a table without metatag processing.void
Set a value in a table without metatag processing.void
Set a value in a table without metatag processing.void
Set a value in a table without metatag processing.void
Set a value in a table without metatag processing.void
Set a value in a table without metatag processing.void
Set a value in a table without metatag processing.void
rawsetlist
(int key0, Varargs values) Set list values in a table without invoking metatag processingvoid
Set a value in a table without metatag processing usingNEWINDEX
.void
Set a value in a table without metatag processing usingNEWINDEX
.void
Set a value in a table without metatag processing usingNEWINDEX
.void
Set a value in a table without metatag processing usingNEWINDEX
.void
Set a value in a table without metatag processing usingNEWINDEX
.void
Set a value in a table without metatag processing usingNEWINDEX
.void
Set a value in a table without metatag processing usingNEWINDEX
.setmetatable
(LuaValue metatable) Set the metatable for thisLuaValue
int
Perform string comparison with another value known to be aLuaString
using string comparison based on byte values.int
Perform string comparison with another value of any type using string comparison based on byte values.Return this value as a strong reference, or null if it was weak and is no longer referenced.strvalue()
sub
(double rhs) Subtract: Perform numeric subtract operation with another value of double type with metatag processingsub
(int rhs) Subtract: Perform numeric subtract operation with another value of int type with metatag processingSubtract: Perform numeric subtract operation with another value of unknown type, including metatag processing.subargs
(int start) Create aVarargs
instance containing arguments starting at indexstart
subFrom
(double lhs) Reverse-subtract: Perform numeric subtract operation from an int value with metatag processingsubFrom
(int lhs) Reverse-subtract: Perform numeric subtract operation from a double value without metatag processingstatic LuaTable
tableOf()
Construct an emptyLuaTable
.static LuaTable
tableOf
(int narray, int nhash) Construct an emptyLuaTable
preallocated to hold array and hashed elementsstatic LuaTable
Construct aLuaTable
initialized with supplied named values.static LuaTable
Construct aLuaTable
initialized with supplied named values and sequential elements.static LuaTable
Construct aLuaTable
initialized with supplied named values and sequential elements in an array part and as varargs.static LuaTable
Construct aLuaTable
initialized with supplied array values.static Varargs
tailcallOf
(LuaValue func, Varargs args) Construct aTailcallVarargs
around a function and arguments.boolean
Perform end-condition test in for-loop processing.boolean
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.Convert to human readable String for any type.long
tolong()
Convert to long if numeric, or 0 if not.tonumber()
Conditionally convert to lua number without throwing errors.short
toshort()
Convert to short if numeric, or 0 if not.tostring()
Conditionally convert to lua string without throwing errors.toString()
Convert the value to a human readable string usingtojstring()
Convert to userdata instance, or null.<T> T
touserdata
(Class<T> c) Convert to userdata instance if specific type, or null.abstract int
type()
Get the enumeration value for the type of this value.abstract String
typename()
Get the String name of the type of this value.static LuaUserdata
userdataOf
(Object o) Construct a LuaUserdata for an object.static LuaUserdata
userdataOf
(Object o, LuaValue metatable) Construct a LuaUserdata for an object with a user supplied metatable.static LuaBoolean
valueOf
(boolean b) Convert java boolean to aLuaValue
.static LuaString
valueOf
(byte[] bytes) Convert bytes in an array to aLuaValue
.static LuaString
valueOf
(byte[] bytes, int off, int len) Convert bytes in an array to aLuaValue
.static LuaNumber
valueOf
(double d) Convert java double to aLuaValue
.static LuaNumber
valueOf
(int i) Convert java int to aLuaValue
.static LuaString
Convert java string to aLuaValue
.static Varargs
static Varargs
static Varargs
static Varargs
static Varargs
static Varargs
Methods inherited from class com.prineside.luaj.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkuserdata, checkuserdata, checkvalue, dealias, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optjstring, optlong, optnumber, optstring, opttable, optuserdata, optuserdata, optvalue, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type
-
Field Details
-
NILLABLE_SERIALIZER
-
TINT
public static final int TINTType enumeration constant for lua numbers that are ints, for compatibility with lua 5.1 number patch only- See Also:
-
TNONE
public static final int TNONEType enumeration constant for lua values that have no type, for example weak table entries- See Also:
-
TNIL
public static final int TNILType enumeration constant for lua nil- See Also:
-
TBOOLEAN
public static final int TBOOLEANType enumeration constant for lua booleans- See Also:
-
TLIGHTUSERDATA
public static final int TLIGHTUSERDATAType enumeration constant for lua light userdata, for compatibility with C-based lua only- See Also:
-
TNUMBER
public static final int TNUMBERType enumeration constant for lua numbers- See Also:
-
TSTRING
public static final int TSTRINGType enumeration constant for lua strings- See Also:
-
TTABLE
public static final int TTABLEType enumeration constant for lua tables- See Also:
-
TFUNCTION
public static final int TFUNCTIONType enumeration constant for lua functions- See Also:
-
TUSERDATA
public static final int TUSERDATAType enumeration constant for lua userdatas- See Also:
-
TTHREAD
public static final int TTHREADType enumeration constant for lua threads- See Also:
-
TVALUE
public static final int TVALUEType enumeration constant for unknown values, for compatibility with C-based lua only- See Also:
-
TYPE_NAMES
String array constant containing names of each of the lua value types- See Also:
-
NIL
LuaValue constant corresponding to lua#NIL
-
TRUE
LuaBoolean constant corresponding to luatrue
-
FALSE
LuaBoolean constant corresponding to luafalse
-
NONE
LuaValue constant corresponding to aVarargs
list of no values -
ZERO
LuaValue number constant equal to 0 -
ONE
LuaValue number constant equal to 1 -
MINUSONE
LuaValue number constant equal to -1 -
NOVALS
LuaValue array constant with no values -
ENV
The variable name of the environment. -
INDEX
LuaString constant with value "__index" for use as metatag -
NEWINDEX
LuaString constant with value "__newindex" for use as metatag -
CALL
LuaString constant with value "__call" for use as metatag -
MODE
LuaString constant with value "__mode" for use as metatag -
METATABLE
LuaString constant with value "__metatable" for use as metatag -
ADD
LuaString constant with value "__add" for use as metatag -
SUB
LuaString constant with value "__sub" for use as metatag -
DIV
LuaString constant with value "__div" for use as metatag -
MUL
LuaString constant with value "__mul" for use as metatag -
POW
LuaString constant with value "__pow" for use as metatag -
MOD
LuaString constant with value "__mod" for use as metatag -
UNM
LuaString constant with value "__unm" for use as metatag -
LEN
LuaString constant with value "__len" for use as metatag -
EQ
LuaString constant with value "__eq" for use as metatag -
LT
LuaString constant with value "__lt" for use as metatag -
LE
LuaString constant with value "__le" for use as metatag -
TOSTRING
LuaString constant with value "__tostring" for use as metatag -
CONCAT
LuaString constant with value "__concat" for use as metatag -
EMPTYSTRING
LuaString constant with value "" -
IPAIRS
LuaString constant with value "__ipairs" for use as metatag -
PAIRS
LuaString constant with value "__ipairs" for use as metatag -
NILS
Array ofNIL
values to optimize filling stacks using System.arraycopy(). Must not be modified.
-
-
Constructor Details
-
LuaValue
public LuaValue()
-
-
Method Details
-
type
public abstract int type()Get the enumeration value for the type of this value. -
typename
Get the String name of the type of this value.- Returns:
- name from type name list
TYPE_NAMES
corresponding to the type of this value: "nil", "boolean", "number", "string", "table", "function", "userdata", "thread" - See Also:
-
isboolean
public boolean isboolean()Check ifthis
is aboolean
- Returns:
- true if this is a
boolean
, otherwise false - See Also:
-
isclosure
public boolean isclosure()Check ifthis
is afunction
that is a closure, meaning interprets lua bytecode for its execution- Returns:
- true if this is a
closure
, otherwise false - See Also:
-
isfunction
public boolean isfunction()Check ifthis
is afunction
- Returns:
- true if this is a
function
, otherwise false - See Also:
-
isint
public boolean isint()Check ifthis
is anumber
and is representable by java int without rounding or truncation -
isinttype
public boolean isinttype()Check ifthis
is an intNo attempt to convert from string will be made by this call.
- Returns:
- true if this is a
LuaInteger
, otherwise false - See Also:
-
islong
public boolean islong()Check ifthis
is anumber
and is representable by java long without rounding or truncation -
isnil
public boolean isnil()Check ifthis
is#NIL
- Returns:
- true if this is
#NIL
, otherwise false - See Also:
-
isnumber
public boolean isnumber()Check ifthis
is anumber
-
isstring
public boolean isstring()Check ifthis
is astring
-
istable
public boolean istable()Check ifthis
is atable
- Returns:
- true if this is a
table
, otherwise false - See Also:
-
isuserdata
public boolean isuserdata()Check ifthis
is auserdata
- Returns:
- true if this is a
userdata
, otherwise false - See Also:
-
isuserdata
Check ifthis
is auserdata
of typec
- Parameters:
c
- Class to test instance against- Returns:
- true if this is a
userdata
and the instance is assignable toc
, otherwise false - See Also:
-
toboolean
public boolean toboolean()- Returns:
- Value cast to byte if number or string convertible to number, otherwise 0
- See Also:
-
tobyte
public byte tobyte()Convert to byte if numeric, or 0 if not.- Returns:
- Value cast to byte if number or string convertible to number, otherwise 0
- See Also:
-
tochar
public char tochar()Convert to char if numeric, or 0 if not.- Returns:
- Value cast to char if number or string convertible to number, otherwise 0
- See Also:
-
todouble
public double todouble()Convert to double if numeric, or 0 if not.- Returns:
- Value cast to double if number or string convertible to number, otherwise 0
- See Also:
-
tofloat
public float tofloat()Convert to float if numeric, or 0 if not.- Returns:
- Value cast to float if number or string convertible to number, otherwise 0
- See Also:
-
toint
public int toint()Convert to int if numeric, or 0 if not.- Returns:
- Value cast to int if number or string convertible to number, otherwise 0
- See Also:
-
tolong
public long tolong()Convert to long if numeric, or 0 if not.- Returns:
- Value cast to long if number or string convertible to number, otherwise 0
- See Also:
-
toshort
public short toshort()Convert to short if numeric, or 0 if not.- Returns:
- Value cast to short if number or string convertible to number, otherwise 0
- See Also:
-
tojstring
Convert to human readable String for any type. -
touserdata
Convert to userdata instance, or null.- Returns:
- userdata instance if userdata, or null if not
LuaUserdata
- See Also:
-
touserdata
Convert to userdata instance if specific type, or null.- Returns:
- userdata instance if is a userdata whose instance derives from
c
, or null if notLuaUserdata
- See Also:
-
toString
Convert the value to a human readable string usingtojstring()
-
tonumber
Conditionally convert to lua number without throwing errors.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, andNIL
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.
-
tostring
Conditionally convert to lua string without throwing errors.In lua all numbers are strings, so this function will return the
LuaValue
this
if it is a string or number, andNIL
for all other cases.This allows values to be tested for their "string-ness" without the penalty of throwing exceptions.
-
optboolean
public boolean optboolean(boolean defval) Check that optional argument is a boolean and return its boolean value- Parameters:
defval
- boolean value to return ifthis
is nil or none- Returns:
this
cast to boolean if aLuaBoolean
,defval
if nil or none, throwsLuaError
otherwise- Throws:
LuaError
- if was not a boolean or nil or none.- See Also:
-
optclosure
Check that optional argument is a closure and return asLuaClosure
A
LuaClosure
is aLuaFunction
that executes lua byteccode.- Parameters:
defval
-LuaClosure
to return ifthis
is nil or none- Returns:
this
cast toLuaClosure
if a function,defval
if nil or none, throwsLuaError
otherwise- Throws:
LuaError
- if was not a closure or nil or none.- See Also:
-
optdouble
public double optdouble(double defval) Check that optional argument is a number or string convertible to number and return as double -
optfunction
Check that optional argument is a function and return asLuaFunction
A
LuaFunction
may either be a Java function that implements functionality directly in Java, or aLuaClosure
which is aLuaFunction
that executes lua bytecode.- Parameters:
defval
-LuaFunction
to return ifthis
is nil or none- Returns:
this
cast toLuaFunction
if a function,defval
if nil or none, throwsLuaError
otherwise- Throws:
LuaError
- if was not a function or nil or none.- See Also:
-
optint
public int optint(int defval) Check that optional argument is a number or string convertible to number and return as int -
optlong
public long optlong(long defval) Check that optional argument is a number or string convertible to number and return as long -
optnumber
Check that optional argument is a number or string convertible to number and return asLuaNumber
-
optjstring
Check that optional argument is a string or number and return as Java String -
optstring
Check that optional argument is a string or number and return asLuaString
-
opttable
Check that optional argument is a table and return asLuaTable
-
optuserdata
Check that optional argument is a userdata and return the Object instance- Parameters:
defval
- Object to return ifthis
is nil or none- Returns:
- Object instance of the userdata if a
LuaUserdata
,defval
if nil or none, throwsLuaError
if some other type - Throws:
LuaError
- if was not a userdata or nil or none.- See Also:
-
optuserdata
Check that optional argument is a userdata whose instance is of a type and return the Object instance- Parameters:
c
- Class to test userdata instance againstdefval
- Object to return ifthis
is nil or none- Returns:
- Object instance of the userdata if a
LuaUserdata
and instance is assignable toc
,defval
if nil or none, throwsLuaError
if some other type - Throws:
LuaError
- if was not a userdata whose instance is assignable toc
or nil or none.- See Also:
-
optvalue
Perform argument check that this is not nil or none. -
checkboolean
public boolean checkboolean()Check that the value is aLuaBoolean
, or throwLuaError
if not- Returns:
- boolean value for
this
if it is aLuaBoolean
- Throws:
LuaError
- if not aLuaBoolean
- See Also:
-
checkclosure
Check that the value is aLuaClosure
, or throwLuaError
if notLuaClosure
is a subclass ofLuaFunction
that interprets lua bytecode.- Returns:
this
cast asLuaClosure
- Throws:
LuaError
- if not aLuaClosure
- See Also:
-
checkdouble
public double checkdouble()Check that the value is numeric and return the value as a double, or throwLuaError
if not numericValues that are
LuaNumber
and values that areLuaString
that can be converted to a number will be converted to double. -
checkfunction
Check that the value is a function , or throwLuaError
if notA
LuaFunction
may either be a Java function that implements functionality directly in Java, or aLuaClosure
which is aLuaFunction
that executes lua bytecode.- Returns:
this
if it is a lua function or closure- Throws:
LuaError
- if not a function- See Also:
-
checkglobals
-
checkint
public int checkint()Check that the value is numeric, and convert and cast value to int, or throwLuaError
if not numericValues that are
LuaNumber
will be cast to int and may lose precision. Values that areLuaString
that can be converted to a number will be converted, then cast to int, so may also lose precision. -
checklong
public long checklong()Check that the value is numeric, and convert and cast value to long, or throwLuaError
if not numericValues that are
LuaNumber
will be cast to long and may lose precision. Values that areLuaString
that can be converted to a number will be converted, then cast to long, so may also lose precision. -
checknumber
Check that the value is numeric, and return as a LuaNumber if so, or throwLuaError
Values that are
LuaString
that can be converted to a number will be converted and returned. -
checknumber
Check that the value is numeric, and return as a LuaNumber if so, or throwLuaError
Values that are
LuaString
that can be converted to a number will be converted and returned. -
checkjstring
Convert this value to a Java String.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.
- Returns:
- String representation of the value
- See Also:
-
checkstring
Check that this is a lua string, or throwLuaError
if it is not.In lua all numbers are strings, so this will succeed for anything that derives from
LuaString
orLuaNumber
. Numbers will be converted toLuaString
. -
checktable
-
checkuserdata
Check that this is aLuaUserdata
, or throwLuaError
if it is not- Returns:
this
if it is aLuaUserdata
- Throws:
LuaError
- ifthis
is not aLuaUserdata
- See Also:
-
checkuserdata
Check that this is aLuaUserdata
, or throwLuaError
if it is not- Returns:
this
if it is aLuaUserdata
- Throws:
LuaError
- ifthis
is not aLuaUserdata
- See Also:
-
checknotnil
-
isvalidkey
public boolean isvalidkey()Return true if this is a valid key in a table index operation.- Returns:
- true if valid as a table key, otherwise false
- See Also:
-
error
Throw aLuaError
with a particular message- Parameters:
message
- String providing message details- Throws:
LuaError
- in all cases
-
assert_
Assert a condition is true, or throw aLuaError
if not Returns no value when b is true, throwserror(String)
withmsg
as argument and does not return if b is false.- Parameters:
b
- condition to testmsg
- String message to produce on failure- Throws:
LuaError
- if b is not true
-
argerror
Throw aLuaError
indicating an invalid argument was supplied to a function- Parameters:
iarg
- index of the argument that was invalid, first index is 1msg
- String providing information about the invalid argument- Throws:
LuaError
- in all cases
-
get
Get a value in a table including metatag processing usingINDEX
. -
get
Get a value in a table including metatag processing usingINDEX
. -
get
Get a value in a table including metatag processing usingINDEX
. -
set
Set a value in a table without metatag processing usingNEWINDEX
. -
set
Set a value in a table without metatag processing usingNEWINDEX
. -
set
Set a value in a table without metatag processing usingNEWINDEX
. -
set
Set a value in a table without metatag processing usingNEWINDEX
. -
set
Set a value in a table without metatag processing usingNEWINDEX
. -
set
Set a value in a table without metatag processing usingNEWINDEX
. -
set
Set a value in a table without metatag processing usingNEWINDEX
. -
rawget
Get a value in a table without metatag processing. -
rawget
Get a value in a table without metatag processing. -
rawget
Get a value in a table without metatag processing. -
rawset
Set a value in a table without metatag processing. -
rawset
Set a value in a table without metatag processing. -
rawset
Set a value in a table without metatag processing. -
rawset
Set a value in a table without metatag processing. -
rawset
Set a value in a table without metatag processing.- Parameters:
key
- the key to use, must not be nullvalue
- the value to use- Throws:
LuaError
- ifthis
is not a table
-
rawset
Set a value in a table without metatag processing.- Parameters:
key
- the key to use, must not be nullvalue
- the value to use- Throws:
LuaError
- ifthis
is not a table
-
rawset
Set a value in a table without metatag processing.- Parameters:
key
- the key to use, must not be nullvalue
- the value to use, must not be null- Throws:
LuaError
- ifthis
is not a table
-
rawsetlist
Set list values in a table without invoking metatag processingPrimarily used internally in response to a SETLIST bytecode.
- Parameters:
key0
- the first key to set in the tablevalues
- the list of values to set- Throws:
LuaError
- if this is not a table.
-
presize
public void presize(int i) Preallocate the array part of a table to be a certain size,Primarily used internally in response to a SETLIST bytecode.
- Parameters:
i
- the number of array slots to preallocate in the table.- Throws:
LuaError
- if this is not a table.
-
next
Find the next key,value pair ifthis
is a table, returnNIL
if there are no more, or throw aLuaError
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 ) }
-
inext
Find the next integer-key,value pair ifthis
is a table, returnNIL
if there are no more, or throw aLuaError
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 ) }
-
load
Load a library instance by calling it with and empty string as the modname, and this Globals as the environment. This is normally used to iniitalize the library instance and which may install itself into these globals. -
arg
Description copied from class:Varargs
Get the n-th argument value (1-based). -
narg
public int narg()Description copied from class:Varargs
Get the number of arguments, or 0 if there are none. -
arg1
Description copied from class:Varargs
Get the first argument in the list. -
getmetatable
Get the metatable for thisLuaValue
For
LuaTable
andLuaUserdata
instances, the metatable returned is this instance metatable. For all other types, the class metatable value will be returned.- Returns:
- metatable, or null if it there is none
-
setmetatable
Set the metatable for thisLuaValue
For
LuaTable
andLuaUserdata
instances, the metatable is per instance. For all other types, there is one metatable per type that can be set directly from java- Parameters:
metatable
-LuaValue
instance to serve as the metatable, or null to reset it.- Returns:
this
to allow chaining of Java function calls
-
call
Callthis
with 0 arguments, including metatag processing, and return only the first return value.If
this
is aLuaFunction
, call it, and return only its first return value, dropping any others. Otherwise, look for theCALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useinvoke()
instead.To call
this
as a method call, usemethod(LuaValue)
instead. -
call
Callthis
with 1 argument, including metatag processing, and return only the first return value.If
this
is aLuaFunction
, call it, and return only its first return value, dropping any others. Otherwise, look for theCALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useinvoke()
instead.To call
this
as a method call, usemethod(LuaValue)
instead. -
call
Convenience function which calls a luavalue with a single, string argument.- Parameters:
arg
- String argument to the function. This will be converted to a LuaString.- Returns:
- return value of the invocation.
- See Also:
-
call
Callthis
with 2 arguments, including metatag processing, and return only the first return value.If
this
is aLuaFunction
, call it, and return only its first return value, dropping any others. Otherwise, look for theCALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useinvoke()
instead.To call
this
as a method call, usemethod(LuaValue)
instead.- Parameters:
arg1
- First argument to supply to the called functionarg2
- Second argument to supply to the called function- Returns:
- First return value
(this(arg1,arg2))
, orNIL
if there were none. - Throws:
LuaError
- if not a function andCALL
is not defined, or the invoked function throws aLuaError
or the invoked closure throw a luaerror
- See Also:
-
call
Callthis
with 3 arguments, including metatag processing, and return only the first return value.If
this
is aLuaFunction
, call it, and return only its first return value, dropping any others. Otherwise, look for theCALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useinvoke()
instead.To call
this
as a method call, usemethod(LuaValue)
instead.- Parameters:
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- Returns:
- First return value
(this(arg1,arg2,arg3))
, orNIL
if there were none. - Throws:
LuaError
- if not a function andCALL
is not defined, or the invoked function throws aLuaError
or the invoked closure throw a luaerror
- See Also:
-
method
Call named method onthis
with 0 arguments, including metatag processing, and return only the first return value.Look up
this[name]
and if it is aLuaFunction
, call it insertingthis
as an additional first argument. and return only its first return value, dropping any others. Otherwise, look for theCALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useinvoke()
instead.To call
this
as a plain call, usecall()
instead. -
method
Call named method onthis
with 0 arguments, including metatag processing, and return only the first return value.Look up
this[name]
and if it is aLuaFunction
, call it insertingthis
as an additional first argument, and return only its first return value, dropping any others. Otherwise, look for theCALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useinvoke()
instead.To call
this
as a plain call, usecall()
instead. -
method
Call named method onthis
with 1 argument, including metatag processing, and return only the first return value.Look up
this[name]
and if it is aLuaFunction
, call it insertingthis
as an additional first argument, and return only its first return value, dropping any others. Otherwise, look for theCALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useinvoke()
instead.To call
this
as a plain call, usecall(LuaValue)
instead.- Parameters:
name
- Name of the method to look up for invocationarg
- Argument to supply to the method- Returns:
- All values returned from
this:name(arg)
as aVarargs
instance - Throws:
LuaError
- if not a function andCALL
is not defined, or the invoked function throws aLuaError
or the invoked closure throw a luaerror
- See Also:
-
method
Call named method onthis
with 1 argument, including metatag processing, and return only the first return value.Look up
this[name]
and if it is aLuaFunction
, call it insertingthis
as an additional first argument, and return only its first return value, dropping any others. Otherwise, look for theCALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useinvoke()
instead.To call
this
as a plain call, usecall(LuaValue)
instead.- Parameters:
name
- Name of the method to look up for invocationarg
- Argument to supply to the method- Returns:
- All values returned from
this:name(arg)
as aVarargs
instance - Throws:
LuaError
- if not a function andCALL
is not defined, or the invoked function throws aLuaError
or the invoked closure throw a luaerror
- See Also:
-
method
Call named method onthis
with 2 arguments, including metatag processing, and return only the first return value.Look up
this[name]
and if it is aLuaFunction
, call it insertingthis
as an additional first argument, and return only its first return value, dropping any others. Otherwise, look for theCALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useinvoke()
instead.To call
this
as a plain call, usecall(LuaValue,LuaValue)
instead.- Parameters:
name
- Name of the method to look up for invocationarg1
- First argument to supply to the methodarg2
- Second argument to supply to the method- Returns:
- All values returned from
this:name(arg1,arg2)
as aVarargs
instance - Throws:
LuaError
- if not a function andCALL
is not defined, or the invoked function throws aLuaError
or the invoked closure throw a luaerror
- See Also:
-
method
Call named method onthis
with 2 arguments, including metatag processing, and return only the first return value.Look up
this[name]
and if it is aLuaFunction
, call it insertingthis
as an additional first argument, and return only its first return value, dropping any others. Otherwise, look for theCALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useinvoke()
instead.To call
this
as a plain call, usecall(LuaValue,LuaValue)
instead.- Parameters:
name
- Name of the method to look up for invocationarg1
- First argument to supply to the methodarg2
- Second argument to supply to the method- Returns:
- All values returned from
this:name(arg1,arg2)
as aVarargs
instance - Throws:
LuaError
- if not a function andCALL
is not defined, or the invoked function throws aLuaError
or the invoked closure throw a luaerror
- See Also:
-
invoke
Callthis
with 0 arguments, including metatag processing, and retain all return values in aVarargs
.If
this
is aLuaFunction
, call it, and return all values. Otherwise, look for theCALL
metatag and call that.To get a particular return value, us
Varargs.arg(int)
To call
this
as a method call, useinvokemethod(LuaValue)
instead. -
invoke
Should not return args (must be new varargs) -
invoke
-
invoke
Callthis
with variable arguments, including metatag processing, and retain all return values in aVarargs
.If
this
is aLuaFunction
, call it, and return all values. Otherwise, look for theCALL
metatag and call that.To get a particular return value, us
Varargs.arg(int)
To call
this
as a method call, useinvokemethod(LuaValue,Varargs)
instead.- Parameters:
arg
- The first argument to supply to the called functionvarargs
- Varargs containing the remaining arguments to supply to the called function- Returns:
- All return values as a
Varargs
instance. - Throws:
LuaError
- if not a function andCALL
is not defined, or the invoked function throws aLuaError
or the invoked closure throw a luaerror
- See Also:
-
invoke
Callthis
with variable arguments, including metatag processing, and retain all return values in aVarargs
.If
this
is aLuaFunction
, call it, and return all values. Otherwise, look for theCALL
metatag and call that.To get a particular return value, us
Varargs.arg(int)
To call
this
as a method call, useinvokemethod(LuaValue,Varargs)
instead.- Parameters:
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- Returns:
- All return values as a
Varargs
instance. - Throws:
LuaError
- if not a function andCALL
is not defined, or the invoked function throws aLuaError
or the invoked closure throw a luaerror
- See Also:
-
invokemethod
Call named method onthis
with 0 arguments, including metatag processing, and retain all return values in aVarargs
.Look up
this[name]
and if it is aLuaFunction
, call it insertingthis
as an additional first argument, and return all return values as aVarargs
instance. Otherwise, look for theCALL
metatag and call that.To get a particular return value, us
Varargs.arg(int)
To call
this
as a plain call, useinvoke()
instead. -
invokemethod
Call named method onthis
with 0 arguments, including metatag processing, and retain all return values in aVarargs
.Look up
this[name]
and if it is aLuaFunction
, call it insertingthis
as an additional first argument, and return all return values as aVarargs
instance. Otherwise, look for theCALL
metatag and call that.To get a particular return value, us
Varargs.arg(int)
To call
this
as a plain call, useinvoke()
instead. -
invokemethod
Call named method onthis
with 1 argument, including metatag processing, and retain all return values in aVarargs
.Look up
this[name]
and if it is aLuaFunction
, call it insertingthis
as an additional first argument, and return all return values as aVarargs
instance. Otherwise, look for theCALL
metatag and call that.To get a particular return value, us
Varargs.arg(int)
To call
this
as a plain call, useinvoke(Varargs)
instead.- Parameters:
name
- Name of the method to look up for invocationargs
-Varargs
containing arguments to supply to the called function afterthis
- Returns:
- All values returned from
this:name(args)
as aVarargs
instance - Throws:
LuaError
- if not a function andCALL
is not defined, or the invoked function throws aLuaError
or the invoked closure throw a luaerror
- See Also:
-
invokemethod
Call named method onthis
with variable arguments, including metatag processing, and retain all return values in aVarargs
.Look up
this[name]
and if it is aLuaFunction
, call it insertingthis
as an additional first argument, and return all return values as aVarargs
instance. Otherwise, look for theCALL
metatag and call that.To get a particular return value, us
Varargs.arg(int)
To call
this
as a plain call, useinvoke(Varargs)
instead.- Parameters:
name
- Name of the method to look up for invocationargs
-Varargs
containing arguments to supply to the called function afterthis
- Returns:
- All values returned from
this:name(args)
as aVarargs
instance - Throws:
LuaError
- if not a function andCALL
is not defined, or the invoked function throws aLuaError
or the invoked closure throw a luaerror
- See Also:
-
not
Unary not: return inverse boolean value(~this)
as defined by lua not operator -
neg
Unary minus: return negative value(-this)
as defined by lua unary minus operator- Returns:
- boolean inverse as
LuaBoolean
if boolean or nil, numeric inverse asLuaNumber
if numeric, or metatag processing result ifUNM
metatag is defined - Throws:
LuaError
- ifthis
is not a table or string, and has noUNM
metatag
-
len
Length operator: return lua length of object(#this)
including metatag processing as java int -
length
public int length()Length operator: return lua length of object(#this)
including metatag processing as java int -
rawlen
public int rawlen()Get raw length of table or string without metatag processing.- Returns:
- the length of the table or string.
- Throws:
LuaError
- ifthis
is not a table or string.
-
equals
-
eq
Equals: Perform equality comparison with another value including metatag processing usingEQ
. -
eq_b
Equals: Perform equality comparison with another value including metatag processing usingEQ
, and return java boolean- Parameters:
val
- The value to compare with.- Returns:
- true if values are comparable and
(this == rhs)
, false if comparable but not equal, result converted to java boolean if metatag processing occurs. - See Also:
-
neq
Notquals: Perform inequality comparison with another value including metatag processing usingEQ
.- Parameters:
val
- The value to compare with.- Returns:
TRUE
if values are comparable and(this != rhs)
,FALSE
if comparable but equal, inverse ofLuaValue
converted toLuaBoolean
if metatag processing occurs.- See Also:
-
neq_b
Notquals: Perform inequality comparison with another value including metatag processing usingEQ
.- Parameters:
val
- The value to compare with.- Returns:
- true if values are comparable and
(this != rhs)
, false if comparable but equal, inverse of result converted to boolean if metatag processing occurs. - See Also:
-
raweq
Equals: Perform direct equality comparison with another value without metatag processing.- Parameters:
val
- The value to compare with.- Returns:
- true if
(this == rhs)
, false otherwise - See Also:
-
raweq
Equals: Perform direct equality comparison with aLuaUserdata
value without metatag processing.- Parameters:
val
- TheLuaUserdata
to compare with.- Returns:
- true if
this
is userdata and their metatables are the same using == and their instances are equal usingequals(Object)
, otherwise false - See Also:
-
raweq
Equals: Perform direct equality comparison with aLuaString
value without metatag processing. -
raweq
public boolean raweq(double val) Equals: Perform direct equality comparison with a double value without metatag processing.- Parameters:
val
- The double value to compare with.- Returns:
- true if
this
is aLuaNumber
whose value equals val, otherwise false
-
raweq
public boolean raweq(int val) Equals: Perform direct equality comparison with a int value without metatag processing.- Parameters:
val
- The double value to compare with.- Returns:
- true if
this
is aLuaNumber
whose value equals val, otherwise false
-
eqmtcall
Perform equality testing metatag processing- Parameters:
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- Returns:
- true if metatag processing result is not
NIL
orFALSE
- Throws:
LuaError
- if metatag was not defined for either operand- See Also:
-
add
Add: Perform numeric add operation with another value including metatag processing.Each operand must derive from
LuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the add with- Returns:
- value of
(this + rhs)
if both are numeric, orLuaValue
if metatag processing occurs - Throws:
LuaError
- if either operand is not a number or string convertible to number, and neither has theADD
metatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
add
Add: Perform numeric add operation with another value of double type with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the add with- Returns:
- value of
(this + rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
add
Add: Perform numeric add operation with another value of int type with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the add with- Returns:
- value of
(this + rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
sub
Subtract: Perform numeric subtract operation with another value of unknown type, including metatag processing.Each operand must derive from
LuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the subtract with- Returns:
- value of
(this - rhs)
if both are numeric, orLuaValue
if metatag processing occurs - Throws:
LuaError
- if either operand is not a number or string convertible to number, and neither has theSUB
metatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
sub
Subtract: Perform numeric subtract operation with another value of double type with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the subtract with- Returns:
- value of
(this - rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
sub
Subtract: Perform numeric subtract operation with another value of int type with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the subtract with- Returns:
- value of
(this - rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
subFrom
Reverse-subtract: Perform numeric subtract operation from an int value with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
lhs
- The left-hand-side value from which to perform the subtraction- Returns:
- value of
(lhs - this)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
subFrom
Reverse-subtract: Perform numeric subtract operation from a double value without metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a numberFor metatag processing
sub(LuaValue)
must be used- Parameters:
lhs
- The left-hand-side value from which to perform the subtraction- Returns:
- value of
(lhs - this)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
mul
Multiply: Perform numeric multiply operation with another value of unknown type, including metatag processing.Each operand must derive from
LuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the multiply with- Returns:
- value of
(this * rhs)
if both are numeric, orLuaValue
if metatag processing occurs - Throws:
LuaError
- if either operand is not a number or string convertible to number, and neither has theMUL
metatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
mul
Multiply: Perform numeric multiply operation with another value of double type with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the multiply with- Returns:
- value of
(this * rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number
-
mul
Multiply: Perform numeric multiply operation with another value of int type with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the multiply with- Returns:
- value of
(this * rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number
-
pow
Raise to power: Raise this value to a power including metatag processing.Each operand must derive from
LuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The power to raise this value to- Returns:
- value of
(this ^ rhs)
if both are numeric, orLuaValue
if metatag processing occurs - Throws:
LuaError
- if either operand is not a number or string convertible to number, and neither has thePOW
metatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
pow
Raise to power: Raise this value to a power of double type with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The power to raise this value to- Returns:
- value of
(this ^ rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
pow
Raise to power: Raise this value to a power of int type with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The power to raise this value to- Returns:
- value of
(this ^ rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
powWith
Reverse-raise to power: Raise another value of double type to this power with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
lhs
- The left-hand-side value which will be raised to this power- Returns:
- value of
(lhs ^ this)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
powWith
Reverse-raise to power: Raise another value of double type to this power with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
lhs
- The left-hand-side value which will be raised to this power- Returns:
- value of
(lhs ^ this)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
div
Divide: Perform numeric divide operation by another value of unknown type, including metatag processing.Each operand must derive from
LuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the divulo with- Returns:
- value of
(this / rhs)
if both are numeric, orLuaValue
if metatag processing occurs - Throws:
LuaError
- if either operand is not a number or string convertible to number, and neither has theDIV
metatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
div
Divide: Perform numeric divide operation by another value of double type without metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a numberFor metatag processing
div(LuaValue)
must be used- Parameters:
rhs
- The right-hand-side value to perform the divulo with- Returns:
- value of
(this / rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
div
Divide: Perform numeric divide operation by another value of int type without metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a numberFor metatag processing
div(LuaValue)
must be used- Parameters:
rhs
- The right-hand-side value to perform the divulo with- Returns:
- value of
(this / rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
divInto
Reverse-divide: Perform numeric divide operation into another value with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
lhs
- The left-hand-side value which will be divided by this- Returns:
- value of
(lhs / this)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
mod
Modulo: Perform numeric modulo operation with another value of unknown type, including metatag processing.Each operand must derive from
LuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
rhs
- The right-hand-side value to perform the modulo with- Returns:
- value of
(this % rhs)
if both are numeric, orLuaValue
if metatag processing occurs - Throws:
LuaError
- if either operand is not a number or string convertible to number, and neither has theMOD
metatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
mod
Modulo: Perform numeric modulo operation with another value of double type without metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a numberFor metatag processing
mod(LuaValue)
must be used- Parameters:
rhs
- The right-hand-side value to perform the modulo with- Returns:
- value of
(this % rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
mod
Modulo: Perform numeric modulo operation with another value of int type without metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a numberFor metatag processing
mod(LuaValue)
must be used- Parameters:
rhs
- The right-hand-side value to perform the modulo with- Returns:
- value of
(this % rhs)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
modFrom
Reverse-modulo: Perform numeric modulo operation from another value with metatag processingthis
must derive fromLuaNumber
or derive fromLuaString
and be convertible to a number- Parameters:
lhs
- The left-hand-side value which will be modulo'ed by this- Returns:
- value of
(lhs % this)
if this is numeric - Throws:
LuaError
- ifthis
is not a number or string convertible to number- See Also:
-
lt
Less than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returningLuaValue
.To be comparable, both operands must derive from
LuaString
or both must derive fromLuaNumber
. -
lt
Less than: Perform numeric comparison with another value of double type, including metatag processing, and returningLuaValue
.To be comparable, this must derive from
LuaNumber
. -
lt
Less than: Perform numeric comparison with another value of int type, including metatag processing, and returningLuaValue
.To be comparable, this must derive from
LuaNumber
. -
lt_b
Less than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.To be comparable, both operands must derive from
LuaString
or both must derive fromLuaNumber
.- Parameters:
rhs
- The right-hand-side value to perform the comparison with- Returns:
- true if
(this < rhs)
, false if not, and boolean interpreation of result if metatag processing occurs. - Throws:
LuaError
- if either both operands are not a strings or both are not numbers and noLT
metatag is defined.- See Also:
-
lt_b
public boolean lt_b(int rhs) Less than: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean.To be comparable, this must derive from
LuaNumber
. -
lt_b
public 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.To be comparable, both operands must derive from
LuaString
or both must derive fromLuaNumber
.- Parameters:
rhs
- The right-hand-side value to perform the comparison with- Returns:
- true if
(this < rhs)
, false if not, and boolean interpreation of result if metatag processing occurs. - Throws:
LuaError
- if either both operands are not a strings or both are not numbers and noLT
metatag is defined.- See Also:
-
lteq
Less than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returningLuaValue
.To be comparable, both operands must derive from
LuaString
or both must derive fromLuaNumber
. -
lteq
Less than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returningLuaValue
.To be comparable, this must derive from
LuaNumber
. -
lteq
Less than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returningLuaValue
.To be comparable, this must derive from
LuaNumber
. -
lteq_b
Less than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.To be comparable, both operands must derive from
LuaString
or both must derive fromLuaNumber
.- Parameters:
rhs
- The right-hand-side value to perform the comparison with- Returns:
- true if
(this <= rhs)
, false if not, and boolean interpreation of result if metatag processing occurs. - Throws:
LuaError
- if either both operands are not a strings or both are not numbers and noLE
metatag is defined.- See Also:
-
lteq_b
public 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.To be comparable, this must derive from
LuaNumber
. -
lteq_b
public 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.To be comparable, this must derive from
LuaNumber
. -
gt
Greater than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returningLuaValue
.To be comparable, both operands must derive from
LuaString
or both must derive fromLuaNumber
. -
gt
Greater than: Perform numeric comparison with another value of double type, including metatag processing, and returningLuaValue
.To be comparable, this must derive from
LuaNumber
. -
gt
Greater than: Perform numeric comparison with another value of int type, including metatag processing, and returningLuaValue
.To be comparable, this must derive from
LuaNumber
. -
gt_b
Greater than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.To be comparable, both operands must derive from
LuaString
or both must derive fromLuaNumber
.- Parameters:
rhs
- The right-hand-side value to perform the comparison with- Returns:
- true if
(this > rhs)
, false if not, and boolean interpreation of result if metatag processing occurs. - Throws:
LuaError
- if either both operands are not a strings or both are not numbers and noLE
metatag is defined.- See Also:
-
gt_b
public boolean gt_b(int rhs) Greater than: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean.To be comparable, this must derive from
LuaNumber
. -
gt_b
public 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.To be comparable, both operands must derive from
LuaString
or both must derive fromLuaNumber
.- Parameters:
rhs
- The right-hand-side value to perform the comparison with- Returns:
- true if
(this > rhs)
, false if not, and boolean interpreation of result if metatag processing occurs. - Throws:
LuaError
- if either both operands are not a strings or both are not numbers and noLE
metatag is defined.- See Also:
-
gteq
Greater than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returningLuaValue
.To be comparable, both operands must derive from
LuaString
or both must derive fromLuaNumber
. -
gteq
Greater than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returningLuaValue
.To be comparable, this must derive from
LuaNumber
. -
gteq
Greater than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returningLuaValue
.To be comparable, this must derive from
LuaNumber
. -
gteq_b
Greater than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.To be comparable, both operands must derive from
LuaString
or both must derive fromLuaNumber
.- Parameters:
rhs
- The right-hand-side value to perform the comparison with- Returns:
- true if
(this >= rhs)
, false if not, and boolean interpreation of result if metatag processing occurs. - Throws:
LuaError
- if either both operands are not a strings or both are not numbers and noLT
metatag is defined.- See Also:
-
gteq_b
public 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.To be comparable, this must derive from
LuaNumber
. -
gteq_b
public 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.To be comparable, this must derive from
LuaNumber
. -
comparemt
Perform metatag processing for comparison operations.Finds the supplied metatag value and invokes it, or throws
LuaError
if none applies.- Parameters:
tag
- The metatag to look upop1
- The operand with which to to perform the operation- Returns:
LuaValue
resulting from metatag processing- Throws:
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.- See Also:
-
strcmp
Perform string comparison with another value of any type using string comparison based on byte values.Only strings can be compared, meaning each operand must derive from
LuaString
.- Parameters:
rhs
- The right-hand-side value to perform the comparison with- Returns:
- int < 0 for
(this < rhs)
, int > 0 for(this > rhs)
, or 0 when same string. - Throws:
LuaError
- if either operand is not a string
-
strcmp
Perform string comparison with another value known to be aLuaString
using string comparison based on byte values.Only strings can be compared, meaning each operand must derive from
LuaString
.- Parameters:
rhs
- The right-hand-side value to perform the comparison with- Returns:
- int < 0 for
(this < rhs)
, int > 0 for(this > rhs)
, or 0 when same string. - Throws:
LuaError
- if this is not a string
-
concat
-
concatTo
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.Only strings and numbers as represented can be concatenated, meaning each operand must derive from
LuaString
orLuaNumber
. -
concatTo
Reverse-concatenation: concatenate this value onto another value known to be aLuaNumber
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
orLuaNumber
. -
concatTo
Reverse-concatenation: concatenate this value onto another value known to be aLuaString
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
orLuaNumber
. -
buffer
Convert the value to aBuffer
for more efficient concatenation of multiple strings.- Returns:
- Buffer instance containing the string or number
-
concat
-
concatmt
-
and
Perform booleanand
with another operand, based on lua rules for boolean evaluation. This returns eitherthis
orrhs
depending on the boolean value forthis
.- Parameters:
rhs
- The right-hand-side value to perform the operation with- Returns:
this
ifthis.toboolean()
is false,rhs
otherwise.
-
or
Perform booleanor
with another operand, based on lua rules for boolean evaluation. This returns eitherthis
orrhs
depending on the boolean value forthis
.- Parameters:
rhs
- The right-hand-side value to perform the operation with- Returns:
this
ifthis.toboolean()
is true,rhs
otherwise.
-
testfor_b
Perform end-condition test in for-loop processing.Used in lua-bytecode to Java-bytecode conversion.
- Parameters:
limit
- the numerical limit to complete the for loopstep
- the numberical step size to use.- Returns:
- true if limit has not been reached, false otherwise.
-
strvalue
-
strongvalue
Return this value as a strong reference, or null if it was weak and is no longer referenced. -
valueOf
Convert java boolean to aLuaValue
. -
valueOf
Convert java int to aLuaValue
.- Parameters:
i
- int value to convert- Returns:
- instance, possibly pooled, whose value is i
-
valueOf
Convert java double to aLuaValue
. This may return a or depending on the value supplied.- Parameters:
d
- double value to convert- Returns:
LuaNumber
instance, possibly pooled, whose value is d
-
valueOf
Convert java string to aLuaValue
.- Parameters:
s
- String value to convert- Returns:
LuaString
instance, possibly pooled, whose value is s
-
valueOf
Convert bytes in an array to aLuaValue
.- Parameters:
bytes
- byte array to convert- Returns:
LuaString
instance, possibly pooled, whose bytes are those in the supplied array
-
valueOf
Convert bytes in an array to aLuaValue
. -
tableOf
Construct an emptyLuaTable
.- Returns:
- new
LuaTable
instance with no values and no metatable.
-
tableOf
Construct aLuaTable
initialized with supplied array values. -
tableOf
Construct an emptyLuaTable
preallocated to hold array and hashed elements- Parameters:
narray
- Number of array elements to preallocatenhash
- Number of hash elements to preallocate- Returns:
- new
LuaTable
instance with no values and no metatable, but preallocated for array and hashed elements.
-
listOf
Construct aLuaTable
initialized with supplied array values. -
listOf
Construct aLuaTable
initialized with supplied array values.- Parameters:
unnamedValues
- array ofLuaValue
containing the first values to use in initializationlastarg
-Varargs
containing additional values to use in initialization to be put after the last unnamedValues element- Returns:
- new
LuaTable
instance with sequential elements coming from the array and varargs.
-
tableOf
Construct aLuaTable
initialized with supplied named values. -
tableOf
Construct aLuaTable
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.- Parameters:
namedValues
- array ofLuaValue
containing the keys and values to use in initialization in order{key-a, value-a, key-b, value-b, ...}
unnamedValues
- array ofLuaValue
containing the sequenctial elements to use in initialization in order{value-1, value-2, ...}
, or null if there are none- Returns:
- new
LuaTable
instance with named and sequential values supplied.
-
tableOf
Construct aLuaTable
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.- Parameters:
namedValues
- array ofLuaValue
containing the keys and values to use in initialization in order{key-a, value-a, key-b, value-b, ...}
unnamedValues
- array ofLuaValue
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- Returns:
- new
LuaTable
instance with named and sequential values supplied.
-
userdataOf
Construct a LuaUserdata for an object.- Parameters:
o
- The java instance to be wrapped as userdata- Returns:
LuaUserdata
value wrapping the java instance.
-
userdataOf
Construct a LuaUserdata for an object with a user supplied metatable.- Parameters:
o
- The java instance to be wrapped as userdatametatable
- The metatble to associate with the userdata instance.- Returns:
LuaUserdata
value wrapping the java instance.
-
metatag
Get particular metatag, or returnNIL
if it doesn't exist -
cFloat
-
cDouble
-
cInt
-
cNcInt
-
cNcFloat
-
cNcDouble
-
cBool
-
cRegObject
For regular objects only. Not for: - String (use StringCoercion) - Object (raw, could be anything) - Class instances (JavaClass.coerce()) - LuaValue instances (LuaCoercion) -
isRegObject
-
cObject
-
varargsOf
-
varargsOf
-
varargsOf
-
varargsOf
-
varargsOf
-
varargsOf
-
tailcallOf
Construct aTailcallVarargs
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.
- Parameters:
func
-LuaValue
to be called as a tail callargs
-Varargs
containing the arguments to the call- Returns:
TailcallVarargs
to be used in tailcall oprocessing.- See Also:
-
onInvoke
Callback used during tail call processing to invoke the function once.This may return a
TailcallVarargs
to be evaluated by the client.This should not be called directly, instead use one of the call invocation functions.
- Parameters:
args
- the arguments to the call invocation.- Returns:
- Varargs the return values, possible a TailcallVarargs.
- See Also:
-
initupvalue1
Hook for implementations such as LuaJC to load the environment of the main chunk into the first upvalue location. If the function has no upvalues or is not a main chunk, calling this will be no effect.- Parameters:
env
- The environment to load into the first upvalue, if there is one.
-
subargs
Create aVarargs
instance containing arguments starting at indexstart
-