1 #include "music-function.hh"
3 LY_DEFINE (ly_music_function_extract, "ly:music-function-extract", 1, 0, 0,
5 "Return the Scheme function inside@tie{}@var{x}.")
7 LY_ASSERT_SMOB (Music_function, x, 1);
9 return Music_function::unsmob (x)->get_function ();
12 LY_DEFINE (ly_music_function_signature, "ly:music-function-signature", 1, 0, 0,
14 "Return the function signature inside@tie{}@var{x}.")
16 LY_ASSERT_SMOB (Music_function, x, 1);
18 return Music_function::unsmob (x)->get_signature ();
21 LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0,
22 (SCM signature, SCM func),
23 "Make a function to process music, to be used for the"
24 " parser. @var{func} is the function, and @var{signature}"
25 " describes its arguments. @var{signature}'s cdr is a list"
26 " containing either @code{ly:music?} predicates or other type"
27 " predicates. Its car is the syntax function to call.")
29 LY_ASSERT_TYPE (ly_is_list, signature, 1);
30 LY_ASSERT_TYPE (ly_is_procedure, func, 2);
32 for (SCM p = signature; scm_is_pair (p); p = scm_cdr (p), ++n)
34 SCM proc = scm_car (p);
35 if (scm_is_pair (proc))
36 proc = scm_car (proc);
37 if (scm_is_false (scm_procedure_p (proc)))
39 scm_wrong_type_arg_msg ("music-function", n, p,
40 "music function predicate");
44 return Music_function::make_smob (signature, func);