]> git.donarmstrong.com Git - lilypond.git/blob - lily/protected-scm.cc
release: 1.3.0
[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--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9 #include "protected-scm.hh"
10 #include "lily-guile.hh"
11 #include "main.hh"
12
13 Protected_scm::Protected_scm ()
14 {
15   object_ = 0;
16 }
17
18 Protected_scm::Protected_scm (SCM s)
19 {
20   object_ = s  ? scm_protect_object (s): 0;
21 }
22
23 Protected_scm::Protected_scm (Protected_scm const &s)
24 {
25   object_ = s.object_ ? scm_protect_object (s.object_) : 0;
26 }
27
28 Protected_scm & 
29 Protected_scm::operator =(SCM s)
30 {
31   if (object_ == s)
32     return *this;
33   if (object_)
34     scm_unprotect_object(object_);
35
36   object_ =  s ? scm_protect_object (s): 0;
37   return *this;
38 }
39
40 Protected_scm&
41 Protected_scm::operator = (Protected_scm const &s)
42 {
43   return operator= (s.object_);
44 }
45
46
47 Protected_scm::~Protected_scm ()
48 {
49   if  (object_)
50     {
51       scm_unprotect_object (object_);
52     }
53 }
54
55 Protected_scm::operator SCM () const
56 {
57   return object_;
58 }
59
60 SCM 
61 Protected_scm::to_SCM () const
62 {
63   return object_;
64 }