]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4834: Remove routing information from Grob_info
authorDavid Kastrup <dak@gnu.org>
Mon, 25 Apr 2016 15:20:30 +0000 (17:20 +0200)
committerDavid Kastrup <dak@gnu.org>
Mon, 2 May 2016 18:29:02 +0000 (20:29 +0200)
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.

lily/auto-beam-engraver.cc
lily/engraver-group.cc
lily/engraver.cc
lily/grob-info.cc
lily/include/engraver-group.hh
lily/include/engraver.hh
lily/include/grob-info.hh
lily/include/score-engraver.hh
lily/score-engraver.cc
lily/span-bar-stub-engraver.cc

index 7500ec9ef09bf9fb9af7dc4d272c2e8d2c0e3218..37872577387bd1750a5e30d24558e45b7ea1c8a8 100644 (file)
@@ -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_;
         }
index cf1832fe1fb73dd25f93e621e7a20d077485bbd0..35c14d460ddb3646cd3597048cd8f517b0c890fc 100644 (file)
@@ -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);
index 7891a1b9eb8fe17f44409f314ef6be32fe4d229c..25ae579bd7dbcd59f844b28c05b51d1db54e9d4a 100644 (file)
@@ -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
index ef991418a1510ac2cd14f8acb9a8e8aa7a470aa1..aab0d3cb8d61b352cf381969d479982d7300f08e 100644 (file)
@@ -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 *
index aa3cd478bce652c5bc6a098e0250be689a38d0f0..39e52f3c522e7bca705164e6d65301da2504eed5 100644 (file)
 #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 ();
index 70e168d783ad15b1b18c64ccd7e2c7bb31d7d74d..956f49365b6cc17d4e65c8734d4ec4227cb2bb3d 100644 (file)
@@ -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:
index 1df88ce749f2de9204db3684c38bcf017367db34..6d418379c917402a346f03b03642da436459a205 100644 (file)
@@ -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
index 9b7927ddab680a6be67089e4d0a85f6f193e35e3..d0ec7821679d13da39e8e90dd9c3d6495ee4680d 100644 (file)
@@ -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 ();
 
   /*
index 0415d5e4a1c72c6a6be52019b2553474b501358f..3e4fb973152f691fce87f9d2bed7052227d13820 100644 (file)
@@ -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 ());
index 3517c3f5fd38e6e3938a567b90f63caab4adf733..304564398f0841c7832aa8d5412f6b8e04a30459 100644 (file)
@@ -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 ();
         }