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