validate.h 17 KB

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