1 #include "music-function.hh"
3 LY_DEFINE (ly_music_function_p, "ly:music-function?", 1, 0, 0,
5 "Is @var{x} a @code{music-function}?")
7 return is_music_function (x) ? SCM_BOOL_T : SCM_BOOL_F;
10 LY_DEFINE (ly_music_function_extract, "ly:music-function-extract", 1, 0, 0,
12 "Return the Scheme function inside@tie{}@var{x}.")
14 LY_ASSERT_TYPE (is_music_function, x, 1);
16 return SCM_CELL_OBJECT_1 (x);
19 LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0,
20 (SCM signature, SCM func),
21 "Make a function to process music, to be used for the"
22 " parser. @var{func} is the function, and @var{signature}"
23 " describes its arguments. @var{signature}'s cdr is a list"
24 " containing either @code{ly:music?} predicates or other type"
25 " predicates. Its car is the syntax function to call.")
27 LY_ASSERT_TYPE (ly_is_list, signature, 1);
28 LY_ASSERT_TYPE (ly_is_procedure, func, 2);
30 for (SCM p = signature; scm_is_pair (p); p = scm_cdr (p), ++n)
32 SCM proc = scm_car (p);
33 if (scm_is_pair (proc))
34 proc = scm_car (proc);
35 if (scm_is_false (scm_procedure_p (proc)))
37 scm_wrong_type_arg_msg ("music-function", n, p,
38 "music function predicate");
42 return make_music_function (signature, func);