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.
Add any compatibility definitions here for Guile V2.n
*/
#endif // SCM_MAJOR_VERSION == 1
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 */
#endif /* GUILE_COMPATIBILITY_HH */
along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
-#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"
#include "warn.hh"
#include "main.hh"
#include "std-string.hh"
return SCM_UNSPECIFIED;
}
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);
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