]> git.donarmstrong.com Git - lilypond.git/commitdiff
page breaking coding style fixes.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 20 May 2007 20:13:32 +0000 (17:13 -0300)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 20 May 2007 20:13:32 +0000 (17:13 -0300)
- rename sys_ -> system_spec_index_
- rename last() -> is_last()
- make breaks_ private; add last_break_position() method.

lily/include/page-breaking.hh
lily/optimal-page-breaking.cc
lily/page-breaking.cc
lily/page-spacing.cc
lily/page-turn-page-breaking.cc

index 2bedb23f448823a49e1be38f9d6b2eafde41a92c..208c1e8b0e9b57760ffb3183fb5eacb2ac87cf78 100644 (file)
@@ -41,40 +41,39 @@ struct System_spec
 
 struct Break_position
 {
-   /* our index in the all_ list */
-  vsize sys_;
+  vsize system_spec_index_;
 
-  /* if sys_ is a score, then we start at the score_brk_'th possible
+  /* if system_spec_index_ is a score, then we start at the score_brk_'th possible
      page-break in the score */
   vsize score_break_; 
 
-  /* if sys_ is a score, this points to the broken column */
+  /* if system_spec_index_ is a score, this points to the broken column */
   Grob *col_;  
   bool score_ender_;
 
   Break_position (vsize s=VPOS, vsize brk=VPOS, Grob *g=NULL, bool end=false)
   {
-    sys_ = s;
+    system_spec_index_ = s;
     score_break_ = brk;
     col_ = g;
     score_ender_ = end;
   }
 
   /*
-    lexicographic in (sys_, score_break_)
+    lexicographic in (system_spec_index_, score_break_)
    */
   bool operator< (const Break_position &other)
   {
-    return (sys_ == VPOS && other.sys_ != VPOS)
-      || (sys_ < other.sys_)
-      || (sys_ == other.sys_ && score_break_ < other.score_break_);
+    return (system_spec_index_ == VPOS && other.system_spec_index_ != VPOS)
+      || (system_spec_index_ < other.system_spec_index_)
+      || (system_spec_index_ == other.system_spec_index_ && score_break_ < other.score_break_);
   }
 
   bool operator<= (const Break_position &other)
   {
-    return (sys_ == VPOS)
-      || (sys_ < other.sys_ && other.sys_ != VPOS)
-      || (sys_ == other.sys_ && score_break_ <= other.score_break_);
+    return (system_spec_index_ == VPOS)
+      || (system_spec_index_ < other.system_spec_index_ && other.system_spec_index_ != VPOS)
+      || (system_spec_index_ == other.system_spec_index_ && score_break_ <= other.score_break_);
   }
 };
 
@@ -97,7 +96,7 @@ public:
 
   bool ragged () const;
   bool ragged_last () const;
-  bool last () const;
+  bool is_last () const;
   Real page_height (int page_number, bool last) const;
 
 protected:
@@ -135,11 +134,9 @@ protected:
 
   SCM breakpoint_property (vsize breakpoint, char const *str);
 
-
-protected:
-  vector<Break_position> breaks_;
-
+  vsize last_break_position () const;
 private:
+  vector<Break_position> breaks_;
   vector<Break_position> chunks_;
   vector<System_spec> system_specs_;
   vector<Constrained_breaking> line_breaking_;
