]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/guile-compatibility.hh
(scm_from_unsigned): add scm_from_unsigned().
[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_from_unsigned(x) scm_uint2num (x)
45 #define scm_is_integer(x) SCM_INUMP (x)
46 #define scm_is_string(x) SCM_STRINGP (x)
47 #define scm_hash_table_p scm_vector_p
48 #define scm_from_locale_stringn(s, n) scm_mem2string (s, n)
49 #define scm_from_locale_string(x) scm_makfrom0str (x)
50 #define scm_i_string_chars(x) SCM_STRING_CHARS (x)
51 #define scm_i_string_length(x) SCM_STRING_LENGTH (x)
52 inline int ly_c_number_p (SCM x) { return SCM_NUMBERP (x); }
53 #define scm_is_number(x) (scm_number_p (x) == SCM_BOOL_T)
54 inline int ly_scm2int (SCM x) { return scm_num2int (x, 0, "ly_scm2int"); }
55 #define scm_to_int(x) (ly_scm2int (x))
56 inline int ly_scm2unsigned (SCM x) { return scm_num2uint (x, 0, "ly_scm2unsigned"); }
57 #define scm_to_unsigned(x) (ly_scm2unsigned (x))
58 inline int ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); }
59 #define scm_is_symbol(x) ly_c_symbol_p (x)
60 inline int ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); }
61 #define scm_is_bool(x) ly_c_boolean_p (x)
62 inline int ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); }
63 #define scm_is_eq(x, y) (SCM_EQ_P ((x), (y)))
64
65 #define scm_c_string_length(x) SCM_STRING_LENGTH (x)
66 #define scm_is_pair(x) (SCM_CONSP (x))
67
68 #define scm_c_vector_length(x) SCM_VECTOR_LENGTH (x)
69 #define scm_c_vector_ref(x, y) SCM_VECTOR_REF (x, y)
70
71 inline double ly_scm2double (SCM x) { return scm_num2dbl (x, "ly_scm2double"); }
72 #define scm_to_double(x) (ly_scm2double (x))
73 #define scm_from_double(x) (scm_make_real (x))
74
75 #else /* !SCM_MINOR_VERSION < 7 */
76
77 #define scm_to_unsigned(x) scm_to_uint32 (x)
78 #define scm_from_unsigned(x) scm_from_unsigned_integer (x)
79
80 #endif /* !SCM_MINOR_VERSION < 7 */
81
82 #endif /* GUILE_COMPATIBILITY_HH */