2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "listener.hh"
24 Smob_core::get_listener (SCM callback)
26 return Listener (callback, self_scm ());
30 The CDR contains the actual protected list.
32 static SCM smob_protection_list = SCM_EOL;
35 init_smob_protection ()
37 smob_protection_list = scm_cons (SCM_BOOL_F, SCM_EOL);
38 scm_gc_protect_object (smob_protection_list);
40 ADD_SCM_INIT_FUNC (init_smob_protection, init_smob_protection);
42 LY_DEFINE (ly_smob_protects, "ly:smob-protects",
44 "Return LilyPond's internal smob protection list.")
46 return scm_is_pair (smob_protection_list)
47 ? scm_cdr (smob_protection_list)
52 protect_smob (SCM smob, SCM *prot_cons)
55 SCM s = scm_cdr (smob_protection_list);
56 while (scm_is_pair (s) && scm_is_false (scm_car (s))
60 SCM prot = scm_cons (smob, s);
61 scm_set_cdr_x (smob_protection_list,
66 scm_gc_protect_object (smob);
71 unprotect_smob (SCM smob, SCM *prot_cons)
75 scm_gc_unprotect_object (smob);
77 SCM next = scm_cdr (*prot_cons);
79 if (scm_is_null (next)))
80 scm_set_car_x (*prot_cons, SCM_BOOL_F);
83 scm_set_car_x (*prot_cons, SCM_BOOL_F);
84 while (scm_is_pair (next)
85 && scm_is_false (scm_car (next)))
87 next = scm_cdr (next);
89 scm_set_cdr_x (*prot_cons, next);
97 Scm_init const *Scm_init::list_ = 0;
102 for (Scm_init const *p = list_; p; p = p->next_)