]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/guile-compatibility.hh
*** empty log message ***
[lilypond.git] / flower / include / guile-compatibility.hh
1 /*
2   guile-compatibility.hh -- declare compat functions for GUILE 1.6
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef GUILE_COMPATIBILITY_HH
10 #define GUILE_COMPATIBILITY_HH
11
12 #if SCM_MINOR_VERSION < 7
13 /* guile-1.6.x compatibility */
14
15 inline SCM scm_cdr (SCM x)
16 {
17   if (SCM_NCONSP (x))
18     abort ();
19   return SCM_CDR (x);
20 }
21 inline SCM scm_car (SCM x)
22 {
23   if (SCM_NCONSP (x))
24     abort ();
25   return SCM_CAR (x);
26 }
27 inline SCM scm_caar (SCM x) { return SCM_CAAR (x); }
28 inline SCM scm_cdar (SCM x) { return SCM_CDAR (x); }
29 inline SCM scm_cadr (SCM x) { return SCM_CADR (x); }
30 inline SCM scm_cddr (SCM x) { return SCM_CDDR (x); }
31 inline SCM scm_caddr (SCM x) { return SCM_CADDR (x); }
32 inline SCM scm_cdadr (SCM x) { return SCM_CDADR (x); }
33 inline SCM scm_caadr (SCM x) { return SCM_CAADR (x); }
34 inline SCM scm_cadar (SCM x) { return SCM_CADAR (x); }
35 #define scm_gc_unregister_collectable_memory(a, b, c) scm_done_free (b)
36 #define scm_gc_register_collectable_memory(a, b, c) scm_done_malloc (b)
37 #define scm_is_vector(x) (SCM_VECTORP ((SCM) x))
38 #define SCM_HASHTABLE_P(x) (SCM_VECTORP ((SCM) x))
39 #define SCM_VECTOR_REF(v, i) (SCM_VELTS ((v))[ (i)])
40 #define scm_from_bool(x) (x ? SCM_BOOL_T : SCM_BOOL_F)
41 #define scm_from_int(x) SCM_MAKINUM (x)
42 #define scm_from_unsigned_integer(x) scm_uint2num (x)
43 #define scm_is_integer(x) SCM_INUMP (x)
44 #define scm_is_string(x) SCM_STRINGP (x)
45 #define scm_hash_table_p scm_vector_p
46 #define scm_from_locale_stringn(s, n) scm_mem2string (s, n)
47 #define scm_from_locale_string(x) scm_makfrom0str (x)
48 #define scm_i_string_chars(x) SCM_STRING_CHARS (x)
49 #define scm_i_string_length(x) SCM_STRING_LENGTH (x)
50 inline int ly_c_number_p (SCM x) { return SCM_NUMBERP (x); }
51 #define scm_is_number(x) (scm_number_p (x) == SCM_BOOL_T)
52 inline int ly_scm2int (SCM x) { return scm_num2int (x, 0, "ly_scm2int"); }
53 #define scm_to_int(x) (ly_scm2int (x))
54 inline int ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); }
55 #define scm_is_symbol(x) ly_c_symbol_p (x)
56 inline int ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); }
57 #define scm_is_bool(x) ly_c_boolean_p (x)
58 inline int ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); }
59 #define scm_is_eq(x, y) (SCM_EQ_P ((x), (y)))
60
61 #define scm_c_string_length(x) SCM_STRING_LENGTH (x)
62 #define scm_is_pair(x) (SCM_CONSP (x))
63
64 #define scm_c_vector_length(x) SCM_VECTOR_LENGTH (x)
65 #define scm_c_vector_ref(x, y) SCM_VECTOR_REF (x, y)
66
67 inline double ly_scm2double (SCM x) { return scm_num2dbl (x, "ly_scm2double"); }
68 #define scm_to_double(x) (ly_scm2double (x))
69 #define scm_from_double(x) (scm_make_real (x))
70
71 #endif /* SCM_MINOR_VERSION < 7 */
72
73 #endif /* GUILE_COMPATIBILITY_HH */