* Eliminate another couple of calls to scm_wta.
[bpt/guile.git] / libguile / validate.h
CommitLineData
276dd677 1/* $Id: validate.h,v 1.27 2001-03-04 22:48:13 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_MISC_ERROR(str, args) \
58 do { scm_misc_error (FUNC_NAME, str, args); } while (0)
1bbd0b84 59
398d8ee1
KN
60#define SCM_WRONG_NUM_ARGS() \
61 do { scm_wrong_num_args (scm_makfrom0str (FUNC_NAME)); } while (0)
62
39bcc76e
MD
63#define SCM_WRONG_TYPE_ARG(pos, obj) \
64 do { scm_wrong_type_arg (FUNC_NAME, pos, obj); } while (0)
1bbd0b84 65
39bcc76e 66#define SCM_NUM2ULONG(pos, arg) (scm_num2ulong (arg, (char *) pos, FUNC_NAME))
1bbd0b84 67
39bcc76e 68#define SCM_NUM2LONG(pos, arg) (scm_num2long (arg, (char *) pos, FUNC_NAME))
1bbd0b84 69
39bcc76e
MD
70#define SCM_NUM2LONG_DEF(pos, arg, def) \
71 (SCM_UNBNDP (arg) ? def : scm_num2long (arg, (char *) pos, FUNC_NAME))
c1bfcf60 72
39bcc76e
MD
73#define SCM_NUM2LONG_LONG(pos, arg) \
74 (scm_num2long_long (arg, (char *) pos, FUNC_NAME))
1bbd0b84 75
39bcc76e
MD
76#define SCM_OUT_OF_RANGE(pos, arg) \
77 do { scm_out_of_range_pos (FUNC_NAME, arg, SCM_MAKINUM (pos)); } while (0)
1bbd0b84 78
39bcc76e 79#define SCM_ASSERT_RANGE(pos, arg, f) \
23deee81 80 do { if (!(f)) scm_out_of_range_pos (FUNC_NAME, arg, SCM_MAKINUM (pos)); } while (0)
1bbd0b84 81
39bcc76e
MD
82#define SCM_MUST_MALLOC_TYPE(type) \
83 ((type *) scm_must_malloc (sizeof (type), FUNC_NAME))
1bbd0b84 84
39bcc76e
MD
85#define SCM_MUST_MALLOC_TYPE_NUM(type, num) \
86 ((type *) scm_must_malloc (sizeof (type) * (num), FUNC_NAME))
1bbd0b84 87
39bcc76e 88#define SCM_MUST_MALLOC(size) (scm_must_malloc ((size), FUNC_NAME))
1bbd0b84 89
39bcc76e
MD
90#define SCM_MAKE_VALIDATE(pos, var, pred) \
91 do { \
92 SCM_ASSERT_TYPE (SCM_ ## pred (var), var, pos, FUNC_NAME, #pred); \
93 } while (0)
6b5a304f 94
6e8d25a6
GB
95\f
96
af45e3b0
DH
97#define SCM_VALIDATE_REST_ARGUMENT(x) \
98 do { \
99 if (SCM_DEBUG_REST_ARGUMENT) { \
100 if (scm_ilength (x) < 0) { \
101 SCM_MISC_ERROR ("Rest arguments do not form a proper list.", SCM_EOL); \
102 } \
103 } \
104 } while (0)
105
39bcc76e 106#define SCM_VALIDATE_NIM(pos, scm) SCM_MAKE_VALIDATE (pos, scm, NIMP)
6e8d25a6 107
39bcc76e 108#define SCM_VALIDATE_BOOL(pos, flag) SCM_MAKE_VALIDATE(pos, flag, BOOLP)
1bbd0b84 109
39bcc76e
MD
110#define SCM_VALIDATE_BOOL_COPY(pos, flag, cvar) \
111 do { \
112 SCM_ASSERT (SCM_BOOLP (flag), flag, pos, FUNC_NAME); \
9a09deb1 113 cvar = SCM_EQ_P (flag, SCM_BOOL_T) ? 1 : 0; \
39bcc76e 114 } while (0)
1bbd0b84 115
f5f2dcff 116#define SCM_VALIDATE_CHAR(pos, scm) SCM_MAKE_VALIDATE (pos, scm, CHARP)
1bbd0b84 117
39bcc76e
MD
118#define SCM_VALIDATE_CHAR_COPY(pos, scm, cvar) \
119 do { \
120 SCM_ASSERT (SCM_CHARP (scm), scm, pos, FUNC_NAME); \
121 cvar = SCM_CHAR (scm); \
122 } while (0)
1bbd0b84 123
39bcc76e 124#define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE (pos, str, STRINGP)
1bbd0b84 125
39bcc76e
MD
126#define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \
127 do { \
128 SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \
86c991c2 129 cvar = SCM_STRING_CHARS(str); \
39bcc76e 130 } while (0)
1bbd0b84 131
60d02d09
GH
132/* validate a string and optional start/end arguments which default to
133 0/string-len. this is unrelated to the old shared substring
134 support, so please do not deprecate it :) */
135#define SCM_VALIDATE_SUBSTRING_SPEC_COPY(pos_str, str, c_str, \
136 pos_start, start, c_start,\
137 pos_end, end, c_end) \
138 do {\
139 SCM_VALIDATE_STRING_COPY (pos_str, str, c_str);\
140 SCM_VALIDATE_INUM_DEF_COPY (pos_start, start, 0, c_start);\
141 SCM_VALIDATE_INUM_DEF_COPY (pos_end, end, SCM_STRING_LENGTH (str), c_end);\
142 SCM_ASSERT_RANGE (pos_start, start,\
143 0 <= c_start && c_start <= SCM_STRING_LENGTH (str));\
144 SCM_ASSERT_RANGE (pos_end, end,\
145 c_start <= c_end && c_end <= SCM_STRING_LENGTH (str));\
146 } while (0)
147
39bcc76e 148#define SCM_VALIDATE_REAL(pos, z) SCM_MAKE_VALIDATE (pos, z, REALP)
1bbd0b84 149
e8a46ba8
MV
150#define SCM_VALIDATE_NUMBER(pos, z) SCM_MAKE_VALIDATE (pos, z, NUMBERP)
151
2891588b
MD
152#define SCM_VALIDATE_NUMBER_COPY(pos, z, cvar) \
153 do { \
154 if (SCM_INUMP (z)) \
155 cvar = (double) SCM_INUM (z); \
156 else if (SCM_REALP (z)) \
157 cvar = SCM_REAL_VALUE (z); \
158 else if (SCM_BIGP (z)) \
159 cvar = scm_big2dbl (z); \
160 else \
161 { \
162 cvar = 0.0; \
276dd677 163 SCM_WRONG_TYPE_ARG (pos, z); \
2891588b 164 } \
1a94d961
MD
165 } while (0)
166
ee1a1c20
MD
167#define SCM_VALIDATE_NUMBER_DEF_COPY(pos, number, def, cvar) \
168 do { \
169 if (SCM_UNBNDP (number)) \
170 cvar = def; \
171 else \
172 SCM_VALIDATE_NUMBER_COPY(pos, number, cvar); \
173 } while (0)
174
39bcc76e 175#define SCM_VALIDATE_INUM(pos, k) SCM_MAKE_VALIDATE (pos, k, INUMP)
1bbd0b84 176
39bcc76e
MD
177#define SCM_VALIDATE_INUM_COPY(pos, k, cvar) \
178 do { \
179 SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
180 cvar = SCM_INUM (k); \
181 } while (0)
1bbd0b84 182
39bcc76e
MD
183#define SCM_VALIDATE_ULONG_COPY(pos, k, cvar) \
184 do { \
185 cvar = SCM_NUM2ULONG (pos, k); \
186 } while (0)
2cd04b42 187
39bcc76e
MD
188#define SCM_VALIDATE_LONG_COPY(pos, k, cvar) \
189 do { \
190 cvar = SCM_NUM2LONG(pos, k); \
191 } while (0)
2cd04b42 192
39bcc76e 193#define SCM_VALIDATE_BIGINT(pos, k) SCM_MAKE_VALIDATE (pos, k, BIGP)
1bbd0b84 194
39bcc76e
MD
195#define SCM_VALIDATE_INUM_MIN(pos, k, min) \
196 do { \
197 SCM_ASSERT (SCM_INUMP(k), k, pos, FUNC_NAME); \
198 SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
199 } while (0)
1bbd0b84 200
39bcc76e
MD
201#define SCM_VALIDATE_INUM_MIN_COPY(pos, k, min, cvar) \
202 do { \
203 SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
fdf25853 204 SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
39bcc76e 205 cvar = SCM_INUM (k); \
39bcc76e 206 } while (0)
1bbd0b84 207
39bcc76e
MD
208#define SCM_VALIDATE_INUM_MIN_DEF_COPY(pos, k, min, default, cvar) \
209 do { \
210 if (SCM_UNBNDP (k)) \
211 k = SCM_MAKINUM (default); \
212 SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
fdf25853 213 SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
39bcc76e 214 cvar = SCM_INUM (k); \
39bcc76e 215 } while (0)
1bbd0b84 216
39bcc76e
MD
217#define SCM_VALIDATE_INUM_DEF(pos, k, default) \
218 do { \
219 if (SCM_UNBNDP (k)) \
220 k = SCM_MAKINUM (default); \
221 else SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
222 } while (0)
1bbd0b84 223
39bcc76e
MD
224#define SCM_VALIDATE_INUM_DEF_COPY(pos, k, default, cvar) \
225 do { \
226 if (SCM_UNBNDP (k)) \
227 { \
228 k = SCM_MAKINUM (default); \
229 cvar = default; \
230 } \
231 else \
232 { \
233 SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
234 cvar = SCM_INUM (k); \
235 } \
236 } while (0)
1bbd0b84
GB
237
238/* [low,high) */
120d4924
GB
239#define SCM_VALIDATE_INUM_RANGE(pos,k,low,high) \
240 do { SCM_ASSERT(SCM_INUMP(k), k, pos, FUNC_NAME); \
241 SCM_ASSERT_RANGE(pos,k, \
242 (SCM_INUM (k) >= low && \
243 SCM_INUM (k) < high)); \
244 } while (0)
39bcc76e 245
7642eb4b
MD
246#define SCM_VALIDATE_INUM_RANGE_COPY(pos, k, low, high, cvar) \
247 do { \
248 SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
fdf25853 249 SCM_ASSERT_RANGE (pos, k, low <= SCM_INUM (k) && SCM_INUM (k) < high); \
7642eb4b 250 cvar = SCM_INUM (k); \
7642eb4b
MD
251 } while (0)
252
39bcc76e 253#define SCM_VALIDATE_NULL(pos, scm) SCM_MAKE_VALIDATE (pos, scm, NULLP)
1bbd0b84 254
39bcc76e 255#define SCM_VALIDATE_CONS(pos, scm) SCM_MAKE_VALIDATE (pos, scm, CONSP)
1bbd0b84 256
39bcc76e
MD
257#define SCM_VALIDATE_LIST(pos, lst) \
258 do { \
259 SCM_ASSERT (scm_ilength (lst) >= 0, lst, pos, FUNC_NAME); \
260 } while (0)
1bbd0b84 261
39bcc76e
MD
262#define SCM_VALIDATE_NONEMPTYLIST(pos, lst) \
263 do { \
264 SCM_ASSERT (scm_ilength (lst) > 0, lst, pos, FUNC_NAME); \
265 } while (0)
1bbd0b84 266
39bcc76e
MD
267#define SCM_VALIDATE_LIST_COPYLEN(pos, lst, cvar) \
268 do { \
269 cvar = scm_ilength (lst); \
270 SCM_ASSERT (cvar >= 0, lst, pos, FUNC_NAME); \
271 } while (0)
c1bfcf60 272
39bcc76e
MD
273#define SCM_VALIDATE_NONEMPTYLIST_COPYLEN(pos, lst, cvar) \
274 do { \
275 cvar = scm_ilength (lst); \
276 SCM_ASSERT (cvar >= 1, lst, pos, FUNC_NAME); \
277 } while (0)
1bbd0b84 278
39bcc76e
MD
279#define SCM_VALIDATE_ALISTCELL(pos, alist) \
280 do { \
281 SCM_ASSERT (SCM_CONSP (alist) && SCM_CONSP (SCM_CAR (alist)), \
282 alist, pos, FUNC_NAME); \
283 } while (0)
1bbd0b84 284
39bcc76e 285#define SCM_VALIDATE_ALISTCELL_COPYSCM(pos, alist, cvar) \
1bbd0b84 286 do { \
39bcc76e
MD
287 SCM_ASSERT (SCM_CONSP (alist), alist, pos, FUNC_NAME); \
288 cvar = SCM_CAR (alist); \
289 SCM_ASSERT (SCM_CONSP (cvar), alist, pos, FUNC_NAME); \
30939477 290 } while (0)
1bbd0b84 291
39bcc76e 292#define SCM_VALIDATE_OPORT_VALUE(pos, port) \
1bbd0b84 293 do { \
39bcc76e
MD
294 SCM_ASSERT (scm_valid_oport_value_p (port), port, pos, FUNC_NAME); \
295 } while (0)
296
297#define SCM_VALIDATE_PRINTSTATE(pos, a) SCM_MAKE_VALIDATE(pos,a,PRINT_STATE_P)
1bbd0b84 298
39bcc76e
MD
299#define SCM_VALIDATE_SMOB(pos, obj, type) \
300 do { \
e841c3e0 301 SCM_ASSERT (SCM_TYP16_PREDICATE (scm_tc16_ ## type, obj), \
39bcc76e
MD
302 obj, pos, FUNC_NAME); \
303 } while (0)
1bbd0b84 304
39bcc76e 305#define SCM_VALIDATE_THREAD(pos, a) SCM_MAKE_VALIDATE (pos, a, THREADP)
1bbd0b84 306
39bcc76e
MD
307#define SCM_VALIDATE_THUNK(pos, thunk) \
308 do { \
309 SCM_ASSERT (SCM_NFALSEP (scm_thunk_p (thunk)), thunk, pos, FUNC_NAME); \
310 } while (0)
1bbd0b84 311
39bcc76e 312#define SCM_VALIDATE_SYMBOL(pos, sym) SCM_MAKE_VALIDATE (pos, sym, SYMBOLP)
0c95b57d 313
39bcc76e 314#define SCM_VALIDATE_VARIABLE(pos, var) SCM_MAKE_VALIDATE (pos, var, VARIABLEP)
1bbd0b84 315
39bcc76e 316#define SCM_VALIDATE_MEMOIZED(pos, obj) SCM_MAKE_VALIDATE (pos, obj, MEMOIZEDP)
1bbd0b84 317
39bcc76e 318#define SCM_VALIDATE_CLOSURE(pos, obj) SCM_MAKE_VALIDATE (pos, obj, CLOSUREP)
1bbd0b84 319
39bcc76e
MD
320#define SCM_VALIDATE_PROC(pos, proc) \
321 do { \
9a09deb1 322 SCM_ASSERT (SCM_EQ_P (scm_procedure_p (proc), SCM_BOOL_T), proc, pos, FUNC_NAME); \
39bcc76e 323 } while (0)
1bbd0b84 324
39bcc76e
MD
325#define SCM_VALIDATE_NULLORCONS(pos, env) \
326 do { \
327 SCM_ASSERT (SCM_NULLP (env) || SCM_CONSP (env), env, pos, FUNC_NAME); \
328 } while (0)
1bbd0b84 329
39bcc76e 330#define SCM_VALIDATE_HOOK(pos, a) SCM_MAKE_VALIDATE (pos, a, HOOKP)
1bbd0b84 331
39bcc76e 332#define SCM_VALIDATE_RGXP(pos, a) SCM_MAKE_VALIDATE (pos, a, RGXP)
1bbd0b84 333
39bcc76e 334#define SCM_VALIDATE_DIR(pos, port) SCM_MAKE_VALIDATE (pos, port, DIRP)
1bbd0b84 335
39bcc76e 336#define SCM_VALIDATE_PORT(pos, port) SCM_MAKE_VALIDATE (pos, port, PORTP)
1bbd0b84 337
39bcc76e
MD
338#define SCM_VALIDATE_INPUT_PORT(pos, port) \
339 SCM_MAKE_VALIDATE (pos, port, INPUT_PORT_P)
1bbd0b84 340
39bcc76e
MD
341#define SCM_VALIDATE_OUTPUT_PORT(pos, port) \
342 SCM_MAKE_VALIDATE (pos, port, OUTPUT_PORT_P)
1bbd0b84 343
39bcc76e 344#define SCM_VALIDATE_FPORT(pos, port) SCM_MAKE_VALIDATE (pos, port, FPORTP)
1bbd0b84 345
39bcc76e 346#define SCM_VALIDATE_OPFPORT(pos, port) SCM_MAKE_VALIDATE (pos, port, OPFPORTP)
1bbd0b84 347
39bcc76e
MD
348#define SCM_VALIDATE_OPINPORT(pos, port) \
349 SCM_MAKE_VALIDATE (pos, port, OPINPORTP)
1bbd0b84
GB
350
351#define SCM_VALIDATE_OPENPORT(pos,port) \
39bcc76e
MD
352 do { \
353 SCM_ASSERT (SCM_PORTP (port) && SCM_OPENP (port), \
354 port, pos, FUNC_NAME); \
355 } while (0)
1bbd0b84 356
39bcc76e 357#define SCM_VALIDATE_OPPORT(pos, port) SCM_MAKE_VALIDATE (pos, port, OPPORTP)
1bbd0b84 358
39bcc76e
MD
359#define SCM_VALIDATE_OPOUTPORT(pos, port) \
360 SCM_MAKE_VALIDATE (pos, port, OPOUTPORTP)
1bbd0b84 361
39bcc76e 362#define SCM_VALIDATE_FLUID(pos, fluid) SCM_MAKE_VALIDATE (pos, fluid, FLUIDP)
1bbd0b84 363
39bcc76e 364#define SCM_VALIDATE_KEYWORD(pos, v) SCM_MAKE_VALIDATE (pos, v, KEYWORDP)
1bbd0b84 365
39bcc76e 366#define SCM_VALIDATE_STACK(pos, v) SCM_MAKE_VALIDATE (pos, v, STACKP)
1bbd0b84 367
39bcc76e 368#define SCM_VALIDATE_FRAME(pos, v) SCM_MAKE_VALIDATE (pos, v, FRAMEP)
1bbd0b84 369
39bcc76e 370#define SCM_VALIDATE_RSTATE(pos, v) SCM_MAKE_VALIDATE (pos, v, RSTATEP)
1bbd0b84
GB
371
372#define SCM_VALIDATE_ARRAY(pos,v) \
39bcc76e
MD
373 do { \
374 SCM_ASSERT (SCM_NIMP (v) \
375 && !SCM_FALSEP (scm_array_p (v, SCM_UNDEFINED)), \
376 v, pos, FUNC_NAME); \
377 } while (0)
1bbd0b84 378
39bcc76e 379#define SCM_VALIDATE_VECTOR(pos, v) SCM_MAKE_VALIDATE (pos, v, VECTORP)
1bbd0b84 380
39bcc76e
MD
381#define SCM_VALIDATE_VECTOR_OR_DVECTOR(pos, v) \
382 do { \
383 SCM_ASSERT ((SCM_VECTORP (v) \
384 || (SCM_NIMP (v) && SCM_TYP7 (v) == scm_tc7_dvect)), \
385 v, pos, FUNC_NAME); \
386 } while (0)
368cf54d 387
39bcc76e 388#define SCM_VALIDATE_STRUCT(pos, v) SCM_MAKE_VALIDATE (pos, v, STRUCTP)
1bbd0b84 389
39bcc76e
MD
390#define SCM_VALIDATE_VTABLE(pos, v) \
391 do { \
392 SCM_ASSERT (SCM_NIMP (v) && SCM_NFALSEP (scm_struct_vtable_p (v)), \
393 v, pos, FUNC_NAME); \
394 } while (0)
1bbd0b84 395
39bcc76e
MD
396#define SCM_VALIDATE_VECTOR_LEN(pos, v, len) \
397 do { \
9fd38a3d 398 SCM_ASSERT (SCM_VECTORP (v) && len == SCM_VECTOR_LENGTH (v), v, pos, FUNC_NAME); \
39bcc76e 399 } while (0)
1bbd0b84 400
d1ca2c64
DH
401\f
402
403#if (SCM_DEBUG_DEPRECATED == 0)
404
276dd677
DH
405#define SCM_WTA(pos, scm) \
406 do { scm_wta (scm, (char *) pos, FUNC_NAME); } while (0)
407
408#define RETURN_SCM_WTA(pos, scm) \
409 do { return scm_wta (scm, (char *) pos, FUNC_NAME); } while (0)
410
d1ca2c64
DH
411#define SCM_VALIDATE_STRINGORSUBSTR SCM_VALIDATE_STRING
412
a6d9e5ab
DH
413#define SCM_VALIDATE_ROSTRING(pos, str) SCM_MAKE_VALIDATE (pos, str, ROSTRINGP)
414
415#define SCM_VALIDATE_ROSTRING_COPY(pos, str, cvar) \
416 do { \
417 SCM_ASSERT (SCM_ROSTRINGP (str), str, pos, FUNC_NAME); \
418 cvar = SCM_ROCHARS (str); \
419 } while (0)
420
421#define SCM_VALIDATE_NULLORROSTRING_COPY(pos, str, cvar) \
422 do { \
423 SCM_ASSERT (SCM_FALSEP (str) || SCM_ROSTRINGP (str), \
424 str, pos, FUNC_NAME); \
425 if (SCM_FALSEP(str)) \
426 cvar = NULL; \
427 else \
428 cvar = SCM_ROCHARS(str); \
429 } while (0)
430
395d8627
DH
431#define SCM_VALIDATE_RWSTRING(pos, str) \
432 do { \
433 SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \
434 if (!SCM_RWSTRINGP (str)) \
435 scm_misc_error (FUNC_NAME, "argument is a read-only string", str); \
436 } while (0)
437
30ea841d
DH
438#define SCM_VALIDATE_OPDIR(pos, port) SCM_MAKE_VALIDATE (pos, port, OPDIRP)
439
d1ca2c64
DH
440#endif /* SCM_DEBUG_DEPRECATED == 0 */
441
1bbd0b84 442#endif
89e00824
ML
443
444/*
445 Local Variables:
446 c-file-style: "gnu"
447 End:
448*/