2 lily-guile.cc -- implement assorted guile functions
4 source file of the GNU LilyPond music typesetter
6 (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
8 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "libc-extension.hh"
13 #include "lily-guile.hh"
17 ly_append (SCM a, SCM b)
19 return gh_call2 (gh_eval_str ("append"), a, b);
25 return gh_call1 (gh_eval_str ("list"), a);
31 return gh_eval_str ("'quote");
37 return gh_list (ly_quote (), s, SCM_UNDEFINED);
43 return gh_call1 (gh_eval_str ("eval"), a);
49 return gh_eval_str ("'(lambda (o))");
53 ly_func_o (char const* name)
55 char buf[200]; // ugh.
56 snprintf (buf, 200, "'(%s o)", name);
57 return gh_eval_str (buf);
62 lambda_scm (String str, Array<int> args_arr)
69 SCM args_scm = SCM_EOL;
70 for (int i = args_arr.size () - 1; i >= 0; i--)
71 args_scm = gh_cons (gh_int2scm (args_arr[i]), args_scm);
73 ly_append (ly_lambda_o (),
74 ly_list1 (ly_append (ly_func_o (str.ch_l ()), args_scm)));
79 lambda_scm (String str, Array<Scalar> args_arr)
86 SCM args_scm = SCM_EOL;
87 for (int i = args_arr.size () - 1; i >= 0; i--)
88 args_scm = gh_cons (gh_str02scm (args_arr[i].ch_l ()), args_scm);
90 ly_append (ly_lambda_o (),
91 ly_list1 (ly_append (ly_func_o (str.ch_l ()), args_scm)));
96 lambda_scm (String str, Array<Real> args_arr)
103 SCM args_scm = SCM_EOL;
104 for (int i = args_arr.size () - 1; i >= 0; i--)
105 args_scm = gh_cons (gh_double2scm (args_arr[i]), args_scm);
107 ly_append (ly_lambda_o (),
108 ly_list1 (ly_append (ly_func_o (str.ch_l ()), args_scm)));