]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/system.cc
Merge branch 'master' into translation
[lilypond.git] / lily / system.cc
index e3da76687d9676704963b711c3a2e583236ccfa0..528135ad60d046b2b02d7f77640381450f368664 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1996--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1996--2015 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
@@ -40,6 +40,7 @@
 #include "text-interface.hh"
 #include "warn.hh"
 #include "unpure-pure-container.hh"
+#include "lily-imports.hh"
 
 System::System (System const &src)
   : Spanner (src)
@@ -62,7 +63,7 @@ void
 System::init_elements ()
 {
   SCM scm_arr = Grob_array::make_array ();
-  all_elements_ = unsmob_grob_array (scm_arr);
+  all_elements_ = unsmob<Grob_array> (scm_arr);
   all_elements_->set_ordered (false);
   set_object ("all-elements", scm_arr);
 }
@@ -223,7 +224,7 @@ System::get_paper_systems ()
       scm_vector_set_x (lines, scm_from_int (i),
                         system->get_paper_system ());
 
-      debug_output (to_string (i) + "]", false);
+      debug_output (::to_string (i) + "]", false);
     }
   return lines;
 }
@@ -327,13 +328,13 @@ System::internal_get_note_heights_in_range (vsize start, vsize end, bool foot)
       if (!Text_interface::is_markup (footnote_markup))
         continue;
 
-      SCM props = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"),
-                              pscore_->layout ()->self_scm ());
+      SCM props =
+        Lily::layout_extract_page_properties (pscore_->layout ()->self_scm ());
 
       SCM footnote_stl = Text_interface::interpret_markup (pscore_->layout ()->self_scm (),
                                                            props, footnote_markup);
 
-      Stencil *footnote_stencil = unsmob_stencil (footnote_stl);
+      Stencil *footnote_stencil = unsmob<Stencil> (footnote_stl);
       out.push_back (footnote_stencil->extent (Y_AXIS).length ());
     }
 
@@ -378,7 +379,7 @@ MAKE_SCHEME_CALLBACK (System, footnotes_before_line_breaking, 1);
 SCM
 System::footnotes_before_line_breaking (SCM smob)
 {
-  Grob *me = unsmob_grob (smob);
+  Grob *me = unsmob<Grob> (smob);
   vector<Grob *> footnotes;
   SCM grobs_scm = Grob_array::make_array ();
   extract_grob_set (me, "all-elements", elts);
@@ -386,7 +387,7 @@ System::footnotes_before_line_breaking (SCM smob)
     if (elts[i]->internal_has_interface (ly_symbol2scm ("footnote-interface")))
       footnotes.push_back (elts[i]);
 
-  unsmob_grob_array (grobs_scm)->set_array (footnotes);
+  unsmob<Grob_array> (grobs_scm)->set_array (footnotes);
   return grobs_scm;
 }
 
@@ -394,14 +395,14 @@ MAKE_SCHEME_CALLBACK (System, footnotes_after_line_breaking, 1);
 SCM
 System::footnotes_after_line_breaking (SCM smob)
 {
-  Spanner *sys_span = unsmob_spanner (smob);
+  Spanner *sys_span = unsmob<Spanner> (smob);
   System *sys = dynamic_cast<System *> (sys_span);
   Interval_t<int> sri = sys->spanned_rank_interval ();
   vector<Grob *> footnote_grobs = sys->get_footnote_grobs_in_range (sri[LEFT], sri[RIGHT]);
   vector_sort (footnote_grobs, grob_2D_less);
 
   SCM grobs_scm = Grob_array::make_array ();
-  unsmob_grob_array (grobs_scm)->set_array (footnote_grobs);
+  unsmob<Grob_array> (grobs_scm)->set_array (footnote_grobs);
   return grobs_scm;
 }
 
