]> git.donarmstrong.com Git - lilypond.git/commitdiff
Remove paper var caching.
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 28 Apr 2004 22:03:54 +0000 (22:03 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 28 Apr 2004 22:03:54 +0000 (22:03 +0000)
ChangeLog
Documentation/user/music-glossary.tely
lily/book.cc
lily/include/book.hh
lily/include/page.hh
lily/page.cc
lily/parser.yy
lily/protected-scm.cc
lily/score.cc
lily/system.cc
lily/virtual-font-metric.cc

index 7ad5d7fb8b59e28ca7023946bd10c0383b4d6d06..81a753815c30a6e5bacd718f4068c034d59fcc47 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
+2004-04-29  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * lily/page.cc: Remove paper var caching.
+
 2004-04-28  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * Documentation/user/music-glossary.tely: Add name to @top node.
+       Remove comment from @table definitions (workaround for makinfo
+       bug).
+
        * lily/stencil-scheme.cc (ly:stencil-expr): Rename (was:
        ly:stencil-get-expr).  Update callers.
        (ly:stencil-align-to!):  Return stencil too.
index 5d0a3e7517b5c0a12c2eccf082e155eee0b4197b..ac02de30f8f3e7f72818f919878b01eda486842e 100644 (file)
@@ -1,4 +1,4 @@
-\input texinfo  @c -*-texinfo-*-
+                   \input texinfo  @c -*-texinfo-*-
 @settitle Music Glossary
 @setfilename music-glosssary.info
 
@@ -52,14 +52,14 @@ Copyright @copyright{} 1999--2004 by the authors
 
 @ifnottex
 @node Top
-@top
+@top Music Glossary
 @chapter Music Glossary
 @menu
 @end menu
 @end ifnottex
 
 @ifnottex
-@table @code
+@table @samp
 @item Adrian Mariano
 Italian glossary,
 @item Bjoern Jacke
@@ -159,9 +159,9 @@ they look too intrusive (says Han-Wen).
 This is an example reference, that points you to the @aref{accent}
 entry.
 
-@c All `@table @strong' replaced by `@table @samp @c @strong'
+@c All `@table @strong' replaced by `@table @samp'
 @c @strong{note xxx} breaks for info with makeinfo CVS <= 2004-04-26
-@table @samp @c @strong
+@table @samp
 
 @aitem{A}
 ES: la,
@@ -4193,7 +4193,7 @@ symphony orchestra are flute, oboe, clarinet, saxophone, and bassoon.
 
 @page
 
-@table @samp @c @strong
+@table @samp
 @item DURATION NAMES, NOTES AND RESTS
 @end table
 
@@ -4256,7 +4256,7 @@ sextio@-fj@"arde@-del @tab kuudeskymmenesnelj@"asosa- @tab
 
 @page
 
-@table @samp @c @strong
+@table @samp
 @item PITCH NAMES
 @end table
 
@@ -4322,7 +4322,7 @@ ais @tab ais @tab ais
 
 @
 
-@table @samp @c @strong
+@table @samp
 
 @item ---------------------
 
index 477c25087891e00fea24a2eb7509d92c28023d19..93c2cf84eb993211bcbd32b60e0d4ba4981937ea 100644 (file)
@@ -28,28 +28,10 @@ Book::Book ()
   : Input ()
 {
   header_ = SCM_EOL;
+  assert (!scores_.size ());
   smobify_self ();
 }
 
-#if 0
-Book::Book (Book const &src)
-  : Input (src)
-{
-  header_ = SCM_EOL;
-  smobify_self ();
-
-  int score_count = src.scores_.size ();
-  for (int i = 0; i < score_count; i++)
-    scores_.push (src.scores_[i]->clone ());
-
-#if 0
-  header_ = ly_make_anonymous_module ();
-  if (is_module (src.header_))
-    ly_import_module (header_, src.header_);
-#endif
-}
-#endif
-
 Book::~Book ()
 {
 }
@@ -120,11 +102,11 @@ Book::to_stencil (Music_output_def *default_def, SCM header)
     }
 
   SCM pages = paper_book->pages ();
