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