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