Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / smobs.cc
blob5544d95d7b08d8fbdae5ffc1f151323265f8121f
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2011 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/>.
20 #include "smobs.hh"
23 The CDR contains the actual protected list.
25 static SCM smob_protection_list = SCM_EOL;
27 void
28 init_smob_protection ()
30 smob_protection_list = scm_cons (SCM_BOOL_F, SCM_EOL);
31 scm_gc_protect_object (smob_protection_list);
33 ADD_SCM_INIT_FUNC (init_smob_protection, init_smob_protection);
35 LY_DEFINE (ly_smob_protects, "ly:smob-protects",
36 0, 0, 0, (),
37 "Return LilyPond's internal smob protection list.")
39 return scm_is_pair (smob_protection_list)
40 ? scm_cdr (smob_protection_list)
41 : SCM_EOL;
44 void
45 protect_smob (SCM smob, SCM *prot_cons)
47 #if 0
48 SCM s = scm_cdr (smob_protection_list);
49 while (scm_is_pair (s) && scm_car (s) == SCM_BOOL_F)
51 s = scm_cdr (s);
53 SCM prot = scm_cons (smob, s);
54 scm_set_cdr_x (smob_protection_list,
55 prot);
56 *prot_cons = prot;
57 #else
58 (void) prot_cons;
59 scm_gc_protect_object (smob);
60 #endif
63 void
64 unprotect_smob (SCM smob, SCM *prot_cons)
66 #if 1
67 (void) prot_cons;
68 scm_gc_unprotect_object (smob);
69 #else
70 SCM next = scm_cdr (*prot_cons);
72 if (next == SCM_EOL)
73 scm_set_car_x (*prot_cons, SCM_BOOL_F);
74 else
76 scm_set_car_x (*prot_cons, SCM_BOOL_F);
77 while (scm_is_pair (next)
78 && scm_car (next) == SCM_BOOL_F)
80 next = scm_cdr (next);
82 scm_set_cdr_x (*prot_cons, next);
85 *prot_cons = SCM_EOL;
86 #endif