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 scm_m_quote doesn't use any env, but needs one for a good signature in GUILE.
25 Why there is no gh_quote () in GUILE beats me.
31 return scm_cons2 (scm_i_quote, s, SCM_EOL);
35 See: libguile/symbols.c
38 scm_string_to_symbol(s)
42 ly_symbol (String name)
44 return gh_car (scm_intern (name.ch_C(), name.length_i()));
48 symbol_to_string (SCM s)
50 return String((Byte*)SCM_CHARS (s), (int) SCM_LENGTH(s));
54 ly_set_scm (String name, SCM val)
56 return scm_sysintern (name.ch_C(), val);
61 Read a file, and shove it down GUILE. GUILE also has file read
62 functions, but you can't fiddle with the path of those.
65 read_lily_scm_file (String fn)
67 String s = global_path.find (fn);
70 String e = _f ("Can not find file `%s\'", fn);
72 e += _f ("(Load path is `%s\'", global_path.str ());
79 Simple_file_storage f(s);
81 gh_eval_str ((char *) f.ch_C());
82 *mlog << ']' << flush;
87 ly_gulp_file (SCM name)
89 String fn (ly_scm2string (name));
90 String s = global_path.find (fn);
93 String e = _f ("Can not find file `%s\'", fn);
95 e += _f ("(Load path is `%s\'", global_path.str ());
102 Simple_file_storage f(s);
103 return gh_str02scm (f.ch_C());
107 ly_display_scm (SCM s)
114 ly_scm2string (SCM s)
117 char * p = gh_scm2newstr (s , &len);
126 index_cell (SCM s, Direction d)
129 return (d == LEFT) ? SCM_CAR (s) : SCM_CDR (s);
134 array_to_list (SCM *a , int l)
137 for (int i= l; i--; )
139 list = gh_cons (a[i], list);
147 assert (gh_string_p (str));
148 warning ("lily-guile: " + ly_scm2string (str));
155 scm_make_gsubr ("ly-warn", 1, 0, 0, ly_warning);
156 scm_make_gsubr ("ly-gulp-file", 1,0, 0, ly_gulp_file);
159 extern void init_symbols ();