Class LuaValue

java.lang.Object
com.prineside.luaj.Varargs
com.prineside.luaj.LuaValue
Direct Known Subclasses:
LuaBoolean, LuaFunction, LuaNil, LuaNumber, LuaString, LuaTable, LuaThread, LuaUserdata

public abstract class LuaValue extends Varargs
Base class for all concrete lua type values.

Establishes base implementations for all the operations on lua types. This allows Java clients to deal essentially with one type for all Java values, namely LuaValue.

Constructors are provided as static methods for common Java types, such as valueOf(int) or valueOf(String) to allow for instance pooling.

Constants are defined for the lua values NIL, TRUE, and FALSE. A constant NONE is defined which is a Varargs list having no values.

Operations are performed on values directly via their Java methods. For example, the following code divides two numbers:

 
 LuaValue a = LuaValue.valueOf( 5 );
 LuaValue b = LuaValue.valueOf( 4 );
 LuaValue c = a.div(b);
  
Note that in this example, c will be a LuaDouble, but would be a LuaInteger if the value of a were changed to 8, say. In general the value of c in practice will vary depending on both the types and values of a and b as well as any metatable/metatag processing that occurs.

Field access and function calls are similar, with common overloads to simplify Java usage:

 
 LuaValue globals = JsePlatform.standardGlobals();
 LuaValue sqrt = globals.get("math").get("sqrt");
 LuaValue print = globals.get("print");
 LuaValue d = sqrt.call( a );
 print.call( LuaValue.valueOf("sqrt(5):"), a );
  

To supply variable arguments or get multiple return values, use invoke(Varargs) or invokemethod(LuaValue, Varargs) methods:

 
 LuaValue modf = globals.get("math").get("modf");
 Varargs r = modf.invoke( d );
 print.call( r.arg(1), r.arg(2) );
  

To load and run a script, LoadState is used:

 
 LoadState.load( new FileInputStream("main.lua"), "main.lua", globals ).call();
  

although require could also be used:

 
 globals.get("require").call(LuaValue.valueOf("main"));
  
For this to work the file must be in the current directory, or in the class path, dependening on the platform.

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:

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.