@@ -409,7 +410,7 @@ MAKE_SCHEME_CALLBACK (System, vertical_skyline_elements, 1);
 SCM
 System::vertical_skyline_elements (SCM smob)
 {
-  Grob *me_grob = unsmob_grob (smob);
+  Grob *me_grob = unsmob<Grob> (smob);
   vector<Grob *> vertical_skyline_grobs;
   extract_grob_set (me_grob, "elements", my_elts);
   for (vsize i = 0; i < my_elts.size (); i++)
@@ -417,11 +418,11 @@ System::vertical_skyline_elements (SCM smob)
       vertical_skyline_grobs.push_back (my_elts[i]);
 
   System *me = dynamic_cast<System *> (me_grob);
-  Grob *align = unsmob_grob (me->get_object ("vertical-alignment"));
+  Grob *align = unsmob<Grob> (me->get_object ("vertical-alignment"));
   if (!align)
     {
       SCM grobs_scm = Grob_array::make_array ();
-      unsmob_grob_array (grobs_scm)->set_array (vertical_skyline_grobs);
+      unsmob<Grob_array> (grobs_scm)->set_array (vertical_skyline_grobs);
       return grobs_scm;
     }
 
@@ -432,7 +433,7 @@ System::vertical_skyline_elements (SCM smob)
       vertical_skyline_grobs.push_back (elts[i]);
 
   SCM grobs_scm = Grob_array::make_array ();
-  unsmob_grob_array (grobs_scm)->set_array (vertical_skyline_grobs);
+  unsmob<Grob_array> (grobs_scm)->set_array (vertical_skyline_grobs);
   return grobs_scm;
 }
 
