summaryrefslogtreecommitdiff
path: root/libguile/numbers.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2018-06-17 22:28:13 +0200
committerAndy Wingo <wingo@pobox.com>2018-06-17 22:28:13 +0200
commitd10c3aa3cd2cbe71a9132530613f0ae42121b9db (patch)
treeeb7e994566b7d9efba48671105b372742d1bb6cd /libguile/numbers.h
parent87896eb3e69fc976bc9820bc216a766643a6db3d (diff)
downloadguile-d10c3aa3cd2cbe71a9132530613f0ae42121b9db.tar.gz
Move number validators to numbers.h.
* libguile/validate.h: * libguile/numbers.h (SCM_NUM2SIZE, SCM_NUM2SIZE_DEF, SCM_NUM2PTRDIFF) SCM_NUM2PTRDIFF_DEF, SCM_NUM2SHORT, SCM_NUM2SHORT_DEF, SCM_NUM2USHORT) SCM_NUM2USHORT_DEF, SCM_NUM2INT, SCM_NUM2INT_DEF, SCM_NUM2UINT) SCM_NUM2UINT_DEF, SCM_NUM2ULONG, SCM_NUM2ULONG_DEF, SCM_NUM2LONG) SCM_NUM2LONG_DEF, SCM_NUM2LONG_LONG, SCM_NUM2LONG_LONG_DEF) SCM_NUM2ULONG_LONG, SCM_NUM2ULONG_LONG_DEF, SCM_NUM2FLOAT) SCM_NUM2DOUBLE): Move these here, from validate.h.
Diffstat (limited to 'libguile/numbers.h')
-rw-r--r--libguile/numbers.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/libguile/numbers.h b/libguile/numbers.h
index 744ef7fc5..8a2b38672 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -27,6 +27,7 @@
#include <gmp.h>
#include "libguile/__scm.h"
+#include "libguile/error.h"
#include "libguile/print.h"
#ifndef SCM_T_WCHAR_DEFINED
@@ -596,6 +597,67 @@ SCM_API int scm_install_gmp_memory_functions;
SCM_INTERNAL void scm_init_numbers (void);
+
+
+#define SCM_NUM2SIZE(pos, arg) (scm_to_size_t (arg))
+
+#define SCM_NUM2SIZE_DEF(pos, arg, def) \
+ (SCM_UNBNDP (arg) ? def : scm_to_size_t (arg))
+
+#define SCM_NUM2PTRDIFF(pos, arg) (scm_to_ssize_t (arg))
+
+#define SCM_NUM2PTRDIFF_DEF(pos, arg, def) \
+ (SCM_UNBNDP (arg) ? def : scm_to_ssize_t (arg))
+
+#define SCM_NUM2SHORT(pos, arg) (scm_to_short (arg))
+
+#define SCM_NUM2SHORT_DEF(pos, arg, def) \
+ (SCM_UNBNDP (arg) ? def : scm_to_short (arg))
+
+#define SCM_NUM2USHORT(pos, arg) (scm_to_ushort (arg))
+
+#define SCM_NUM2USHORT_DEF(pos, arg, def) \
+ (SCM_UNBNDP (arg) ? def : scm_to_ushort (arg))
+
+#define SCM_NUM2INT(pos, arg) (scm_to_int (arg))
+
+#define SCM_NUM2INT_DEF(pos, arg, def) \
+ (SCM_UNBNDP (arg) ? def : scm_to_int (arg))
+
+#define SCM_NUM2UINT(pos, arg) (scm_to_uint (arg))
+
+#define SCM_NUM2UINT_DEF(pos, arg, def) \
+ (SCM_UNBNDP (arg) ? def : scm_to_uint (arg))
+
+#define SCM_NUM2ULONG(pos, arg) (scm_to_ulong (arg))
+
+#define SCM_NUM2ULONG_DEF(pos, arg, def) \
+ (SCM_UNBNDP (arg) ? def : scm_to_ulong (arg))
+
+#define SCM_NUM2LONG(pos, arg) (scm_to_long (arg))
+
+#define SCM_NUM2LONG_DEF(pos, arg, def) \
+ (SCM_UNBNDP (arg) ? def : scm_to_long (arg))
+
+#define SCM_NUM2LONG_LONG(pos, arg) (scm_to_long_long (arg))
+
+#define SCM_NUM2LONG_LONG_DEF(pos, arg, def) \
+ (SCM_UNBNDP (arg) ? def : scm_to_long_long (arg))
+
+#define SCM_NUM2ULONG_LONG(pos, arg) (scm_to_ulong_long (arg))
+
+#define SCM_NUM2ULONG_LONG_DEF(pos, arg, def) \
+ (SCM_UNBNDP (arg) ? def : scm_to_ulong_long (arg))
+
+#define SCM_NUM2SIZE(pos, arg) (scm_to_size_t (arg))
+
+#define SCM_NUM2FLOAT(pos, arg) ((float) scm_to_double (arg))
+
+#define SCM_NUM2DOUBLE(pos, arg) (scm_to_double (arg))
+
+
+
+
#endif /* SCM_NUMBERS_H */
/*