-  scm_gc_unprotect_object (paper_book->self_scm ());
+  paper_book = 0;
   if (pages != SCM_EOL)
     {
       progress_indication (_f ("paper output to `%s'...", "<markup>"));
-      return unsmob_page (ly_car (pages))->to_stencil ();
+      return (unsmob_page (ly_car (pages)))->to_stencil ();
     }
   return SCM_EOL;
 }
index 86825995492ee083b3765022d9463e2a0ea60c16..c9191e63f9d0bb61c9e253f9418bf8cef91cb24f 100644 (file)
@@ -24,7 +24,7 @@ public:
   Link_array<Score> scores_;
     
   Book ();
-  Book (Book const&);
+
   void process (String outname, Music_output_def*, SCM header);
   SCM to_stencil (Music_output_def*, SCM header);
 };
index 880cbc0bd562e2324dfa60f6cbe614b00c3f3dbe..c12d32c02caddc85885ab50555b6c6837bba4cb1 100644 (file)
@@ -33,14 +33,9 @@ public:
   Real height_;
   
   // HMMM all this size stuff to paper/paper-outputter?
-  Real hsize_;
   Real vsize_;
-  Real left_margin_;
   Real top_margin_;
   Real bottom_margin_;
-  Real foot_sep_;
-  Real head_sep_;
-  Real text_width_;
 
   Page (Paper_def*, int);
 
index 801e9c9c50af7cc07ac3c7681505d3f556c1b3f4..f296b4bc8b7500333995bf663b8e5db4c8ccaab8 100644 (file)
@@ -20,29 +20,20 @@ Real Page::MIN_COVERAGE_ = 0.66;
 
 Page::Page (Paper_def *paper, int number)
 {
-  paper_ = paper;
-  number_ = number;
-
   copyright_ = SCM_EOL;
   footer_ = SCM_EOL;
   header_ = SCM_EOL;
   lines_ = SCM_EOL;
   tagline_ = SCM_EOL;
   
+  paper_ = paper;
+  number_ = number;
+
   height_ = 0;
   line_count_ = 0;
   
   page_count_++;
 
-  hsize_ = paper->get_dimension (ly_symbol2scm ("hsize"));
-  vsize_ = paper->get_dimension (ly_symbol2scm ("vsize"));
-  top_margin_ = paper->get_dimension (ly_symbol2scm ("top-margin"));
-  bottom_margin_ = paper->get_dimension (ly_symbol2scm ("bottom-margin"));
-  head_sep_ = paper->get_dimension (ly_symbol2scm ("head-sep"));
-  foot_sep_ = paper->get_dimension (ly_symbol2scm ("foot-sep"));
-  text_width_ = paper->get_dimension (ly_symbol2scm ("linewidth"));
-  left_margin_ = (hsize_ - text_width_) / 2;
-  
   SCM make_header = ly_scheme_function ("make-header");
   SCM make_footer = ly_scheme_function ("make-footer");
 
@@ -73,11 +64,11 @@ SCM
 Page::mark_smob (SCM smob)
 {
   Page *p = (Page*) SCM_CELL_WORD_1 (smob);
-  scm_gc_mark (p->lines_);
   scm_gc_mark (p->header_);
   scm_gc_mark (p->footer_);
   scm_gc_mark (p->copyright_);
   scm_gc_mark (p->tagline_);
+  //scm_gc_mark (p->lines_);
   return p->lines_;
 }
 
@@ -116,6 +107,13 @@ Page::to_stencil () const
   return scm_call_1 (proc, self_scm ());
 }
 
+Real
+Page::left_margin () const
+{
+  return (paper_->get_dimension (ly_symbol2scm ("hsize"))
+         - paper_->get_dimension (ly_symbol2scm ("linewidth"))) / 2;
+}
+
 LY_DEFINE (ly_page_header_lines_footer_stencil, "ly:page-header-lines-footer-stencil",
           1, 0, 0, (SCM page),
           "Simple header, lines, footer stencil from PAGE.")
