1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*
This file is part of LilyPond, the GNU music typesetter.
Copyright (C) 2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LilyPond is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
#include "smobs.hh"
class Undead : public Simple_smob<Undead>
{
public:
int print_smob (SCM, scm_print_state *);
SCM mark_smob ();
static const char type_p_name_[];
private:
SCM object_;
public:
SCM object () { return object_; }
Undead (SCM object = SCM_UNDEFINED) : object_ (object) { };
};
SCM
Undead::mark_smob ()
{
bool saved = parsed_objects_should_be_dead;
parsed_objects_should_be_dead = false;
scm_gc_mark (object ());
parsed_objects_should_be_dead = saved;
return SCM_UNDEFINED;
}
int
Undead::print_smob (SCM port, scm_print_state *)
{
scm_puts ("#<Undead ", port);
scm_display (object (), port);
scm_puts (" >", port);
return 1;
}
const char Undead::type_p_name_[] = "ly:undead?";
LY_DEFINE (ly_make_undead, "ly:make-undead",
1, 0, 0, (SCM object),
"This packages @var{object} in a manner that keeps it from"
" triggering \"Parsed object should be dead\" messages.")
{
Undead undead (object);
return undead.smobbed_copy ();
}
LY_DEFINE (ly_get_undead, "ly:get-undead",
1, 0, 0, (SCM undead),
"Get back object from @var{undead}.")
{
LY_ASSERT_SMOB (Undead, undead, 1);
return Undead::unsmob (undead)->object ();
}
// '
// These are not protected since the means of protecting them would be
// problematic to trigger during the mark pass where the array element
// references get set. However, they get set only when in the mark
// pass when checking for parsed elements that should be dead, and we
// query and clear them immediately afterwards. So there should be no
// way in which the references would have become unprotected in the
// mean time.
vector<parsed_dead *> parsed_dead::elements;
SCM
parsed_dead::readout ()
{
SCM result = SCM_EOL;
for (vsize i = 0; i < elements.size (); i++)
{
SCM elt = elements[i]->readout_one ();
if (!SCM_UNBNDP (elt))
result = scm_cons (elt, result);
}
return result;
}
LY_DEFINE (ly_parsed_undead_list_x, "ly:parsed-undead-list!",
0, 0, 0, (),
"Return the list of objects that have been found live"
" that should have been dead, and clear that list.")
{
return parsed_dead::readout ();
}
|