From 743de3ae4dbf1841b8cc0ab72e76a9c6168b041a Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 23:55:06 +0000 Subject: [PATCH] lilypond-1.3.82 --- .../ntweb/guile-1.4-gnu-windows.patch | 85 ++++ aclocal.m4 | 6 +- buildscripts/pmx2ly.py | 25 ++ input/bugs/slur-steep-broken.ly | 9 + input/test/pushproperty.ly | 22 +- input/trip.ly | 2 + lily/audio-element-info.cc | 16 +- lily/auto-change-iterator.cc | 2 +- lily/axis-group-interface.cc | 8 +- lily/bar-engraver.cc | 2 +- lily/bar-number-engraver.cc | 22 +- lily/break-align-engraver.cc | 7 + lily/change-iterator.cc | 2 +- lily/clef-engraver.cc | 26 +- lily/engraver-group-engraver.cc | 33 +- lily/grace-engraver-group.cc | 6 - lily/grace-performer-group.cc | 7 +- lily/identifier.cc | 8 +- lily/include/audio-element-info.hh | 2 +- lily/include/grace-engraver-group.hh | 1 - lily/include/grace-performer-group.hh | 1 - lily/include/identifier.hh | 3 - lily/include/lyric-phrasing-engraver.hh | 2 +- lily/include/translation-property.hh | 6 + lily/include/translator-group.hh | 48 ++- lily/include/translator.hh | 23 +- lily/key-engraver.cc | 10 +- lily/lexer.ll | 5 +- lily/lyric-phrasing-engraver.cc | 274 +------------ lily/mark-engraver.cc | 18 +- lily/music-output-def.cc | 9 +- lily/parser.yy | 30 +- lily/part-combine-music-iterator.cc | 2 +- lily/performer-group-performer.cc | 52 ++- lily/performer.cc | 3 +- lily/piano-pedal-engraver.cc | 11 +- lily/property-engraver.cc | 11 +- lily/property-iterator.cc | 35 +- lily/repeat-engraver.cc | 2 +- lily/score-element.cc | 5 +- lily/score-performer.cc | 2 +- lily/score.cc | 3 +- lily/syllable-group.cc | 268 +++++++++++++ lily/translator-group.cc | 373 +++++++++--------- lily/translator.cc | 101 ++++- lily/voice-devnull-engraver.cc | 33 +- scm/chord-names.scm | 8 +- scm/generic-property.scm | 2 +- scm/lily.scm | 8 +- scripts/abc2ly.py | 5 +- stepmake/aclocal.m4 | 8 +- 51 files changed, 958 insertions(+), 694 deletions(-) create mode 100644 Documentation/ntweb/guile-1.4-gnu-windows.patch create mode 100644 buildscripts/pmx2ly.py create mode 100644 input/bugs/slur-steep-broken.ly create mode 100644 lily/syllable-group.cc diff --git a/Documentation/ntweb/guile-1.4-gnu-windows.patch b/Documentation/ntweb/guile-1.4-gnu-windows.patch new file mode 100644 index 0000000000..4dd55d3205 --- /dev/null +++ b/Documentation/ntweb/guile-1.4-gnu-windows.patch @@ -0,0 +1,85 @@ +diff -urN ../guile-1.4/ChangeLog ./ChangeLog +--- ../guile-1.4/ChangeLog Fri Jun 2 15:17:01 2000 ++++ ./ChangeLog Mon Jun 5 15:18:32 2000 +@@ -1,3 +1,12 @@ ++2000-06-05 ++ ++ * guile-config/cross-guile-config.in: Simple shell script to ++ take over guile-config's functionality for cross-compilation. ++ It will be installed as ${target}-guile-config. ++ ++ * guile-config/Makefile.am: Provide for cross-guile-config.in ++ and its targets. ++ + 2000-06-21 Mikael Djurfeldt + + * Guile 1.4 released. +diff -urN ../guile-1.4/configure.in ./configure.in +--- ../guile-1.4/configure.in Fri Jun 2 08:44:27 2000 ++++ ./configure.in Mon Jun 5 15:13:58 2000 +@@ -21,6 +21,7 @@ + dnl Boston, MA 02111-1307, USA. + + AC_INIT(Makefile.in) ++AC_CANONICAL_SYSTEM + . $srcdir/GUILE-VERSION + AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define) + AM_MAINTAINER_MODE +diff -urN ../guile-1.4/guile-config/Makefile.am ./guile-config/Makefile.am +--- ../guile-1.4/guile-config/Makefile.am Wed Jan 12 22:42:41 2000 ++++ ./guile-config/Makefile.am Mon Jun 5 15:17:37 2000 +@@ -20,9 +20,9 @@ + ## to the Free Software Foundation, Inc., 59 Temple Place, Suite + ## 330, Boston, MA 02111-1307 USA + +-bin_SCRIPTS=guile-config +-CLEANFILES=guile-config +-EXTRA_DIST=guile-config.in guile.m4 ++bin_SCRIPTS=guile-config @target@-guile-config ++CLEANFILES=guile-config @target@-guile-config ++EXTRA_DIST=guile-config.in guile.m4 cross-guile-config.in + + ## FIXME: in the future there will be direct automake support for + ## doing this. When that happens, switch over. +@@ -39,6 +39,21 @@ + -e s:@-GUILE_VERSION-@:${GUILE_VERSION}: + chmod +x guile-config.tmp + mv guile-config.tmp guile-config ++ ++LDFLAGS=@LDFLAGS@ ++CFLAGS=@CFLAGS@ ++CPPFLAGS=@CPPFLAGS@ ++ ++@target@-guile-config: cross-guile-config.in ++ rm -f $<.tmp ++ sed < ${srcdir}/$< > $<.tmp \ ++ -e s:@-SHELL-@:${SHELL}: \ ++ -e s:@-GUILE_VERSION-@:${GUILE_VERSION}:\ ++ -e s:@-PREFIX-@:${prefix}: \ ++ -e "s:@-CPPFLAGS-@:${CPPFLAGS}:" \ ++ -e "s:@-LDFLAGS-@:${LDFLAGS}:" ++ chmod +x $<.tmp ++ mv $<.tmp $@ + + ## Get rid of any copies of the configuration script under the old + ## name, so people don't end up running ancient copies of it. +diff -urN ../guile-1.4/guile-config/cross-guile-config.in ./guile-config/cross-guile-config.in +--- ../guile-1.4/guile-config/cross-guile-config.in Thu Jan 1 01:00:00 1970 ++++ ./guile-config/cross-guile-config.in Mon Jun 5 15:13:58 2000 +@@ -0,0 +1,16 @@ ++#!@-SHELL-@ ++# target-guile-config.in ++case $1 in ++ --version) ++ echo "@-GUILE_VERSION-@" ++ exit 0 ++ ;; ++ compile) ++ echo "@-CPPFLAGS-@ -I @-PREFIX-@/include/guile" ++ exit 0 ++ ;; ++ link) ++ echo "-L @-PREFIX-@/lib -lguile @-LDFLAGS-@" ++ exit 0 ++ ;; ++esac diff --git a/aclocal.m4 b/aclocal.m4 index 122038c7f7..d1220794a6 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -648,20 +648,24 @@ AC_DEFUN(AC_STEPMAKE_TEXMF, [ break; fi done + AC_MSG_RESULT($MFMODE) + AC_MSG_CHECKING(for mfplain.mp) # # For now let people define these in their environments # : ${MFPLAIN_MP=`kpsewhich mp mfplain.mp`} + AC_MSG_RESULT($MFPLAIN_MP) + AC_MSG_CHECKING(for inimetapost flags) if test ${INIMETAPOST} = "inimp" ; then : ${INIMETAPOST_FLAGS=''} else : ${INIMETAPOST_FLAGS='-interaction=nonstopmode'} fi + AC_MSG_RESULT($INIMETAPOST_FLAGS) rm -f mfput.* - AC_MSG_RESULT($MFMODE) AC_SUBST(METAFONT) AC_SUBST(METAPOST) diff --git a/buildscripts/pmx2ly.py b/buildscripts/pmx2ly.py new file mode 100644 index 0000000000..58d32cb4bb --- /dev/null +++ b/buildscripts/pmx2ly.py @@ -0,0 +1,25 @@ +#!@PYTHON@ +import string + +ls = open ('barsant.pmx').readlines () +def stripcomment (l): + return re.sub ('^%.*$', '', l) + +ls = map (stripcomment, ls) +ls = filter (lambda x: x <> '', ls) + +opening = ls[0] +ls = ls[1:] + +opening = map (string.atoi, re.split ('[\t ]+', opening)) +(nv,noinst,mtrnuml,mtrdenl,mtrnump,mtrdenp,xmtrnum0,isig) = tuple (opening) + + +opening = ls[0] +ls = ls[1:] +opening = map (string.atoi, re.split ('[\t ]+', opening)) +(npages,nsyst,musicsize,fracindent) = tuple (opening) + +for l in ls: + pass + diff --git a/input/bugs/slur-steep-broken.ly b/input/bugs/slur-steep-broken.ly new file mode 100644 index 0000000000..f5f495e700 --- /dev/null +++ b/input/bugs/slur-steep-broken.ly @@ -0,0 +1,9 @@ +\score{ + \notes\relative c''{ + \time 2/4; + [f8 e d f, (] | \break + [) a'8. gis16 fis8. cis16] | + } + \paper{linewidth = 3.0\cm;indent = .0;} +} + diff --git a/input/test/pushproperty.ly b/input/test/pushproperty.ly index 7ca018f9b9..0ab097c1a3 100644 --- a/input/test/pushproperty.ly +++ b/input/test/pushproperty.ly @@ -49,10 +49,6 @@ Incorrect (\popproperty costs memory): \popproperty #'( ... ) #'symbolA \popproperty #'( ... ) #'symbolB - - - - the syntax isn't likely to stay, so it is advisable to use identifiers, eg. @@ -64,15 +60,21 @@ use identifiers, eg. \score { \notes \relative c' { - c4( + c4-.( \context Voice \pushproperty #'(basicDotsProperties basicStemProperties basicNoteColumnProperties basicScriptProperties basicTextProperties) #'direction #-1 - ) c4 ( - ) c4 ( - \context Voice \pushproperty #'(basicSlurProperties) #'direction #-1 - ) c4 ( \context Voice \popproperty #'(basicDotsProperties basicStemProperties + ) c4-. ( + ) c4-. ( + \context Voice \pushproperty #'basicSlurProperties #'direction #-1 + ) c4-. ( \context Voice \popproperty #'(basicDotsProperties basicStemProperties basicScriptProperties basicTextProperties) #'direction - ) c4 () c4 + ) c4-. () c4-. +} + +\paper { +\translator { \VoiceContext + \pushproperty #'basicNoteHeadProperties #'font-size #-2 +} } } diff --git a/input/trip.ly b/input/trip.ly index 750a0f6eb7..ed3e877acd 100644 --- a/input/trip.ly +++ b/input/trip.ly @@ -15,6 +15,8 @@ TODO: * tremolo +* lyrics. + %} \version "1.3.59"; diff --git a/lily/audio-element-info.cc b/lily/audio-element-info.cc index 5580b6f0b8..c9f99c7732 100644 --- a/lily/audio-element-info.cc +++ b/lily/audio-element-info.cc @@ -7,11 +7,12 @@ */ #include "audio-element-info.hh" -#include "request.hh" +#include "translator-group.hh" Audio_element_info::Audio_element_info (Audio_element*s_l, Music *r_l) { elem_l_ = s_l; + origin_trans_l_ =0; req_l_ = r_l; } @@ -20,10 +21,19 @@ Audio_element_info::Audio_element_info() { elem_l_ = 0; req_l_ = 0; + origin_trans_l_ =0; } + Link_array -Audio_element_info::origin_trans_l_arr (Translator*) const +Audio_element_info::origin_trans_l_arr (Translator* end) const { - return origin_trans_l_arr_; + Translator * t = origin_trans_l_; + Link_array r; + do { + r.push (t); + t = t->daddy_trans_l_; + } while (t && t != end->daddy_trans_l_); + + return r; } diff --git a/lily/auto-change-iterator.cc b/lily/auto-change-iterator.cc index 2c9de1f717..0ae3021d46 100644 --- a/lily/auto-change-iterator.cc +++ b/lily/auto-change-iterator.cc @@ -49,7 +49,7 @@ Auto_change_iterator::change_to (Music_iterator *it, String to_type, Translator_group * dest = it->report_to_l ()->find_create_translator_l (to_type, to_id); current->remove_translator_p (last); - dest->add_translator (last); + dest->add_group_translator (last); } else { diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index a156379adb..4d7db9b452 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -77,11 +77,11 @@ Axis_group_interface::set_axes (Score_element*me,Axis a1, Axis a2) SCM sa1= gh_int2scm (a1); SCM sa2 = gh_int2scm (a2); - SCM prop = me->get_elt_property ("axes"); + SCM axes = me->get_elt_property ("axes"); - if (!gh_pair_p (prop) - || scm_memq (sa1, prop) == SCM_BOOL_F - || scm_memq (sa2, prop) == SCM_BOOL_F) + if (!gh_pair_p (axes) + || scm_memq (sa1, axes) == SCM_BOOL_F + || scm_memq (sa2, axes) == SCM_BOOL_F) { SCM ax = gh_cons (sa1, SCM_EOL); if (a1 != a2) diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index dfa4d906fa..bbb1af8238 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -90,7 +90,7 @@ Bar_engraver::do_removal_processing () void Bar_engraver::do_process_music() { - Translator * t = daddy_grav_l ()->get_simple_translator ("Timing_engraver"); + Translator * t = daddy_grav_l ()->get_simple_translator ("Timing_engraver"); // UGH.! Timing_engraver * te = dynamic_cast(t); String which = (te) ? te->which_bar () : ""; diff --git a/lily/bar-number-engraver.cc b/lily/bar-number-engraver.cc index 34a0cb2eae..4fe7d7172f 100644 --- a/lily/bar-number-engraver.cc +++ b/lily/bar-number-engraver.cc @@ -15,18 +15,18 @@ #include "item.hh" #include "moment.hh" #include "engraver.hh" -#include "protected-scm.hh" +#include "translator-group.hh" + class Bar_number_engraver : public Engraver { protected: Item* text_p_; - Protected_scm staffs_; - protected: virtual void do_pre_move_processing (); virtual void acknowledge_element (Score_element_info); + virtual void do_creation_processing (); void create_items(); void do_process_music (); public: @@ -58,9 +58,16 @@ ADD_THIS_TRANSLATOR(Bar_number_engraver); Bar_number_engraver::Bar_number_engraver () { text_p_ =0; - staffs_ = SCM_EOL; } +void +Bar_number_engraver::do_creation_processing () +{ + /* + ugh: need to share code with mark_engraver + */ + daddy_trans_l_->set_property ("staffsFound", SCM_EOL); +} @@ -70,7 +77,10 @@ Bar_number_engraver::acknowledge_element (Score_element_info inf) Score_element * s = inf.elem_l_; if (Staff_symbol::has_interface (s)) { - staffs_ = gh_cons (inf.elem_l_->self_scm (), staffs_); + SCM sts = get_property ("staffsFound"); + SCM thisstaff = inf.elem_l_->self_scm (); + if (scm_memq (thisstaff, sts) == SCM_BOOL_F) + daddy_trans_l_->set_property ("staffsFound", gh_cons (thisstaff, sts)); } else if (text_p_ && dynamic_cast (s) @@ -88,7 +98,7 @@ Bar_number_engraver::do_pre_move_processing () { if (text_p_) { - text_p_->set_elt_property ("side-support-elements", staffs_); + text_p_->set_elt_property ("side-support-elements", get_property ("staffsFound")); typeset_element (text_p_); text_p_ =0; } diff --git a/lily/break-align-engraver.cc b/lily/break-align-engraver.cc index b48f31b25a..aa3bc9760c 100644 --- a/lily/break-align-engraver.cc +++ b/lily/break-align-engraver.cc @@ -19,6 +19,7 @@ class Break_align_engraver : public Engraver Item *align_l_; Protected_scm column_alist_; protected: + virtual void do_removal_processing (); virtual void acknowledge_element(Score_element_info i); virtual void do_pre_move_processing (); void add_column (SCM); @@ -40,6 +41,12 @@ Break_align_engraver::add_column (SCM smob) typeset_element (e); } +void +Break_align_engraver::do_removal_processing () +{ + column_alist_ = SCM_EOL; +} + void Break_align_engraver::do_pre_move_processing () { diff --git a/lily/change-iterator.cc b/lily/change-iterator.cc index 08fdc53271..730e4adc8e 100644 --- a/lily/change-iterator.cc +++ b/lily/change-iterator.cc @@ -66,7 +66,7 @@ Change_iterator::do_process_and_next (Moment m) Translator_group * dest = report_to_l ()->find_create_translator_l (to_type, to_id); current->remove_translator_p (last); - dest->add_translator (last); + dest->add_group_translator (last); } else { diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index df8b2eb23f..d448e71648 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -11,6 +11,7 @@ #include +#include "translator-group.hh" #include "key-item.hh" #include "local-key-item.hh" #include "bar.hh" @@ -18,14 +19,14 @@ #include "staff-symbol-referencer.hh" #include "debug.hh" #include "command-request.hh" -#include "array.hh" #include "engraver.hh" #include "direction.hh" #include "side-position-interface.hh" #include "item.hh" /// where is c-0 in the staff? -class Clef_engraver : public Engraver { +class Clef_engraver : public Engraver +{ Item * clef_p_; Item * octavate_p_; Clef_change_req * clef_req_l_; @@ -50,15 +51,11 @@ public: Clef_engraver(); bool first_b_; - - Protected_scm current_settings_; }; Clef_engraver::Clef_engraver() { - current_settings_ = SCM_EOL; - first_b_ = true; clef_glyph_ = SCM_EOL; clef_p_ = 0; @@ -108,13 +105,14 @@ Clef_engraver::set_type (String s) c0_position_i_ -= (int) octave_dir_ * 7; - SCM basic = get_property ("basicClefItemProperties"); - current_settings_ = gh_cons (gh_cons (ly_symbol2scm ("glyph"), clef_glyph_), basic); - current_settings_ = - gh_cons (gh_cons (ly_symbol2scm ("c0-position"), - gh_int2scm (c0_position_i_)), - current_settings_); - + SCM basic = ly_symbol2scm ("basicClefItemProperties"); + SCM c0 = ly_symbol2scm ("c0-position"); + SCM gl = ly_symbol2scm ("glyph"); + daddy_trans_l_->execute_single_pushpop_property (basic, gl, SCM_UNDEFINED); + daddy_trans_l_->execute_single_pushpop_property (basic, c0, SCM_UNDEFINED); + daddy_trans_l_->execute_single_pushpop_property (basic, gl, clef_glyph_); + daddy_trans_l_->execute_single_pushpop_property (basic, c0, gh_int2scm (c0_position_i_)); + return true; } @@ -178,7 +176,7 @@ Clef_engraver::create_clef() { if (!clef_p_) { - Item *c= new Item ( current_settings_); + Item *c= new Item (get_property ("basicClefItemProperties")); announce_element (c, clef_req_l_); Staff_symbol_referencer::set_interface (c); diff --git a/lily/engraver-group-engraver.cc b/lily/engraver-group-engraver.cc index c12283e8e4..847bb5d13e 100644 --- a/lily/engraver-group-engraver.cc +++ b/lily/engraver-group-engraver.cc @@ -27,38 +27,33 @@ Engraver_group_engraver::announce_element (Score_element_info info) void Engraver_group_engraver::do_announces() { - for (Cons *p = trans_p_list_.head_; p; p = p->next_) + for (SCM p = trans_group_list_; gh_pair_p (p); p =gh_cdr ( p)) { - if (Engraver_group_engraver *trg = dynamic_cast (p->car_)) - trg->do_announces (); + Translator * t = unsmob_translator (gh_car (p)); + dynamic_cast (t)->do_announces (); } - + while (announce_info_arr_.size ()) { for (int j =0; j < announce_info_arr_.size(); j++) { Score_element_info info = announce_info_arr_[j]; - for (Cons *p = trans_p_list_.head_; p; p = p->next_) + for (SCM p = simple_trans_list_; gh_pair_p (p); p = gh_cdr (p)) { - if (!dynamic_cast (p->car_)) - { - Engraver * eng = dynamic_cast (p->car_); - if (eng && eng!= info.origin_trans_l_arr (this)[0]) - eng->acknowledge_element (info); - } + Translator * t = unsmob_translator (gh_car (p)); + Engraver * eng = dynamic_cast (t); + if (eng && eng!= info.origin_trans_l_) + eng->acknowledge_element (info); } } - announce_info_arr_.clear (); - for (Cons *p = trans_p_list_.head_; p; p = p->next_) + for (SCM p = simple_trans_list_; gh_pair_p (p); p = gh_cdr ( p)) { - if (!dynamic_cast (p->car_)) - { - Engraver * eng = dynamic_cast (p->car_); - if (eng) - eng->process_acknowledged (); - } + Translator * t = unsmob_translator (gh_car (p)); + Engraver * eng = dynamic_cast (t); + if (eng) + eng->process_acknowledged (); } } } diff --git a/lily/grace-engraver-group.cc b/lily/grace-engraver-group.cc index f7b66a62c3..ae3a2f5a3e 100644 --- a/lily/grace-engraver-group.cc +++ b/lily/grace-engraver-group.cc @@ -85,12 +85,6 @@ Grace_engraver_group::each (Method_pointer method) } -void -Grace_engraver_group::each (Const_method_pointer method) const -{ - if (calling_self_b_) - Engraver_group_engraver::each (method); -} ADD_THIS_TRANSLATOR(Grace_engraver_group); diff --git a/lily/grace-performer-group.cc b/lily/grace-performer-group.cc index fcfad2a339..4bf89fe1da 100644 --- a/lily/grace-performer-group.cc +++ b/lily/grace-performer-group.cc @@ -87,12 +87,7 @@ Grace_performer_group::each (Method_pointer method) } -void -Grace_performer_group::each (Const_method_pointer method) const -{ - if (calling_self_b_) - Performer_group_performer::each (method); -} + /* don't let the commands trickle up. diff --git a/lily/identifier.cc b/lily/identifier.cc index d3d0e7221b..bedc2f9dfd 100644 --- a/lily/identifier.cc +++ b/lily/identifier.cc @@ -11,12 +11,12 @@ JUNKTHIS! */ #include + #include "music-output-def.hh" #include "score.hh" #include "identifier.hh" #include "my-lily-lexer.hh" #include "debug.hh" -#include "translator-group.hh" #include "ly-smobs.icc" @@ -81,8 +81,6 @@ Class ## _identifier::do_print () const { \ } - -DEFAULT_PRINT(Translator_group); DEFAULT_PRINT(Score); DEFAULT_PRINT(Music_output_def); @@ -93,8 +91,6 @@ Class ## _identifier::do_str () const { \ return String (#Class); \ } - -DUMMY_STR(Translator_group); DUMMY_STR(Score); DUMMY_STR(Music_output_def); DUMMY_STR(Duration); @@ -151,10 +147,8 @@ Class ## _identifier::Class ## _identifier (Class ## _identifier const &s) \ IMPLEMENT_ID_CLASS(Duration); -IMPLEMENT_ID_CLASS(Translator_group); IMPLEMENT_ID_CLASS(Score); IMPLEMENT_ID_CLASS(Music_output_def); -VIRTUAL_ACCESSOR(Translator_group); VIRTUAL_ACCESSOR(Music_output_def); DEFAULT_ACCESSOR(Duration); DEFAULT_ACCESSOR(Score); diff --git a/lily/include/audio-element-info.hh b/lily/include/audio-element-info.hh index 2d09970ab4..b3b805ca07 100644 --- a/lily/include/audio-element-info.hh +++ b/lily/include/audio-element-info.hh @@ -19,7 +19,7 @@ struct Audio_element_info { Audio_element * elem_l_; Music *req_l_; - Link_array origin_trans_l_arr_; + Translator * origin_trans_l_; Link_array origin_trans_l_arr (Translator*) const; Audio_element_info (Audio_element*, Music*); diff --git a/lily/include/grace-engraver-group.hh b/lily/include/grace-engraver-group.hh index 5c63b4fd2a..2ba5768a67 100644 --- a/lily/include/grace-engraver-group.hh +++ b/lily/include/grace-engraver-group.hh @@ -28,7 +28,6 @@ protected: virtual void finish (); virtual void process (); virtual void each (Method_pointer); - virtual void each (Const_method_pointer) const; virtual void do_removal_processing () ; virtual void typeset_element (Score_element*); virtual bool do_try_music (Music *m); diff --git a/lily/include/grace-performer-group.hh b/lily/include/grace-performer-group.hh index cfeb9884a0..5b05625b09 100644 --- a/lily/include/grace-performer-group.hh +++ b/lily/include/grace-performer-group.hh @@ -27,7 +27,6 @@ protected: virtual void finish (); virtual void process (); virtual void each (Method_pointer); - virtual void each (Const_method_pointer) const; virtual void do_removal_processing () ; virtual void play_element (Audio_element*); virtual bool do_try_music (Music *m); diff --git a/lily/include/identifier.hh b/lily/include/identifier.hh index 02587ce978..2e39b1ff47 100644 --- a/lily/include/identifier.hh +++ b/lily/include/identifier.hh @@ -15,7 +15,6 @@ #include "smobs.hh" -class Translator_group_identifier; class Output_def_identifier; class Score_identifier; class Duration_identifier; @@ -43,7 +42,6 @@ struct Identifier : public Input { void error (String) const; String str () const; - IDACCESSOR(Translator_group) IDACCESSOR(Music_output_def) IDACCESSOR(Score) IDACCESSOR(Duration) @@ -69,7 +67,6 @@ struct Class ## _identifier : Identifier {\ }\ -DECLARE_ID_CLASS(Translator_group); DECLARE_ID_CLASS(Duration); DECLARE_ID_CLASS(Score); DECLARE_ID_CLASS(Music_output_def); diff --git a/lily/include/lyric-phrasing-engraver.hh b/lily/include/lyric-phrasing-engraver.hh index e00a1c159c..cda6f6584a 100644 --- a/lily/include/lyric-phrasing-engraver.hh +++ b/lily/include/lyric-phrasing-engraver.hh @@ -66,7 +66,7 @@ protected: virtual void acknowledge_element(Score_element_info); virtual void process_acknowledged (); virtual void do_pre_move_processing(); - + virtual void do_removal_processing (); private: void record_notehead(const String &context_id, Score_element * notehead); void record_lyric(const String &context_id, Score_element * lyric); diff --git a/lily/include/translation-property.hh b/lily/include/translation-property.hh index 0b887470fc..c8a4950783 100644 --- a/lily/include/translation-property.hh +++ b/lily/include/translation-property.hh @@ -39,6 +39,7 @@ public: class Push_translation_property : public Music { public: + VIRTUAL_COPY_CONS(Music); }; /** @@ -51,7 +52,12 @@ public: class Pop_translation_property : public Music { public: + VIRTUAL_COPY_CONS(Music); }; +void apply_push_property (Translator_group*trans, SCM syms, SCM eprop, SCM val); +void apply_pop_property (Translator_group*trans, SCM syms, SCM eprop); + + #endif // PROPERTY_HH diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 5bb0d08e28..126c232c8d 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -14,46 +14,58 @@ #include "lily-proto.hh" #include "virtual-methods.hh" #include "translator.hh" -#include "cons.hh" #include "parray.hh" - +#include "smobs.hh" // egcs typedef void (Translator::*Method_pointer)(void); -typedef void (Translator::*Const_method_pointer)(void) const; + class Scheme_hash_table; + +/* + should make a struct out of this, and move SCM list stuff in here. + */ +struct Translator_group_initializer { + static SCM modify_definition (SCM, SCM, bool); + + static void set_acceptor (Translator*,SCM accepts, bool add); + static void add_element (Translator*,SCM name); + static void remove_element (Translator*,SCM name); + static void add_last_element (Translator*,SCM name); + static void apply_pushpop_property (Translator*trans, SCM syms, SCM eprop, SCM val); + static void add_push_property (Translator*, SCM,SCM,SCM); + static void add_pop_property (Translator*, SCM,SCM); + +}; + /** Make some kind of Elements from Requests. Elements are made by hierarchically grouped Translators */ class Translator_group : public virtual Translator { - Array consists_str_arr_; - Array accepts_str_arr_; - Array consists_end_str_arr_; - Scheme_hash_table *properties_dict_; + Scheme_hash_table *properties_dict () const; int iterator_count_; - friend class Interpretation_context_handle; -protected: - Cons_list trans_p_list_; + friend class Interpretation_context_handle; +protected: + ~Translator_group (); public: + SCM add_translator (SCM, Translator*); + void execute_single_pushpop_property (SCM prop, SCM sym, SCM val); SCM get_property (SCM name_sym) const; void set_property (String var_name, SCM value); void set_property (SCM var_sym, SCM value); Translator_group *where_defined (SCM name_sym) const; String id_str_; - void add_last_element (String s); VIRTUAL_COPY_CONS(Translator); - - void set_acceptor (String accepts, bool add); - void set_element (String elt, bool add); - Translator_group(Translator_group const &); Translator_group(); - void add_translator (Translator *trans_p); + void add_simple_translator (Translator *trans_p); + void add_group_translator (Translator *trans_p); + /// Score_register = 0, Staff_registers = 1, etc) Translator_group* ancestor_l (int l=1); @@ -63,14 +75,12 @@ public: void terminate_translator (Translator*r_l); Translator *remove_translator_p (Translator*trans_l); void check_removal (); - Translator *get_simple_translator (String) const; Translator_group *find_existing_translator_l (String n, String id); Translator_group *find_create_translator_l (String n, String id); Link_array path_to_acceptable_translator (String alias, Music_output_def*) const; Translator_group*get_default_interpreter(); - virtual ~Translator_group (); protected: bool try_music_on_nongroup_children (Music *m); @@ -84,7 +94,7 @@ protected: virtual void do_creation_processing(); virtual void do_removal_processing(); virtual void each (Method_pointer); - virtual void each (Const_method_pointer) const; + }; #endif // TRANSLATOR_GROUP_HH diff --git a/lily/include/translator.hh b/lily/include/translator.hh index a40fd07275..2cca991105 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -17,12 +17,13 @@ #include "lily-guile.hh" #include "parray.hh" #include "input.hh" - +#include "smobs.hh" /** Make some kind of #Element#s from Requests. Elements are made by hierarchically grouped #Translator#s */ class Translator : public Input { + void init (); public: Music_output_def * output_def_l_; String type_str_; @@ -33,7 +34,6 @@ public: VIRTUAL_COPY_CONS(Translator); Translator (Translator const &); Translator (); - virtual ~Translator (); Translator_group * daddy_trans_l_ ; @@ -65,7 +65,19 @@ public: virtual Moment now_mom () const; -protected: + /* + ugh: bubbled up from Translator_group. + */ + SCM consists_name_list_; + SCM end_consists_name_list_; + SCM accepts_name_list_; + SCM simple_trans_list_; + SCM trans_group_list_; + SCM properties_scm_; + SCM property_pushes_; + DECLARE_SMOBS(Translator, dummy); + +public: /* UGH. Clean this up. */ @@ -78,7 +90,8 @@ protected: PROCESSED_REQS, ACKED_REQS, MOVE_DONE - } status; + } status_; // junkme +protected: /* @see{try_request} @@ -112,5 +125,5 @@ extern Dictionary *global_translator_dict_p; void add_translator (Translator*trans_p); Translator*get_translator_l (String s); - +Translator *unsmob_translator (SCM); #endif // TRANSLATOR_HH diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index f19ddf1c1f..8fcae86fd2 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -22,7 +22,8 @@ /** Make the key signature. */ -class Key_engraver : public Engraver { +class Key_engraver : public Engraver +{ void create_key(bool); void read_req (Key_change_req const * r); @@ -37,6 +38,7 @@ public: protected: virtual void do_creation_processing(); + virtual void do_removal_processing (); virtual bool do_try_music (Music *req_l); virtual void do_process_music(); virtual void do_pre_move_processing(); @@ -45,6 +47,12 @@ protected: }; +void +Key_engraver::do_removal_processing () +{ + old_accs_ = SCM_EOL; // unprotect can be called from dtor. +} + Key_engraver::Key_engraver () { keyreq_l_ = 0; diff --git a/lily/lexer.ll b/lily/lexer.ll index 90f4ba43f4..09378ba961 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -39,7 +39,7 @@ #include "identifier.hh" #include "version.hh" #include "mudela-version.hh" - +#include "translator-group.hh" void strip_trailing_white (String&); void strip_leading_white (String&); @@ -477,6 +477,9 @@ My_lily_lexer::scan_escaped_word (String str) } else if (gh_number_p (sid)) { yylval.scm = sid; return NUMBER_IDENTIFIER; + } else if (Translator* tr = unsmob_translator (sid)) { + yylval.scm = sid; + return TRANSLATOR_IDENTIFIER; } else if (Music * mus =unsmob_music (sid)) { yylval.scm = sid; diff --git a/lily/lyric-phrasing-engraver.cc b/lily/lyric-phrasing-engraver.cc index c17f9ce515..5cc40bc936 100644 --- a/lily/lyric-phrasing-engraver.cc +++ b/lily/lyric-phrasing-engraver.cc @@ -10,10 +10,7 @@ #include "lyric-phrasing-engraver.hh" #include "note-head.hh" #include "translator-group.hh" -#include "side-position-interface.hh" -#include "ly-smobs.icc" #include "spanner.hh" -#include "paper-def.hh" String get_context_id(Translator_group * ancestor, const char * type); @@ -56,6 +53,17 @@ Lyric_phrasing_engraver::~Lyric_phrasing_engraver() */ } +void +Lyric_phrasing_engraver::do_removal_processing () +{ + /* + but do need to unprotect alist_, since Engravers are gc'd now. + */ + + voice_alist_ = SCM_EOL; +} + + Syllable_group * Lyric_phrasing_engraver::lookup_context_id(const String &context_id) { @@ -275,263 +283,3 @@ Lyric_phrasing_engraver::do_pre_move_processing () -/*=========================================================================================*/ - -/** Syllable_group is a class to be smobbed and entered as data in the association list - member of the Lyric_phrasing_engraver class. -*/ - -Syllable_group::Syllable_group() -{ - first_in_phrase_b_=true; - melisma_b_ = false; - clear(); -} - -void -Syllable_group::clear() -{ - notehead_l_=0; - lyric_list_.clear(); - longest_lyric_l_=0; - shortest_lyric_l_=0; - melisma_b_ = false; - group_translation_f_ = 0.0; -} - -void -Syllable_group::copy( Syllable_group *from) -{ - notehead_l_ = from->notehead_l_; - lyric_list_ = from->lyric_list_; - longest_lyric_l_ = from->longest_lyric_l_; - shortest_lyric_l_ = from->shortest_lyric_l_; - melisma_b_ = from->melisma_b_; - alignment_i_ = from->alignment_i_; - first_in_phrase_b_ = from->first_in_phrase_b_; - group_translation_f_ = from->group_translation_f_; -} - -void -Syllable_group::set_first_in_phrase(bool f) -{ - first_in_phrase_b_ = f; -} - -void -Syllable_group::set_notehead(Score_element * notehead) -{ - if(!notehead_l_) { - /* there should only be a single notehead, so silently ignore any extras */ - notehead_l_=notehead; - } -} - -void -Syllable_group::add_lyric(Score_element * lyric) -{ - lyric_list_.push(lyric); - /* record longest and shortest lyrics */ - if( longest_lyric_l_ ) { - if(lyric->extent(X_AXIS).length() > (longest_lyric_l_->extent(X_AXIS)).length()) - longest_lyric_l_ = lyric; - if(lyric->extent(X_AXIS).length() < (shortest_lyric_l_->extent(X_AXIS)).length()) - shortest_lyric_l_ = lyric; - } - else - longest_lyric_l_ = shortest_lyric_l_ = lyric; -} - -void -Syllable_group::add_extender(Score_element * extender) -{ - if(notehead_l_ && melisma_b_) { - dynamic_cast(extender)->set_bound (RIGHT, notehead_l_); - // should the extender finish at the right of the last note of the melisma, or the left? - // Comments in lyric-extender.hh say left, but right looks better to me. GP. - - // Left: -// extender->set_elt_property("right-trim-amount", gh_double2scm(0.0)); - - // Right: - Real ss = extender->paper_l ()->get_var ("staffspace"); - extender->set_elt_property("right-trim-amount", - gh_double2scm(-notehead_l_->extent(X_AXIS).length()/ss)); - } -} - -bool -Syllable_group::set_lyric_align(const char *punc, Score_element *default_notehead_l) -{ - if(lyric_list_.size()==0) { - // No lyrics: nothing to do. - return true; - } - - Score_element * lyric; - alignment_i_ = appropriate_alignment(punc); - - // If there was no notehead in the matching voice context, use the first - // notehead caught from any voice context (any port in a storm). - if(!notehead_l_) { - notehead_l_ = default_notehead_l; - } - - group_translation_f_ = amount_to_translate(); - - // set the x alignment of each lyric - for(int l = 0; l < lyric_list_.size(); l++) { - lyric = lyric_list_[l]; - lyric->set_elt_property("self-alignment-X", gh_int2scm(alignment_i_)); - // centre on notehead ... if we have one. - if(notehead_l_) { - lyric->set_parent(notehead_l_, X_AXIS); - lyric->add_offset_callback (Side_position::centered_on_parent, X_AXIS); - // reference is on the right of the notehead; move it left half way, and add translation - lyric->translate_axis (group_translation_f_-(notehead_l_->extent(X_AXIS)).center(), X_AXIS); - } - } - return (notehead_l_); -} - -/** determine the distance to translate lyrics to get correct alignment - Rules: If alignment is centre, translate = 0 - Otherwise, - If (length of longest lyric) < 2 * (length of shortest lyric), - - centre longest lyric on notehead - Otherwise - - move so shortest lyric just reaches notehead centre -*/ -Real -Syllable_group::amount_to_translate() -{ - Real translate = 0.0; - if(alignment_i_ != CENTER) { - // FIXME: do we really know the lyric extent here? Some font sizing comes later? - if((longest_lyric_l_->extent(X_AXIS)).length() < - (shortest_lyric_l_->extent(X_AXIS)).length() * 2 ) - translate = alignment_i_*(longest_lyric_l_->extent(X_AXIS)).length()/2; - else - translate = alignment_i_*(shortest_lyric_l_->extent(X_AXIS)).length(); - } - return translate; -} - - -/** determine what alignment we want. - Rules: if first_in_phrase_b_ is set, then alignment is LEFT. - otherwise if each syllable ends in punctuation, then alignment is RIGHT - otherwise alignment is centre. -*/ -int -Syllable_group::appropriate_alignment(const char *punc) -{ - if(first_in_phrase_b_) - return LEFT; - - Score_element * lyric; - bool end_phrase = true; - - for(int l = 0; l < lyric_list_.size() && end_phrase; l++) { - lyric = lyric_list_[l]; - SCM lyric_scm = lyric->get_elt_property("text"); - String lyric_str = gh_string_p(lyric_scm)?ly_scm2string(lyric_scm):""; - char lastchar; - if(lyric_str.length_i()>0) { - lastchar = lyric_str[lyric_str.length_i()-1]; - /* If it doesn't end in punctuation then it ain't an end of phrase */ - if(! strchr(punc, lastchar)) { - /* Special case: trailing space. Here examine the previous character and reverse the - sense of the test (i.e. trailing space makes a break without punctuation, or - suppresses a break with punctuation). - This behaviour can be suppressed by including a space in the - phrasingPunctuation property, in which case trailing space always means - the same as punctuation. - - FIXME: The extra space throws alignment out a bit. - */ - if(lastchar == ' ') { - if(lyric_str.length_i()>1) { - lastchar = lyric_str[lyric_str.length_i()-2]; - if(strchr(punc, lastchar)) - end_phrase=false; - } - } - else - end_phrase=false; - } - } - } - if(end_phrase) - return RIGHT; - - return CENTER; -} - -/** We don't know about the melisma until after the initial alignment work is done, so go - back and fix the alignment when we DO know. -*/ -void -Syllable_group::adjust_melisma_align() -{ - if(notehead_l_ && lyric_list_.size()) { - // override any previous offset adjustments - Real translation = -group_translation_f_; - // melisma aligning: - switch (alignment_i_) { - // case LEFT: // that's all - case CENTER: // move right so smallest lyric is left-aligned on notehead - translation += (shortest_lyric_l_->extent(X_AXIS)).length()/2; - break; - case RIGHT: // move right so smallest lyric is left-aligned on notehead - translation += (shortest_lyric_l_->extent(X_AXIS)).length(); - break; - } - group_translation_f_ += translation; - for(int l = 0; l < lyric_list_.size(); l++) { - lyric_list_[l]->translate_axis (translation, X_AXIS); - } - } -} - - -bool -Syllable_group::is_empty() -{ - return lyric_list_.size()==0; -} - -void -Syllable_group::next_lyric() -{ - first_in_phrase_b_ = (alignment_i_ == RIGHT); - clear(); -} - -/* SMOB */ - - - -SCM -Syllable_group::mark_smob (SCM) -{ - return SCM_EOL; -} - -int -Syllable_group::print_smob (SCM, SCM port, scm_print_state * ) -{ - scm_puts ("#", port); - return 1; -} - -IMPLEMENT_UNSMOB(Syllable_group, voice_entry); -IMPLEMENT_SIMPLE_SMOBS(Syllable_group); -IMPLEMENT_DEFAULT_EQUAL_P(Syllable_group); - -SCM -Syllable_group::make_entry () -{ - Syllable_group *vi = new Syllable_group; - return vi->smobbed_self (); -} diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc index b57bafa3e2..9ada64765f 100644 --- a/lily/mark-engraver.cc +++ b/lily/mark-engraver.cc @@ -15,7 +15,7 @@ #include "lily-guile.hh" #include "paper-column.hh" #include "paper-def.hh" -#include "protected-scm.hh" + #include "side-position-interface.hh" #include "staff-symbol-referencer.hh" #include "item.hh" @@ -32,7 +32,6 @@ public: Mark_engraver (); protected: Item* text_p_; - Protected_scm staffs_; protected: virtual void do_pre_move_processing (); @@ -41,6 +40,8 @@ protected: virtual bool do_try_music (Music *req_l); virtual void do_process_music (); virtual void do_post_move_processing (); + virtual void do_creation_processing (); + private: Mark_req * mark_req_l_; }; @@ -53,9 +54,13 @@ Mark_engraver::Mark_engraver () { text_p_ =0; mark_req_l_ = 0; - staffs_ = SCM_EOL; } +void +Mark_engraver::do_creation_processing () +{ + daddy_trans_l_->set_property ("staffsFound", SCM_EOL); // ugh: sharing with barnumber grav. +} void @@ -64,7 +69,10 @@ Mark_engraver::acknowledge_element (Score_element_info inf) Score_element * s = inf.elem_l_; if (Staff_symbol::has_interface (s)) { - staffs_ = gh_cons (inf.elem_l_->self_scm (), staffs_); + SCM sts = get_property ("staffsFound"); + SCM thisstaff = inf.elem_l_->self_scm (); + if (scm_memq (thisstaff, sts) == SCM_BOOL_F) + daddy_trans_l_->set_property ("staffsFound", gh_cons (thisstaff, sts)); } else if (text_p_ && Bar::has_interface (s)) { @@ -81,7 +89,7 @@ Mark_engraver::do_pre_move_processing () { if (text_p_) { - text_p_->set_elt_property("side-support-elements" , staffs_); + text_p_->set_elt_property("side-support-elements" , get_property ("staffsFound")); typeset_element (text_p_); text_p_ =0; } diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc index 07895d86e2..a0107291a5 100644 --- a/lily/music-output-def.cc +++ b/lily/music-output-def.cc @@ -50,15 +50,17 @@ Music_output_def::assign_translator (Translator_group*tp) { tp->warning (_("Interpretation context with empty type")); } - - translator_p_dict_p_->set (s, new Translator_group_identifier (tp, 0)); + + SCM tr = tp->self_scm (); + scm_unprotect_object (tr); + translator_p_dict_p_->set (s, tr); } Translator* Music_output_def::find_translator_l (String name) const { if (translator_p_dict_p_->elem_b (name)) - return translator_p_dict_p_->elem (name)->access_content_Translator_group (false); + return unsmob_translator (translator_p_dict_p_->scm_elem (name)); map::const_iterator ki =global_translator_dict_p->find (name); @@ -77,6 +79,7 @@ Music_output_def::get_global_translator_p () if (!t) error (_f ("can't find `%s' context", "Score")); t = t->clone (); + t->output_def_l_ = this; Global_translator *g = dynamic_cast (t); t->add_processing (); diff --git a/lily/parser.yy b/lily/parser.yy index bb7b882e36..84a0b042d8 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -198,14 +198,14 @@ yylex (YYSTYPE *s, void * v_l) %token CHORDMODIFIER_PITCH %token DURATION_IDENTIFIER %token IDENTIFIER -%token TRANS_IDENTIFIER + %token SCORE_IDENTIFIER %token MUSIC_OUTPUT_DEF_IDENTIFIER %token NUMBER_IDENTIFIER %token REQUEST_IDENTIFIER -%token MUSIC_IDENTIFIER +%token MUSIC_IDENTIFIER TRANSLATOR_IDENTIFIER %token STRING_IDENTIFIER SCM_IDENTIFIER %token DURATION RESTNAME %token STRING @@ -388,7 +388,7 @@ identifier_init: $$ = (new Music_output_def_identifier ($1, MUSIC_OUTPUT_DEF_IDENTIFIER))->self_scm(); } | translator_spec_block { - $$ = (new Translator_group_identifier ($1, TRANS_IDENTIFIER))->self_scm(); + $$ = $1->self_scm (); } | Music { $$ = $1->self_scm (); @@ -418,8 +418,10 @@ translator_spec_block: ; translator_spec_body: - TRANS_IDENTIFIER { - $$ = $1->access_content_Translator_group (true); + TRANSLATOR_IDENTIFIER { + SCM trs = $1; + Translator*tr = unsmob_translator (trs); + $$ = dynamic_cast (tr->clone ()); $$-> set_spot (THIS->here_input ()); } | TYPE STRING semicolon { @@ -449,23 +451,31 @@ translator_spec_body: tg->set_property (ly_scm2string ($2), v); } + | translator_spec_body PUSHPROPERTY + embedded_scm embedded_scm embedded_scm { + Translator_group_initializer::add_push_property ($$, $3, $4, $5); + } + | translator_spec_body POPPROPERTY + embedded_scm embedded_scm { + Translator_group_initializer::add_pop_property ($$, $3, $4); + } | translator_spec_body NAME STRING semicolon { $$->type_str_ = ly_scm2string ($3); } | translator_spec_body CONSISTS STRING semicolon { - dynamic_cast ($$)-> set_element (ly_scm2string ($3), true); + Translator_group_initializer::add_element ($$, $3); } | translator_spec_body CONSISTSEND STRING semicolon { - dynamic_cast ($$)-> set_element (ly_scm2string ($3), true); + Translator_group_initializer::add_last_element ($$, $3); } | translator_spec_body ACCEPTS STRING semicolon { - dynamic_cast ($$)-> set_acceptor (ly_scm2string ($3), true); + Translator_group_initializer::set_acceptor ($$, $3,true); } | translator_spec_body DENIES STRING semicolon { - dynamic_cast ($$)-> set_acceptor (ly_scm2string ($3), false); + Translator_group_initializer::set_acceptor ($$, $3,false); } | translator_spec_body REMOVE STRING semicolon { - dynamic_cast ($$)-> set_element (ly_scm2string ($3), false); + Translator_group_initializer::remove_element ($$, $3); } ; diff --git a/lily/part-combine-music-iterator.cc b/lily/part-combine-music-iterator.cc index 1f57157c48..3a72a587a9 100644 --- a/lily/part-combine-music-iterator.cc +++ b/lily/part-combine-music-iterator.cc @@ -101,7 +101,7 @@ Part_combine_music_iterator::change_to (Music_iterator *it, String to_type, Translator_group * dest = it->report_to_l ()->find_create_translator_l (to_type, to_id); current->remove_translator_p (last); - dest->add_translator (last); + dest->add_group_translator (last); } else { diff --git a/lily/performer-group-performer.cc b/lily/performer-group-performer.cc index 7a38830b53..0c07bf694f 100644 --- a/lily/performer-group-performer.cc +++ b/lily/performer-group-performer.cc @@ -22,48 +22,44 @@ Performer_group_performer::announce_element (Audio_element_info info) Performer::announce_element (info); } + + void Performer_group_performer::do_announces() { - for (Cons *p = trans_p_list_.head_; p; p = p->next_) + for (SCM p = trans_group_list_; gh_pair_p (p); p =gh_cdr ( p)) { - if (Performer_group_performer *trg = dynamic_cast (p->car_)) - trg->do_announces (); + Translator * t = unsmob_translator (gh_car (p)); + dynamic_cast (t)->do_announces (); } - - - while (announce_info_arr_.size ()) { for (int j =0; j < announce_info_arr_.size(); j++) { Audio_element_info info = announce_info_arr_[j]; - for (Cons *p = trans_p_list_.head_; p; p = p->next_) - { - if (!dynamic_cast (p->car_)) - { - Performer * eng = dynamic_cast (p->car_); - // urg, huh? core dump? - //if (eng && eng!= info.origin_trans_l_arr ()[0]) - if (eng && info.origin_trans_l_arr (this).size () - && eng!= info.origin_trans_l_arr (this)[0]) - eng->acknowledge_element (info); - } - } - announce_info_arr_.clear (); - - - for (Cons *p = trans_p_list_.head_; p; p = p->next_) + + for (SCM p = simple_trans_list_; gh_pair_p (p); p = gh_cdr (p)) { - if (!dynamic_cast (p->car_)) - { - Performer * eng = dynamic_cast (p->car_); - if (eng) - eng->process_acknowledged (); - } + Translator * t = unsmob_translator (gh_car (p)); + Performer * eng = dynamic_cast (t); + if (eng && eng!= info.origin_trans_l_) + eng->acknowledge_element (info); } } + announce_info_arr_.clear (); + for (SCM p = simple_trans_list_; gh_pair_p (p); p = gh_cdr ( p)) + { + Translator * t = unsmob_translator (gh_car (p)); + Performer * eng = dynamic_cast (t); + if (eng) + eng->process_acknowledged (); + } } } + + + + + diff --git a/lily/performer.cc b/lily/performer.cc index fe706b01f9..8cf1c972f7 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -45,6 +45,7 @@ Performer::process_acknowledged () void Performer::announce_element (Audio_element_info i) { - i.origin_trans_l_arr_.push (this); + if (!i.origin_trans_l_) + i.origin_trans_l_= this; daddy_perf_l()->announce_element (i); } diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 6b1fd8f7c1..b9688e5de7 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -182,15 +182,8 @@ Piano_pedal_engraver::do_process_music () if (gh_string_p (s)) { - if (p->name_ == String ("Sustain")) - { - // fixme: Item should be sufficient. - p->item_p_ = new Item (get_property ("basicSustainPedalProperties")); - } - else - { - p->item_p_ = new Item (get_property ("basicPedalProperties")); - } + String propname = String ("basic")+ p->name_ + "PedalProperties"; + p->item_p_ = new Item (get_property (propname.ch_C())); p->item_p_->set_elt_property ("text", s); // guh diff --git a/lily/property-engraver.cc b/lily/property-engraver.cc index e7baf2ec25..1e5a16b931 100644 --- a/lily/property-engraver.cc +++ b/lily/property-engraver.cc @@ -9,11 +9,14 @@ #include "lily-guile.hh" #include "engraver.hh" -#include "protected-scm.hh" #include "dictionary.hh" #include "score-element.hh" #include "scm-hash.hh" +/* + JUNKME: should use pushproperty everywhere. + + */ class Property_engraver : public Engraver { /* @@ -99,12 +102,12 @@ Property_engraver::apply_properties (SCM p, Score_element *e) SCM type_p = gh_cadr (entry); SCM elt_prop_sym = gh_caddr (entry); - SCM preset = e->get_elt_property (elt_prop_sym); // scm_assq(elt_prop_sym, e->property_alist_); - if (preset != SCM_EOL) + SCM preset = scm_assq(elt_prop_sym, e->mutable_property_alist_); + if (preset != SCM_BOOL_F) continue; SCM val = get_property (prop_sym); - + if (val == SCM_UNDEFINED) ; // Not defined in context. else if (gh_apply (type_p, scm_listify (val, SCM_UNDEFINED)) diff --git a/lily/property-iterator.cc b/lily/property-iterator.cc index 0e50832e64..41b0ed5406 100644 --- a/lily/property-iterator.cc +++ b/lily/property-iterator.cc @@ -28,20 +28,11 @@ void Push_property_iterator::do_process_and_next (Moment m) { SCM syms = music_l_->get_mus_property ("symbols"); - SCM eprop = music_l_->get_mus_property ("element-property"); + SCM eprop = music_l_->get_mus_property ("element-property"); SCM val = music_l_->get_mus_property ("element-value"); - for (SCM s = syms; gh_pair_p (s); s = gh_cdr (s)) - { - SCM sym = gh_car (s); - if (gh_symbol_p(sym)) - { - SCM prev = report_to_l ()->get_property (sym); - - prev = gh_cons (gh_cons (eprop, val), prev); - report_to_l ()->set_property (gh_car (s), prev); - } - } + Translator_group_initializer::apply_pushpop_property (report_to_l (), syms,eprop, val); + Music_iterator::do_process_and_next (m); } @@ -50,23 +41,7 @@ Pop_property_iterator::do_process_and_next (Moment m) { SCM syms = music_l_->get_mus_property ("symbols"); SCM eprop = music_l_->get_mus_property ("element-property"); - for (SCM s = syms; gh_pair_p (s); s = gh_cdr (s)) - { - SCM sym = gh_car (s); - if (gh_symbol_p(sym)) - { - SCM prev = report_to_l ()->get_property (sym); - - SCM newprops= SCM_EOL ; - while (gh_pair_p (prev) && gh_caar (prev) != eprop) - { - newprops = gh_cons (gh_car (prev), newprops); - prev = gh_cdr (prev); - } - - newprops = scm_reverse_x (newprops, gh_cdr (prev)); - report_to_l ()->set_property (sym, newprops); - } - } + Translator_group_initializer::apply_pushpop_property (report_to_l (), syms, eprop, SCM_UNDEFINED); + Music_iterator::do_process_and_next (m); } diff --git a/lily/repeat-engraver.cc b/lily/repeat-engraver.cc index 9874744414..2cae99cb09 100644 --- a/lily/repeat-engraver.cc +++ b/lily/repeat-engraver.cc @@ -208,7 +208,7 @@ Repeat_engraver::do_process_music () return; Bar_engraver* bar_engraver_l = dynamic_cast - (daddy_grav_l ()->get_simple_translator ("Bar_engraver")); + (daddy_grav_l ()->get_simple_translator ("Bar_engraver")); // UGH /* Do all the events that need to be done now. diff --git a/lily/score-element.cc b/lily/score-element.cc index 49493167f3..26a62293fc 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -189,10 +189,13 @@ Score_element::paper_l () const Lookup const * Score_element::lookup_l () const { + /* + URG junkthis, caching is clumsy. + */ if (!lookup_l_) { Score_element * urg = (Score_element*)this; - SCM sz = urg->remove_elt_property ("fontsize"); + SCM sz = urg->remove_elt_property ("font-size"); int i = (gh_number_p (sz)) ? gh_scm2int (sz) : 0; diff --git a/lily/score-performer.cc b/lily/score-performer.cc index ad868ae9e3..1908644904 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -47,7 +47,7 @@ void Score_performer::announce_element (Audio_element_info info) { announce_info_arr_.push (info); - info.origin_trans_l_arr_.push (this); + /* huh? diff --git a/lily/score.cc b/lily/score.cc index 75e397aab8..4f33c853f1 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -95,7 +95,8 @@ Score::run_translator (Music_output_def *odef_l) } Music_output * output = trans_p->get_output_p(); - delete trans_p; + scm_unprotect_object (trans_p->self_scm ()); + if(verbose_global_b) progress_indication (_f ("elapsed time: %.2f seconds", timer.read ())); diff --git a/lily/syllable-group.cc b/lily/syllable-group.cc new file mode 100644 index 0000000000..a0cf73d270 --- /dev/null +++ b/lily/syllable-group.cc @@ -0,0 +1,268 @@ +#include + +#include "lyric-phrasing-engraver.hh" +#include "note-head.hh" +#include "translator-group.hh" +#include "side-position-interface.hh" +#include "ly-smobs.icc" +#include "spanner.hh" +#include "paper-def.hh" + + +/*=========================================================================================*/ + +/** Syllable_group is a class to be smobbed and entered as data in the association list + member of the Lyric_phrasing_engraver class. +*/ + +Syllable_group::Syllable_group() +{ + first_in_phrase_b_=true; + melisma_b_ = false; + clear(); +} + +void +Syllable_group::clear() +{ + notehead_l_=0; + lyric_list_.clear(); + longest_lyric_l_=0; + shortest_lyric_l_=0; + melisma_b_ = false; + group_translation_f_ = 0.0; +} + +void +Syllable_group::copy( Syllable_group *from) +{ + notehead_l_ = from->notehead_l_; + lyric_list_ = from->lyric_list_; + longest_lyric_l_ = from->longest_lyric_l_; + shortest_lyric_l_ = from->shortest_lyric_l_; + melisma_b_ = from->melisma_b_; + alignment_i_ = from->alignment_i_; + first_in_phrase_b_ = from->first_in_phrase_b_; + group_translation_f_ = from->group_translation_f_; +} + +void +Syllable_group::set_first_in_phrase(bool f) +{ + first_in_phrase_b_ = f; +} + +void +Syllable_group::set_notehead(Score_element * notehead) +{ + if(!notehead_l_) { + /* there should only be a single notehead, so silently ignore any extras */ + notehead_l_=notehead; + } +} + +void +Syllable_group::add_lyric(Score_element * lyric) +{ + lyric_list_.push(lyric); + /* record longest and shortest lyrics */ + if( longest_lyric_l_ ) { + if(lyric->extent(X_AXIS).length() > (longest_lyric_l_->extent(X_AXIS)).length()) + longest_lyric_l_ = lyric; + if(lyric->extent(X_AXIS).length() < (shortest_lyric_l_->extent(X_AXIS)).length()) + shortest_lyric_l_ = lyric; + } + else + longest_lyric_l_ = shortest_lyric_l_ = lyric; +} + +void +Syllable_group::add_extender(Score_element * extender) +{ + if(notehead_l_ && melisma_b_) { + dynamic_cast(extender)->set_bound (RIGHT, notehead_l_); + // should the extender finish at the right of the last note of the melisma, or the left? + // Comments in lyric-extender.hh say left, but right looks better to me. GP. + + // Left: +// extender->set_elt_property("right-trim-amount", gh_double2scm(0.0)); + + // Right: + Real ss = extender->paper_l ()->get_var ("staffspace"); + extender->set_elt_property("right-trim-amount", + gh_double2scm(-notehead_l_->extent(X_AXIS).length()/ss)); + } +} + +bool +Syllable_group::set_lyric_align(const char *punc, Score_element *default_notehead_l) +{ + if(lyric_list_.size()==0) { + // No lyrics: nothing to do. + return true; + } + + Score_element * lyric; + alignment_i_ = appropriate_alignment(punc); + + // If there was no notehead in the matching voice context, use the first + // notehead caught from any voice context (any port in a storm). + if(!notehead_l_) { + notehead_l_ = default_notehead_l; + } + + group_translation_f_ = amount_to_translate(); + + // set the x alignment of each lyric + for(int l = 0; l < lyric_list_.size(); l++) { + lyric = lyric_list_[l]; + lyric->set_elt_property("self-alignment-X", gh_int2scm(alignment_i_)); + // centre on notehead ... if we have one. + if(notehead_l_) { + lyric->set_parent(notehead_l_, X_AXIS); + lyric->add_offset_callback (Side_position::centered_on_parent, X_AXIS); + // reference is on the right of the notehead; move it left half way, and add translation + lyric->translate_axis (group_translation_f_-(notehead_l_->extent(X_AXIS)).center(), X_AXIS); + } + } + return (notehead_l_); +} + +/** determine the distance to translate lyrics to get correct alignment + Rules: If alignment is centre, translate = 0 + Otherwise, + If (length of longest lyric) < 2 * (length of shortest lyric), + - centre longest lyric on notehead + Otherwise + - move so shortest lyric just reaches notehead centre +*/ +Real +Syllable_group::amount_to_translate() +{ + Real translate = 0.0; + if(alignment_i_ != CENTER) { + // FIXME: do we really know the lyric extent here? Some font sizing comes later? + if((longest_lyric_l_->extent(X_AXIS)).length() < + (shortest_lyric_l_->extent(X_AXIS)).length() * 2 ) + translate = alignment_i_*(longest_lyric_l_->extent(X_AXIS)).length()/2; + else + translate = alignment_i_*(shortest_lyric_l_->extent(X_AXIS)).length(); + } + return translate; +} + + +/** determine what alignment we want. + Rules: if first_in_phrase_b_ is set, then alignment is LEFT. + otherwise if each syllable ends in punctuation, then alignment is RIGHT + otherwise alignment is centre. +*/ +int +Syllable_group::appropriate_alignment(const char *punc) +{ + if(first_in_phrase_b_) + return LEFT; + + Score_element * lyric; + bool end_phrase = true; + + for(int l = 0; l < lyric_list_.size() && end_phrase; l++) { + lyric = lyric_list_[l]; + SCM lyric_scm = lyric->get_elt_property("text"); + String lyric_str = gh_string_p(lyric_scm)?ly_scm2string(lyric_scm):""; + char lastchar; + if(lyric_str.length_i()>0) { + lastchar = lyric_str[lyric_str.length_i()-1]; + /* If it doesn't end in punctuation then it ain't an end of phrase */ + if(! strchr(punc, lastchar)) { + /* Special case: trailing space. Here examine the previous character and reverse the + sense of the test (i.e. trailing space makes a break without punctuation, or + suppresses a break with punctuation). + This behaviour can be suppressed by including a space in the + phrasingPunctuation property, in which case trailing space always means + the same as punctuation. + + FIXME: The extra space throws alignment out a bit. + */ + if(lastchar == ' ') { + if(lyric_str.length_i()>1) { + lastchar = lyric_str[lyric_str.length_i()-2]; + if(strchr(punc, lastchar)) + end_phrase=false; + } + } + else + end_phrase=false; + } + } + } + if(end_phrase) + return RIGHT; + + return CENTER; +} + +/** We don't know about the melisma until after the initial alignment work is done, so go + back and fix the alignment when we DO know. +*/ +void +Syllable_group::adjust_melisma_align() +{ + if(notehead_l_ && lyric_list_.size()) { + // override any previous offset adjustments + Real translation = -group_translation_f_; + // melisma aligning: + switch (alignment_i_) { + // case LEFT: // that's all + case CENTER: // move right so smallest lyric is left-aligned on notehead + translation += (shortest_lyric_l_->extent(X_AXIS)).length()/2; + break; + case RIGHT: // move right so smallest lyric is left-aligned on notehead + translation += (shortest_lyric_l_->extent(X_AXIS)).length(); + break; + } + group_translation_f_ += translation; + for(int l = 0; l < lyric_list_.size(); l++) { + lyric_list_[l]->translate_axis (translation, X_AXIS); + } + } +} + + +bool +Syllable_group::is_empty() +{ + return lyric_list_.size()==0; +} + +void +Syllable_group::next_lyric() +{ + first_in_phrase_b_ = (alignment_i_ == RIGHT); + clear(); +} + +/* SMOB */ +SCM +Syllable_group::mark_smob (SCM) +{ + return SCM_EOL; +} + +int +Syllable_group::print_smob (SCM, SCM port, scm_print_state * ) +{ + scm_puts ("#", port); + return 1; +} + +IMPLEMENT_UNSMOB(Syllable_group, voice_entry); +IMPLEMENT_SIMPLE_SMOBS(Syllable_group); +IMPLEMENT_DEFAULT_EQUAL_P(Syllable_group); + +SCM +Syllable_group::make_entry () +{ + Syllable_group *vi = new Syllable_group; + return vi->smobbed_self (); +} diff --git a/lily/translator-group.cc b/lily/translator-group.cc index 8d92fb8ac1..d2b7c83a04 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -17,111 +17,78 @@ Translator_group::Translator_group (Translator_group const&s) : Translator(s) { - consists_str_arr_ = s.consists_str_arr_; - consists_end_str_arr_ = s.consists_end_str_arr_; - accepts_str_arr_ = s.accepts_str_arr_; iterator_count_ =0; - properties_dict_ = new Scheme_hash_table (*s.properties_dict_); + + Scheme_hash_table * tab = new Scheme_hash_table (*s.properties_dict ()); + properties_scm_ = tab->self_scm (); + scm_unprotect_object (tab->self_scm( )); +} + +Scheme_hash_table* +Translator_group::properties_dict () const +{ + return Scheme_hash_table::unsmob (properties_scm_); } Translator_group::~Translator_group () { assert (removable_b()); - trans_p_list_.junk (); - scm_unprotect_object (properties_dict_->self_scm ()); } Translator_group::Translator_group() { iterator_count_ = 0; - properties_dict_ = new Scheme_hash_table ; + Scheme_hash_table *tab = new Scheme_hash_table ; + properties_scm_ = tab->self_scm (); + + scm_unprotect_object (tab->self_scm ()); } void Translator_group::check_removal() { - Cons *next =0; - for (Cons *p = trans_p_list_.head_; p; p = next) + SCM next = SCM_EOL; + for (SCM p = trans_group_list_; gh_pair_p (p); p = next) { - next = p->next_; - if (Translator_group *trg = dynamic_cast (p->car_)) - { - trg->check_removal (); - if (trg->removable_b()) - terminate_translator (trg); - } + next = gh_cdr (p); + + Translator_group *trg = dynamic_cast (unsmob_translator (gh_car (p))); + + trg->check_removal (); + if (trg->removable_b()) + terminate_translator (trg); } } -void -Translator_group::add_translator (Translator *trans_p) + +SCM +Translator_group::add_translator (SCM list, Translator *t) { - trans_p_list_.append (new Killing_cons (trans_p,0)); + list = gh_append2 (list, gh_cons (t->self_scm (), SCM_EOL)); + t->daddy_trans_l_ = this; + t->output_def_l_ = output_def_l_; + t->add_processing (); - trans_p->daddy_trans_l_ = this; - trans_p->output_def_l_ = output_def_l_; - trans_p->add_processing (); + return list; } - void -Translator_group::set_acceptor (String accepts, bool add) +Translator_group::add_simple_translator (Translator*t) { - if (add) - accepts_str_arr_.push (accepts); - else - for (int i=accepts_str_arr_.size (); i--; ) - if (accepts_str_arr_[i] == accepts) - accepts_str_arr_.del (i); + simple_trans_list_ = add_translator (simple_trans_list_, t); } - void -Translator_group::add_last_element (String s) +Translator_group::add_group_translator (Translator *t) { - if (!get_translator_l (s)) - error (_ ("Program has no such type")); - - for (int i=consists_end_str_arr_.size (); i--; ) - if (consists_end_str_arr_[i] == s) - warning (_f ("Already contains: `%s'", s)); - - consists_end_str_arr_.push (s); + trans_group_list_ = add_translator (trans_group_list_,t); } -void -Translator_group::set_element (String s, bool add) -{ - if (!get_translator_l (s)) - error (_ ("Program has no such type")); - if (add) - { - for (int i=consists_str_arr_.size (); i--; ) - if (consists_str_arr_[i] == s) - warning (_f("Already contains: `%s'", s)); - - consists_str_arr_.push (s); - } - else - { - for (int i=consists_str_arr_.size (); i--; ) - if (consists_str_arr_[i] == s) - consists_str_arr_.del (i); - for (int i=consists_end_str_arr_.size (); i--; ) - if (consists_end_str_arr_[i] == s) - consists_end_str_arr_.del (i); - } -} + bool Translator_group::removable_b() const { - for (Cons *p = trans_p_list_.head_; p; p = p->next_) - { - if (dynamic_cast (p->car_)) - return false; - } - - return !iterator_count_; + return trans_group_list_ == SCM_EOL && ! iterator_count_; } Translator_group * @@ -131,10 +98,11 @@ Translator_group::find_existing_translator_l (String n, String id) return this; Translator_group* r = 0; - for (Cons *p = trans_p_list_.head_; !r && p; p = p->next_) + for (SCM p = trans_group_list_; !r && gh_pair_p (p); p = gh_cdr (p)) { - if (Translator_group *trg = dynamic_cast (p->car_)) - r = trg->find_existing_translator_l (n, id); + Translator * t = unsmob_translator (gh_car (p)); + + r = dynamic_cast (t)->find_existing_translator_l (n, id); } return r; @@ -143,10 +111,11 @@ Translator_group::find_existing_translator_l (String n, String id) Link_array Translator_group::path_to_acceptable_translator (String type, Music_output_def* odef) const { - Link_array accepted_arr; - for (int i=0; i < accepts_str_arr_.size (); i++) + Link_array accepted_arr; + for (SCM s = accepts_name_list_; gh_pair_p (s); s = gh_cdr (s)) { - Translator *t = odef->find_translator_l (accepts_str_arr_[i]); + + Translator *t = odef->find_translator_l (ly_scm2string (gh_car (s))); if (!t || !dynamic_cast (t)) continue; accepted_arr.push (dynamic_cast (t)); @@ -198,7 +167,7 @@ Translator_group::find_create_translator_l (String n, String id) { Translator_group * new_group = dynamic_cast(path[i]->clone ()); - current->add_translator (new_group); + current->add_group_translator (new_group); current = new_group; } current->id_str_ = id; @@ -221,12 +190,10 @@ Translator_group::try_music_on_nongroup_children (Music *m) { bool hebbes_b =false; - for (Cons *p = trans_p_list_.head_; !hebbes_b && p; p = p->next_) + + for (SCM p = simple_trans_list_; !hebbes_b && gh_pair_p (p); p = gh_cdr (p)) { - if (!dynamic_cast (p->car_)) - { - hebbes_b = p->car_->try_music (m); - } + hebbes_b = unsmob_translator (gh_car (p))->try_music (m); } return hebbes_b; } @@ -256,17 +223,14 @@ Translator_group::ancestor_l (int level) return daddy_trans_l_->ancestor_l (level-1); } - - - - void Translator_group::terminate_translator (Translator*r_l) { r_l->removal_processing(); Translator * trans_p =remove_translator_p (r_l); - - delete trans_p; + /* + forget trans_p, GC does the rest. + */ } @@ -277,28 +241,20 @@ Translator * Translator_group::remove_translator_p (Translator*trans_l) { assert (trans_l); - - for (Cons **pp = &trans_p_list_.head_; *pp; pp = &(*pp)->next_) - if ((*pp)->car_ == trans_l) - { - Cons *r = trans_p_list_.remove_cons (pp); - r->car_ =0; - trans_l->daddy_trans_l_ =0; - delete r; - return trans_l; - } - return 0; + trans_group_list_ = scm_delq_x (trans_l->self_scm (), trans_group_list_); + trans_l->daddy_trans_l_ = 0; + return trans_l; } Translator* Translator_group::get_simple_translator (String type) const { - for (Cons *p = trans_p_list_.head_; p; p = p->next_) + for (SCM p = simple_trans_list_; gh_pair_p (p); p =gh_cdr (p)) { - if (classname (p->car_) == type) - return p->car_; + if (classname (unsmob_translator (gh_car (p))) == type) + return unsmob_translator (gh_car (p)); } if (daddy_trans_l_) return daddy_trans_l_->get_simple_translator (type); @@ -309,7 +265,7 @@ Translator_group::get_simple_translator (String type) const bool Translator_group::is_bottom_translator_b () const { - return !accepts_str_arr_.size (); + return accepts_name_list_ == SCM_EOL; } @@ -317,16 +273,17 @@ Translator_group::is_bottom_translator_b () const Translator_group* Translator_group::get_default_interpreter() { - if (accepts_str_arr_.size()) + if (gh_pair_p (accepts_name_list_)) { - Translator*t = output_def_l ()->find_translator_l (accepts_str_arr_[0]); + String str = ly_scm2string (gh_car (accepts_name_list_)); + Translator*t = output_def_l ()->find_translator_l (str); if (!t) { - warning (_f ("can't find or create: `%s'", accepts_str_arr_[0])); + warning (_f ("can't find or create: `%s'", str)); t = this; } Translator_group * g= dynamic_cast (t->clone ()); - add_translator (g); + add_group_translator (g); if (!g->is_bottom_translator_b ()) return g->get_default_interpreter (); @@ -336,105 +293,90 @@ Translator_group::get_default_interpreter() return this; } -void -Translator_group::each (Method_pointer method) +static void +static_each (SCM list, Method_pointer method) { - for (Cons *p = trans_p_list_.head_; p; p = p->next_) - (p->car_->*method) (); + for (SCM p = list; gh_pair_p (p); p = gh_cdr(p)) + (unsmob_translator (gh_car (p))->*method) (); + } - void -Translator_group::each (Const_method_pointer method) const +Translator_group::each (Method_pointer method) { - for (Cons *p = trans_p_list_.head_; p; p = p->next_) - (p->car_->*method) (); + static_each (simple_trans_list_, method); + static_each (trans_group_list_, method); } void Translator_group::do_print() const { #ifndef NPRINT - if (!flower_dstream) - return ; - - gh_display (properties_dict_->self_scm ()); - if (status == ORPHAN) - { - DEBUG_OUT << "consists of: "; - for (int i=0; i < consists_str_arr_.size (); i++) - DEBUG_OUT << consists_str_arr_[i] << ", "; - DEBUG_OUT << "\naccepts: "; - for (int i=0; i < accepts_str_arr_.size (); i++) - DEBUG_OUT << accepts_str_arr_[i] << ", "; - } - else - { - if (id_str_.length_i ()) - DEBUG_OUT << "ID: " << id_str_ ; - DEBUG_OUT << " iterators: " << iterator_count_<< '\n'; - } - each (&Translator::print); #endif } -void -Translator_group::do_pre_move_processing () +static SCM +trans_list (SCM namelist, Music_output_def *mdef) { - each (&Translator::pre_move_processing); -} - -void -Translator_group::do_post_move_processing () -{ - each (&Translator::post_move_processing); -} - -void -Translator_group::do_process_music () -{ - each (&Translator::process_music); -} - -void -Translator_group::do_creation_processing () -{ - each (&Translator::creation_processing); + SCM l = SCM_EOL; + for (SCM s = namelist; gh_pair_p (s) ; s = gh_cdr (s)) + { + Translator * t = mdef->find_translator_l (ly_scm2string (gh_car (s))); + if (!t) + warning (_f ("can't find: `%s'", s)); + else + { + Translator * tr = t->clone (); + SCM str = tr->self_scm (); + l = gh_cons (str, l); + scm_unprotect_object (str); + } + } + return l; } -void -Translator_group::do_removal_processing () -{ - each (&Translator::removal_processing); -} void Translator_group::do_add_processing () { - for (int i=0; i < consists_str_arr_.size(); i++) + assert (simple_trans_list_== SCM_EOL); + + SCM correct_order = scm_reverse (property_pushes_); // pity of the mem. + for (SCM s = correct_order; gh_pair_p (s); s = gh_cdr (s)) { - String s = consists_str_arr_[i]; - Translator * t = output_def_l ()->find_translator_l (s); - if (!t) - warning (_f ("can't find: `%s'", s)); - else - add_translator (t->clone ()); + SCM entry = gh_car (s); + SCM val = gh_cddr (entry); + val = gh_pair_p (val) ? gh_car (val) : SCM_UNDEFINED; + + Translator_group_initializer::apply_pushpop_property (this, gh_car (entry), + gh_cadr (entry), + val); } - for (int i=0; i-- < consists_end_str_arr_.size (); i++) - { - String s = consists_end_str_arr_[i]; - Translator * t = output_def_l ()->find_translator_l (s); - if (!t) - warning (_f ("can't find: `%s'", s)); - else - add_translator (t->clone ()); + + SCM l1 = trans_list (consists_name_list_, output_def_l ()); + SCM l2 =trans_list (end_consists_name_list_, output_def_l ()); + l1 = scm_reverse_x (l1, l2); + + simple_trans_list_ = l1; + for (SCM s = l1; gh_pair_p (s) ; s = gh_cdr (s)) + { + Translator * t = unsmob_translator (gh_car (s)); + + t->daddy_trans_l_ = this; + t->output_def_l_ = output_def_l_; + t->add_processing (); } + + } +/* + PROPERTIES + */ Translator_group* Translator_group::where_defined (SCM sym) const { - if (properties_dict_->elem_b (sym)) + if (properties_dict ()->elem_b (sym)) { return (Translator_group*)this; } @@ -445,9 +387,9 @@ Translator_group::where_defined (SCM sym) const SCM Translator_group::get_property (SCM sym) const { - if (properties_dict_->elem_b (sym)) + if (properties_dict ()->elem_b (sym)) { - return properties_dict_->get (sym); + return properties_dict ()->get (sym); } if (daddy_trans_l_) @@ -465,7 +407,78 @@ Translator_group::set_property (String id, SCM val) void Translator_group::set_property (SCM sym, SCM val) { - properties_dict_->set (sym, val); + properties_dict ()->set (sym, val); } +/* + Push or pop (depending on value of VAL) a single entry (ELTPROP . VAL) + entry from a translator property list by name of PROP +*/ +void +Translator_group::execute_single_pushpop_property (SCM prop, SCM eltprop, SCM val) +{ + if (gh_symbol_p(prop)) + { + if (val != SCM_UNDEFINED) + { + SCM prev = get_property (prop); + prev = gh_cons (gh_cons (eltprop, val), prev); + set_property (prop, prev); + } + else + { + SCM prev = get_property (prop); + + SCM newprops= SCM_EOL ; + while (gh_pair_p (prev) && gh_caar (prev) != eltprop) + { + newprops = gh_cons (gh_car (prev), newprops); + prev = gh_cdr (prev); + } + + if (gh_pair_p (prev)) + { + newprops = scm_reverse_x (newprops, gh_cdr (prev)); + set_property (prop, newprops); + } + } + } +} + + + + + +/* + STUBS +*/ +void +Translator_group::do_pre_move_processing () +{ + each (&Translator::pre_move_processing); +} + +void +Translator_group::do_post_move_processing () +{ + each (&Translator::post_move_processing); +} + +void +Translator_group::do_process_music () +{ + each (&Translator::process_music); +} + +void +Translator_group::do_creation_processing () +{ + each (&Translator::creation_processing); +} + +void +Translator_group::do_removal_processing () +{ + each (&Translator::removal_processing); +} diff --git a/lily/translator.cc b/lily/translator.cc index 68db603831..6605eaae0c 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -12,6 +12,7 @@ #include "translator-group.hh" #include "moment.hh" +#include "ly-smobs.icc" char const* Translator::name() const @@ -23,20 +24,42 @@ Translator::~Translator () { } +void +Translator::init () +{ + status_ = ORPHAN; + simple_trans_list_ = SCM_EOL; + trans_group_list_ = SCM_EOL; + properties_scm_ = SCM_EOL; + accepts_name_list_ = SCM_EOL; + consists_name_list_ = SCM_EOL; + end_consists_name_list_ = SCM_EOL; + property_pushes_ = SCM_EOL; + daddy_trans_l_ =0; +} + Translator::Translator () { - status = ORPHAN; - daddy_trans_l_ = 0; + init (); output_def_l_ = 0; + smobify_self (); + } Translator::Translator (Translator const &s) : Input (s) { - status = ORPHAN; - daddy_trans_l_ =0; + init (); + + consists_name_list_ = scm_list_copy (s.consists_name_list_); + end_consists_name_list_ = scm_list_copy (s.end_consists_name_list_); + accepts_name_list_ = scm_list_copy (s.accepts_name_list_); + property_pushes_ = scm_list_copy (s.property_pushes_); + output_def_l_ = s.output_def_l_; type_str_ = s.type_str_; + + smobify_self (); } bool @@ -62,11 +85,11 @@ Translator::now_mom () const void Translator::add_processing () { - if (status > ORPHAN) + if (status_ > ORPHAN) return; do_add_processing (); - status = VIRGIN; + status_ = VIRGIN; } void @@ -97,40 +120,40 @@ Translator::do_print () const void Translator::creation_processing () { - if (status >= CREATION_INITED) + if (status_ >= CREATION_INITED) return ; do_creation_processing (); - status = CREATION_INITED; + status_ = CREATION_INITED; } void Translator::post_move_processing () { - if (status >= MOVE_INITED) + if (status_ >= MOVE_INITED) return; creation_processing (); do_post_move_processing (); - status = MOVE_INITED; + status_ = MOVE_INITED; } void Translator::removal_processing () { - if (status == ORPHAN) + if (status_ == ORPHAN) return; creation_processing (); do_removal_processing (); // elegancy ... - // status = ORPHAN; + // status_ = ORPHAN; } bool Translator::try_music (Music * r) { - if (status < MOVE_INITED) + if (status_ < MOVE_INITED) post_move_processing (); return do_try_music (r); @@ -139,12 +162,12 @@ Translator::try_music (Music * r) void Translator::process_music () { - if (status < PROCESSED_REQS) + if (status_ < PROCESSED_REQS) post_move_processing (); - else if (status >= PROCESSED_REQS) + else if (status_ >= PROCESSED_REQS) return; - status = PROCESSED_REQS; + status_ = PROCESSED_REQS; do_process_music (); } @@ -152,7 +175,7 @@ void Translator::pre_move_processing () { do_pre_move_processing (); - status = CREATION_INITED; + status_ = CREATION_INITED; } @@ -199,3 +222,47 @@ void Translator::do_removal_processing () { } + + +/* + + SMOBS + +*/ +SCM +Translator::mark_smob (SCM sm) +{ + Translator * me = (Translator*) SCM_CELL_WORD_1(sm); + scm_gc_mark (me->consists_name_list_); + scm_gc_mark (me->accepts_name_list_); + scm_gc_mark (me->end_consists_name_list_); + scm_gc_mark (me->simple_trans_list_); + scm_gc_mark (me->trans_group_list_); + scm_gc_mark (me->property_pushes_); + return me->properties_scm_; +} + + +int +Translator::print_smob (SCM s, SCM port, scm_print_state *) +{ + Translator *sc = (Translator *) gh_cdr (s); + + scm_puts ("#name (), port); + scm_display (sc->simple_trans_list_, port); + /* + don't try to print properties, that is too much hassle. + */ + scm_puts (" >", port); + + + + return 1; +} + + + +IMPLEMENT_UNSMOB(Translator, translator); +IMPLEMENT_SMOBS(Translator); +IMPLEMENT_DEFAULT_EQUAL_P(Translator); diff --git a/lily/voice-devnull-engraver.cc b/lily/voice-devnull-engraver.cc index ed5e782706..a6684ed454 100644 --- a/lily/voice-devnull-engraver.cc +++ b/lily/voice-devnull-engraver.cc @@ -22,30 +22,27 @@ protected: ADD_THIS_TRANSLATOR (Voice_devnull_engraver); +static char const *junk_interfaces[] = { + // "beam-interface", + "slur-interface", + "tie-interface", + "text-item-interface", + "text-script-interface", + "dynamic-interface", + "crescendo-interface", + 0 +}; + void Voice_devnull_engraver::acknowledge_element (Score_element_info i) { if (daddy_trans_l_->id_str_ == "two" && (to_boolean (get_property ("unison")) || to_boolean (get_property ("unisilence")))) - { - static char const *junk[] = { - // "beam-interface", - "slur-interface", - "tie-interface", - "text-item-interface", - "text-script-interface", - "dynamic-interface", - "crescendo-interface", - 0 - }; - for (char const **p = junk; *p; *p++) + for (char const **p = junk_interfaces; *p; p++) + if (i.elem_l_->has_interface (ly_symbol2scm (*p))) { - if (i.elem_l_->has_interface (ly_symbol2scm (*p))) - { - i.elem_l_->suicide (); - return; - } + i.elem_l_->suicide (); + return; } - } } diff --git a/scm/chord-names.scm b/scm/chord-names.scm index 5116a7904f..70285815a7 100644 --- a/scm/chord-names.scm +++ b/scm/chord-names.scm @@ -11,10 +11,14 @@ ) ;; The regex module may not be available, or may be broken. -(define use-regex +(define chord-use-regex (let ((os (string-downcase (vector-ref (uname) 0)))) (not (equal? "cygwin" (substring os 0 (min 6 (string-length os))))))) +;; If you have trouble with regex, define #f +(define chord-use-regex #t) +;;(define chord-use-regex #f) + ;; ;; (octave notename accidental) ;; @@ -260,7 +264,7 @@ (apply append (pitch->text-banter tonic) (if user-name user-name '()) ;; why does list->string not work, format seems only hope... - (if (and use-regex + (if (and chord-use-regex (string-match "super" (format "~s" user-name)) (or (pair? additions) (pair? subtractions))) diff --git a/scm/generic-property.scm b/scm/generic-property.scm index a786acd0a1..befcda71bc 100644 --- a/scm/generic-property.scm +++ b/scm/generic-property.scm @@ -144,7 +144,7 @@ (define generic-All-properties (cons 'all - (list (list 'fontSize number? 'fontsize)))) + (list (list 'fontSize number? 'font-size)))) (define generic-notehead-properties diff --git a/scm/lily.scm b/scm/lily.scm index 13f8359c55..147f5b5850 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -18,14 +18,14 @@ (use-modules (ice-9 regex)) ;; The regex module may not be available, or may be broken. -;; If you have trouble with regex, define #f -;;(define use-regex #t) -;;(define use-regex #f) - (define use-regex (let ((os (string-downcase (vector-ref (uname) 0)))) (not (equal? "cygwin" (substring os 0 (min 6 (string-length os))))))) +;; If you have trouble with regex, define #f +(define use-regex #t) +;;(define use-regex #f) + ;; do nothing in .scm output (define (comment s) "") diff --git a/scripts/abc2ly.py b/scripts/abc2ly.py index e592f9f38f..cc0d03c07e 100644 --- a/scripts/abc2ly.py +++ b/scripts/abc2ly.py @@ -1049,12 +1049,15 @@ def help (): print r""" Convert ABC to Mudela. -Usage: abc2ly [OPTION]... ABC-FILE +Usage: abc2ly [OPTIONS]... ABC-FILE Options: -h, --help this help -o, --output=FILE set output filename to FILE -v, --version version information + +This program converts ABC music files (see +http://www.gre.ac.uk/~c.walshaw/abc2mtex/abc.txt) To LilyPond input. """ def print_version (): diff --git a/stepmake/aclocal.m4 b/stepmake/aclocal.m4 index 6bca70dc77..d1220794a6 100644 --- a/stepmake/aclocal.m4 +++ b/stepmake/aclocal.m4 @@ -1,3 +1,5 @@ +dnl WARNING WARNING WARNING WARNING +dnl do not edit! this is aclocal.m4, generated from stepmake/aclocal.m4 dnl aclocal.m4 -*-shell-script-*- dnl StepMake subroutines for configure.in @@ -646,20 +648,24 @@ AC_DEFUN(AC_STEPMAKE_TEXMF, [ break; fi done + AC_MSG_RESULT($MFMODE) + AC_MSG_CHECKING(for mfplain.mp) # # For now let people define these in their environments # : ${MFPLAIN_MP=`kpsewhich mp mfplain.mp`} + AC_MSG_RESULT($MFPLAIN_MP) + AC_MSG_CHECKING(for inimetapost flags) if test ${INIMETAPOST} = "inimp" ; then : ${INIMETAPOST_FLAGS=''} else : ${INIMETAPOST_FLAGS='-interaction=nonstopmode'} fi + AC_MSG_RESULT($INIMETAPOST_FLAGS) rm -f mfput.* - AC_MSG_RESULT($MFMODE) AC_SUBST(METAFONT) AC_SUBST(METAPOST) -- 2.39.5