See Also:
  • Field Details

    • NILLABLE_SERIALIZER

      public static final LuaValue.NillableSerializer NILLABLE_SERIALIZER
    • TINT

      public static final int TINT
      Type enumeration constant for lua numbers that are ints, for compatibility with lua 5.1 number patch only
      See Also:
    • TNONE

      public static final int TNONE
      Type enumeration constant for lua values that have no type, for example weak table entries
      See Also:
    • TNIL

      public static final int TNIL
      Type enumeration constant for lua nil
      See Also:
    • TBOOLEAN

      public static final int TBOOLEAN
      Type enumeration constant for lua booleans
      See Also:
    • TLIGHTUSERDATA

      public static final int TLIGHTUSERDATA
      Type enumeration constant for lua light userdata, for compatibility with C-based lua only
      See Also:
    • TNUMBER

      public static final int TNUMBER
      Type enumeration constant for lua numbers
      See Also:
    • TSTRING

      public static final int TSTRING
      Type enumeration constant for lua strings
      See Also:
    • TTABLE

      public static final int TTABLE
      Type enumeration constant for lua tables
      See Also:
    • TFUNCTION

      public static final int TFUNCTION
      Type enumeration constant for lua functions
      See Also:
    • TUSERDATA

      public static final int TUSERDATA
      Type enumeration constant for lua userdatas
      See Also:
    • TTHREAD

      public static final int TTHREAD
      Type enumeration constant for lua threads
      See Also:
    • TVALUE

      public static final int TVALUE
      Type enumeration constant for unknown values, for compatibility with C-based lua only
      See Also:
    • TYPE_NAMES

      public static final String[] TYPE_NAMES
      String array constant containing names of each of the lua value types
      See Also:
    • NIL

      public static final LuaValue NIL
      LuaValue constant corresponding to lua #NIL
    • TRUE

      public static final LuaBoolean TRUE
      LuaBoolean constant corresponding to lua true
    • FALSE

      public static final LuaBoolean FALSE
      LuaBoolean constant corresponding to lua false
    • NONE

      public static final LuaValue NONE
      LuaValue constant corresponding to a Varargs list of no values
    • ZERO

      public static final LuaNumber ZERO
      LuaValue number constant equal to 0
    • ONE

      public static final LuaNumber ONE
      LuaValue number constant equal to 1
    • MINUSONE

      public static final LuaNumber MINUSONE
      LuaValue number constant equal to -1
    • NOVALS

      public static final LuaValue[] NOVALS
      LuaValue array constant with no values
    • ENV

      public static LuaString ENV
      The variable name of the environment.
    • INDEX

      public static final LuaString INDEX
      LuaString constant with value "__index" for use as metatag
    • NEWINDEX

      public static final LuaString NEWINDEX
      LuaString constant with value "__newindex" for use as metatag
    • CALL

      public static final LuaString CALL
      LuaString constant with value "__call" for use as metatag
    • MODE

      public static final LuaString MODE
      LuaString constant with value "__mode" for use as metatag
    • METATABLE

      public static final LuaString METATABLE
      LuaString constant with value "__metatable" for use as metatag
    • ADD

      public static final LuaString ADD
      LuaString constant with value "__add" for use as metatag
    • SUB

      public static final LuaString SUB
      LuaString constant with value "__sub" for use as metatag
    • DIV

      public static final LuaString DIV
      LuaString constant with value "__div" for use as metatag
    • MUL

      public static final LuaString MUL
      LuaString constant with value "__mul" for use as metatag
    • POW

      public static final LuaString POW
      LuaString constant with value "__pow" for use as metatag
    • MOD

      public static final LuaString MOD
      LuaString constant with value "__mod" for use as metatag
    • UNM

      public static final LuaString UNM
      LuaString constant with value "__unm" for use as metatag
    • LEN

      public static final LuaString LEN
      LuaString constant with value "__len" for use as metatag
    • EQ

      public static final LuaString EQ
      LuaString constant with value "__eq" for use as metatag
    • LT

      public static final LuaString LT
      LuaString constant with value "__lt" for use as metatag
    • LE

      public static final LuaString LE
      LuaString constant with value "__le" for use as metatag
    • TOSTRING

      public static final LuaString TOSTRING
      LuaString constant with value "__tostring" for use as metatag
    • CONCAT

      public static final LuaString CONCAT
      LuaString constant with value "__concat" for use as metatag
    • EMPTYSTRING

      public static final LuaString EMPTYSTRING
      LuaString constant with value ""
    • NILS

      public static final LuaValue[] NILS
      Array of NIL 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.
      Returns:
      value for this type, one of TNIL, TBOOLEAN, TNUMBER, TSTRING, TTABLE, TFUNCTION, TUSERDATA, TTHREAD
      See Also:
    • typename

      public abstract String 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 if this is a boolean
      Returns:
      true if this is a boolean, otherwise false
      See Also:
    • isclosure

      public boolean isclosure()
      Check if this is a function 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 if this is a function
      Returns:
      true if this is a function, otherwise false
      See Also:
    • isint

      public boolean isint()
      Check if this is a number and is representable by java int without rounding or truncation
      Returns:
      true if this is a number meaning derives from LuaNumber or derives from LuaString and is convertible to a number, and can be represented by int, otherwise false
      See Also:
    • isinttype

      public boolean isinttype()
      Check if this is a LuaInteger

      No 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 if this is a number and is representable by java long without rounding or truncation
      Returns:
      true if this is a number meaning derives from LuaNumber or derives from LuaString and is convertible to a number, and can be represented by long, otherwise false
      See Also:
    • isnil

      public boolean isnil()
      Check if this is #NIL
      Returns:
      true if this is #NIL, otherwise false
      See Also:
    • isnumber

      public boolean isnumber()
      Check if this is a number
      Returns:
      true if this is a number, meaning derives from LuaNumber or derives from LuaString and is convertible to a number, otherwise false
      See Also:
    • isstring

      public boolean isstring()
      Check if this is a string
      Returns:
      true if this is a string, meaning derives from LuaString or LuaNumber, otherwise false
      See Also:
    • isthread

      public boolean isthread()
      Check if this is a thread
      Returns:
      true if this is a thread, otherwise false
      See Also:
    • istable

      public boolean istable()
      Check if this is a table
      Returns:
      true if this is a table, otherwise false
      See Also:
    • isuserdata

      public boolean isuserdata()
      Check if this is a userdata
      Returns:
      true if this is a userdata, otherwise false
      See Also:
    • isuserdata

      public boolean isuserdata(Class c)
      Check if this is a userdata of type c
      Parameters:
      c - Class to test instance against
      Returns:
      true if this is a userdata and the instance is assignable to c, otherwise false
      See Also:
    • toboolean

      public boolean toboolean()
      Convert to boolean false if NIL or FALSE, true if anything else
      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

      public String tojstring()
      Convert to human readable String for any type.
      Overrides:
      tojstring in class Varargs
      Returns:
      String for use by human readers based on type.
      See Also:
    • touserdata

      public Object touserdata()
      Convert to userdata instance, or null.
      Returns:
      userdata instance if userdata, or null if not LuaUserdata
      See Also:
    • touserdata

      public Object touserdata(Class c)
      Convert to userdata instance if specific type, or null.
      Returns:
      userdata instance if is a userdata whose instance derives from c, or null if not LuaUserdata
      See Also:
    • toString

      public String toString()
      Convert the value to a human readable string using tojstring()
      Overrides:
      toString in class Varargs
      Returns:
      String value intended to be human readible.
      See Also:
    • tonumber

      public LuaValue 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, and NIL for all other cases.

      This allows values to be tested for their "numeric-ness" without the penalty of throwing exceptions, nor the cost of converting the type and creating storage for it.

      Returns:
      this if it is a LuaNumber or LuaString that can be converted to a number, otherwise NIL
      See Also:
    • tostring

      public LuaValue 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, and NIL for all other cases.

      This allows values to be tested for their "string-ness" without the penalty of throwing exceptions.

      Returns:
      this if it is a LuaString or LuaNumber, otherwise NIL
      See Also:
    • optboolean

      public boolean optboolean(boolean defval)
      Check that optional argument is a boolean and return its boolean value
      Parameters:
      defval - boolean value to return if this is nil or none
      Returns:
      this cast to boolean if a LuaBoolean, defval if nil or none, throws LuaError otherwise
      Throws:
      LuaError - if was not a boolean or nil or none.
      See Also:
    • optclosure

      public LuaClosure optclosure(LuaClosure defval)
      Check that optional argument is a closure and return as LuaClosure

      A LuaClosure is a LuaFunction that executes lua byteccode.

      Parameters:
      defval - LuaClosure to return if this is nil or none
      Returns:
      this cast to LuaClosure if a function, defval if nil or none, throws LuaError 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
      Parameters:
      defval - double to return if this is nil or none
      Returns:
      this cast to double if numeric, defval if nil or none, throws LuaError otherwise
      Throws:
      LuaError - if was not numeric or nil or none.
      See Also:
    • optfunction

      public LuaFunction optfunction(LuaFunction defval)
      Check that optional argument is a function and return as LuaFunction

      A LuaFunction may either be a Java function that implements functionality directly in Java, or a LuaClosure which is a LuaFunction that executes lua bytecode.

      Parameters:
      defval - LuaFunction to return if this is nil or none
      Returns:
      this cast to LuaFunction if a function, defval if nil or none, throws LuaError 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
      Parameters:
      defval - int to return if this is nil or none
      Returns:
      this cast to int if numeric, defval if nil or none, throws LuaError otherwise
      Throws:
      LuaError - if was not numeric or nil or none.
      See Also:
    • optinteger

      public LuaInteger optinteger(LuaInteger defval)
      Check that optional argument is a number or string convertible to number and return as LuaInteger
      Parameters:
      defval - LuaInteger to return if this is nil or none
      Returns:
      this converted and wrapped in LuaInteger if numeric, defval if nil or none, throws LuaError otherwise
      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
      Parameters:
      defval - long to return if this is nil or none
      Returns:
      this cast to long if numeric, defval if nil or none, throws LuaError otherwise
      Throws:
      LuaError - if was not numeric or nil or none.
      See Also:
    • optnumber

      public LuaNumber optnumber(LuaNumber defval)
      Check that optional argument is a number or string convertible to number and return as LuaNumber
      Parameters:
      defval - LuaNumber to return if this is nil or none
      Returns:
      this cast to LuaNumber if numeric, defval if nil or none, throws LuaError otherwise
      Throws:
      LuaError - if was not numeric or nil or none.
      See Also:
    • optjstring

      public String optjstring(String defval)
      Check that optional argument is a string or number and return as Java String
      Parameters:
      defval - LuaString to return if this is nil or none
      Returns:
      this converted to String if a string or number, defval if nil or none, throws LuaError if some other type
      Throws:
      LuaError - if was not a string or number or nil or none.
      See Also:
    • optstring

      public LuaString optstring(LuaString defval)
      Check that optional argument is a string or number and return as LuaString
      Parameters:
      defval - LuaString to return if this is nil or none
      Returns:
      this converted to LuaString if a string or number, defval if nil or none, throws LuaError if some other type
      Throws:
      LuaError - if was not a string or number or nil or none.
      See Also:
    • opttable

      public LuaTable opttable(LuaTable defval)
      Check that optional argument is a table and return as LuaTable
      Parameters:
      defval - LuaTable to return if this is nil or none
      Returns:
      this cast to LuaTable if a table, defval if nil or none, throws LuaError if some other type
      Throws:
      LuaError - if was not a table or nil or none.
      See Also:
    • optthread

      public LuaThread optthread(LuaThread defval)
      Check that optional argument is a thread and return as LuaThread
      Parameters:
      defval - LuaThread to return if this is nil or none
      Returns:
      this cast to LuaTable if a thread, defval if nil or none, throws LuaError if some other type
      Throws:
      LuaError - if was not a thread or nil or none.
      See Also:
    • optuserdata

      public Object optuserdata(Object defval)
      Check that optional argument is a userdata and return the Object instance
      Parameters:
      defval - Object to return if this is nil or none
      Returns:
      Object instance of the userdata if a LuaUserdata, defval if nil or none, throws LuaError if some other type
      Throws:
      LuaError - if was not a userdata or nil or none.
      See Also:
    • optuserdata

      public Object optuserdata(Class c, Object defval)
      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 against
      defval - Object to return if this is nil or none
      Returns:
      Object instance of the userdata if a LuaUserdata and instance is assignable to c, defval if nil or none, throws LuaError if some other type
      Throws:
      LuaError - if was not a userdata whose instance is assignable to c or nil or none.
      See Also:
    • optvalue

      public LuaValue optvalue(LuaValue defval)
      Perform argument check that this is not nil or none.
      Parameters:
      defval - LuaValue to return if this is nil or none
      Returns:
      this if not nil or none, else defval
      See Also:
    • checkboolean

      public boolean checkboolean()
      Check that the value is a LuaBoolean, or throw LuaError if not
      Returns:
      boolean value for this if it is a LuaBoolean
      Throws:
      LuaError - if not a LuaBoolean
      See Also:
    • checkclosure

      public LuaClosure checkclosure()
      Check that the value is a LuaClosure , or throw LuaError if not

      LuaClosure is a subclass of LuaFunction that interprets lua bytecode.

      Returns:
      this cast as LuaClosure
      Throws:
      LuaError - if not a LuaClosure
      See Also:
    • checkdouble

      public double checkdouble()
      Check that the value is numeric and return the value as a double, or throw LuaError if not numeric

      Values that are LuaNumber and values that are LuaString that can be converted to a number will be converted to double.

      Returns:
      value cast to a double if numeric
      Throws:
      LuaError - if not a LuaNumber or is a LuaString that can't be converted to number
      See Also:
    • checkfunction

      public LuaFunction checkfunction()
      Check that the value is a function , or throw LuaError if not

      A LuaFunction may either be a Java function that implements functionality directly in Java, or a LuaClosure which is a LuaFunction that executes lua bytecode.

      Returns:
      this if it is a lua function or closure
      Throws:
      LuaError - if not a function
      See Also:
    • checkglobals

      public Globals checkglobals()
      Check that the value is a Globals instance, or throw LuaError if not

      Globals are a special LuaTable that establish the default global environment.

      Returns:
      this if if an instance fof Globals
      Throws:
      LuaError - if not a Globals instance.
    • checkint

      public int checkint()
      Check that the value is numeric, and convert and cast value to int, or throw LuaError if not numeric

      Values that are LuaNumber will be cast to int and may lose precision. Values that are LuaString that can be converted to a number will be converted, then cast to int, so may also lose precision.

      Returns:
      value cast to a int if numeric
      Throws:
      LuaError - if not a LuaNumber or is a LuaString that can't be converted to number
      See Also:
    • checkinteger

      public LuaInteger checkinteger()
      Check that the value is numeric, and convert and cast value to int, or throw LuaError if not numeric

      Values that are LuaNumber will be cast to int and may lose precision. Values that are LuaString that can be converted to a number will be converted, then cast to int, so may also lose precision.

      Returns:
      value cast to a int and wrapped in LuaInteger if numeric
      Throws:
      LuaError - if not a LuaNumber or is a LuaString that 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 throw LuaError if not numeric

      Values that are LuaNumber will be cast to long and may lose precision. Values that are LuaString that can be converted to a number will be converted, then cast to long, so may also lose precision.

      Returns:
      value cast to a long if numeric
      Throws:
      LuaError - if not a LuaNumber or is a LuaString that can't be converted to number
      See Also:
    • checknumber

      public LuaNumber checknumber()
      Check that the value is numeric, and return as a LuaNumber if so, or throw LuaError

      Values that are LuaString that can be converted to a number will be converted and returned.

      Returns:
      value as a LuaNumber if numeric
      Throws:
      LuaError - if not a LuaNumber or is a LuaString that can't be converted to number
      See Also:
    • checknumber

      public LuaNumber checknumber(String msg)
      Check that the value is numeric, and return as a LuaNumber if so, or throw LuaError

      Values that are LuaString that can be converted to a number will be converted and returned.

      Parameters:
      msg - String message to supply if conversion fails
      Returns:
      value as a LuaNumber if numeric
      Throws:
      LuaError - if not a LuaNumber or is a LuaString that can't be converted to number
      See Also:
    • checkjstring

      public String 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

      public LuaString checkstring()
      Check that this is a lua string, or throw LuaError if it is not.

      In lua all numbers are strings, so this will succeed for anything that derives from LuaString or LuaNumber. Numbers will be converted to LuaString.

      Returns:
      LuaString representation of the value if it is a LuaString or LuaNumber
      Throws:
      LuaError - if this is not a LuaTable
      See Also:
    • checktable

      public LuaTable checktable()
      Check that this is a LuaTable, or throw LuaError if it is not
      Returns:
      this if it is a LuaTable
      Throws:
      LuaError - if this is not a LuaTable
      See Also:
    • checkthread

      public LuaThread checkthread()
      Check that this is a LuaThread, or throw LuaError if it is not
      Returns:
      this if it is a LuaThread
      Throws:
      LuaError - if this is not a LuaThread
      See Also:
    • checkuserdata

      public Object checkuserdata()
      Check that this is a LuaUserdata, or throw LuaError if it is not
      Returns:
      this if it is a LuaUserdata
      Throws:
      LuaError - if this is not a LuaUserdata
      See Also:
    • checkuserdata

      public Object checkuserdata(Class c)
      Check that this is a LuaUserdata, or throw LuaError if it is not
      Returns:
      this if it is a LuaUserdata
      Throws:
      LuaError - if this is not a LuaUserdata
      See Also:
    • checknotnil

      public LuaValue checknotnil()
      Check that this is not the value NIL, or throw LuaError if it is
      Returns:
      this if it is not NIL
      Throws:
      LuaError - if this is NIL
      See Also:
    • 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

      public static LuaValue error(String message)
      Throw a LuaError with a particular message
      Parameters:
      message - String providing message details
      Throws:
      LuaError - in all cases
    • assert_

      public static void assert_(boolean b, String msg)
      Assert a condition is true, or throw a LuaError if not Returns no value when b is true, throws error(String) with msg as argument and does not return if b is false.
      Parameters:
      b - condition to test
      msg - String message to produce on failure
      Throws:
      LuaError - if b is not true
    • argerror

      public static LuaValue argerror(int iarg, String msg)
      Throw a LuaError indicating an invalid argument was supplied to a function
      Parameters:
      iarg - index of the argument that was invalid, first index is 1
      msg - String providing information about the invalid argument
      Throws:
      LuaError - in all cases
    • get

      public LuaValue get(LuaValue key)
      Get a value in a table including metatag processing using INDEX.
      Parameters:
      key - the key to look up, must not be NIL or null
      Returns:
      LuaValue for that key, or NIL if not found and no metatag
      Throws:
      LuaError - if this is not a table, or there is no INDEX metatag, or key is NIL
      See Also:
    • get

      public LuaValue get(int key)
      Get a value in a table including metatag processing using INDEX.
      Parameters:
      key - the key to look up
      Returns:
      LuaValue for that key, or NIL if not found
      Throws:
      LuaError - if this is not a table, or there is no INDEX metatag
      See Also:
    • get

      public LuaValue get(String key)
      Get a value in a table including metatag processing using INDEX.
      Parameters:
      key - the key to look up, must not be null
      Returns:
      LuaValue for that key, or NIL if not found
      Throws:
      LuaError - if this is not a table, or there is no INDEX metatag
      See Also:
    • set

      public void set(LuaValue key, LuaValue value)
      Set a value in a table without metatag processing using NEWINDEX.
      Parameters:
      key - the key to use, must not be NIL or null
      value - the value to use, can be NIL, must not be null
      Throws:
      LuaError - if this is not a table, or key is NIL, or there is no NEWINDEX metatag
    • set

      public void set(int key, LuaValue value)
      Set a value in a table without metatag processing using NEWINDEX.
      Parameters:
      key - the key to use
      value - the value to use, can be NIL, must not be null
      Throws:
      LuaError - if this is not a table, or there is no NEWINDEX metatag
    • set

      public void set(int key, String value)
      Set a value in a table without metatag processing using NEWINDEX.
      Parameters:
      key - the key to use
      value - the value to use, must not be null
      Throws:
      LuaError - if this is not a table, or there is no NEWINDEX metatag
    • set

      public void set(String key, LuaValue value)
      Set a value in a table without metatag processing using NEWINDEX.
      Parameters:
      key - the key to use, must not be NIL or null
      value - the value to use, can be NIL, must not be null
      Throws:
      LuaError - if this is not a table, or there is no NEWINDEX metatag
    • set

      public void set(String key, double value)
      Set a value in a table without metatag processing using NEWINDEX.
      Parameters:
      key - the key to use, must not be null
      value - the value to use
      Throws:
      LuaError - if this is not a table, or there is no NEWINDEX metatag
    • set

      public void set(String key, int value)
      Set a value in a table without metatag processing using NEWINDEX.
      Parameters:
      key - the key to use, must not be null
      value - the value to use
      Throws:
      LuaError - if this is not a table, or there is no NEWINDEX metatag
    • set

      public void set(String key, String value)
      Set a value in a table without metatag processing using NEWINDEX.
      Parameters:
      key - the key to use, must not be null
      value - the value to use, must not be null
      Throws:
      LuaError - if this is not a table, or there is no NEWINDEX metatag
    • rawget

      public LuaValue rawget(LuaValue key)
      Get a value in a table without metatag processing.
      Parameters:
      key - the key to look up, must not be NIL or null
      Returns:
      LuaValue for that key, or NIL if not found
      Throws:
      LuaError - if this is not a table, or key is NIL
    • rawget

      public LuaValue rawget(int key)
      Get a value in a table without metatag processing.
      Parameters:
      key - the key to look up
      Returns:
      LuaValue for that key, or NIL if not found
      Throws:
      LuaError - if this is not a table
    • rawget

      public LuaValue rawget(String key)
      Get a value in a table without metatag processing.
      Parameters:
      key - the key to look up, must not be null
      Returns:
      LuaValue for that key, or NIL if not found
      Throws:
      LuaError - if this is not a table
    • rawset

      public void rawset(LuaValue key, LuaValue value)
      Set a value in a table without metatag processing.
      Parameters:
      key - the key to use, must not be NIL or null
      value - the value to use, can be NIL, must not be null
      Throws:
      LuaError - if this is not a table, or key is NIL
    • rawset

      public void rawset(int key, LuaValue value)
      Set a value in a table without metatag processing.
      Parameters:
      key - the key to use
      value - the value to use, can be NIL, must not be null
      Throws:
      LuaError - if this is not a table
    • rawset

      public void rawset(int key, String value)
      Set a value in a table without metatag processing.
      Parameters:
      key - the key to use
      value - the value to use, can be NIL, must not be null
      Throws:
      LuaError - if this is not a table
    • rawset

      public void rawset(String key, LuaValue value)
      Set a value in a table without metatag processing.
      Parameters:
      key - the key to use, must not be null
      value - the value to use, can be NIL, must not be null
      Throws:
      LuaError - if this is not a table
    • rawset

      public void rawset(String key, double value)
      Set a value in a table without metatag processing.
      Parameters:
      key - the key to use, must not be null
      value - the value to use
      Throws:
      LuaError - if this is not a table
    • rawset

      public void rawset(String key, int value)
      Set a value in a table without metatag processing.
      Parameters:
      key - the key to use, must not be null
      value - the value to use
      Throws:
      LuaError - if this is not a table
    • rawset

      public void rawset(String key, String value)
      Set a value in a table without metatag processing.
      Parameters:
      key - the key to use, must not be null
      value - the value to use, must not be null
      Throws:
      LuaError - if this is not a table
    • rawsetlist

      public void rawsetlist(int key0, Varargs values)
      Set list values in a table without invoking metatag processing

      Primarily used internally in response to a SETLIST bytecode.

      Parameters:
      key0 - the first key to set in the table
      values - 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

      public Varargs next(LuaValue index)
      Find the next key,value pair if this is a table, return NIL if there are no more, or throw a LuaError if not a table.

      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 - LuaInteger value identifying a key to start from, or NIL to start at the beginning
      Returns:
      Varargs containing {key,value} for the next entry, or NIL if there are no more.
      Throws:
      LuaError - if this is not a table, or the supplied key is invalid.
      See Also:
    • inext

      public Varargs inext(LuaValue index)
      Find the next integer-key,value pair if this is a table, return NIL if there are no more, or throw a LuaError if not a table.

      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 - LuaInteger value identifying a key to start from, or NIL to start at the beginning
      Returns:
      Varargs containing (key,value) for the next entry, or NONE if there are no more.
      Throws:
      LuaError - if this is not a table, or the supplied key is invalid.
      See Also:
    • load

      public LuaValue load(LuaValue library)
      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.
      Parameters:
      library - The callable LuaValue to load into this
      Returns:
      LuaValue returned by the initialization call.
    • arg

      public LuaValue arg(int index)
      Description copied from class: Varargs
      Get the n-th argument value (1-based).
      Specified by:
      arg in class Varargs
      Parameters:
      index - the index of the argument to get, 1 is the first argument
      Returns:
      Value at position i, or LuaValue.NIL if there is none.
      See Also:
    • narg

      public int narg()
      Description copied from class: Varargs
      Get the number of arguments, or 0 if there are none.
      Specified by:
      narg in class Varargs
      Returns:
      number of arguments.
    • arg1

      public LuaValue arg1()
      Description copied from class: Varargs
      Get the first argument in the list.
      Specified by:
      arg1 in class Varargs
      Returns:
      LuaValue which is first in the list, or LuaValue.NIL if there are no values.
      See Also:
    • getmetatable

      public LuaValue getmetatable()
      Get the metatable for this LuaValue

      For LuaTable and LuaUserdata 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
      See Also:
    • setmetatable

      public LuaValue setmetatable(LuaValue metatable)
      Set the metatable for this LuaValue

      For LuaTable and LuaUserdata instances, the metatable is per instance. For all other types, there is one metatable per type that can be set directly from java

      Parameters:
      metatable - LuaValue instance to serve as the metatable, or null to reset it.
      Returns:
      this to allow chaining of Java function calls
      See Also:
    • call

      public LuaValue call()
      Call this with 0 arguments, including metatag processing, and return only the first return value.

      If this is a LuaFunction, call it, and return only its first return value, dropping any others. Otherwise, look for the CALL metatag and call that.

      If the return value is a Varargs, only the 1st value will be returned. To get multiple values, use invoke() instead.

      To call this as a method call, use method(LuaValue) instead.

      Returns:
      First return value (this()), or NIL if there were none.
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • call

      public LuaValue call(LuaValue arg)
      Call this with 1 argument, including metatag processing, and return only the first return value.

      If this is a LuaFunction, call it, and return only its first return value, dropping any others. Otherwise, look for the CALL metatag and call that.

      If the return value is a Varargs, only the 1st value will be returned. To get multiple values, use invoke() instead.

      To call this as a method call, use method(LuaValue) instead.

      Parameters:
      arg - First argument to supply to the called function
      Returns:
      First return value (this(arg)), or NIL if there were none.
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • call

      public LuaValue call(String arg)
      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

      public LuaValue call(LuaValue arg1, LuaValue arg2)
      Call this with 2 arguments, including metatag processing, and return only the first return value.

      If this is a LuaFunction, call it, and return only its first return value, dropping any others. Otherwise, look for the CALL metatag and call that.

      If the return value is a Varargs, only the 1st value will be returned. To get multiple values, use invoke() instead.

      To call this as a method call, use method(LuaValue) instead.

      Parameters:
      arg1 - First argument to supply to the called function
      arg2 - Second argument to supply to the called function
      Returns:
      First return value (this(arg1,arg2)), or NIL if there were none.
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • call

      public LuaValue call(LuaValue arg1, LuaValue arg2, LuaValue arg3)
      Call this with 3 arguments, including metatag processing, and return only the first return value.

      If this is a LuaFunction, call it, and return only its first return value, dropping any others. Otherwise, look for the CALL metatag and call that.

      If the return value is a Varargs, only the 1st value will be returned. To get multiple values, use invoke() instead.

      To call this as a method call, use method(LuaValue) instead.

      Parameters:
      arg1 - First argument to supply to the called function
      arg2 - Second argument to supply to the called function
      arg3 - Second argument to supply to the called function
      Returns:
      First return value (this(arg1,arg2,arg3)), or NIL if there were none.
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • method

      public LuaValue method(String name)
      Call named method on this with 0 arguments, including metatag processing, and return only the first return value.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument. and return only its first return value, dropping any others. Otherwise, look for the CALL metatag and call that.

      If the return value is a Varargs, only the 1st value will be returned. To get multiple values, use invoke() instead.

      To call this as a plain call, use call() instead.

      Parameters:
      name - Name of the method to look up for invocation
      Returns:
      All values returned from this:name() as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • method

      public LuaValue method(LuaValue name)
      Call named method on this with 0 arguments, including metatag processing, and return only the first return value.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return only its first return value, dropping any others. Otherwise, look for the CALL metatag and call that.

      If the return value is a Varargs, only the 1st value will be returned. To get multiple values, use invoke() instead.

      To call this as a plain call, use call() instead.

      Parameters:
      name - Name of the method to look up for invocation
      Returns:
      All values returned from this:name() as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • method

      public LuaValue method(String name, LuaValue arg)
      Call named method on this with 1 argument, including metatag processing, and return only the first return value.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return only its first return value, dropping any others. Otherwise, look for the CALL metatag and call that.

      If the return value is a Varargs, only the 1st value will be returned. To get multiple values, use invoke() instead.

      To call this as a plain call, use call(LuaValue) instead.

      Parameters:
      name - Name of the method to look up for invocation
      arg - Argument to supply to the method
      Returns:
      All values returned from this:name(arg) as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • method

      public LuaValue method(LuaValue name, LuaValue arg)
      Call named method on this with 1 argument, including metatag processing, and return only the first return value.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return only its first return value, dropping any others. Otherwise, look for the CALL metatag and call that.

      If the return value is a Varargs, only the 1st value will be returned. To get multiple values, use invoke() instead.

      To call this as a plain call, use call(LuaValue) instead.

      Parameters:
      name - Name of the method to look up for invocation
      arg - Argument to supply to the method
      Returns:
      All values returned from this:name(arg) as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • method

      public LuaValue method(String name, LuaValue arg1, LuaValue arg2)
      Call named method on this with 2 arguments, including metatag processing, and return only the first return value.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return only its first return value, dropping any others. Otherwise, look for the CALL metatag and call that.

      If the return value is a Varargs, only the 1st value will be returned. To get multiple values, use invoke() instead.

      To call this as a plain call, use call(LuaValue,LuaValue) instead.

      Parameters:
      name - Name of the method to look up for invocation
      arg1 - First argument to supply to the method
      arg2 - Second argument to supply to the method
      Returns:
      All values returned from this:name(arg1,arg2) as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • method

      public LuaValue method(LuaValue name, LuaValue arg1, LuaValue arg2)
      Call named method on this with 2 arguments, including metatag processing, and return only the first return value.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return only its first return value, dropping any others. Otherwise, look for the CALL metatag and call that.

      If the return value is a Varargs, only the 1st value will be returned. To get multiple values, use invoke() instead.

      To call this as a plain call, use call(LuaValue,LuaValue) instead.

      Parameters:
      name - Name of the method to look up for invocation
      arg1 - First argument to supply to the method
      arg2 - Second argument to supply to the method
      Returns:
      All values returned from this:name(arg1,arg2) as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invoke

      public Varargs invoke()
      Call this with 0 arguments, including metatag processing, and retain all return values in a Varargs.

      If this is a LuaFunction, call it, and return all values. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a method call, use invokemethod(LuaValue) instead.

      Returns:
      All return values as a Varargs instance.
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invoke

      public Varargs invoke(Varargs args)
      Call this with variable arguments, including metatag processing, and retain all return values in a Varargs.

      If this is a LuaFunction, call it, and return all values. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a method call, use invokemethod(LuaValue) instead.

      Parameters:
      args - Varargs containing the arguments to supply to the called function
      Returns:
      All return values as a Varargs instance.
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invoke

      public Varargs invoke(LuaValue arg, Varargs varargs)
      Call this with variable arguments, including metatag processing, and retain all return values in a Varargs.

      If this is a LuaFunction, call it, and return all values. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a method call, use invokemethod(LuaValue,Varargs) instead.

      Parameters:
      arg - The first argument to supply to the called function
      varargs - 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 and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invoke

      public Varargs invoke(LuaValue arg1, LuaValue arg2, Varargs varargs)
      Call this with variable arguments, including metatag processing, and retain all return values in a Varargs.

      If this is a LuaFunction, call it, and return all values. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a method call, use invokemethod(LuaValue,Varargs) instead.

      Parameters:
      arg1 - The first argument to supply to the called function
      arg2 - The second argument to supply to the called function
      varargs - 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 and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invoke

      public Varargs invoke(LuaValue[] args)
      Call this with variable arguments, including metatag processing, and retain all return values in a Varargs.

      If this is a LuaFunction, call it, and return all values. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a method call, use invokemethod(LuaValue,Varargs) instead.

      Parameters:
      args - Array of arguments to supply to the called function
      Returns:
      All return values as a Varargs instance.
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invoke

      public Varargs invoke(LuaValue[] args, Varargs varargs)
      Call this with variable arguments, including metatag processing, and retain all return values in a Varargs.

      If this is a LuaFunction, call it, and return all values. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a method call, use invokemethod(LuaValue,Varargs) instead.

      Parameters:
      args - Array of arguments to supply to the called function
      varargs - Varargs containing additional arguments to supply to the called function
      Returns:
      All return values as a Varargs instance.
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invokemethod

      public Varargs invokemethod(String name)
      Call named method on this with 0 arguments, including metatag processing, and retain all return values in a Varargs.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return all return values as a Varargs instance. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a plain call, use invoke() instead.

      Parameters:
      name - Name of the method to look up for invocation
      Returns:
      All values returned from this:name() as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invokemethod

      public Varargs invokemethod(LuaValue name)
      Call named method on this with 0 arguments, including metatag processing, and retain all return values in a Varargs.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return all return values as a Varargs instance. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a plain call, use invoke() instead.

      Parameters:
      name - Name of the method to look up for invocation
      Returns:
      All values returned from this:name() as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invokemethod

      public Varargs invokemethod(String name, Varargs args)
      Call named method on this with 1 argument, including metatag processing, and retain all return values in a Varargs.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return all return values as a Varargs instance. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a plain call, use invoke(Varargs) instead.

      Parameters:
      name - Name of the method to look up for invocation
      args - Varargs containing arguments to supply to the called function after this
      Returns:
      All values returned from this:name(args) as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invokemethod

      public Varargs invokemethod(LuaValue name, Varargs args)
      Call named method on this with variable arguments, including metatag processing, and retain all return values in a Varargs.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return all return values as a Varargs instance. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a plain call, use invoke(Varargs) instead.

      Parameters:
      name - Name of the method to look up for invocation
      args - Varargs containing arguments to supply to the called function after this
      Returns:
      All values returned from this:name(args) as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invokemethod

      public Varargs invokemethod(String name, LuaValue[] args)
      Call named method on this with 1 argument, including metatag processing, and retain all return values in a Varargs.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return all return values as a Varargs instance. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a plain call, use invoke(Varargs) instead.

      Parameters:
      name - Name of the method to look up for invocation
      args - Array of LuaValue containing arguments to supply to the called function after this
      Returns:
      All values returned from this:name(args) as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • invokemethod

      public Varargs invokemethod(LuaValue name, LuaValue[] args)
      Call named method on this with variable arguments, including metatag processing, and retain all return values in a Varargs.

      Look up this[name] and if it is a LuaFunction, call it inserting this as an additional first argument, and return all return values as a Varargs instance. Otherwise, look for the CALL metatag and call that.

      To get a particular return value, us Varargs.arg(int)

      To call this as a plain call, use invoke(Varargs) instead.

      Parameters:
      name - Name of the method to look up for invocation
      args - Array of LuaValue containing arguments to supply to the called function after this
      Returns:
      All values returned from this:name(args) as a Varargs instance
      Throws:
      LuaError - if not a function and CALL is not defined, or the invoked function throws a LuaError or the invoked closure throw a lua error
      See Also:
    • not

      public LuaValue not()
      Unary not: return inverse boolean value (~this) as defined by lua not operator
      Returns:
      TRUE if NIL or FALSE, otherwise FALSE
    • neg

      public LuaValue 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 as LuaNumber if numeric, or metatag processing result if UNM metatag is defined
      Throws:
      LuaError - if this is not a table or string, and has no UNM metatag
    • len

      public LuaValue len()
      Length operator: return lua length of object (#this) including metatag processing as java int
      Returns:
      length as defined by the lua # operator or metatag processing result
      Throws:
      LuaError - if this is not a table or string, and has no LEN metatag
    • length

      public int length()
      Length operator: return lua length of object (#this) including metatag processing as java int
      Returns:
      length as defined by the lua # operator or metatag processing result converted to java int using toint()
      Throws:
      LuaError - if this is not a table or string, and has no LEN metatag
    • rawlen

      public int rawlen()
      Get raw length of table or string without metatag processing.
      Returns:
      the length of the table or string.
      Throws:
      LuaError - if this is not a table or string.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • eq

      public LuaValue eq(LuaValue val)
      Equals: Perform equality comparison with another value including metatag processing using EQ.
      Parameters:
      val - The value to compare with.
      Returns:
      TRUE if values are comparable and (this == rhs), FALSE if comparable but not equal, LuaValue if metatag processing occurs.
      See Also:
    • eq_b

      public boolean eq_b(LuaValue val)
      Equals: Perform equality comparison with another value including metatag processing using EQ, 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

      public LuaValue neq(LuaValue val)
      Notquals: Perform inequality comparison with another value including metatag processing using EQ.
      Parameters:
      val - The value to compare with.
      Returns:
      TRUE if values are comparable and (this != rhs), FALSE if comparable but equal, inverse of LuaValue converted to LuaBoolean if metatag processing occurs.
      See Also:
    • neq_b

      public boolean neq_b(LuaValue val)
      Notquals: Perform inequality comparison with another value including metatag processing using EQ.
      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

      public boolean raweq(LuaValue val)
      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

      public boolean raweq(LuaUserdata val)
      Equals: Perform direct equality comparison with a LuaUserdata value without metatag processing.
      Parameters:
      val - The LuaUserdata to compare with.
      Returns:
      true if this is userdata and their metatables are the same using == and their instances are equal using equals(Object), otherwise false
      See Also:
    • raweq

      public boolean raweq(LuaString val)
      Equals: Perform direct equality comparison with a LuaString value without metatag processing.
      Parameters:
      val - The LuaString to compare with.
      Returns:
      true if this is a LuaString and their byte sequences match, otherwise false
    • 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 a LuaNumber 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 a LuaNumber whose value equals val, otherwise false
    • eqmtcall

      public static final boolean eqmtcall(LuaValue lhs, LuaValue lhsmt, LuaValue rhs, LuaValue rhsmt)
      Perform equality testing metatag processing
      Parameters:
      lhs - left-hand-side of equality expression
      lhsmt - metatag value for left-hand-side
      rhs - right-hand-side of equality expression
      rhsmt - metatag value for right-hand-side
      Returns:
      true if metatag processing result is not NIL or FALSE
      Throws:
      LuaError - if metatag was not defined for either operand
      See Also:
    • add

      public LuaValue add(LuaValue rhs)
      Add: Perform numeric add operation with another value including metatag processing.

      Each operand must derive from LuaNumber or derive from LuaString 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, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if either operand is not a number or string convertible to number, and neither has the ADD metatag defined
      See Also:
      • arithmt(LuaValue, LuaValue)
    • add

      public LuaValue add(double rhs)
      Add: Perform numeric add operation with another value of double type with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • add

      public LuaValue add(int rhs)
      Add: Perform numeric add operation with another value of int type with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • sub

      public LuaValue sub(LuaValue rhs)
      Subtract: Perform numeric subtract operation with another value of unknown type, including metatag processing.

      Each operand must derive from LuaNumber or derive from LuaString 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, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if either operand is not a number or string convertible to number, and neither has the SUB metatag defined
      See Also:
      • arithmt(LuaValue, LuaValue)
    • sub

      public LuaValue sub(double rhs)
      Subtract: Perform numeric subtract operation with another value of double type with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • sub

      public LuaValue sub(int rhs)
      Subtract: Perform numeric subtract operation with another value of int type with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • subFrom

      public LuaValue subFrom(double lhs)
      Reverse-subtract: Perform numeric subtract operation from an int value with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • subFrom

      public LuaValue subFrom(int lhs)
      Reverse-subtract: Perform numeric subtract operation from a double value without metatag processing

      this must derive from LuaNumber or derive from LuaString and be convertible to a number

      For 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 - if this is not a number or string convertible to number
      See Also:
    • mul

      public LuaValue mul(LuaValue rhs)
      Multiply: Perform numeric multiply operation with another value of unknown type, including metatag processing.

      Each operand must derive from LuaNumber or derive from LuaString 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, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if either operand is not a number or string convertible to number, and neither has the MUL metatag defined
      See Also:
      • arithmt(LuaValue, LuaValue)
    • mul

      public LuaValue mul(double rhs)
      Multiply: Perform numeric multiply operation with another value of double type with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • mul

      public LuaValue mul(int rhs)
      Multiply: Perform numeric multiply operation with another value of int type with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • pow

      public LuaValue pow(LuaValue rhs)
      Raise to power: Raise this value to a power including metatag processing.

      Each operand must derive from LuaNumber or derive from LuaString and be convertible to a number

      Parameters:
      rhs - The power to raise this value to
      Returns:
      value of (this ^ rhs) if both are numeric, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if either operand is not a number or string convertible to number, and neither has the POW metatag defined
      See Also:
      • arithmt(LuaValue, LuaValue)
    • pow

      public LuaValue pow(double rhs)
      Raise to power: Raise this value to a power of double type with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • pow

      public LuaValue pow(int rhs)
      Raise to power: Raise this value to a power of int type with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • powWith

      public LuaValue powWith(double lhs)
      Reverse-raise to power: Raise another value of double type to this power with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • powWith

      public LuaValue powWith(int lhs)
      Reverse-raise to power: Raise another value of double type to this power with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • div

      public LuaValue div(LuaValue rhs)
      Divide: Perform numeric divide operation by another value of unknown type, including metatag processing.

      Each operand must derive from LuaNumber or derive from LuaString 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, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if either operand is not a number or string convertible to number, and neither has the DIV metatag defined
      See Also:
      • arithmt(LuaValue, LuaValue)
    • div

      public LuaValue div(double rhs)
      Divide: Perform numeric divide operation by another value of double type without metatag processing

      this must derive from LuaNumber or derive from LuaString and be convertible to a number

      For 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 - if this is not a number or string convertible to number
      See Also:
    • div

      public LuaValue div(int rhs)
      Divide: Perform numeric divide operation by another value of int type without metatag processing

      this must derive from LuaNumber or derive from LuaString and be convertible to a number

      For 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 - if this is not a number or string convertible to number
      See Also:
    • divInto

      public LuaValue divInto(double lhs)
      Reverse-divide: Perform numeric divide operation into another value with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • mod

      public LuaValue mod(LuaValue rhs)
      Modulo: Perform numeric modulo operation with another value of unknown type, including metatag processing.

      Each operand must derive from LuaNumber or derive from LuaString 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, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if either operand is not a number or string convertible to number, and neither has the MOD metatag defined
      See Also:
      • arithmt(LuaValue, LuaValue)
    • mod

      public LuaValue mod(double rhs)
      Modulo: Perform numeric modulo operation with another value of double type without metatag processing

      this must derive from LuaNumber or derive from LuaString and be convertible to a number

      For 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 - if this is not a number or string convertible to number
      See Also:
    • mod

      public LuaValue mod(int rhs)
      Modulo: Perform numeric modulo operation with another value of int type without metatag processing

      this must derive from LuaNumber or derive from LuaString and be convertible to a number

      For 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 - if this is not a number or string convertible to number
      See Also:
    • modFrom

      public LuaValue modFrom(double lhs)
      Reverse-modulo: Perform numeric modulo operation from another value with metatag processing

      this must derive from LuaNumber or derive from LuaString 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 - if this is not a number or string convertible to number
      See Also:
    • lt

      public LuaValue lt(LuaValue rhs)
      Less than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning LuaValue.

      To be comparable, both operands must derive from LuaString or both must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this < rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if either both operands are not a strings or both are not numbers and no LT metatag is defined.
      See Also:
    • lt

      public LuaValue lt(double rhs)
      Less than: Perform numeric comparison with another value of double type, including metatag processing, and returning LuaValue.

      To be comparable, this must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this < rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if this is not a number and no LT metatag is defined.
      See Also:
    • lt

      public LuaValue lt(int rhs)
      Less than: Perform numeric comparison with another value of int type, including metatag processing, and returning LuaValue.

      To be comparable, this must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this < rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if this is not a number and no LT metatag is defined.
      See Also:
    • lt_b

      public boolean lt_b(LuaValue rhs)
      Less than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.

      To be comparable, both operands must derive from LuaString or both must derive from LuaNumber.

      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 no LT 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.

      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 this is not a number and no LT metatag is defined.
      See Also:
    • 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 from LuaNumber.

      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 no LT metatag is defined.
      See Also:
    • lteq

      public LuaValue lteq(LuaValue rhs)
      Less than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning LuaValue.

      To be comparable, both operands must derive from LuaString or both must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this <= rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if either both operands are not a strings or both are not numbers and no LE metatag is defined.
      See Also:
    • lteq

      public LuaValue lteq(double rhs)
      Less than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returning LuaValue.

      To be comparable, this must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this <= rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if this is not a number and no LE metatag is defined.
      See Also:
    • lteq

      public LuaValue lteq(int rhs)
      Less than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returning LuaValue.

      To be comparable, this must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this <= rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if this is not a number and no LE metatag is defined.
      See Also:
    • lteq_b

      public boolean lteq_b(LuaValue rhs)
      Less than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.

      To be comparable, both operands must derive from LuaString or both must derive from LuaNumber.

      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 no LE 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.

      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 this is not a number and no LE metatag is defined.
      See Also:
    • 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.

      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 this is not a number and no LE metatag is defined.
      See Also:
    • gt

      public LuaValue gt(LuaValue rhs)
      Greater than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning LuaValue.

      To be comparable, both operands must derive from LuaString or both must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this > rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if either both operands are not a strings or both are not numbers and no LE metatag is defined.
      See Also:
    • gt

      public LuaValue gt(double rhs)
      Greater than: Perform numeric comparison with another value of double type, including metatag processing, and returning LuaValue.

      To be comparable, this must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this > rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if this is not a number and no LE metatag is defined.
      See Also:
    • gt

      public LuaValue gt(int rhs)
      Greater than: Perform numeric comparison with another value of int type, including metatag processing, and returning LuaValue.

      To be comparable, this must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this > rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if this is not a number and no LE metatag is defined.
      See Also:
    • gt_b

      public boolean gt_b(LuaValue rhs)
      Greater than: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.

      To be comparable, both operands must derive from LuaString or both must derive from LuaNumber.

      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 no LE 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.

      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 this is not a number and no LE metatag is defined.
      See Also:
    • 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 from LuaNumber.

      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 no LE metatag is defined.
      See Also:
    • gteq

      public LuaValue gteq(LuaValue rhs)
      Greater than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning LuaValue.

      To be comparable, both operands must derive from LuaString or both must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this >= rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if either both operands are not a strings or both are not numbers and no LT metatag is defined.
      See Also:
    • gteq

      public LuaValue gteq(double rhs)
      Greater than or equals: Perform numeric comparison with another value of double type, including metatag processing, and returning LuaValue.

      To be comparable, this must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this >= rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if this is not a number and no LT metatag is defined.
      See Also:
    • gteq

      public LuaValue gteq(int rhs)
      Greater than or equals: Perform numeric comparison with another value of int type, including metatag processing, and returning LuaValue.

      To be comparable, this must derive from LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the comparison with
      Returns:
      TRUE if (this >= rhs), FALSE if not, or LuaValue if metatag processing occurs
      Throws:
      LuaError - if this is not a number and no LT metatag is defined.
      See Also:
    • gteq_b

      public boolean gteq_b(LuaValue rhs)
      Greater than or equals: Perform numeric or string comparison with another value of unknown type, including metatag processing, and returning java boolean.

      To be comparable, both operands must derive from LuaString or both must derive from LuaNumber.

      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 no LT 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.

      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 this is not a number and no LT metatag is defined.
      See Also:
    • 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.

      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 this is not a number and no LT metatag is defined.
      See Also:
    • comparemt

      public LuaValue comparemt(LuaValue tag, LuaValue op1)
      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 up
      op1 - 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

      public int strcmp(LuaValue rhs)
      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 &lt; rhs), int > 0 for (this &gt; rhs), or 0 when same string.
      Throws:
      LuaError - if either operand is not a string
    • strcmp

      public int strcmp(LuaString rhs)
      Perform string comparison with another value known to be a LuaString 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 &lt; rhs), int > 0 for (this &gt; rhs), or 0 when same string.
      Throws:
      LuaError - if this is not a string
    • concat

      public LuaValue concat(LuaValue rhs)
      Concatenate another value onto this value and return the result using rules of lua string concatenation including metatag processing.

      Only strings and numbers as represented can be concatenated, meaning each operand must derive from LuaString or LuaNumber.

      Parameters:
      rhs - The right-hand-side value to perform the operation with
      Returns:
      LuaValue resulting from concatenation of (this .. rhs)
      Throws:
      LuaError - if either operand is not of an appropriate type, such as nil or a table
    • concatTo

      public LuaValue concatTo(LuaValue lhs)
      Reverse-concatenation: concatenate this value onto another value whose type is unknwon and return the result using rules of lua string concatenation including metatag processing.

      Only strings and numbers as represented can be concatenated, meaning each operand must derive from LuaString or LuaNumber.

      Parameters:
      lhs - The left-hand-side value onto which this will be concatenated
      Returns:
      LuaValue resulting from concatenation of (lhs .. this)
      Throws:
      LuaError - if either operand is not of an appropriate type, such as nil or a table
      See Also:
    • concatTo

      public LuaValue concatTo(LuaNumber lhs)
      Reverse-concatenation: concatenate this value onto another value known to be a LuaNumber and return the result using rules of lua string concatenation including metatag processing.

      Only strings and numbers as represented can be concatenated, meaning each operand must derive from LuaString or LuaNumber.

      Parameters:
      lhs - The left-hand-side value onto which this will be concatenated
      Returns:
      LuaValue resulting from concatenation of (lhs .. this)
      Throws:
      LuaError - if either operand is not of an appropriate type, such as nil or a table
      See Also:
    • concatTo

      public LuaValue concatTo(LuaString lhs)
      Reverse-concatenation: concatenate this value onto another value known to be a LuaString and return the result using rules of lua string concatenation including metatag processing.

      Only strings and numbers as represented can be concatenated, meaning each operand must derive from LuaString or LuaNumber.

      Parameters:
      lhs - The left-hand-side value onto which this will be concatenated
      Returns:
      LuaValue resulting from concatenation of (lhs .. this)
      Throws:
      LuaError - if either operand is not of an appropriate type, such as nil or a table
      See Also:
    • buffer

      public Buffer buffer()
      Convert the value to a Buffer for more efficient concatenation of multiple strings.
      Returns:
      Buffer instance containing the string or number
    • concat

      public Buffer concat(Buffer rhs)
      Concatenate a Buffer onto this value and return the result using rules of lua string concatenation including metatag processing.

      Only strings and numbers as represented can be concatenated, meaning each operand must derive from LuaString or LuaNumber.

      Parameters:
      rhs - The right-hand-side Buffer to perform the operation with
      Returns:
      LuaString resulting from concatenation of (this .. rhs)
      Throws:
      LuaError - if either operand is not of an appropriate type, such as nil or a table
    • concatmt

      public LuaValue concatmt(LuaValue rhs)
      Perform metatag processing for concatenation operations.

      Finds the CONCAT metatag value and invokes it, or throws LuaError if it doesn't exist.

      Parameters:
      rhs - The right-hand-side value to perform the operation with
      Returns:
      LuaValue resulting from metatag processing for CONCAT metatag.
      Throws:
      LuaError - if metatag was not defined for either operand
    • and

      public LuaValue and(LuaValue rhs)
      Perform boolean and with another operand, based on lua rules for boolean evaluation. This returns either this or rhs depending on the boolean value for this.
      Parameters:
      rhs - The right-hand-side value to perform the operation with
      Returns:
      this if this.toboolean() is false, rhs otherwise.
    • or

      public LuaValue or(LuaValue rhs)
      Perform boolean or with another operand, based on lua rules for boolean evaluation. This returns either this or rhs depending on the boolean value for this.
      Parameters:
      rhs - The right-hand-side value to perform the operation with
      Returns:
      this if this.toboolean() is true, rhs otherwise.
    • testfor_b

      public boolean testfor_b(LuaValue limit, LuaValue step)
      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 loop
      step - the numberical step size to use.
      Returns:
      true if limit has not been reached, false otherwise.
    • strvalue

      public LuaString strvalue()
      Convert this value to a string if it is a LuaString or LuaNumber, or throw a LuaError if it is not
      Returns:
      LuaString corresponding to the value if a string or number
      Throws:
      LuaError - if not a string or number
    • strongvalue

      public LuaValue strongvalue()
      Return this value as a strong reference, or null if it was weak and is no longer referenced.
      Returns:
      LuaValue referred to, or null if it was weak and is no longer referenced.
      See Also:
    • valueOf

      public static LuaBoolean valueOf(boolean b)
      Convert java boolean to a LuaValue.
      Parameters:
      b - boolean value to convert
      Returns:
      TRUE if not or FALSE if false
    • valueOf

      public static LuaInteger valueOf(int i)
      Convert java int to a LuaValue.
      Parameters:
      i - int value to convert
      Returns:
      LuaInteger instance, possibly pooled, whose value is i
    • valueOf

      public static LuaNumber valueOf(double d)
      Convert java double to a LuaValue. This may return a LuaInteger or LuaDouble depending on the value supplied.
      Parameters:
      d - double value to convert
      Returns:
      LuaNumber instance, possibly pooled, whose value is d
    • valueOf

      public static LuaString valueOf(String s)
      Convert java string to a LuaValue.
      Parameters:
      s - String value to convert
      Returns:
      LuaString instance, possibly pooled, whose value is s
    • valueOf

      public static LuaString valueOf(byte[] bytes)
      Convert bytes in an array to a LuaValue.
      Parameters:
      bytes - byte array to convert
      Returns:
      LuaString instance, possibly pooled, whose bytes are those in the supplied array
    • valueOf

      public static LuaString valueOf(byte[] bytes, int off, int len)
      Convert bytes in an array to a LuaValue.
      Parameters:
      bytes - byte array to convert
      off - offset into the byte array, starting at 0
      len - number of bytes to include in the LuaString
      Returns:
      LuaString instance, possibly pooled, whose bytes are those in the supplied array
    • tableOf

      public static LuaTable tableOf()
      Construct an empty LuaTable.
      Returns:
      new LuaTable instance with no values and no metatable.
    • tableOf

      public static LuaTable tableOf(Varargs varargs, int firstarg)
      Construct a LuaTable initialized with supplied array values.
      Parameters:
      varargs - Varargs containing the values to use in initialization
      firstarg - the index of the first argument to use from the varargs, 1 being the first.
      Returns:
      new LuaTable instance with sequential elements coming from the varargs.
    • tableOf

      public static LuaTable tableOf(int narray, int nhash)
      Construct an empty LuaTable preallocated to hold array and hashed elements
      Parameters:
      narray - Number of array elements to preallocate
      nhash - Number of hash elements to preallocate
      Returns:
      new LuaTable instance with no values and no metatable, but preallocated for array and hashed elements.
    • listOf

      public static LuaTable listOf(LuaValue[] unnamedValues)
      Construct a LuaTable initialized with supplied array values.
      Parameters:
      unnamedValues - array of LuaValue containing the values to use in initialization
      Returns:
      new LuaTable instance with sequential elements coming from the array.
    • listOf

      public static LuaTable listOf(LuaValue[] unnamedValues, Varargs lastarg)
      Construct a LuaTable initialized with supplied array values.
      Parameters:
      unnamedValues - array of LuaValue containing the first values to use in initialization
      lastarg - 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

      public static LuaTable tableOf(LuaValue[] namedValues)
      Construct a LuaTable initialized with supplied named values.
      Parameters:
      namedValues - array of LuaValue containing the keys and values to use in initialization in order {key-a, value-a, key-b, value-b, ...}
      Returns:
      new LuaTable instance with non-sequential keys coming from the supplied array.
    • tableOf

      public static LuaTable tableOf(LuaValue[] namedValues, LuaValue[] unnamedValues)
      Construct a LuaTable initialized with supplied named values and sequential elements. The named values will be assigned first, and the sequential elements will be assigned later, possibly overwriting named values at the same slot if there are conflicts.
      Parameters:
      namedValues - array of LuaValue containing the keys and values to use in initialization in order {key-a, value-a, key-b, value-b, ...}
      unnamedValues - array of LuaValue containing the sequenctial elements to use in initialization in order {value-1, value-2, ...} , or null if there are none
      Returns:
      new LuaTable instance with named and sequential values supplied.
    • tableOf

      public static LuaTable tableOf(LuaValue[] namedValues, LuaValue[] unnamedValues, Varargs lastarg)
      Construct a LuaTable initialized with supplied named values and sequential elements in an array part and as varargs. 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 of LuaValue containing the keys and values to use in initialization in order {key-a, value-a, key-b, value-b, ...}
      unnamedValues - array of LuaValue containing the first sequenctial elements to use in initialization in order {value-1, value-2, ...} , or null if there are none
      lastarg - 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

      public static LuaUserdata userdataOf(Object o)
      Construct a LuaUserdata for an object.
      Parameters:
      o - The java instance to be wrapped as userdata
      Returns:
      LuaUserdata value wrapping the java instance.
    • userdataOf

      public static LuaUserdata userdataOf(Object o, LuaValue metatable)
      Construct a LuaUserdata for an object with a user supplied metatable.
      Parameters:
      o - The java instance to be wrapped as userdata
      metatable - The metatble to associate with the userdata instance.
      Returns:
      LuaUserdata value wrapping the java instance.
    • metatag

      public LuaValue metatag(LuaValue tag)
      Get particular metatag, or return NIL if it doesn't exist
      Parameters:
      tag - Metatag name to look up, typically a string such as INDEX or NEWINDEX
      Returns:
      LuaValue for tag reason, or NIL
    • varargsOf

      public static Varargs varargsOf(LuaValue[] v)
      Construct a Varargs around an array of LuaValues.
      Parameters:
      v - The array of LuaValues
      Returns:
      Varargs wrapping the supplied values.
      See Also:
    • cachedDouble

      public static LuaDouble cachedDouble(double val)
    • cachedInt

      public static LuaInteger cachedInt(int val)
    • cachedVarargsOf

      public static Varargs cachedVarargsOf(LuaValue v1)
    • cachedVarargsOf

      public static Varargs cachedVarargsOf(LuaValue v1, LuaValue v2)
    • cachedVarargsOf

      public static Varargs cachedVarargsOf(LuaValue v1, LuaValue v2, LuaValue v3)
    • cachedVarargsOf

      public static Varargs cachedVarargsOf(LuaValue v1, LuaValue v2, LuaValue v3, LuaValue v4)
    • cachedVarargsOf

      public static Varargs cachedVarargsOf(LuaValue v1, LuaValue v2, LuaValue v3, LuaValue v4, LuaValue v5)
    • cachedVarargsOf

      public static Varargs cachedVarargsOf(LuaValue v1, LuaValue v2, LuaValue v3, LuaValue v4, LuaValue v5, LuaValue v6)
    • varargsOf

      public static Varargs varargsOf(LuaValue[] v, Varargs r)
      Construct a Varargs around an array of LuaValues.
      Parameters:
      v - The array of LuaValues
      r - Varargs contain values to include at the end
      Returns:
      Varargs wrapping the supplied values.
      See Also:
    • varargsOf

      public static Varargs varargsOf(LuaValue[] v, int offset, int length)
      Construct a Varargs around an array of LuaValues.
      Parameters:
      v - The array of LuaValues
      offset - number of initial values to skip in the array
      length - number of values to include from the array
      Returns:
      Varargs wrapping the supplied values.
      See Also:
    • varargsOf

      public static Varargs varargsOf(LuaValue[] v, int offset, int length, Varargs more)
      Construct a Varargs around an array of LuaValues. Caller must ensure that array contents are not mutated after this call or undefined behavior will result.
      Parameters:
      v - The array of LuaValues
      offset - number of initial values to skip in the array
      length - number of values to include from the array
      more - Varargs contain values to include at the end
      Returns:
      Varargs wrapping the supplied values.
      See Also:
    • varargsOf

      public static Varargs varargsOf(LuaValue v, Varargs r)
      Construct a Varargs around a set of 2 or more LuaValues.

      This can be used to wrap exactly 2 values, or a list consisting of 1 initial value followed by another variable list of remaining values.

      Parameters:
      v - First LuaValue in the Varargs
      r - LuaValue supplying the 2rd value, or Varargss supplying all values beyond the first
      Returns:
      Varargs wrapping the supplied values.
    • varargsOf

      public static Varargs varargsOf(LuaValue v1, LuaValue v2, Varargs v3)
      Construct a Varargs around a set of 3 or more LuaValues.

      This can be used to wrap exactly 3 values, or a list consisting of 2 initial values followed by another variable list of remaining values.

      Parameters:
      v1 - First LuaValue in the Varargs
      v2 - Second LuaValue in the Varargs
      v3 - LuaValue supplying the 3rd value, or Varargss supplying all values beyond the second
      Returns:
      Varargs wrapping the supplied values.
    • tailcallOf

      public static Varargs tailcallOf(LuaValue func, Varargs args)
      Construct a TailcallVarargs around a function and arguments.

      The tail call is not yet called or processing until the client invokes TailcallVarargs.eval() which performs the tail call processing.

      This method is typically not used directly by client code. Instead use one of the function invocation methods.

      Parameters:
      func - LuaValue to be called as a tail call
      args - Varargs containing the arguments to the call
      Returns:
      TailcallVarargs to be used in tailcall oprocessing.
      See Also:
    • onInvoke

      public Varargs onInvoke(Varargs args)
      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

      public void initupvalue1(LuaValue env)
      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

      public Varargs subargs(int start)
      Create a Varargs instance containing arguments starting at index start
      Specified by:
      subargs in class Varargs
      Parameters:
      start - the index from which to include arguments, where 1 is the first argument.
      Returns:
      Varargs containing argument { start, start+1, ... , narg-start-1 }