Class LuaValue
- Direct Known Subclasses:
LuaBoolean,LuaFunction,LuaNil,LuaNumber,LuaString,LuaTable,LuaThread,LuaUserdata
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.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic final classVarargs implemenation with no values. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LuaStringLuaString constant with value "__add" for use as metatagstatic final LuaStringLuaString constant with value "__call" for use as metatagstatic final LuaStringLuaString constant with value "__concat" for use as metatagstatic final LuaStringLuaString constant with value "__div" for use as metatagstatic final LuaStringLuaString constant with value ""static LuaStringThe variable name of the environment.static final LuaStringLuaString constant with value "__eq" for use as metatagstatic final LuaBooleanLuaBoolean constant corresponding to luafalsestatic final LuaStringLuaString constant with value "__index" for use as metatagstatic final LuaStringLuaString constant with value "__le" for use as metatagstatic final LuaStringLuaString constant with value "__len" for use as metatagstatic final LuaStringLuaString constant with value "__lt" for use as metatagstatic final LuaStringLuaString constant with value "__metatable" for use as metatagstatic final LuaNumberLuaValue number constant equal to -1static final LuaStringLuaString constant with value "__mod" for use as metatagstatic final LuaStringLuaString constant with value "__mode" for use as metatagstatic final LuaStringLuaString constant with value "__mul" for use as metatagstatic final LuaStringLuaString constant with value "__newindex" for use as metatagstatic final LuaValueLuaValue constant corresponding to lua#NILstatic final LuaValue.NillableSerializerstatic final LuaValue[]Array ofNILvalues to optimize filling stacks using System.arraycopy().static final LuaValueLuaValue constant corresponding to aVarargslist of no valuesstatic final LuaValue[]LuaValue array constant with no valuesstatic final LuaNumberLuaValue number constant equal to 1static final LuaStringLuaString constant with value "__pow" for use as metatagstatic final LuaStringLuaString constant with value "__sub" for use as metatagstatic final intType enumeration constant for lua booleansstatic final intType enumeration constant for lua functionsstatic final intType enumeration constant for lua numbers that are ints, for compatibility with lua 5.1 number patch onlystatic final intType enumeration constant for lua light userdata, for compatibility with C-based lua onlystatic final intType enumeration constant for lua nilstatic final intType enumeration constant for lua values that have no type, for example weak table entriesstatic final intType enumeration constant for lua numbersstatic final LuaStringLuaString constant with value "__tostring" for use as metatagstatic final LuaBooleanLuaBoolean constant corresponding to luatruestatic final intType enumeration constant for lua stringsstatic final intType enumeration constant for lua tablesstatic final intType enumeration constant for lua threadsstatic final intType enumeration constant for lua userdatasstatic final intType 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 LuaStringLuaString constant with value "__unm" for use as metatagstatic final LuaNumberLuaValue 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 booleanandwith 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 LuaValueThrow aLuaErrorindicating an invalid argument was supplied to a functionstatic voidAssert a condition is true, or throw aLuaErrorif not Returns no value when b is true, throwserror(String)withmsgas argument and does not return if b is false.buffer()Convert the value to aBufferfor more efficient concatenation of multiple strings.static LuaDoublecachedDouble(double val) static LuaIntegercachedInt(int val) static Varargsstatic VarargscachedVarargsOf(LuaValue v1, LuaValue v2) static VarargscachedVarargsOf(LuaValue v1, LuaValue v2, LuaValue v3) static VarargscachedVarargsOf(LuaValue v1, LuaValue v2, LuaValue v3, LuaValue v4) static Varargsstatic Varargscall()Callthiswith 0 arguments, including metatag processing, and return only the first return value.Callthiswith 1 argument, including metatag processing, and return only the first return value.Callthiswith 2 arguments, including metatag processing, and return only the first return value.Callthiswith 3 arguments, including metatag processing, and return only the first return value.Convenience function which calls a luavalue with a single, string argument.booleanCheck that the value is aLuaBoolean, or throwLuaErrorif notCheck that the value is aLuaClosure, or throwLuaErrorif notdoubleCheck that the value is numeric and return the value as a double, or throwLuaErrorif not numericCheck that the value is a function , or throwLuaErrorif notCheck that the value is a Globals instance, or throwLuaErrorif notintcheckint()Check that the value is numeric, and convert and cast value to int, or throwLuaErrorif not numericCheck that the value is numeric, and convert and cast value to int, or throwLuaErrorif not numericConvert this value to a Java String.longCheck that the value is numeric, and convert and cast value to long, or throwLuaErrorif not numericCheck that the value is numeric, and return as a LuaNumber if so, or throwLuaErrorchecknumber(String msg) Check that the value is numeric, and return as a LuaNumber if so, or throwLuaErrorCheck that this is a lua string, or throwLuaErrorif it is not.Check that this is aLuaUserdata, or throwLuaErrorif it is notCheck that this is aLuaUserdata, or throwLuaErrorif it is notPerform metatag processing for comparison operations.Concatenate aBufferonto 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 aLuaNumberand return the result using rules of lua string concatenation including metatag processing.Reverse-concatenation: concatenate this value onto another value known to be aLuaStringand 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.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.booleanEquals: Perform equality comparison with another value including metatag processing usingEQ, and return java booleanstatic final booleanPerform equality testing metatag processingbooleanstatic LuaValueThrow aLuaErrorwith 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 thisLuaValuegt(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.booleangt_b(double rhs) Greater than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.booleangt_b(int rhs) Greater than: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean.booleanGreater 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.booleangteq_b(double rhs) Greater than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returning java boolean.booleangteq_b(int rhs) Greater than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean.booleanGreater than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.voidinitupvalue1(LuaValue env) Hook for implementations such as LuaJC to load the environment of the main chunk into the first upvalue location.invoke()Callthiswith 0 arguments, including metatag processing, and retain all return values in aVarargs.Callthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.Callthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.Callthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.Callthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.Callthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.invokemethod(LuaValue name) Call named method onthiswith 0 arguments, including metatag processing, and retain all return values in aVarargs.invokemethod(LuaValue name, LuaValue[] args) Call named method onthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.invokemethod(LuaValue name, Varargs args) Call named method onthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.invokemethod(String name) Call named method onthiswith 0 arguments, including metatag processing, and retain all return values in aVarargs.invokemethod(String name, LuaValue[] args) Call named method onthiswith 1 argument, including metatag processing, and retain all return values in aVarargs.invokemethod(String name, Varargs args) Call named method onthiswith 1 argument, including metatag processing, and retain all return values in aVarargs.booleanCheck ifthisis abooleanbooleanCheck ifthisis afunctionthat is a closure, meaning interprets lua bytecode for its executionbooleanCheck ifthisis afunctionbooleanisint()Check ifthisis anumberand is representable by java int without rounding or truncationbooleanCheck ifthisis aLuaIntegerbooleanislong()Check ifthisis anumberand is representable by java long without rounding or truncationbooleanisnil()Check ifthisis#NILbooleanisnumber()Check ifthisis anumberbooleanisstring()Check ifthisis astringbooleanistable()Check ifthisis atablebooleanisthread()Check ifthisis athreadbooleanCheck ifthisis auserdatabooleanisuserdata(Class c) Check ifthisis auserdataof typecbooleanReturn 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 intintlength()Length operator: return lua length of object(#this)including metatag processing as java intstatic LuaTableConstruct aLuaTableinitialized with supplied array values.static LuaTableConstruct aLuaTableinitialized 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.booleanlt_b(double rhs) Less than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.booleanlt_b(int rhs) Less than: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean.booleanLess 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.booleanlteq_b(double rhs) Less than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returning java boolean.booleanlteq_b(int rhs) Less than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returning java boolean.booleanLess 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 returnNILif it doesn't existCall named method onthiswith 0 arguments, including metatag processing, and return only the first return value.Call named method onthiswith 1 argument, including metatag processing, and return only the first return value.Call named method onthiswith 2 arguments, including metatag processing, and return only the first return value.Call named method onthiswith 0 arguments, including metatag processing, and return only the first return value.Call named method onthiswith 1 argument, including metatag processing, and return only the first return value.Call named method onthiswith 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.intnarg()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.booleanNotquals: 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.booleanoptboolean(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 asLuaClosuredoubleoptdouble(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 asLuaFunctionintoptint(int defval) Check that optional argument is a number or string convertible to number and return as intoptinteger(LuaInteger defval) Check that optional argument is a number or string convertible to number and return asLuaIntegeroptjstring(String defval) Check that optional argument is a string or number and return as Java Stringlongoptlong(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 asLuaNumberCheck that optional argument is a string or number and return asLuaStringCheck that optional argument is a table and return asLuaTableCheck that optional argument is a thread and return asLuaThreadoptuserdata(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 booleanorwith 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 processingvoidpresize(int i) Preallocate the array part of a table to be a certain size,booleanraweq(double val) Equals: Perform direct equality comparison with a double value without metatag processing.booleanraweq(int val) Equals: Perform direct equality comparison with a int value without metatag processing.booleanEquals: Perform direct equality comparison with aLuaStringvalue without metatag processing.booleanraweq(LuaUserdata val) Equals: Perform direct equality comparison with aLuaUserdatavalue without metatag processing.booleanEquals: 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.intrawlen()Get raw length of table or string without metatag processing.voidSet a value in a table without metatag processing.voidSet a value in a table without metatag processing.voidSet a value in a table without metatag processing.voidSet a value in a table without metatag processing.voidSet a value in a table without metatag processing.voidSet a value in a table without metatag processing.voidSet a value in a table without metatag processing.voidrawsetlist(int key0, Varargs values) Set list values in a table without invoking metatag processingvoidSet a value in a table without metatag processing usingNEWINDEX.voidSet a value in a table without metatag processing usingNEWINDEX.voidSet a value in a table without metatag processing usingNEWINDEX.voidSet a value in a table without metatag processing usingNEWINDEX.voidSet a value in a table without metatag processing usingNEWINDEX.voidSet a value in a table without metatag processing usingNEWINDEX.voidSet a value in a table without metatag processing usingNEWINDEX.setmetatable(LuaValue metatable) Set the metatable for thisLuaValueintPerform string comparison with another value known to be aLuaStringusing string comparison based on byte values.intPerform 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 aVarargsinstance containing arguments starting at indexstartsubFrom(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 LuaTabletableOf()Construct an emptyLuaTable.static LuaTabletableOf(int narray, int nhash) Construct an emptyLuaTablepreallocated to hold array and hashed elementsstatic LuaTableConstruct aLuaTableinitialized with supplied named values.static LuaTableConstruct aLuaTableinitialized with supplied named values and sequential elements.static LuaTableConstruct aLuaTableinitialized with supplied named values and sequential elements in an array part and as varargs.static LuaTableConstruct aLuaTableinitialized with supplied array values.static VarargstailcallOf(LuaValue func, Varargs args) Construct aTailcallVarargsaround a function and arguments.booleanPerform end-condition test in for-loop processing.booleanbytetobyte()Convert to byte if numeric, or 0 if not.chartochar()Convert to char if numeric, or 0 if not.doubletodouble()Convert to double if numeric, or 0 if not.floattofloat()Convert to float if numeric, or 0 if not.inttoint()Convert to int if numeric, or 0 if not.Convert to human readable String for any type.longtolong()Convert to long if numeric, or 0 if not.tonumber()Conditionally convert to lua number without throwing errors.shorttoshort()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.touserdata(Class c) Convert to userdata instance if specific type, or null.abstract inttype()Get the enumeration value for the type of this value.abstract Stringtypename()Get the String name of the type of this value.static LuaUserdatauserdataOf(Object o) Construct a LuaUserdata for an object.static LuaUserdatauserdataOf(Object o, LuaValue metatable) Construct a LuaUserdata for an object with a user supplied metatable.static LuaBooleanvalueOf(boolean b) Convert java boolean to aLuaValue.static LuaStringvalueOf(byte[] bytes) Convert bytes in an array to aLuaValue.static LuaStringvalueOf(byte[] bytes, int off, int len) Convert bytes in an array to aLuaValue.static LuaNumbervalueOf(double d) Convert java double to aLuaValue.static LuaIntegervalueOf(int i) Convert java int to aLuaValue.static LuaStringConvert java string to aLuaValue.static Varargsstatic Varargsstatic Varargsstatic Varargsstatic Varargsstatic VarargsMethods inherited from class com.prineside.luaj.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, dealias, 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, 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 aVarargslist 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 "" -
NILS
Array ofNILvalues 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_NAMEScorresponding to the type of this value: "nil", "boolean", "number", "string", "table", "function", "userdata", "thread" - See Also:
-
isboolean
public boolean isboolean()Check ifthisis aboolean- Returns:
- true if this is a
boolean, otherwise false - See Also:
-
isclosure
public boolean isclosure()Check ifthisis afunctionthat 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 ifthisis afunction- Returns:
- true if this is a
function, otherwise false - See Also:
-
isint
public boolean isint()Check ifthisis anumberand is representable by java int without rounding or truncation -
isinttype
public boolean isinttype()- Returns:
- true if this is a
LuaInteger, otherwise false - See Also:
-
islong
public boolean islong()Check ifthisis anumberand is representable by java long without rounding or truncation -
isnil
public boolean isnil()Check ifthisis#NIL- Returns:
- true if this is
#NIL, otherwise false - See Also:
-
isnumber
public boolean isnumber()Check ifthisis anumber -
isstring
public boolean isstring()Check ifthisis astring -
isthread
public boolean isthread()Check ifthisis athread- Returns:
- true if this is a
thread, otherwise false - See Also:
-
istable
public boolean istable()Check ifthisis atable- Returns:
- true if this is a
table, otherwise false - See Also:
-
isuserdata
public boolean isuserdata()Check ifthisis auserdata- Returns:
- true if this is a
userdata, otherwise false - See Also:
-
isuserdata
Check ifthisis auserdataof typec- Parameters:
c- Class to test instance against- Returns:
- true if this is a
userdataand 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
LuaValuethisif it is a number or a string convertible to a number, andNILfor 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
LuaValuethisif it is a string or number, andNILfor 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 ifthisis nil or none- Returns:
thiscast to boolean if aLuaBoolean,defvalif nil or none, throwsLuaErrorotherwise- Throws:
LuaError- if was not a boolean or nil or none.- See Also:
-
optclosure
Check that optional argument is a closure and return asLuaClosureA
LuaClosureis aLuaFunctionthat executes lua byteccode.- Parameters:
defval-LuaClosureto return ifthisis nil or none- Returns:
thiscast toLuaClosureif a function,defvalif nil or none, throwsLuaErrorotherwise- 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 asLuaFunctionA
LuaFunctionmay either be a Java function that implements functionality directly in Java, or aLuaClosurewhich is aLuaFunctionthat executes lua bytecode.- Parameters:
defval-LuaFunctionto return ifthisis nil or none- Returns:
thiscast toLuaFunctionif a function,defvalif nil or none, throwsLuaErrorotherwise- 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 -
optinteger
Check that optional argument is a number or string convertible to number and return asLuaInteger- Parameters:
defval-LuaIntegerto return ifthisis nil or none- Returns:
thisconverted and wrapped inLuaIntegerif numeric,defvalif nil or none, throwsLuaErrorotherwise- Throws:
LuaError- if was not numeric or nil or none.- See Also:
-
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 -
optthread
Check that optional argument is a thread and return asLuaThread -
optuserdata
Check that optional argument is a userdata and return the Object instance- Parameters:
defval- Object to return ifthisis nil or none- Returns:
- Object instance of the userdata if a
LuaUserdata,defvalif nil or none, throwsLuaErrorif 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 ifthisis nil or none- Returns:
- Object instance of the userdata if a
LuaUserdataand instance is assignable toc,defvalif nil or none, throwsLuaErrorif some other type - Throws:
LuaError- if was not a userdata whose instance is assignable tocor 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 throwLuaErrorif not- Returns:
- boolean value for
thisif it is aLuaBoolean - Throws:
LuaError- if not aLuaBoolean- See Also:
-
checkclosure
Check that the value is aLuaClosure, or throwLuaErrorif notLuaClosureis a subclass ofLuaFunctionthat interprets lua bytecode.- Returns:
thiscast 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 throwLuaErrorif not numericValues that are
LuaNumberand values that areLuaStringthat can be converted to a number will be converted to double. -
checkfunction
Check that the value is a function , or throwLuaErrorif notA
LuaFunctionmay either be a Java function that implements functionality directly in Java, or aLuaClosurewhich is aLuaFunctionthat executes lua bytecode.- Returns:
thisif 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 throwLuaErrorif not numericValues that are
LuaNumberwill be cast to int and may lose precision. Values that areLuaStringthat can be converted to a number will be converted, then cast to int, so may also lose precision. -
checkinteger
Check that the value is numeric, and convert and cast value to int, or throwLuaErrorif not numericValues that are
LuaNumberwill be cast to int and may lose precision. Values that areLuaStringthat can be converted to a number will be converted, then cast to int, so may also lose precision.- Returns:
- value cast to a int and wrapped in
LuaIntegerif numeric - Throws:
LuaError- if not aLuaNumberor is aLuaStringthat can't be converted to number- See Also:
-
checklong
public long checklong()Check that the value is numeric, and convert and cast value to long, or throwLuaErrorif not numericValues that are
LuaNumberwill be cast to long and may lose precision. Values that areLuaStringthat 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 throwLuaErrorValues that are
LuaStringthat 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 throwLuaErrorValues that are
LuaStringthat 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 throwLuaErrorif it is not.In lua all numbers are strings, so this will succeed for anything that derives from
LuaStringorLuaNumber. Numbers will be converted toLuaString. -
checktable
-
checkthread
-
checkuserdata
Check that this is aLuaUserdata, or throwLuaErrorif it is not- Returns:
thisif it is aLuaUserdata- Throws:
LuaError- ifthisis not aLuaUserdata- See Also:
-
checkuserdata
Check that this is aLuaUserdata, or throwLuaErrorif it is not- Returns:
thisif it is aLuaUserdata- Throws:
LuaError- ifthisis 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 aLuaErrorwith a particular message- Parameters:
message- String providing message details- Throws:
LuaError- in all cases
-
assert_
Assert a condition is true, or throw aLuaErrorif not Returns no value when b is true, throwserror(String)withmsgas 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 aLuaErrorindicating 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- ifthisis 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- ifthisis 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- ifthisis 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 ifthisis a table, returnNILif there are no more, or throw aLuaErrorif 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 ) }- Parameters:
index-LuaIntegervalue identifying a key to start from, orNILto start at the beginning- Returns:
Varargscontaining {key,value} for the next entry, orNILif there are no more.- Throws:
LuaError- ifthisis not a table, or the supplied key is invalid.- See Also:
-
inext
Find the next integer-key,value pair ifthisis a table, returnNILif there are no more, or throw aLuaErrorif 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 ) }- Parameters:
index-LuaIntegervalue identifying a key to start from, orNILto start at the beginning- Returns:
Varargscontaining(key,value)for the next entry, orNONEif there are no more.- Throws:
LuaError- ifthisis not a table, or the supplied key is invalid.- See Also:
-
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:VarargsGet the n-th argument value (1-based). -
narg
public int narg()Description copied from class:VarargsGet the number of arguments, or 0 if there are none. -
arg1
Description copied from class:VarargsGet the first argument in the list. -
getmetatable
Get the metatable for thisLuaValueFor
LuaTableandLuaUserdatainstances, 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
- See Also:
-
setmetatable
Set the metatable for thisLuaValueFor
LuaTableandLuaUserdatainstances, the metatable is per instance. For all other types, there is one metatable per type that can be set directly from java- Parameters:
metatable-LuaValueinstance to serve as the metatable, or null to reset it.- Returns:
thisto allow chaining of Java function calls- See Also:
-
call
Callthiswith 0 arguments, including metatag processing, and return only the first return value.If
thisis aLuaFunction, call it, and return only its first return value, dropping any others. Otherwise, look for theCALLmetatag 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
thisas a method call, usemethod(LuaValue)instead. -
call
Callthiswith 1 argument, including metatag processing, and return only the first return value.If
thisis aLuaFunction, call it, and return only its first return value, dropping any others. Otherwise, look for theCALLmetatag 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
thisas 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
Callthiswith 2 arguments, including metatag processing, and return only the first return value.If
thisis aLuaFunction, call it, and return only its first return value, dropping any others. Otherwise, look for theCALLmetatag 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
thisas 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)), orNILif there were none. - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
call
Callthiswith 3 arguments, including metatag processing, and return only the first return value.If
thisis aLuaFunction, call it, and return only its first return value, dropping any others. Otherwise, look for theCALLmetatag 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
thisas 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)), orNILif there were none. - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
method
Call named method onthiswith 0 arguments, including metatag processing, and return only the first return value.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument. and return only its first return value, dropping any others. Otherwise, look for theCALLmetatag 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
thisas a plain call, usecall()instead. -
method
Call named method onthiswith 0 arguments, including metatag processing, and return only the first return value.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return only its first return value, dropping any others. Otherwise, look for theCALLmetatag 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
thisas a plain call, usecall()instead. -
method
Call named method onthiswith 1 argument, including metatag processing, and return only the first return value.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return only its first return value, dropping any others. Otherwise, look for theCALLmetatag 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
thisas 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 aVarargsinstance - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
method
Call named method onthiswith 1 argument, including metatag processing, and return only the first return value.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return only its first return value, dropping any others. Otherwise, look for theCALLmetatag 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
thisas 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 aVarargsinstance - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
method
Call named method onthiswith 2 arguments, including metatag processing, and return only the first return value.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return only its first return value, dropping any others. Otherwise, look for theCALLmetatag 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
thisas 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 aVarargsinstance - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
method
Call named method onthiswith 2 arguments, including metatag processing, and return only the first return value.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return only its first return value, dropping any others. Otherwise, look for theCALLmetatag 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
thisas 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 aVarargsinstance - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
invoke
Callthiswith 0 arguments, including metatag processing, and retain all return values in aVarargs.If
thisis aLuaFunction, call it, and return all values. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas a method call, useinvokemethod(LuaValue)instead. -
invoke
Callthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.If
thisis aLuaFunction, call it, and return all values. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas a method call, useinvokemethod(LuaValue)instead. -
invoke
Callthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.If
thisis aLuaFunction, call it, and return all values. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas 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
Varargsinstance. - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
invoke
Callthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.If
thisis aLuaFunction, call it, and return all values. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas 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
Varargsinstance. - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
invoke
Callthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.If
thisis aLuaFunction, call it, and return all values. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas a method call, useinvokemethod(LuaValue,Varargs)instead. -
invoke
Callthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.If
thisis aLuaFunction, call it, and return all values. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas a method call, useinvokemethod(LuaValue,Varargs)instead.- Parameters:
args- Array of arguments to supply to the called functionvarargs- Varargs containing additional arguments to supply to the called function- Returns:
- All return values as a
Varargsinstance. - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
invokemethod
Call named method onthiswith 0 arguments, including metatag processing, and retain all return values in aVarargs.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return all return values as aVarargsinstance. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas a plain call, useinvoke()instead. -
invokemethod
Call named method onthiswith 0 arguments, including metatag processing, and retain all return values in aVarargs.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return all return values as aVarargsinstance. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas a plain call, useinvoke()instead. -
invokemethod
Call named method onthiswith 1 argument, including metatag processing, and retain all return values in aVarargs.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return all return values as aVarargsinstance. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas a plain call, useinvoke(Varargs)instead.- Parameters:
name- Name of the method to look up for invocationargs-Varargscontaining arguments to supply to the called function afterthis- Returns:
- All values returned from
this:name(args)as aVarargsinstance - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
invokemethod
Call named method onthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return all return values as aVarargsinstance. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas a plain call, useinvoke(Varargs)instead.- Parameters:
name- Name of the method to look up for invocationargs-Varargscontaining arguments to supply to the called function afterthis- Returns:
- All values returned from
this:name(args)as aVarargsinstance - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
invokemethod
Call named method onthiswith 1 argument, including metatag processing, and retain all return values in aVarargs.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return all return values as aVarargsinstance. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas a plain call, useinvoke(Varargs)instead.- Parameters:
name- Name of the method to look up for invocationargs- Array ofLuaValuecontaining arguments to supply to the called function afterthis- Returns:
- All values returned from
this:name(args)as aVarargsinstance - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror the invoked closure throw a luaerror- See Also:
-
invokemethod
Call named method onthiswith variable arguments, including metatag processing, and retain all return values in aVarargs.Look up
this[name]and if it is aLuaFunction, call it insertingthisas an additional first argument, and return all return values as aVarargsinstance. Otherwise, look for theCALLmetatag and call that.To get a particular return value, us
Varargs.arg(int)To call
thisas a plain call, useinvoke(Varargs)instead.- Parameters:
name- Name of the method to look up for invocationargs- Array ofLuaValuecontaining arguments to supply to the called function afterthis- Returns:
- All values returned from
this:name(args)as aVarargsinstance - Throws:
LuaError- if not a function andCALLis not defined, or the invoked function throws aLuaErroror 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
LuaBooleanif boolean or nil, numeric inverse asLuaNumberif numeric, or metatag processing result ifUNMmetatag is defined - Throws:
LuaError- ifthisis not a table or string, and has noUNMmetatag
-
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- ifthisis 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:
TRUEif values are comparable and(this != rhs),FALSEif comparable but equal, inverse ofLuaValueconverted toLuaBooleanif 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 aLuaUserdatavalue without metatag processing.- Parameters:
val- TheLuaUserdatato compare with.- Returns:
- true if
thisis 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 aLuaStringvalue 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
thisis aLuaNumberwhose 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
thisis aLuaNumberwhose 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
NILorFALSE - 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
LuaNumberor derive fromLuaStringand 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, orLuaValueif metatag processing occurs - Throws:
LuaError- if either operand is not a number or string convertible to number, and neither has theADDmetatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
add
Add: Perform numeric add operation with another value of double type with metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis not a number or string convertible to number- See Also:
-
add
Add: Perform numeric add operation with another value of int type with metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis 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
LuaNumberor derive fromLuaStringand 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, orLuaValueif metatag processing occurs - Throws:
LuaError- if either operand is not a number or string convertible to number, and neither has theSUBmetatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
sub
Subtract: Perform numeric subtract operation with another value of double type with metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis not a number or string convertible to number- See Also:
-
sub
Subtract: Perform numeric subtract operation with another value of int type with metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis not a number or string convertible to number- See Also:
-
subFrom
Reverse-subtract: Perform numeric subtract operation from an int value with metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis not a number or string convertible to number- See Also:
-
subFrom
Reverse-subtract: Perform numeric subtract operation from a double value without metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis 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
LuaNumberor derive fromLuaStringand 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, orLuaValueif metatag processing occurs - Throws:
LuaError- if either operand is not a number or string convertible to number, and neither has theMULmetatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
mul
Multiply: Perform numeric multiply operation with another value of double type with metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis not a number or string convertible to number- See Also:
-
mul
Multiply: Perform numeric multiply operation with another value of int type with metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis not a number or string convertible to number- See Also:
-
pow
Raise to power: Raise this value to a power including metatag processing.Each operand must derive from
LuaNumberor derive fromLuaStringand be convertible to a number- Parameters:
rhs- The power to raise this value to- Returns:
- value of
(this ^ rhs)if both are numeric, orLuaValueif metatag processing occurs - Throws:
LuaError- if either operand is not a number or string convertible to number, and neither has thePOWmetatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
pow
Raise to power: Raise this value to a power of double type with metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis 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 processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis 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 processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis 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 processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis 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
LuaNumberor derive fromLuaStringand 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, orLuaValueif metatag processing occurs - Throws:
LuaError- if either operand is not a number or string convertible to number, and neither has theDIVmetatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
div
Divide: Perform numeric divide operation by another value of double type without metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis not a number or string convertible to number- See Also:
-
div
Divide: Perform numeric divide operation by another value of int type without metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis not a number or string convertible to number- See Also:
-
divInto
Reverse-divide: Perform numeric divide operation into another value with metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis 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
LuaNumberor derive fromLuaStringand 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, orLuaValueif metatag processing occurs - Throws:
LuaError- if either operand is not a number or string convertible to number, and neither has theMODmetatag defined- See Also:
-
arithmt(LuaValue, LuaValue)
-
mod
Modulo: Perform numeric modulo operation with another value of double type without metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis not a number or string convertible to number- See Also:
-
mod
Modulo: Perform numeric modulo operation with another value of int type without metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis not a number or string convertible to number- See Also:
-
modFrom
Reverse-modulo: Perform numeric modulo operation from another value with metatag processingthismust derive fromLuaNumberor derive fromLuaStringand 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- ifthisis 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
LuaStringor 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
LuaStringor 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 noLTmetatag 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
LuaStringor 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 noLTmetatag 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
LuaStringor 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
LuaStringor 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 noLEmetatag 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
LuaStringor 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
LuaStringor 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 noLEmetatag 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
LuaStringor 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 noLEmetatag 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
LuaStringor 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
LuaStringor 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 noLTmetatag 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
LuaErrorif none applies.- Parameters:
tag- The metatag to look upop1- The operand with which to to perform the operation- Returns:
LuaValueresulting 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 aLuaStringusing 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
LuaStringorLuaNumber. -
concatTo
Reverse-concatenation: concatenate this value onto another value known to be aLuaNumberand 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
LuaStringorLuaNumber. -
concatTo
Reverse-concatenation: concatenate this value onto another value known to be aLuaStringand 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
LuaStringorLuaNumber. -
buffer
Convert the value to aBufferfor more efficient concatenation of multiple strings.- Returns:
- Buffer instance containing the string or number
-
concat
-
concatmt
-
and
Perform booleanandwith another operand, based on lua rules for boolean evaluation. This returns eitherthisorrhsdepending on the boolean value forthis.- Parameters:
rhs- The right-hand-side value to perform the operation with- Returns:
thisifthis.toboolean()is false,rhsotherwise.
-
or
Perform booleanorwith another operand, based on lua rules for boolean evaluation. This returns eitherthisorrhsdepending on the boolean value forthis.- Parameters:
rhs- The right-hand-side value to perform the operation with- Returns:
thisifthis.toboolean()is true,rhsotherwise.
-
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:
LuaIntegerinstance, possibly pooled, whose value is i
-
valueOf
Convert java double to aLuaValue. This may return aLuaIntegerorLuaDoubledepending on the value supplied.- Parameters:
d- double value to convert- Returns:
LuaNumberinstance, possibly pooled, whose value is d
-
valueOf
Convert java string to aLuaValue.- Parameters:
s- String value to convert- Returns:
LuaStringinstance, possibly pooled, whose value is s
-
valueOf
Convert bytes in an array to aLuaValue.- Parameters:
bytes- byte array to convert- Returns:
LuaStringinstance, possibly pooled, whose bytes are those in the supplied array
-
valueOf
Convert bytes in an array to aLuaValue. -
tableOf
Construct an emptyLuaTable.- Returns:
- new
LuaTableinstance with no values and no metatable.
-
tableOf
Construct aLuaTableinitialized with supplied array values. -
tableOf
Construct an emptyLuaTablepreallocated to hold array and hashed elements- Parameters:
narray- Number of array elements to preallocatenhash- Number of hash elements to preallocate- Returns:
- new
LuaTableinstance with no values and no metatable, but preallocated for array and hashed elements.
-
listOf
Construct aLuaTableinitialized with supplied array values. -
listOf
Construct aLuaTableinitialized with supplied array values.- Parameters:
unnamedValues- array ofLuaValuecontaining the first values to use in initializationlastarg-Varargscontaining additional values to use in initialization to be put after the last unnamedValues element- Returns:
- new
LuaTableinstance with sequential elements coming from the array and varargs.
-
tableOf
Construct aLuaTableinitialized with supplied named values. -
tableOf
Construct aLuaTableinitialized 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 ofLuaValuecontaining the keys and values to use in initialization in order{key-a, value-a, key-b, value-b, ...}unnamedValues- array ofLuaValuecontaining the sequenctial elements to use in initialization in order{value-1, value-2, ...}, or null if there are none- Returns:
- new
LuaTableinstance with named and sequential values supplied.
-
tableOf
Construct aLuaTableinitialized 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 ofLuaValuecontaining the keys and values to use in initialization in order{key-a, value-a, key-b, value-b, ...}unnamedValues- array ofLuaValuecontaining the first sequenctial elements to use in initialization in order{value-1, value-2, ...}, or null if there are nonelastarg-Varargscontaining additional values to use in the sequential part of the initialization, to be put after the last unnamedValues element- Returns:
- new
LuaTableinstance with named and sequential values supplied.
-
userdataOf
Construct a LuaUserdata for an object.- Parameters:
o- The java instance to be wrapped as userdata- Returns:
LuaUserdatavalue 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:
LuaUserdatavalue wrapping the java instance.
-
metatag
Get particular metatag, or returnNILif it doesn't exist -
varargsOf
-
cachedDouble
-
cachedInt
-
cachedVarargsOf
-
cachedVarargsOf
-
cachedVarargsOf
-
cachedVarargsOf
-
cachedVarargsOf
-
cachedVarargsOf
-
varargsOf
-
varargsOf
-
varargsOf
Construct aVarargsaround an array ofLuaValues. Caller must ensure that array contents are not mutated after this call or undefined behavior will result. -
varargsOf
-
varargsOf
-
tailcallOf
Construct aTailcallVarargsaround 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-LuaValueto be called as a tail callargs-Varargscontaining the arguments to the call- Returns:
TailcallVarargsto be used in tailcall oprocessing.- See Also:
-
onInvoke
Callback used during tail call processing to invoke the function once.This may return a
TailcallVarargsto 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 aVarargsinstance containing arguments starting at indexstart
-