]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spacing-spanner.cc
Issue 4627: Convert Scheme_hash_table to using Smob1
[lilypond.git] / lily / spacing-spanner.cc
index ee4904999f372fbf5b7cda819052a556ad0c4119..12f18e865fedbf6adba8575b8d2db74bfffe969f 100644 (file)
@@ -39,6 +39,8 @@
 #include "system.hh"
 #include "warn.hh"
 
+using std::vector;
+
 vector<Grob *>
 Spacing_spanner::get_columns (Grob *me_grob)
 {
@@ -58,7 +60,7 @@ MAKE_SCHEME_CALLBACK (Spacing_spanner, set_springs, 1);
 SCM
 Spacing_spanner::set_springs (SCM smob)
 {
-  Spanner *me = Spanner::unsmob (smob);
+  Spanner *me = unsmob<Spanner> (smob);
 
   /*
     can't use get_system () ? --hwn.
@@ -89,7 +91,7 @@ MAKE_SCHEME_CALLBACK (Spacing_spanner, calc_common_shortest_duration, 1);
 SCM
 Spacing_spanner::calc_common_shortest_duration (SCM grob)
 {
-  Spanner *me = Spanner::unsmob (grob);
+  Spanner *me = unsmob<Spanner> (grob);
 
   vector<Grob *> cols (get_columns (me));
 
@@ -106,7 +108,7 @@ Spacing_spanner::calc_common_shortest_duration (SCM grob)
     {
       if (Paper_column::is_musical (cols[i]))
         {
-          Moment *when = Moment::unsmob (cols[i]->get_property ("when"));
+          Moment *when = unsmob<Moment> (cols[i]->get_property ("when"));
 
           /*
             ignore grace notes for shortest notes.
@@ -115,9 +117,9 @@ Spacing_spanner::calc_common_shortest_duration (SCM grob)
             continue;
 
           SCM st = cols[i]->get_property ("shortest-starter-duration");
-          Moment this_shortest = *Moment::unsmob (st);
+          Moment this_shortest = *unsmob<Moment> (st);
           assert (this_shortest.to_bool ());
-          shortest_in_measure = min (shortest_in_measure, this_shortest.main_part_);
+          shortest_in_measure = std::min (shortest_in_measure, this_shortest.main_part_);
         }
       else if (!shortest_in_measure.is_infinity ()
                && Paper_column::is_breakable (cols[i]))
@@ -161,11 +163,11 @@ Spacing_spanner::calc_common_shortest_duration (SCM grob)
 
   SCM bsd = me->get_property ("base-shortest-duration");
   Rational d = Rational (1, 8);
-  if (Moment *m = Moment::unsmob (bsd))
+  if (Moment *m = unsmob<Moment> (bsd))
     d = m->main_part_;
 
   if (max_idx != VPOS)
-    d = min (d, durations[max_idx]);
+    d = std::min (d, durations[max_idx]);
 
   return Moment (d).smobbed_copy ();
 }
@@ -237,14 +239,14 @@ set_column_rods (vector<Grob *> const &cols, Real padding)
       if (Separation_item::is_empty (r) && (!rb || Separation_item::is_empty (rb)))
         continue;
 
-      Skyline_pair *skys = Skyline_pair::unsmob (r->get_property ("horizontal-skylines"));
+      Skyline_pair *skys = unsmob<Skyline_pair> (r->get_property ("horizontal-skylines"));
       overhangs[i] = skys ? (*skys)[RIGHT].max_height () : 0.0;
 
       if (0 == i) continue;
 
       /* min rather than max because stickout will be negative if the right-hand column
          sticks out a lot to the left */
-      Real stickout = min (skys ? (*skys)[LEFT].max_height () : 0.0,
+      Real stickout = std::min (skys ? (*skys)[LEFT].max_height () : 0.0,
                            Separation_item::conditional_skyline (r, cols[i - 1]).max_height ());
 
       Real prev_distances = 0.0;
@@ -261,7 +263,7 @@ set_column_rods (vector<Grob *> const &cols, Real padding)
           Item *lb = l->find_prebroken_piece (RIGHT);
 
           Real dist = Separation_item::set_distance (l, r, padding);
-          distances[i] = max (distances[i], dist - prev_distances);
+          distances[i] = std::max (distances[i], dist - prev_distances);
 
           if (lb)
             {
@@ -270,7 +272,7 @@ set_column_rods (vector<Grob *> const &cols, Real padding)
               // right than the unbroken version, by extending farther and/or
               // nesting more closely;
               if (j == i - 1) // check this, the first time we see each lb.
-                overhangs[j] = max (overhangs[j],
+                overhangs[j] = std::max (overhangs[j],
                                     lb->extent (lb, X_AXIS)[RIGHT]
                                     + distances[i] - dist);
             }
@@ -281,7 +283,7 @@ set_column_rods (vector<Grob *> const &cols, Real padding)
 
           prev_distances += distances[j];
         }
-      overhangs[i] = max (overhangs[i],
+      overhangs[i] = std::max (overhangs[i],
                           overhangs[i - 1] - distances[i]);
     }
 }
@@ -351,10 +353,10 @@ Spacing_spanner::musical_column_spacing (Grob *me,
           /*
             This is probably a waste of time in the case of polyphonic
             music.  */
-          if (found_matching_column && Note_spacing::has_interface (wish))
+          if (found_matching_column && has_interface<Note_spacing> (wish))
             {
               Real inc = options->increment_;
-              Grob *gsp = Grob::unsmob (left_col->get_object ("grace-spacing"));
+              Grob *gsp = unsmob<Grob> (left_col->get_object ("grace-spacing"));
               if (gsp && Paper_column::when_mom (left_col).grace_part_)
                 {
                   Spacing_options grace_opts;
@@ -418,7 +420,7 @@ Spacing_spanner::musical_column_spacing (Grob *me,
       if (Paper_column::is_extraneous_column_from_ligature (left_col))
         spring.set_distance (spring.min_distance ());
       else
-        spring.set_distance (max (left_col->extent (left_col, X_AXIS)[RIGHT],
+        spring.set_distance (std::max (left_col->extent (left_col, X_AXIS)[RIGHT],
                                   spring.min_distance ()));
 
       spring.set_inverse_stretch_strength (1.0);
@@ -447,7 +449,7 @@ Spacing_spanner::fills_measure (Grob *me, Item *left, Item *col)
   Moment dt
     = Paper_column::when_mom (next) - Paper_column::when_mom (col);
 
-  Moment *len = Moment::unsmob (left->get_property ("measure-length"));
+  Moment *len = unsmob<Moment> (left->get_property ("measure-length"));
   if (!len)
     return false;
 
@@ -489,7 +491,7 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r,
         {
           Item *spacing_grob = dynamic_cast<Item *> (wishes[i]);
 
-          if (!spacing_grob || !Staff_spacing::has_interface (spacing_grob))
+          if (!spacing_grob || !has_interface<Staff_spacing> (spacing_grob))
             continue;
 
           /*