2 lily-guile.hh encapsulate guile
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
15 TODO: the GH interface is deprecated as of GUILE 1.6
17 Remove all gh_XXX functions.
23 /* Guile 1.3.4 compatibility */
24 #if GUILE_MINOR_VERSION < 4
26 #define scm_bits_t SCM
28 #define fix_guile_1_3_4_scm_puts(scm_data, port) scm_puts ((char*)scm_data, port)
29 #define scm_puts(scm_data, port) fix_guile_1_3_4_scm_puts (scm_data, port)
32 /* Guile 1.4.x compatibility */
33 #if GUILE_MINOR_VERSION < 5
35 #define scm_t_bits scm_bits_t
37 #define fix_guile_1_4_gh_scm2newstr(str, lenp) gh_scm2newstr (str, (int*)lenp)
38 #define gh_scm2newstr(str, lenp) fix_guile_1_4_gh_scm2newstr (str, lenp)
40 #define fix_guile_1_4_scm_primitive_eval(form) scm_eval_3 (form, 1, SCM_EOL)
41 #define scm_primitive_eval(form) fix_guile_1_4_scm_primitive_eval (form)
43 #define scm_c_define_gsubr scm_make_gsubr
44 #define scm_c_eval_string(str) gh_eval_str ((char*)str)
45 #define scm_c_memq scm_sloppy_memq
46 #define scm_gc_protect_object scm_protect_object
47 #define scm_gc_unprotect_object scm_unprotect_object
48 #define scm_list_n scm_listify
49 #define SCM_STRING_CHARS SCM_CHARS
50 #define SCM_STRING_LENGTH SCM_LENGTH
55 #include "direction.hh"
56 #include "flower-proto.hh"
59 #define SCM_PACK(x) ((SCM) x)
63 #define SCM_UNPACK(x) ( x)
67 conversion functions follow the GUILE naming convention, i.e.
72 SCM ly_last (SCM list);
73 SCM ly_str02scm (char const*c);
74 SCM ly_write2scm (SCM s);
75 SCM ly_deep_copy (SCM);
76 SCM ly_symbol2scm (char const *);
77 String ly_scm2string (SCM s);
78 String ly_symbol2string (SCM);
79 SCM ly_offset2scm (Offset);
80 Offset ly_scm2offset (SCM);
81 SCM ly_assoc_chain (SCM key, SCM achain);
82 Interval ly_scm2interval (SCM);
83 SCM ly_interval2scm (Interval);
85 SCM ly_parse_scm (char const* s, int* n);
86 SCM ly_quote_scm (SCM s);
88 bool type_check_assignment (SCM val, SCM sym, SCM type_symbol) ;
89 SCM ly_number2string (SCM s);
91 SCM parse_symbol_list (char const *);
93 inline SCM ly_cdr (SCM x) { return SCM_CDR (x); }
94 inline SCM ly_car (SCM x) { return SCM_CAR (x); }
95 inline SCM ly_caar (SCM x) { return SCM_CAAR (x); }
96 inline SCM ly_cdar (SCM x) { return SCM_CDAR (x); }
97 inline SCM ly_cadr (SCM x) { return SCM_CADR (x); }
98 inline SCM ly_cddr (SCM x) { return SCM_CDDR (x); }
99 inline SCM ly_caddr (SCM x) { return SCM_CADDR (x); }
100 inline SCM ly_cdadr (SCM x) { return SCM_CDADR (x); }
101 inline SCM ly_caadr (SCM x) { return SCM_CAADR (x); }
102 inline bool ly_pair_p (SCM x) { return SCM_NFALSEP (scm_pair_p (x)); }
103 inline bool ly_symbol_p (SCM x) { return SCM_SYMBOLP (x); }
104 inline bool ly_number_p (SCM x) { return SCM_NUMBERP (x); }
105 inline bool ly_procedure_p (SCM x) { return SCM_NFALSEP (scm_procedure_p(x)); }
108 display and print newline.
111 void ly_display_scm (SCM s);
116 void read_lily_scm_file (String);
117 void init_lily_guile ();
119 bool isdir_b (SCM s);
120 bool isaxis_b (SCM s);
121 bool ly_number_pair_p (SCM);
122 bool ly_axis_p (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_cell (SCM cellp, Direction d);
136 SCM index_set_cell (SCM cellp, Direction d, SCM val);
142 void add_scm_init_func (void (*) ());
145 typedef SCM (*Scheme_function_unknown) ();
147 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
148 typedef SCM (*Scheme_function_0) ();
149 typedef SCM (*Scheme_function_1) (SCM);
150 typedef SCM (*Scheme_function_2) (SCM,SCM);
152 typedef SCM (*Scheme_function_0) (...);
153 typedef SCM (*Scheme_function_1) (...);
154 typedef SCM (*Scheme_function_2) (...);
157 #define DECLARE_SCHEME_CALLBACK(NAME,ARGS) \
158 static SCM NAME ARGS; \
159 static SCM NAME ## _proc
161 #define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \
162 SCM TYPE :: FUNC ## _proc;\
164 TYPE ## _ ## FUNC ## _init_functions () \
166 TYPE :: FUNC ## _proc = gh_new_procedure ## ARGCOUNT ## _0 (#TYPE "::" #FUNC, \
167 ((Scheme_function_ ## ARGCOUNT)TYPE :: FUNC)); \
170 ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, TYPE ## _ ## FUNC ## _init_functions); \
173 #define ADD_SCM_INIT_FUNC(name, func)\
174 class name ## _scm_initter { \
176 name ## _scm_initter () \
178 add_scm_init_func (func); \
180 } _ ## name ## _scm_initter; \
183 #endif // LILY_GUILE_HH