index c3d3f03315fdff4da77db5a39c2398517bd7f000..4f82c2d1aec0ae86a8bd17c660d9e79295535428 100644 (file)
@@ -36,7 +36,7 @@ Optimal_page_breaking::~Optimal_page_breaking ()
 SCM
 Optimal_page_breaking::solve ()
 {
-  vsize end = breaks_.size () - 1;
+  vsize end = last_break_position ();
   vsize min_sys_count = 0;
   vsize ideal_sys_count = 0;
   vsize max_sys_count = max_system_count (0, end);
index 8243ebc8bd4bff9e4089435811298cdd9d60f52e..d84c278a900d10ebb97fea9bae9208a046fddd96 100644 (file)
@@ -85,7 +85,7 @@ uncompress_solution (vector<vsize> const &systems_per_page,
 vsize
 Page_breaking::next_system (Break_position const &break_pos) const
 {
-  vsize sys = break_pos.sys_;
+  vsize sys = break_pos.system_spec_index_;
 
   if (sys == VPOS) /* beginning of the book */
     return 0;
@@ -128,14 +128,14 @@ Page_breaking::line_breaker_args (vsize sys,
                                  vsize *line_breaker_end)
 {
   assert (system_specs_[sys].pscore_);
-  assert (next_system (start) <= sys && sys <= end.sys_);
+  assert (next_system (start) <= sys && sys <= end.system_spec_index_);
 
-  if (start.sys_ == sys)
+  if (start.system_spec_index_ == sys)
     *line_breaker_start = start.score_break_;
   else
     *line_breaker_start = 0;
 
-  if (end.sys_ == sys)
+  if (end.system_spec_index_ == sys)
     *line_breaker_end = end.score_break_;
   else
     *line_breaker_end = VPOS;
@@ -218,11 +218,11 @@ Page_breaking::breakpoint_property (vsize breakpoint, char const *str)
 {
   Break_position const &pos = breaks_[breakpoint];
 
-  if (pos.sys_ == VPOS)
+  if (pos.system_spec_index_ == VPOS)
     return SCM_EOL;
-  if (system_specs_[pos.sys_].pscore_)
+  if (system_specs_[pos.system_spec_index_].pscore_)
     return pos.col_->get_property (str);
-  return system_specs_[pos.sys_].prob_->get_property (str);
+  return system_specs_[pos.system_spec_index_].prob_->get_property (str);
 }
 
 SCM
@@ -649,8 +649,8 @@ Page_breaking::space_systems_on_n_pages (vsize configuration, vsize n, vsize fir
     return Spacing_result ();
   if (n == 1)
     ret = space_systems_on_1_page (cached_line_details_,
-                                  page_height (first_page_num, last ()),
-                                  ragged () || (last () && ragged_last ()));
+                                  page_height (first_page_num, is_last ()),
+                                  ragged () || (is_last () && ragged_last ()));
   else if (n == 2)
     ret = space_systems_on_2_pages (configuration, first_page_num);
   else
@@ -665,7 +665,7 @@ Page_breaking::space_systems_on_n_pages (vsize configuration, vsize n, vsize fir
 Real
 Page_breaking::blank_page_penalty () const
 {
-  SCM penalty_sym = last () ? ly_symbol2scm ("blank-last-page-force") : ly_symbol2scm ("blank-page-force");
+  SCM penalty_sym = is_last () ? ly_symbol2scm ("blank-last-page-force") : ly_symbol2scm ("blank-page-force");
   return robust_scm2double (book_->paper_->lookup_variable (penalty_sym), 0.0);
 }
 
@@ -790,9 +790,9 @@ Spacing_result
 Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_num)
 {
   Real page1_height = page_height (first_page_num, false);
-  Real page2_height = page_height (first_page_num+1, last ());
+  Real page2_height = page_height (first_page_num + 1, is_last ());
   bool ragged1 = ragged ();
-  bool ragged2 = ragged () || (last () && ragged_last ());
+  bool ragged2 = ragged () || (is_last () && ragged_last ());
 
   /* if there is a forced break, this reduces to 2 1-page problems */
   cache_line_details (configuration);
@@ -879,7 +879,14 @@ Page_breaking::current_configuration (vsize configuration_index) const
   return current_configurations_[configuration_index];
 }
 
-bool Page_breaking::last () const
+bool
+Page_breaking::is_last () const
+{
+  return current_end_breakpoint_ == last_break_position ();
+}
+
+vsize
+Page_breaking::last_break_position () const
 {
-  return current_end_breakpoint_ == breaks_.size () - 1;
+  return breaks_.size () - 1;  
 }
index d1545369564ec3cc764c41462c9dc980986a2025..60e5174c3b5f0c10e6c1aa0a843f1575e205b996 100644 (file)
@@ -74,7 +74,7 @@ Page_spacer::Page_spacer (vector<Line_details> const &lines, vsize first_page_nu
   breaker_ = breaker;
   max_page_count_ = 0;
   ragged_ = breaker->ragged ();
-  ragged_last_ = breaker->last () && breaker->ragged_last ();
+  ragged_last_ = breaker->is_last () && breaker->ragged_last ();
 }
 
 Spacing_result
index 782399542c0ab01b47ba53c5283c4d6b80e50f0b..d17e6a86a3d34c8d86202729380940d563f9c76f 100644 (file)
@@ -206,8 +206,8 @@ Page_turn_page_breaking::solve ()
 {
   state_.clear ();
   message (_f ("Calculating page and line breaks (%d possible page breaks)...",
-               (int)breaks_.size () - 1) + " ");
-  for (vsize i = 0; i + 1 < breaks_.size (); i++)
+               (int) last_break_position ()));
+  for (vsize i = 0; i < last_break_position (); i++)
     {
       calc_subproblem (i);
       progress_indication (string ("[") + to_string (i + 1) + "]");