1 /*
2  * guile-api.h - compatibility and miscellaneous guile functionality
3  *
4  * Copyright (C) 2011-2013 Thien-Thi Nguyen
5  * Copyright (C) 2001, 2002, 2003 Stefan Jahn <stefan@lkcc.org>
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this package.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef __GUILE_API_H__
22 #define __GUILE_API_H__ 1
23 
24 /* Compatibility definitions for various Guile versions.  These definitions
25    are mainly due to the fact that the gh interface is deprecated in newer
26    versions.  */
27 #ifndef SCM_PROCEDUREP
28 #define SCM_PROCEDUREP(obj) gi_nfalsep (scm_procedure_p (obj))
29 #endif
30 #ifndef SCM_POSITIVEP
31 #define SCM_POSITIVEP(obj) gi_nfalsep (scm_positive_p (obj))
32 #endif
33 #ifndef SCM_NEGATIVEP
34 #define SCM_NEGATIVEP(obj) gi_nfalsep (scm_negative_p (obj))
35 #endif
36 #ifndef SCM_PAIRP
37 #define SCM_PAIRP(obj) gi_nfalsep (scm_pair_p (obj))
38 #endif
39 #ifndef SCM_LISTP
40 #define SCM_LISTP(obj) gi_nfalsep (scm_list_p (obj))
41 #endif
42 #ifndef SCM_BOOLP
43 #define SCM_BOOLP(obj) gi_nfalsep (scm_boolean_p (obj))
44 #endif
45 #ifndef SCM_BOOL
46 #define SCM_BOOL(x) ((x) ? SCM_BOOL_T : SCM_BOOL_F)
47 #endif
48 #ifndef SCM_EQ_P
49 #define SCM_EQ_P(x, y) gi_nfalsep (scm_eq_p (x, y))
50 #endif
51 #ifndef SCM_CHARP
52 #define SCM_CHARP(obj) gi_nfalsep (scm_char_p (obj))
53 #endif
54 #ifndef SCM_CHAR
55 #define SCM_CHAR(x) SCM_ICHR (x)
56 #endif
57 #ifndef SCM_MAKE_CHAR
58 #define SCM_MAKE_CHAR(x) SCM_MAKICHR (x)
59 #endif
60 #ifndef SCM_OUT_OF_RANGE
61 #define SCM_OUT_OF_RANGE(pos, arg) \
62     scm_out_of_range_pos (FUNC_NAME, arg, gi_integer2scm (pos))
63 #endif
64 
65 /* Idioms.  */
66 
67 #define ASSERT_EXACT(n,obj)                     \
68   SCM_ASSERT_TYPE                               \
69   (gi_exactp (obj), obj,                        \
70    SCM_ARG ## n, FUNC_NAME, "exact")
71 
72 #define ASSERT_STRING(n,obj)                    \
73   SCM_ASSERT_TYPE                               \
74   (gi_stringp (obj), obj,                       \
75    SCM_ARG ## n, FUNC_NAME, "string")
76 
77 #define BSMOB_WHAT  "svz-binary"
78 #define BDATA_WHAT  "svz-binary-data"
79 
80 /* You are lucky: We have successfully resisted the urge
81    to name this ‘BEEE_FREEEEEEEE_XXXXX_ONE’.  */
82 #define BFREE(what,ptr,len)  gi_free (ptr, len, B ## what ## _WHAT)
83 
84 #endif /* not __GUILE_API_H__ */
85