diff options
author | David Kastrup <dak@gnu.org> | 2016-04-25 17:20:30 +0200 |
---|---|---|
committer | David Kastrup <dak@gnu.org> | 2016-05-02 20:29:02 +0200 |
commit | f947f7e126ccaaea212a7e65ed458a05555c771e (patch) | |
tree | 231d16a2e66086966a3205971ce6911b05a0a545 /lily | |
parent | 07320557cd246fd3f4837f15b4f80b098f048981 (diff) |
Issue 4834: Remove routing information from Grob_info
Routing information manages how to pass information to acknowledgers
but should not reach the acknowledgers themselves. Moving this
information into arguments for the various kinds of announce_grob
procedures is cleaner and allows to bounce Grob_info through Scheme
without the danger of information loss.
Diffstat (limited to 'lily')
-rw-r--r-- | lily/auto-beam-engraver.cc | 6 | ||||
-rw-r--r-- | lily/engraver-group.cc | 17 | ||||
-rw-r--r-- | lily/engraver.cc | 9 | ||||
-rw-r--r-- | lily/grob-info.cc | 4 | ||||
-rw-r--r-- | lily/include/engraver-group.hh | 15 | ||||
-rw-r--r-- | lily/include/engraver.hh | 4 | ||||
-rw-r--r-- | lily/include/grob-info.hh | 17 | ||||
-rw-r--r-- | lily/include/score-engraver.hh | 2 | ||||
-rw-r--r-- | lily/score-engraver.cc | 6 | ||||
-rw-r--r-- | lily/span-bar-stub-engraver.cc | 3 |
10 files changed, 36 insertions, 47 deletions
diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 7500ec9ef0..3787257738 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -223,8 +223,7 @@ Auto_beam_engraver::create_beam () Beam::add_stem (beam, (*stems_)[i]); Grob_info i = make_grob_info (beam, (*stems_)[0]->self_scm ()); - i.rerouting_daddy_context_ = beam_start_context_.get_context (); - announce_grob (i); + announce_grob (i, beam_start_context_.get_context ()); return beam; } @@ -283,9 +282,8 @@ Auto_beam_engraver::end_beam () if (finished_beam_) { Grob_info i = make_grob_info (finished_beam_, SCM_EOL); - i.rerouting_daddy_context_ = beam_start_context_.get_context (); - announce_end_grob (i); + announce_end_grob (i, beam_start_context_.get_context ()); finished_grouping_ = grouping_; finished_beaming_options_ = beaming_options_; } diff --git a/lily/engraver-group.cc b/lily/engraver-group.cc index cf1832fe1f..35c14d460d 100644 --- a/lily/engraver-group.cc +++ b/lily/engraver-group.cc @@ -92,16 +92,13 @@ Engraver_group::disconnect_from_context () } void -Engraver_group::announce_grob (Grob_info info) +Engraver_group::announce_grob (Grob_info info, Direction dir, + Context *reroute_context) { - announce_infos_.push_back (info); + announce_infos_.push_back (Announce_grob_info (info, dir)); - Context *dad_con = context_->get_parent_context (); - if (info.rerouting_daddy_context_) - { - dad_con = info.rerouting_daddy_context_; - info.rerouting_daddy_context_ = 0; - } + Context *dad_con = reroute_context ? reroute_context + : context_->get_parent_context (); Engraver_group *dad_eng = dad_con @@ -109,7 +106,7 @@ Engraver_group::announce_grob (Grob_info info) : 0; if (dad_eng) - dad_eng->announce_grob (info); + dad_eng->announce_grob (info, dir); } void @@ -122,7 +119,7 @@ Engraver_group::acknowledge_grobs () for (vsize j = 0; j < announce_infos_.size (); j++) { - Grob_info info = announce_infos_[j]; + Announce_grob_info info = announce_infos_[j]; SCM meta = info.grob ()->get_property ("meta"); SCM nm = scm_assoc (name_sym, meta); diff --git a/lily/engraver.cc b/lily/engraver.cc index 7891a1b9eb..25ae579bd7 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -36,16 +36,15 @@ Engraver::get_daddy_engraver () const } void -Engraver::announce_grob (Grob_info inf) +Engraver::announce_grob (Grob_info inf, Context *reroute_context) { - get_daddy_engraver ()->announce_grob (inf); + get_daddy_engraver ()->announce_grob (inf, START, reroute_context); } void -Engraver::announce_end_grob (Grob_info inf) +Engraver::announce_end_grob (Grob_info inf, Context *reroute_context) { - inf.start_end_ = STOP; - get_daddy_engraver ()->announce_grob (inf); + get_daddy_engraver ()->announce_grob (inf, STOP, reroute_context); } Grob_info diff --git a/lily/grob-info.cc b/lily/grob-info.cc index ef991418a1..aab0d3cb8d 100644 --- a/lily/grob-info.cc +++ b/lily/grob-info.cc @@ -29,8 +29,6 @@ Grob_info::Grob_info (Translator *t, Grob *g) { origin_trans_ = t; grob_ = g; - start_end_ = START; - rerouting_daddy_context_ = 0; /* assert here, because this is easier to debug. @@ -41,9 +39,7 @@ Grob_info::Grob_info (Translator *t, Grob *g) Grob_info::Grob_info () { grob_ = 0; - start_end_ = START; origin_trans_ = 0; - rerouting_daddy_context_ = 0; } Stream_event * diff --git a/lily/include/engraver-group.hh b/lily/include/engraver-group.hh index aa3cd478bc..39e52f3c52 100644 --- a/lily/include/engraver-group.hh +++ b/lily/include/engraver-group.hh @@ -23,10 +23,20 @@ #include "engraver.hh" #include "translator-group.hh" +class Announce_grob_info : public Grob_info +{ + Direction start_end_; +public: + Announce_grob_info (Grob_info gi, Direction start_end) + : Grob_info (gi), start_end_ (start_end) + { } + Direction start_end () const { return start_end_; } +}; + class Engraver_group : public Translator_group { protected: - vector<Grob_info> announce_infos_; + vector<Announce_grob_info> announce_infos_; Drul_array<SCM> acknowledge_hash_table_drul_; void override (SCM); void revert (SCM); @@ -37,7 +47,8 @@ public: void do_announces (); virtual void connect_to_context (Context *c); virtual void disconnect_from_context (); - virtual void announce_grob (Grob_info); + virtual void announce_grob (Grob_info, Direction start_end, + Context *reroute_context = 0); bool pending_grobs () const; private: virtual void acknowledge_grobs (); diff --git a/lily/include/engraver.hh b/lily/include/engraver.hh index 70e168d783..956f49365b 100644 --- a/lily/include/engraver.hh +++ b/lily/include/engraver.hh @@ -41,8 +41,8 @@ protected: Default: ignore the info */ virtual void acknowledge_grob (Grob_info) {} - virtual void announce_grob (Grob_info); - virtual void announce_end_grob (Grob_info); + virtual void announce_grob (Grob_info, Context *reroute_context = 0); + virtual void announce_end_grob (Grob_info, Context *reroute_context = 0); Engraver_group *get_daddy_engraver () const; public: diff --git a/lily/include/grob-info.hh b/lily/include/grob-info.hh index 1df88ce749..6d418379c9 100644 --- a/lily/include/grob-info.hh +++ b/lily/include/grob-info.hh @@ -17,8 +17,8 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef STAFFELEMINFO_HH -#define STAFFELEMINFO_HH +#ifndef GROB_INFO_HH +#define GROB_INFO_HH #include "lily-guile.hh" #include "lily-proto.hh" @@ -31,11 +31,8 @@ class Grob_info { Translator *origin_trans_; Grob *grob_; - Direction start_end_; - friend class Engraver; public: - Direction start_end () const { return start_end_; } Grob *grob () const { return grob_; } Translator *origin_translator () const { return origin_trans_; } @@ -49,14 +46,6 @@ public: Item *item () const; Spanner *spanner () const; static bool less (Grob_info i, Grob_info j); - - /* - For contexts that change staves, it may be desirable to emit a - grob into a staff other than the current one. If this is non-null, - this grob should be announced in this context instead of the - daddy_context_. - */ - Context *rerouting_daddy_context_; }; -#endif // STAFFELEMINFO_HH +#endif // GROB_INFO_HH diff --git a/lily/include/score-engraver.hh b/lily/include/score-engraver.hh index 9b7927ddab..d0ec782167 100644 --- a/lily/include/score-engraver.hh +++ b/lily/include/score-engraver.hh @@ -41,7 +41,7 @@ protected: virtual void disconnect_from_context (); virtual void initialize (); virtual void finalize (); - virtual void announce_grob (Grob_info); + virtual void announce_grob (Grob_info, Direction dir, Context *reroute_context = 0); void stop_translation_timestep (); /* diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index 0415d5e4a1..3e4fb97315 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -155,10 +155,10 @@ Score_engraver::one_time_step (SCM) } void -Score_engraver::announce_grob (Grob_info info) +Score_engraver::announce_grob (Grob_info info, Direction start_end, Context *reroute_context) { - Engraver_group::announce_grob (info); - if (info.start_end () == START) + Engraver_group::announce_grob (info, start_end, reroute_context); + if (start_end == START) { pscore_->root_system ()->typeset_grob (info.grob ()); elems_.push_back (info.grob ()); diff --git a/lily/span-bar-stub-engraver.cc b/lily/span-bar-stub-engraver.cc index 3517c3f5fd..304564398f 100644 --- a/lily/span-bar-stub-engraver.cc +++ b/lily/span-bar-stub-engraver.cc @@ -148,8 +148,7 @@ Span_bar_stub_engraver::process_acknowledged () Item *it = new Item (Grob_property_info (affected_contexts[j], ly_symbol2scm ("SpanBarStub")).updated ()); it->set_parent (spanbars_[i], X_AXIS); Grob_info gi = make_grob_info (it, spanbars_[i]->self_scm ()); - gi.rerouting_daddy_context_ = affected_contexts[j]; - announce_grob (gi); + announce_grob (gi, affected_contexts[j]); if (!keep_extent[j]) it->suicide (); } |