]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/guile-compatibility.hh
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[lilypond.git] / flower / include / guile-compatibility.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2004--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef GUILE_COMPATIBILITY_HH
21 #define GUILE_COMPATIBILITY_HH
22
23 #if SCM_MINOR_VERSION < 7
24 /* guile-1.6.x compatibility */
25
26 inline SCM scm_cdr (SCM x)
27 {
28   if (SCM_NCONSP (x))
29     abort ();
30   return SCM_CDR (x);
31 }
32 inline SCM scm_car (SCM x)
33 {
34   if (SCM_NCONSP (x))
35     abort ();
36   return SCM_CAR (x);
37 }
38 #define SCM_I_CONSP(x) SCM_CONSP (x)
39 inline SCM scm_caar (SCM x) { return SCM_CAAR (x); }
40 inline SCM scm_cdar (SCM x) { return SCM_CDAR (x); }
41 inline SCM scm_cadr (SCM x) { return SCM_CADR (x); }
42 inline SCM scm_cddr (SCM x) { return SCM_CDDR (x); }
43 inline SCM scm_caddr (SCM x) { return SCM_CADDR (x); }
44 inline SCM scm_cdadr (SCM x) { return SCM_CDADR (x); }
45 inline SCM scm_caadr (SCM x) { return SCM_CAADR (x); }
46 inline SCM scm_cadar (SCM x) { return SCM_CADAR (x); }
47 #define scm_gc_unregister_collectable_memory(a, b, c) scm_done_free (b)
48 #define scm_gc_register_collectable_memory(a, b, c) scm_done_malloc (b)
49 #define scm_is_vector(x) (SCM_VECTORP ((SCM) x))
50 #define SCM_HASHTABLE_P(x) (SCM_VECTORP ((SCM) x))
51 #define SCM_VECTOR_REF(v, i) (SCM_VELTS ((v))[ (i)])
52 #define scm_from_bool(x) (x ? SCM_BOOL_T : SCM_BOOL_F)
53 #define scm_from_int(x) SCM_MAKINUM (x)
54 #define scm_from_unsigned_integer(x) scm_uint2num (x)
55 #define scm_from_unsigned(x) scm_uint2num (x)
56 #define scm_from_uint32(x) scm_uint2num (x)
57 #define scm_is_integer(x) SCM_INUMP (x)
58 #define scm_is_string(x) SCM_STRINGP (x)
59 #define scm_hash_table_p scm_vector_p
60 #define scm_from_locale_stringn(s, n) scm_mem2string (s, n)
61 #define scm_from_locale_string(x) scm_makfrom0str (x)
62 #define scm_i_string_chars(x) SCM_STRING_CHARS (x)
63 #define scm_i_string_length(x) SCM_STRING_LENGTH (x)
64 inline int ly_c_number_p (SCM x) { return SCM_NUMBERP (x); }
65 #define scm_is_number(x) (scm_number_p (x) == SCM_BOOL_T)
66 inline int ly_scm2int (SCM x) { return scm_num2int (x, 0, "ly_scm2int"); }
67 #define scm_to_int(x) (ly_scm2int (x))
68 inline int ly_scm2unsigned (SCM x) { return scm_num2uint (x, 0, "ly_scm2unsigned"); }
69 #define scm_to_unsigned(x) (ly_scm2unsigned (x))
70 inline int ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); }
71 #define scm_is_symbol(x) ly_c_symbol_p (x)
72 inline int ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); }
73 #define scm_is_bool(x) ly_c_boolean_p (x)
74 inline int ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); }
75 #define scm_is_eq(x, y) (SCM_EQ_P ((x), (y)))
76
77 #define scm_c_string_length(x) SCM_STRING_LENGTH (x)
78 #define scm_is_pair(x) (SCM_CONSP (x))
79
80 #define scm_c_vector_length(x) SCM_VECTOR_LENGTH (x)
81 #define scm_c_vector_ref(x, y) SCM_VECTOR_REF (x, y)
82
83 inline double ly_scm2double (SCM x) { return scm_num2dbl (x, "ly_scm2double"); }
84 #define scm_to_double(x) (ly_scm2double (x))
85 #define scm_from_double(x) (scm_make_real (x))
86
87 #else /* !SCM_MINOR_VERSION < 7 */
88
89 #define scm_to_unsigned(x) scm_to_uint32 (x)
90 #define scm_from_unsigned(x) scm_from_unsigned_integer (x)
91
92 #endif /* !SCM_MINOR_VERSION < 7 */
93
94 #endif /* GUILE_COMPATIBILITY_HH */