2 lily-guile.hh encapsulate guile
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2007 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "mingw-compatibility.hh"
20 Hack for various MacOS incarnations.
22 #ifndef GUILE_ELLIPSIS
23 #define GUILE_ELLIPSIS
26 #include "guile-compatibility.hh"
27 #include "interval.hh"
28 #include "lily-guile-macros.hh"
29 #include "ly-module.hh"
31 /** Conversion functions follow the GUILE naming convention, i.e.
34 SCM ly_last (SCM list);
35 SCM ly_write2scm (SCM s);
36 SCM ly_deep_copy (SCM);
37 SCM ly_truncate_list (int k, SCM lst);
39 SCM ly_to_string (SCM scm);
40 SCM ly_to_symbol (SCM scm);
42 extern SCM global_lily_module;
44 string gulp_file_to_string (string fn, bool must_exist, int size);
46 SCM ly_string2scm (string const &s);
47 string ly_scm2string (SCM s);
48 string ly_symbol2string (SCM);
49 Rational ly_scm2rational (SCM);
50 SCM ly_rational2scm (Rational);
51 SCM ly_offset2scm (Offset);
52 Offset ly_scm2offset (SCM);
53 SCM ly_chain_assoc (SCM key, SCM achain);
54 SCM ly_chain_assoc_get (SCM key, SCM achain, SCM dfault);
55 SCM ly_assoc_cdr (SCM key, SCM alist);
56 SCM ly_assoc_get (SCM key, SCM alist, SCM def);
57 Interval ly_scm2interval (SCM);
58 Drul_array<Real> ly_scm2realdrul (SCM);
59 Slice int_list_to_slice (SCM l);
60 SCM ly_interval2scm (Drul_array<Real>);
61 char *ly_scm2newstr (SCM str, size_t *lenp);
63 Real robust_scm2double (SCM, double);
64 int robust_scm2int (SCM, int);
65 Direction robust_scm2dir (SCM, Direction);
66 Drul_array<Real> robust_scm2drul (SCM, Drul_array<Real>);
67 Drul_array<bool> robust_scm2booldrul (SCM, Drul_array<bool>);
68 Interval robust_scm2interval (SCM, Drul_array<Real>);
69 Offset robust_scm2offset (SCM, Offset);
70 string robust_scm2string (SCM, string);
73 SCM ly_quote_scm (SCM s);
74 bool type_check_assignment (SCM val, SCM sym, SCM type_symbol);
75 string print_scm_val (SCM val);
76 SCM ly_number2string (SCM s);
78 SCM parse_symbol_list (char const *);
79 SCM robust_list_ref (int i, SCM l);
80 SCM alist_to_hashq (SCM);
82 SCM ly_alist_vals (SCM alist);
83 SCM ly_hash2alist (SCM tab);
84 SCM ly_hash_table_keys (SCM tab);
85 int procedure_arity (SCM);
87 SCM ly_assoc_prepend_x (SCM alist, SCM key, SCM val);
88 inline bool ly_is_list (SCM x) { return SCM_NFALSEP (scm_list_p (x)); }
89 inline bool ly_is_procedure (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); }
90 inline bool ly_is_port (SCM x) { return SCM_NFALSEP (scm_port_p (x)); }
92 inline bool ly_is_equal (SCM x, SCM y)
94 return SCM_NFALSEP (scm_equal_p (x, y));
97 inline bool ly_scm2bool (SCM x) { return SCM_NFALSEP (x); }
98 inline char ly_scm2char (SCM x) { return SCM_CHAR (x); }
99 inline SCM ly_bool2scm (bool x) { return SCM_BOOL (x); }
101 inline SCM ly_append2 (SCM x1, SCM x2)
103 return scm_append (scm_listify (x1, x2, SCM_UNDEFINED));
105 inline SCM ly_append3 (SCM x1, SCM x2, SCM x3)
107 return scm_append (scm_listify (x1, x2, x3, SCM_UNDEFINED));
109 inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4)
111 return scm_append (scm_listify (x1, x2, x3, x4, SCM_UNDEFINED));
115 display and print newline.
118 void ly_display_scm (SCM s);
121 void read_lily_scm_file (string);
122 void ly_c_init_guile ();
124 bool is_direction (SCM s);
125 bool is_number_pair (SCM);
129 these conversion functions also do a typecheck on the argument, and
130 return a default value if S has the wrong type.
133 Direction to_dir (SCM s);
134 bool to_boolean (SCM s);
136 void init_ly_protection ();
137 unsigned int ly_scm_hash (SCM s);
139 SCM index_get_cell (SCM cell, Direction d);
140 SCM index_set_cell (SCM cell, Direction d, SCM val);
142 SCM ly_snoc (SCM s, SCM list);
143 SCM ly_split_list (SCM s, SCM lst);
144 SCM ly_unique (SCM lst);
145 SCM ly_list_qsort_uniq_x (SCM lst);
147 SCM ly_output_formats ();
148 SCM ly_kpathsea_find_file (SCM);
153 void add_scm_init_func (void (*) ());
156 typedef SCM (*Scheme_function_unknown) (GUILE_ELLIPSIS);
159 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
160 typedef SCM (*Scheme_function_0) ();
161 typedef SCM (*Scheme_function_1) (SCM);
162 typedef SCM (*Scheme_function_2) (SCM, SCM);
163 typedef SCM (*Scheme_function_3) (SCM, SCM, SCM);
165 typedef SCM (*Scheme_function_0) (GUILE_ELLIPSIS);
166 typedef SCM (*Scheme_function_1) (GUILE_ELLIPSIS);
167 typedef SCM (*Scheme_function_2) (GUILE_ELLIPSIS);
168 typedef SCM (*Scheme_function_3) (GUILE_ELLIPSIS);
173 Inline these for performance reasons.
175 #define scm_cdr ly_cdr
176 #define scm_car ly_car
179 #define scm_is_pair ly_is_pair
182 inline SCM ly_car (SCM x) { return SCM_CAR (x); }
183 inline SCM ly_cdr (SCM x) { return SCM_CDR (x); }
184 inline bool ly_is_pair (SCM x) { return SCM_I_CONSP (x); }
188 #include "std-vector.hh"
192 ly_cxx_vector_to_list (vector<T> const &src)
195 for (vsize i = src.size (); i --; )
196 l = scm_cons (src[i]->self_scm (), l);
202 SCM ly_offsets2scm (vector<Offset> os);
203 vector<Offset> ly_scm2offsets (SCM s);
205 #endif /* LILY_GUILE_HH */