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"
15 #include "simple-file-storage.hh"
16 #include "file-path.hh"
21 return gh_list (a
, SCM_UNDEFINED
);
27 return gh_eval_str ("'quote");
31 scm_m_quote doesn't use any env, but needs one for a good signature in GUILE.
33 Why there is no gh_quote () in GUILE beats me.
39 // return scm_m_quote (s, SCM_UNDEFINED);
40 return scm_cons2 (scm_i_quote
, s
, SCM_EOL
);
47 return gh_call1 (gh_eval_str ("eval"), a
);
53 return gh_eval_str ("'(lambda (o))");
57 ly_func_o (char const* name
)
59 char buf
[200]; // ugh.
60 snprintf (buf
, 200, "'(%s o)", name
);
61 return gh_eval_str (buf
);
66 lambda_scm (String str
, Array
<int> args_arr
)
73 SCM args_scm
= SCM_EOL
;
74 for (int i
= args_arr
.size () - 1; i
>= 0; i
--)
75 args_scm
= gh_cons (gh_int2scm (args_arr
[i
]), args_scm
);
77 gh_append2 (ly_lambda_o (),
78 ly_list1 (gh_append2 (ly_func_o (str
.ch_l ()), args_scm
)));
82 // scm_top_level_env(SCM_CDR(scm_top_level_lookup_closure_var)))
84 lambda_scm (String str
, Array
<Scalar
> args_arr
)
91 SCM args_scm
= SCM_EOL
;
92 for (int i
= args_arr
.size (); i
--; )
93 args_scm
= gh_cons (gh_str02scm (args_arr
[i
].ch_l ()), args_scm
);
95 gh_append2 (ly_lambda_o (),
96 ly_list1 (gh_append2 (ly_func_o (str
.ch_l ()), args_scm
)));
101 lambda_scm (String str
, Array
<Real
> args_arr
)
108 SCM args_scm
= SCM_EOL
;
109 for (int i
= args_arr
.size (); i
--; )
110 args_scm
= gh_cons (gh_double2scm (args_arr
[i
]), args_scm
);
113 gh_append2 (ly_lambda_o (),
114 ly_list1 (gh_append2 (ly_func_o (str
.ch_l ()), args_scm
)));
120 Read a file, and shove it down GUILE. GUILE also has file read
121 functions, but you can't fiddle with the path of those.
126 read_lily_scm_file (String fn
)
128 String s
= global_path
.find (fn
);
129 Simple_file_storage
f(s
);
131 gh_eval_str ((char *) f
.ch_C());