From: Han-Wen Nienhuys Date: Wed, 4 May 2005 10:35:56 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: release/2.5.24~65 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=791feccaca7f6dd5c11773c766e94ab5f757993c;p=lilypond.git *** empty log message *** --- diff --git a/ChangeLog b/ChangeLog index 3406001df9..081397d992 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2005-05-04 Han-Wen Nienhuys + * lily/*.cc: more ? to min/max changes + * lily/include/interpretation-context-handle.hh: rename Interpretation_context_handle to Context_handle. diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 7bfc3385f1..ea9dba5010 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -26,8 +26,8 @@ SCM Rest_collision::force_shift_callback (SCM element_smob, SCM axis) { Grob *them = unsmob_grob (element_smob); - Axis a = (Axis) scm_to_int (axis); - assert (a == Y_AXIS); + (void) axis; + assert (scm_to_int (axis) == Y_AXIS); if (Note_column::has_rests (them)) { @@ -234,7 +234,7 @@ Rest_collision::do_shift (Grob *me) } Real dist - = minimum_dist + dir * (notedim[dir] - restdim[-dir]) >? 0; + = minimum_dist + dir * max (notedim[dir] - restdim[-dir], 0.0); int stafflines = Staff_symbol_referencer::line_count (me); if (!stafflines) diff --git a/lily/scm-hash.cc b/lily/scm-hash.cc index af73ca3a30..f59adc0104 100644 --- a/lily/scm-hash.cc +++ b/lily/scm-hash.cc @@ -9,9 +9,12 @@ #include "scm-hash.hh" #include +#include #include "ly-smobs.icc" +using namespace std; + /* Return: number of objects. */ @@ -43,7 +46,7 @@ Scheme_hash_table::Scheme_hash_table (Scheme_hash_table const &src) elt_count_ = 0; smobify_self (); - hash_tab_ = scm_make_vector (scm_int2num (src.elt_count_ >? 11), SCM_EOL); + hash_tab_ = scm_make_vector (scm_int2num (max ((int) src.elt_count_, 11)), SCM_EOL); elt_count_ = copy_scm_hashes (hash_tab_, src.hash_tab_); } @@ -53,7 +56,7 @@ Scheme_hash_table::operator = (Scheme_hash_table const &src) if (&src == this) return; - hash_tab_ = scm_make_vector (scm_int2num (src.elt_count_ >? 11), SCM_EOL); + hash_tab_ = scm_make_vector (scm_int2num (max ((int) src.elt_count_, 11)), SCM_EOL); elt_count_ = copy_scm_hashes (hash_tab_, src.hash_tab_); } diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index eed4f322bc..d9689abaaa 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -9,6 +9,8 @@ #include "side-position-interface.hh" #include // ceil. +#include + #include "note-head.hh" #include "warn.hh" @@ -20,6 +22,8 @@ #include "staff-symbol-referencer.hh" #include "string-convert.hh" +using namespace std; + void Side_position_interface::add_support (Grob *me, Grob *e) { @@ -226,7 +230,7 @@ Side_position_interface::aligned_side (SCM element_smob, SCM axis) Interval staff_size = st->extent (common, Y_AXIS); Real diff = d*staff_size[d] + padding - d * (o + iv[-d]); - o += (d * (diff >? 0)); + o += d * max (diff, 0.0); } return scm_make_real (o); diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index 5f21a62a3b..f23dfb8450 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -100,11 +100,10 @@ Simple_spacer::add_rod (int l, int r, Real dist) Real block_stretch = dist - d; Real block_force = c * block_stretch; - force_ = force_ >? block_force; + force_ = max (force_, block_force); for (int i = l; i < r; i++) - springs_[i].block_force_ = block_force >? - springs_[i].block_force_; + springs_[i].block_force_ = max (block_force, springs_[i].block_force_); } Real @@ -136,7 +135,7 @@ Simple_spacer::active_blocking_force () const for (int i = 0; i < springs_.size (); i++) if (springs_[i].is_active_) { - bf = bf >? springs_[i].block_force_; + bf = max (bf, springs_[i].block_force_); } return bf; } @@ -222,7 +221,7 @@ Simple_spacer::my_solve_natural_len () while (is_active ()) { - force_ = active_blocking_force () >? 0.0; + force_ = max (active_blocking_force (), 0.0); Real conf = configuration_length (); if (conf < line_len_) diff --git a/lily/skyline.cc b/lily/skyline.cc index b3b6349461..455ebb2b9b 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -155,7 +155,7 @@ skyline_meshing_distance (Array const &buildings, w.intersect (clouds[j].width_); if (!w.is_empty ()) - distance = distance >? (buildings[i].height_ - clouds[j].height_); + distance = max (distance, (buildings[i].height_ - clouds[j].height_)); if (i > 0 && buildings[i].width_[LEFT] >= clouds[j].width_[LEFT]) { diff --git a/lily/slur-configuration.cc b/lily/slur-configuration.cc index 4d4e3de171..7fe077d12e 100644 --- a/lily/slur-configuration.cc +++ b/lily/slur-configuration.cc @@ -88,7 +88,7 @@ fit_factor (Offset dz_unit, Offset dz_perp, Real y = curve.get_other_coordinate (X_AXIS, p[X_AXIS]); if (y) { - fit_factor = fit_factor >? (p[Y_AXIS] / y); + fit_factor = max (fit_factor, (p[Y_AXIS] / y)); } } return fit_factor; @@ -108,7 +108,7 @@ Slur_configuration::generate_curve (Slur_score_state const &state, continue; Encompass_info inf (state.get_encompass_info (encompasses[i])); - Real y = state.dir_ * ((state.dir_ * inf.head_) >? (state.dir_ * inf.stem_)); + Real y = state.dir_ * (max (state.dir_ * inf.head_, state.dir_ * inf.stem_)); avoid.push (Offset (inf.x_, y + state.dir_ * state.parameters_.free_head_distance_)); } @@ -151,7 +151,7 @@ Slur_configuration::generate_curve (Slur_score_state const &state, (control3 - control0). */ Real max_indent = len / 3.1; - indent = indent ? ((height * ff) ? 0)? state.dir_ * line_y); + = state.dir_ * max (state.dir_ * state.encompass_infos_[j].get_point (state.dir_), state.dir_ * line_y); Real d = fabs (closest - y); convex_head_distances.push (d); @@ -279,8 +278,7 @@ Slur_configuration::score_encompass (Slur_score_state const &state) // ? demerit += -state.parameters_.closeness_factor_ * (state.dir_ - * (y - (ext[state.dir_] + state.dir_ * state.parameters_.free_head_distance_)) - 0.0) variance_penalty - = (avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_) - 1.0) - ? 0.0; + variance_penalty = max (variance_penalty, 0.0); variance_penalty *= state.parameters_.head_slur_distance_factor_; } @@ -382,7 +379,7 @@ Slur_configuration::score_extra_encompass (Slur_score_state const &state) Real dist = state.extra_encompass_infos_[j].extents_[Y_AXIS].distance (y); demerit - += fabs (0 >? (state.parameters_.extra_encompass_free_distance_ - dist)) + += fabs (max (0.0, (state.parameters_.extra_encompass_free_distance_ - dist))) / state.parameters_.extra_encompass_free_distance_ * state.extra_encompass_infos_[j].penalty_; } @@ -430,8 +427,8 @@ Slur_configuration ::score_slopes (Slur_score_state const &state) Real slur_dy = slur_dz[Y_AXIS]; Real demerit = 0.0; - demerit += ((fabs (slur_dy / slur_dz[X_AXIS]) - - state.parameters_.max_slope_) >? 0) + demerit += max ((fabs (slur_dy / slur_dz[X_AXIS]) + - state.parameters_.max_slope_), 0.0) * state.parameters_.max_slope_factor_; /* 0.2: account for staffline offset. */ @@ -441,10 +438,10 @@ Slur_configuration ::score_slopes (Slur_score_state const &state) if (!state.is_broken_) demerit += state.parameters_.steeper_slope_factor_ - * ((fabs (slur_dy) -max_dy) >? 0); + * (max (fabs (slur_dy) -max_dy, >? 0.0)); - demerit += ((fabs (slur_dy / slur_dz[X_AXIS]) - - state.parameters_.max_slope_) >? 0) + demerit += max ((fabs (slur_dy / slur_dz[X_AXIS]) + - state.parameters_.max_slope_), 0.0) * state.parameters_.max_slope_factor_; if (sign (dy) == 0 diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index 160e157089..9b005386c4 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -469,10 +469,9 @@ Slur_score_state::get_y_attachment_range () const if (extremes_[d].note_column_) { end_ys[d] = dir_ - * ((dir_ * (base_attachments_[d][Y_AXIS] + parameters_.region_size_ * dir_)) - >? (dir_ * (dir_ + extremes_[d].note_column_->extent (common_[Y_AXIS], - Y_AXIS)[dir_])) - >? (dir_ * base_attachments_[-d][Y_AXIS])); + * max (max (dir_ * (base_attachments_[d][Y_AXIS] + parameters_.region_size_ * dir_), + dir_ * (dir_ + extremes_[d].note_column_->extent (common_[Y_AXIS], Y_AXIS)[dir_])), + dir_ * base_attachments_[-d][Y_AXIS]); } else end_ys[d] = base_attachments_[d][Y_AXIS] + parameters_.region_size_ * dir_; diff --git a/lily/slur.cc b/lily/slur.cc index 929353c00a..3e1ee4f126 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -130,6 +130,7 @@ Slur::outside_slur_callback (SCM grob, SCM axis) { Grob *script = unsmob_grob (grob); Axis a = Axis (scm_to_int (axis)); + (void) a; assert (a == Y_AXIS); Grob *slur = unsmob_grob (script->get_property ("slur")); @@ -187,8 +188,8 @@ Slur::outside_slur_callback (SCM grob, SCM axis) Direction dir = get_grob_direction (script); for (int d = LEFT; d <= RIGHT; d++) { - offset = dir * (dir * offset >? dir - * (ys[k] - yext[-dir] + dir * slur_padding)); + offset = dir * (max (dir * offset, + dir * (ys[k] - yext[-dir] + dir * slur_padding))); k++; } } diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 4ed3029df7..388ab5666d 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -114,8 +114,9 @@ SCM Span_bar::width_callback (SCM element_smob, SCM scm_axis) { Grob *se = unsmob_grob (element_smob); - Axis a = (Axis) scm_to_int (scm_axis); - assert (a == X_AXIS); + (void) scm_axis; + + assert ( (Axis) scm_to_int (scm_axis) == X_AXIS); String gl = ly_scm2string (se->get_property ("glyph")); /* @@ -146,8 +147,8 @@ SCM Span_bar::center_on_spanned_callback (SCM element_smob, SCM axis) { Grob *me = unsmob_grob (element_smob); - Axis a = (Axis) scm_to_int (axis); - assert (a == Y_AXIS); + (void) axis; + assert (scm_to_int (axis) == Y_AXIS); Interval i (get_spanned_interval (me)); /* Bar_line::print delivers a barline of y-extent (-h/2, h/2), so diff --git a/lily/staff-spacing.cc b/lily/staff-spacing.cc index b175987674..762e039dc1 100644 --- a/lily/staff-spacing.cc +++ b/lily/staff-spacing.cc @@ -32,7 +32,7 @@ Staff_spacing::next_note_correction (Grob *me, return 0.0; Item *col = dynamic_cast (g)->get_column (); - Real max_corr = 0. >? (- g->extent (col, X_AXIS)[LEFT]); + Real max_corr = max (0., (- g->extent (col, X_AXIS)[LEFT])); /* Duh. If this gets out of hand, we should invent something more generic. @@ -47,11 +47,11 @@ Staff_spacing::next_note_correction (Grob *me, else v = a->extent (col, X_AXIS); - max_corr = max_corr >? (- v[LEFT]); + max_corr = max (max_corr, (- v[LEFT])); } if (Grob *a = unsmob_grob (g->get_property ("arpeggio"))) { - max_corr = max_corr >? (- a->extent (col, X_AXIS)[LEFT]); + max_corr = max (max_corr, - a->extent (col, X_AXIS)[LEFT]); } /* @@ -69,18 +69,18 @@ Staff_spacing::next_note_correction (Grob *me, { Real stem_start = Stem::head_positions (stem) [DOWN]; Real stem_end = Stem::stem_end_position (stem); - Interval stem_posns (stem_start ? stem_start); + Interval stem_posns (min (stem_start, stem_end), + max (stem_end, stem_start)); stem_posns.intersect (bar_size); - Real corr = abs (stem_posns.length () / 7.) get_property ("stem-spacing-correction"), 1); if (d != DOWN) corr = 0.0; - max_corr = max_corr >? corr; + max_corr = max (max_corr, corr); } } return max_corr; @@ -128,10 +128,10 @@ Staff_spacing::next_notes_correction (Grob *me, Grob *last_grob) { Grob *g = unsmob_grob (scm_car (s)); - max_corr = max_corr >? next_note_correction (me, g, bar_size); + max_corr = max (max_corr, next_note_correction (me, g, bar_size)); for (SCM t = g->get_property ("elements"); scm_is_pair (t); t = scm_cdr (t)) - max_corr = max_corr >? next_note_correction (me, unsmob_grob (scm_car (t)), bar_size); + max_corr = max (max_corr, next_note_correction (me, unsmob_grob (scm_car (t)), bar_size)); } return max_corr; @@ -223,11 +223,11 @@ Staff_spacing::get_spacing_params (Grob *me, Real *space, Real *fixed) } else if (type == ly_symbol2scm ("minimum-space")) { - *space = last_ext[LEFT] + (last_ext.length () >? distance); + *space = last_ext[LEFT] + max (last_ext.length (), distance); } else if (type == ly_symbol2scm ("minimum-fixed-space")) { - *space = last_ext[LEFT] + (last_ext.length () >? distance); + *space = last_ext[LEFT] + max (last_ext.length (), distance); *fixed = *space; } diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index b68699725c..b1daa6284b 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -144,7 +144,7 @@ Stem_tremolo::print (SCM grob) Real end_y = Stem::stem_end_position (stem) * ss / 2 - stemdir * (beam_count * beamthickness - + ((beam_count -1) >? 0) * beam_translation); + + (max (beam_count -1, 0) * beam_translation)); /* FIXME: the 0.33 ss is to compensate for the size of the note head. */ Real chord_start_y = Stem::chord_start_y (stem) + 0.33 * ss * stemdir; diff --git a/lily/stem.cc b/lily/stem.cc index 5eebd974e5..2bdc2fbcf5 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -298,7 +298,7 @@ Stem::get_default_stem_end_position (Grob *me) { SCM sshorten = me->get_property ("stem-shorten"); SCM scm_shorten = scm_is_pair (sshorten) - ? robust_list_ref ((duration_log (me) - 2) >? 0, sshorten) : SCM_EOL; + ? robust_list_ref (max (duration_log (me) - 2, 0), sshorten) : SCM_EOL; Real shorten = 2* robust_scm2double (scm_shorten, 0); /* On boundary: shorten only half */ @@ -332,7 +332,7 @@ Stem::get_default_stem_end_position (Grob *me) if (dir == DOWN) minlen -= 1.0; } - length = length >? (minlen + 1.0); + length = max (length, minlen + 1.0); } Real st = dir ? hp[dir] + dir * length : 0; @@ -598,8 +598,8 @@ MAKE_SCHEME_CALLBACK (Stem, width_callback, 2); SCM Stem::width_callback (SCM e, SCM ax) { - Axis a = (Axis) scm_to_int (ax); - assert (a == X_AXIS); + (void) ax; + assert (scm_to_int (ax) == X_AXIS); Grob *me = unsmob_grob (e); Interval r; @@ -671,11 +671,11 @@ Stem::print (SCM smob) y2 -= d * (0.5 * beam_thickness - + beam_translation * (0 >? (beam_count - 1)) + + beam_translation * max (0, (beam_count - 1)) + stemlet_length) / half_space; } - Interval stem_y (y1 ? y1); + Interval stem_y (min (y1, y2), max (y2, y1)); if (Grob *hed = support_head (me)) { @@ -828,7 +828,7 @@ Stem::calc_stem_info (Grob *me) /* stem only extends to center of beam */ - 0.5 * beam_thickness; - ideal_length = ideal_length >? ideal_minimum_length; + ideal_length = max (ideal_length, ideal_minimum_length); /* Convert to Y position, calculate for dir == UP */ Real note_start @@ -858,10 +858,10 @@ Stem::calc_stem_info (Grob *me) { /* Highest beam of (UP) beam must never be lower than middle staffline */ - ideal_y = ideal_y >? 0; + ideal_y = max (ideal_y, 0.0); /* Lowest beam of (UP) beam must never be lower than second staffline */ - ideal_y = ideal_y >? (-staff_space - - beam_thickness + height_of_my_beams); + ideal_y = max (ideal_y, (-staff_space + - beam_thickness + height_of_my_beams)); } ideal_y -= robust_scm2double (beam->get_property ("shorten"), 0); @@ -882,7 +882,7 @@ Stem::calc_stem_info (Grob *me) { Interval y_ext = tremolo->extent (tremolo, Y_AXIS); y_ext.widen (0.5); // FIXME. Should be tunable? - minimum_length = minimum_length >? y_ext.length (); + minimum_length = max (minimum_length, y_ext.length ()); } ideal_y *= my_dir; diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index 0a5b6fe532..f079c7db13 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -168,7 +168,7 @@ System_start_delimiter::staff_brace (Grob *me, Real y) fm = select_font (me->get_layout (), scm_list_n (alist, SCM_UNDEFINED)); int lo = 0; - int hi = (fm->count () - 1) >? 2; + int hi = max (fm->count () - 1,2); Box b; /* do a binary search for each Y, not very efficient, but passable? */ diff --git a/lily/tfm.cc b/lily/tfm.cc index e5aeea72cd..485fde0b5c 100644 --- a/lily/tfm.cc +++ b/lily/tfm.cc @@ -45,8 +45,8 @@ Tex_font_char_metric::dimensions () const Real point_constant = 1 PT; return Box (Interval (0, width_ * point_constant), - Interval ((d ? height_) * point_constant)); + Interval (min (d, height_) * point_constant, + max (d, height_) * point_constant)); } Tex_font_metric::Tex_font_metric () @@ -126,4 +126,5 @@ int Tex_font_metric::name_to_index (String) const { assert (false); + return 0; } diff --git a/lily/tuplet-engraver.cc b/lily/tuplet-engraver.cc index 9acf07106b..c2ca198984 100644 --- a/lily/tuplet-engraver.cc +++ b/lily/tuplet-engraver.cc @@ -54,7 +54,7 @@ Tuplet_engraver::try_music (Music *music) SCM s = get_property ("tupletSpannerDuration"); if (unsmob_moment (s)) - d.span_stop_ = d.span_stop_