]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/module-scheme.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / module-scheme.cc
index 4fc43ca32b8c8f846d5373673615ae23a7a9eca8..58fc141f38c4675d7a8be002ef0036d2d7cb45b1 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2005--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2005--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -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,31 @@ 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);
-
+/*
+  Issue 2758:
+    Guile V2 onward has a scm_module_variable API module.
+    Guile V1.8.7 only has a (module-variable) REPL function, however
+    using ly_lily_module_constant ("module-variable") and calling
+    the memoized result is slow.
+ */
+#if GUILEV1
   return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F);
+#else
+  return scm_module_variable (module, sym);
+#endif
 #undef FUNC_NAME
 }