* deprecated.h (SCM_FALSEP, SCM_NFALSEP, SCM_BOOLP, SCM_BOOL):
[bpt/guile.git] / libguile / deprecated.h
index 5c20c78..2794a50 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef SCM_DEPRECATED_H
 #define SCM_DEPRECATED_H
 
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003,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
 
 #if (SCM_ENABLE_DEPRECATED == 1)
 
+/* From eval.h: Macros for handling ilocs.  These were deprecated in guile
+ * 1.7.0 on 2004-04-22.  */
+#define SCM_IFRINC             (0x00000100L)
+#define SCM_ICDR               (0x00080000L)
+#define SCM_IFRAME(n)          ((long)((SCM_ICDR-SCM_IFRINC)>>8) \
+                                & (SCM_UNPACK (n) >> 8))
+#define SCM_IDIST(n)           (SCM_UNPACK (n) >> 20)
+#define SCM_ICDRP(n)           (SCM_ICDR & SCM_UNPACK (n))
+
+
+/* From tags.h: Macros to access internal symbol names of isyms.  Deprecated
+ * in guile 1.7.0 on 2004-04-22.  */
+SCM_API char *scm_isymnames[];
+#define SCM_ISYMNUM(n)                0
+#define SCM_ISYMCHARS(n)       "#@<deprecated>"
+
+
+/* From tags.h: Macro checking for two tc16 types that are allocated to differ
+ * only in the 's'-bit.  Deprecated in guile 1.7.0 on 2003-09-21.  */
+#define SCM_TYP16S(x)          (0xfeff & SCM_CELL_TYPE (x))
+
+
+/* From numbers.h: Macros checking for types, but avoiding a redundant check
+ * for !SCM_IMP.  These were deprecated in guile 1.7.0 on 2003-09-06.  */
+#define SCM_SLOPPY_INEXACTP(x) (SCM_TYP16S (x) == scm_tc16_real)
+#define SCM_SLOPPY_REALP(x) (SCM_TYP16 (x) == scm_tc16_real)
+#define SCM_SLOPPY_COMPLEXP(x) (SCM_TYP16 (x) == scm_tc16_complex)
+
+
+/* From eval.h: Macros for handling ilocs.  These were deprecated in guile
+ * 1.7.0 on 2003-06-04.  */
+#define SCM_ILOC00             SCM_MAKE_ITAG8(0L, scm_tc8_iloc)
+#define SCM_IDINC              (0x00100000L)
+#define SCM_IDSTMSK            (-SCM_IDINC)
+
+
 /* From eval.h: Error messages of the evaluator.  These were deprecated in
  * guile 1.7.0 on 2003-06-02.  */
 SCM_API const char scm_s_expression[];
@@ -41,29 +77,22 @@ SCM_API const char scm_s_formals[];
 /* From eval.h: Helper macros for evaluation and application.  These were
  * deprecated in guile 1.7.0 on 2003-06-02.  */
 #define SCM_EVALIM2(x) \
-  ((SCM_EQ_P ((x), SCM_EOL) \
+  ((scm_is_eq ((x), SCM_EOL) \
     ? scm_misc_error (NULL, scm_s_expression, SCM_EOL), 0 \
     : 0), \
    (x))
 #define SCM_EVALIM(x, env) (SCM_ILOCP (x) \
                             ? *scm_ilookup ((x), env) \
                            : SCM_EVALIM2(x))
-#define SCM_XEVAL(x, env) (SCM_IMP (x) \
-                          ? SCM_EVALIM2(x) \
-                          : (*scm_ceval_ptr) ((x), (env)))
-#define SCM_XEVALCAR(x, env) (SCM_IMP (SCM_CAR (x)) \
-                             ? SCM_EVALIM (SCM_CAR (x), env) \
-                             : (SCM_SYMBOLP (SCM_CAR (x)) \
-                                ? *scm_lookupcar (x, env, 1) \
-                                : (*scm_ceval_ptr) (SCM_CAR (x), env)))
+#define SCM_XEVAL(x, env) (scm_i_eval_x ((x), (env)))
+#define SCM_XEVALCAR(x, env) (SCM_SYMBOLP (SCM_CAR (x)) \
+                             ? *scm_lookupcar (x, env, 1) \
+                             : scm_i_eval_x (SCM_CAR (x), (env)))
 
 
 #define scm_substring_move_left_x scm_substring_move_x
 #define scm_substring_move_right_x scm_substring_move_x
 
