Class: Rufus::Lua::Ref
- Inherits:
-
Object
- Object
- Rufus::Lua::Ref
- Includes:
- StateMixin
- Defined in:
- lib/rufus/lua/objects.rb
Overview
The parent class for Table, Function and Coroutine. Simply holds a reference to the object in the Lua registry.
Constant Summary
Constants included from StateMixin
StateMixin::LUA_ENVIRONINDEX, StateMixin::LUA_GCCOLLECT, StateMixin::LUA_GCCOUNT, StateMixin::LUA_GCCOUNTB, StateMixin::LUA_GCRESTART, StateMixin::LUA_GCSETPAUSE, StateMixin::LUA_GCSETSTEPMUL, StateMixin::LUA_GCSTEP, StateMixin::LUA_GCSTOP, StateMixin::LUA_GLOBALSINDEX, StateMixin::LUA_MULTRET, StateMixin::LUA_NOREF, StateMixin::LUA_REFNIL, StateMixin::LUA_REGISTRYINDEX, StateMixin::SIMPLE_TYPES, StateMixin::TBOOLEAN, StateMixin::TFUNCTION, StateMixin::TLIGHTUSERDATA, StateMixin::TNIL, StateMixin::TNONE, StateMixin::TNUMBER, StateMixin::TSTRING, StateMixin::TTABLE, StateMixin::TTHREAD, StateMixin::TUSERDATA
Instance Attribute Summary collapse
-
#ref ⇒ Object
readonly
The reference in the Lua registry.
Instance Method Summary collapse
-
#free ⇒ Object
Frees the reference to this object (Problably a good idea if you want Lua’s GC to get rid of it later).
-
#initialize(pointer) ⇒ Ref
constructor
A new instance of Ref.
Constructor Details
#initialize(pointer) ⇒ Ref
Returns a new instance of Ref.
40 41 42 43 44 45 |
# File 'lib/rufus/lua/objects.rb', line 40 def initialize(pointer) @pointer = pointer @ref = Lib.luaL_ref(@pointer, LUA_REGISTRYINDEX) # this pops the object out of the stack ! end |
Instance Attribute Details
#ref ⇒ Object (readonly)
The reference in the Lua registry. (You shouldn’t care about this value)
38 39 40 |
# File 'lib/rufus/lua/objects.rb', line 38 def ref @ref end |
Instance Method Details
#free ⇒ Object
Frees the reference to this object (Problably a good idea if you want Lua’s GC to get rid of it later).
50 51 52 53 54 |
# File 'lib/rufus/lua/objects.rb', line 50 def free Lib.luaL_unref(@pointer, LUA_REGISTRYINDEX, @ref) @ref = nil end |