From 999ec4ece307e6325ab44bb751194fc281d6d656 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 6 Nov 2004 20:52:20 +0000 Subject: [PATCH] (Generic_prefix_music_scm): add MUSIC_FUNCTION_SCM_SCM_MUSIC --- ChangeLog | 8 +++++-- lily/include/moment.hh | 2 ++ lily/include/music-wrapper-iterator.hh | 1 - lily/moment.cc | 8 +++++++ lily/music-wrapper-iterator.cc | 3 +-- lily/parser.yy | 5 +++++ lily/quote-iterator.cc | 29 +------------------------- ly/music-functions-init.ly | 14 +++++++++++++ scm/define-music-types.scm | 7 +++++++ 9 files changed, 44 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c10f23372..41394d7903 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,12 @@ 2004-11-06 Han-Wen Nienhuys - * scm/lily.scm (sanitize-command-option): new function. + * lily/parser.yy (Generic_prefix_music_scm): add + MUSIC_FUNCTION_SCM_SCM_MUSIC - * scm/framework-tex.scm (header): sanitize TeX paper size. + * scm/lily.scm (sanitize-command-option): new function. (backportme) + + * scm/framework-tex.scm (header): sanitize TeX paper size. + (backportme) 2004-11-06 Jan Nieuwenhuizen diff --git a/lily/include/moment.hh b/lily/include/moment.hh index 894c9d7017..7d4f7977bc 100644 --- a/lily/include/moment.hh +++ b/lily/include/moment.hh @@ -66,5 +66,7 @@ Moment robust_scm2moment (SCM, Moment); std::ostream & operator << (std::ostream &, Moment const &); #endif +bool moment_less (SCM a, SCM b); + #endif /* MOMENT_HH */ diff --git a/lily/include/music-wrapper-iterator.hh b/lily/include/music-wrapper-iterator.hh index 0befe300b0..8738152e2b 100644 --- a/lily/include/music-wrapper-iterator.hh +++ b/lily/include/music-wrapper-iterator.hh @@ -25,7 +25,6 @@ public: Music_wrapper_iterator (); virtual void derived_substitute (Context *f, Context *t) ; - virtual void derived_mark () const; virtual void construct_children () ; virtual Moment pending_moment () const; diff --git a/lily/moment.cc b/lily/moment.cc index f30f361367..51664870b4 100644 --- a/lily/moment.cc +++ b/lily/moment.cc @@ -257,3 +257,11 @@ robust_scm2moment (SCM m, Moment d) else return *p; } + + +bool +moment_less (SCM a, SCM b) +{ + return *unsmob_moment (a) < *unsmob_moment (b); +} + diff --git a/lily/music-wrapper-iterator.cc b/lily/music-wrapper-iterator.cc index 428cac5a62..7d6f3888b4 100644 --- a/lily/music-wrapper-iterator.cc +++ b/lily/music-wrapper-iterator.cc @@ -12,7 +12,7 @@ Music_wrapper_iterator::Music_wrapper_iterator () { - child_iter_ =0; + child_iter_ = 0; } void @@ -31,7 +31,6 @@ Music_wrapper_iterator::derived_mark () const void Music_wrapper_iterator::derived_substitute (Context *f,Context *t) { - if (child_iter_) child_iter_->substitute_outlet (f,t); } diff --git a/lily/parser.yy b/lily/parser.yy index 1c33a01082..0c3b76df01 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1016,6 +1016,11 @@ Generic_prefix_music_scm: } embedded_scm embedded_scm { $$ = scm_list_4 ($1, make_input (THIS->pop_spot ()), $3, $4); } + | MUSIC_FUNCTION_SCM_SCM_MUSIC { + THIS->push_spot (); + } embedded_scm embedded_scm Music { + $$ = scm_list_5 ($1, make_input (THIS->pop_spot ()), $3, $4, $5->self_scm ()); + } | MUSIC_FUNCTION_MARKUP_MUSIC { THIS->push_spot (); } full_markup Music { diff --git a/lily/quote-iterator.cc b/lily/quote-iterator.cc index 3b676a4cd5..9e012104de 100644 --- a/lily/quote-iterator.cc +++ b/lily/quote-iterator.cc @@ -70,35 +70,8 @@ Quote_iterator::Quote_iterator () end_idx_ = 0; } -bool -moment_less (SCM a, SCM b) -{ - return *unsmob_moment (a) < *unsmob_moment (b); -} - - int -binsearch_scm_vector (SCM vec, SCM key, bool (*is_less)(SCM a,SCM b)) -{ - int lo = 0; - int hi = SCM_VECTOR_LENGTH (vec); - - /* binary search */ - do - { - int cmp = (lo + hi) / 2; - - SCM when = scm_caar (SCM_VECTOR_REF (vec, cmp)); - bool result = (*is_less) (key, when); - if (result) - hi = cmp; - else - lo = cmp; - } - while (hi - lo > 1); - - return lo; -} +binsearch_scm_vector (SCM vec, SCM key, bool (*is_less)(SCM a,SCM b)); void diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index d9e60efcfd..81129b7b0d 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -72,6 +72,20 @@ keepWithTag = (memq tag tags)))) music)) + + +quoteDuring = +#(def-music-function + (location what dir music) (string? ly:dir? ly:music?) + (let* + ((quote-music (make-music 'NewQuoteMusic + 'quoted-music-name what + 'element music + 'origin location) + )) + + quote-music)) + %{ TODO: diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index acb25a3095..fb7f565067 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -409,6 +409,13 @@ goes down).") (iterator-ctor . ,Quote_iterator::constructor) (types . (general-music)) )) + (NewQuoteMusic + . ( + (description . "Quote preprocessed snippets of music. ") + (internal-class-name . "Music") ;; so we get Event::get_length (). + (iterator-ctor . ,New_quote_iterator::constructor) + (types . (general-music)) + )) (RelativeOctaveCheck . ((description . "Check if a pitch is in the correct octave.") -- 2.39.5