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);
26 scm_m_quote doesn't use any env, but needs one for a good signature in GUILE.
28 Why there is no gh_quote () in GUILE beats me.
34 // return scm_m_quote (s, SCM_UNDEFINED);
35 return scm_cons2 (scm_i_quote, s, SCM_EOL);
42 return gh_call1 (gh_eval_str ("eval"), a);
48 return gh_eval_str ("'(lambda (o))");
52 ly_func_o (char const* name)
54 char buf[200]; // ugh.
55 snprintf (buf, 200, "'(%s o)", name);
56 return gh_eval_str (buf);
60 See: libguile/symbols.c
63 scm_string_to_symbol(s)
67 ly_symbol (String name)
69 return gh_car (scm_intern (name.ch_C(), name.length_i()));
73 lambda_scm (String str, Array<int> args_arr)
80 SCM args_scm = SCM_EOL;
81 for (int i = args_arr.size () - 1; i >= 0; i--)
82 args_scm = gh_cons (gh_int2scm (args_arr[i]), args_scm);
83 args_scm = gh_cons (ly_symbol (str.ch_l ()), args_scm);
87 // scm_top_level_env(SCM_CDR(scm_top_level_lookup_closure_var)))
89 lambda_scm (String str, Array<Scalar> args_arr)
96 SCM args_scm = SCM_EOL;
97 for (int i = args_arr.size (); i--; )
98 args_scm = gh_cons (gh_str02scm (args_arr[i].ch_l ()), args_scm);
99 args_scm = gh_cons (ly_symbol (str.ch_l ()), args_scm);
104 lambda_scm (String str, Array<Real> args_arr)
111 SCM args_scm = SCM_EOL;
112 for (int i = args_arr.size (); i--; )
113 args_scm = gh_cons (gh_double2scm (args_arr[i]), args_scm);
115 args_scm = gh_cons (ly_symbol (str.ch_l ()), args_scm);
121 Read a file, and shove it down GUILE. GUILE also has file read
122 functions, but you can't fiddle with the path of those.
127 read_lily_scm_file (String fn)
129 String s = global_path.find (fn);
130 Simple_file_storage f(s);
132 gh_eval_str ((char *) f.ch_C());