lilypond-1.3.67
[lilypond.git] / lily / protected-scm.cc
blob2878e9c9a8aa9032f0c311644522b98d6dcf0963
1 /*
2 protected-scm.cc -- implement Protected_scm
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9 #include "protected-scm.hh"
10 #include "lily-guile.hh"
11 #include "main.hh"
13 Protected_scm::Protected_scm ()
15 object_ = SCM_UNDEFINED;
18 Protected_scm::Protected_scm (SCM s)
20 object_ = SCM_NIMP(s) ? scm_protect_object (s): s;
23 Protected_scm::Protected_scm (Protected_scm const &s)
25 object_ = SCM_NIMP(s.object_) ? scm_protect_object (s.object_) : s.object_;
28 Protected_scm &
29 Protected_scm::operator =(SCM s)
31 if (object_ == s)
32 return *this;
34 if (SCM_NIMP (object_))
35 scm_unprotect_object(object_);
37 object_ = SCM_NIMP (s) ? scm_protect_object (s): s;
38 return *this;
41 Protected_scm&
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_unprotect_object (object_);
56 Protected_scm::operator SCM () const
58 return object_;
61 SCM
62 Protected_scm::to_SCM () const
64 return object_;