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 extern SCM global_lily_module;
41 string gulp_file_to_string (string fn, bool must_exist, int size);
43 SCM ly_string2scm (string const &s);
44 string ly_scm2string (SCM s);
45 string ly_symbol2string (SCM);
46 Rational ly_scm2rational (SCM);
47 SCM ly_rational2scm (Rational);
48 SCM ly_offset2scm (Offset);
49 Offset ly_scm2offset (SCM);
50 SCM ly_chain_assoc (SCM key, SCM achain);
51 SCM ly_chain_assoc_get (SCM key, SCM achain, SCM dfault);
52 SCM ly_assoc_cdr (SCM key, SCM alist);
53 SCM ly_assoc_get (SCM key, SCM alist, SCM def);
54 Interval ly_scm2interval (SCM);
55 Drul_array<Real> ly_scm2realdrul (SCM);
56 Slice int_list_to_slice (SCM l);
57 SCM ly_interval2scm (Drul_array<Real>);
58 char *ly_scm2newstr (SCM str, size_t *lenp);
60 Real robust_scm2double (SCM, double);
61 int robust_scm2int (SCM, int);
62 Direction robust_scm2dir (SCM, Direction);
63 Drul_array<Real> robust_scm2drul (SCM, Drul_array<Real>);
64 Drul_array<bool> robust_scm2booldrul (SCM, Drul_array<bool>);
65 Interval robust_scm2interval (SCM, Drul_array<Real>);
66 Offset robust_scm2offset (SCM, Offset);
67 string robust_scm2string (SCM, string);
70 SCM ly_quote_scm (SCM s);
71 bool type_check_assignment (SCM val, SCM sym, SCM type_symbol);
72 string print_scm_val (SCM val);
73 SCM ly_number2string (SCM s);
75 SCM parse_symbol_list (char const *);
76 SCM robust_list_ref (int i, SCM l);
77 SCM alist_to_hashq (SCM);
79 SCM ly_alist_vals (SCM alist);
80 SCM ly_hash2alist (SCM tab);
81 SCM ly_hash_table_keys (SCM tab);
83 SCM ly_assoc_prepend_x (SCM alist, SCM key, SCM val);
84 inline bool ly_is_list (SCM x) { return SCM_NFALSEP (scm_list_p (x)); }
85 inline bool ly_is_procedure (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); }
86 inline bool ly_is_port (SCM x) { return SCM_NFALSEP (scm_port_p (x)); }
88 inline bool ly_is_equal (SCM x, SCM y)
90 return SCM_NFALSEP (scm_equal_p (x, y));
93 inline bool ly_scm2bool (SCM x) { return SCM_NFALSEP (x); }
94 inline char ly_scm2char (SCM x) { return SCM_CHAR (x); }
95 inline SCM ly_bool2scm (bool x) { return SCM_BOOL (x); }
97 inline SCM ly_append2 (SCM x1, SCM x2)
99 return scm_append (scm_listify (x1, x2, SCM_UNDEFINED));
101 inline SCM ly_append3 (SCM x1, SCM x2, SCM x3)
103 return scm_append (scm_listify (x1, x2, x3, SCM_UNDEFINED));
105 inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4)
107 return scm_append (scm_listify (x1, x2, x3, x4, SCM_UNDEFINED));
111 display and print newline.
114 void ly_display_scm (SCM s);
117 void read_lily_scm_file (string);
118 void ly_c_init_guile ();
120 bool is_direction (SCM s);
121 bool is_number_pair (SCM);
125 these conversion functions also do a typecheck on the argument, and
126 return a default value if S has the wrong type.
129 Direction to_dir (SCM s);
130 bool to_boolean (SCM s);
132 void init_ly_protection ();
133 unsigned int ly_scm_hash (SCM s);
135 SCM index_get_cell (SCM cell, Direction d);
136 SCM index_set_cell (SCM cell, Direction d, SCM val);
138 SCM ly_snoc (SCM s, SCM list);
139 SCM ly_split_list (SCM s, SCM lst);
140 SCM ly_unique (SCM lst);
141 SCM ly_list_qsort_uniq_x (SCM lst);
143 SCM ly_output_formats ();
144 SCM ly_kpathsea_find_file (SCM);
149 void add_scm_init_func (void (*) ());
152 typedef SCM (*Scheme_function_unknown) (GUILE_ELLIPSIS);
155 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
156 typedef SCM (*Scheme_function_0) ();
157 typedef SCM (*Scheme_function_1) (SCM);
158 typedef SCM (*Scheme_function_2) (SCM, SCM);
159 typedef SCM (*Scheme_function_3) (SCM, SCM, SCM);
161 typedef SCM (*Scheme_function_0) (GUILE_ELLIPSIS);
162 typedef SCM (*Scheme_function_1) (GUILE_ELLIPSIS);
163 typedef SCM (*Scheme_function_2) (GUILE_ELLIPSIS);
164 typedef SCM (*Scheme_function_3) (GUILE_ELLIPSIS);
169 Inline these for performance reasons.
171 #define scm_cdr ly_cdr
172 #define scm_car ly_car
175 #define scm_is_pair ly_is_pair
178 inline SCM ly_car (SCM x) { return SCM_CAR (x); }
179 inline SCM ly_cdr (SCM x) { return SCM_CDR (x); }
180 inline bool ly_is_pair (SCM x) { return SCM_I_CONSP (x); }
184 #include "std-vector.hh"
188 ly_cxx_vector_to_list (vector<T> const &src)
191 for (vsize i = src.size (); i --; )
192 l = scm_cons (src[i]->self_scm (), l);
198 SCM ly_offsets2scm (vector<Offset> os);
199 vector<Offset> ly_scm2offsets (SCM s);
201 #endif /* LILY_GUILE_HH */