From 47b1c9fddeec6d243c4df9d66ab71969bdee7b2f Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 22 Jun 2002 02:02:21 +0000 Subject: '' --- ChangeLog | 7 ++++++- DEDICATION | 8 +++---- lily/grob.cc | 59 +++++++++++++++++++++++++++++++++++++++------------- lily/include/grob.hh | 33 +++++------------------------ lily/item.cc | 6 +++--- ly/engraver-init.ly | 6 ++++-- 6 files changed, 67 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 153161ec49..06b993dc6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2002-06-21 Han-Wen Nienhuys +2002-06-22 Han-Wen + + * lily/grob.cc (do_break_substitution): rename function, use + global var for criterion argument. Reduces stack usage a little. + + * ly/engraver-init.ly (StaffContext): add Instrument_engraver * scripts/convert-ly.py, lily/*.cc, scm/*.scm: change visibility-lambda to break-visibility diff --git a/DEDICATION b/DEDICATION index ad8fcd5309..5a4b29022f 100644 --- a/DEDICATION +++ b/DEDICATION @@ -5,10 +5,10 @@ met through music. - Those deserving special mentioning (in no particular order): Esther, -Marijke, Heike, Inge, Judith, Hannah, Auke, Ilse, Evelyn, Maartje, Suzanne, -Ilse (gee, again?), Marieke, Irene, Martine, Idwine and last (but certainly not -least) Janneke! + Those deserving special mentioning (in no particular order): +Esther, Marijke, Heike, Inge, Judith, Hannah, Auke, Ilse, Evelyn, +Maartje, Suzanne, Ilse (gee, again?), Marieke, Irene, Martine, Idwine, +Hanna and last (but certainly not least) Janneke! HWN diff --git a/lily/grob.cc b/lily/grob.cc index 08d263bcf6..d8e4dbf438 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -377,18 +377,30 @@ Grob::add_dependency (Grob*e) It is rather tightly coded, since it takes a lot of time; it is one of the top functions in the profile. + We don't pass break_criterion as a parameter, since it is + `constant', but takes up stack space. + */ + + +static SCM break_criterion; +void +set_break_subsititution (SCM criterion) +{ + break_criterion = criterion; +} + SCM -Grob::handle_broken_grobs (SCM src, SCM criterion) +do_break_substitution (SCM src) { again: Grob *sc = unsmob_grob (src); if (sc) { - if (SCM_INUMP (criterion)) + if (SCM_INUMP (break_criterion)) { Item * i = dynamic_cast (sc); - Direction d = to_dir (criterion); + Direction d = to_dir (break_criterion); if (i && i->break_status_dir () != d) { Item *br = i->find_prebroken_piece (d); @@ -398,7 +410,7 @@ Grob::handle_broken_grobs (SCM src, SCM criterion) else { System * line - = dynamic_cast (unsmob_grob (criterion)); + = dynamic_cast (unsmob_grob (break_criterion)); if (sc->line_l () != line) { sc = sc->find_broken_piece (line); @@ -435,7 +447,7 @@ Grob::handle_broken_grobs (SCM src, SCM criterion) /* UGH! breaks on circular lists. */ - SCM newcar = handle_broken_grobs (oldcar, criterion); + SCM newcar = do_break_substitution (oldcar); SCM oldcdr = ly_cdr (src); if (newcar == SCM_UNDEFINED @@ -444,7 +456,7 @@ Grob::handle_broken_grobs (SCM src, SCM criterion) /* This is tail-recursion, ie. - return handle_broken_grobs (cdr, criterion); + return do_break_substution (cdr, break_criterion); We don't want to rely on the compiler to do this. Without tail-recursion, this easily crashes with a stack overflow. */ @@ -452,7 +464,7 @@ Grob::handle_broken_grobs (SCM src, SCM criterion) goto again; } - SCM newcdr = handle_broken_grobs (oldcdr, criterion); + SCM newcdr = do_break_substitution (oldcdr); return scm_cons (newcar, newcdr); } else @@ -474,9 +486,11 @@ Grob::handle_broken_dependencies () { Grob * sc = s->broken_into_l_arr_[i]; System * l = sc->line_l (); + + set_break_subsititution (l ? l->self_scm () : SCM_UNDEFINED); sc->mutable_property_alist_ = - handle_broken_grobs (mutable_property_alist_, - l ? l->self_scm () : SCM_UNDEFINED); + do_break_substitution (mutable_property_alist_); + } } @@ -485,14 +499,13 @@ Grob::handle_broken_dependencies () if (line && common_refpoint (line, X_AXIS) && common_refpoint (line, Y_AXIS)) { - mutable_property_alist_ - = handle_broken_grobs (mutable_property_alist_, - line ? line->self_scm () : SCM_UNDEFINED); + set_break_subsititution (line ? line->self_scm () : SCM_UNDEFINED); + mutable_property_alist_ = do_break_substitution (mutable_property_alist_); } else if (dynamic_cast (this)) { - mutable_property_alist_ = handle_broken_grobs (mutable_property_alist_, - SCM_UNDEFINED); + set_break_subsititution (SCM_UNDEFINED); + mutable_property_alist_ = do_break_substitution (mutable_property_alist_); } else { @@ -540,6 +553,9 @@ Grob::find_broken_piece (System*) const return 0; } +/* + translate in one direction +*/ void Grob::translate_axis (Real y, Axis a) { @@ -551,6 +567,13 @@ Grob::translate_axis (Real y, Axis a) } } + +/* + Find the offset relative to D. If D equals THIS, then it is 0. + Otherwise, it recursively defd as + + OFFSET_ + PARENT_L_->relative_coordinate (D) +*/ Real Grob::relative_coordinate (Grob const*refp, Axis a) const { @@ -568,6 +591,11 @@ Grob::relative_coordinate (Grob const*refp, Axis a) const return get_offset (a) + dim_cache_[a].parent_l_->relative_coordinate (refp, a); } + + +/* + Invoke callbacks to get offset relative to parent. +*/ Real Grob::get_offset (Axis a) const { @@ -656,6 +684,9 @@ Grob::extent (Grob * refp, Axis a) const return ext; } +/* + Find the group-element which has both #this# and #s# +*/ Grob * Grob::common_refpoint (Grob const* s, Axis a) const { diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 792cdf8f9e..8e8cde5890 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -101,7 +101,7 @@ public: #funcptr# is the function to call to update this element. */ void calculate_dependencies (int final, int busy, SCM funcname); - static SCM handle_broken_grobs(SCM, SCM criterion); + virtual void do_break_processing (); virtual Grob *find_broken_piece (System*) const; @@ -117,7 +117,6 @@ public: DECLARE_SCHEME_CALLBACK (point_dimension_callback, (SCM smob, SCM axis)); DECLARE_SCHEME_CALLBACK (molecule_extent, (SCM smob, SCM axis)); - static SCM ly_set_grob_property (SCM, SCM,SCM); static SCM ly_get_grob_property (SCM, SCM); @@ -127,34 +126,16 @@ public: virtual void handle_broken_dependencies (); virtual void handle_prebroken_dependencies (); - DECLARE_SMOBS (Grob,foo); void init (); - - public: - bool empty_b (Axis a) const; Interval extent (Grob * refpoint, Axis) const; - /** - translate in one direction - */ - void translate_axis (Real, Axis); - - /** - Find the offset relative to D. If D equals THIS, then it is 0. - Otherwise, it recursively defd as - - OFFSET_ + PARENT_L_->relative_coordinate (D) - */ Real relative_coordinate (Grob const* refp, Axis) const; - /** - Find the group-element which has both #this# and #s# - */ Grob*common_refpoint (Grob const* s, Axis a) const; @@ -163,15 +144,8 @@ public: void add_offset_callback (SCM callback, Axis); bool has_extent_callback_b (SCM, Axis)const; void set_extent (SCM , Axis); - - - /** - Invoke callbacks to get offset relative to parent. - */ Real get_offset (Axis a) const; - /** - Set the parent refpoint of THIS to E - */ + void set_parent (Grob* e, Axis); Grob *get_parent (Axis a) const { return dim_cache_[a].parent_l_; } @@ -185,5 +159,8 @@ Item* unsmob_item (SCM ); Grob*common_refpoint_of_list (SCM elt_list, Grob * , Axis a); Grob*common_refpoint_of_array (Link_array const&, Grob * , Axis a); +void set_break_subsititution (SCM criterion); +SCM do_break_substitution (SCM); + #endif // STAFFELEM_HH diff --git a/lily/item.cc b/lily/item.cc index 594c97517c..0f964f2668 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -145,9 +145,9 @@ Item::handle_prebroken_dependencies () { if (original_l_) { - mutable_property_alist_ - = handle_broken_grobs(original_l_->mutable_property_alist_, - gh_int2scm (break_status_dir ())); + set_break_subsititution (gh_int2scm (break_status_dir ())); + mutable_property_alist_ = do_break_substitution(original_l_->mutable_property_alist_); + } /* diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 003d0cc5c1..313fb16237 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -113,6 +113,7 @@ RhythmicStaffContext=\translator{ \consists "Bar_engraver" \consists "Time_signature_engraver" \consists "Staff_symbol_engraver" + \consists "Instrument_name_engraver" \consistsend "Axis_group_engraver" \accepts "Voice" } @@ -446,16 +447,17 @@ FiguredBassContext = \translator { \consistsend "Axis_group_engraver" } + TabVoiceContext = \translator { \VoiceContext \name "TabVoice" \denies "Thread" \consists "Tab_note_heads_engraver" - + % Draws all stems/beams out of the staff (and not in the middle of the staff !) Beam \override #'damping = #100000 Stem \override #'up-to-staff = ##t - + % No accidental in tablature ! \remove Accidental_engraver Accidental = \turnOff -- cgit v1.2.3