X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Foutput-property-engraver.cc;h=ee17d82b079010f86633d12f0cd7bd07ad108851;hb=a54fef48345564ae701839c525379939c840638d;hp=f022bf56d7a072ae7c72c7a2a0096b184ac7347e;hpb=75f8a001fe30f30fa2d32a961218d0f1cdbeeb7e;p=lilypond.git diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc index f022bf56d7..ee17d82b07 100644 --- a/lily/output-property-engraver.cc +++ b/lily/output-property-engraver.cc @@ -3,32 +3,19 @@ source file of the GNU LilyPond music typesetter - (c) 2000--2001 Han-Wen Nienhuys + (c) 2000--2004 Han-Wen Nienhuys */ #include "engraver.hh" #include "grob.hh" -#include "output-property-music-iterator.hh" +#include "context.hh" + class Output_property_engraver : public Engraver { -public: - VIRTUAL_COPY_CONS (Translator); +TRANSLATOR_DECLARATIONS(Output_property_engraver); protected: - - /* - should do this with \once and \push ? - - - \property Voice.outputProperties \push #pred = #modifier - - where both MODIFIER and PRED are functions taking a - grob. - - */ - - Link_array props_; virtual void stop_translation_timestep (); @@ -40,8 +27,7 @@ protected: bool Output_property_engraver::try_music (Music* m) { - if (m->get_mus_property ("iterator-ctor") == - Output_property_music_iterator::constructor_cxx_function) + if (m->is_mus_type ("layout-instruction")) { props_.push (m); return true; @@ -55,18 +41,36 @@ Output_property_engraver::acknowledge_grob (Grob_info inf) for (int i=props_.size (); i--;) { Music * o = props_[i]; - SCM pred = o->get_mus_property ("predicate"); - - /* - should typecheck pred. - */ - SCM result=gh_apply (pred, - scm_list_n (inf.elem_l_->self_scm (), SCM_UNDEFINED)); - if (to_boolean (result)) + SCM pred = o->get_property ("predicate"); + + + + if (gh_procedure_p (pred)) + { + /* + should typecheck pred. + */ + SCM result=scm_call_1 (pred, inf.grob_->self_scm ()); + if (to_boolean (result)) + { + SCM sym = o->get_property ("grob-property"); + SCM val = o->get_property ("grob-value"); + inf.grob_->internal_set_property (sym, val); + } + } + else { - SCM sym = o->get_mus_property ("grob-property"); - SCM val = o->get_mus_property ("grob-value"); - inf.elem_l_->set_grob_property (sym, val); + Context * d = + dynamic_cast (inf.origin_trans_); + + if (!d) + d = dynamic_cast (inf.origin_trans_->daddy_context_); + + SCM proc = o->get_property ("procedure"); + scm_call_3 (proc, + inf.grob_->self_scm(), + d->self_scm(), + daddy_context_->self_scm()); } } } @@ -77,4 +81,15 @@ Output_property_engraver::stop_translation_timestep () props_.clear (); } -ADD_THIS_TRANSLATOR (Output_property_engraver); +Output_property_engraver::Output_property_engraver() +{ +} + +ENTER_DESCRIPTION(Output_property_engraver, +/* descr */ "Interpret Music of Output_property type, and apply a function " +" to any Graphic objects that satisfies the predicate.", +/* creats*/ "", +/* accepts */ "layout-instruction", +/* acks */ "grob-interface", +/* reads */ "", +/* write */ "");