From: Han-Wen Nienhuys Date: Fri, 14 Jan 2005 13:07:58 +0000 (+0000) Subject: * lily/include/music.hh (class Music): replace Music::start_mom() X-Git-Tag: release/2.5.14~259 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4034396f1e07d5453d81103532bcc2969e131b92;p=lilypond.git * lily/include/music.hh (class Music): replace Music::start_mom() by start-callback property * lily/include/grace-music.hh: remove file. * lily/time-scaled-music.cc: remove file. * lily/include/music.hh (class Music): include SCM init argument. (class Music): replace Music::get_length() virtual by length-callback property everywhere. --- diff --git a/ChangeLog b/ChangeLog index df15f42c6e..849ade778e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-01-14 Han-Wen Nienhuys + * lily/include/music.hh (class Music): replace Music::start_mom() + by start-callback property + + * lily/include/grace-music.hh: remove file. + * lily/stem.cc (height): robustness fix. * lily/time-scaled-music.cc: remove file. diff --git a/lily/grace-iterator.cc b/lily/grace-iterator.cc index daa8137548..e9e6259acb 100644 --- a/lily/grace-iterator.cc +++ b/lily/grace-iterator.cc @@ -8,8 +8,6 @@ */ #include "grace-iterator.hh" - -#include "grace-music.hh" #include "global-context.hh" #include "warn.hh" diff --git a/lily/grace-music.cc b/lily/grace-music.cc index 02abe88c60..358efcdd3a 100644 --- a/lily/grace-music.cc +++ b/lily/grace-music.cc @@ -7,21 +7,21 @@ */ -#include "grace-music.hh" -#include "grace-iterator.hh" +#include "music.hh" +#include "music-wrapper.hh" -Moment -Grace_music::start_mom () const +class Grace_music { - Moment *l = unsmob_moment (Music_wrapper::length_callback (self_scm ())); - Moment gl; - gl.grace_part_ = -(l->main_part_ + l->grace_part_ ); - return gl; -} +public: + DECLARE_SCHEME_CALLBACK(start_callback, (SCM)); +}; -Grace_music::Grace_music (SCM x) - : Music_wrapper (x) +MAKE_SCHEME_CALLBACK(Grace_music,start_callback,1); +SCM +Grace_music::start_callback (SCM m) { + Moment *l = unsmob_moment (Music_wrapper::length_callback (m)); + Moment gl; + gl.grace_part_ = -(l->main_part_ + l->grace_part_ ); + return gl.smobbed_copy (); } - -ADD_MUSIC (Grace_music); diff --git a/lily/include/grace-music.hh b/lily/include/grace-music.hh deleted file mode 100644 index 9ddb705b9c..0000000000 --- a/lily/include/grace-music.hh +++ /dev/null @@ -1,25 +0,0 @@ -/* - grace-music.hh -- declare Grace_music - - source file of the GNU LilyPond music typesetter - - (c) 1999--2004 Han-Wen Nienhuys - - */ - -#ifndef GRACE_MUSIC_HH -#define GRACE_MUSIC_HH - -#include "music-wrapper.hh" - -class Grace_music : public Music_wrapper -{ -public: - VIRTUAL_COPY_CONSTRUCTOR (Music, Grace_music); - Grace_music (SCM); -protected: - virtual Moment start_mom () const; -}; - -#endif /* GRACE_MUSIC_HH */ - diff --git a/lily/include/music-iterator.hh b/lily/include/music-iterator.hh index c5fdfe912c..9429273ca4 100644 --- a/lily/include/music-iterator.hh +++ b/lily/include/music-iterator.hh @@ -60,7 +60,7 @@ protected: public: Moment music_get_length () const; - virtual Moment music_start_mom () const; + Moment music_start_mom () const; Music_iterator (); /** diff --git a/lily/include/music-list.hh b/lily/include/music-list.hh index fcbcb78e93..b16e573476 100644 --- a/lily/include/music-list.hh +++ b/lily/include/music-list.hh @@ -20,9 +20,7 @@ class Simultaneous_music : public Music_sequence public: Simultaneous_music (SCM); VIRTUAL_COPY_CONSTRUCTOR (Music, Simultaneous_music); - virtual Pitch to_relative_octave (Pitch); - virtual Moment start_mom () const; }; /* @@ -43,8 +41,6 @@ class Sequential_music : public Music_sequence { public: VIRTUAL_COPY_CONSTRUCTOR (Music, Sequential_music); - virtual Moment start_mom () const; - Sequential_music (SCM); }; diff --git a/lily/include/music-sequence.hh b/lily/include/music-sequence.hh index 34e69c16b9..46ee4507ee 100644 --- a/lily/include/music-sequence.hh +++ b/lily/include/music-sequence.hh @@ -19,6 +19,8 @@ public: VIRTUAL_COPY_CONSTRUCTOR (Music, Music_sequence); DECLARE_SCHEME_CALLBACK(cumulative_length_callback, (SCM)); DECLARE_SCHEME_CALLBACK(maximum_length_callback, (SCM)); + DECLARE_SCHEME_CALLBACK(minimum_start_callback, (SCM)); + DECLARE_SCHEME_CALLBACK(first_start_callback, (SCM)); SCM music_list () const; Pitch do_relative_octave (Pitch p, bool b); diff --git a/lily/include/music-wrapper.hh b/lily/include/music-wrapper.hh index 7403095562..d2aa355676 100644 --- a/lily/include/music-wrapper.hh +++ b/lily/include/music-wrapper.hh @@ -25,8 +25,9 @@ public: Music_wrapper (SCM); VIRTUAL_COPY_CONSTRUCTOR (Music, Music_wrapper); DECLARE_SCHEME_CALLBACK(length_callback,(SCM)); + DECLARE_SCHEME_CALLBACK(start_callback, (SCM)); + Music *element () const; - virtual Moment start_mom () const; }; #endif /* MUSIC_WRAPPER_HH */ diff --git a/lily/include/music.hh b/lily/include/music.hh index 82de70454b..0eefbc3b71 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -47,7 +47,7 @@ public: virtual Pitch to_relative_octave (Pitch); String name () const; Moment get_length () const; - virtual Moment start_mom () const; + Moment start_mom () const; void print () const; /// Transpose, with the interval central C to #p# virtual void transpose (Pitch p); @@ -61,6 +61,7 @@ protected: SCM mutable_property_alist_; protected: SCM length_callback_; + SCM start_callback_; friend SCM ly_extended_make_music (SCM, SCM); }; diff --git a/lily/music-sequence.cc b/lily/music-sequence.cc index 3051f48e67..150cc9cba4 100644 --- a/lily/music-sequence.cc +++ b/lily/music-sequence.cc @@ -82,6 +82,23 @@ Music_sequence::cumulative_length_callback (SCM m) return cumulative_length (me->get_property ("elements")).smobbed_copy(); } + +MAKE_SCHEME_CALLBACK(Music_sequence,minimum_start_callback,1); +SCM +Music_sequence::minimum_start_callback (SCM m) +{ + Music* me = unsmob_music (m); + return minimum_start (me->get_property ("elements")).smobbed_copy(); +} + +MAKE_SCHEME_CALLBACK(Music_sequence,first_start_callback,1); +SCM +Music_sequence::first_start_callback (SCM m) +{ + Music* me = unsmob_music (m); + return first_start (me->get_property ("elements")).smobbed_copy(); +} + Pitch music_list_to_relative (SCM l,Pitch p, bool ret_first) { diff --git a/lily/music-wrapper.cc b/lily/music-wrapper.cc index a8dbf95bff..0a1650f991 100644 --- a/lily/music-wrapper.cc +++ b/lily/music-wrapper.cc @@ -14,8 +14,18 @@ Music_wrapper::Music_wrapper (SCM x) { if (!ly_c_procedure_p (length_callback_)) length_callback_ = length_callback_proc; + if (!ly_c_procedure_p (start_callback_)) + start_callback_ = length_callback_proc; } +MAKE_SCHEME_CALLBACK(Music_wrapper,start_callback,1); +SCM +Music_wrapper::start_callback (SCM m) +{ + Music *me = unsmob_music (m); + Music *elt = unsmob_music (me->get_property ("element")); + return elt->start_mom ().smobbed_copy (); +} MAKE_SCHEME_CALLBACK(Music_wrapper,length_callback,1); SCM @@ -35,9 +45,3 @@ Music_wrapper::element () const ADD_MUSIC (Music_wrapper); - -Moment -Music_wrapper::start_mom () const -{ - return element ()->start_mom (); -} diff --git a/lily/music.cc b/lily/music.cc index f0622a731e..edaed5e3f3 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -47,6 +47,7 @@ Music::Music (SCM init) smobify_self (); length_callback_ = get_property ("length-callback"); + start_callback_ = get_property ("start-callback"); } Music::Music (Music const &m) @@ -61,6 +62,7 @@ Music::Music (Music const &m) smobify_self (); mutable_property_alist_ = ly_music_deep_copy (m.mutable_property_alist_); length_callback_ = m.length_callback_; + start_callback_ = m.start_callback_; set_spot (*m.origin ()); } @@ -104,7 +106,7 @@ Music::get_length () const Moment Music::start_mom () const { - SCM lst = get_property ("start-moment-function"); + SCM lst = get_property ("start-callback"); if (ly_c_procedure_p (lst)) { SCM res = scm_call_1 (lst, self_scm ()); diff --git a/lily/repeated-music.cc b/lily/repeated-music.cc index f145ecfe36..90764d987e 100644 --- a/lily/repeated-music.cc +++ b/lily/repeated-music.cc @@ -156,8 +156,6 @@ Repeated_music::Repeated_music (SCM x) MAKE_SCHEME_CALLBACK (Repeated_music,minimum_start, 1); -MAKE_SCHEME_CALLBACK (Repeated_music,first_start, 1); - SCM Repeated_music::minimum_start (SCM m) { @@ -172,6 +170,7 @@ Repeated_music::minimum_start (SCM m) } } +MAKE_SCHEME_CALLBACK (Repeated_music,first_start, 1); SCM Repeated_music::first_start (SCM m) { diff --git a/lily/sequential-music.cc b/lily/sequential-music.cc index ada814deb0..dee78e2e28 100644 --- a/lily/sequential-music.cc +++ b/lily/sequential-music.cc @@ -7,9 +7,3 @@ Sequential_music::Sequential_music (SCM x) } ADD_MUSIC (Sequential_music); - -Moment -Sequential_music::start_mom () const -{ - return Music_sequence::first_start (get_property ("elements")); -} diff --git a/lily/simultaneous-music.cc b/lily/simultaneous-music.cc index 04f0506c2b..7d82cc7660 100644 --- a/lily/simultaneous-music.cc +++ b/lily/simultaneous-music.cc @@ -12,12 +12,6 @@ #include "music-list.hh" #include "scm-option.hh" -Moment -Simultaneous_music::start_mom () const -{ - return Music_sequence::minimum_start (get_property ("elements")); -} - Simultaneous_music::Simultaneous_music (SCM x) : Music_sequence (x) { diff --git a/scm/define-music-properties.scm b/scm/define-music-properties.scm index b8aba452ff..8b730ef2ab 100644 --- a/scm/define-music-properties.scm +++ b/scm/define-music-properties.scm @@ -98,7 +98,7 @@ processed.") (repeat-count ,integer? "do a @code{\repeat} how ofen?") (span-direction ,ly:dir? "Does this start or stop a spanner?") (split-list ,list? "splitting moments for part combiner.") - (start-moment-function ,procedure? "Function to compute the negative length of + (start-callback ,procedure? "Function to compute the negative length of starting grace notes.") (string-number ,integer? "The number of the string in a String_number_req") (symbol ,symbol? "Grob name to perform an override/revert on.") diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index 4578a7a481..fe790ec6a2 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -198,7 +198,8 @@ Syntax: @var{note}\\cr (GraceMusic . ( (description . "Interpret the argument as grace notes. ") - (internal-class-name . "Grace_music") + (internal-class-name . "Music_wrapper") + (start-callback . ,Grace_music::start_callback) (length . ,(ly:make-moment 0 1)) (iterator-ctor . ,Grace_iterator::constructor) (types . (grace-music music-wrapper-music general-music)) @@ -352,6 +353,8 @@ SYNTAX (description . "Combine two parts on a staff, either merged or as separate voices.") (internal-class-name . "Simultaneous_music") + (length-callback . ,Music_sequence::maximum_length_callback) + (start-callback . ,Music_sequence::minimum_start_callback) (types . (general-music part-combine-music)) (iterator-ctor . ,Part_combine_iterator::constructor) )) @@ -368,15 +371,12 @@ Syntax NOTE \\( and \\) NOTE") . ( (description . "Set a context property. - - Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.") (internal-class-name . "Music") (types . (layout-instruction general-music)) (iterator-ctor . ,Property_iterator::constructor) - ) - ) - + )) + (PropertyUnset . ( (description . "Remove the definition of a context @code{\\property}.") @@ -384,8 +384,7 @@ Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.") (internal-class-name . "Music") (types . (layout-instruction general-music)) (iterator-ctor . ,Property_unset_iterator::constructor) - ) - ) + )) (PesOrFlexaEvent . ( @@ -454,6 +453,7 @@ Syntax \\sequential @{..@} or simply @{..@} .") (internal-class-name . "Sequential_music") (length-callback . ,Music_sequence::cumulative_length_callback) + (start-callback . ,Music_sequence::first_start_callback) (iterator-ctor . ,Sequential_music_iterator::constructor) (types . (general-music sequential-music)) )) @@ -466,6 +466,7 @@ to group start-mmrest, skip, stop-mmrest sequence. Syntax @code{R2.*5} for 5 measures in 3/4 time.") (internal-class-name . "Sequential_music") (length-callback . ,Music_sequence::cumulative_length_callback) + (start-callback . ,Music_sequence::first_start_callback) (iterator-ctor . ,Sequential_music_iterator::constructor) (types . (general-music sequential-music)) )) @@ -500,6 +501,7 @@ SYNTAX (internal-class-name . "Simultaneous_music") (iterator-ctor . ,Simultaneous_music_iterator::constructor) + (start-callback . ,Music_sequence::minimum_start_callback) (length-callback . ,Music_sequence::maximum_length_callback) (types . (general-music simultaneous-music)) @@ -715,7 +717,7 @@ Syntax: @code{\\\\}") (iterator-ctor . ,Volta_repeat_iterator::constructor) (internal-class-name . "Repeated_music") (description . "") - (start-moment-function . ,Repeated_music::first_start) + (start-callback . ,Repeated_music::first_start) (length-callback . ,Repeated_music::volta_music_length) (types . (general-music repeated-music volta-repeated-music)) )) @@ -724,7 +726,7 @@ Syntax: @code{\\\\}") . ( (iterator-ctor . ,Unfolded_repeat_iterator::constructor) (description . "") - (start-moment-function . ,Repeated_music::first_start) + (start-callback . ,Repeated_music::first_start) (internal-class-name . "Repeated_music") (types . (general-music repeated-music unfolded-repeated-music)) (length-callback . ,Repeated_music::unfolded_music_length) @@ -734,7 +736,7 @@ Syntax: @code{\\\\}") (internal-class-name . "Repeated_music") (description . "Repeats encoded by percents.") (iterator-ctor . ,Percent_repeat_iterator::constructor) - (start-moment-function . ,Repeated_music::first_start) + (start-callback . ,Repeated_music::first_start) (length-callback . ,Repeated_music::unfolded_music_length) (types . (general-music repeated-music percent-repeated-music)) )) @@ -744,7 +746,7 @@ Syntax: @code{\\\\}") (iterator-ctor . ,Chord_tremolo_iterator::constructor) (description . "Repeated notes denoted by tremolo beams.") (internal-class-name . "Repeated_music") - (start-moment-function . ,Repeated_music::first_start) + (start-callback . ,Repeated_music::first_start) ;; the length of the repeat is handled by shifting the note logs (length-callback . ,Repeated_music::folded_music_length) @@ -757,7 +759,7 @@ Syntax: @code{\\\\}") (internal-class-name . "Repeated_music") (description . "Repeats with alternatives placed in parallel. ") (iterator-ctor . ,Folded_repeat_iterator::constructor) - (start-moment-function . ,Repeated_music::minimum_start) + (start-callback . ,Repeated_music::minimum_start) (length-callback . ,Repeated_music::folded_music_length) (types . (general-music repeated-music folded-repeated-music)) ))