*** empty log message ***
[bpt/guile.git] / libguile / validate.h
index 04bcb2b..1810be1 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef SCM_VALIDATE_H
 #define SCM_VALIDATE_H
 
-/* Copyright (C) 1999,2000,2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1999,2000,2001, 2002, 2004 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
     SCM_ASSERT_TYPE (SCM_ ## pred (var), var, pos, FUNC_NAME, #pred); \
   } while (0)
 
-#define SCM_MAKE_VALIDATE_MSG(pos, var, pred, msg) \
+#define SCM_I_MAKE_VALIDATE_MSG2(pos, var, pred, msg) \
   do { \
-    SCM_ASSERT_TYPE (SCM_ ## pred (var), var, pos, FUNC_NAME, msg); \
+    SCM_ASSERT_TYPE (pred (var), var, pos, FUNC_NAME, msg); \
   } while (0)
 
+#define SCM_MAKE_VALIDATE_MSG(pos, var, pred, msg) \
+  SCM_I_MAKE_VALIDATE_MSG2 (pos, var, SCM_ ## pred, msg)
+
+
 \f
 
 #define SCM_VALIDATE_REST_ARGUMENT(x) \
     cvar = SCM_CHAR (scm); \
   } while (0)
 
-#define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE_MSG (pos, str, STRINGP, "string")
-
-#define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \
+#define SCM_VALIDATE_STRING(pos, str) \
   do { \
-    SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \
-    cvar = SCM_STRING_CHARS(str); \
-  } while (0)
-
-/* validate a string and optional start/end arguments which default to
-   0/string-len.  this is unrelated to the old shared substring
-   support, so please do not deprecate it :) */
-#define SCM_VALIDATE_SUBSTRING_SPEC_COPY(pos_str, str, c_str, \
-                                         pos_start, start, c_start,\
-                                         pos_end, end, c_end) \
-  do {\
-    SCM_VALIDATE_STRING_COPY (pos_str, str, c_str);\
-    c_start = SCM_UNBNDP(start)? 0 : scm_to_size_t (start);\
-    c_end = SCM_UNBNDP(end)? SCM_STRING_LENGTH(str) : scm_to_size_t (end);\
-    SCM_ASSERT_RANGE (pos_start, start,\
-                      0 <= c_start \
-                      && (size_t) c_start <= SCM_STRING_LENGTH (str));\
-    SCM_ASSERT_RANGE (pos_end, end,\
-                     c_start <= c_end \
-                      && (size_t) c_end <= SCM_STRING_LENGTH (str));\
+    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")
       } \
   } while (0)
 
-#define SCM_VALIDATE_NULL(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, NULLP, "null")
+#define SCM_VALIDATE_NULL(pos, scm) \
+  SCM_I_MAKE_VALIDATE_MSG2 (pos, scm, scm_is_null, "empty list")
 
-#define SCM_VALIDATE_NULL_OR_NIL(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, NULL_OR_NIL_P, "null")
+#define SCM_VALIDATE_NULL_OR_NIL(pos, scm) \
+  SCM_MAKE_VALIDATE_MSG (pos, scm, NULL_OR_NIL_P, "empty list")
 
-#define SCM_VALIDATE_CONS(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, CONSP, "pair")
+#define SCM_VALIDATE_CONS(pos, scm) \
+  SCM_I_MAKE_VALIDATE_MSG2 (pos, scm, scm_is_pair, "pair")
 
 #define SCM_VALIDATE_LIST(pos, lst) \
   do { \
 
 #define SCM_VALIDATE_ALISTCELL(pos, alist) \
   do { \
-    SCM_ASSERT (SCM_CONSP (alist) && SCM_CONSP (SCM_CAR (alist)), \
+    SCM_ASSERT (scm_is_pair (alist) && scm_is_pair (SCM_CAR (alist)), \
                 alist, pos, FUNC_NAME); \
   } while (0)
 
 #define SCM_VALIDATE_ALISTCELL_COPYSCM(pos, alist, cvar) \
   do { \
-    SCM_ASSERT (SCM_CONSP (alist), alist, pos, FUNC_NAME); \
+    SCM_ASSERT (scm_is_pair (alist), alist, pos, FUNC_NAME); \
     cvar = SCM_CAR (alist); \
-    SCM_ASSERT (SCM_CONSP (cvar), alist, pos, FUNC_NAME); \
+    SCM_ASSERT (scm_is_pair (cvar), alist, pos, FUNC_NAME); \
   } while (0)
 
 #define SCM_VALIDATE_OPORT_VALUE(pos, port) \
     SCM_ASSERT (scm_is_true (scm_thunk_p (thunk)), thunk, pos, FUNC_NAME); \
   } while (0)
 
-#define SCM_VALIDATE_SYMBOL(pos, sym) SCM_MAKE_VALIDATE_MSG (pos, sym, SYMBOLP, "symbol")
+#define SCM_VALIDATE_SYMBOL(pos, str) \
+  do { \
+    SCM_ASSERT_TYPE (scm_is_symbol (str), str, pos, FUNC_NAME, "symbol"); \
+  } while (0)
 
 #define SCM_VALIDATE_VARIABLE(pos, var) SCM_MAKE_VALIDATE_MSG (pos, var, VARIABLEP, "variable")
 
 
 #define SCM_VALIDATE_NULLORCONS(pos, env) \
   do { \
-    SCM_ASSERT (SCM_NULLP (env) || SCM_CONSP (env), env, pos, FUNC_NAME); \
+    SCM_ASSERT (scm_is_null (env) || scm_is_pair (env), env, pos, FUNC_NAME); \
   } while (0)
 
 #define SCM_VALIDATE_HOOK(pos, a) SCM_MAKE_VALIDATE_MSG (pos, a, HOOKP, "hook")
                 v, pos, FUNC_NAME); \
   } while (0)
 
-#define SCM_VALIDATE_VECTOR(pos, v) SCM_MAKE_VALIDATE_MSG (pos, v, VECTORP, "vector")
+#define SCM_VALIDATE_VECTOR(pos, v) \
+  do { \
+    SCM_ASSERT (scm_is_simple_vector (v), v, pos, FUNC_NAME); \
+  } while (0)
 
 #define SCM_VALIDATE_VECTOR_OR_DVECTOR(pos, v) \
   do { \
-    SCM_ASSERT ((SCM_VECTORP (v) \
-                || (!SCM_IMP (v) && SCM_TYP7 (v) == scm_tc7_dvect)), \
+    SCM_ASSERT ((scm_is_simple_vector (v) \
+                || (scm_is_true (scm_f64vector_p (v)))), \
                 v, pos, FUNC_NAME); \
   } while (0)
 
     SCM_ASSERT (SCM_VECTORP (v) && len == SCM_VECTOR_LENGTH (v), v, pos, FUNC_NAME); \
   } while (0)
 
+
 #endif  /* SCM_VALIDATE_H */
 
 /*