From 0cd896ded4213d642d742fb9da56d03e897a369d Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 22:45:53 +0000 Subject: [PATCH] lilypond-1.3.27 --- input/test/generic-output-property.ly | 10 ++++ lily/dynamic-engraver.cc | 11 +++++ lily/group-interface.cc | 12 ++++- lily/include/group-interface.hh | 17 +++++-- lily/include/output-property.hh | 27 +++++++++++ lily/include/request-iterator.hh | 3 +- lily/include/score-element.hh | 3 ++ lily/include/translator.hh | 3 ++ lily/lily-guile.cc | 4 +- lily/music-iterator.cc | 11 +++-- lily/my-lily-lexer.cc | 1 + lily/output-property-engraver.cc | 66 +++++++++++++++++++++++++++ lily/output-property-engraver.hh | 61 +++++++++++++++++++++++++ lily/output-property.cc | 16 +++++++ lily/request-iterator.cc | 10 ++-- mf/feta-accordion.mf | 4 ++ 16 files changed, 237 insertions(+), 22 deletions(-) create mode 100644 input/test/generic-output-property.ly create mode 100644 lily/include/output-property.hh create mode 100644 lily/output-property-engraver.cc create mode 100644 lily/output-property-engraver.hh create mode 100644 lily/output-property.cc diff --git a/input/test/generic-output-property.ly b/input/test/generic-output-property.ly new file mode 100644 index 0000000000..3a7661efcc --- /dev/null +++ b/input/test/generic-output-property.ly @@ -0,0 +1,10 @@ + +\score +{ +\notes { + c''4 + \outputproperty #(make-type-checker 'Note_head) #'staff-position = #20 + c''4 + +} +} diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index c6c35a908f..7f519db38b 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -18,6 +18,7 @@ #include "engraver.hh" #include "stem.hh" #include "note-head.hh" +#include "group-interface.hh" /** print text & hairpin dynamics. @@ -36,6 +37,9 @@ public: Dynamic_engraver(); protected: + + void announce_element (Score_element_info); + virtual void do_removal_processing (); virtual void acknowledge_element (Score_element_info); virtual bool do_try_music (Music *req_l); @@ -45,6 +49,13 @@ protected: virtual void typeset_element (Score_element*); }; +void +Dynamic_engraver::announce_element (Score_element_info i) +{ + group (i.elem_l_, "interfaces").add_thing (ly_symbol2scm ("dynamic")); + + Engraver::announce_element (i); +} Dynamic_engraver::Dynamic_engraver() diff --git a/lily/group-interface.cc b/lily/group-interface.cc index d9ae970c19..628a9fff58 100644 --- a/lily/group-interface.cc +++ b/lily/group-interface.cc @@ -35,11 +35,19 @@ Group_interface::add_element (Score_element*p) { p->used_b_ = true; elt_l_->used_b_ = true; - + + add_thing (p->self_scm_); +} + +void +Group_interface::add_thing (SCM s) +{ elt_l_->set_elt_property (name_, - gh_cons (p->self_scm_, elt_l_->get_elt_property (name_))); + gh_cons (s, elt_l_->get_elt_property (name_))); + } + int Group_interface::count () { diff --git a/lily/include/group-interface.hh b/lily/include/group-interface.hh index bf461a4052..eb21db6ee6 100644 --- a/lily/include/group-interface.hh +++ b/lily/include/group-interface.hh @@ -15,6 +15,15 @@ #include "lily-guile.hh" #include "smobs.hh" +/* + rename to list interface? + */ + +/** + Look at Score element ELT as thing which has a list property called + NAME_. Normally the list would contain Score_elements, but + sometimes it can be different things. +*/ struct Group_interface { Score_element * elt_l_; @@ -23,6 +32,7 @@ public: Group_interface (Score_element const*); Group_interface (Score_element const*, String); int count (); + void add_thing (SCM); bool has_interface_b (); void set_interface (); void add_element (Score_element*); @@ -31,10 +41,9 @@ public: Group_interface group (Score_element*); Group_interface group (Score_element*, String); -/* - template - Link_array Group_interface__extract_elements (T *, String name); -*/ +/** + Put all score elements of ELT's property called NAME into an array, + and return it. */ template Link_array Group_interface__extract_elements (Score_element const *elt, T *, String name) diff --git a/lily/include/output-property.hh b/lily/include/output-property.hh new file mode 100644 index 0000000000..f266642eb2 --- /dev/null +++ b/lily/include/output-property.hh @@ -0,0 +1,27 @@ +/* + output-property.hh -- declare Output_property + + source file of the GNU LilyPond music typesetter + + (c) 2000 Han-Wen Nienhuys + + */ + +#ifndef OUTPUT_PROPERTY_HH +#define OUTPUT_PROPERTY_HH + +#include "music.hh" +#include "protected-scm.hh" + +class Output_property : public Music +{ +public: + Output_property(SCM, SCM, SCM); + + /** + relevant stuff: the predicate, the symbol, the value + */ + Protected_scm pred_sym_val_list_; +}; + +#endif /* OUTPUT_PROPERTY_HH */ diff --git a/lily/include/request-iterator.hh b/lily/include/request-iterator.hh index 53a7a76070..ea2b07b026 100644 --- a/lily/include/request-iterator.hh +++ b/lily/include/request-iterator.hh @@ -12,10 +12,9 @@ #include "music-iterator.hh" -class Request_iterator : public Music_iterator +class Simple_music_iterator : public Music_iterator { public: - Request_iterator (); protected: virtual void do_process_and_next (Moment ); }; diff --git a/lily/include/score-element.hh b/lily/include/score-element.hh index f37990f7ee..2a962607fd 100644 --- a/lily/include/score-element.hh +++ b/lily/include/score-element.hh @@ -154,6 +154,9 @@ protected: static Interval dim_cache_callback (Dimension_cache const*); public: + static SCM ly_set_elt_property (SCM, SCM,SCM); + static SCM ly_get_elt_property (SCM, SCM); + virtual void handle_broken_dependencies (); virtual void handle_prebroken_dependencies (); diff --git a/lily/include/translator.hh b/lily/include/translator.hh index 6c4e314941..df5f253254 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -67,6 +67,9 @@ public: virtual Moment now_mom () const; protected: + /* + UGH. Clean this up. + */ enum { ORPHAN, VIRGIN, diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index e317ea5438..036bd19039 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -220,7 +220,7 @@ ly_isdir_p (SCM s) } -void +static void init_functions () { scm_make_gsubr ("ly-warn", 1, 0, 0, (SCM(*)(...))ly_warning); @@ -310,9 +310,7 @@ to_boolean (SCM s) /* Appendable list L: the cdr contains the list, the car the last cons in the list. - */ - SCM appendable_list () { diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index 590271201c..edbb722e24 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -5,6 +5,10 @@ (c) 1997--2000 Han-Wen Nienhuys */ + +/* + UGH. too many includes. + */ #include "debug.hh" #include "music-list.hh" #include "music-iterator.hh" @@ -32,6 +36,7 @@ #include "auto-change-iterator.hh" #include "request.hh" #include "request-iterator.hh" +#include "output-property.hh" void Music_iterator::do_print() const @@ -149,12 +154,10 @@ Music_iterator::static_get_iterator_p (Music const *m) else p = new Unfolded_repeat_iterator; } - else if (Request const * r = dynamic_cast (m)) + else { - p = new Request_iterator ; + p = new Simple_music_iterator ; } - else - assert (0); p->music_l_ = m; return p; diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index f413a5dc9a..0e74531f07 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -57,6 +57,7 @@ static Keyword_ent the_key_tab[]={ {"name", NAME}, {"notenames", NOTENAMES}, {"notes", NOTES}, + {"outputproperty", OUTPUTPROPERTY}, {"partial", PARTIAL}, {"paper", PAPER}, {"penalty", PENALTY}, diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc new file mode 100644 index 0000000000..6f0b6cf88f --- /dev/null +++ b/lily/output-property-engraver.cc @@ -0,0 +1,66 @@ +/* + output-property-engraver.cc -- implement Output_property_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2000 Han-Wen Nienhuys + + */ + +#include "output-property.hh" +#include "engraver.hh" +#include "score-element.hh" + +class Output_property_engraver : public Engraver +{ +public: + VIRTUAL_COPY_CONS(Translator); +protected: + + Link_array props_; + + virtual void do_pre_move_processing (); + virtual void acknowledge_element (Score_element_info); + virtual bool do_try_music (Music*); +}; + + +bool +Output_property_engraver::do_try_music (Music* m) +{ + if (Output_property * o = dynamic_cast (m)) + { + props_.push (o); + return true; + } + return false; +} + +void +Output_property_engraver::acknowledge_element (Score_element_info inf) +{ + for (int i=props_.size (); i--; ) + { + Output_property * o = props_[i]; + SCM pred = gh_car (o->pred_sym_val_list_); + /* + should typecheck pred. + */ + SCM result=gh_apply (pred, + gh_list (inf.elem_l_->self_scm_, SCM_UNDEFINED)); + if (to_boolean (result)) + { + Score_element::ly_set_elt_property (inf.elem_l_->self_scm_, + gh_cadr (o->pred_sym_val_list_), + gh_caddr (o->pred_sym_val_list_)); + } + } +} + +void +Output_property_engraver::do_pre_move_processing () +{ + props_.clear (); +} + +ADD_THIS_TRANSLATOR(Output_property_engraver); diff --git a/lily/output-property-engraver.hh b/lily/output-property-engraver.hh new file mode 100644 index 0000000000..ef30fdf091 --- /dev/null +++ b/lily/output-property-engraver.hh @@ -0,0 +1,61 @@ +/* + output-property-engraver.cc -- implement Output_property_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2000 Han-Wen Nienhuys + + */ + +#include "output-property.hh" +#include "engraver.hh" + +class Output_property_engraver : public Engraver +{ +public: + Output_property_engraver(); + VIRTUAL_COPY_CONS(Translator); +protected: + + Link_array props_; + + virtual void do_acknowledge_element (Score_element_info); + virtual bool do_try_music (Music*); +}; + + +Output_property_engraver::do_try_music (Music* m) +{ + if (Output_property * o = dynamic_cast (m)) + { + props_.push (m); + return true; + } + return false; +} + +void +Output_property_engraver::do_acknowledge_element (Score_element_info i) +{ + for (int i=props_.size (); i--; ) + { + Output_property * o = props_[i]; + SCM pred = gh_car (o->pred_sym_val_list_); + /* + should typecheck pred. + */ + SCM result=gh_apply (pred, + gh_listify (i.elem_l_->self_scm_, SCM_UNDEFINED)); + if (to_boolean (result)) + { + i.elem_l_->set_elt_property (gh_cadr (o->pred_sym_val_list_), + gh_caddr (o->pred_sym_val_list_)); + } + } +} + +void +Output_property_engraver::do_pre_move_processing () +{ + props_.clear (); +} diff --git a/lily/output-property.cc b/lily/output-property.cc new file mode 100644 index 0000000000..e8a2d6a463 --- /dev/null +++ b/lily/output-property.cc @@ -0,0 +1,16 @@ +/* + output-property.cc -- implement Output_property + + source file of the GNU LilyPond music typesetter + + (c) 2000 Han-Wen Nienhuys + + */ +#include "output-property.hh" +#include "lily-guile.hh" + +Output_property::Output_property(SCM pred, SCM sym, SCM val) +{ + pred_sym_val_list_ = gh_list (pred, sym, val, SCM_UNDEFINED); +} + diff --git a/lily/request-iterator.cc b/lily/request-iterator.cc index 94d5e90dcc..6cefe8b5b5 100644 --- a/lily/request-iterator.cc +++ b/lily/request-iterator.cc @@ -1,5 +1,5 @@ /* - request-iterator.cc -- implement + request-iterator.cc -- implement Simple_music_iterator source file of the GNU LilyPond music typesetter @@ -9,19 +9,15 @@ #include "request-iterator.hh" #include "music.hh" -Request_iterator::Request_iterator() -{ -} - void -Request_iterator::do_process_and_next (Moment m) +Simple_music_iterator::do_process_and_next (Moment m) { if (first_b_) { bool g= try_music (music_l_); if (!g) - music_l_->warning (_f ("Junking request: `%s'", classname(music_l_))); + music_l_->warning (_f ("Junking music: `%s'", classname(music_l_))); first_b_ = false; } diff --git a/mf/feta-accordion.mf b/mf/feta-accordion.mf index 2ac7cdecbe..7694cc3a18 100644 --- a/mf/feta-accordion.mf +++ b/mf/feta-accordion.mf @@ -62,6 +62,7 @@ fet_beginchar("accStdbase", "accStdbase", "accStdbase") currentpicture := currentpicture shifted (0, r); fet_endchar; +%%% strange turning path. fet_beginchar("accBayanbase", "accBayanbase", "accBayanbase") save lh; lh = accreg_lh; @@ -143,6 +144,7 @@ def def_some_vars = cTwo = 0.60; enddef; +%%% strange turning path. fet_beginchar("accSB", "accSB", "accSB") set_char_box(.4staffsize#, .4staffsize#, 0, 2.4staff_space#); def_some_vars; @@ -172,6 +174,7 @@ fet_beginchar("accSB", "accSB", "accSB") currentpicture := currentpicture shifted (0, 2.4staff_space); fet_endchar; +%%% strange turning path. fet_beginchar("accBB", "accBB", "accBB") set_char_box(.4staffsize#, .4staffsize#, 0, 2.4staff_space#); def_some_vars; @@ -196,6 +199,7 @@ fet_beginchar("accBB", "accBB", "accBB") fet_endchar; +%%% strange turning path. fet_beginchar("accOldEE", "accOldEE", "accOldEE") set_char_box(staff_space#, staff_space#, 0, 2staff_space#); show w; -- 2.39.5