-typedef long long long_long;
-typedef unsigned long long ulong_long;
-
 #define scm_sizet size_t
 
 SCM_API SCM scm_wta (SCM arg, const char *pos, const char *s_subr);
@@ -206,94 +235,179 @@ SCM_API long scm_i_object_length (SCM);
 
 #define SCM_LENGTH(x) scm_i_object_length(x)
 
-void scm_i_init_deprecated (void);
-
+#define scm_strhash(str, len, n) (scm_string_hash ((str), (len)) % (n))
+
+SCM_API SCM scm_sym2ovcell_soft (SCM sym, SCM obarray);
+SCM_API SCM scm_sym2ovcell (SCM sym, SCM obarray);
+SCM_API SCM scm_intern_obarray_soft (const char *name, size_t len,
+                                    SCM obarray, unsigned int softness);
+SCM_API SCM scm_intern_obarray (const char *name, size_t len, SCM obarray);
+SCM_API SCM scm_symbol_value0 (const char *name);
+
+SCM_API SCM scm_string_to_obarray_symbol (SCM o, SCM s, SCM softp);
+SCM_API SCM scm_intern_symbol (SCM o, SCM s);
+SCM_API SCM scm_unintern_symbol (SCM o, SCM s);
+SCM_API SCM scm_symbol_binding (SCM o, SCM s);
+#if 0
+/* This name has been reused for real uninterned symbols. */
+SCM_API SCM scm_symbol_interned_p (SCM o, SCM s);
 #endif
+SCM_API SCM scm_symbol_bound_p (SCM o, SCM s);
+SCM_API SCM scm_symbol_set_x (SCM o, SCM s, SCM v);
+
+SCM_API SCM scm_gentemp (SCM prefix, SCM obarray);
+
+#define SCM_OPDIRP(x) (SCM_DIRP (x) && (SCM_DIR_OPEN_P (x)))
+#define scm_fport scm_t_fport
+#define scm_option scm_t_option
+#define scm_srcprops scm_t_srcprops
+#define scm_srcprops_chunk scm_t_srcprops_chunk
+#define scm_info_frame scm_t_info_frame
+#define scm_stack scm_t_stack
+#define scm_array scm_t_array
+#define scm_array_dim scm_t_array_dim
+#define SCM_ARRAY_CONTIGUOUS SCM_ARRAY_FLAG_CONTIGUOUS
+#define SCM_FUNC_NAME (scm_makfrom0str (FUNC_NAME))
+
+#define SCM_WTA(pos, scm) \
+  do { scm_wta (scm, (char *) pos, FUNC_NAME); } while (0)
+
+#define RETURN_SCM_WTA(pos, scm) \
+  do { return scm_wta (scm, (char *) pos, FUNC_NAME); } while (0)
+
+#define SCM_VALIDATE_NUMBER_COPY(pos, z, cvar) \
+  do {                                         \
+    if (SCM_I_INUMP (z))                               \
+      cvar = (double) SCM_I_INUM (z);          \
+    else if (SCM_REALP (z))                    \
+      cvar = SCM_REAL_VALUE (z);               \
+    else if (SCM_BIGP (z))                     \
+      cvar = scm_i_big2dbl (z);                        \
+    else                                       \
+      {                                                \
+       cvar = 0.0;                             \
+        SCM_WRONG_TYPE_ARG (pos, z);           \
+      }                                                \
+  } while (0)
+
+#define SCM_VALIDATE_NUMBER_DEF_COPY(pos, number, def, cvar)   \
+  do {                                                         \
+    if (SCM_UNBNDP (number))                                   \
+      cvar = def;                                              \
+    else                                                       \
+      SCM_VALIDATE_NUMBER_COPY(pos, number, cvar);             \
+  } while (0)
+
+#define SCM_VALIDATE_OPDIR(pos, port) SCM_MAKE_VALIDATE (pos, port, OPDIRP)
+
+/* Deprecated because we can not safely cast a SCM* to a scm_t_bits*
+ */
 
