1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-30 06:50:31 +02:00

Move more number validators to numbers.h.

* libguile/validate.h:
* libguile/numbers.h (SCM_OUT_OF_RANGE, SCM_ASSERT_RANGE)
  SCM_VALIDATE_REAL, SCM_VALIDATE_NUMBER, SCM_VALIDATE_USHORT_COPY)
  SCM_VALIDATE_SHORT_COPY, SCM_VALIDATE_UINT_COPY)
  SCM_VALIDATE_INT_COPY, SCM_VALIDATE_ULONG_COPY)
  SCM_VALIDATE_LONG_COPY, SCM_VALIDATE_SIZE_COPY)
  SCM_VALIDATE_FLOAT_COPY, SCM_VALIDATE_DOUBLE_COPY)
  SCM_VALIDATE_DOUBLE_DEF_COPY): Move here, from validate.h.
This commit is contained in:
Andy Wingo 2018-06-17 22:32:08 +02:00
parent d10c3aa3cd
commit bdd66fdd24
2 changed files with 72 additions and 72 deletions

View file

@ -655,6 +655,76 @@ SCM_INTERNAL void scm_init_numbers (void);
#define SCM_NUM2DOUBLE(pos, arg) (scm_to_double (arg))
#define SCM_OUT_OF_RANGE(pos, arg) \
do { scm_out_of_range_pos (FUNC_NAME, arg, scm_from_int (pos)); } while (0)
#define SCM_ASSERT_RANGE(pos, arg, f) \
do { if (SCM_UNLIKELY (!(f))) \
scm_out_of_range_pos (FUNC_NAME, arg, scm_from_int (pos)); } \
while (0)
#define SCM_VALIDATE_REAL(pos, z) SCM_MAKE_VALIDATE_MSG (pos, z, REALP, "real")
#define SCM_VALIDATE_NUMBER(pos, z) SCM_MAKE_VALIDATE_MSG (pos, z, NUMBERP, "number")
#define SCM_VALIDATE_USHORT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2USHORT (pos, k); \
} while (0)
#define SCM_VALIDATE_SHORT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2SHORT (pos, k); \
} while (0)
#define SCM_VALIDATE_UINT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2UINT (pos, k); \
} while (0)
#define SCM_VALIDATE_INT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2INT (pos, k); \
} while (0)
#define SCM_VALIDATE_ULONG_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2ULONG (pos, k); \
} while (0)
#define SCM_VALIDATE_LONG_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2LONG (pos, k); \
} while (0)
#define SCM_VALIDATE_SIZE_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2SIZE (pos, k); \
} while (0)
#define SCM_VALIDATE_FLOAT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2FLOAT (pos, k); \
} while (0)
#define SCM_VALIDATE_DOUBLE_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2DOUBLE (pos, k); \
} while (0)
#define SCM_VALIDATE_DOUBLE_DEF_COPY(pos, k, default, cvar) \
do { \
if (SCM_UNBNDP (k)) \
{ \
k = scm_make_real (default); \
cvar = default; \
} \
else \
{ \
cvar = SCM_NUM2DOUBLE (pos, k); \
} \
} while (0)

View file

@ -3,8 +3,8 @@
#ifndef SCM_VALIDATE_H
#define SCM_VALIDATE_H
/* Copyright (C) 1999, 2000, 2001, 2002, 2004, 2006, 2007, 2009,
* 2011, 2012, 2013, 2014, 2018 Free Software Foundation, Inc.
/* Copyright (C) 1999-2002,2004,2006-2007,2009,2011-2014,2018
* Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@ -31,14 +31,6 @@
#define SCM_OUT_OF_RANGE(pos, arg) \
do { scm_out_of_range_pos (FUNC_NAME, arg, scm_from_int (pos)); } while (0)
#define SCM_ASSERT_RANGE(pos, arg, f) \
do { if (SCM_UNLIKELY (!(f))) \
scm_out_of_range_pos (FUNC_NAME, arg, scm_from_int (pos)); } \
while (0)
#define SCM_MUST_MALLOC_TYPE(type) \
((type *) scm_must_malloc (sizeof (type), FUNC_NAME))
@ -89,68 +81,6 @@
SCM_ASSERT_TYPE (scm_is_string (str), str, pos, FUNC_NAME, "string"); \
} while (0)
#define SCM_VALIDATE_REAL(pos, z) SCM_MAKE_VALIDATE_MSG (pos, z, REALP, "real")
#define SCM_VALIDATE_NUMBER(pos, z) SCM_MAKE_VALIDATE_MSG (pos, z, NUMBERP, "number")
#define SCM_VALIDATE_USHORT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2USHORT (pos, k); \
} while (0)
#define SCM_VALIDATE_SHORT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2SHORT (pos, k); \
} while (0)
#define SCM_VALIDATE_UINT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2UINT (pos, k); \
} while (0)
#define SCM_VALIDATE_INT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2INT (pos, k); \
} while (0)
#define SCM_VALIDATE_ULONG_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2ULONG (pos, k); \
} while (0)
#define SCM_VALIDATE_LONG_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2LONG (pos, k); \
} while (0)
#define SCM_VALIDATE_SIZE_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2SIZE (pos, k); \
} while (0)
#define SCM_VALIDATE_FLOAT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2FLOAT (pos, k); \
} while (0)
#define SCM_VALIDATE_DOUBLE_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2DOUBLE (pos, k); \
} while (0)
#define SCM_VALIDATE_DOUBLE_DEF_COPY(pos, k, default, cvar) \
do { \
if (SCM_UNBNDP (k)) \
{ \
k = scm_make_real (default); \
cvar = default; \
} \
else \
{ \
cvar = SCM_NUM2DOUBLE (pos, k); \
} \
} while (0)
#define SCM_VALIDATE_NULL(pos, scm) \
SCM_I_MAKE_VALIDATE_MSG2 (pos, scm, scm_is_null, "empty list")