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.
43 return scm_m_quote (scm_cons2 (SCM_EOL, s, SCM_EOL) ,SCM_EOL); // apparently env arg is ignored.
47 See: libguile/symbols.c
50 scm_string_to_symbol(s)
54 ly_symbol (String name)
56 return gh_car (scm_intern ((char*)name.ch_C(), name.length_i()));
60 symbol_to_string (SCM s)
62 return String((Byte*)SCM_CHARS (s), (int) SCM_LENGTH(s));
66 ly_set_scm (String name, SCM val)
68 return scm_sysintern ((char*)name.ch_C(), val);
73 Read a file, and shove it down GUILE. GUILE also has file read
74 functions, but you can't fiddle with the path of those.
77 read_lily_scm_file (String fn)
79 String s = global_path.find (fn);
82 String e = _f ("Can't find file: `%s'", fn);
84 e += _f ("(load path: `%s')", global_path.str ());
91 Simple_file_storage f(s);
93 ly_ch_C_eval_scm ((char *) f.ch_C());
94 *mlog << "]" << flush;
99 ly_gulp_file (SCM name)
101 String fn (ly_scm2string (name));
102 String s = global_path.find (fn);
105 String e = _f ("Can't find file: `%s'", fn);
107 e += _f ("(load path: `%s')", global_path.str ());
114 Simple_file_storage f(s);
115 return ly_ch_C_to_scm (f.ch_C());
119 ly_display_scm (SCM s)
126 ly_scm2string (SCM s)
129 char * p = gh_scm2newstr (s , &len);
138 index_cell (SCM s, Direction d)
141 return (d == LEFT) ? SCM_CAR (s) : SCM_CDR (s);
146 array_to_list (SCM *a , int l)
149 for (int i= l; i--; )
151 list = gh_cons (a[i], list);
159 assert (gh_string_p (str));
160 warning ("lily-guile: " + ly_scm2string (str));
167 scm_make_gsubr ("ly-warn", 1, 0, 0, (SCM(*)(...))ly_warning);
168 scm_make_gsubr ("ly-gulp-file", 1,0, 0, (SCM(*)(...))ly_gulp_file);
171 extern void init_symbols ();