]> git.donarmstrong.com Git - lilypond.git/commitdiff
Configure: Add backward compat fix for Guile 1.8.
authorPatrick McCarty <pnorcks@gmail.com>
Fri, 2 Apr 2010 00:39:52 +0000 (17:39 -0700)
committerPatrick McCarty <pnorcks@gmail.com>
Sat, 17 Apr 2010 02:16:49 +0000 (19:16 -0700)
Guile 1.9 introduces two new typedefs that are used with the
scm_internal_hash_fold() and scm_internal_hash_for_each_handle()
functions.

To preserve backward compatibility with Guile 1.8, we must check for
these typedefs in Guile's API, and conditionally compile them.

According to the Guile team, these two functions were intended for
internal use (thus their naming convention), so LilyPond should
eventually migrate away from using them.

config.hh.in
configure.in
lily/general-scheme.cc
lily/include/ly-module.hh
lily/ly-module.cc
lily/module-scheme.cc
lily/scm-hash.cc

index 47f057fcbc096c757f64322e713b6473b6efe4ab..338f8eb969fb0c91474d49abbfaa4fbd62e83c9e 100644 (file)
@@ -94,3 +94,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
index 3f6959fa788cb016181c824539fef8e7ab172f72..3f3b4f4d7b83f3df2ffa77440f6000c34a0f5eed 100644 (file)
@@ -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 <libguile.h>])
+CFLAGS="$save_CFLAGS"
 
 ## check rational bugfix.
 save_CPPFLAGS="$CPPFLAGS"
index cd7e25d8c055f052392a6d40a793c5b24bef7a06..d409ce0967813d1503037ff9558f24de7e3cc86a 100644 (file)
@@ -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);
 }
 
index e9ab0b85373c70f660f4d5037615c05cb2f71d5e..0a7fdc8726c7a305fd099eb6a7f6af9a3b8f3a97 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef LY_MODULE_HH
 #define LY_MODULE_HH
 
+#include "config.hh"
 #include "lily-guile.hh"
 
 SCM ly_make_anonymous_module (bool safe);
@@ -33,8 +34,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
 
index 07fdc531ede2f6adfc0ba5474b58548e1757cc8a..b5880a0e9a9cd2d1086af68cae379cdf52ce9385 100644 (file)
@@ -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;
 }
index 192fcf49664d0a08f2fdba8c09d1eead7db3d2c1..b58bf15ffb60981cf584639f0fbe32bb07b0f9fc 100644 (file)
@@ -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;
index bb73d52cd57bc7f90ce7105112be9120215f5d0d..058f3be9d5a79a430597a0cfd4f8df94a11f5c97 100644 (file)
@@ -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)) &copy_handle, dest, src);
+  scm_internal_hash_for_each_handle ((scm_t_hash_handle_fn) &copy_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);