From e0af94bb8939bc6f4998db6294010baa77139092 Mon Sep 17 00:00:00 2001 From: Valentin Villenave Date: Tue, 21 Apr 2015 17:57:03 +0200 Subject: Replace C++ (in)equality checks with proper SCM syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit replaces the most straightforward situations where two SCM objects are compared. Here are the basic replacements used: x == y -------> scm_is_eq (x,y) x == SCM_BOOL_T -------> to_boolean (x) x == SCM_BOOL_F -------> scm_is_false (x) x != SCM_BOOL_T -------> scm_is_true (x) x == SCM_UNDEFINED -------> SCM_UNBNDP (x) x == SCM_EOL -------> scm_is_null (x) (scm_exact_p (x) == SCM_BOOL_T) -------> ly_is_rational (x) (scm_integer_p (x) == SCM_BOOL_T) -------> scm_is_integer (x) (scm_list_p (x) == SCM_BOOL_T) -------> ly_is_list (x) (scm_port_p (x) == SCM_BOOL_T) -------> ly_is_port (x) (scm_equal_p (x, y) == SCM_BOOL_T) -------> ly_is_equal (x,y) Finally, I replaced (!cached) with (!SCM_UNPACK (cached)) in lily-guile-macros.hh, as has been suggested once by David. Please note that this commit does not handle some situations I’m less comfortable with (namely those involving scm_c_memq, scm_assq or scm_hashq_get_handle), and some scm_*_p checks for which there isn’t a ly_is_* replacement yet (to wit, scm_hash_table_p, scm_promise_p, and scm_variable_bound_p). Those should be dealt with later (another patch is in the works). --- lily/dynamic-engraver.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lily/dynamic-engraver.cc') diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 8be008f8fb..0bbe69f075 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -107,7 +107,7 @@ Dynamic_engraver::get_property_setting (Stream_event *evt, char const *ctxprop) { SCM spanner_type = evt->get_property (evprop); - if (spanner_type == SCM_EOL) + if (scm_is_null (spanner_type)) spanner_type = get_property (ctxprop); return spanner_type; } @@ -141,7 +141,7 @@ Dynamic_engraver::process_music () SCM cresc_type = get_property_setting (current_span_event_, "span-type", (start_type + "Spanner").c_str ()); - if (cresc_type == ly_symbol2scm ("text")) + if (scm_is_eq (cresc_type, ly_symbol2scm ("text"))) { current_spanner_ = make_spanner ("DynamicTextSpanner", @@ -156,12 +156,13 @@ Dynamic_engraver::process_music () early: this allows dynamics to be spaced individually instead of being linked together. */ - if (current_spanner_->get_property ("style") == ly_symbol2scm ("none")) + if (scm_is_eq (current_spanner_->get_property ("style"), + ly_symbol2scm ("none"))) current_spanner_->set_property ("spanner-broken", SCM_BOOL_T); } else { - if (cresc_type != ly_symbol2scm ("hairpin")) + if (!scm_is_eq (cresc_type, ly_symbol2scm ("hairpin"))) { string as_string = ly_scm_write_string (cresc_type); current_span_event_ @@ -244,9 +245,9 @@ Dynamic_engraver::get_spanner_type (Stream_event *ev) string type; SCM start_sym = scm_car (ev->get_property ("class")); - if (start_sym == ly_symbol2scm ("decrescendo-event")) + if (scm_is_eq (start_sym, ly_symbol2scm ("decrescendo-event"))) type = "decrescendo"; - else if (start_sym == ly_symbol2scm ("crescendo-event")) + else if (scm_is_eq (start_sym, ly_symbol2scm ("crescendo-event"))) type = "crescendo"; else programming_error ("unknown dynamic spanner type"); -- cgit v1.2.3