2 lily-guile.hh encapsulate guile
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
16 /* Guile 1.3.4 compatibility */
17 #if GUILE_MINOR_VERSION < 4
19 #define scm_bits_t SCM
21 #define fix_guile_1_3_4_scm_puts(scm_data, port) scm_puts ((char*)scm_data, port)
22 #define scm_puts(scm_data, port) fix_guile_1_3_4_scm_puts (scm_data, port)
25 /* Guile 1.4.x compatibility */
26 #if GUILE_MINOR_VERSION < 5
28 #define scm_t_bits scm_bits_t
30 #define fix_guile_1_4_gh_scm2newstr(str, lenp) gh_scm2newstr (str, (int*)lenp)
31 #define gh_scm2newstr(str, lenp) fix_guile_1_4_gh_scm2newstr (str, lenp)
33 #define fix_guile_1_4_scm_primitive_eval(form) scm_eval_3 (form, 1, SCM_EOL)
34 #define scm_primitive_eval(form) fix_guile_1_4_scm_primitive_eval (form)
36 #define scm_c_define_gsubr scm_make_gsubr
37 #define scm_c_memq scm_sloppy_memq
38 #define scm_gc_protect_object scm_protect_object
39 #define scm_gc_unprotect_object scm_unprotect_object
40 #define scm_list_n scm_listify
41 #define SCM_STRING_CHARS SCM_CHARS
42 #define SCM_STRING_LENGTH SCM_LENGTH
47 #include "direction.hh"
48 #include "flower-proto.hh"
51 #define SCM_PACK(x) ((SCM) x)
55 #define SCM_UNPACK(x) ( x)
59 conversion functions follow the GUILE naming convention, i.e.
64 SCM ly_last (SCM list);
65 SCM ly_str02scm (char const*c);
66 SCM ly_write2scm (SCM s);
67 SCM ly_deep_copy (SCM);
68 SCM ly_symbol2scm (char const *);
69 String ly_scm2string (SCM s);
70 String ly_symbol2string (SCM);
71 SCM ly_offset2scm (Offset);
72 Offset ly_scm2offset (SCM);
73 SCM ly_assoc_chain (SCM key, SCM achain);
74 Interval ly_scm2interval (SCM);
75 SCM ly_interval2scm (Interval);
77 SCM ly_parse_scm (char const* s, int* n);
78 SCM ly_quote_scm (SCM s);
80 bool type_check_assignment (SCM val, SCM sym, SCM type_symbol) ;
81 SCM ly_number2string (SCM s);
84 display and print newline.
87 void ly_display_scm (SCM s);
92 void read_lily_scm_file (String);
93 void init_lily_guile ();
96 bool isaxis_b (SCM s);
97 bool ly_number_pair_p (SCM);
101 these conversion functions also do a typecheck on the argument, and
102 return a default value if S has the wrong type.
105 Direction to_dir (SCM s);
106 bool to_boolean (SCM s);
108 void init_ly_protection ();
109 unsigned int ly_scm_hash (SCM s);
111 SCM index_cell (SCM cellp, Direction d);
112 SCM index_set_cell (SCM cellp, Direction d, SCM val);
118 void add_scm_init_func (void (*) ());
121 typedef SCM (*Scheme_function_unknown) ();
123 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
124 typedef SCM (*Scheme_function_0) ();
125 typedef SCM (*Scheme_function_1) (SCM);
126 typedef SCM (*Scheme_function_2) (SCM,SCM);
128 typedef SCM (*Scheme_function_0) (...);
129 typedef SCM (*Scheme_function_1) (...);
130 typedef SCM (*Scheme_function_2) (...);
133 #define DECLARE_SCHEME_CALLBACK(NAME,ARGS) \
134 static SCM NAME ARGS; \
135 static SCM NAME ## _proc
137 #define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \
138 SCM TYPE :: FUNC ## _proc;\
140 TYPE ## _ ## FUNC ## _init_functions () \
142 TYPE :: FUNC ## _proc = gh_new_procedure ## ARGCOUNT ## _0 (#TYPE "::" #FUNC, \
143 ((Scheme_function_ ## ARGCOUNT)TYPE :: FUNC)); \
146 ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, TYPE ## _ ## FUNC ## _init_functions); \
149 #define ADD_SCM_INIT_FUNC(name, func)\
150 class name ## _scm_initter { \
152 name ## _scm_initter () \
154 add_scm_init_func (func); \
156 } _ ## name ## _scm_initter; \
159 #endif // LILY_GUILE_HH