]> git.donarmstrong.com Git - lilypond.git/blob - lily/percent-repeat-iterator.cc
* lily/lyric-combine-music-iterator.cc (find_voice): return 0 if
[lilypond.git] / lily / percent-repeat-iterator.cc
1 /*
2   percent-repeat-iterator.cc -- implement Percent_repeat_iterator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2001--2006  Han-Wen Nienhuys <hanwen@xs4all.nl>
7                   Erik Sandberg <mandolaerik@gmail.com>
8 */
9
10 #include "percent-repeat-iterator.hh"
11 #include "input.hh"
12 #include "music.hh"
13 #include "repeated-music.hh"
14
15 IMPLEMENT_CTOR_CALLBACK (Percent_repeat_iterator);
16
17 Percent_repeat_iterator::Percent_repeat_iterator ()
18 {
19 }
20
21 SCM
22 Percent_repeat_iterator::get_music_list () const
23 {
24   /* TODO: Distinction between percent, double-percent and slash */
25   Music *mus = get_music ();
26   Music *child = Repeated_music::body (mus);
27   SCM length = child->get_length ().smobbed_copy ();
28   SCM child_list = SCM_EOL;
29
30   int repeats = scm_to_int (mus->get_property ("repeat-count"));
31   for (int i = repeats; i > 1; i--)
32   {
33     Music *percent = make_music_by_name (ly_symbol2scm ("PercentEvent"));
34     percent->set_spot (*mus->origin ());
35     percent->set_property ("length", length);
36     if (repeats > 1)
37       percent->set_property ("repeat-count", scm_int2num (i));
38     child_list = scm_cons (percent->unprotect (), child_list);
39   }
40   child_list = scm_cons (child->self_scm (), child_list);
41
42   return child_list;
43 }