]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/lily-guile.hh
* lily/parser.yy (assignment_id): allow LYRICS_STRING as
[lilypond.git] / lily / include / lily-guile.hh
1 /*
2   lily-guile.hh encapsulate guile
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #ifndef LILY_GUILE_HH
10 #define LILY_GUILE_HH
11
12 #include <libguile.h>
13
14 #include "interval.hh"
15 #include "guile-compatibility.hh"
16 #include "lily-guile-macros.hh"
17 #include "ly-module.hh"
18
19
20 /** Conversion functions follow the GUILE naming convention, i.e.
21     A ly_B2A (B b);  */
22
23 SCM ly_last (SCM list);
24 SCM ly_write2scm (SCM s);
25 SCM ly_deep_copy (SCM);
26 SCM ly_truncate_list (int k, SCM lst);
27
28 SCM ly_to_string (SCM scm);
29 SCM ly_to_symbol (SCM scm);
30
31 extern SCM global_lily_module;
32
33 String gulp_file_to_string (String fn, bool must_exist);
34
35 String ly_scm2string (SCM s);
36 String ly_symbol2string (SCM);
37 SCM ly_offset2scm (Offset);
38 Offset ly_scm2offset (SCM);
39 SCM ly_chain_assoc (SCM key, SCM achain);
40 SCM ly_chain_assoc_get (SCM key, SCM achain, SCM dfault);
41 SCM ly_assoc_cdr (SCM key, SCM alist);
42 SCM ly_assoc_get (SCM key, SCM alist, SCM def);
43 Interval ly_scm2interval (SCM);
44 Drul_array<Real> ly_scm2realdrul (SCM);
45 Slice int_list_to_slice (SCM l);
46 SCM ly_interval2scm (Drul_array<Real>);
47 char *ly_scm2newstr (SCM str, size_t *lenp);
48
49 Real robust_scm2double (SCM, double);
50 int robust_scm2int (SCM, int);
51 Drul_array<Real> robust_scm2drul (SCM, Drul_array<Real>);
52 Interval robust_scm2interval (SCM, Drul_array<Real>);
53 Offset robust_scm2offset (SCM, Offset);
54
55 SCM ly_quote_scm (SCM s);
56 bool type_check_assignment (SCM val, SCM sym,  SCM type_symbol) ;
57 String print_scm_val (SCM val);
58 SCM ly_number2string (SCM s);
59
60 SCM parse_symbol_list (char const *);
61 SCM robust_list_ref(int i, SCM l);
62 SCM alist_to_hashq (SCM);
63
64 SCM ly_alist_vals (SCM alist);
65 SCM ly_hash2alist (SCM tab);
66
67 /* inserts at front, removing dublicates */
68 inline SCM ly_assoc_front_x(SCM alist, SCM key, SCM val)
69 {
70   return scm_acons(key, val, scm_assoc_remove_x (alist, key));
71 }
72 inline bool ly_c_list_p (SCM x) { return SCM_NFALSEP (scm_list_p (x)); }
73 inline bool ly_c_procedure_p (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); }
74 inline bool ly_c_equal_p (SCM x, SCM y) {
75   return SCM_NFALSEP (scm_equal_p (x, y));
76 }
77
78
79 inline bool ly_scm2bool (SCM x) { return SCM_NFALSEP (x); }
80 inline char ly_scm2char (SCM x) { return SCM_CHAR(x); }
81 inline unsigned long ly_length (SCM x) {
82   return scm_num2ulong (scm_length (x), 0, "ly_length");
83 }
84 inline SCM ly_bool2scm (bool x) { return SCM_BOOL (x); }
85
86 inline SCM ly_append2 (SCM x1, SCM x2) {
87   return scm_append (scm_listify (x1, x2, SCM_UNDEFINED));
88 }
89 inline SCM ly_append3 (SCM x1, SCM x2, SCM x3) {
90   return scm_append (scm_listify (x1, x2, x3, SCM_UNDEFINED));
91 }
92 inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4) {
93   return scm_append (scm_listify (x1, x2, x3, x4, SCM_UNDEFINED));
94 }
95
96 /*
97   display and print newline.
98  */
99 extern "C" {
100 void ly_display_scm (SCM s);
101 }
102
103 void read_lily_scm_file (String);
104 void ly_c_init_guile ();
105
106 bool is_direction (SCM s);
107 bool is_number_pair (SCM);
108 bool is_axis (SCM);
109
110 /*
111   these conversion functions also do a typecheck on the argument, and
112   return a default value if S has the wrong type.
113 */
114
115 Direction to_dir (SCM s);
116 bool to_boolean (SCM s);
117
118 void init_ly_protection ();
119 unsigned int ly_scm_hash (SCM s);
120
121 SCM index_get_cell (SCM cell, Direction d);
122 SCM index_set_cell (SCM cell, Direction d, SCM val);
123
124 SCM ly_snoc (SCM s, SCM list);
125 SCM ly_split_list (SCM s, SCM lst);
126 SCM ly_unique (SCM lst);
127 SCM ly_list_qsort_uniq_x (SCM lst);
128
129 SCM ly_output_formats();
130 SCM ly_kpathsea_find_file (SCM);
131
132 /*
133   snarfing.
134  */
135 void add_scm_init_func (void (*) ());
136
137 extern "C" {
138 typedef SCM (*Scheme_function_unknown) ();
139 }
140
141 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
142 typedef SCM (*Scheme_function_0) ();
143 typedef SCM (*Scheme_function_1) (SCM);
144 typedef SCM (*Scheme_function_2) (SCM,SCM);     
145 typedef SCM (*Scheme_function_3) (SCM,SCM, SCM);        
146 #else
147 typedef SCM (*Scheme_function_0) (...);
148 typedef SCM (*Scheme_function_1) (...);
149 typedef SCM (*Scheme_function_2) (...);
150 typedef SCM (*Scheme_function_3) (...);
151 #endif
152 #endif /* LILY_GUILE_HH */