* stepmake/stepmake/metafont-rules.make: backport 1.7 fixes.
[lilypond.git] / lily / output-property-engraver.cc
blob17b025423c3a73d8837ae2c7eec2d320b1733c5c
1 /*
2 output-property-engraver.cc -- implement Output_property_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "engraver.hh"
11 #include "grob.hh"
12 #include "output-property-music-iterator.hh"
14 class Output_property_engraver : public Engraver
16 TRANSLATOR_DECLARATIONS(Output_property_engraver);
17 protected:
20 should do this with \once and \push ?
23 \property Voice.outputProperties \push #pred = #modifier
25 where both MODIFIER and PRED are functions taking a
26 grob.
31 Link_array<Music> props_;
33 virtual void stop_translation_timestep ();
34 virtual void acknowledge_grob (Grob_info);
35 virtual bool try_music (Music*);
39 bool
40 Output_property_engraver::try_music (Music* m)
42 if (m->get_mus_property ("iterator-ctor") ==
43 Output_property_music_iterator::constructor_proc)
45 props_.push (m);
46 return true;
48 return false;
51 void
52 Output_property_engraver::acknowledge_grob (Grob_info inf)
54 for (int i=props_.size (); i--;)
56 Music * o = props_[i];
57 SCM pred = o->get_mus_property ("predicate");
60 should typecheck pred.
62 SCM result=gh_apply (pred,
63 scm_list_n (inf.grob_->self_scm (), SCM_UNDEFINED));
64 if (to_boolean (result))
66 SCM sym = o->get_mus_property ("grob-property");
67 SCM val = o->get_mus_property ("grob-value");
68 inf.grob_->internal_set_grob_property (sym, val);
73 void
74 Output_property_engraver::stop_translation_timestep ()
76 props_.clear ();
79 Output_property_engraver::Output_property_engraver()
83 ENTER_DESCRIPTION(Output_property_engraver,
84 /* descr */ "Interpret Music of Output_property type, and apply a function
85 to any Graphic objects that satisfies the predicate.",
86 /* creats*/ "",
87 /* acks */ "grob-interface",
88 /* reads */ "",
89 /* write */ "");