2 engraver-group-engraver.cc -- implement Engraver_group_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "flower-proto.hh"
10 #include "engraver-group-engraver.hh"
11 #include "engraver.hh"
13 #include "paper-score.hh"
20 Engraver_group_engraver::announce_grob (Grob_info info
)
22 announce_infos_
.push (info
);
23 get_daddy_engraver ()->announce_grob (info
);
27 SCM
find_acknowledge_engravers (SCM gravlist
, SCM meta
);
28 SCM
find_accept_engravers (SCM gravlist
, SCM music_descr
);
31 Engraver_group_engraver::acknowledge_grobs ()
33 if (!announce_infos_
.size ())
36 SCM tab
= get_property ("acknowledgeHashTable");
37 SCM name_sym
= ly_symbol2scm ("name");
38 SCM meta_sym
= ly_symbol2scm ("meta");
41 for (int j
=0; j
< announce_infos_
.size (); j
++)
43 Grob_info info
= announce_infos_
[j
];
45 SCM meta
= info
.grob_
->internal_get_property (meta_sym
);
46 SCM nm
= scm_assoc (name_sym
, meta
);
52 it's tempting to put an assert for
53 immutable_property_alist_ == '(), but in fact, some
54 engravers (clef-engraver) add some more information to the
55 immutable_property_alist_ (after it has been '()-ed).
57 We ignore the grob anyway. He who has no name, shall not
63 SCM acklist
= scm_hashq_ref (tab
, nm
, SCM_UNDEFINED
);
64 if (acklist
== SCM_BOOL_F
)
66 acklist
= find_acknowledge_engravers (scm_cons (self_scm (), get_simple_trans_list ()), meta
);
67 scm_hashq_set_x (tab
, nm
, acklist
);
70 for (SCM p
= acklist
; ly_c_pair_p (p
); p
= ly_cdr (p
))
72 Translator
* t
= unsmob_translator (ly_car (p
));
73 Engraver
* eng
= dynamic_cast<Engraver
*> (t
);
74 if (eng
&& eng
!= info
.origin_trans_
)
75 eng
->acknowledge_grob (info
);
82 Engraver_group_engraver::do_announces ()
86 engraver_each (get_simple_trans_list (),
87 &Engraver::process_acknowledged_grobs
);
89 if (!announce_infos_
.size ())
93 announce_infos_
.clear ();
101 Engraver_group_engraver::initialize ()
103 SCM tab
= scm_make_vector (scm_int2num (61), SCM_BOOL_F
);
104 context ()->set_property ("acknowledgeHashTable", tab
);
106 Translator_group::initialize ();
109 Engraver_group_engraver::Engraver_group_engraver () {}
111 ENTER_DESCRIPTION (Engraver_group_engraver
,
112 /* descr */ "A group of engravers taken together",
125 engraver_valid (Translator
*tr
, SCM ifaces
)
127 SCM ack_ifs
= scm_assoc (ly_symbol2scm ("interfaces-acked"), tr
->translator_description ());
128 ack_ifs
= ly_cdr (ack_ifs
);
129 for (SCM s
= ifaces
; ly_c_pair_p (s
); s
= ly_cdr (s
))
130 if (scm_c_memq (ly_car (s
), ack_ifs
) != SCM_BOOL_F
)
138 find_acknowledge_engravers (SCM gravlist
, SCM meta_alist
)
140 SCM ifaces
= ly_cdr (scm_assoc (ly_symbol2scm ("interfaces"), meta_alist
));
143 for (SCM s
= gravlist
; ly_c_pair_p (s
); s
= ly_cdr (s
))
145 Translator
* tr
= unsmob_translator (ly_car (s
));
146 if (engraver_valid (tr
, ifaces
))
147 l
= scm_cons (tr
->self_scm (), l
);
149 l
= scm_reverse_x (l
, SCM_EOL
);
155 /* c&p engraver-group.cc */
157 recurse_down_engravers (Context
* c
, Engraver_method ptr
, bool context_first
)
159 Engraver_group_engraver
* tg
160 = dynamic_cast<Engraver_group_engraver
*> (c
->implementation ());
165 engraver_each (tg
->get_simple_trans_list (),
171 for (SCM s
= c
->children_contexts () ; ly_c_pair_p (s
);
174 recurse_down_engravers (unsmob_context (ly_car (s
)), ptr
, context_first
);
179 engraver_each (tg
->get_simple_trans_list (),
187 engraver_each (SCM list
, Engraver_method method
)
189 for (SCM p
= list
; ly_c_pair_p (p
); p
= ly_cdr (p
))
191 Engraver
* e
= dynamic_cast<Engraver
*>(unsmob_translator (ly_car (p
)));