X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmodule-scheme.cc;h=67f642ec08dbcfd41adc007a0c36cba92846aea7;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=4fc43ca32b8c8f846d5373673615ae23a7a9eca8;hpb=d61cf3bbdb1c6670a127ba3baddf2f04d3e34fd3;p=lilypond.git diff --git a/lily/module-scheme.cc b/lily/module-scheme.cc index 4fc43ca32b..67f642ec08 100644 --- a/lily/module-scheme.cc +++ b/lily/module-scheme.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2005--2012 Han-Wen Nienhuys + Copyright (C) 2005--2015 Han-Wen Nienhuys 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 . */ -#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 }