Commit | Line | Data |
---|---|---|
405aaef9 | 1 | /* $Id: validate.h,v 1.16 2000-09-26 21:53:49 dirk Exp $ */ |
39bcc76e | 2 | /* Copyright (C) 1999, 2000 Free Software Foundation, Inc. |
e94e3f21 | 3 | * |
5bff3127 GB |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2, or (at your option) | |
7 | * any later version. | |
e94e3f21 | 8 | * |
5bff3127 GB |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
e94e3f21 | 13 | * |
5bff3127 GB |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this software; see the file COPYING. If not, write to | |
16 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |
17 | * Boston, MA 02111-1307 USA | |
1bbd0b84 | 18 | * |
5bff3127 GB |
19 | * As a special exception, the Free Software Foundation gives permission |
20 | * for additional uses of the text contained in its release of GUILE. | |
21 | * | |
22 | * The exception is that, if you link the GUILE library with other files | |
23 | * to produce an executable, this does not by itself cause the | |
24 | * resulting executable to be covered by the GNU General Public License. | |
25 | * Your use of that executable is in no way restricted on account of | |
26 | * linking the GUILE library code into it. | |
27 | * | |
28 | * This exception does not however invalidate any other reasons why | |
29 | * the executable file might be covered by the GNU General Public License. | |
30 | * | |
31 | * This exception applies only to the code released by the | |
32 | * Free Software Foundation under the name GUILE. If you copy | |
33 | * code from other Free Software Foundation releases into a copy of | |
34 | * GUILE, as the General Public License permits, the exception does | |
35 | * not apply to the code that you add in this way. To avoid misleading | |
36 | * anyone as to the status of such modified files, you must delete | |
37 | * this exception notice from them. | |
38 | * | |
39 | * If you write modifications of your own for GUILE, it is your choice | |
40 | * whether to permit this exception to apply to your modifications. | |
41 | * If you do not wish that, delete this exception notice. */ | |
42 | ||
43 | /* Written by Greg J. Badros <gjb@cs.washington.edu>, Dec-1999 */ | |
1bbd0b84 GB |
44 | |
45 | #ifndef SCM_VALIDATE_H__ | |
46 | #define SCM_VALIDATE_H__ | |
47 | ||
39bcc76e | 48 | #define SCM_FUNC_NAME (scm_makfrom0str (FUNC_NAME)) |
1bbd0b84 | 49 | |
39bcc76e | 50 | #define SCM_SYSERROR do { scm_syserror (FUNC_NAME); } while (0) |
1bbd0b84 | 51 | |
39bcc76e | 52 | #define SCM_MEMORY_ERROR do { scm_memory_error (FUNC_NAME); } while (0) |
1bbd0b84 | 53 | |
39bcc76e MD |
54 | #define SCM_SYSERROR_MSG(str, args, val) \ |
55 | do { scm_syserror_msg (FUNC_NAME, (str), (args), (val)); } while (0) | |
1bbd0b84 | 56 | |
39bcc76e MD |
57 | #define SCM_WTA(pos, scm) \ |
58 | do { scm_wta (scm, (char *) pos, FUNC_NAME); } while (0) | |
1bbd0b84 | 59 | |
39bcc76e MD |
60 | #define RETURN_SCM_WTA(pos, scm) \ |
61 | do { return scm_wta (scm, (char *) pos, FUNC_NAME); } while (0) | |
1bbd0b84 | 62 | |
39bcc76e MD |
63 | #define SCM_MISC_ERROR(str, args) \ |
64 | do { scm_misc_error (FUNC_NAME, str, args); } while (0) | |
1bbd0b84 | 65 | |
39bcc76e MD |
66 | #define SCM_WRONG_TYPE_ARG(pos, obj) \ |
67 | do { scm_wrong_type_arg (FUNC_NAME, pos, obj); } while (0) | |
1bbd0b84 | 68 | |
39bcc76e | 69 | #define SCM_NUM2ULONG(pos, arg) (scm_num2ulong (arg, (char *) pos, FUNC_NAME)) |
1bbd0b84 | 70 | |
39bcc76e | 71 | #define SCM_NUM2LONG(pos, arg) (scm_num2long (arg, (char *) pos, FUNC_NAME)) |
1bbd0b84 | 72 | |
39bcc76e MD |
73 | #define SCM_NUM2LONG_DEF(pos, arg, def) \ |
74 | (SCM_UNBNDP (arg) ? def : scm_num2long (arg, (char *) pos, FUNC_NAME)) | |
c1bfcf60 | 75 | |
39bcc76e MD |
76 | #define SCM_NUM2LONG_LONG(pos, arg) \ |
77 | (scm_num2long_long (arg, (char *) pos, FUNC_NAME)) | |
1bbd0b84 | 78 | |
39bcc76e MD |
79 | #define SCM_OUT_OF_RANGE(pos, arg) \ |
80 | do { scm_out_of_range_pos (FUNC_NAME, arg, SCM_MAKINUM (pos)); } while (0) | |
1bbd0b84 | 81 | |
39bcc76e | 82 | #define SCM_ASSERT_RANGE(pos, arg, f) \ |
fdf25853 | 83 | do { if (!(f)) scm_out_of_range (FUNC_NAME, arg); } while (0) |
1bbd0b84 | 84 | |
39bcc76e MD |
85 | #define SCM_MUST_MALLOC_TYPE(type) \ |
86 | ((type *) scm_must_malloc (sizeof (type), FUNC_NAME)) | |
1bbd0b84 | 87 | |
39bcc76e MD |
88 | #define SCM_MUST_MALLOC_TYPE_NUM(type, num) \ |
89 | ((type *) scm_must_malloc (sizeof (type) * (num), FUNC_NAME)) | |
1bbd0b84 | 90 | |
39bcc76e | 91 | #define SCM_MUST_MALLOC(size) (scm_must_malloc ((size), FUNC_NAME)) |
1bbd0b84 | 92 | |
39bcc76e MD |
93 | #define SCM_MAKE_VALIDATE(pos, var, pred) \ |
94 | do { \ | |
95 | SCM_ASSERT_TYPE (SCM_ ## pred (var), var, pos, FUNC_NAME, #pred); \ | |
96 | } while (0) | |
6b5a304f | 97 | |
6e8d25a6 GB |
98 | \f |
99 | ||
af45e3b0 DH |
100 | #define SCM_VALIDATE_REST_ARGUMENT(x) \ |
101 | do { \ | |
102 | if (SCM_DEBUG_REST_ARGUMENT) { \ | |
103 | if (scm_ilength (x) < 0) { \ | |
104 | SCM_MISC_ERROR ("Rest arguments do not form a proper list.", SCM_EOL); \ | |
105 | } \ | |
106 | } \ | |
107 | } while (0) | |
108 | ||
39bcc76e | 109 | #define SCM_VALIDATE_NIM(pos, scm) SCM_MAKE_VALIDATE (pos, scm, NIMP) |
6e8d25a6 | 110 | |
39bcc76e | 111 | #define SCM_VALIDATE_BOOL(pos, flag) SCM_MAKE_VALIDATE(pos, flag, BOOLP) |
1bbd0b84 | 112 | |
39bcc76e MD |
113 | #define SCM_VALIDATE_BOOL_COPY(pos, flag, cvar) \ |
114 | do { \ | |
115 | SCM_ASSERT (SCM_BOOLP (flag), flag, pos, FUNC_NAME); \ | |
9a09deb1 | 116 | cvar = SCM_EQ_P (flag, SCM_BOOL_T) ? 1 : 0; \ |
39bcc76e | 117 | } while (0) |
1bbd0b84 | 118 | |
f5f2dcff | 119 | #define SCM_VALIDATE_CHAR(pos, scm) SCM_MAKE_VALIDATE (pos, scm, CHARP) |
1bbd0b84 | 120 | |
39bcc76e MD |
121 | #define SCM_VALIDATE_CHAR_COPY(pos, scm, cvar) \ |
122 | do { \ | |
123 | SCM_ASSERT (SCM_CHARP (scm), scm, pos, FUNC_NAME); \ | |
124 | cvar = SCM_CHAR (scm); \ | |
125 | } while (0) | |
1bbd0b84 | 126 | |
39bcc76e | 127 | #define SCM_VALIDATE_ROSTRING(pos, str) SCM_MAKE_VALIDATE (pos, str, ROSTRINGP) |
1bbd0b84 | 128 | |
39bcc76e MD |
129 | #define SCM_VALIDATE_ROSTRING_COPY(pos, str, cvar) \ |
130 | do { \ | |
131 | SCM_ASSERT (SCM_ROSTRINGP (str), str, pos, FUNC_NAME); \ | |
132 | cvar = SCM_ROCHARS (str); \ | |
133 | } while (0) | |
1bbd0b84 | 134 | |
39bcc76e MD |
135 | #define SCM_VALIDATE_NULLORROSTRING_COPY(pos, str, cvar) \ |
136 | do { \ | |
137 | SCM_ASSERT (SCM_FALSEP (str) || SCM_ROSTRINGP (str), \ | |
138 | str, pos, FUNC_NAME); \ | |
139 | if (SCM_FALSEP(str)) \ | |
140 | cvar = NULL; \ | |
141 | else \ | |
142 | cvar = SCM_ROCHARS(str); \ | |
143 | } while (0) | |
1bbd0b84 | 144 | |
39bcc76e | 145 | #define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE (pos, str, STRINGP) |
1bbd0b84 | 146 | |
39bcc76e MD |
147 | #define SCM_VALIDATE_STRINGORSUBSTR(pos, str) \ |
148 | do { \ | |
149 | SCM_ASSERT (SCM_STRINGP (str) || SCM_SUBSTRP (str), \ | |
150 | str, pos, FUNC_NAME); \ | |
151 | } while (0) | |
1bbd0b84 | 152 | |
39bcc76e MD |
153 | #define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \ |
154 | do { \ | |
155 | SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \ | |
86c991c2 | 156 | cvar = SCM_STRING_CHARS(str); \ |
39bcc76e | 157 | } while (0) |
1bbd0b84 | 158 | |
39bcc76e MD |
159 | #define SCM_VALIDATE_RWSTRING(pos, str) \ |
160 | do { \ | |
161 | SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \ | |
162 | if (!SCM_RWSTRINGP (str)) \ | |
163 | scm_misc_error (FUNC_NAME, "argument is a read-only string", str); \ | |
164 | } while (0) | |
1bbd0b84 | 165 | |
39bcc76e | 166 | #define SCM_VALIDATE_REAL(pos, z) SCM_MAKE_VALIDATE (pos, z, REALP) |
1bbd0b84 | 167 | |
2891588b MD |
168 | #define SCM_VALIDATE_NUMBER_COPY(pos, z, cvar) \ |
169 | do { \ | |
170 | if (SCM_INUMP (z)) \ | |
171 | cvar = (double) SCM_INUM (z); \ | |
172 | else if (SCM_REALP (z)) \ | |
173 | cvar = SCM_REAL_VALUE (z); \ | |
174 | else if (SCM_BIGP (z)) \ | |
175 | cvar = scm_big2dbl (z); \ | |
176 | else \ | |
177 | { \ | |
178 | cvar = 0.0; \ | |
179 | SCM_WTA (pos, z); \ | |
180 | } \ | |
1a94d961 MD |
181 | } while (0) |
182 | ||
ee1a1c20 MD |
183 | #define SCM_VALIDATE_NUMBER_DEF_COPY(pos, number, def, cvar) \ |
184 | do { \ | |
185 | if (SCM_UNBNDP (number)) \ | |
186 | cvar = def; \ | |
187 | else \ | |
188 | SCM_VALIDATE_NUMBER_COPY(pos, number, cvar); \ | |
189 | } while (0) | |
190 | ||
39bcc76e | 191 | #define SCM_VALIDATE_INUM(pos, k) SCM_MAKE_VALIDATE (pos, k, INUMP) |
1bbd0b84 | 192 | |
39bcc76e MD |
193 | #define SCM_VALIDATE_INUM_COPY(pos, k, cvar) \ |
194 | do { \ | |
195 | SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \ | |
196 | cvar = SCM_INUM (k); \ | |
197 | } while (0) | |
1bbd0b84 | 198 | |
39bcc76e MD |
199 | #define SCM_VALIDATE_ULONG_COPY(pos, k, cvar) \ |
200 | do { \ | |
201 | cvar = SCM_NUM2ULONG (pos, k); \ | |
202 | } while (0) | |
2cd04b42 | 203 | |
39bcc76e MD |
204 | #define SCM_VALIDATE_LONG_COPY(pos, k, cvar) \ |
205 | do { \ | |
206 | cvar = SCM_NUM2LONG(pos, k); \ | |
207 | } while (0) | |
2cd04b42 | 208 | |
39bcc76e | 209 | #define SCM_VALIDATE_BIGINT(pos, k) SCM_MAKE_VALIDATE (pos, k, BIGP) |
1bbd0b84 | 210 | |
39bcc76e MD |
211 | #define SCM_VALIDATE_INUM_MIN(pos, k, min) \ |
212 | do { \ | |
213 | SCM_ASSERT (SCM_INUMP(k), k, pos, FUNC_NAME); \ | |
214 | SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \ | |
215 | } while (0) | |
1bbd0b84 | 216 | |
39bcc76e MD |
217 | #define SCM_VALIDATE_INUM_MIN_COPY(pos, k, min, cvar) \ |
218 | do { \ | |
219 | SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \ | |
fdf25853 | 220 | SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \ |
39bcc76e | 221 | cvar = SCM_INUM (k); \ |
39bcc76e | 222 | } while (0) |
1bbd0b84 | 223 | |
39bcc76e MD |
224 | #define SCM_VALIDATE_INUM_MIN_DEF_COPY(pos, k, min, default, cvar) \ |
225 | do { \ | |
226 | if (SCM_UNBNDP (k)) \ | |
227 | k = SCM_MAKINUM (default); \ | |
228 | SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \ | |
fdf25853 | 229 | SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \ |
39bcc76e | 230 | cvar = SCM_INUM (k); \ |
39bcc76e | 231 | } while (0) |
1bbd0b84 | 232 | |
39bcc76e MD |
233 | #define SCM_VALIDATE_INUM_DEF(pos, k, default) \ |
234 | do { \ | |
235 | if (SCM_UNBNDP (k)) \ | |
236 | k = SCM_MAKINUM (default); \ | |
237 | else SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \ | |
238 | } while (0) | |
1bbd0b84 | 239 | |
39bcc76e MD |
240 | #define SCM_VALIDATE_INUM_DEF_COPY(pos, k, default, cvar) \ |
241 | do { \ | |
242 | if (SCM_UNBNDP (k)) \ | |
243 | { \ | |
244 | k = SCM_MAKINUM (default); \ | |
245 | cvar = default; \ | |
246 | } \ | |
247 | else \ | |
248 | { \ | |
249 | SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \ | |
250 | cvar = SCM_INUM (k); \ | |
251 | } \ | |
252 | } while (0) | |
1bbd0b84 GB |
253 | |
254 | /* [low,high) */ | |
120d4924 GB |
255 | #define SCM_VALIDATE_INUM_RANGE(pos,k,low,high) \ |
256 | do { SCM_ASSERT(SCM_INUMP(k), k, pos, FUNC_NAME); \ | |
257 | SCM_ASSERT_RANGE(pos,k, \ | |
258 | (SCM_INUM (k) >= low && \ | |
259 | SCM_INUM (k) < high)); \ | |
260 | } while (0) | |
39bcc76e | 261 | |
7642eb4b MD |
262 | #define SCM_VALIDATE_INUM_RANGE_COPY(pos, k, low, high, cvar) \ |
263 | do { \ | |
264 | SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \ | |
fdf25853 | 265 | SCM_ASSERT_RANGE (pos, k, low <= SCM_INUM (k) && SCM_INUM (k) < high); \ |
7642eb4b | 266 | cvar = SCM_INUM (k); \ |
7642eb4b MD |
267 | } while (0) |
268 | ||
39bcc76e | 269 | #define SCM_VALIDATE_NULL(pos, scm) SCM_MAKE_VALIDATE (pos, scm, NULLP) |
1bbd0b84 | 270 | |
39bcc76e | 271 | #define SCM_VALIDATE_CONS(pos, scm) SCM_MAKE_VALIDATE (pos, scm, CONSP) |
1bbd0b84 | 272 | |
39bcc76e MD |
273 | #define SCM_VALIDATE_LIST(pos, lst) \ |
274 | do { \ | |
275 | SCM_ASSERT (scm_ilength (lst) >= 0, lst, pos, FUNC_NAME); \ | |
276 | } while (0) | |
1bbd0b84 | 277 | |
39bcc76e MD |
278 | #define SCM_VALIDATE_NONEMPTYLIST(pos, lst) \ |
279 | do { \ | |
280 | SCM_ASSERT (scm_ilength (lst) > 0, lst, pos, FUNC_NAME); \ | |
281 | } while (0) | |
1bbd0b84 | 282 | |
39bcc76e MD |
283 | #define SCM_VALIDATE_LIST_COPYLEN(pos, lst, cvar) \ |
284 | do { \ | |
285 | cvar = scm_ilength (lst); \ | |
286 | SCM_ASSERT (cvar >= 0, lst, pos, FUNC_NAME); \ | |
287 | } while (0) | |
c1bfcf60 | 288 | |
39bcc76e MD |
289 | #define SCM_VALIDATE_NONEMPTYLIST_COPYLEN(pos, lst, cvar) \ |
290 | do { \ | |
291 | cvar = scm_ilength (lst); \ | |
292 | SCM_ASSERT (cvar >= 1, lst, pos, FUNC_NAME); \ | |
293 | } while (0) | |
1bbd0b84 | 294 | |
39bcc76e MD |
295 | #define SCM_VALIDATE_ALISTCELL(pos, alist) \ |
296 | do { \ | |
297 | SCM_ASSERT (SCM_CONSP (alist) && SCM_CONSP (SCM_CAR (alist)), \ | |
298 | alist, pos, FUNC_NAME); \ | |
299 | } while (0) | |
1bbd0b84 | 300 | |
39bcc76e | 301 | #define SCM_VALIDATE_ALISTCELL_COPYSCM(pos, alist, cvar) \ |
1bbd0b84 | 302 | do { \ |
39bcc76e MD |
303 | SCM_ASSERT (SCM_CONSP (alist), alist, pos, FUNC_NAME); \ |
304 | cvar = SCM_CAR (alist); \ | |
305 | SCM_ASSERT (SCM_CONSP (cvar), alist, pos, FUNC_NAME); \ | |
30939477 | 306 | } while (0) |
1bbd0b84 | 307 | |
39bcc76e | 308 | #define SCM_VALIDATE_OPORT_VALUE(pos, port) \ |
1bbd0b84 | 309 | do { \ |
39bcc76e MD |
310 | SCM_ASSERT (scm_valid_oport_value_p (port), port, pos, FUNC_NAME); \ |
311 | } while (0) | |
312 | ||
313 | #define SCM_VALIDATE_PRINTSTATE(pos, a) SCM_MAKE_VALIDATE(pos,a,PRINT_STATE_P) | |
1bbd0b84 | 314 | |
39bcc76e MD |
315 | #define SCM_VALIDATE_SMOB(pos, obj, type) \ |
316 | do { \ | |
317 | SCM_ASSERT ((SCM_NIMP (obj) && SCM_TYP16 (obj) == scm_tc16_ ## type), \ | |
318 | obj, pos, FUNC_NAME); \ | |
319 | } while (0) | |
1bbd0b84 | 320 | |
39bcc76e | 321 | #define SCM_VALIDATE_THREAD(pos, a) SCM_MAKE_VALIDATE (pos, a, THREADP) |
1bbd0b84 | 322 | |
39bcc76e MD |
323 | #define SCM_VALIDATE_THUNK(pos, thunk) \ |
324 | do { \ | |
325 | SCM_ASSERT (SCM_NFALSEP (scm_thunk_p (thunk)), thunk, pos, FUNC_NAME); \ | |
326 | } while (0) | |
1bbd0b84 | 327 | |
39bcc76e | 328 | #define SCM_VALIDATE_SYMBOL(pos, sym) SCM_MAKE_VALIDATE (pos, sym, SYMBOLP) |
0c95b57d | 329 | |
39bcc76e | 330 | #define SCM_VALIDATE_VARIABLE(pos, var) SCM_MAKE_VALIDATE (pos, var, VARIABLEP) |
1bbd0b84 | 331 | |
39bcc76e | 332 | #define SCM_VALIDATE_MEMOIZED(pos, obj) SCM_MAKE_VALIDATE (pos, obj, MEMOIZEDP) |
1bbd0b84 | 333 | |
39bcc76e | 334 | #define SCM_VALIDATE_CLOSURE(pos, obj) SCM_MAKE_VALIDATE (pos, obj, CLOSUREP) |
1bbd0b84 | 335 | |
39bcc76e MD |
336 | #define SCM_VALIDATE_PROC(pos, proc) \ |
337 | do { \ | |
9a09deb1 | 338 | SCM_ASSERT (SCM_EQ_P (scm_procedure_p (proc), SCM_BOOL_T), proc, pos, FUNC_NAME); \ |
39bcc76e | 339 | } while (0) |
1bbd0b84 | 340 | |
39bcc76e MD |
341 | #define SCM_VALIDATE_NULLORCONS(pos, env) \ |
342 | do { \ | |
343 | SCM_ASSERT (SCM_NULLP (env) || SCM_CONSP (env), env, pos, FUNC_NAME); \ | |
344 | } while (0) | |
1bbd0b84 | 345 | |
39bcc76e | 346 | #define SCM_VALIDATE_HOOK(pos, a) SCM_MAKE_VALIDATE (pos, a, HOOKP) |
1bbd0b84 | 347 | |
39bcc76e | 348 | #define SCM_VALIDATE_RGXP(pos, a) SCM_MAKE_VALIDATE (pos, a, RGXP) |
1bbd0b84 | 349 | |
39bcc76e | 350 | #define SCM_VALIDATE_OPDIR(pos, port) SCM_MAKE_VALIDATE (pos, port, OPDIRP) |
1bbd0b84 | 351 | |
39bcc76e | 352 | #define SCM_VALIDATE_DIR(pos, port) SCM_MAKE_VALIDATE (pos, port, DIRP) |
1bbd0b84 | 353 | |
39bcc76e | 354 | #define SCM_VALIDATE_PORT(pos, port) SCM_MAKE_VALIDATE (pos, port, PORTP) |
1bbd0b84 | 355 | |
39bcc76e MD |
356 | #define SCM_VALIDATE_INPUT_PORT(pos, port) \ |
357 | SCM_MAKE_VALIDATE (pos, port, INPUT_PORT_P) | |
1bbd0b84 | 358 | |
39bcc76e MD |
359 | #define SCM_VALIDATE_OUTPUT_PORT(pos, port) \ |
360 | SCM_MAKE_VALIDATE (pos, port, OUTPUT_PORT_P) | |
1bbd0b84 | 361 | |
39bcc76e | 362 | #define SCM_VALIDATE_FPORT(pos, port) SCM_MAKE_VALIDATE (pos, port, FPORTP) |
1bbd0b84 | 363 | |
39bcc76e | 364 | #define SCM_VALIDATE_OPFPORT(pos, port) SCM_MAKE_VALIDATE (pos, port, OPFPORTP) |
1bbd0b84 | 365 | |
39bcc76e MD |
366 | #define SCM_VALIDATE_OPINPORT(pos, port) \ |
367 | SCM_MAKE_VALIDATE (pos, port, OPINPORTP) | |
1bbd0b84 GB |
368 | |
369 | #define SCM_VALIDATE_OPENPORT(pos,port) \ | |
39bcc76e MD |
370 | do { \ |
371 | SCM_ASSERT (SCM_PORTP (port) && SCM_OPENP (port), \ | |
372 | port, pos, FUNC_NAME); \ | |
373 | } while (0) | |
1bbd0b84 | 374 | |
39bcc76e | 375 | #define SCM_VALIDATE_OPPORT(pos, port) SCM_MAKE_VALIDATE (pos, port, OPPORTP) |
1bbd0b84 | 376 | |
39bcc76e MD |
377 | #define SCM_VALIDATE_OPOUTPORT(pos, port) \ |
378 | SCM_MAKE_VALIDATE (pos, port, OPOUTPORTP) | |
1bbd0b84 | 379 | |
39bcc76e | 380 | #define SCM_VALIDATE_FLUID(pos, fluid) SCM_MAKE_VALIDATE (pos, fluid, FLUIDP) |
1bbd0b84 | 381 | |
39bcc76e | 382 | #define SCM_VALIDATE_KEYWORD(pos, v) SCM_MAKE_VALIDATE (pos, v, KEYWORDP) |
1bbd0b84 | 383 | |
39bcc76e | 384 | #define SCM_VALIDATE_STACK(pos, v) SCM_MAKE_VALIDATE (pos, v, STACKP) |
1bbd0b84 | 385 | |
39bcc76e | 386 | #define SCM_VALIDATE_FRAME(pos, v) SCM_MAKE_VALIDATE (pos, v, FRAMEP) |
1bbd0b84 | 387 | |
39bcc76e | 388 | #define SCM_VALIDATE_RSTATE(pos, v) SCM_MAKE_VALIDATE (pos, v, RSTATEP) |
1bbd0b84 GB |
389 | |
390 | #define SCM_VALIDATE_ARRAY(pos,v) \ | |
39bcc76e MD |
391 | do { \ |
392 | SCM_ASSERT (SCM_NIMP (v) \ | |
393 | && !SCM_FALSEP (scm_array_p (v, SCM_UNDEFINED)), \ | |
394 | v, pos, FUNC_NAME); \ | |
395 | } while (0) | |
1bbd0b84 | 396 | |
39bcc76e | 397 | #define SCM_VALIDATE_VECTOR(pos, v) SCM_MAKE_VALIDATE (pos, v, VECTORP) |
1bbd0b84 | 398 | |
39bcc76e MD |
399 | #define SCM_VALIDATE_VECTOR_OR_DVECTOR(pos, v) \ |
400 | do { \ | |
401 | SCM_ASSERT ((SCM_VECTORP (v) \ | |
402 | || (SCM_NIMP (v) && SCM_TYP7 (v) == scm_tc7_dvect)), \ | |
403 | v, pos, FUNC_NAME); \ | |
404 | } while (0) | |
368cf54d | 405 | |
39bcc76e | 406 | #define SCM_VALIDATE_STRUCT(pos, v) SCM_MAKE_VALIDATE (pos, v, STRUCTP) |
1bbd0b84 | 407 | |
39bcc76e MD |
408 | #define SCM_VALIDATE_VTABLE(pos, v) \ |
409 | do { \ | |
410 | SCM_ASSERT (SCM_NIMP (v) && SCM_NFALSEP (scm_struct_vtable_p (v)), \ | |
411 | v, pos, FUNC_NAME); \ | |
412 | } while (0) | |
1bbd0b84 | 413 | |
39bcc76e MD |
414 | #define SCM_VALIDATE_VECTOR_LEN(pos, v, len) \ |
415 | do { \ | |
416 | SCM_ASSERT (SCM_VECTORP (v) && len == SCM_LENGTH (v), v, pos, FUNC_NAME); \ | |
417 | } while (0) | |
1bbd0b84 GB |
418 | |
419 | #endif | |
89e00824 ML |
420 | |
421 | /* | |
422 | Local Variables: | |
423 | c-file-style: "gnu" | |
424 | End: | |
425 | */ |