Sha256: 40267b5f7f379f65de80eb8da79f3a2b21778e4ca45ec0234d95c3c756098800
Contents?: true
Size: 639 Bytes
Versions: 38
Compression:
Stored size: 639 Bytes
Contents
module Rufus::Lua # Auto-unref Lua ref when it goes out of scope in Ruby. class Ref def initialize_with_finalizer(*args) initialize_without_finalizer(*args) ObjectSpace.define_finalizer self, self.class.finalize(@pointer, @ref) end alias_method :initialize_without_finalizer, :initialize alias_method :initialize, :initialize_with_finalizer def self.finalize(pointer, ref) proc do Lib.luaL_unref(pointer, LUA_REGISTRYINDEX, ref) end end undef :free def free # Noop. Taken care of by finalizer. Should not conflict. end public :load_onto_stack end end
Version data entries
38 entries across 38 versions & 1 rubygems