From: hanwen Date: Thu, 2 Mar 2006 00:39:54 +0000 (+0000) Subject: * stepmake/aclocal.m4 (depth): fix bashism. X-Git-Tag: release/2.7.38^2~21 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=222e972df7a0f2ec1c7bbe56111bb97679dbf59f;p=lilypond.git * stepmake/aclocal.m4 (depth): fix bashism. * lily/lyric-combine-music-iterator.cc: move from new-lyric-combine-iterator.cc (process): add pending_grace_lyric_ member to delay lyrics on grace notes. --- diff --git a/ChangeLog b/ChangeLog index cf93e670e6..2219c732ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2006-03-02 Han-Wen Nienhuys + * stepmake/aclocal.m4 (depth): fix bashism. + + * lily/lyric-combine-music-iterator.cc: move from + new-lyric-combine-iterator.cc + (process): add pending_grace_lyric_ member to delay lyrics on + grace notes. + * lily/system-start-text.cc (print): suicide if we don't have any elements. Fixes hara kiri'd instrument names. diff --git a/THANKS b/THANKS index a9cf2ca49d..21078903a6 100644 --- a/THANKS +++ b/THANKS @@ -88,6 +88,7 @@ Paul Scott Ralph Little Richard Schoeller Robert Vlatasy +Roman Kurakin Scott Russell Sean Reed Seng Liang diff --git a/lily/lyric-combine-music-iterator.cc b/lily/lyric-combine-music-iterator.cc new file mode 100644 index 0000000000..f812d1c952 --- /dev/null +++ b/lily/lyric-combine-music-iterator.cc @@ -0,0 +1,270 @@ +/* + new-lyric-combine-iterator.cc -- implement Lyric_combine_music_iterator + + source file of the GNU LilyPond music typesetter + + (c) 2004--2006 Han-Wen Nienhuys +*/ + +#include "context.hh" +#include "grob.hh" +#include "input.hh" +#include "international.hh" +#include "music-iterator.hh" +#include "music.hh" + +class Lyric_combine_music_iterator : public Music_iterator +{ +public: + Lyric_combine_music_iterator (); + Lyric_combine_music_iterator (Lyric_combine_music_iterator const &src); + DECLARE_SCHEME_CALLBACK (constructor, ()); +protected: + virtual void construct_children (); + virtual Moment pending_moment () const; + virtual void do_quit (); + virtual void process (Moment); + virtual Music_iterator *try_music_in_children (Music *) const; + virtual bool run_always ()const; + virtual bool ok () const; + virtual void derived_mark () const; + virtual void derived_substitute (Context *, Context *); +private: + bool start_new_syllable (); + void find_voice (); + + bool pending_grace_lyric_; + bool music_found_; + bool made_association_; + Context *lyrics_context_; + Context *music_context_; + SCM lyricsto_voice_name_; + + Music_iterator *lyric_iter_; +}; + +/* + Ugh; this is a hack, let's not export this hack, so static. +*/ +static Music *busy_ev; +static Music *start_ev; +static Music *melisma_playing_ev; + +Lyric_combine_music_iterator::Lyric_combine_music_iterator () +{ + music_found_ = false; + made_association_ = false; + pending_grace_lyric_ = false; + lyric_iter_ = 0; + music_context_ = 0; + lyrics_context_ = 0; + + /* + Ugh. out of place here. + */ + if (!busy_ev) + { + busy_ev + = make_music_by_name (ly_symbol2scm ("BusyPlayingEvent")); + start_ev + = make_music_by_name (ly_symbol2scm ("StartPlayingEvent")); + melisma_playing_ev + = make_music_by_name (ly_symbol2scm ("MelismaPlayingEvent")); + } +} + +bool +Lyric_combine_music_iterator::start_new_syllable () +{ + bool b = music_context_->try_music (busy_ev); + + if (!b) + return false; + + if (!lyrics_context_) + return false; + + if (!to_boolean (lyrics_context_->get_property ("ignoreMelismata"))) + { + bool m = music_context_->try_music (melisma_playing_ev); + if (m) + return false; + } + + return true; +} + +Moment +Lyric_combine_music_iterator::pending_moment () const +{ + Moment m; + + m.set_infinite (1); + + return m; +} + +bool +Lyric_combine_music_iterator::run_always () const +{ + return true; +} + +bool +Lyric_combine_music_iterator::ok () const +{ + return lyric_iter_ && lyric_iter_->ok (); +} + +void +Lyric_combine_music_iterator::derived_mark ()const +{ + if (lyric_iter_) + scm_gc_mark (lyric_iter_->self_scm ()); + if (lyrics_context_) + scm_gc_mark (lyrics_context_->self_scm ()); + if (music_context_) + scm_gc_mark (music_context_->self_scm ()); +} + +void +Lyric_combine_music_iterator::derived_substitute (Context *f, Context *t) +{ + if (lyric_iter_) + lyric_iter_->substitute_outlet (f, t); + if (lyrics_context_ && lyrics_context_ == f) + lyrics_context_ = t; + if (music_context_ && music_context_ == f) + music_context_ = t; +} + +void +Lyric_combine_music_iterator::construct_children () +{ + Music *m = unsmob_music (get_music ()->get_property ("element")); + lyric_iter_ = unsmob_iterator (get_iterator (m)); + + lyricsto_voice_name_ = get_music ()->get_property ("associated-context"); + + find_voice (); + + if (lyric_iter_) + lyrics_context_ = find_context_below (lyric_iter_->get_outlet (), + ly_symbol2scm ("Lyrics"), ""); + + /* + We do not create a Lyrics context, because the user might + create one with a different name, and then we will not find that + one. + */ +} + +void +Lyric_combine_music_iterator::find_voice () +{ + SCM voice_name = lyricsto_voice_name_; + SCM running = lyrics_context_ + ? lyrics_context_->get_property ("associatedVoice") + : SCM_EOL; + + if (scm_is_string (running)) + voice_name = running; + + if (scm_is_string (voice_name) + && (!music_context_ || ly_scm2string (voice_name) != music_context_->id_string ())) + { + /* + (spaghettini). + + Need to set associatedVoiceContext again + */ + if (music_context_) + made_association_ = false; + + Context *t = get_outlet (); + while (t && t->get_parent_context ()) + t = t->get_parent_context (); + + string name = ly_scm2string (voice_name); + Context *voice = find_context_below (t, ly_symbol2scm ("Voice"), name); + + if (voice) + music_context_ = voice; + } + + if (lyrics_context_ && music_context_) + { + if (!made_association_) + { + made_association_ = true; + lyrics_context_->set_property ("associatedVoiceContext", + music_context_->self_scm ()); + } + } +} + +void +Lyric_combine_music_iterator::process (Moment mom) +{ + (void) mom; + find_voice (); + if (!music_context_) + return; + + if (!music_context_->get_parent_context ()) + { + /* + The melody has died. + We die too. + */ + if (lyrics_context_) + lyrics_context_->unset_property (ly_symbol2scm ("associatedVoiceContext")); + lyric_iter_ = 0; + music_context_ = 0; + } + + if (music_context_ + && (start_new_syllable () || pending_grace_lyric_) + && lyric_iter_->ok ()) + { + if (music_context_->now_mom ().grace_part_) + { + pending_grace_lyric_ = true; + return; + } + else + pending_grace_lyric_ = false; + + Moment m = lyric_iter_->pending_moment (); + lyric_iter_->process (m); + + music_found_ = true; + } +} + +void +Lyric_combine_music_iterator::do_quit () +{ + if (!music_found_) + { + SCM voice_name = get_music ()->get_property ("associated-context"); + + string name; + if (scm_is_string (voice_name)) + name = ly_scm2string (voice_name); + + get_music ()->origin ()->warning (_f ("cannot find Voice `%s'", + name.c_str ()) + "\n"); + } + + if (lyric_iter_) + lyric_iter_->quit (); +} + +Music_iterator * +Lyric_combine_music_iterator::try_music_in_children (Music *m) const +{ + return lyric_iter_->try_music (m); +} + +IMPLEMENT_CTOR_CALLBACK (Lyric_combine_music_iterator); diff --git a/lily/new-lyric-combine-music-iterator.cc b/lily/new-lyric-combine-music-iterator.cc deleted file mode 100644 index 6e75f43d51..0000000000 --- a/lily/new-lyric-combine-music-iterator.cc +++ /dev/null @@ -1,258 +0,0 @@ -/* - new-lyric-combine-iterator.cc -- implement Lyric_combine_music_iterator - - source file of the GNU LilyPond music typesetter - - (c) 2004--2006 Han-Wen Nienhuys -*/ - -#include "context.hh" -#include "grob.hh" -#include "input.hh" -#include "international.hh" -#include "music-iterator.hh" -#include "music.hh" - -class Lyric_combine_music_iterator : public Music_iterator -{ -public: - Lyric_combine_music_iterator (); - Lyric_combine_music_iterator (Lyric_combine_music_iterator const &src); - DECLARE_SCHEME_CALLBACK (constructor, ()); -protected: - virtual void construct_children (); - virtual Moment pending_moment () const; - virtual void do_quit (); - virtual void process (Moment); - virtual Music_iterator *try_music_in_children (Music *) const; - virtual bool run_always ()const; - virtual bool ok () const; - virtual void derived_mark () const; - virtual void derived_substitute (Context *, Context *); -private: - bool start_new_syllable (); - void find_voice (); - - bool music_found_; - bool made_association_; - Context *lyrics_context_; - Context *music_context_; - SCM lyricsto_voice_name_; - - Music_iterator *lyric_iter_; -}; - -/* - Ugh, why static? -*/ -static Music *busy_ev; -static Music *start_ev; -static Music *melisma_playing_ev; - -Lyric_combine_music_iterator::Lyric_combine_music_iterator () -{ - music_found_ = false; - made_association_ = false; - lyric_iter_ = 0; - music_context_ = 0; - lyrics_context_ = 0; - - /* - Ugh. out of place here. - */ - if (!busy_ev) - { - busy_ev - = make_music_by_name (ly_symbol2scm ("BusyPlayingEvent")); - start_ev - = make_music_by_name (ly_symbol2scm ("StartPlayingEvent")); - melisma_playing_ev - = make_music_by_name (ly_symbol2scm ("MelismaPlayingEvent")); - } -} - -bool -Lyric_combine_music_iterator::start_new_syllable () -{ - bool b = music_context_->try_music (busy_ev); - - if (!b) - return false; - - if (!lyrics_context_) - return false; - - if (!to_boolean (lyrics_context_->get_property ("ignoreMelismata"))) - { - bool m = music_context_->try_music (melisma_playing_ev); - if (m) - return false; - } - - return true; -} - -Moment -Lyric_combine_music_iterator::pending_moment () const -{ - Moment m; - - m.set_infinite (1); - - return m; -} - -bool -Lyric_combine_music_iterator::run_always () const -{ - return true; -} - -bool -Lyric_combine_music_iterator::ok () const -{ - return lyric_iter_ && lyric_iter_->ok (); -} - -void -Lyric_combine_music_iterator::derived_mark ()const -{ - if (lyric_iter_) - scm_gc_mark (lyric_iter_->self_scm ()); - if (lyrics_context_) - scm_gc_mark (lyrics_context_->self_scm ()); - if (music_context_) - scm_gc_mark (music_context_->self_scm ()); -} - -void -Lyric_combine_music_iterator::derived_substitute (Context *f, Context *t) -{ - if (lyric_iter_) - lyric_iter_->substitute_outlet (f, t); - if (lyrics_context_ && lyrics_context_ == f) - lyrics_context_ = t; - if (music_context_ && music_context_ == f) - music_context_ = t; -} - -void -Lyric_combine_music_iterator::construct_children () -{ - Music *m = unsmob_music (get_music ()->get_property ("element")); - lyric_iter_ = unsmob_iterator (get_iterator (m)); - - lyricsto_voice_name_ = get_music ()->get_property ("associated-context"); - - find_voice (); - - if (lyric_iter_) - lyrics_context_ = find_context_below (lyric_iter_->get_outlet (), - ly_symbol2scm ("Lyrics"), ""); - - /* - We do not create a Lyrics context, because the user might - create one with a different name, and then we will not find that - one. - */ -} - -void -Lyric_combine_music_iterator::find_voice () -{ - SCM voice_name = lyricsto_voice_name_; - SCM running = lyrics_context_ - ? lyrics_context_->get_property ("associatedVoice") - : SCM_EOL; - - if (scm_is_string (running)) - voice_name = running; - - if (scm_is_string (voice_name) - && (!music_context_ || ly_scm2string (voice_name) != music_context_->id_string ())) - { - /* - (spaghettini). - - Need to set associatedVoiceContext again - */ - if (music_context_) - made_association_ = false; - - Context *t = get_outlet (); - while (t && t->get_parent_context ()) - t = t->get_parent_context (); - - string name = ly_scm2string (voice_name); - Context *voice = find_context_below (t, ly_symbol2scm ("Voice"), name); - - if (voice) - music_context_ = voice; - } - - if (lyrics_context_ && music_context_) - { - if (!made_association_) - { - made_association_ = true; - lyrics_context_->set_property ("associatedVoiceContext", - music_context_->self_scm ()); - } - } -} - -void -Lyric_combine_music_iterator::process (Moment) -{ - find_voice (); - if (!music_context_) - return; - - if (!music_context_->get_parent_context ()) - { - /* - The melody has died. - We die too. - */ - if (lyrics_context_) - lyrics_context_->unset_property (ly_symbol2scm ("associatedVoiceContext")); - lyric_iter_ = 0; - music_context_ = 0; - } - - if (music_context_ - && start_new_syllable () && lyric_iter_->ok ()) - { - Moment m = lyric_iter_->pending_moment (); - lyric_iter_->process (m); - - music_found_ = true; - } -} - -void -Lyric_combine_music_iterator::do_quit () -{ - if (!music_found_) - { - SCM voice_name = get_music ()->get_property ("associated-context"); - - string name; - if (scm_is_string (voice_name)) - name = ly_scm2string (voice_name); - - get_music ()->origin ()->warning (_f ("cannot find Voice `%s'", - name.c_str ()) + "\n"); - } - - if (lyric_iter_) - lyric_iter_->quit (); -} - -Music_iterator * -Lyric_combine_music_iterator::try_music_in_children (Music *m) const -{ - return lyric_iter_->try_music (m); -} - -IMPLEMENT_CTOR_CALLBACK (Lyric_combine_music_iterator); diff --git a/stepmake/aclocal.m4 b/stepmake/aclocal.m4 index b51d087712..3718904ceb 100644 --- a/stepmake/aclocal.m4 +++ b/stepmake/aclocal.m4 @@ -450,7 +450,7 @@ using namespace std; EOF FLEXLEXER_FILE=`$CXX -E conftest.cc | \ sed 's!# 1 "\(.*FlexLexer.h\)"!@FLEXLEXER@\1@@!g' | grep '@@' | \ - sed 's!.*@FLEXLEXER@\(.*\)@@.*$!\1!g' ` >& /dev/null + sed 's!.*@FLEXLEXER@\(.*\)@@.*$!\1!g' ` 1> /dev/null 2> /dev/null rm conftest.cc AC_SUBST(FLEXLEXER_FILE) AC_MSG_RESULT($FLEXLEXER_FILE) @@ -1256,11 +1256,11 @@ AC_DEFUN(STEPMAKE_WINDOWS, [ AC_CYGWIN AC_MINGW32 - if test "$CYGWIN" == "yes"; then + if test "$CYGWIN" = "yes"; then LN_S='cp -r' # Cygwin symbolic links do not work for native apps. program_suffix=.exe INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c" - elif test "$MINGW32" == "yes"; then + elif test "$MINGW32" = "yes"; then LN='cp -r' LN_S='cp -r' program_suffix=.exe @@ -1277,7 +1277,7 @@ AC_DEFUN(STEPMAKE_WINDOWS, [ AC_SUBST(program_suffix) AC_MSG_CHECKING([for some flavor of Windows]) - if test "$CYGWIN$MINGW32" == "nono"; then + if test "$CYGWIN$MINGW32" = "nono"; then PLATFORM_WINDOWS=no else PLATFORM_WINDOWS=yes