]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 2758. ly_module_lookup caused deprecation warnings with Guile V2.06.
authorIan Hulin <ian@hulin.org.uk>
Sun, 16 Sep 2012 21:10:13 +0000 (22:10 +0100)
committerIan Hulin <ian@hulin.org.uk>
Sat, 22 Sep 2012 17:24:40 +0000 (18:24 +0100)
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
lily/module-scheme.cc

index 7c249afe893103760a3bdb68445d5fc70506823a..3ef0413772f1dd0c03fee0a7d8f0922310ae00f2 100644 (file)
    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 */
index 4fc43ca32b8c8f846d5373673615ae23a7a9eca8..d18e507dcdda6f95504defe09ba2737c63f3ea8b 100644 (file)
@@ -17,8 +17,7 @@
   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"
@@ -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
 }