2 protected-scm.cc -- implement Protected_scm
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "protected-scm.hh"
10 #include "lily-guile.hh"
12 Protected_scm::Protected_scm ()
14 object_
= SCM_UNDEFINED
;
17 Protected_scm::Protected_scm (SCM s
)
19 object_
= SCM_NIMP (s
) ? scm_gc_protect_object (s
): s
;
22 Protected_scm::Protected_scm (Protected_scm
const &s
)
24 object_
= SCM_NIMP (s
.object_
) ? scm_gc_protect_object (s
.object_
) : s
.object_
;
28 Protected_scm::operator = (SCM s
)
33 if (SCM_NIMP (object_
))
34 scm_gc_unprotect_object (object_
);
36 object_
= SCM_NIMP (s
) ? scm_gc_protect_object (s
): s
;
41 Protected_scm::operator = (Protected_scm
const &s
)
43 return operator= (s
.object_
);
47 Protected_scm::~Protected_scm ()
49 if (SCM_NIMP (object_
))
51 scm_gc_unprotect_object (object_
);
55 Protected_scm::operator SCM () const
61 Protected_scm::to_SCM () const