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"
18 #include "guile-compatibility.hh"
19 #include "interval.hh"
20 #include "lily-guile-macros.hh"
21 #include "ly-module.hh"
23 /** Conversion functions follow the GUILE naming convention, i.e.
26 SCM
ly_last (SCM list
);
27 SCM
ly_write2scm (SCM s
);
28 SCM
ly_deep_copy (SCM
);
29 SCM
ly_truncate_list (int k
, SCM lst
);
31 SCM
ly_to_string (SCM scm
);
32 SCM
ly_to_symbol (SCM scm
);
34 extern SCM global_lily_module
;
36 String
gulp_file_to_string (String fn
, bool must_exist
);
38 String
ly_scm2string (SCM s
);
39 String
ly_symbol2string (SCM
);
40 SCM
ly_offset2scm (Offset
);
41 Offset
ly_scm2offset (SCM
);
42 SCM
ly_chain_assoc (SCM key
, SCM achain
);
43 SCM
ly_chain_assoc_get (SCM key
, SCM achain
, SCM dfault
);
44 SCM
ly_assoc_cdr (SCM key
, SCM alist
);
45 SCM
ly_assoc_get (SCM key
, SCM alist
, SCM def
);
46 Interval
ly_scm2interval (SCM
);
47 Drul_array
<Real
> ly_scm2realdrul (SCM
);
48 Slice
int_list_to_slice (SCM l
);
49 SCM
ly_interval2scm (Drul_array
<Real
>);
50 char *ly_scm2newstr (SCM str
, size_t *lenp
);
52 Real
robust_scm2double (SCM
, double);
53 int robust_scm2int (SCM
, int);
54 Drul_array
<Real
> robust_scm2drul (SCM
, Drul_array
<Real
>);
55 Interval
robust_scm2interval (SCM
, Drul_array
<Real
>);
56 Offset
robust_scm2offset (SCM
, Offset
);
58 SCM
ly_quote_scm (SCM s
);
59 bool type_check_assignment (SCM val
, SCM sym
, SCM type_symbol
);
60 String
print_scm_val (SCM val
);
61 SCM
ly_number2string (SCM s
);
63 SCM
parse_symbol_list (char const *);
64 SCM
robust_list_ref (int i
, SCM l
);
65 SCM
alist_to_hashq (SCM
);
67 SCM
ly_alist_vals (SCM alist
);
68 SCM
ly_hash2alist (SCM tab
);
70 /* inserts at front, removing dublicates */
71 inline SCM
ly_assoc_front_x (SCM alist
, SCM key
, SCM val
)
73 return scm_acons (key
, val
, scm_assoc_remove_x (alist
, key
));
75 inline bool ly_is_list (SCM x
) { return SCM_NFALSEP (scm_list_p (x
)); }
76 inline bool ly_is_procedure (SCM x
) { return SCM_NFALSEP (scm_procedure_p (x
)); }
77 inline bool ly_is_port (SCM x
) { return SCM_NFALSEP (scm_port_p (x
)); }
79 inline bool ly_is_equal (SCM x
, SCM y
)
81 return SCM_NFALSEP (scm_equal_p (x
, y
));
84 inline bool ly_scm2bool (SCM x
) { return SCM_NFALSEP (x
); }
85 inline char ly_scm2char (SCM x
) { return SCM_CHAR (x
); }
86 inline unsigned long ly_length (SCM x
)
88 return scm_num2ulong (scm_length (x
), 0, "ly_length");
90 inline SCM
ly_bool2scm (bool x
) { return SCM_BOOL (x
); }
92 inline SCM
ly_append2 (SCM x1
, SCM x2
)
94 return scm_append (scm_listify (x1
, x2
, SCM_UNDEFINED
));
96 inline SCM
ly_append3 (SCM x1
, SCM x2
, SCM x3
)
98 return scm_append (scm_listify (x1
, x2
, x3
, SCM_UNDEFINED
));
100 inline SCM
ly_append4 (SCM x1
, SCM x2
, SCM x3
, SCM x4
)
102 return scm_append (scm_listify (x1
, x2
, x3
, x4
, SCM_UNDEFINED
));
106 display and print newline.
109 void ly_display_scm (SCM s
);
112 void read_lily_scm_file (String
);
113 void ly_c_init_guile ();
115 bool is_direction (SCM s
);
116 bool is_number_pair (SCM
);
120 these conversion functions also do a typecheck on the argument, and
121 return a default value if S has the wrong type.
124 Direction
to_dir (SCM s
);
125 bool to_boolean (SCM s
);
127 void init_ly_protection ();
128 unsigned int ly_scm_hash (SCM s
);
130 SCM
index_get_cell (SCM cell
, Direction d
);
131 SCM
index_set_cell (SCM cell
, Direction d
, SCM val
);
133 SCM
ly_snoc (SCM s
, SCM list
);
134 SCM
ly_split_list (SCM s
, SCM lst
);
135 SCM
ly_unique (SCM lst
);
136 SCM
ly_list_qsort_uniq_x (SCM lst
);
138 SCM
ly_output_formats ();
139 SCM
ly_kpathsea_find_file (SCM
);
144 void add_scm_init_func (void (*) ());
147 typedef SCM (*Scheme_function_unknown
) ();
150 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
151 typedef SCM (*Scheme_function_0
) ();
152 typedef SCM (*Scheme_function_1
) (SCM
);
153 typedef SCM (*Scheme_function_2
) (SCM
, SCM
);
154 typedef SCM (*Scheme_function_3
) (SCM
, SCM
, SCM
);
156 typedef SCM (*Scheme_function_0
) (...);
157 typedef SCM (*Scheme_function_1
) (...);
158 typedef SCM (*Scheme_function_2
) (...);
159 typedef SCM (*Scheme_function_3
) (...);
162 #define scm_cdr ly_cdr
163 #define scm_car ly_car
166 #define scm_is_pair ly_is_pair
169 inline SCM
ly_car (SCM x
) { return SCM_CAR (x
); }
170 inline SCM
ly_cdr (SCM x
) { return SCM_CDR (x
); }
171 inline bool ly_is_pair (SCM x
) { return SCM_I_CONSP (x
); }
175 #endif /* LILY_GUILE_HH */