@@ -489,12 +490,12 @@ void
 System::add_column (Paper_column *p)
 {
   Grob *me = this;
-  Grob_array *ga = unsmob_grob_array (me->get_object ("columns"));
+  Grob_array *ga = unsmob<Grob_array> (me->get_object ("columns"));
   if (!ga)
     {
       SCM scm_ga = Grob_array::make_array ();
       me->set_object ("columns", scm_ga);
-      ga = unsmob_grob_array (scm_ga);
+      ga = unsmob<Grob_array> (scm_ga);
     }
 
   p->set_rank (ga->size ());
@@ -548,8 +549,7 @@ System::post_processing ()
      anyway. */
 
   vector<Grob *> all_elts_sorted (all_elements_->array ());
-  vector_sort (all_elts_sorted, std::less<Grob *> ());
-  uniq (all_elts_sorted);
+  uniquify (all_elts_sorted);
   this->get_stencil ();
   for (vsize i = all_elts_sorted.size (); i--;)
     {
@@ -595,7 +595,7 @@ System::get_paper_system ()
       Grob *g = entries[j].grob_;
       Stencil st = g->get_print_stencil ();
 
-      if (st.expr () == SCM_EOL)
+      if (scm_is_null (st.expr ()))
         continue;
 
       Offset o;
@@ -625,7 +625,7 @@ System::get_paper_system ()
                                  exprs));
   if (debug_skylines)
     {
-      Skyline_pair *skylines = Skyline_pair::unsmob (get_property ("vertical-skylines"));
+      Skyline_pair *skylines = unsmob<Skyline_pair> (get_property ("vertical-skylines"));
       if (skylines)
         {
           Stencil up
@@ -654,7 +654,7 @@ System::get_paper_system ()
     pl->set_property ("last-in-score", SCM_BOOL_T);
 
   Interval staff_refpoints;
-  if (Grob *align = unsmob_grob (get_object ("vertical-alignment")))
+  if (Grob *align = unsmob<Grob> (get_object ("vertical-alignment")))
     {
       extract_grob_set (align, "elements", staves);
       for (vsize i = 0; i < staves.size (); i++)
@@ -759,7 +759,7 @@ MAKE_SCHEME_CALLBACK (System, get_vertical_alignment, 1);
 SCM
 System::get_vertical_alignment (SCM smob)
 {
-  Grob *me = unsmob_grob (smob);
+  Grob *me = unsmob<Grob> (smob);
   extract_grob_set (me, "elements", elts);
   Grob *ret = 0;
   for (vsize i = 0; i < elts.size (); i++)
@@ -783,7 +783,7 @@ System::get_vertical_alignment (SCM smob)
 Grob *
 System::get_extremal_staff (Direction dir, Interval const &iv)
 {
-  Grob *align = unsmob_grob (get_object ("vertical-alignment"));
+  Grob *align = unsmob<Grob> (get_object ("vertical-alignment"));
   if (!align)
     return 0;
 
@@ -807,7 +807,7 @@ System::get_extremal_staff (Direction dir, Interval const &iv)
 Grob *
 System::get_neighboring_staff (Direction dir, Grob *vertical_axis_group, Interval_t<int> bounds)
 {
-  Grob *align = unsmob_grob (get_object ("vertical-alignment"));
+  Grob *align = unsmob<Grob> (get_object ("vertical-alignment"));
   if (!align)
     return 0;
 
@@ -837,7 +837,7 @@ Interval
 System::pure_refpoint_extent (vsize start, vsize end)
 {
   Interval ret;
-  Grob *alignment = unsmob_grob (get_object ("vertical-alignment"));
+  Grob *alignment = unsmob<Grob> (get_object ("vertical-alignment"));
   if (!alignment)
     return Interval ();
 
@@ -864,7 +864,7 @@ System::pure_refpoint_extent (vsize start, vsize end)
 Interval
 System::part_of_line_pure_height (vsize start, vsize end, bool begin)
 {
-  Grob *alignment = unsmob_grob (get_object ("vertical-alignment"));
+  Grob *alignment = unsmob<Grob> (get_object ("vertical-alignment"));
   if (!alignment)
     return Interval ();
 
@@ -910,25 +910,23 @@ MAKE_SCHEME_CALLBACK (System, calc_pure_relevant_grobs, 1);
 SCM
 System::calc_pure_relevant_grobs (SCM smob)
 {
-  Grob *me = unsmob_grob (smob);
+  Grob *me = unsmob<Grob> (smob);
 
   extract_grob_set (me, "elements", elts);
   vector<Grob *> relevant_grobs;
-  SCM pure_relevant_p = ly_lily_module_constant ("pure-relevant?");
 
   for (vsize i = 0; i < elts.size (); ++i)
     {
       if (!Axis_group_interface::has_interface (elts[i]))
         {
-          if (to_boolean (scm_apply_1 (pure_relevant_p, elts[i]->self_scm (), SCM_EOL)))
-            relevant_grobs.push_back (elts[i]);
+          relevant_grobs.push_back (elts[i]);
 
           if (Item *it = dynamic_cast<Item *> (elts[i]))
             {
               for (LEFT_and_RIGHT (d))
                 {
                   Item *piece = it->find_prebroken_piece (d);
-                  if (piece && to_boolean (scm_apply_1 (pure_relevant_p, piece->self_scm (), SCM_EOL)))
+                  if (piece && piece->is_live ())
                     relevant_grobs.push_back (piece);
                 }
             }
@@ -937,7 +935,7 @@ System::calc_pure_relevant_grobs (SCM smob)
 
   SCM grobs_scm = Grob_array::make_array ();
 
-  unsmob_grob_array (grobs_scm)->set_array (relevant_grobs);
+  unsmob<Grob_array> (grobs_scm)->set_array (relevant_grobs);
   return grobs_scm;
 }
 
@@ -952,7 +950,7 @@ MAKE_SCHEME_CALLBACK (System, calc_pure_height, 3);
 SCM
 System::calc_pure_height (SCM smob, SCM start_scm, SCM end_scm)
 {
-  System *me = dynamic_cast<System *> (unsmob_grob (smob));
+  System *me = unsmob<System> (smob);
   int start = scm_to_int (start_scm);
   int end = scm_to_int (end_scm);
 
@@ -996,8 +994,8 @@ enum
 static SCM
 get_maybe_spaceable_staves (SCM smob, int filter)
 {
-  System *me = dynamic_cast<System *> (unsmob_grob (smob));
-  Grob *align = unsmob_grob (me->get_object ("vertical_alignment"));
+  System *me = unsmob<System> (smob);
+  Grob *align = unsmob<Grob> (me->get_object ("vertical_alignment"));
   SCM ret = SCM_EOL;
 
   if (align)