]> git.donarmstrong.com Git - lilypond.git/blob - lily/protected-scm.cc
Patch for auto-beam; Fix issue 511
[lilypond.git] / lily / protected-scm.cc
1 /*
2   protected-scm.cc -- implement Protected_scm
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1998--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "protected-scm.hh"
10
11 Protected_scm::Protected_scm ()
12 {
13   object_ = SCM_UNDEFINED;
14 }
15
16 Protected_scm::Protected_scm (SCM s)
17 {
18   object_ = SCM_NIMP (s) ? scm_gc_protect_object (s) : s;
19 }
20
21 Protected_scm::Protected_scm (Protected_scm const &s)
22 {
23   object_ = (SCM_NIMP (s.object_) ? scm_gc_protect_object (s.object_)
24              : s.object_);
25 }
26
27 Protected_scm::~Protected_scm ()
28 {
29   if (SCM_NIMP (object_))
30     scm_gc_unprotect_object (object_);
31 }
32
33 Protected_scm &
34 Protected_scm::operator = (SCM s)
35 {
36   if (object_ == s)
37     return *this;
38
39   if (SCM_NIMP (object_))
40     scm_gc_unprotect_object (object_);
41
42   object_ = SCM_NIMP (s) ? scm_gc_protect_object (s) : s;
43   return *this;
44 }
45
46 Protected_scm &
47 Protected_scm::operator = (Protected_scm const &s)
48 {
49   return operator = (s.object_);
50 }
51
52 Protected_scm::operator SCM () const
53 {
54   return object_;
55 }
56
57 SCM
58 Protected_scm::to_SCM () const
59 {
60   return object_;
61 }