From a2df6d13e3d521717e372d880c4ff5dbef831d67 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 28 Apr 2004 22:03:54 +0000 Subject: [PATCH] Remove paper var caching. --- ChangeLog | 8 +++++ Documentation/user/music-glossary.tely | 16 ++++----- lily/book.cc | 24 ++------------ lily/include/book.hh | 2 +- lily/include/page.hh | 5 --- lily/page.cc | 46 +++++++++++++++----------- lily/parser.yy | 2 +- lily/protected-scm.cc | 22 ++++++------ lily/score.cc | 14 ++++---- lily/system.cc | 43 +++++++++++------------- lily/virtual-font-metric.cc | 6 ++-- 11 files changed, 85 insertions(+), 103 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ad5d7fb8b..81a753815c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ +2004-04-29 Jan Nieuwenhuizen + + * lily/page.cc: Remove paper var caching. + 2004-04-28 Jan Nieuwenhuizen + * 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. diff --git a/Documentation/user/music-glossary.tely b/Documentation/user/music-glossary.tely index 5d0a3e7517..ac02de30f8 100644 --- a/Documentation/user/music-glossary.tely +++ b/Documentation/user/music-glossary.tely @@ -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 --------------------- diff --git a/lily/book.cc b/lily/book.cc index 477c250878..93c2cf84eb 100644 --- a/lily/book.cc +++ b/lily/book.cc @@ -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'...", "")); - return unsmob_page (ly_car (pages))->to_stencil (); + return (unsmob_page (ly_car (pages)))->to_stencil (); } return SCM_EOL; } diff --git a/lily/include/book.hh b/lily/include/book.hh index 8682599549..c9191e63f9 100644 --- a/lily/include/book.hh +++ b/lily/include/book.hh @@ -24,7 +24,7 @@ public: Link_array scores_; Book (); - Book (Book const&); + void process (String outname, Music_output_def*, SCM header); SCM to_stencil (Music_output_def*, SCM header); }; diff --git a/lily/include/page.hh b/lily/include/page.hh index 880cbc0bd5..c12d32c02c 100644 --- a/lily/include/page.hh +++ b/lily/include/page.hh @@ -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); diff --git a/lily/page.cc b/lily/page.cc index 801e9c9c50..f296b4bc8b 100644 --- a/lily/page.cc +++ b/lily/page.cc @@ -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_)) diff --git a/lily/parser.yy b/lily/parser.yy index 8575eb2071..9bb3c89627 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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); } ; diff --git a/lily/protected-scm.cc b/lily/protected-scm.cc index 93b29a48d4..56bd2def2f 100644 --- a/lily/protected-scm.cc +++ b/lily/protected-scm.cc @@ -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_; diff --git a/lily/score.cc b/lily/score.cc index 7a82662dd9..e52c8b5815 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -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 ()); } diff --git a/lily/system.cc b/lily/system.cc index 503a81b28b..3f8d7e6710 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -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 const &breaking) { - for (int i=0; i < breaking.size (); i++) + for (int i = 0; i < breaking.size (); i++) { System *system = dynamic_cast (clone ()); system->rank_ = i; @@ -238,9 +235,9 @@ System::break_into_pieces (Array 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 (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 -System::broken_col_range (Item const*l, Item const*r) const +System::broken_col_range (Item const *left, Item const *right) const { Link_array 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 (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 -System::columns ()const +System::columns () const { Link_array 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; diff --git a/lily/virtual-font-metric.cc b/lily/virtual-font-metric.cc index a282476009..065a9a5436 100644 --- a/lily/virtual-font-metric.cc +++ b/lily/virtual-font-metric.cc @@ -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 ()); } -- 2.39.2