2 lily-guile.cc -- implement assorted guile functions
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
8 Han-Wen Nienhuys <hanwen@cs.uu.nl>
15 #include "libc-extension.hh"
16 #include "lily-guile.hh"
18 #include "simple-file-storage.hh"
19 #include "file-path.hh"
23 ly_ch_C_to_scm (char const*c)
25 // this all really sucks, guile should take char const* arguments!
26 return gh_str02scm ((char*)c);
30 ly_ch_C_eval_scm (char const*c)
32 // this all really sucks, guile should take char const* arguments!
33 return gh_eval_str ((char*)c);
37 scm_m_quote doesn't use any env, but needs one for a good signature in GUILE.
39 Why there is no gh_quote () in GUILE beats me.
45 return scm_cons2 (scm_i_quote, s, SCM_EOL);
49 See: libguile/symbols.c
52 scm_string_to_symbol(s)
56 ly_symbol (String name)
58 return gh_car (scm_intern ((char*)name.ch_C(), name.length_i()));
62 symbol_to_string (SCM s)
64 return String((Byte*)SCM_CHARS (s), (int) SCM_LENGTH(s));
68 ly_set_scm (String name, SCM val)
70 return scm_sysintern ((char*)name.ch_C(), val);
75 Read a file, and shove it down GUILE. GUILE also has file read
76 functions, but you can't fiddle with the path of those.
79 read_lily_scm_file (String fn)
81 String s = global_path.find (fn);
84 String e = _f ("Can not find file `%s\'", fn);
86 e += _f ("(Load path is `%s\'", global_path.str ());
93 Simple_file_storage f(s);
95 ly_ch_C_eval_scm ((char *) f.ch_C());
96 *mlog << ']' << flush;
101 ly_gulp_file (SCM name)
103 String fn (ly_scm2string (name));
104 String s = global_path.find (fn);
107 String e = _f ("Can not find file `%s\'", fn);
109 e += _f ("(Load path is `%s\'", global_path.str ());
116 Simple_file_storage f(s);
117 return ly_ch_C_to_scm (f.ch_C());
121 ly_display_scm (SCM s)
128 ly_scm2string (SCM s)
131 char * p = gh_scm2newstr (s , &len);
140 index_cell (SCM s, Direction d)
143 return (d == LEFT) ? SCM_CAR (s) : SCM_CDR (s);
148 array_to_list (SCM *a , int l)
151 for (int i= l; i--; )
153 list = gh_cons (a[i], list);
161 assert (gh_string_p (str));
162 warning ("lily-guile: " + ly_scm2string (str));
169 scm_make_gsubr ("ly-warn", 1, 0, 0, (SCM(*)(...))ly_warning);
170 scm_make_gsubr ("ly-gulp-file", 1,0, 0, (SCM(*)(...))ly_gulp_file);
173 extern void init_symbols ();