>From a12cb1e44df280a1f4320d2be1ebb34711f979f4 Mon Sep 17 00:00:00 2001 From: Ian Hulin Date: Mon, 18 Oct 2010 20:20:07 +0100 Subject: [PATCH] T1265 - Remove deprecation warnings when running with Guile V2 Replace scm_str2symbol with scm_from_locale_symbol, scm_symbol2_string with scm_to_locale_symbol, also scm_num2int, scm_int2num, scm_num2double --- flower/include/guile-compatibility.hh | 85 ++++++--------------------------- lily/dispatcher.cc | 6 +- lily/grob-array-scheme.cc | 4 +- lily/include/lily-guile-macros.hh | 12 ++-- lily/open-type-font.cc | 6 +- lily/paper-book.cc | 6 +- lily/paper-def.cc | 2 +- lily/parse-scm.cc | 2 +- lily/parser.yy | 6 +- lily/percent-repeat-iterator.cc | 6 +- lily/piano-pedal-engraver.cc | 6 +- lily/translator.cc | 2 +- 12 files changed, 44 insertions(+), 99 deletions(-) diff --git a/flower/include/guile-compatibility.hh b/flower/include/guile-compatibility.hh index f18c182..bab8325 100644 --- a/flower/include/guile-compatibility.hh +++ b/flower/include/guile-compatibility.hh @@ -20,75 +20,20 @@ #ifndef GUILE_COMPATIBILITY_HH #define GUILE_COMPATIBILITY_HH -#if SCM_MINOR_VERSION < 7 -/* guile-1.6.x compatibility */ - -inline SCM scm_cdr (SCM x) -{ - if (SCM_NCONSP (x)) - abort (); - return SCM_CDR (x); -} -inline SCM scm_car (SCM x) -{ - if (SCM_NCONSP (x)) - abort (); - return SCM_CAR (x); -} -#define SCM_I_CONSP(x) SCM_CONSP (x) -inline SCM scm_caar (SCM x) { return SCM_CAAR (x); } -inline SCM scm_cdar (SCM x) { return SCM_CDAR (x); } -inline SCM scm_cadr (SCM x) { return SCM_CADR (x); } -inline SCM scm_cddr (SCM x) { return SCM_CDDR (x); } -inline SCM scm_caddr (SCM x) { return SCM_CADDR (x); } -inline SCM scm_cdadr (SCM x) { return SCM_CDADR (x); } -inline SCM scm_caadr (SCM x) { return SCM_CAADR (x); } -inline SCM scm_cadar (SCM x) { return SCM_CADAR (x); } -#define scm_gc_unregister_collectable_memory(a, b, c) scm_done_free (b) -#define scm_gc_register_collectable_memory(a, b, c) scm_done_malloc (b) -#define scm_is_vector(x) (SCM_VECTORP ((SCM) x)) -#define SCM_HASHTABLE_P(x) (SCM_VECTORP ((SCM) x)) -#define SCM_VECTOR_REF(v, i) (SCM_VELTS ((v))[ (i)]) -#define scm_from_bool(x) (x ? SCM_BOOL_T : SCM_BOOL_F) -#define scm_from_int(x) SCM_MAKINUM (x) -#define scm_from_unsigned_integer(x) scm_uint2num (x) -#define scm_from_unsigned(x) scm_uint2num (x) -#define scm_from_uint32(x) scm_uint2num (x) -#define scm_is_integer(x) SCM_INUMP (x) -#define scm_is_string(x) SCM_STRINGP (x) -#define scm_hash_table_p scm_vector_p -#define scm_from_locale_stringn(s, n) scm_mem2string (s, n) -#define scm_from_locale_string(x) scm_makfrom0str (x) -#define scm_i_string_chars(x) SCM_STRING_CHARS (x) -#define scm_i_string_length(x) SCM_STRING_LENGTH (x) -inline int ly_c_number_p (SCM x) { return SCM_NUMBERP (x); } -#define scm_is_number(x) (scm_number_p (x) == SCM_BOOL_T) -inline int ly_scm2int (SCM x) { return scm_num2int (x, 0, "ly_scm2int"); } -#define scm_to_int(x) (ly_scm2int (x)) -inline int ly_scm2unsigned (SCM x) { return scm_num2uint (x, 0, "ly_scm2unsigned"); } -#define scm_to_unsigned(x) (ly_scm2unsigned (x)) -inline int ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); } -#define scm_is_symbol(x) ly_c_symbol_p (x) -inline int ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); } -#define scm_is_bool(x) ly_c_boolean_p (x) -inline int ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); } -#define scm_is_eq(x, y) (SCM_EQ_P ((x), (y))) - -#define scm_c_string_length(x) SCM_STRING_LENGTH (x) -#define scm_is_pair(x) (SCM_CONSP (x)) - -#define scm_c_vector_length(x) SCM_VECTOR_LENGTH (x) -#define scm_c_vector_ref(x, y) SCM_VECTOR_REF (x, y) - -inline double ly_scm2double (SCM x) { return scm_num2dbl (x, "ly_scm2double"); } -#define scm_to_double(x) (ly_scm2double (x)) -#define scm_from_double(x) (scm_make_real (x)) - -#else /* !SCM_MINOR_VERSION < 7 */ - -#define scm_to_unsigned(x) scm_to_uint32 (x) +#if SCM_MAJOR_VERSION == 1 +#if SCM_MINOR_VERSION > 6 && SCM_MINOR_VERSION < 9 +/* + GUILE V1.7.0 - V1.8.n +*/ #define scm_from_unsigned(x) scm_from_unsigned_integer (x) - -#endif /* !SCM_MINOR_VERSION < 7 */ - +#else // SCM_MINOR_VERSION >= 9 +/* + GUILE V1.9.n +*/ +#endif // SCM_MINOR_VERSION > 6 && SCM_MINOR_VERSION < 9 +#else // SCM_MAJOR_VERSION != 1 +/* + Add any compatibility definitions here for Guile V2.n +*/ +#endif // SCM_MAJOR_VERSION == 1 #endif /* GUILE_COMPATIBILITY_HH */ diff --git a/lily/dispatcher.cc b/lily/dispatcher.cc index b91b4fa..7507501 100644 --- a/lily/dispatcher.cc +++ b/lily/dispatcher.cc @@ -185,7 +185,7 @@ Dispatcher::internal_add_listener (Listener l, SCM ev_class, int priority) SCM list = scm_hashq_ref (listeners_, ev_class, SCM_EOL); if (!scm_is_pair (list)) { - /* Tell all dispatchers that we listen to, that we want to hear ev_class + /* Tell all dispatchers that we listen to, that we want to hear ev_class events */ for (SCM disp = dispatchers_; scm_is_pair (disp); disp = scm_cdr (disp)) { @@ -195,7 +195,7 @@ Dispatcher::internal_add_listener (Listener l, SCM ev_class, int priority) } listen_classes_ = scm_cons (ev_class, listen_classes_); } - SCM entry = scm_cons (scm_int2num (priority), l.smobbed_copy ()); + SCM entry = scm_cons (scm_from_int (priority), l.smobbed_copy ()); list = scm_merge (list, scm_list_1 (entry), ly_lily_module_constant ("car<")); scm_hashq_set_x (listeners_, ev_class, list); } @@ -255,7 +255,7 @@ Dispatcher::register_as_listener (Dispatcher *disp) return; } - dispatchers_ = scm_acons (disp->self_scm (), scm_int2num (priority), dispatchers_); + dispatchers_ = scm_acons (disp->self_scm (), scm_from_int (priority), dispatchers_); Listener list = GET_LISTENER (dispatch); for (SCM cl = listen_classes_; scm_is_pair (cl); cl = scm_cdr (cl)) diff --git a/lily/grob-array-scheme.cc b/lily/grob-array-scheme.cc index 1c10f64..d99cb58 100644 --- a/lily/grob-array-scheme.cc +++ b/lily/grob-array-scheme.cc @@ -42,9 +42,9 @@ LY_DEFINE (ly_grob_array_ref, "ly:grob-array-ref", LY_ASSERT_SMOB (Grob_array, grob_arr, 1); LY_ASSERT_TYPE (scm_is_integer, index, 2); - vsize i = scm_to_unsigned (index); + vsize i = scm_to_uint (index); if (i == VPOS || i >= me->size ()) - scm_out_of_range (NULL, scm_from_unsigned (i)); + scm_out_of_range (NULL, scm_from_unsigned_integer (i)); return me->grob (i)->self_scm (); } diff --git a/lily/include/lily-guile-macros.hh b/lily/include/lily-guile-macros.hh index b86c317..f4cd79c 100644 --- a/lily/include/lily-guile-macros.hh +++ b/lily/include/lily-guile-macros.hh @@ -41,7 +41,7 @@ /* this lets us "overload" macros such as get_property to take symbols as well as strings */ inline SCM -scm_or_str2symbol (char const *c) { return scm_str2symbol (c); } +scm_or_str2symbol (char const *c) { return scm_from_locale_symbol (c); } inline SCM scm_or_str2symbol (SCM s) { @@ -49,7 +49,7 @@ scm_or_str2symbol (SCM s) { return s; } -/* Using this trick we cache the value of scm_str2symbol ("fooo") where +/* Using this trick we cache the value of scm_from_locale_symbol ("fooo") where "fooo" is a constant string. This is done at the cost of one static variable per ly_symbol2scm() use, and one boolean evaluation for every call. @@ -69,7 +69,7 @@ scm_or_str2symbol (SCM s) { value; \ }) #else -inline SCM ly_symbol2scm (char const *x) { return scm_str2symbol ((x)); } +inline SCM ly_symbol2scm (char const *x) { return scm_from_locale_symbol ((x)); } #endif /* @@ -87,11 +87,11 @@ inline SCM ly_symbol2scm (char const *x) { return scm_str2symbol ((x)); } if (__builtin_constant_p ((x))) \ { \ if (!cached) \ - value = cached = scm_eval (scm_str2symbol (x), \ - global_lily_module); \ + value = cached = scm_eval (scm_from_locale_symbol (x), \ + global_lily_module); \ } \ else \ - value = scm_eval (scm_str2symbol (x), global_lily_module); \ + value = scm_eval (scm_from_locale_symbol (x), global_lily_module); \ value; \ }) diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index 6be9dc4..e7081b6 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -172,7 +172,7 @@ Open_type_font::get_indexed_char_dimensions (size_t signed_idx) const if (SCM_HASHTABLE_P (lily_index_to_bbox_table_)) { SCM box = scm_hashq_ref (lily_index_to_bbox_table_, - scm_from_unsigned (signed_idx), SCM_BOOL_F); + scm_from_unsigned_integer (signed_idx), SCM_BOOL_F); Box *box_ptr = Box::unsmob (box); if (box_ptr) return *box_ptr; @@ -208,7 +208,7 @@ Open_type_font::get_indexed_char_dimensions (size_t signed_idx) const b.scale (point_constant); scm_hashq_set_x (lily_index_to_bbox_table_, - scm_from_unsigned (signed_idx), + scm_from_unsigned_integer (signed_idx), b.smobbed_copy ()); return b; } @@ -270,7 +270,7 @@ Open_type_font::design_size () const which will trip errors more quickly. --hwn. */ - scm_from_unsigned (1)); + scm_from_unsigned_integer (1)); return scm_to_double (entry) * Real (point_constant); } diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 33998a1..94eb705 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -134,7 +134,7 @@ Paper_book::output_aux (SCM output_channel, scm_call_3 (proc, performances (), output_channel, - scm_long2num (*first_performance_number)); + scm_from_long (*first_performance_number)); *first_performance_number += scm_ilength (performances_); } @@ -155,7 +155,7 @@ Paper_book::output_aux (SCM output_channel, if (scores_ == SCM_EOL) return 0; paper_->set_variable (ly_symbol2scm ("first-page-number"), - scm_long2num (*first_page_number)); + scm_from_long (*first_page_number)); paper_->set_variable (ly_symbol2scm ("is-last-bookpart"), ly_bool2scm (is_last)); /* Generate all stencils to trigger font loads. */ @@ -245,7 +245,7 @@ Paper_book::classic_output_aux (SCM output, scm_call_3 (proc, performances (), output, - scm_long2num (*first_performance_number)); + scm_from_long (*first_performance_number)); *first_performance_number += scm_ilength (performances_); } diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 5034376..dd8f97a 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -115,7 +115,7 @@ Output_def * scale_output_def (Output_def *o, Real amount) { SCM proc = ly_lily_module_constant ("scale-layout"); - SCM new_pap = scm_call_2 (proc, o->self_scm (), scm_double2num (amount)); + SCM new_pap = scm_call_2 (proc, o->self_scm (), scm_from_double (amount)); o = unsmob_output_def (new_pap); o->protect (); diff --git a/lily/parse-scm.cc b/lily/parse-scm.cc index a8c6f65..9f6ff8b 100644 --- a/lily/parse-scm.cc +++ b/lily/parse-scm.cc @@ -40,7 +40,7 @@ internal_ly_parse_scm (Parse_start *ps) int off = ps->start_location_.start () - sf->c_str (); - scm_seek (port, scm_long2num (off), scm_long2num (SEEK_SET)); + scm_seek (port, scm_from_long (off), scm_from_long (SEEK_SET)); SCM from = scm_ftell (port); scm_set_port_line_x (port, scm_from_int (ps->start_location_.line_number () -1)); diff --git a/lily/parser.yy b/lily/parser.yy index fcde80e..abcf101 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -907,13 +907,13 @@ output_def_body: tempo_event: TEMPO steno_duration '=' bare_unsigned { - $$ = MAKE_SYNTAX ("tempo", @$, SCM_BOOL_F, $2, scm_int2num ($4)); + $$ = MAKE_SYNTAX ("tempo", @$, SCM_BOOL_F, $2, scm_from_int ($4)); } | TEMPO string steno_duration '=' bare_unsigned { - $$ = MAKE_SYNTAX ("tempo", @$, make_simple_markup($2), $3, scm_int2num ($5)); + $$ = MAKE_SYNTAX ("tempo", @$, make_simple_markup($2), $3, scm_from_int ($5)); } | TEMPO full_markup steno_duration '=' bare_unsigned { - $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, scm_int2num ($5)); + $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, scm_from_int ($5)); } | TEMPO string { $$ = MAKE_SYNTAX ("tempoText", @$, make_simple_markup($2) ); diff --git a/lily/percent-repeat-iterator.cc b/lily/percent-repeat-iterator.cc index 666e242..c41bbed 100644 --- a/lily/percent-repeat-iterator.cc +++ b/lily/percent-repeat-iterator.cc @@ -54,11 +54,11 @@ Percent_repeat_iterator::get_music_list () const percent->set_spot (*mus->origin ()); percent->set_property ("length", length); if (repeats > 1) - percent->set_property ("repeat-count", scm_int2num (i)); - + percent->set_property ("repeat-count", scm_from_int (i)); + child_list = scm_cons (percent->unprotect (), child_list); } - + child_list = scm_cons (child->self_scm (), child_list); return child_list; diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index d708ddf..55e0d4e 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -168,9 +168,9 @@ init_pedal_types () be careful, as we don't want to loose references to the _sym_ members. */ Pedal_type_info info; - info.event_class_sym_ = scm_str2symbol ((base_ident + "-event").c_str ()); - info.style_sym_ = scm_str2symbol (("pedal" + base_name + "Style").c_str ()); - info.strings_sym_ = scm_str2symbol (("pedal" + base_name + "Strings").c_str ()); + info.event_class_sym_ = scm_from_locale_symbol ((base_ident + "-event").c_str ()); + info.style_sym_ = scm_from_locale_symbol (("pedal" + base_name + "Style").c_str ()); + info.strings_sym_ = scm_from_locale_symbol (("pedal" + base_name + "Strings").c_str ()); info.base_name_ = name; info.pedal_c_str_ = strdup ((base_name + "Pedal").c_str ()); diff --git a/lily/translator.cc b/lily/translator.cc index 64cff83..d793178 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -186,7 +186,7 @@ Translator::add_translator_listener (translator_listener_record **listener_list, name = replace_all (&name, '_', '-'); name += "-event"; - SCM class_sym = scm_str2symbol (name.c_str ()); + SCM class_sym = scm_from_locale_symbol (name.c_str ()); add_listened_event_class (class_sym); -- 1.7.0.4