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"
26 DECLARE_SIMPLE_SMOBS (Musicfunction);
30 Musicfunction (SCM signature, SCM function):
31 signature_(signature), function_(function) { }
32 SCM get_function () { return function_; }
33 SCM get_signature () { return signature_; }
36 IMPLEMENT_SIMPLE_SMOBS (Musicfunction);
37 IMPLEMENT_DEFAULT_EQUAL_P (Musicfunction);
39 /* Print a textual represenation of the smob to a given port. */
41 Musicfunction::print_smob (SCM b, SCM port, scm_print_state *)
43 scm_puts ("#<Music function ", port);
44 scm_write (Musicfunction::unsmob (b)->get_function (), port);
47 /* Non-zero means success. */
52 is_music_function (SCM music_function)
54 return Musicfunction::unsmob (music_function);
58 get_music_function_transform (SCM music_function)
60 if (!is_music_function (music_function))
63 return Musicfunction::unsmob (music_function)->get_function ();
67 make_music_function (SCM signature, SCM func)
69 return Musicfunction (signature, func).smobbed_copy ();
73 get_music_function_signature (SCM music_function)
75 if (!is_music_function (music_function))
78 return Musicfunction::unsmob (music_function)->get_signature ();
82 Musicfunction::mark_smob (SCM s)
84 Musicfunction *p = Musicfunction::unsmob (s);
85 scm_gc_mark (p->signature_);
86 ASSERT_LIVE_IS_ALLOWED (s);