guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 16/86: Move more number validators to numbers.h.


From: Andy Wingo
Subject: [Guile-commits] 16/86: Move more number validators to numbers.h.
Date: Wed, 20 Jun 2018 14:09:29 -0400 (EDT)

wingo pushed a commit to branch master
in repository guile.

commit bdd66fdd2487342f30b82025948746035f2d3653
Author: Andy Wingo <address@hidden>
Date:   Sun Jun 17 22:32:08 2018 +0200

    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.
---
 libguile/numbers.h  | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++
 libguile/validate.h | 74 ++---------------------------------------------------
 2 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/libguile/numbers.h b/libguile/numbers.h
index 8a2b386..b4b77f8 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -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)
+
 
 
 
diff --git a/libguile/validate.h b/libguile/validate.h
index dbf10ca..e8416ad 100644
--- a/libguile/validate.h
+++ b/libguile/validate.h
@@ -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")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]