-#endif /* SCM_DEPRECATED_H */
-
-#if 0 
-/* TODO */
-
-scm_strhash
-
-scm_sym2vcell
-scm_sym2ovcell_soft
-scm_sym2ovcell
-
-scm_intern_obarray_soft
-scm_intern_obarray
-scm_intern
-scm_intern0
-
-scm_sysintern
-scm_sysintern0
-scm_sysintern0_no_module_lookup
-
-scm_symbol_value0
-scm_string_to_obarray_symbol
-scm_intern_symbol
-
-scm_unintern_symbol
-scm_symbol_binding
-scm_symbol_interned_p
-
-scm_symbol_bound_p
-scm_symbol_set_x
-scm_gentemp
-
-scm_init_symbols_deprecated
-scm_vector_set_length_x
-
-SCM_OPDIRP
-
-scm_fport
-scm_option
-SCM_CONST_LONG
-SCM_VCELL
-SCM_GLOBAL_VCELL
-
-SCM_VCELL_INIT
-SCM_GLOBAL_VCELL_INIT
-scm_srcprops
-scm_srcprops_chunk
+#define SCM_CELL_WORD_LOC(x, n)   ((scm_t_bits*)SCM_CELL_OBJECT_LOC((x),(n)))
 
-scm_info_frame
-scm_stack
-scm_array
-scm_array_dim
-SCM_ARRAY_CONTIGUOUS
+/* Deprecated because they do not follow the naming convention.  that
+   is, they endiin "P" but return a C boolean.  Also, SCM_BOOLP
+   evaluates its argument twice.
+*/
 
-SCM_HUGE_LENGTH
-SCM_FUNC_NAME
-SCM_WTA
-RETURN_SCM_WTA
+#define SCM_FALSEP             scm_is_false
+#define SCM_NFALSEP            scm_is_true
+#define SCM_BOOLP               scm_is_bool
+#define SCM_EQ_P                scm_is_eq
 
-SCM_VALIDATE_NUMBER_COPY
-SCM_VALIDATE_NUMBER_DEF_COPY
 
-SCM_VALIDATE_STRINGORSUBSTR
-SCM_VALIDATE_ROSTRING
+/* Convert from a C boolean to a SCM boolean value */
+#define SCM_BOOL               scm_from_bool
 
-SCM_VALIDATE_ROSTRING_COPY
-SCM_VALIDATE_NULLORROSTRING_COPY
+/* Convert from a C boolean to a SCM boolean value and negate it */
+#define SCM_NEGATE_BOOL(f)     scm_from_bool(!(f))
 
-SCM_VALIDATE_RWSTRING
-SCM_VALIDATE_OPDIR
-scm_small_istr2int
+/* SCM_BOOL_NOT returns the other boolean.  
+ * The order of ^s here is important for Borland C++ (!?!?!)
+ */
+#define SCM_BOOL_NOT(x)                (SCM_PACK (SCM_UNPACK (x) \
+                                          ^ (SCM_UNPACK (SCM_BOOL_T) \
+                                             ^ SCM_UNPACK (SCM_BOOL_F))))
 
-scm_istr2int
-scm_istr2flo
-scm_istring2number
-scm_istr2int
+/* Users shouldn't know about INUMs.
+ */
 
