2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
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 #include "music-function.hh"
23 #include "ly-smobs.icc"
27 DECLARE_SIMPLE_SMOBS (Musicfunction);
31 Musicfunction (SCM signature, SCM function):
32 signature_ (signature), function_ (function) { }
33 SCM get_function () { return function_; }
34 SCM get_signature () { return signature_; }
37 IMPLEMENT_SIMPLE_SMOBS (Musicfunction);
38 IMPLEMENT_DEFAULT_EQUAL_P (Musicfunction);
40 /* Print a textual represenation of the smob to a given port. */
42 Musicfunction::print_smob (SCM b, SCM port, scm_print_state *)
44 scm_puts ("#<Music function ", port);
45 scm_write (Musicfunction::unsmob (b)->get_function (), port);
48 /* Non-zero means success. */
53 is_music_function (SCM music_function)
55 return Musicfunction::unsmob (music_function);
59 get_music_function_transform (SCM music_function)
61 if (!is_music_function (music_function))
64 return Musicfunction::unsmob (music_function)->get_function ();
68 make_music_function (SCM signature, SCM func)
70 return Musicfunction (signature, func).smobbed_copy ();
74 get_music_function_signature (SCM music_function)
76 if (!is_music_function (music_function))
79 return Musicfunction::unsmob (music_function)->get_signature ();
83 Musicfunction::mark_smob (SCM s)
85 Musicfunction *p = Musicfunction::unsmob (s);
86 scm_gc_mark (p->signature_);
87 ASSERT_LIVE_IS_ALLOWED (s);