]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-check-iterator.cc
Run `make grand-replace'.
[lilypond.git] / lily / bar-check-iterator.cc
1 /*
2   bar-check-iterator.cc -- implement Bar_check_iterator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2001--2008  Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "context.hh"
10 #include "input.hh"
11 #include "international.hh"
12 #include "music.hh"
13 #include "simple-music-iterator.hh"
14
15 /*
16   Check bar checks. We do this outside the engravers so that you can
17   race through the score using skipTypesetting to correct durations.
18 */
19 class Bar_check_iterator : Simple_music_iterator
20 {
21 public:
22   virtual void process (Moment);
23   Bar_check_iterator ();
24   DECLARE_SCHEME_CALLBACK (constructor, ());
25 };
26
27 IMPLEMENT_CTOR_CALLBACK (Bar_check_iterator);
28
29 Bar_check_iterator::Bar_check_iterator ()
30 {
31 }
32
33 void
34 Bar_check_iterator::process (Moment m)
35 {
36   Simple_music_iterator::process (m);
37   if (!m.to_bool ())
38     {
39       Context *tr = get_outlet ();
40
41       SCM check = tr->get_property ("ignoreBarChecks");
42       if (to_boolean (check))
43         return;
44
45       SCM mp = tr->get_property ("measurePosition");
46       SCM sync = tr->get_property ("barCheckSynchronize");
47
48       Moment *where = unsmob_moment (mp);
49       if (!where)
50         return;
51
52       if (where->main_part_)
53         {
54           bool warn = true;
55           if (to_boolean (sync))
56             {
57               SCM mp;
58               tr = tr->where_defined (ly_symbol2scm ("measurePosition"), &mp);
59               Moment zero;
60               tr->set_property ("measurePosition", zero.smobbed_copy ());
61             }
62           else
63             {
64               SCM lf = tr->get_property ("barCheckLastFail");
65               if (unsmob_moment (lf)
66                   && *unsmob_moment (lf) == *where)
67                 warn = false;
68               else
69                 tr->set_property ("barCheckLastFail", mp);
70             }
71
72           if (warn)
73             get_music ()->origin ()->warning (_f ("barcheck failed at: %s",
74                                                   where->to_string ()));
75         }
76     }
77 }