2 lily-guile.hh encapsulate guile
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
14 #include "interval.hh"
15 #include "guile-compatibility.hh"
16 #include "lily-guile-macros.hh"
17 #include "ly-module.hh"
20 /** Conversion functions follow the GUILE naming convention, i.e.
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);
28 SCM ly_to_string (SCM scm);
29 SCM ly_to_symbol (SCM scm);
31 extern SCM global_lily_module;
33 String gulp_file_to_string (String fn, bool must_exist);
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);
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);
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);
60 SCM parse_symbol_list (char const *);
61 SCM robust_list_ref(int i, SCM l);
62 SCM alist_to_hashq (SCM);
65 /* inserts at front, removing dublicates */
66 inline SCM ly_assoc_front_x(SCM alist, SCM key, SCM val)
68 return scm_acons(key, val, scm_assoc_remove_x (alist, key));
70 inline bool ly_c_list_p (SCM x) { return SCM_NFALSEP (scm_list_p (x)); }
71 inline bool ly_c_procedure_p (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); }
72 inline bool ly_c_equal_p (SCM x, SCM y) {
73 return SCM_NFALSEP (scm_equal_p (x, y));
77 inline bool ly_scm2bool (SCM x) { return SCM_NFALSEP (x); }
78 inline char ly_scm2char (SCM x) { return SCM_CHAR(x); }
79 inline unsigned long ly_length (SCM x) {
80 return scm_num2ulong (scm_length (x), 0, "ly_length");
82 inline SCM ly_bool2scm (bool x) { return SCM_BOOL (x); }
84 inline SCM ly_append2 (SCM x1, SCM x2) {
85 return scm_append (scm_listify (x1, x2, SCM_UNDEFINED));
87 inline SCM ly_append3 (SCM x1, SCM x2, SCM x3) {
88 return scm_append (scm_listify (x1, x2, x3, SCM_UNDEFINED));
90 inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4) {
91 return scm_append (scm_listify (x1, x2, x3, x4, SCM_UNDEFINED));
95 display and print newline.
98 void ly_display_scm (SCM s);
101 void read_lily_scm_file (String);
102 void ly_c_init_guile ();
104 bool is_direction (SCM s);
105 bool is_number_pair (SCM);
109 these conversion functions also do a typecheck on the argument, and
110 return a default value if S has the wrong type.
113 Direction to_dir (SCM s);
114 bool to_boolean (SCM s);
116 void init_ly_protection ();
117 unsigned int ly_scm_hash (SCM s);
119 SCM index_get_cell (SCM cell, Direction d);
120 SCM index_set_cell (SCM cell, Direction d, SCM val);
122 SCM ly_snoc (SCM s, SCM list);
123 SCM ly_split_list (SCM s, SCM lst);
124 SCM ly_unique (SCM lst);
125 SCM ly_list_qsort_uniq_x (SCM lst);
127 SCM ly_output_formats();
128 SCM ly_kpathsea_find_file (SCM);
133 void add_scm_init_func (void (*) ());
136 typedef SCM (*Scheme_function_unknown) ();
139 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
140 typedef SCM (*Scheme_function_0) ();
141 typedef SCM (*Scheme_function_1) (SCM);
142 typedef SCM (*Scheme_function_2) (SCM,SCM);
143 typedef SCM (*Scheme_function_3) (SCM,SCM, SCM);
145 typedef SCM (*Scheme_function_0) (...);
146 typedef SCM (*Scheme_function_1) (...);
147 typedef SCM (*Scheme_function_2) (...);
148 typedef SCM (*Scheme_function_3) (...);
150 #endif /* LILY_GUILE_HH */