]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/guile-compatibility.hh
78ec55575b4e666eb8b292378c27cb57bb12b702
[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
10 #ifndef GUILE_COMPATIBILITY_HH
11 #define GUILE_COMPATIBILITY_HH
12
13 #if SCM_MINOR_VERSION < 7
14 /* guile-1.6.x compatibility */
15
16 inline SCM scm_cdr (SCM x)
17 {
18   if (SCM_NCONSP (x))
19     abort ();
20   return SCM_CDR (x);
21 }
22 inline SCM scm_car (SCM x)
23 {
24   if (SCM_NCONSP (x))
25     abort ();    
26   return SCM_CAR (x);
27 }
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_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 */