]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/break-substitution.cc
Imported Upstream version 2.14.2
[lilypond.git] / lily / break-substitution.cc
index d14092876f7a401f2584af4a50a2e21cf7c0d1ed..2cd29707d611a1d60c704d0c9615eaa7a73af35c 100644 (file)
@@ -1,18 +1,29 @@
 /*
-  break-substitution.cc -- implement grob break substitution.
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
+  Copyright (C) 2001--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
-  (c) 2001--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include <cstdio>
 #include <cstdlib>
 using namespace std;
 
-#include "grob-array.hh"
 #include "item.hh"
 #include "system.hh"
+#include "grob-array.hh"
 
 static SCM break_criterion;
 void
@@ -139,17 +150,17 @@ do_break_substitution (SCM src)
 /*
   Perform substitution on GROB_LIST using a constant amount of stack.
 */
-Link_array<Grob> temporary_substition_array;
+vector<Grob*> temporary_substition_array;
 void
 substitute_grob_array (Grob_array *grob_arr, Grob_array *new_arr)
 {
-  Link_array<Grob> &old_grobs (grob_arr->array_reference ());
-  Link_array<Grob> *new_grobs (new_arr == grob_arr
+  vector<Grob*> &old_grobs (grob_arr->array_reference ());
+  vector<Grob*> *new_grobs (new_arr == grob_arr
                               ? & temporary_substition_array
                               : &new_arr->array_reference ());
 
   new_grobs->resize (old_grobs.size ());
-  Grob **array = (Grob **) new_grobs->accesses ();
+  Grob **array = (Grob **) new_grobs->data ();
   Grob **ptr = array;
   for (vsize i = 0; i < old_grobs.size (); i++)
     {
@@ -263,6 +274,8 @@ grob_system_range (Grob *g)
 struct Substitution_entry
 {
   Grob *grob_;
+
+  /* Assumption: we have less than 32k paper columns. */
   short left_;
   short right_;
 
@@ -282,8 +295,8 @@ struct Substitution_entry
       }
     else
       {
-       left_ = sr[LEFT];
-       right_ = sr[RIGHT];
+       left_ = (short) sr[LEFT];
+       right_ = (short) sr[RIGHT];
       }
   }
   Substitution_entry ()
@@ -322,6 +335,8 @@ Spanner::fast_substitute_grob_array (SCM sym,
 
   /*
     We store items on the left, spanners on the right in this vector.
+
+    FIXME: will not multithread.
   */
   static Substitution_entry *vec;
   static int vec_room;
@@ -356,15 +371,15 @@ Spanner::fast_substitute_grob_array (SCM sym,
   qsort (vec, item_index,
         sizeof (Substitution_entry), &Substitution_entry::item_compare);
 
-  std::vector<Slice> item_indices;
-  std::vector<Slice> spanner_indices;
+  vector<Slice> item_indices;
+  vector<Slice> spanner_indices;
   for (int i = 0; i <= system_range.length (); i++)
     {
       item_indices.push_back (Slice (len, 0));
       spanner_indices.push_back (Slice (len, 0));
     }
 
-  std::vector<Slice> *arrs[]
+  vector<Slice> *arrs[]
     = {
     &item_indices, &spanner_indices
   };
@@ -397,7 +412,7 @@ Spanner::fast_substitute_grob_array (SCM sym,
       if (!unsmob_grob_array (newval))
        {
          newval = Grob_array::make_array ();
-         sc->internal_set_object (sym, newval);
+         sc->set_object (sym, newval);
        }
 
       Grob_array *new_array = unsmob_grob_array (newval);
@@ -500,14 +515,14 @@ Spanner::substitute_one_mutable_property (SCM sym,
            if (!unsmob_grob_array (newval))
              {
                newval = Grob_array::make_array ();
-               sc->internal_set_object (sym, newval);
+               sc->set_object (sym, newval);
              }
            substitute_grob_array (grob_array, unsmob_grob_array (newval));
          }
        else
          {
            SCM newval = do_break_substitution (val);
-           sc->internal_set_object (sym, newval);
+           sc->set_object (sym, newval);
          }
       }
 }