2 protected-scm.cc -- implement Protected_scm
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "protected-scm.hh"
10 #include "lily-guile.hh"
13 Protected_scm::Protected_scm ()
15 object_ = SCM_UNDEFINED;
18 Protected_scm::Protected_scm (SCM s)
20 object_ = SCM_NIMP (s) ? scm_gc_protect_object (s): s;
23 Protected_scm::Protected_scm (Protected_scm const &s)
25 object_ = SCM_NIMP (s.object_) ? scm_gc_protect_object (s.object_) : s.object_;
29 Protected_scm::operator = (SCM s)
34 if (SCM_NIMP (object_))
35 scm_gc_unprotect_object (object_);
37 object_ = SCM_NIMP (s) ? scm_gc_protect_object (s): s;
42 Protected_scm::operator = (Protected_scm const &s)
44 return operator= (s.object_);
48 Protected_scm::~Protected_scm ()
50 if (SCM_NIMP (object_))
52 scm_gc_unprotect_object (object_);
56 Protected_scm::operator SCM () const
62 Protected_scm::to_SCM () const