]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4503 (3/4) Eliminate Tie::get_position_generic
authorDan Eble <nine.fierce.ballads@gmail.com>
Mon, 13 Jul 2015 00:13:57 +0000 (20:13 -0400)
committerDan Eble <nine.fierce.ballads@gmail.com>
Tue, 21 Jul 2015 18:09:46 +0000 (14:09 -0400)
lily/include/tie.hh
lily/tie-specification.cc
lily/tie.cc

index f349ddd61207903548dd81bddb48193e9d429fc1..162637e514d40579cda173d06c7a23fd04491371 100644 (file)
@@ -32,7 +32,6 @@ public:
   static Item *head (Spanner *, Direction);
   static int get_column_rank (Spanner *, Direction);
   static int get_position (Spanner *);
-  static int get_position_generic (Grob *);
   static Direction get_default_dir (Spanner *);
   static SCM get_control_points (Grob *, Grob *,
                                  Tie_configuration const &,
index 9beb9859136c17d392f1cd6ff2285f4422fef434..f404ad597c4b9514885b3d1e7aa2aed5cddbec18 100644 (file)
@@ -1,5 +1,8 @@
 #include "tie-formatting-problem.hh"
 #include "grob.hh"
+#include "item.hh"
+#include "semi-tie.hh"
+#include "spanner.hh"
 #include "tie.hh"
 #include "libc-extension.hh"
 #include "tie-specification.hh"
@@ -22,6 +25,8 @@ Tie_specification::Tie_specification ()
 void
 Tie_specification::from_grob (Grob *tie)
 {
+  // In this method, Tie and Semi_tie require the same logic with different
+  // types.  It might be clearer to use a template.
   tie_grob_ = tie;
   if (scm_is_number (tie->get_property_data ("direction")))
     {
@@ -29,7 +34,16 @@ Tie_specification::from_grob (Grob *tie)
       has_manual_dir_ = true;
     }
 
-  position_ = Tie::get_position_generic (tie);
+  if (Spanner *spanner = dynamic_cast<Spanner *> (tie))
+    position_ = Tie::get_position (spanner);
+  else if (Item *item = dynamic_cast<Item *> (tie))
+    position_ = Semi_tie::get_position (item);
+  else
+    {
+      programming_error ("grob is neither a tie nor a semi-tie");
+      position_ = 0;
+    }
+
   SCM pos_scm = tie->get_property ("staff-position");
   if (scm_is_number (pos_scm))
     {
index 57cbf6e3f4587f73757600c6d7fcc46b3b7af8d8..ae81317e392665ac08cca89a1926e7853c342f04 100644 (file)
@@ -93,21 +93,6 @@ Tie::get_position (Spanner *me)
   return 0;
 }
 
-int
-Tie::get_position_generic (Grob *me) // TODO: do away with this
-{
-  Spanner *spanner = dynamic_cast<Spanner *> (me);
-  if (spanner)
-    return get_position (spanner);
-
-  Item *item = dynamic_cast<Item *> (me);
-  if (item)
-    return Semi_tie::get_position (item);
-
-  programming_error ("grob is neither a tie nor a semi-tie");
-  return 0;
-}
-
 /*
   Default:  Put the tie oppositie of the stem [Wanske p231]