2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2015 by David Kastrup <dak@gnu.org>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef LILY_MODULES_HH
21 #define LILY_MODULES_HH
23 #include "lily-guile.hh"
31 class Variable_record;
32 Variable_record *variables_;
33 static void boot_init (void *);
35 void boot (void (*init)() = 0);
37 void register_variable (const char *name, Scm_variable *var);
39 Scm_module (const char *name);
43 assert (SCM_MODULEP (module_));
52 void boot (const char *name);
53 void import (SCM module, const char *name);
58 // One could conceivably work with variables even before the
59 // module is initialized
60 return SCM_VARIABLEP (var_) ? *SCM_VARIABLE_LOC (var_) : var_;
63 assert (SCM_VARIABLEP (var_));
65 return *SCM_VARIABLE_LOC (var_);
69 return scm_call_0 (*this);
71 SCM operator () (SCM arg1)
73 return scm_call_1 (*this, arg1);
75 SCM operator () (SCM arg1, SCM arg2)
77 return scm_call_2 (*this, arg1, arg2);
79 SCM operator () (SCM arg1, SCM arg2, SCM arg3)
81 return scm_call_3 (*this, arg1, arg2, arg3);
83 SCM operator () (SCM arg1, SCM arg2, SCM arg3, SCM arg4)
85 return scm_call_4 (*this, arg1, arg2, arg3, arg4);
87 Scm_variable (Scm_module &m, const char *name, SCM value = SCM_UNDEFINED);
90 template <Scm_module &m>
91 class Module_variable : public Scm_variable
94 Module_variable (const char *name, SCM value = SCM_UNDEFINED)
95 : Scm_variable (m, name, value)