From b89b87d14b6a5b32f46ecdf10dfa0d023a34d3a2 Mon Sep 17 00:00:00 2001 From: Ian Hulin Date: Sun, 16 Sep 2012 22:10:13 +0100 Subject: [PATCH] Issue 2758. ly_module_lookup caused deprecation warnings with Guile V2.06. The V2.17.0 definition of ly_module_lookup in module-scheme.cc uses two functions, scm_sym2var and scm_module_lookup_closure, which issue deprecation warnings in Guile V2.06. A call to the new Guile API function, scm_module_variable, provides the functionality for both deprecated routines, but has not been back-ported to Guile V1.8. This patch adds a conditionally-compiled block when running with a Guile version < V2.0, so that Guile V1 will not use the deprecated scm_ calls in ly_module_lookup, and Guile V2 will use API call scm_module_variable. --- flower/include/guile-compatibility.hh | 8 ++++++++ lily/module-scheme.cc | 27 ++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/flower/include/guile-compatibility.hh b/flower/include/guile-compatibility.hh index 7c249afe89..3ef0413772 100644 --- a/flower/include/guile-compatibility.hh +++ b/flower/include/guile-compatibility.hh @@ -36,4 +36,12 @@ Add any compatibility definitions here for Guile V2.n */ #endif // SCM_MAJOR_VERSION == 1 +#if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION > 1) +#define GUILEV2 1 +#endif +// TODO - remove GUILE1 definition when support for Guile 1 is dropped. +#if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) +#define GUILEV1 1 +#define GUILEV2 0 +#endif #endif /* GUILE_COMPATIBILITY_HH */ diff --git a/lily/module-scheme.cc b/lily/module-scheme.cc index 4fc43ca32b..d18e507dcd 100644 --- a/lily/module-scheme.cc +++ b/lily/module-scheme.cc @@ -17,8 +17,7 @@ along with LilyPond. If not, see . */ -#include "ly-module.hh" - +#include "ly-module.hh" // pulls in lily-guile.hh and guile-compatibility.hh #include "warn.hh" #include "main.hh" #include "std-string.hh" @@ -52,14 +51,32 @@ LY_DEFINE (ly_module_copy, "ly:module-copy", return SCM_UNSPECIFIED; } -/* Lookup SYM, but don't give error when it is not defined. */ + + +/* Lookup SYM, but don't give error when it is not defined. + N.B. this is only needed when running with Guile versions + prior to V2.0.3, when calls to ly_module_lookup can be replaced + with direct calls to the Guile API scm_module_variable in the + LilyPond codebase. +*/ SCM ly_module_lookup (SCM module, SCM sym) { #define FUNC_NAME __FUNCTION__ SCM_VALIDATE_MODULE (1, module); - - return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); +/* + Issue 2758: + Guile V2 onward has a scm_module_variable API module. + Guile V1.8.7 only has a (module-variable) REPL function. + Replace previous code using undocumented API calls deprecated + in Guile V2. + */ +#if GUILEV1 + static SCM module_variable_func = ly_lily_module_constant ("module-variable"); + return scm_call_2 (module_variable_func, module, sym); +#else + return scm_module_variable (module, sym); +#endif #undef FUNC_NAME } -- 2.39.2