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>
10 #include "engraver.hh"
12 #include "output-property-music-iterator.hh"
14 class Output_property_engraver
: public Engraver
16 TRANSLATOR_DECLARATIONS(Output_property_engraver
);
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
31 Link_array
<Music
> props_
;
33 virtual void stop_translation_timestep ();
34 virtual void acknowledge_grob (Grob_info
);
35 virtual bool try_music (Music
*);
40 Output_property_engraver::try_music (Music
* m
)
42 if (m
->get_mus_property ("iterator-ctor") ==
43 Output_property_music_iterator::constructor_proc
)
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
);
74 Output_property_engraver::stop_translation_timestep ()
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.",
87 /* acks */ "grob-interface",