class Rufus::Lua::Ref

The parent class for Table, Function and Coroutine. Simply holds a reference to the object in the Lua registry.

Attributes

ref[R]

The reference in the Lua registry. (You shouldn't care about this value)

Public Class Methods

new(pointer) click to toggle source
# File lib/rufus/lua/objects.rb, line 16
def initialize(pointer)

  @pointer = pointer
  @ref = Lib.luaL_ref(@pointer, LUA_REGISTRYINDEX)
    # this pops the object out of the stack !
  @error_handler = 0
end

Public Instance Methods

free() click to toggle source

Frees the reference to this object (Problably a good idea if you want Lua's GC to get rid of it later).

# File lib/rufus/lua/objects.rb, line 27
def free

  Lib.luaL_unref(@pointer, LUA_REGISTRYINDEX, @ref)
  @ref = nil
end

Protected Instance Methods

load_onto_stack() click to toggle source

Brings the referenced object on top of the stack (will probably then take part in a method call).

# File lib/rufus/lua/objects.rb, line 38
def load_onto_stack

  raise RuntimeError.new(
    "#{self.class} got freed, cannot re-access it directly"
  ) unless @ref

  stack_load_ref(@ref)
end