Workaround for broken MusicXML files (percussion clef in MuseScore)
[lilypond.git] / lily / music-function.cc
blobd093f25a9581a63045c3c6ca060668484f1427a9
1 /*
2 music-function.cc -- implement music_function
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "music-function.hh"
11 #include "music.hh"
13 static scm_t_bits music_function_tag;
15 /* Print a textual represenation of the smob to a given port. */
16 static int
17 print_music_function (SCM b, SCM port, scm_print_state *)
19 SCM value = SCM_CELL_OBJECT_1 (b);
21 scm_puts ("#<Music function ", port);
22 scm_write (value, port);
23 scm_puts (">", port);
25 /* Non-zero means success. */
26 return 1;
29 bool
30 is_music_function (SCM music_function)
32 return (SCM_NIMP (music_function) && SCM_CELL_TYPE (music_function) == music_function_tag);
35 SCM
36 get_music_function_transform (SCM music_function)
38 if (!is_music_function (music_function))
39 return SCM_UNDEFINED;
41 return SCM_CELL_OBJECT_1 (music_function);
44 static void
45 init_music_function (void)
47 music_function_tag = scm_make_smob_type ("music-function", 0);
48 scm_set_smob_mark (music_function_tag, scm_markcdr);
49 scm_set_smob_print (music_function_tag, print_music_function);
52 SCM
53 make_music_function (SCM signature, SCM func)
55 scm_set_object_property_x (func, ly_symbol2scm ("music-function-signature"),
56 signature);
58 SCM_RETURN_NEWSMOB (music_function_tag, func);
61 ADD_SCM_INIT_FUNC (music_function_tag, init_music_function);