X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Foutput-property-engraver.cc;h=06bfffefcacfa8b802beaa600273612f26efbc12;hb=c2d44e3a71b2d031305abede97a53f6e5fcf832b;hp=25c156f539ccb1d3626bfb0f262349e10d6f1deb;hpb=d9b43b93f2c885409bafdb157138158f65cc49aa;p=lilypond.git diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc index 25c156f539..06bfffefca 100644 --- a/lily/output-property-engraver.cc +++ b/lily/output-property-engraver.cc @@ -3,31 +3,19 @@ source file of the GNU LilyPond music typesetter - (c) 2000--2002 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 { -TRANSLATOR_DECLARATIONS(Output_property_engraver); +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 (); @@ -39,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; @@ -54,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.grob_l_->self_scm (), SCM_UNDEFINED)); - if (to_boolean (result)) + SCM pred = o->get_property ("predicate"); + + + + if (ly_c_procedure_p (pred)) { - SCM sym = o->get_mus_property ("grob-property"); - SCM val = o->get_mus_property ("grob-value"); - inf.grob_l_->internal_set_grob_property (sym, val); + /* + 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 + { + Context * d = + dynamic_cast (inf.origin_trans_); + + if (!d) + d = dynamic_cast (inf.origin_trans_->context ()); + + SCM proc = o->get_property ("procedure"); + scm_call_3 (proc, + inf.grob_->self_scm (), + d->self_scm (), + context ()->self_scm ()); } } } @@ -76,14 +81,15 @@ Output_property_engraver::stop_translation_timestep () props_.clear (); } -Output_property_engraver::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.", +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 */ "");