2 lily-guile.hh encapsulate guile
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "mingw-compatibility.hh"
20 Hack for various MacOS incarnations.
22 #ifndef GUILE_ELLIPSIS
23 #define GUILE_ELLIPSIS
27 #include "guile-compatibility.hh"
28 #include "interval.hh"
29 #include "lily-guile-macros.hh"
30 #include "ly-module.hh"
32 /** Conversion functions follow the GUILE naming convention, i.e.
35 SCM ly_last (SCM list);
36 SCM ly_write2scm (SCM s);
37 SCM ly_deep_copy (SCM);
38 SCM ly_truncate_list (int k, SCM lst);
40 SCM ly_to_string (SCM scm);
41 SCM ly_to_symbol (SCM scm);
43 extern SCM global_lily_module;
45 String gulp_file_to_string (String fn, bool must_exist, int size);
47 String ly_scm2string (SCM s);
48 String ly_symbol2string (SCM);
49 SCM ly_offset2scm (Offset);
50 Offset ly_scm2offset (SCM);
51 SCM ly_chain_assoc (SCM key, SCM achain);
52 SCM ly_chain_assoc_get (SCM key, SCM achain, SCM dfault);
53 SCM ly_assoc_cdr (SCM key, SCM alist);
54 SCM ly_assoc_get (SCM key, SCM alist, SCM def);
55 Interval ly_scm2interval (SCM);
56 Drul_array<Real> ly_scm2realdrul (SCM);
57 Slice int_list_to_slice (SCM l);
58 SCM ly_interval2scm (Drul_array<Real>);
59 char *ly_scm2newstr (SCM str, size_t *lenp);
61 Real robust_scm2double (SCM, double);
62 int robust_scm2int (SCM, int);
63 Direction robust_scm2dir (SCM, Direction);
64 Drul_array<Real> robust_scm2drul (SCM, Drul_array<Real>);
65 Interval robust_scm2interval (SCM, Drul_array<Real>);
66 Offset robust_scm2offset (SCM, Offset);
68 SCM ly_quote_scm (SCM s);
69 bool type_check_assignment (SCM val, SCM sym, SCM type_symbol);
70 String print_scm_val (SCM val);
71 SCM ly_number2string (SCM s);
73 SCM parse_symbol_list (char const *);
74 SCM robust_list_ref (int i, SCM l);
75 SCM alist_to_hashq (SCM);
77 SCM ly_alist_vals (SCM alist);
78 SCM ly_hash2alist (SCM tab);
80 /* inserts at front, removing dublicates */
81 inline SCM ly_assoc_front_x (SCM alist, SCM key, SCM val)
83 return scm_acons (key, val, scm_assoc_remove_x (alist, key));
85 inline bool ly_is_list (SCM x) { return SCM_NFALSEP (scm_list_p (x)); }
86 inline bool ly_is_procedure (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); }
87 inline bool ly_is_port (SCM x) { return SCM_NFALSEP (scm_port_p (x)); }
89 inline bool ly_is_equal (SCM x, SCM y)
91 return SCM_NFALSEP (scm_equal_p (x, y));
94 inline bool ly_scm2bool (SCM x) { return SCM_NFALSEP (x); }
95 inline char ly_scm2char (SCM x) { return SCM_CHAR (x); }
96 inline unsigned long ly_length (SCM x)
98 return scm_num2ulong (scm_length (x), 0, "ly_length");
100 inline SCM ly_bool2scm (bool x) { return SCM_BOOL (x); }
102 inline SCM ly_append2 (SCM x1, SCM x2)
104 return scm_append (scm_listify (x1, x2, SCM_UNDEFINED));
106 inline SCM ly_append3 (SCM x1, SCM x2, SCM x3)
108 return scm_append (scm_listify (x1, x2, x3, SCM_UNDEFINED));
110 inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4)
112 return scm_append (scm_listify (x1, x2, x3, x4, SCM_UNDEFINED));
116 display and print newline.
119 void ly_display_scm (SCM s);
122 void read_lily_scm_file (String);
123 void ly_c_init_guile ();
125 bool is_direction (SCM s);
126 bool is_number_pair (SCM);
130 these conversion functions also do a typecheck on the argument, and
131 return a default value if S has the wrong type.
134 Direction to_dir (SCM s);
135 bool to_boolean (SCM s);
137 void init_ly_protection ();
138 unsigned int ly_scm_hash (SCM s);
140 SCM index_get_cell (SCM cell, Direction d);
141 SCM index_set_cell (SCM cell, Direction d, SCM val);
143 SCM ly_snoc (SCM s, SCM list);
144 SCM ly_split_list (SCM s, SCM lst);
145 SCM ly_unique (SCM lst);
146 SCM ly_list_qsort_uniq_x (SCM lst);
148 SCM ly_output_formats ();
149 SCM ly_kpathsea_find_file (SCM);
154 void add_scm_init_func (void (*) ());
157 typedef SCM (*Scheme_function_unknown) (GUILE_ELLIPSIS);
160 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
161 typedef SCM (*Scheme_function_0) ();
162 typedef SCM (*Scheme_function_1) (SCM);
163 typedef SCM (*Scheme_function_2) (SCM, SCM);
164 typedef SCM (*Scheme_function_3) (SCM, SCM, SCM);
166 typedef SCM (*Scheme_function_0) (GUILE_ELLIPSIS);
167 typedef SCM (*Scheme_function_1) (GUILE_ELLIPSIS);
168 typedef SCM (*Scheme_function_2) (GUILE_ELLIPSIS);
169 typedef SCM (*Scheme_function_3) (GUILE_ELLIPSIS);
172 #define scm_cdr ly_cdr
173 #define scm_car ly_car
176 #define scm_is_pair ly_is_pair
179 inline SCM ly_car (SCM x) { return SCM_CAR (x); }
180 inline SCM ly_cdr (SCM x) { return SCM_CDR (x); }
181 inline bool ly_is_pair (SCM x) { return SCM_I_CONSP (x); }
184 #endif /* LILY_GUILE_HH */