* Makefile.am (subpkgdatadir): VERSION -> GUILE_EFFECTIVE_VERSION.
[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
6182ceac 6/* Copyright (C) 1999,2000,2001, 2002 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
6182ceac
MV
144#define SCM_MAKE_VALIDATE_MSG(pos, var, pred, msg) \
145 do { \
146 SCM_ASSERT_TYPE (SCM_ ## pred (var), var, pos, FUNC_NAME, msg); \
147 } while (0)
148
6e8d25a6
GB
149\f
150
af45e3b0
DH
151#define SCM_VALIDATE_REST_ARGUMENT(x) \
152 do { \
153 if (SCM_DEBUG_REST_ARGUMENT) { \
154 if (scm_ilength (x) < 0) { \
155 SCM_MISC_ERROR ("Rest arguments do not form a proper list.", SCM_EOL); \
156 } \
157 } \
158 } while (0)
159
6182ceac 160#define SCM_VALIDATE_NIM(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, NIMP, "non-immediate")
6e8d25a6 161
6182ceac 162#define SCM_VALIDATE_BOOL(pos, flag) SCM_MAKE_VALIDATE_MSG(pos, flag, BOOLP, "boolean")
1bbd0b84 163
39bcc76e
MD
164#define SCM_VALIDATE_BOOL_COPY(pos, flag, cvar) \
165 do { \
166 SCM_ASSERT (SCM_BOOLP (flag), flag, pos, FUNC_NAME); \
9a09deb1 167 cvar = SCM_EQ_P (flag, SCM_BOOL_T) ? 1 : 0; \
39bcc76e 168 } while (0)
1bbd0b84 169
6182ceac 170#define SCM_VALIDATE_CHAR(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, CHARP, "character")
1bbd0b84 171
39bcc76e
MD
172#define SCM_VALIDATE_CHAR_COPY(pos, scm, cvar) \
173 do { \
174 SCM_ASSERT (SCM_CHARP (scm), scm, pos, FUNC_NAME); \
175 cvar = SCM_CHAR (scm); \
176 } while (0)
1bbd0b84 177
6182ceac 178#define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE_MSG (pos, str, STRINGP, "string")
1bbd0b84 179
39bcc76e
MD
180#define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \
181 do { \
182 SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \
86c991c2 183 cvar = SCM_STRING_CHARS(str); \
39bcc76e 184 } while (0)
1bbd0b84 185
60d02d09
GH
186/* validate a string and optional start/end arguments which default to
187 0/string-len. this is unrelated to the old shared substring
188 support, so please do not deprecate it :) */
189#define SCM_VALIDATE_SUBSTRING_SPEC_COPY(pos_str, str, c_str, \
190 pos_start, start, c_start,\
191 pos_end, end, c_end) \
192 do {\
193 SCM_VALIDATE_STRING_COPY (pos_str, str, c_str);\
194 SCM_VALIDATE_INUM_DEF_COPY (pos_start, start, 0, c_start);\
195 SCM_VALIDATE_INUM_DEF_COPY (pos_end, end, SCM_STRING_LENGTH (str), c_end);\
196 SCM_ASSERT_RANGE (pos_start, start,\
36284627
DH
197 0 <= c_start \
198 && (size_t) c_start <= SCM_STRING_LENGTH (str));\
60d02d09 199 SCM_ASSERT_RANGE (pos_end, end,\
36284627
DH
200 c_start <= c_end \
201 && (size_t) c_end <= SCM_STRING_LENGTH (str));\
60d02d09
GH
202 } while (0)
203
6182ceac 204#define SCM_VALIDATE_REAL(pos, z) SCM_MAKE_VALIDATE_MSG (pos, z, REALP, "real")
1bbd0b84 205
6182ceac 206#define SCM_VALIDATE_NUMBER(pos, z) SCM_MAKE_VALIDATE_MSG (pos, z, NUMBERP, "number")
e8a46ba8 207
6182ceac 208#define SCM_VALIDATE_INUM(pos, k) SCM_MAKE_VALIDATE_MSG (pos, k, INUMP, "exact integer")
1bbd0b84 209
39bcc76e
MD
210#define SCM_VALIDATE_INUM_COPY(pos, k, cvar) \
211 do { \
212 SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
213 cvar = SCM_INUM (k); \
214 } while (0)
1bbd0b84 215
d098d810
TTN
216#define SCM_VALIDATE_USHORT_COPY(pos, k, cvar) \
217 do { \
218 cvar = SCM_NUM2USHORT (pos, k); \
219 } while (0)
220
221#define SCM_VALIDATE_SHORT_COPY(pos, k, cvar) \
222 do { \
223 cvar = SCM_NUM2SHORT (pos, k); \
224 } while (0)
225
226#define SCM_VALIDATE_UINT_COPY(pos, k, cvar) \
227 do { \
228 cvar = SCM_NUM2UINT (pos, k); \
229 } while (0)
230
231#define SCM_VALIDATE_INT_COPY(pos, k, cvar) \
232 do { \
233 cvar = SCM_NUM2INT (pos, k); \
234 } while (0)
235
39bcc76e
MD
236#define SCM_VALIDATE_ULONG_COPY(pos, k, cvar) \
237 do { \
238 cvar = SCM_NUM2ULONG (pos, k); \
239 } while (0)
2cd04b42 240
39bcc76e
MD
241#define SCM_VALIDATE_LONG_COPY(pos, k, cvar) \
242 do { \
e4b265d8 243 cvar = SCM_NUM2LONG (pos, k); \
39bcc76e 244 } while (0)
2cd04b42 245
581ded70
MD
246#define SCM_VALIDATE_FLOAT_COPY(pos, k, cvar) \
247 do { \
248 cvar = SCM_NUM2FLOAT (pos, k); \
249 } while (0)
250
251#define SCM_VALIDATE_DOUBLE_COPY(pos, k, cvar) \
252 do { \
253 cvar = SCM_NUM2DOUBLE (pos, k); \
254 } while (0)
255
6182ceac 256#define SCM_VALIDATE_BIGINT(pos, k) SCM_MAKE_VALIDATE_MSG (pos, k, BIGP, "bignum")
1bbd0b84 257
39bcc76e
MD
258#define SCM_VALIDATE_INUM_MIN(pos, k, min) \
259 do { \
260 SCM_ASSERT (SCM_INUMP(k), k, pos, FUNC_NAME); \
261 SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
262 } while (0)
1bbd0b84 263
39bcc76e
MD
264#define SCM_VALIDATE_INUM_MIN_COPY(pos, k, min, cvar) \
265 do { \
266 SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
fdf25853 267 SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
39bcc76e 268 cvar = SCM_INUM (k); \
39bcc76e 269 } while (0)
1bbd0b84 270
39bcc76e
MD
271#define SCM_VALIDATE_INUM_MIN_DEF_COPY(pos, k, min, default, cvar) \
272 do { \
273 if (SCM_UNBNDP (k)) \
274 k = SCM_MAKINUM (default); \
275 SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
fdf25853 276 SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
39bcc76e 277 cvar = SCM_INUM (k); \
39bcc76e 278 } while (0)
1bbd0b84 279
39bcc76e
MD
280#define SCM_VALIDATE_INUM_DEF(pos, k, default) \
281 do { \
282 if (SCM_UNBNDP (k)) \
283 k = SCM_MAKINUM (default); \
284 else SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
285 } while (0)
1bbd0b84 286
39bcc76e
MD
287#define SCM_VALIDATE_INUM_DEF_COPY(pos, k, default, cvar) \
288 do { \
289 if (SCM_UNBNDP (k)) \
290 { \
291 k = SCM_MAKINUM (default); \
292 cvar = default; \
293 } \
294 else \
295 { \
296 SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
297 cvar = SCM_INUM (k); \
298 } \
299 } while (0)
1bbd0b84 300
68665a97
MD
301#define SCM_VALIDATE_DOUBLE_DEF_COPY(pos, k, default, cvar) \
302 do { \
303 if (SCM_UNBNDP (k)) \
304 { \
305 k = scm_make_real (default); \
306 cvar = default; \
307 } \
308 else \
309 { \
310 cvar = SCM_NUM2DOUBLE (pos, k); \
311 } \
312 } while (0)
313
34d19ef6
HWN
314/* [low, high) */
315#define SCM_VALIDATE_INUM_RANGE(pos, k, low, high) \
120d4924 316 do { SCM_ASSERT(SCM_INUMP(k), k, pos, FUNC_NAME); \
34d19ef6 317 SCM_ASSERT_RANGE(pos, k, \
120d4924
GB
318 (SCM_INUM (k) >= low && \
319 SCM_INUM (k) < high)); \
320 } while (0)
39bcc76e 321
7642eb4b
MD
322#define SCM_VALIDATE_INUM_RANGE_COPY(pos, k, low, high, cvar) \
323 do { \
324 SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
fdf25853 325 SCM_ASSERT_RANGE (pos, k, low <= SCM_INUM (k) && SCM_INUM (k) < high); \
7642eb4b 326 cvar = SCM_INUM (k); \
7642eb4b
MD
327 } while (0)
328
6182ceac 329#define SCM_VALIDATE_NULL(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, NULLP, "null")
1bbd0b84 330
6182ceac 331#define SCM_VALIDATE_NULL_OR_NIL(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, NULL_OR_NIL_P, "null")
c96d76b8 332
6182ceac 333#define SCM_VALIDATE_CONS(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, CONSP, "pair")
1bbd0b84 334
39bcc76e
MD
335#define SCM_VALIDATE_LIST(pos, lst) \
336 do { \
337 SCM_ASSERT (scm_ilength (lst) >= 0, lst, pos, FUNC_NAME); \
338 } while (0)
1bbd0b84 339
39bcc76e
MD
340#define SCM_VALIDATE_NONEMPTYLIST(pos, lst) \
341 do { \
342 SCM_ASSERT (scm_ilength (lst) > 0, lst, pos, FUNC_NAME); \
343 } while (0)
1bbd0b84 344
39bcc76e
MD
345#define SCM_VALIDATE_LIST_COPYLEN(pos, lst, cvar) \
346 do { \
347 cvar = scm_ilength (lst); \
348 SCM_ASSERT (cvar >= 0, lst, pos, FUNC_NAME); \
349 } while (0)
c1bfcf60 350
39bcc76e
MD
351#define SCM_VALIDATE_NONEMPTYLIST_COPYLEN(pos, lst, cvar) \
352 do { \
353 cvar = scm_ilength (lst); \
354 SCM_ASSERT (cvar >= 1, lst, pos, FUNC_NAME); \
355 } while (0)
1bbd0b84 356
39bcc76e
MD
357#define SCM_VALIDATE_ALISTCELL(pos, alist) \
358 do { \
359 SCM_ASSERT (SCM_CONSP (alist) && SCM_CONSP (SCM_CAR (alist)), \
360 alist, pos, FUNC_NAME); \
361 } while (0)
1bbd0b84 362
39bcc76e 363#define SCM_VALIDATE_ALISTCELL_COPYSCM(pos, alist, cvar) \
1bbd0b84 364 do { \
39bcc76e
MD
365 SCM_ASSERT (SCM_CONSP (alist), alist, pos, FUNC_NAME); \
366 cvar = SCM_CAR (alist); \
367 SCM_ASSERT (SCM_CONSP (cvar), alist, pos, FUNC_NAME); \
30939477 368 } while (0)
1bbd0b84 369
39bcc76e 370#define SCM_VALIDATE_OPORT_VALUE(pos, port) \
1bbd0b84 371 do { \
39bcc76e
MD
372 SCM_ASSERT (scm_valid_oport_value_p (port), port, pos, FUNC_NAME); \
373 } while (0)
374
6182ceac 375#define SCM_VALIDATE_PRINTSTATE(pos, a) SCM_MAKE_VALIDATE_MSG(pos, a, PRINT_STATE_P, "print-state")
1bbd0b84 376
39bcc76e
MD
377#define SCM_VALIDATE_SMOB(pos, obj, type) \
378 do { \
e841c3e0 379 SCM_ASSERT (SCM_TYP16_PREDICATE (scm_tc16_ ## type, obj), \
39bcc76e
MD
380 obj, pos, FUNC_NAME); \
381 } while (0)
1bbd0b84 382
39bcc76e
MD
383#define SCM_VALIDATE_THUNK(pos, thunk) \
384 do { \
b29058ff 385 SCM_ASSERT (!SCM_FALSEP (scm_thunk_p (thunk)), thunk, pos, FUNC_NAME); \
39bcc76e 386 } while (0)
1bbd0b84 387
6182ceac 388#define SCM_VALIDATE_SYMBOL(pos, sym) SCM_MAKE_VALIDATE_MSG (pos, sym, SYMBOLP, "symbol")
0c95b57d 389
6182ceac 390#define SCM_VALIDATE_VARIABLE(pos, var) SCM_MAKE_VALIDATE_MSG (pos, var, VARIABLEP, "variable")
1bbd0b84 391
6182ceac 392#define SCM_VALIDATE_MEMOIZED(pos, obj) SCM_MAKE_VALIDATE_MSG (pos, obj, MEMOIZEDP, "memoized code")
1bbd0b84 393
6182ceac 394#define SCM_VALIDATE_CLOSURE(pos, obj) SCM_MAKE_VALIDATE_MSG (pos, obj, CLOSUREP, "closure")
1bbd0b84 395
39bcc76e
MD
396#define SCM_VALIDATE_PROC(pos, proc) \
397 do { \
9a09deb1 398 SCM_ASSERT (SCM_EQ_P (scm_procedure_p (proc), SCM_BOOL_T), proc, pos, FUNC_NAME); \
39bcc76e 399 } while (0)
1bbd0b84 400
39bcc76e
MD
401#define SCM_VALIDATE_NULLORCONS(pos, env) \
402 do { \
403 SCM_ASSERT (SCM_NULLP (env) || SCM_CONSP (env), env, pos, FUNC_NAME); \
404 } while (0)
1bbd0b84 405
6182ceac 406#define SCM_VALIDATE_HOOK(pos, a) SCM_MAKE_VALIDATE_MSG (pos, a, HOOKP, "hook")
1bbd0b84 407
6182ceac 408#define SCM_VALIDATE_RGXP(pos, a) SCM_MAKE_VALIDATE_MSG (pos, a, RGXP, "regexp")
1bbd0b84 409
6182ceac 410#define SCM_VALIDATE_DIR(pos, port) SCM_MAKE_VALIDATE_MSG (pos, port, DIRP, "directory port")
1bbd0b84 411
6182ceac 412#define SCM_VALIDATE_PORT(pos, port) SCM_MAKE_VALIDATE_MSG (pos, port, PORTP, "port")
1bbd0b84 413
39bcc76e 414#define SCM_VALIDATE_INPUT_PORT(pos, port) \
6182ceac 415 SCM_MAKE_VALIDATE_MSG (pos, port, INPUT_PORT_P, "input port")
1bbd0b84 416
39bcc76e 417#define SCM_VALIDATE_OUTPUT_PORT(pos, port) \
6182ceac 418 SCM_MAKE_VALIDATE_MSG (pos, port, OUTPUT_PORT_P, "output port")
1bbd0b84 419
6182ceac 420#define SCM_VALIDATE_FPORT(pos, port) SCM_MAKE_VALIDATE_MSG (pos, port, FPORTP, "file port")
1bbd0b84 421
6182ceac 422#define SCM_VALIDATE_OPFPORT(pos, port) SCM_MAKE_VALIDATE_MSG (pos, port, OPFPORTP, "open file port")
1bbd0b84 423
39bcc76e 424#define SCM_VALIDATE_OPINPORT(pos, port) \
6182ceac 425 SCM_MAKE_VALIDATE_MSG (pos, port, OPINPORTP, "open input port")
1bbd0b84 426
34d19ef6 427#define SCM_VALIDATE_OPENPORT(pos, port) \
39bcc76e
MD
428 do { \
429 SCM_ASSERT (SCM_PORTP (port) && SCM_OPENP (port), \
430 port, pos, FUNC_NAME); \
431 } while (0)
1bbd0b84 432
6182ceac 433#define SCM_VALIDATE_OPPORT(pos, port) SCM_MAKE_VALIDATE_MSG (pos, port, OPPORTP, "open port")
1bbd0b84 434
39bcc76e 435#define SCM_VALIDATE_OPOUTPORT(pos, port) \
6182ceac 436 SCM_MAKE_VALIDATE_MSG (pos, port, OPOUTPORTP, "open output port")
1bbd0b84 437
e87a03fc 438#define SCM_VALIDATE_OPOUTSTRPORT(pos, port) \
6182ceac 439 SCM_MAKE_VALIDATE_MSG (pos, port, OPOUTSTRPORTP, "open output string port")
e87a03fc 440
6182ceac 441#define SCM_VALIDATE_FLUID(pos, fluid) SCM_MAKE_VALIDATE_MSG (pos, fluid, FLUIDP, "fluid")
1bbd0b84 442
6182ceac 443#define SCM_VALIDATE_KEYWORD(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, KEYWORDP, "keyword")
1bbd0b84 444
6182ceac 445#define SCM_VALIDATE_STACK(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, STACKP, "stack")
1bbd0b84 446
6182ceac 447#define SCM_VALIDATE_FRAME(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, FRAMEP, "frame")
1bbd0b84 448
6182ceac 449#define SCM_VALIDATE_RSTATE(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, RSTATEP, "random-generator-state")
1bbd0b84 450
34d19ef6 451#define SCM_VALIDATE_ARRAY(pos, v) \
39bcc76e 452 do { \
b29058ff 453 SCM_ASSERT (!SCM_IMP (v) \
39bcc76e
MD
454 && !SCM_FALSEP (scm_array_p (v, SCM_UNDEFINED)), \
455 v, pos, FUNC_NAME); \
456 } while (0)
1bbd0b84 457
6182ceac 458#define SCM_VALIDATE_VECTOR(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, VECTORP, "vector")
1bbd0b84 459
39bcc76e
MD
460#define SCM_VALIDATE_VECTOR_OR_DVECTOR(pos, v) \
461 do { \
462 SCM_ASSERT ((SCM_VECTORP (v) \
b29058ff 463 || (!SCM_IMP (v) && SCM_TYP7 (v) == scm_tc7_dvect)), \
39bcc76e
MD
464 v, pos, FUNC_NAME); \
465 } while (0)
368cf54d 466
6182ceac 467#define SCM_VALIDATE_STRUCT(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, STRUCTP, "struct")
1bbd0b84 468
39bcc76e
MD
469#define SCM_VALIDATE_VTABLE(pos, v) \
470 do { \
b29058ff 471 SCM_ASSERT (!SCM_IMP (v) && !SCM_FALSEP (scm_struct_vtable_p (v)), \
39bcc76e
MD
472 v, pos, FUNC_NAME); \
473 } while (0)
1bbd0b84 474
39bcc76e
MD
475#define SCM_VALIDATE_VECTOR_LEN(pos, v, len) \
476 do { \
9fd38a3d 477 SCM_ASSERT (SCM_VECTORP (v) && len == SCM_VECTOR_LENGTH (v), v, pos, FUNC_NAME); \
39bcc76e 478 } while (0)
1bbd0b84 479
b29058ff 480#endif /* SCM_VALIDATE_H */
89e00824
ML
481
482/*
483 Local Variables:
484 c-file-style: "gnu"
485 End:
486*/