Commit | Line | Data |
---|---|---|
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 | * |
73be1d9e MV |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License as published by the Free Software Foundation; either | |
11 | * version 2.1 of the License, or (at your option) any later version. | |
e94e3f21 | 12 | * |
73be1d9e | 13 | * This library is distributed in the hope that it will be useful, |
5bff3127 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
73be1d9e MV |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. | |
e94e3f21 | 17 | * |
73be1d9e MV |
18 | * You should have received a copy of the GNU Lesser General Public |
19 | * License along with this library; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | */ | |
5bff3127 GB |
22 | |
23 | /* Written by Greg J. Badros <gjb@cs.washington.edu>, Dec-1999 */ | |
1bbd0b84 | 24 | |
b29058ff | 25 | \f |
1bbd0b84 | 26 | |
39bcc76e | 27 | #define SCM_SYSERROR do { scm_syserror (FUNC_NAME); } while (0) |
1bbd0b84 | 28 | |
39bcc76e | 29 | #define SCM_MEMORY_ERROR do { scm_memory_error (FUNC_NAME); } while (0) |
1bbd0b84 | 30 | |
39bcc76e MD |
31 | #define SCM_SYSERROR_MSG(str, args, val) \ |
32 | do { scm_syserror_msg (FUNC_NAME, (str), (args), (val)); } while (0) | |
1bbd0b84 | 33 | |
39bcc76e MD |
34 | #define SCM_MISC_ERROR(str, args) \ |
35 | do { scm_misc_error (FUNC_NAME, str, args); } while (0) | |
1bbd0b84 | 36 | |
398d8ee1 | 37 | #define SCM_WRONG_NUM_ARGS() \ |
68baa7e7 | 38 | do { scm_error_num_args_subr (FUNC_NAME); } while (0) |
398d8ee1 | 39 | |
39bcc76e MD |
40 | #define SCM_WRONG_TYPE_ARG(pos, obj) \ |
41 | do { scm_wrong_type_arg (FUNC_NAME, pos, obj); } while (0) | |
1bbd0b84 | 42 | |
1be6b49c ML |
43 | #define SCM_NUM2SIZE(pos, arg) (scm_num2size (arg, pos, FUNC_NAME)) |
44 | ||
45 | #define SCM_NUM2SIZE_DEF(pos, arg, def) \ | |
46 | (SCM_UNBNDP (arg) ? def : scm_num2size (arg, pos, FUNC_NAME)) | |
47 | ||
48 | #define SCM_NUM2PTRDIFF(pos, arg) (scm_num2ptrdiff (arg, pos, FUNC_NAME)) | |
49 | ||
50 | #define SCM_NUM2PTRDIFF_DEF(pos, arg, def) \ | |
51 | (SCM_UNBNDP (arg) ? def : scm_num2ptrdiff (arg, pos, FUNC_NAME)) | |
52 | ||
53 | #define SCM_NUM2SHORT(pos, arg) (scm_num2short (arg, pos, FUNC_NAME)) | |
54 | ||
55 | #define SCM_NUM2SHORT_DEF(pos, arg, def) \ | |
56 | (SCM_UNBNDP (arg) ? def : scm_num2short (arg, pos, FUNC_NAME)) | |
57 | ||
58 | #define SCM_NUM2USHORT(pos, arg) (scm_num2ushort (arg, pos, FUNC_NAME)) | |
59 | ||
60 | #define SCM_NUM2USHORT_DEF(pos, arg, def) \ | |
61 | (SCM_UNBNDP (arg) ? def : scm_num2ushort (arg, pos, FUNC_NAME)) | |
62 | ||
1be6b49c ML |
63 | #define SCM_NUM2INT(pos, arg) (scm_num2int (arg, pos, FUNC_NAME)) |
64 | ||
65 | #define SCM_NUM2INT_DEF(pos, arg, def) \ | |
66 | (SCM_UNBNDP (arg) ? def : scm_num2int (arg, pos, FUNC_NAME)) | |
67 | ||
68 | #define SCM_NUM2UINT(pos, arg) (scm_num2uint (arg, pos, FUNC_NAME)) | |
69 | ||
70 | #define SCM_NUM2UINT_DEF(pos, arg, def) \ | |
71 | (SCM_UNBNDP (arg) ? def : scm_num2uint (arg, pos, FUNC_NAME)) | |
72 | ||
e4b265d8 | 73 | #define SCM_NUM2ULONG(pos, arg) (scm_num2ulong (arg, pos, FUNC_NAME)) |
1bbd0b84 | 74 | |
1be6b49c ML |
75 | #define SCM_NUM2ULONG_DEF(pos, arg, def) \ |
76 | (SCM_UNBNDP (arg) ? def : scm_num2ulong (arg, pos, FUNC_NAME)) | |
77 | ||
e4b265d8 | 78 | #define SCM_NUM2LONG(pos, arg) (scm_num2long (arg, pos, FUNC_NAME)) |
1bbd0b84 | 79 | |
39bcc76e | 80 | #define SCM_NUM2LONG_DEF(pos, arg, def) \ |
e4b265d8 | 81 | (SCM_UNBNDP (arg) ? def : scm_num2long (arg, pos, FUNC_NAME)) |
c1bfcf60 | 82 | |
39bcc76e | 83 | #define SCM_NUM2LONG_LONG(pos, arg) \ |
e4b265d8 | 84 | (scm_num2long_long (arg, pos, FUNC_NAME)) |
1bbd0b84 | 85 | |
1be6b49c ML |
86 | #define SCM_NUM2LONG_LONG_DEF(pos, arg, def) \ |
87 | (SCM_UNBNDP (arg) ? def : scm_num2long_long (arg, pos, FUNC_NAME)) | |
88 | ||
89 | #define SCM_NUM2ULONG_LONG(pos, arg) \ | |
90 | (scm_num2ulong_long (arg, pos, FUNC_NAME)) | |
91 | ||
92 | #define SCM_NUM2ULONG_LONG_DEF(pos, arg, def) \ | |
93 | (SCM_UNBNDP (arg) ? def : scm_num2ulong_long (arg, pos, FUNC_NAME)) | |
94 | ||
581ded70 MD |
95 | #define SCM_NUM2FLOAT(pos, arg) \ |
96 | (scm_num2float (arg, pos, FUNC_NAME)) | |
97 | ||
98 | #define SCM_NUM2DOUBLE(pos, arg) \ | |
99 | (scm_num2double (arg, pos, FUNC_NAME)) | |
100 | ||
39bcc76e | 101 | #define SCM_OUT_OF_RANGE(pos, arg) \ |
93ccaef0 | 102 | do { scm_out_of_range_pos (FUNC_NAME, arg, scm_from_int (pos)); } while (0) |
1bbd0b84 | 103 | |
39bcc76e | 104 | #define SCM_ASSERT_RANGE(pos, arg, f) \ |
93ccaef0 | 105 | do { if (!(f)) scm_out_of_range_pos (FUNC_NAME, arg, scm_from_int (pos)); } while (0) |
1bbd0b84 | 106 | |
39bcc76e MD |
107 | #define SCM_MUST_MALLOC_TYPE(type) \ |
108 | ((type *) scm_must_malloc (sizeof (type), FUNC_NAME)) | |
1bbd0b84 | 109 | |
39bcc76e MD |
110 | #define SCM_MUST_MALLOC_TYPE_NUM(type, num) \ |
111 | ((type *) scm_must_malloc (sizeof (type) * (num), FUNC_NAME)) | |
1bbd0b84 | 112 | |
39bcc76e | 113 | #define SCM_MUST_MALLOC(size) (scm_must_malloc ((size), FUNC_NAME)) |
1bbd0b84 | 114 | |
39bcc76e MD |
115 | #define SCM_MAKE_VALIDATE(pos, var, pred) \ |
116 | do { \ | |
117 | SCM_ASSERT_TYPE (SCM_ ## pred (var), var, pos, FUNC_NAME, #pred); \ | |
118 | } while (0) | |
6b5a304f | 119 | |
6182ceac MV |
120 | #define SCM_MAKE_VALIDATE_MSG(pos, var, pred, msg) \ |
121 | do { \ | |
122 | SCM_ASSERT_TYPE (SCM_ ## pred (var), var, pos, FUNC_NAME, msg); \ | |
123 | } while (0) | |
124 | ||
6e8d25a6 GB |
125 | \f |
126 | ||
af45e3b0 DH |
127 | #define SCM_VALIDATE_REST_ARGUMENT(x) \ |
128 | do { \ | |
129 | if (SCM_DEBUG_REST_ARGUMENT) { \ | |
130 | if (scm_ilength (x) < 0) { \ | |
131 | SCM_MISC_ERROR ("Rest arguments do not form a proper list.", SCM_EOL); \ | |
132 | } \ | |
133 | } \ | |
134 | } while (0) | |
135 | ||
6182ceac | 136 | #define SCM_VALIDATE_NIM(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, NIMP, "non-immediate") |
6e8d25a6 | 137 | |
7888309b MV |
138 | #define SCM_VALIDATE_BOOL(pos, flag) \ |
139 | do { \ | |
140 | SCM_ASSERT_TYPE (scm_is_bool (flag), flag, pos, FUNC_NAME, "boolean"); \ | |
141 | } while (0) | |
1bbd0b84 | 142 | |
39bcc76e MD |
143 | #define SCM_VALIDATE_BOOL_COPY(pos, flag, cvar) \ |
144 | do { \ | |
7888309b | 145 | SCM_ASSERT (scm_is_bool (flag), flag, pos, FUNC_NAME); \ |
bc36d050 | 146 | cvar = scm_to_bool (flag); \ |
39bcc76e | 147 | } while (0) |
1bbd0b84 | 148 | |
6182ceac | 149 | #define SCM_VALIDATE_CHAR(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, CHARP, "character") |
1bbd0b84 | 150 | |
39bcc76e MD |
151 | #define SCM_VALIDATE_CHAR_COPY(pos, scm, cvar) \ |
152 | do { \ | |
153 | SCM_ASSERT (SCM_CHARP (scm), scm, pos, FUNC_NAME); \ | |
154 | cvar = SCM_CHAR (scm); \ | |
155 | } while (0) | |
1bbd0b84 | 156 | |
6182ceac | 157 | #define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE_MSG (pos, str, STRINGP, "string") |
1bbd0b84 | 158 | |
39bcc76e MD |
159 | #define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \ |
160 | do { \ | |
161 | SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \ | |
86c991c2 | 162 | cvar = SCM_STRING_CHARS(str); \ |
39bcc76e | 163 | } while (0) |
1bbd0b84 | 164 | |
60d02d09 GH |
165 | /* validate a string and optional start/end arguments which default to |
166 | 0/string-len. this is unrelated to the old shared substring | |
167 | support, so please do not deprecate it :) */ | |
168 | #define SCM_VALIDATE_SUBSTRING_SPEC_COPY(pos_str, str, c_str, \ | |
169 | pos_start, start, c_start,\ | |
170 | pos_end, end, c_end) \ | |
171 | do {\ | |
172 | SCM_VALIDATE_STRING_COPY (pos_str, str, c_str);\ | |
8805b77d MV |
173 | c_start = SCM_UNBNDP(start)? 0 : scm_to_size_t (start);\ |
174 | c_end = SCM_UNBNDP(end)? SCM_STRING_LENGTH(str) : scm_to_size_t (end);\ | |
60d02d09 | 175 | SCM_ASSERT_RANGE (pos_start, start,\ |
36284627 DH |
176 | 0 <= c_start \ |
177 | && (size_t) c_start <= SCM_STRING_LENGTH (str));\ | |
60d02d09 | 178 | SCM_ASSERT_RANGE (pos_end, end,\ |
36284627 DH |
179 | c_start <= c_end \ |
180 | && (size_t) c_end <= SCM_STRING_LENGTH (str));\ | |
60d02d09 GH |
181 | } while (0) |
182 | ||
6182ceac | 183 | #define SCM_VALIDATE_REAL(pos, z) SCM_MAKE_VALIDATE_MSG (pos, z, REALP, "real") |
1bbd0b84 | 184 | |
6182ceac | 185 | #define SCM_VALIDATE_NUMBER(pos, z) SCM_MAKE_VALIDATE_MSG (pos, z, NUMBERP, "number") |
e8a46ba8 | 186 | |
d098d810 TTN |
187 | #define SCM_VALIDATE_USHORT_COPY(pos, k, cvar) \ |
188 | do { \ | |
189 | cvar = SCM_NUM2USHORT (pos, k); \ | |
190 | } while (0) | |
191 | ||
192 | #define SCM_VALIDATE_SHORT_COPY(pos, k, cvar) \ | |
193 | do { \ | |
194 | cvar = SCM_NUM2SHORT (pos, k); \ | |
195 | } while (0) | |
196 | ||
197 | #define SCM_VALIDATE_UINT_COPY(pos, k, cvar) \ | |
198 | do { \ | |
199 | cvar = SCM_NUM2UINT (pos, k); \ | |
200 | } while (0) | |
201 | ||
202 | #define SCM_VALIDATE_INT_COPY(pos, k, cvar) \ | |
203 | do { \ | |
204 | cvar = SCM_NUM2INT (pos, k); \ | |
205 | } while (0) | |
206 | ||
39bcc76e MD |
207 | #define SCM_VALIDATE_ULONG_COPY(pos, k, cvar) \ |
208 | do { \ | |
209 | cvar = SCM_NUM2ULONG (pos, k); \ | |
210 | } while (0) | |
2cd04b42 | 211 | |
39bcc76e MD |
212 | #define SCM_VALIDATE_LONG_COPY(pos, k, cvar) \ |
213 | do { \ | |
e4b265d8 | 214 | cvar = SCM_NUM2LONG (pos, k); \ |
39bcc76e | 215 | } while (0) |
2cd04b42 | 216 | |
581ded70 MD |
217 | #define SCM_VALIDATE_FLOAT_COPY(pos, k, cvar) \ |
218 | do { \ | |
219 | cvar = SCM_NUM2FLOAT (pos, k); \ | |
220 | } while (0) | |
221 | ||
222 | #define SCM_VALIDATE_DOUBLE_COPY(pos, k, cvar) \ | |
223 | do { \ | |
224 | cvar = SCM_NUM2DOUBLE (pos, k); \ | |
225 | } while (0) | |
226 | ||
68665a97 MD |
227 | #define SCM_VALIDATE_DOUBLE_DEF_COPY(pos, k, default, cvar) \ |
228 | do { \ | |
229 | if (SCM_UNBNDP (k)) \ | |
230 | { \ | |
231 | k = scm_make_real (default); \ | |
232 | cvar = default; \ | |
233 | } \ | |
234 | else \ | |
235 | { \ | |
236 | cvar = SCM_NUM2DOUBLE (pos, k); \ | |
237 | } \ | |
238 | } while (0) | |
239 | ||
6182ceac | 240 | #define SCM_VALIDATE_NULL(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, NULLP, "null") |
1bbd0b84 | 241 | |
6182ceac | 242 | #define SCM_VALIDATE_NULL_OR_NIL(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, NULL_OR_NIL_P, "null") |
c96d76b8 | 243 | |
6182ceac | 244 | #define SCM_VALIDATE_CONS(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, CONSP, "pair") |
1bbd0b84 | 245 | |
39bcc76e MD |
246 | #define SCM_VALIDATE_LIST(pos, lst) \ |
247 | do { \ | |
248 | SCM_ASSERT (scm_ilength (lst) >= 0, lst, pos, FUNC_NAME); \ | |
249 | } while (0) | |
1bbd0b84 | 250 | |
39bcc76e MD |
251 | #define SCM_VALIDATE_NONEMPTYLIST(pos, lst) \ |
252 | do { \ | |
253 | SCM_ASSERT (scm_ilength (lst) > 0, lst, pos, FUNC_NAME); \ | |
254 | } while (0) | |
1bbd0b84 | 255 | |
39bcc76e MD |
256 | #define SCM_VALIDATE_LIST_COPYLEN(pos, lst, cvar) \ |
257 | do { \ | |
258 | cvar = scm_ilength (lst); \ | |
259 | SCM_ASSERT (cvar >= 0, lst, pos, FUNC_NAME); \ | |
260 | } while (0) | |
c1bfcf60 | 261 | |
39bcc76e MD |
262 | #define SCM_VALIDATE_NONEMPTYLIST_COPYLEN(pos, lst, cvar) \ |
263 | do { \ | |
264 | cvar = scm_ilength (lst); \ | |
265 | SCM_ASSERT (cvar >= 1, lst, pos, FUNC_NAME); \ | |
266 | } while (0) | |
1bbd0b84 | 267 | |
39bcc76e MD |
268 | #define SCM_VALIDATE_ALISTCELL(pos, alist) \ |
269 | do { \ | |
270 | SCM_ASSERT (SCM_CONSP (alist) && SCM_CONSP (SCM_CAR (alist)), \ | |
271 | alist, pos, FUNC_NAME); \ | |
272 | } while (0) | |
1bbd0b84 | 273 | |
39bcc76e | 274 | #define SCM_VALIDATE_ALISTCELL_COPYSCM(pos, alist, cvar) \ |
1bbd0b84 | 275 | do { \ |
39bcc76e MD |
276 | SCM_ASSERT (SCM_CONSP (alist), alist, pos, FUNC_NAME); \ |
277 | cvar = SCM_CAR (alist); \ | |
278 | SCM_ASSERT (SCM_CONSP (cvar), alist, pos, FUNC_NAME); \ | |
30939477 | 279 | } while (0) |
1bbd0b84 | 280 | |
39bcc76e | 281 | #define SCM_VALIDATE_OPORT_VALUE(pos, port) \ |
1bbd0b84 | 282 | do { \ |
39bcc76e MD |
283 | SCM_ASSERT (scm_valid_oport_value_p (port), port, pos, FUNC_NAME); \ |
284 | } while (0) | |
285 | ||
6182ceac | 286 | #define SCM_VALIDATE_PRINTSTATE(pos, a) SCM_MAKE_VALIDATE_MSG(pos, a, PRINT_STATE_P, "print-state") |
1bbd0b84 | 287 | |
39bcc76e MD |
288 | #define SCM_VALIDATE_SMOB(pos, obj, type) \ |
289 | do { \ | |
e841c3e0 | 290 | SCM_ASSERT (SCM_TYP16_PREDICATE (scm_tc16_ ## type, obj), \ |
39bcc76e MD |
291 | obj, pos, FUNC_NAME); \ |
292 | } while (0) | |
1bbd0b84 | 293 | |
39bcc76e MD |
294 | #define SCM_VALIDATE_THUNK(pos, thunk) \ |
295 | do { \ | |
7888309b | 296 | SCM_ASSERT (scm_is_true (scm_thunk_p (thunk)), thunk, pos, FUNC_NAME); \ |
39bcc76e | 297 | } while (0) |
1bbd0b84 | 298 | |
6182ceac | 299 | #define SCM_VALIDATE_SYMBOL(pos, sym) SCM_MAKE_VALIDATE_MSG (pos, sym, SYMBOLP, "symbol") |
0c95b57d | 300 | |
6182ceac | 301 | #define SCM_VALIDATE_VARIABLE(pos, var) SCM_MAKE_VALIDATE_MSG (pos, var, VARIABLEP, "variable") |
1bbd0b84 | 302 | |
6182ceac | 303 | #define SCM_VALIDATE_MEMOIZED(pos, obj) SCM_MAKE_VALIDATE_MSG (pos, obj, MEMOIZEDP, "memoized code") |
1bbd0b84 | 304 | |
6182ceac | 305 | #define SCM_VALIDATE_CLOSURE(pos, obj) SCM_MAKE_VALIDATE_MSG (pos, obj, CLOSUREP, "closure") |
1bbd0b84 | 306 | |
39bcc76e MD |
307 | #define SCM_VALIDATE_PROC(pos, proc) \ |
308 | do { \ | |
bc36d050 | 309 | SCM_ASSERT (scm_is_true (scm_procedure_p (proc)), proc, pos, FUNC_NAME); \ |
39bcc76e | 310 | } while (0) |
1bbd0b84 | 311 | |
39bcc76e MD |
312 | #define SCM_VALIDATE_NULLORCONS(pos, env) \ |
313 | do { \ | |
314 | SCM_ASSERT (SCM_NULLP (env) || SCM_CONSP (env), env, pos, FUNC_NAME); \ | |
315 | } while (0) | |
1bbd0b84 | 316 | |
6182ceac | 317 | #define SCM_VALIDATE_HOOK(pos, a) SCM_MAKE_VALIDATE_MSG (pos, a, HOOKP, "hook") |
1bbd0b84 | 318 | |
6182ceac | 319 | #define SCM_VALIDATE_RGXP(pos, a) SCM_MAKE_VALIDATE_MSG (pos, a, RGXP, "regexp") |
1bbd0b84 | 320 | |
6182ceac | 321 | #define SCM_VALIDATE_DIR(pos, port) SCM_MAKE_VALIDATE_MSG (pos, port, DIRP, "directory port") |
1bbd0b84 | 322 | |
6182ceac | 323 | #define SCM_VALIDATE_PORT(pos, port) SCM_MAKE_VALIDATE_MSG (pos, port, PORTP, "port") |
1bbd0b84 | 324 | |
39bcc76e | 325 | #define SCM_VALIDATE_INPUT_PORT(pos, port) \ |
6182ceac | 326 | SCM_MAKE_VALIDATE_MSG (pos, port, INPUT_PORT_P, "input port") |
1bbd0b84 | 327 | |
39bcc76e | 328 | #define SCM_VALIDATE_OUTPUT_PORT(pos, port) \ |
6182ceac | 329 | SCM_MAKE_VALIDATE_MSG (pos, port, OUTPUT_PORT_P, "output port") |
1bbd0b84 | 330 | |
6182ceac | 331 | #define SCM_VALIDATE_FPORT(pos, port) SCM_MAKE_VALIDATE_MSG (pos, port, FPORTP, "file port") |
1bbd0b84 | 332 | |
6182ceac | 333 | #define SCM_VALIDATE_OPFPORT(pos, port) SCM_MAKE_VALIDATE_MSG (pos, port, OPFPORTP, "open file port") |
1bbd0b84 | 334 | |
39bcc76e | 335 | #define SCM_VALIDATE_OPINPORT(pos, port) \ |
6182ceac | 336 | SCM_MAKE_VALIDATE_MSG (pos, port, OPINPORTP, "open input port") |
1bbd0b84 | 337 | |
34d19ef6 | 338 | #define SCM_VALIDATE_OPENPORT(pos, port) \ |
39bcc76e MD |
339 | do { \ |
340 | SCM_ASSERT (SCM_PORTP (port) && SCM_OPENP (port), \ | |
341 | port, pos, FUNC_NAME); \ | |
342 | } while (0) | |
1bbd0b84 | 343 | |
6182ceac | 344 | #define SCM_VALIDATE_OPPORT(pos, port) SCM_MAKE_VALIDATE_MSG (pos, port, OPPORTP, "open port") |
1bbd0b84 | 345 | |
39bcc76e | 346 | #define SCM_VALIDATE_OPOUTPORT(pos, port) \ |
6182ceac | 347 | SCM_MAKE_VALIDATE_MSG (pos, port, OPOUTPORTP, "open output port") |
1bbd0b84 | 348 | |
e87a03fc | 349 | #define SCM_VALIDATE_OPOUTSTRPORT(pos, port) \ |
6182ceac | 350 | SCM_MAKE_VALIDATE_MSG (pos, port, OPOUTSTRPORTP, "open output string port") |
e87a03fc | 351 | |
6182ceac | 352 | #define SCM_VALIDATE_FLUID(pos, fluid) SCM_MAKE_VALIDATE_MSG (pos, fluid, FLUIDP, "fluid") |
1bbd0b84 | 353 | |
6182ceac | 354 | #define SCM_VALIDATE_KEYWORD(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, KEYWORDP, "keyword") |
1bbd0b84 | 355 | |
6182ceac | 356 | #define SCM_VALIDATE_STACK(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, STACKP, "stack") |
1bbd0b84 | 357 | |
6182ceac | 358 | #define SCM_VALIDATE_FRAME(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, FRAMEP, "frame") |
1bbd0b84 | 359 | |
6182ceac | 360 | #define SCM_VALIDATE_RSTATE(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, RSTATEP, "random-generator-state") |
1bbd0b84 | 361 | |
34d19ef6 | 362 | #define SCM_VALIDATE_ARRAY(pos, v) \ |
39bcc76e | 363 | do { \ |
b29058ff | 364 | SCM_ASSERT (!SCM_IMP (v) \ |
7888309b | 365 | && scm_is_true (scm_array_p (v, SCM_UNDEFINED)), \ |
39bcc76e MD |
366 | v, pos, FUNC_NAME); \ |
367 | } while (0) | |
1bbd0b84 | 368 | |
6182ceac | 369 | #define SCM_VALIDATE_VECTOR(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, VECTORP, "vector") |
1bbd0b84 | 370 | |
39bcc76e MD |
371 | #define SCM_VALIDATE_VECTOR_OR_DVECTOR(pos, v) \ |
372 | do { \ | |
373 | SCM_ASSERT ((SCM_VECTORP (v) \ | |
b29058ff | 374 | || (!SCM_IMP (v) && SCM_TYP7 (v) == scm_tc7_dvect)), \ |
39bcc76e MD |
375 | v, pos, FUNC_NAME); \ |
376 | } while (0) | |
368cf54d | 377 | |
6182ceac | 378 | #define SCM_VALIDATE_STRUCT(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, STRUCTP, "struct") |
1bbd0b84 | 379 | |
39bcc76e MD |
380 | #define SCM_VALIDATE_VTABLE(pos, v) \ |
381 | do { \ | |
7888309b | 382 | SCM_ASSERT (!SCM_IMP (v) && scm_is_true (scm_struct_vtable_p (v)), \ |
39bcc76e MD |
383 | v, pos, FUNC_NAME); \ |
384 | } while (0) | |
1bbd0b84 | 385 | |
39bcc76e MD |
386 | #define SCM_VALIDATE_VECTOR_LEN(pos, v, len) \ |
387 | do { \ | |
9fd38a3d | 388 | SCM_ASSERT (SCM_VECTORP (v) && len == SCM_VECTOR_LENGTH (v), v, pos, FUNC_NAME); \ |
39bcc76e | 389 | } while (0) |
1bbd0b84 | 390 | |
b29058ff | 391 | #endif /* SCM_VALIDATE_H */ |
89e00824 ML |
392 | |
393 | /* | |
394 | Local Variables: | |
395 | c-file-style: "gnu" | |
396 | End: | |
397 | */ |