]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator-dispatch-list.cc
Remove Smob::type_p_name_ default
[lilypond.git] / lily / translator-dispatch-list.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
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.
10
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.
15
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/>.
18 */
19
20 #include "translator-dispatch-list.hh"
21 #include "engraver.hh"
22
23
24 const char * const Engraver_dispatch_list::type_p_name_ = 0;
25
26 void
27 Engraver_dispatch_list::apply (Grob_info gi)
28 {
29   Translator *origin = gi.origin_translator ();
30   for (vsize i = 0; i < dispatch_entries_.size (); i++)
31     {
32       Engraver_dispatch_entry const &e (dispatch_entries_[i]);
33       if (e.engraver_ == origin)
34         continue;
35
36       (e.engraver_->*e.function_) (gi);
37     }
38 }
39
40 SCM
41 Engraver_dispatch_list::create (SCM trans_list,
42                                 SCM iface_list, Direction start_end)
43 {
44   SCM retval = Engraver_dispatch_list ().smobbed_copy ();
45   Engraver_dispatch_list *list = unsmob<Engraver_dispatch_list> (retval);
46
47   Engraver_dispatch_entry entry;
48   bool found = false;
49   for (SCM s = trans_list; scm_is_pair (s); s = scm_cdr (s))
50     {
51       Engraver *eng
52         = unsmob<Engraver> (scm_car (s));
53
54       if (!eng)
55         continue;
56
57       entry.engraver_ = eng;
58       for (SCM i = iface_list; scm_is_pair (i); i = scm_cdr (i))
59         {
60           Translator::Grob_info_callback ptr
61             = (start_end == START)
62               ? eng->get_acknowledger (scm_car (i))
63               : eng->get_end_acknowledger (scm_car (i));
64
65           if (ptr)
66             {
67               entry.function_ = ptr;
68               list->dispatch_entries_.push_back (entry);
69               found = true;
70             }
71         }
72     }
73
74   return found ? retval : SCM_EOL;
75 }