]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/guile-compatibility.hh
* The grand 2005-2006 replace.
[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--2006 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 #define SCM_I_CONSP(x) SCM_CONSP (x)
28 inline SCM scm_caar (SCM x) { return SCM_CAAR (x); }
29 inline SCM scm_cdar (SCM x) { return SCM_CDAR (x); }
30 inline SCM scm_cadr (SCM x) { return SCM_CADR (x); }
31 inline SCM scm_cddr (SCM x) { return SCM_CDDR (x); }
32 inline SCM scm_caddr (SCM x) { return SCM_CADDR (x); }
33 inline SCM scm_cdadr (SCM x) { return SCM_CDADR (x); }
34 inline SCM scm_caadr (SCM x) { return SCM_CAADR (x); }
35 inline SCM scm_cadar (SCM x) { return SCM_CADAR (x); }
36 #define scm_gc_unregister_collectable_memory(a, b, c) scm_done_free (b)
37 #define scm_gc_register_collectable_memory(a, b, c) scm_done_malloc (b)
38 #define scm_is_vector(x) (SCM_VECTORP ((SCM) x))
39 #define SCM_HASHTABLE_P(x) (SCM_VECTORP ((SCM) x))
40 #define SCM_VECTOR_REF(v, i) (SCM_VELTS ((v))[ (i)])
41 #define scm_from_bool(x) (x ? SCM_BOOL_T : SCM_BOOL_F)
42 #define scm_from_int(x) SCM_MAKINUM (x)
43 #define scm_from_unsigned_integer(x) scm_uint2num (x)
44 #define scm_is_integer(x) SCM_INUMP (x)
45 #define scm_is_string(x) SCM_STRINGP (x)
46 #define scm_hash_table_p scm_vector_p
47 #define scm_from_locale_stringn(s, n) scm_mem2string (s, n)
48 #define scm_from_locale_string(x) scm_makfrom0str (x)
49 #define scm_i_string_chars(x) SCM_STRING_CHARS (x)
50 #define scm_i_string_length(x) SCM_STRING_LENGTH (x)
51 inline int ly_c_number_p (SCM x) { return SCM_NUMBERP (x); }
52 #define scm_is_number(x) (scm_number_p (x) == SCM_BOOL_T)
53 inline int ly_scm2int (SCM x) { return scm_num2int (x, 0, "ly_scm2int"); }
54 #define scm_to_int(x) (ly_scm2int (x))
55 inline int ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); }
56 #define scm_is_symbol(x) ly_c_symbol_p (x)
57 inline int ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); }
58 #define scm_is_bool(x) ly_c_boolean_p (x)
59 inline int ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); }
60 #define scm_is_eq(x, y) (SCM_EQ_P ((x), (y)))
61
62 #define scm_c_string_length(x) SCM_STRING_LENGTH (x)
63 #define scm_is_pair(x) (SCM_CONSP (x))
64
65 #define scm_c_vector_length(x) SCM_VECTOR_LENGTH (x)
66 #define scm_c_vector_ref(x, y) SCM_VECTOR_REF (x, y)
67
68 inline double ly_scm2double (SCM x) { return scm_num2dbl (x, "ly_scm2double"); }
69 #define scm_to_double(x) (ly_scm2double (x))
70 #define scm_from_double(x) (scm_make_real (x))
71
72 #endif /* SCM_MINOR_VERSION < 7 */
73
74 #endif /* GUILE_COMPATIBILITY_HH */