From: Han-Wen Nienhuys Date: Fri, 5 Jan 2007 13:38:28 +0000 (+0100) Subject: coverage fixes. X-Git-Tag: release/2.11.9-1~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=dc7e2924512ad9b770317d5e0e6e960ae87f65af;p=lilypond.git coverage fixes. --- diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index ffc4bfcbfc..9c71e6c448 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -356,29 +356,6 @@ next_spaceable_column (vector const &list, vsize starting) return 0; } -static void -get_column_spring (Grob *this_col, Grob *next_col, Real *ideal, Real *inv_hooke) -{ - Spring_smob *spring = 0; - - for (SCM s = this_col->get_object ("ideal-distances"); - !spring && scm_is_pair (s); - s = scm_cdr (s)) - { - Spring_smob *sp = unsmob_spring (scm_car (s)); - - if (sp->other_ == next_col) - spring = sp; - } - - if (!spring) - programming_error (_f ("No spring between column %d and next one", - Paper_column::get_rank (this_col))); - - *ideal = (spring) ? spring->distance_ : 5.0; - *inv_hooke = (spring) ? spring->inverse_strength_ : 1.0; -} - static Column_description get_column_description (vector const &cols, vsize col_index, bool line_starter) { @@ -389,10 +366,10 @@ get_column_description (vector const &cols, vsize col_index, bool line_st Column_description description; Grob *next_col = next_spaceable_column (cols, col_index); if (next_col) - get_column_spring (col, next_col, &description.ideal_, &description.inverse_hooke_); + Spaceable_grob::get_spring (col, next_col, &description.ideal_, &description.inverse_hooke_); Grob *end_col = dynamic_cast (cols[col_index+1])->find_prebroken_piece (LEFT); if (end_col) - get_column_spring (col, end_col, &description.end_ideal_, &description.end_inverse_hooke_); + Spaceable_grob::get_spring (col, end_col, &description.end_ideal_, &description.end_inverse_hooke_); for (SCM s = Spaceable_grob::get_minimum_distances (col); scm_is_pair (s); s = scm_cdr (s)) diff --git a/lily/spaceable-grob.cc b/lily/spaceable-grob.cc index 7d86ebf919..4ec46bbd84 100644 --- a/lily/spaceable-grob.cc +++ b/lily/spaceable-grob.cc @@ -15,6 +15,7 @@ #include "pointer-group-interface.hh" #include "grob.hh" #include "paper-column.hh" +#include "international.hh" SCM Spaceable_grob::get_minimum_distances (Grob *me) @@ -98,20 +99,29 @@ Spaceable_grob::add_spring (Grob *me, Grob *other, } void -Spaceable_grob::get_spring (Grob *me, Grob *other, Real *dist, Real *inv_strength) +Spaceable_grob::get_spring (Grob *this_col, Grob *next_col, Real *dist, Real *inv_strength) { - for (SCM s = me->get_object ("ideal-distances"); - scm_is_pair (s); s = scm_cdr (s)) + Spring_smob *spring = 0; + + for (SCM s = this_col->get_object ("ideal-distances"); + !spring && scm_is_pair (s); + s = scm_cdr (s)) { - Spring_smob *spring = unsmob_spring (scm_car (s)); - if (spring && spring->other_ == other) - { - *dist = spring->distance_; - *inv_strength = spring->inverse_strength_; - } + Spring_smob *sp = unsmob_spring (scm_car (s)); + + if (sp && sp->other_ == next_col) + spring = sp; } + + if (!spring) + programming_error (_f ("No spring between column %d and next one", + Paper_column::get_rank (this_col))); + + *dist = (spring) ? spring->distance_ : 5.0; + *inv_strength = (spring) ? spring->inverse_strength_ : 1.0; } + void Spaceable_grob::remove_interface (Grob *me) { diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc index d9d58cec70..7a751e14d2 100644 --- a/lily/tie-formatting-problem.cc +++ b/lily/tie-formatting-problem.cc @@ -294,8 +294,7 @@ Tie_formatting_problem::from_ties (vector const &ties) do { spec.note_head_drul_[d] = Tie::head (ties[i], d); - spec.column_ranks_[d] = - dynamic_cast (ties[i])->get_bound (d)->get_column ()->get_rank (); + spec.column_ranks_[d] = Tie::get_column_rank (ties[i], d); } while (flip (&d) != LEFT); specifications_.push_back (spec); @@ -328,7 +327,7 @@ Tie_formatting_problem::from_semi_ties (vector const &semi_ties, Directio spec.get_tie_manual_settings (semi_ties[i]); spec.note_head_drul_[head_dir] = head; - column_rank = dynamic_cast (head)->get_column ()->get_rank (); + column_rank = Tie::get_column_rank (semi_ties[i], head_dir); spec.column_ranks_ = Drul_array (column_rank, column_rank); heads.push_back (head); specifications_.push_back (spec);