]> git.donarmstrong.com Git - lilypond.git/blob - lily/lily-guile.cc
release: 1.1.29
[lilypond.git] / lily / lily-guile.cc
1 /*
2   lily-guile.cc -- implement assorted guile functions
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
7
8   Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 */
10
11 #include <stdio.h>
12 #include "libc-extension.hh"
13 #include "lily-guile.hh"
14 #include "main.hh"
15 #include "simple-file-storage.hh"
16 #include "file-path.hh"
17 #include "debug.hh"
18
19
20 /*
21   scm_m_quote doesn't use any env, but needs one for a good signature in GUILE.
22
23   Why there is no gh_quote () in GUILE  beats me.
24 */
25
26 SCM
27 ly_quote_scm (SCM s)
28 {
29   return scm_cons2 (scm_i_quote, s, SCM_EOL);
30 }
31
32 /*
33   See: libguile/symbols.c
34
35   SCM
36   scm_string_to_symbol(s)
37   
38 */
39 SCM
40 ly_symbol (String name)
41 {
42   return gh_car (scm_intern (name.ch_C(), name.length_i()));
43 }
44
45 String
46 symbol_to_string (SCM s)
47 {
48   return String((Byte*)SCM_CHARS (s), (int) SCM_LENGTH(s));
49 }
50
51 SCM
52 ly_set_scm (String name, SCM val)
53 {
54   return scm_sysintern (name.ch_C(), val);
55   
56 }
57 /**
58
59    Read a file, and shove it down GUILE.  GUILE also has file read
60    functions, but you can't fiddle with the path of those.
61    
62  */
63 void
64 read_lily_scm_file (String fn)
65 {
66   String s = global_path.find (fn);
67   if (s == "")
68     {
69       String e = _f ("Can not find file `%s\'", fn);
70       e += " ";
71       e += _f ("(Load path is `%s\'", global_path.str ());
72       error (e);
73     }
74   else
75     *mlog << '[' << s;
76
77
78   Simple_file_storage f(s);
79   
80   gh_eval_str ((char *) f.ch_C());
81   *mlog << ']' << flush;  
82 }
83
84
85 void
86 ly_display_scm (SCM s)
87 {
88   gh_display (s);
89   gh_newline ();
90 }