lilypond-1.3.7
[lilypond.git] / lily / protected-scm.cc
blob1d8fd16b2a1b1449c90f801fe0fdc9e4547e4af3
1 /*
2 protected-scm.cc -- implement Protected_scm
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 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_ = 0;
18 Protected_scm::Protected_scm (SCM s)
20 object_ = s ? scm_protect_object (s): 0;
23 Protected_scm::Protected_scm (Protected_scm const &s)
25 object_ = s.object_ ? scm_protect_object (s.object_) : 0;
28 Protected_scm &
29 Protected_scm::operator =(SCM s)
31 if (object_ == s)
32 return *this;
33 if (object_)
34 scm_unprotect_object(object_);
36 object_ = s ? scm_protect_object (s): 0;
37 return *this;
40 Protected_scm&
41 Protected_scm::operator = (Protected_scm const &s)
43 return operator= (s.object_);
47 Protected_scm::~Protected_scm ()
49 if (object_)
51 scm_unprotect_object (object_);
55 Protected_scm::operator SCM () const
57 return object_;
60 SCM
61 Protected_scm::to_SCM () const
63 return object_;