Web-es: update NEWS.
[lilypond/patrick.git] / lily / translator-dispatch-list.cc
blobaae00e4e1cd2f948edb47ace56a684257f0d3a89
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 "translator-dispatch-list.hh"
21 #include "engraver.hh"
23 #include "ly-smobs.icc"
25 void
26 Engraver_dispatch_list::apply (Grob_info gi)
28 Translator *origin = gi.origin_translator ();
29 for (vsize i = 0; i < dispatch_entries_.size (); i++)
31 Engraver_dispatch_entry const &e (dispatch_entries_[i]);
32 if (e.engraver_ == origin)
33 continue;
35 (*e.function_) (e.engraver_, gi);
39 SCM
40 Engraver_dispatch_list::create (SCM trans_list,
41 SCM iface_list, Direction start_end)
43 SCM retval = Engraver_dispatch_list ().smobbed_copy ();
44 Engraver_dispatch_list *list = Engraver_dispatch_list::unsmob (retval);
46 Engraver_dispatch_entry entry;
47 bool found = false;
48 for (SCM s = trans_list; scm_is_pair (s); s = scm_cdr (s))
50 Engraver *eng
51 = dynamic_cast<Engraver *> (unsmob_translator (scm_car (s)));
53 if (!eng)
54 continue;
56 entry.engraver_ = eng;
57 for (SCM i = iface_list; scm_is_pair (i); i = scm_cdr (i))
59 Engraver_void_function_engraver_grob_info ptr
60 = (start_end == START)
61 ? eng->get_acknowledger (scm_car (i))
62 : eng->get_end_acknowledger (scm_car (i));
64 if (ptr)
66 entry.function_ = ptr;
67 list->dispatch_entries_.push_back (entry);
68 found = true;
73 return found ? retval : SCM_EOL;
76 SCM
77 Engraver_dispatch_list::mark_smob (SCM)
79 return SCM_BOOL_F;
82 int
83 Engraver_dispatch_list::print_smob (SCM /* x */,
84 SCM p,
85 scm_print_state *)
87 scm_puts ("#<Engraver_dispatch_list>", p);
88 return 1;
91 IMPLEMENT_SIMPLE_SMOBS (Engraver_dispatch_list);
92 IMPLEMENT_DEFAULT_EQUAL_P (Engraver_dispatch_list);