From: fred Date: Tue, 26 Mar 2002 22:42:34 +0000 (+0000) Subject: lilypond-1.3.0 X-Git-Tag: release/1.5.59~2030 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=aca03562529347ad8220a99681f780c43e5a1c3f;p=lilypond.git lilypond-1.3.0 --- diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 69b9a4f6ed..7caf691c79 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -103,49 +103,53 @@ Auto_beam_engraver::consider_end_and_begin (Moment test_mom) /* second guess: property generic time exception */ - Scalar begin = get_property (time_str + "beamAutoBegin", 0); - if (begin.length_i ()) - begin_mom = begin.to_rat (); + SCM begin = get_property (time_str + "beamAutoBegin", 0); + if (SMOB_IS_TYPE_B(Moment, begin)) + begin_mom = * SMOB_TO_TYPE(Moment, begin); - Scalar end = get_property (time_str + "beamAutoEnd", 0); - if (end.length_i ()) - end_mom = end.to_rat (); + SCM end = get_property (time_str + "beamAutoEnd", 0); + if (SMOB_IS_TYPE_B (Moment, end)) + end_mom = * SMOB_TO_TYPE(Moment,end); /* third guess: property time exception, specific for duration type */ if (type_str.length_i ()) { - Scalar end_mult = get_property (time_str + "beamAutoEnd" + type_str, 0); - if (end_mult.length_i ()) - end_mom = end_mult.to_rat (); - Scalar begin_mult = get_property (time_str + "beamAutoBegin" + type_str, 0); - if (begin_mult.length_i ()) - begin_mom = begin_mult.to_rat (); + SCM end_mult = get_property (time_str + "beamAutoEnd" + type_str, 0); + if (SMOB_IS_TYPE_B (Moment, end_mult)) + end_mom = * SMOB_TO_TYPE (Moment,end_mult); + + SCM begin_mult = get_property (time_str + "beamAutoBegin" + type_str, 0); + if (SMOB_IS_TYPE_B (Moment, begin_mult)) + begin_mom = * SMOB_TO_TYPE (Moment,begin_mult); } /* fourth guess [user override]: property plain generic */ begin = get_property ("beamAutoBegin", 0); - if (begin.length_i ()) - begin_mom = begin.to_rat (); + if (SMOB_IS_TYPE_B(Moment, begin)) + begin_mom = * SMOB_TO_TYPE(Moment, begin); + + end = get_property ("beamAutoEnd", 0); - if (end.length_i ()) - end_mom = end.to_rat (); + if (SMOB_IS_TYPE_B (Moment, end)) + end_mom = * SMOB_TO_TYPE (Moment,end); /* fifth guess [user override]: property plain, specific for duration type */ if (type_str.length_i ()) { - Scalar end_mult = get_property (String ("beamAutoEnd") + type_str, 0); - if (end_mult.length_i ()) - end_mom = end_mult.to_rat (); - Scalar begin_mult = get_property (String ("beamAutoBegin") + type_str, 0); - if (begin_mult.length_i ()) - begin_mom = begin_mult.to_rat (); + SCM end_mult = get_property (String ("beamAutoEnd") + type_str, 0); + if (SMOB_IS_TYPE_B (Moment, end_mult)) + end_mom = * SMOB_TO_TYPE (Moment,end_mult); + + SCM begin_mult = get_property (String ("beamAutoBegin") + type_str, 0); + if (SMOB_IS_TYPE_B (Moment, begin_mult)) + begin_mom = * SMOB_TO_TYPE (Moment,begin_mult); } Rational r; @@ -160,8 +164,8 @@ Auto_beam_engraver::consider_end_and_begin (Moment test_mom) /* Allow already started autobeam to end */ - Scalar on = get_property ("noAutoBeaming", 0); - if (on.to_bool ()) + SCM on = get_property ("noAutoBeaming", 0); + if (gh_boolean_p (on) && gh_scm2bool (on)) return; if (begin_mom) @@ -200,20 +204,20 @@ Auto_beam_engraver::create_beam_p () } /* urg, copied from Beam_engraver */ - Scalar prop = get_property ("beamslopedamping", 0); - if (prop.isnum_b ()) - beam_p->set_elt_property (damping_scm_sym, gh_int2scm(prop)); + SCM prop = get_property ("beamslopedamping", 0); + if (SCM_NUMBERP(prop)) + beam_p->set_elt_property (damping_scm_sym, prop); prop = get_property ("autoKneeGap", 0); - if (prop.isnum_b ()) - beam_p->set_elt_property (auto_knee_gap_scm_sym, gh_int2scm(prop)); + if (SCM_NUMBERP(prop)) + beam_p->set_elt_property (auto_knee_gap_scm_sym, prop); prop = get_property ("autoInterstaffKneeGap", 0); - if (prop.isnum_b ()) - beam_p->set_elt_property (auto_interstaff_knee_gap_scm_sym, gh_int2scm( prop)); + if (SCM_NUMBERP(prop)) + beam_p->set_elt_property (auto_interstaff_knee_gap_scm_sym, prop); prop = get_property ("beamquantisation", 0); - if (prop.isnum_b ()) + if (SCM_NUMBERP(prop)) beam_p->quantisation_ = (Beam::Quantisation)(int)prop; announce_element (Score_element_info (beam_p, 0)); @@ -281,7 +285,7 @@ Auto_beam_engraver::do_removal_processing () { /* finished beams may be typeset */ typeset_beam (); - /* but unfinished may need another announce/acknoledge pass */ + /* but unfinished may need another announce/acknowledge pass */ if (stem_l_arr_p_) junk_beam (); } @@ -289,9 +293,9 @@ Auto_beam_engraver::do_removal_processing () bool Auto_beam_engraver::same_grace_state_b (Score_element* e) { - bool gr = (e->get_elt_property (grace_scm_sym) != SCM_BOOL_F) ; - - return gr == get_property ("weAreGraceContext",0).to_bool (); + bool gr = e->get_elt_property (grace_scm_sym) != SCM_BOOL_F; + SCM wg =get_property ("weAreGraceContext",0); + return (gh_boolean_p (wg) && gh_scm2bool (wg)) == gr; } void diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index 2aa4904054..5811e6dc86 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -35,25 +35,24 @@ Bar_engraver::create_bar () bar_p_->set_elt_property (break_priority_scm_sym, gh_int2scm (0)); // urg: "" != empty... - String default_type = get_property ("defaultBarType", 0); - if (default_type.length_i ()) + SCM default_type = get_property ("defaultBarType", 0); + if (gh_string_p (default_type)) { - bar_p_->type_str_ = default_type; + bar_p_->type_str_ = ly_scm2string (default_type); } /* urg. Why did I implement this? */ - Scalar prop = get_property ("barAtLineStart", 0); - if (prop.to_bool ()) + SCM prop = get_property ("barAtLineStart", 0); + if (gh_boolean_p (prop) && gh_scm2bool (prop)) { bar_p_->set_elt_property (at_line_start_scm_sym, SCM_BOOL_T); } prop = get_property ("barSize", 0); - if (prop.isnum_b ()) + if (SCM_NUMBERP(prop)) { - bar_p_->set_elt_property (bar_size_scm_sym, - gh_double2scm (Real(prop))); + bar_p_->set_elt_property (bar_size_scm_sym, prop); } announce_element (Score_element_info (bar_p_, 0)); } @@ -67,11 +66,10 @@ Bar_engraver::create_bar () void Bar_engraver::request_bar (String requested_type) { - Scalar prop = get_property ("barAtLineStart", 0); if (!now_mom ()) { - Scalar prop = get_property ("barAtLineStart", 0); - if (!prop.to_bool ()) + SCM prop = get_property ("barAtLineStart", 0); + if (!gh_boolean_p (prop) && gh_scm2bool (prop)) return; } bool bar_existed = bar_p_; diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 5ba4ed9306..6022a0a578 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -99,21 +99,21 @@ Beam_engraver::do_process_requests () /* urg, must copy to Auto_beam_engraver too */ - Scalar prop = get_property ("beamslopedamping", 0); - if (prop.isnum_b ()) - beam_p_->set_elt_property (damping_scm_sym, gh_int2scm( prop)); + SCM prop = get_property ("beamslopedamping", 0); + if (SCM_NUMBERP(prop)) + beam_p_->set_elt_property (damping_scm_sym, prop); prop = get_property ("autoKneeGap", 0); - if (prop.isnum_b ()) - beam_p_->set_elt_property (auto_knee_gap_scm_sym, gh_int2scm( prop)); + if (SCM_NUMBERP(prop)) + beam_p_->set_elt_property (auto_knee_gap_scm_sym, prop); prop = get_property ("autoInterstaffKneeGap", 0); - if (prop.isnum_b ()) - beam_p_->set_elt_property (auto_interstaff_knee_gap_scm_sym, gh_int2scm( prop)); + if (SCM_NUMBERP(prop)) + beam_p_->set_elt_property (auto_interstaff_knee_gap_scm_sym, prop); prop = get_property ("beamquantisation", 0); - if (prop.isnum_b ()) - beam_p_->quantisation_ = (Beam::Quantisation)(int)prop; + if (SCM_NUMBERP(prop)) + beam_p_->quantisation_ = (Beam::Quantisation)gh_scm2int(prop); announce_element (Score_element_info (beam_p_, reqs_drul_[START])); } @@ -173,7 +173,10 @@ Beam_engraver::acknowledge_element (Score_element_info info) bool stem_grace = stem_l->get_elt_property (grace_scm_sym) != SCM_BOOL_F; - if (get_property ("weAreGraceContext",0).to_bool () != stem_grace) + SCM wg =get_property ("weAreGraceContext",0); + bool wgb= gh_boolean_p (wg) && gh_scm2bool (wg); + + if (wgb!= stem_grace) return; Rhythmic_req *rhythmic_req = dynamic_cast (info.req_l_); diff --git a/lily/breathing-sign-engraver.cc b/lily/breathing-sign-engraver.cc index e9f243532b..2259c17097 100644 --- a/lily/breathing-sign-engraver.cc +++ b/lily/breathing-sign-engraver.cc @@ -21,7 +21,6 @@ TODO: #include "note-head.hh" #include "local-key-item.hh" -#include Breathing_sign_engraver::Breathing_sign_engraver() { @@ -46,9 +45,9 @@ Breathing_sign_engraver::do_process_requests() if(breathing_sign_req_l_) { breathing_sign_p_ = new Breathing_sign; - Scalar prop = get_property ("verticalDirection", 0); - if(prop.isnum_b()) - breathing_sign_p_->set_vertical_position((Direction)int(prop)); + SCM prop = get_property ("verticalDirection", 0); + if(isdir_b(prop)) + breathing_sign_p_->set_vertical_position(to_dir (prop)); announce_element (Score_element_info (breathing_sign_p_, breathing_sign_req_l_)); } diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index 487514ff26..d0005c8983 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -56,8 +56,8 @@ Chord_name_engraver::do_process_requests () Chord chord (pitch_arr_); Musical_pitch* inversion = 0; - Scalar chord_inversion = get_property ("chordInversion", 0); - if (chord_inversion.to_bool ()) + SCM chord_inversion = get_property ("chordInversion", 0); + if (gh_boolean_p (chord_inversion) && gh_scm2bool (chord_inversion)) { int tonic_i = tonic_req_ ? chord.find_notename_i (tonic_req_->pitch_) : chord.find_tonic_i (); @@ -76,16 +76,16 @@ Chord_name_engraver::do_process_requests () - switch on property, add american (?) chordNameStyle: Chord::american_str (...) - Scalar chordNameStyle = get_property ("chordNameStyle", 0); + SCM chordNameStyle = get_property ("chordNameStyle", 0); if (chordNameStyle == "Banter") item_p->text_str_ = chord.banter_str (inversion); */ item_p->text_str_ = chord.banter_str (inversion); - Scalar style = get_property ("textStyle", 0); - if (style.length_i ()) - item_p->style_str_ = style; + SCM style = get_property ("textStyle", 0); + if (gh_string_p (style)) + item_p->style_str_ = ly_scm2string (style); text_p_arr_.push (item_p); announce_element (Score_element_info (item_p, 0)); diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 4c3db32bb4..2933131c8d 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -114,9 +114,6 @@ Dynamic_engraver::do_process_requests() text_p_ = new Text_item; text_p_->text_str_ = loud; // ugh - Scalar prop = get_property ("dynamicStyle", 0); - - text_p_->style_str_ = prop.length_i () ? prop : "dynamic"; staff_side_p_ = new Staff_side_item; staff_side_p_->set_elt_property (script_priority_scm_sym, @@ -127,16 +124,16 @@ Dynamic_engraver::do_process_requests() staff_side_p_->dir_ = DOWN; - prop = get_property ("verticalDirection", 0); - if (prop.isdir_b()) + SCM prop = get_property ("verticalDirection", 0); + if (isdir_b (prop)) { - staff_side_p_->dir_ = Direction (int (prop)); + staff_side_p_->dir_ = to_dir (prop); } prop = get_property ("dynamicDirection", 0); - if (prop.isnum_b ()) + if (SCM_NUMBERP(prop)) { - staff_side_p_->dir_ = (Direction) (int) prop; + staff_side_p_->dir_ = to_dir (prop); } if (absd->dir_) { @@ -144,10 +141,9 @@ Dynamic_engraver::do_process_requests() } prop = get_property ("dynamicPadding", 0); - if (prop.isnum_b ()) + if (SCM_NUMBERP(prop)) { - staff_side_p_->set_elt_property (padding_scm_sym, - gh_double2scm(Real(prop))); + staff_side_p_->set_elt_property (padding_scm_sym, prop); } announce_element (Score_element_info (text_p_, absd)); announce_element (Score_element_info (staff_side_p_, absd)); @@ -173,21 +169,20 @@ Dynamic_engraver::do_process_requests() - Scalar prop = get_property ("verticalDirection", 0); - if (prop.isdir_b()) + SCM prop = get_property ("verticalDirection", 0); + if (isdir_b (prop)) { - to_end_ss_span_p_->dir_ = Direction (int (prop)); + to_end_ss_span_p_->dir_ = to_dir (prop); } prop = get_property ("dynamicDirection", 0); - if (prop.isdir_b ()) + if (isdir_b (prop)) { - to_end_ss_span_p_->dir_ = (Direction) (int) prop; + to_end_ss_span_p_->dir_ = to_dir (prop); } prop = get_property ("dynamicPadding", 0); - if (prop.isnum_b ()) + if (SCM_NUMBERP(prop)) { - to_end_ss_span_p_->set_elt_property (padding_scm_sym, - gh_double2scm(Real(prop))); + to_end_ss_span_p_->set_elt_property (padding_scm_sym,prop); } } } diff --git a/lily/grace-position-performer.cc b/lily/grace-position-performer.cc index 41cee8065e..58bdd73d6f 100644 --- a/lily/grace-position-performer.cc +++ b/lily/grace-position-performer.cc @@ -61,9 +61,9 @@ Grace_position_performer::process_acknowledged () shortest_mom = shortest_mom length_mom_; Rational grace_fraction_rat (1, 2); - Scalar prop = get_property ("graceFraction", 0); - if (prop.length_i ()) - grace_fraction_rat = prop.to_rat (); + SCM prop = get_property ("graceFraction", 0); + if (SMOB_IS_TYPE_B(Moment, prop)) + grace_fraction_rat = *SMOB_TO_TYPE (Moment,prop); delay_mom = shortest_mom * grace_fraction_rat; for (int i=0; i < notes_.size (); i++) diff --git a/lily/identifier.cc b/lily/identifier.cc index 0fbaa06185..e8421fb70d 100644 --- a/lily/identifier.cc +++ b/lily/identifier.cc @@ -14,7 +14,7 @@ #include "my-lily-lexer.hh" #include "debug.hh" #include "request.hh" -#include "translator.hh" +#include "translator-group.hh" #include "notename-table.hh" @@ -79,7 +79,7 @@ Class ## _identifier::do_print () const { \ -DEFAULT_PRINT(Translator); +DEFAULT_PRINT(Translator_group); DEFAULT_PRINT(Music); DEFAULT_PRINT(Request); DEFAULT_PRINT(Score); @@ -95,7 +95,7 @@ Class ## _identifier::do_str () const { \ DUMMY_STR(Notename_table); -DUMMY_STR(Translator); +DUMMY_STR(Translator_group); DUMMY_STR(Music); DUMMY_STR(Request); DUMMY_STR(Score); @@ -144,7 +144,7 @@ Class ## _identifier::access_content_ ## Class (bool copy_b) const {\ Class*\ Class ## _identifier::access_content_ ## Class (bool copy_b) const{\ ((Class ## _identifier*)this)->accessed_b_ = true;\ - return copy_b ? (Class*)data_p_->clone() : data_p_;\ + return copy_b ? dynamic_cast (data_p_->clone()) : data_p_;\ } #define IMPLEMENT_ID_CLASS(Class) \ @@ -162,7 +162,7 @@ Class ## _identifier::Class ## _identifier (Class ## _identifier const &s) \ IMPLEMENT_ID_CLASS(Duration); -IMPLEMENT_ID_CLASS(Translator); +IMPLEMENT_ID_CLASS(Translator_group); IMPLEMENT_ID_CLASS(int); IMPLEMENT_ID_CLASS(Real); IMPLEMENT_ID_CLASS(String); @@ -174,7 +174,7 @@ IMPLEMENT_ID_CLASS(Paper_def); IMPLEMENT_ID_CLASS(Notename_table); VIRTUAL_ACCESSOR(Music); VIRTUAL_ACCESSOR(Request); -VIRTUAL_ACCESSOR(Translator); +VIRTUAL_ACCESSOR(Translator_group); DEFAULT_ACCESSOR(Notename_table); DEFAULT_ACCESSOR(Duration); DEFAULT_ACCESSOR(int); diff --git a/lily/include/global-translator.hh b/lily/include/global-translator.hh index 721f97ddaf..00f8ed8204 100644 --- a/lily/include/global-translator.hh +++ b/lily/include/global-translator.hh @@ -11,7 +11,7 @@ #define GLOBAL_TRANSLATOR_HH #include "translator-group.hh" -#include "rational.hh" +#include "moment.hh" #include "pqueue.hh" diff --git a/lily/include/identifier.hh b/lily/include/identifier.hh index 4d705020fb..ded6ac4a0e 100644 --- a/lily/include/identifier.hh +++ b/lily/include/identifier.hh @@ -16,7 +16,7 @@ #define DECLARE_TYPE_NAME(Class) class Notename_table_identifier; -class Translator_identifier; +class Translator_group_identifier; class Music_identifier; class Articulation_req_identifier; class Symtables_identifier; @@ -51,7 +51,7 @@ struct Identifier : public Input { void error (String) const; String str () const; - IDACCESSOR(Translator) + IDACCESSOR(Translator_group) IDACCESSOR(Notename_table) IDACCESSOR(Music) IDACCESSOR(Symtables) @@ -84,7 +84,7 @@ struct Class ## _identifier : Identifier {\ }\ -DECLARE_ID_CLASS(Translator); +DECLARE_ID_CLASS(Translator_group); DECLARE_ID_CLASS(Duration); DECLARE_ID_CLASS(Notename_table); DECLARE_ID_CLASS(Real); diff --git a/lily/include/translation-property.hh b/lily/include/translation-property.hh index 3e55b46a61..8278dd829d 100644 --- a/lily/include/translation-property.hh +++ b/lily/include/translation-property.hh @@ -11,7 +11,8 @@ #define TRANSLATION_PROPERTY_HH #include "music.hh" -#include "scalar.hh" +#include "protected-scm.hh" + /** Set a property of Translator @@ -20,7 +21,8 @@ class Translation_property : public Music { public: String var_str_; - Scalar value_; + Protected_scm value_; + VIRTUAL_COPY_CONS(Music); protected: diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 4868940bb8..00da2cd391 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -16,6 +16,8 @@ #include "translator.hh" #include "cons.hh" #include "parray.hh" +#include "scm-hash.hh" + // egcs typedef void (Translator::*Method_pointer)(void); @@ -28,7 +30,7 @@ class Translator_group : public virtual Translator { Array consists_str_arr_; Array consists_end_str_arr_; Array accepts_str_arr_; - Dictionary properties_dict_; + Scheme_hash_table properties_dict_; int iterator_count_; friend class Interpretation_context_handle; @@ -36,8 +38,8 @@ class Translator_group : public virtual Translator { Cons_list trans_p_list_; public: - Scalar get_property (String type_str, Translator_group **where_found_l) const; - void set_property (String var_name, Scalar value); + SCM get_property (String type_str, Translator_group **where_found_l) const; + void set_property (String var_name, SCM value); String id_str_; @@ -73,10 +75,11 @@ public: Link_array path_to_acceptable_translator (String alias) const; Translator_group*get_default_interpreter(); + virtual ~Translator_group (); + protected: bool try_music_on_nongroup_children (Music *m); - virtual ~Translator_group (); virtual void do_print () const; virtual void do_process_requests (); virtual void do_add_processing (); diff --git a/lily/local-key-engraver.cc b/lily/local-key-engraver.cc index a6a69fec56..8e773bf05a 100644 --- a/lily/local-key-engraver.cc +++ b/lily/local-key-engraver.cc @@ -58,7 +58,8 @@ Local_key_engraver::process_acknowledged () { if (!key_item_p_ && mel_l_arr_.size()) { - bool forget = get_property ("forgetAccidentals",0).to_bool(); + SCM f = get_property ("forgetAccidentals",0); + bool forget = gh_boolean_p (f) && gh_scm2bool(f); for (int i=0; i < mel_l_arr_.size(); i++) { Item * support_l = support_l_arr_[i]; @@ -126,7 +127,9 @@ Local_key_engraver::do_pre_move_processing() void Local_key_engraver::acknowledge_element (Score_element_info info) { - bool selfgr = get_property ("weAreGraceContext", 0).to_bool (); + SCM wg= get_property ("weAreGraceContext", 0); + + bool selfgr = gh_boolean_p (wg) &&gh_scm2bool (wg); bool he_gr = info.elem_l_->get_elt_property (grace_scm_sym) != SCM_BOOL_F; Grace_align_item * gai = dynamic_cast (info.elem_l_); @@ -159,7 +162,8 @@ Local_key_engraver::do_process_requests() Time_description const * time_C_ = get_staff_info().time_C_; if (time_C_ && !time_C_->whole_in_measure_) { - bool no_res = get_property ("noResetKey",0).to_bool (); + SCM n = get_property ("noResetKey",0); + bool no_res = gh_boolean_p (n) && gh_scm2bool (n); if (!no_res && key_grav_l_) local_key_= key_grav_l_->key_; } diff --git a/lily/lyric-engraver.cc b/lily/lyric-engraver.cc index 37aa4065ee..080546f2f5 100644 --- a/lily/lyric-engraver.cc +++ b/lily/lyric-engraver.cc @@ -44,9 +44,9 @@ Lyric_engraver::do_process_requests() text_p_->text_str_ = req_l_->text_str_; text_p_->text_str_ += " "; // ugh. - Scalar style = get_property ("textStyle", 0); - if (style.length_i ()) - text_p_->style_str_ = style; + SCM style = get_property ("textStyle", 0); + if (gh_string_p(style)) + text_p_->style_str_ = ly_scm2string (style); text_p_->set_elt_property (non_rhythmic_scm_sym, SCM_BOOL_T);