Class WeakTable

java.lang.Object
com.prineside.luaj.WeakTable
All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable

public class WeakTable extends Object implements com.esotericsoftware.kryo.KryoSerializable
Subclass of LuaTable that provides weak key and weak value semantics.

Normally these are not created directly, but indirectly when changing the mode of a LuaTable as lua script executes.

However, calling the constructors directly when weak tables are required from Java will reduce overhead.

  • Constructor Details

    • WeakTable

      public WeakTable(boolean weakkeys, boolean weakvalues, LuaValue backing)
      Construct a table with weak keys, weak values, or both
      Parameters:
      weakkeys - true to let the table have weak keys
      weakvalues - true to let the table have weak values
  • Method Details

    • write

      public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output)
      Specified by:
      write in interface com.esotericsoftware.kryo.KryoSerializable
    • read

      public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input)
      Specified by:
      read in interface com.esotericsoftware.kryo.KryoSerializable
    • make

      public static LuaTable make(boolean weakkeys, boolean weakvalues)
    • useWeakKeys

      public boolean useWeakKeys()
    • useWeakValues

      public boolean useWeakValues()
    • toLuaValue

      public LuaValue toLuaValue()
    • entry

      public LuaTable.Slot entry(LuaValue key, LuaValue value)
    • weaken

      protected static LuaValue weaken(LuaValue value)
      Self-sent message to convert a value to its weak counterpart
      Parameters:
      value - value to convert
      Returns:
      LuaValue that is a strong or weak reference, depending on type of value
    • strengthen

      protected static LuaValue strengthen(Object ref)
      Unwrap a LuaValue from a WeakReference and/or WeakUserdata.
      Parameters:
      ref - reference to convert
      Returns:
      LuaValue or null
      See Also:
    • wrap

      public LuaValue wrap(LuaValue value)
    • arrayget

      public LuaValue arrayget(LuaValue[] array, int index)