>From ce815a06b1cc91aa8dfd2a31a782e9a068a6e9d6 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Thu, 1 Apr 2010 17:39:52 -0700 Subject: [PATCH] Add checks for new types in Guile 2.0. In order to preserve backward compatibility with Guile 1.8 and forward compatibility with Guile 2.0 and later, add configure checks to conditionally compile 2 new types used for (internal) hash-fold procedures. Eventually, LilyPond should migrate away from using functions that are intended for internal use, but these checks will suffice for now. --- config.hh.in | 3 +++ configure.in | 7 +++++++ lily/general-scheme.cc | 2 +- lily/include/ly-module.hh | 7 +++++-- lily/ly-module.cc | 9 ++++----- lily/module-scheme.cc | 2 +- lily/scm-hash.cc | 6 ++++-- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/config.hh.in b/config.hh.in index 7f43e21..3bcfa72 100644 --- a/config.hh.in +++ b/config.hh.in @@ -97,3 +97,6 @@ /* define if you have pango FT2 binding */ #define HAVE_PANGO_FT2 0 + +/* define if Guile has types scm_t_hash_fold_fn and scm_t_hash_handle_fn */ +#define HAVE_GUILE_HASH_FUNC 0 diff --git a/configure.in b/configure.in index f7547d1..cc3df1a 100644 --- a/configure.in +++ b/configure.in @@ -112,6 +112,13 @@ STEPMAKE_TEXMF(REQUIRED) STEPMAKE_TEXMF_DIRS STEPMAKE_GUILE_DEVEL(REQUIRED, 1.8.2) +# check for 2 typedefs added in Guile 1.9 +save_CFLAGS="$CFLAGS" +CFLAGS="$GUILE_CFLAGS $CFLAGS" +AC_CHECK_TYPES([scm_t_hash_fold_fn, scm_t_hash_handle_fn], + [AC_DEFINE(HAVE_GUILE_HASH_FUNC)], [], + [#include ]) +CFLAGS="$save_CFLAGS" ## check rational bugfix. save_CPPFLAGS="$CPPFLAGS" diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc index cd7e25d..d409ce0 100644 --- a/lily/general-scheme.cc +++ b/lily/general-scheme.cc @@ -462,7 +462,7 @@ LY_DEFINE (ly_hash_table_keys, "ly:hash-table-keys", 1,0,0, (SCM tab), "Return a list of keys in @var{tab}.") { - return scm_internal_hash_fold ((Hash_closure_function) & accumulate_symbol, + return scm_internal_hash_fold ((scm_t_hash_fold_fn) &accumulate_symbol, NULL, SCM_EOL, tab); } diff --git a/lily/include/ly-module.hh b/lily/include/ly-module.hh index e9ab0b8..f301e59 100644 --- a/lily/include/ly-module.hh +++ b/lily/include/ly-module.hh @@ -33,8 +33,11 @@ SCM ly_clear_anonymous_modules (); void clear_anonymous_modules (); SCM ly_use_module (SCM mod, SCM used); -/* Ugh signature of scm_internal_hash_fold () is inaccurate. */ -typedef SCM (*Hash_closure_function) (GUILE_ELLIPSIS); +/* For backward compatability with Guile 1.8 */ +#if !HAVE_GUILE_HASH_FUNC +typedef SCM (*scm_t_hash_fold_fn) (GUILE_ELLIPSIS); +typedef SCM (*scm_t_hash_handle_fn) (GUILE_ELLIPSIS); +#endif #define MODULE_GC_KLUDGE diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 07fdc53..b5880a0 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -126,7 +126,8 @@ LY_DEFINE (ly_module_2_alist, "ly:module->alist", SCM_VALIDATE_MODULE (1, mod); SCM obarr = SCM_MODULE_OBARRAY (mod); - return scm_internal_hash_fold ((Hash_closure_function) & entry_to_alist, NULL, SCM_EOL, obarr); + return scm_internal_hash_fold ((scm_t_hash_fold_fn) &entry_to_alist, + NULL, SCM_EOL, obarr); } void @@ -188,10 +189,8 @@ make_stand_in_procs_weak () SCM old_tab = scm_stand_in_procs; SCM new_tab = scm_make_weak_key_hash_table (scm_from_int (257)); - new_tab = scm_internal_hash_fold ((Hash_closure_function) & redefine_keyval, - NULL, - new_tab, - old_tab); + new_tab = scm_internal_hash_fold ((scm_t_hash_fold_fn) &redefine_keyval, + NULL, new_tab, old_tab); scm_stand_in_procs = new_tab; } diff --git a/lily/module-scheme.cc b/lily/module-scheme.cc index 192fcf4..b58bf15 100644 --- a/lily/module-scheme.cc +++ b/lily/module-scheme.cc @@ -47,7 +47,7 @@ LY_DEFINE (ly_module_copy, "ly:module-copy", { #define FUNC_NAME __FUNCTION__ SCM_VALIDATE_MODULE (1, src); - scm_internal_hash_fold ((Hash_closure_function) & module_define_closure_func, + scm_internal_hash_fold ((scm_t_hash_fold_fn) &module_define_closure_func, (void *) dest, SCM_EOL, SCM_MODULE_OBARRAY (src)); return SCM_UNSPECIFIED; diff --git a/lily/scm-hash.cc b/lily/scm-hash.cc index bb73d52..058f3be 100644 --- a/lily/scm-hash.cc +++ b/lily/scm-hash.cc @@ -39,7 +39,8 @@ copy_handle (void *closure, SCM handle) static void copy_scm_hashes (SCM dest, SCM src) { - scm_internal_hash_for_each_handle ( (SCM (*)(GUILE_ELLIPSIS)) ©_handle, dest, src); + scm_internal_hash_for_each_handle ((scm_t_hash_handle_fn) ©_handle, + dest, src); } Scheme_hash_table::Scheme_hash_table () @@ -142,7 +143,8 @@ collect_handles (void * /* closure */, SCM Scheme_hash_table::to_alist () const { - return scm_internal_hash_fold ((SCM (*)(GUILE_ELLIPSIS)) &collect_handles, NULL, SCM_EOL, hash_tab_); + return scm_internal_hash_fold ((scm_t_hash_fold_fn) &collect_handles, + NULL, SCM_EOL, hash_tab_); } IMPLEMENT_SMOBS (Scheme_hash_table); -- 1.7.0.3