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 */
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"
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
}