From: Dan Eble Date: Mon, 13 Jul 2015 00:13:57 +0000 (-0400) Subject: Issue 4503 (3/4) Eliminate Tie::get_position_generic X-Git-Tag: release/2.19.24-1~5^2~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6d0e529135e6345f72491358f68242e788baba44;p=lilypond.git Issue 4503 (3/4) Eliminate Tie::get_position_generic --- diff --git a/lily/include/tie.hh b/lily/include/tie.hh index f349ddd612..162637e514 100644 --- a/lily/include/tie.hh +++ b/lily/include/tie.hh @@ -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 &, diff --git a/lily/tie-specification.cc b/lily/tie-specification.cc index 9beb985913..f404ad597c 100644 --- a/lily/tie-specification.cc +++ b/lily/tie-specification.cc @@ -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 (tie)) + position_ = Tie::get_position (spanner); + else if (Item *item = dynamic_cast (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)) { diff --git a/lily/tie.cc b/lily/tie.cc index 57cbf6e3f4..ae81317e39 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -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 (me); - if (spanner) - return get_position (spanner); - - Item *item = dynamic_cast (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]