1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-29 22:40:34 +02:00

Move list validators to list.h

* libguile/validate.h:
* libguile/list.h (SCM_VALIDATE_REST_ARGUMENT, SCM_VALIDATE_LIST)
  SCM_VALIDATE_NONEMPTYLIST, SCM_VALIDATE_LIST_COPYLEN)
  SCM_VALIDATE_NONEMPTYLIST_COPYLEN): Move here from validate.h.
This commit is contained in:
Andy Wingo 2018-06-17 22:38:18 +02:00
parent cd292b3bd9
commit 82d5662887
2 changed files with 35 additions and 34 deletions

View file

@ -3,7 +3,7 @@
#ifndef SCM_LIST_H
#define SCM_LIST_H
/* Copyright (C) 1995,1996,1997,2000,2001,2003,2004,2005,2006,2008,2009
/* Copyright (C) 1995-1997,2000-2001,2003-2006,2008-2009,2018
* Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
@ -69,6 +69,40 @@ SCM_API SCM scm_filter (SCM pred, SCM list);
SCM_API SCM scm_filter_x (SCM pred, SCM list);
SCM_API SCM scm_copy_tree (SCM obj);
#define SCM_VALIDATE_REST_ARGUMENT(x) \
do { \
if (SCM_DEBUG_REST_ARGUMENT) { \
if (scm_ilength (x) < 0) { \
SCM_MISC_ERROR ("Rest arguments do not form a proper list.", SCM_EOL); \
} \
} \
} while (0)
#define SCM_VALIDATE_LIST(pos, lst) \
do { \
SCM_ASSERT (scm_ilength (lst) >= 0, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_NONEMPTYLIST(pos, lst) \
do { \
SCM_ASSERT (scm_ilength (lst) > 0, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_LIST_COPYLEN(pos, lst, cvar) \
do { \
cvar = scm_ilength (lst); \
SCM_ASSERT (cvar >= 0, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_NONEMPTYLIST_COPYLEN(pos, lst, cvar) \
do { \
cvar = scm_ilength (lst); \
SCM_ASSERT (cvar >= 1, lst, pos, FUNC_NAME); \
} while (0)
/* Guile internal functions */

View file

@ -31,17 +31,6 @@
#define SCM_VALIDATE_REST_ARGUMENT(x) \
do { \
if (SCM_DEBUG_REST_ARGUMENT) { \
if (scm_ilength (x) < 0) { \
SCM_MISC_ERROR ("Rest arguments do not form a proper list.", SCM_EOL); \
} \
} \
} while (0)
#define SCM_VALIDATE_NIM(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, NIMP, "non-immediate")
#define SCM_VALIDATE_BOOL(pos, flag) \
@ -86,28 +75,6 @@
SCM_I_MAKE_VALIDATE_MSG2 (pos, scm, scm_is_mutable_pair, "mutable pair")
#endif /* BUILDING_LIBGUILE */
#define SCM_VALIDATE_LIST(pos, lst) \
do { \
SCM_ASSERT (scm_ilength (lst) >= 0, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_NONEMPTYLIST(pos, lst) \
do { \
SCM_ASSERT (scm_ilength (lst) > 0, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_LIST_COPYLEN(pos, lst, cvar) \
do { \
cvar = scm_ilength (lst); \
SCM_ASSERT (cvar >= 0, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_NONEMPTYLIST_COPYLEN(pos, lst, cvar) \
do { \
cvar = scm_ilength (lst); \
SCM_ASSERT (cvar >= 1, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_ALISTCELL(pos, alist) \
do { \
SCM_ASSERT (scm_is_pair (alist) && scm_is_pair (SCM_CAR (alist)), \