@@ -124,7 +122,9 @@ LY_DEFINE (ly_page_header_lines_footer_stencil, "ly:page-header-lines-footer-ste
   SCM_ASSERT_TYPE (p, page, SCM_ARG1, __FUNCTION__, "page");
   
   Stencil stencil;
-  Offset o (p->left_margin_, p->top_margin_);
+  Offset o (p->paper_->get_dimension (ly_symbol2scm ("left-margin")),
+           p->paper_->get_dimension (ly_symbol2scm ("top-margin")));
+
   Real vfill = (p->line_count_ > 1
                ? (p->text_height () - p->height_) / (p->line_count_ - 1)
                : 0);
@@ -139,7 +139,7 @@ LY_DEFINE (ly_page_header_lines_footer_stencil, "ly:page-header-lines-footer-ste
   if (Stencil *s = unsmob_stencil (p->header_))
     {
       stack_stencils (stencil, s, &o);
-      o[Y_AXIS] += p->head_sep_;
+      o[Y_AXIS] += p->paper_->get_dimension (ly_symbol2scm ("head-sep"));
     }
 
   for (SCM s = p->lines_; s != SCM_EOL; s = ly_cdr (s))
@@ -156,7 +156,8 @@ LY_DEFINE (ly_page_header_lines_footer_stencil, "ly:page-header-lines-footer-ste
        o[Y_AXIS] += vfill;
     }
 
-  o[Y_AXIS] = p->vsize_ - p->bottom_margin_;
+  o[Y_AXIS] = p->paper_->get_dimension (ly_symbol2scm ("vsize"))
+    - p->paper_->get_dimension (ly_symbol2scm ("bottom-margin"));
   if (unsmob_stencil (p->copyright_))
     o[Y_AXIS] -= unsmob_stencil (p->copyright_)->extent (Y_AXIS).length ();
   if (unsmob_stencil (p->tagline_))
@@ -177,11 +178,16 @@ LY_DEFINE (ly_page_header_lines_footer_stencil, "ly:page-header-lines-footer-ste
 Real
 Page::text_height () const
 {
-  Real h = vsize_ - top_margin_ - bottom_margin_;
+  Real h = paper_->get_dimension (ly_symbol2scm ("vsize"))
+    - paper_->get_dimension (ly_symbol2scm ("top-margin"))
+    - paper_->get_dimension (ly_symbol2scm ("bottom-margin"));
   if (unsmob_stencil (header_))
-    h -= unsmob_stencil (header_)->extent (Y_AXIS).length () + head_sep_;
-  if (unsmob_stencil (copyright_) || unsmob_stencil (tagline_) || unsmob_stencil (footer_))
-    h -= foot_sep_;
+    h -= unsmob_stencil (header_)->extent (Y_AXIS).length ()
+      + paper_->get_dimension (ly_symbol2scm ("head-sep"));
+  if (unsmob_stencil (copyright_)
+      || unsmob_stencil (tagline_)
+      || unsmob_stencil (footer_))
+    h -= paper_->get_dimension (ly_symbol2scm ("foot-sep"));
   if (unsmob_stencil (copyright_))
     h -= unsmob_stencil (copyright_)->extent (Y_AXIS).length ();
   if (unsmob_stencil (tagline_))
index 8575eb2071c70b690d256aa9bb64598b7cbd227d..9bb3c89627d3dd2a98531e039c33e9c5c3e72b7d 100644 (file)
@@ -2461,9 +2461,9 @@ markup:
                extern Music_output_def* get_paper (My_lily_parser *parser);
                Music_output_def *paper = get_paper (THIS);
                SCM s = book->to_stencil (paper, THIS->header_);
-               $$ = scm_list_2 (ly_scheme_function ("stencil-markup"), s);
                scm_gc_unprotect_object (score->self_scm ());
                scm_gc_unprotect_object (book->self_scm ());
+               $$ = scm_list_2 (ly_scheme_function ("stencil-markup"), s);
        }
        ;
 
index 93b29a48d4a8648d57bf2beb46f754ae9906ea94..56bd2def2fef8f6a190510208cef89b45eb2baf1 100644 (file)
@@ -16,12 +16,19 @@ Protected_scm::Protected_scm ()
 
 Protected_scm::Protected_scm (SCM s)
 {
-  object_ = SCM_NIMP (s)  ? scm_gc_protect_object (s): s;
+  object_ = SCM_NIMP (s) ? scm_gc_protect_object (s): s;
 }
 
 Protected_scm::Protected_scm (Protected_scm const &s)
 {
-  object_ = SCM_NIMP (s.object_) ? scm_gc_protect_object (s.object_) : s.object_;
+  object_ = (SCM_NIMP (s.object_) ? scm_gc_protect_object (s.object_)
+            : s.object_);
+}
+
+Protected_scm::~Protected_scm ()
+{
+  if (SCM_NIMP (object_))
+    scm_gc_unprotect_object (object_);
 }
 
 Protected_scm & 
@@ -33,7 +40,7 @@ Protected_scm::operator = (SCM s)
   if (SCM_NIMP (object_))
     scm_gc_unprotect_object (object_);
 
-  object_ =  SCM_NIMP (s) ? scm_gc_protect_object (s): s;
+  object_ = SCM_NIMP (s) ? scm_gc_protect_object (s) : s;
   return *this;
 }
 
@@ -43,15 +50,6 @@ Protected_scm::operator = (Protected_scm const &s)
   return operator= (s.object_);
 }
 
-
-Protected_scm::~Protected_scm ()
-{
-  if (SCM_NIMP (object_))
-    {
-      scm_gc_unprotect_object (object_);
-    }
-}
-
 Protected_scm::operator SCM () const
 {
   return object_;
index 7a82662dd9ccd037d5ae2a3a021a26a2e74f4a32..e52c8b581520f626ed36a821e081321b6d381e8d 100644 (file)
@@ -79,8 +79,8 @@ Score::Score (Score const &s)
 
   smobify_self ();
 
-  Music * m =unsmob_music (s.music_);
-  music_ =  m?m->clone ()->self_scm () : SCM_EOL;
+  Music *m =unsmob_music (s.music_);
+  music_ = m ? m->clone ()->self_scm () : SCM_EOL;
   scm_gc_unprotect_object (music_);
   
   for (int i = 0; i < s.defs_.size (); i++)
@@ -106,9 +106,7 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
   
   Cpu_timer timer;
   
-  Global_context * trans = new Global_context (odef,
-                                              music->get_length ()
-                                              );
+  Global_context * trans = new Global_context (odef, music->get_length ());
   
   if (!trans)
     {
@@ -123,10 +121,11 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
 
   iter->construct_children ();
 
-  if (! iter->ok ())
+  if (!iter->ok ())
     {
       warning (_ ("Need music in a score"));
-      return SCM_BOOL_F;       // todo: should throw exception.
+      /* todo: should throw exception. */
+      return SCM_BOOL_F;
     }
 
   trans->run_iterator_on_me (iter);
@@ -136,7 +135,6 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
 
   if (verbose_global_b)
     progress_indication (_f ("elapsed time: %.2f seconds",  timer.read ()));
-
   
   return scm_gc_unprotect_object (trans->self_scm ());
 }
index 503a81b28bf8b44ed855000e2cc0c1081cc18c18..3f8d7e67101622ddef097b3d6ce21b523a25fa88 100644 (file)
@@ -148,9 +148,6 @@ System::get_lines ()
    return lines;
 }
 
-
-
-
 /* Find the loose columns in POSNS, and drape them around the columns
    specified in BETWEEN-COLS.  */
 static void
@@ -228,7 +225,7 @@ set_loose_columns (System* which, Column_x_positions const *posns)
 void
 System::break_into_pieces (Array<Column_x_positions> const &breaking)
 {
-  for (int i=0; i < breaking.size (); i++)
+  for (int i = 0; i < breaking.size (); i++)
     {
       System *system = dynamic_cast <System*> (clone ());
       system->rank_ = i;
@@ -238,9 +235,9 @@ System::break_into_pieces (Array<Column_x_positions> const &breaking)
       
       system->set_bound (LEFT,c[0]);
       system->set_bound (RIGHT,c.top ());
-      for (int j=0; j < c.size (); j++)
+      for (int j = 0; j < c.size (); j++)
        {
-         c[j]->translate_axis (breaking[i].config_[j],X_AXIS);
+         c[j]->translate_axis (breaking[i].config_[j], X_AXIS);
          dynamic_cast<Paper_column*> (c[j])->system_ = system;
        }
       set_loose_columns (system, &breaking[i]);
@@ -253,11 +250,11 @@ System::add_column (Paper_column*p)
 {
   Grob *me = this;
   SCM cs = me->get_property ("columns");
-  Grob * prev =  ly_c_pair_p (cs) ? unsmob_grob (ly_car (cs)) : 0;
+  Grob *prev =  ly_c_pair_p (cs) ? unsmob_grob (ly_car (cs)) : 0;
 
   p->rank_ = prev ? Paper_column::get_rank (prev) + 1 : 0; 
 
-  me->set_property ("columns",  scm_cons (p->self_scm (), cs));
+  me->set_property ("columns", scm_cons (p->self_scm (), cs));
 
   Axis_group_interface::add_element (me, p);
 }
@@ -269,7 +266,7 @@ System::pre_processing ()
     unsmob_grob (ly_car (s))->discretionary_processing ();
 
   if (verbose_global_b)
-    progress_indication (_f ("Grob count %d",  element_count ()));
+    progress_indication (_f ("Grob count %d", element_count ()));
 
   
   for (SCM s = get_property ("all-elements"); ly_c_pair_p (s); s = ly_cdr (s))
@@ -286,7 +283,7 @@ System::pre_processing ()
   progress_indication ("\n" + _ ("Calculating line breaks...") + " ");
   for (SCM s = get_property ("all-elements"); ly_c_pair_p (s); s = ly_cdr (s))
     {
-      Grob * e = unsmob_grob (ly_car (s));
+      Grob *e = unsmob_grob (ly_car (s));
       SCM proc = e->get_property ("spacing-procedure");
       if (ly_c_procedure_p (proc))
        scm_call_1 (proc, e->self_scm ());
@@ -385,21 +382,21 @@ System::get_line ()
 }
 
 Link_array<Item> 
-System::broken_col_range (Item const*l, Item const*r) const
+System::broken_col_range (Item const *left, Item const *right) const
 {
   Link_array<Item> ret;
 
-  l = l->get_column ();
-  r = r->get_column ();
+  left = left->get_column ();
+  right = right->get_column ();
   SCM s = get_property ("columns");
 
-  while (ly_c_pair_p (s) && ly_car (s) != r->self_scm ())
+  while (ly_c_pair_p (s) && ly_car (s) != right->self_scm ())
     s = ly_cdr (s);
 
   if (ly_c_pair_p (s))
     s = ly_cdr (s);
 
-  while (ly_c_pair_p (s) && ly_car (s) != l->self_scm ())
+  while (ly_c_pair_p (s) && ly_car (s) != left->self_scm ())
     {
       Paper_column*c = dynamic_cast<Paper_column*> (unsmob_grob (ly_car (s)));
       if (Item::is_breakable (c) && !c->system_)
@@ -412,27 +409,25 @@ System::broken_col_range (Item const*l, Item const*r) const
   return ret;
 }
 
-/**
-   Return all columns, but filter out any unused columns , since they might
-   disrupt the spacing problem.
- */
+/** Return all columns, but filter out any unused columns , since they might
+    disrupt the spacing problem. */
 Link_array<Grob>
-System::columns ()const
+System::columns () const
 {
   Link_array<Grob> acs
     = Pointer_group_interface__extract_grobs (this, (Grob*) 0, "columns");
-  bool bfound = false;
-  for (int i= acs.size (); i -- ;)
+  bool found = false;
+  for (int i = acs.size (); i--;)
     {
       bool brb = Item::is_breakable (acs[i]);
-      bfound = bfound || brb;
+      found = found || brb;
 
       /*
        the last column should be breakable. Weed out any columns that
        seem empty. We need to retain breakable columns, in case
        someone forced a breakpoint.
       */
-      if (!bfound || !Paper_column::is_used (acs[i]))
+      if (!found || !Paper_column::is_used (acs[i]))
        acs.del (i);
     }
   return acs;
index a2824760092afe13a92730e1a22a47869dc839c8..065a9a5436f1d29a6f390aedffc28eda976245b2 100644 (file)
@@ -166,10 +166,10 @@ Virtual_font_metric::get_font_list () const
 
 LY_DEFINE (ly_make_virtual_font, "ly:make-virtual-font", 0, 0, 1,
           (SCM args),
-          "Make a virtual font metric from @var{args}, a list of font objects.")
+          "Make a virtual font metric from @var{args}, "
+          "a list of font objects.")
 {
-  Virtual_font_metric *fm = new  Virtual_font_metric (args);
-
+  Virtual_font_metric *fm = new Virtual_font_metric (args);
   return scm_gc_unprotect_object (fm->self_scm ());
 }