-scm_istr2flo
-scm_istring2number
-scm_vtable_index_vcell
+SCM_API SCM SCM_MAKINUM (scm_t_signed_bits val);
+SCM_API int SCM_INUMP (SCM obj);
+#define SCM_NINUMP(x) (!SCM_INUMP(x))
+SCM_API scm_t_signed_bits SCM_INUM (SCM obj);
+
+#define SCM_VALIDATE_INUM(pos, k) SCM_MAKE_VALIDATE_MSG (pos, k, INUMP, "exact integer")
+
+#define SCM_VALIDATE_INUM_COPY(pos, k, cvar) \
+  do { \
+    SCM_ASSERT (SCM_I_INUMP (k), k, pos, FUNC_NAME); \
+    cvar = SCM_I_INUM (k); \
+  } while (0)
+
+#define SCM_VALIDATE_BIGINT(pos, k) SCM_MAKE_VALIDATE_MSG (pos, k, BIGP, "bignum")
+
+#define SCM_VALIDATE_INUM_MIN(pos, k, min) \
+  do { \
+    SCM_ASSERT (SCM_I_INUMP(k), k, pos, FUNC_NAME); \
+    SCM_ASSERT_RANGE (pos, k, (SCM_I_INUM (k) >= min)); \
+  } while (0)
+
+#define SCM_VALIDATE_INUM_MIN_COPY(pos, k, min, cvar) \
+  do { \
+    SCM_ASSERT (SCM_I_INUMP (k), k, pos, FUNC_NAME); \
+    SCM_ASSERT_RANGE (pos, k, (SCM_I_INUM (k) >= min)); \
+    cvar = SCM_INUM (k); \
+  } while (0)
+
+#define SCM_VALIDATE_INUM_MIN_DEF_COPY(pos, k, min, default, cvar) \
+  do { \
+    if (SCM_UNBNDP (k)) \
+      k = SCM_I_MAKINUM (default); \
+    SCM_ASSERT (SCM_I_INUMP (k), k, pos, FUNC_NAME); \
+    SCM_ASSERT_RANGE (pos, k, (SCM_I_INUM (k) >= min)); \
+    cvar = SCM_INUM (k); \
+  } while (0)
+
+#define SCM_VALIDATE_INUM_DEF(pos, k, default) \
+  do { \
+    if (SCM_UNBNDP (k)) \
+      k = SCM_I_MAKINUM (default); \
+    else SCM_ASSERT (SCM_I_INUMP (k), k, pos, FUNC_NAME); \
+  } while (0)
+
+#define SCM_VALIDATE_INUM_DEF_COPY(pos, k, default, cvar) \
+  do { \
+    if (SCM_UNBNDP (k)) \
+      { \
+        k = SCM_I_MAKINUM (default); \
+        cvar = default; \
+      } \
+    else \
+      { \
+        SCM_ASSERT (SCM_I_INUMP (k), k, pos, FUNC_NAME); \
+        cvar = SCM_INUM (k); \
+      } \
+  } while (0)
+
+/* [low, high) */
+#define SCM_VALIDATE_INUM_RANGE(pos, k, low, high) \
+  do { SCM_ASSERT(SCM_I_INUMP(k), k, pos, FUNC_NAME); \
+       SCM_ASSERT_RANGE(pos, k, \
+                        (SCM_I_INUM (k) >= low && \
+                         SCM_I_INUM (k) < high)); \
+     } while (0)
+
+#define SCM_VALIDATE_INUM_RANGE_COPY(pos, k, low, high, cvar) \
+  do { \
+    SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
+    SCM_ASSERT_RANGE (pos, k, low <= SCM_INUM (k) && SCM_INUM (k) < high); \
+    cvar = SCM_INUM (k); \
+  } while (0)
 
-SCM_ECONSP
-SCM_NECONSP
 
-scm_tc16_variable
+void scm_i_init_deprecated (void);
 
 #endif
+
+#endif /* SCM_DEPRECATED_H */