class Object

Protected Class Methods

_upl_finalizer_blk(atom_t) click to toggle source

Have to put this in a separate method, otherwise the finalizer block's binding holds onto the obj it's trying to finalize.

# File lib/upl/inter.rb, line 135
def self._upl_finalizer_blk atom_t
  proc do |objid| Upl::Extern.PL_unregister_atom atom_t end
end

Public Instance Methods

to_atom() click to toggle source
# File lib/upl/inter.rb, line 92
def to_atom
  if frozen?
    # TODO must check instance variable here
    _upl_atomize
  else
    @_upl_atom ||= _upl_atomize
  end
end
to_term() click to toggle source

return a Term object from to_term_t

# File lib/upl/inter.rb, line 102
def to_term
  Upl::Term.new to_term_t
end
to_term_t() click to toggle source

return a term_t pointer

# File lib/upl/inter.rb, line 107
def to_term_t
  if frozen?
    # TODO must check instance variable here
    _upl_termize
  else
    # @_upl_termize ||= _upl_termize
    _upl_termize
  end
end

Protected Instance Methods

_upl_atomize() click to toggle source
# File lib/upl/inter.rb, line 126
def _upl_atomize
  # TODO see also PL_agc_hook for hooking into the swipl GC
  atom_t = Upl::Atom.t_of_ruby self
  ObjectSpace.define_finalizer self, &self.class._upl_finalizer_blk(atom_t)
  atom_t
end
_upl_termize() click to toggle source
# File lib/upl/inter.rb, line 119
def _upl_termize
  term_t = Upl::Extern.PL_new_term_ref
  rv = Upl::Extern.PL_put_atom term_t, to_atom
  rv == 1 or raise "can't create atom from #{self}"
  term_t
end