Docs for scm_array_handle_pos.
[bpt/guile.git] / libguile / deprecated.h
index 1b76ae2..4032baf 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))
@@ -60,34 +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
 
-#if SCM_SIZEOF_LONG_LONG != 0
-typedef long long long_long;
-typedef unsigned long long ulong_long;
-#elif SCM_SIZEOF___INT64 != 0
-typedef __int64 long_long;
-typedef unsigned __int64 ulong_long;
-#endif
-
 #define scm_sizet size_t
 
 SCM_API SCM scm_wta (SCM arg, const char *pos, const char *s_subr);
@@ -272,8 +277,8 @@ SCM_API SCM scm_gentemp (SCM prefix, SCM obarray);
 
 #define SCM_VALIDATE_NUMBER_COPY(pos, z, cvar) \
   do {                                         \
-    if (SCM_INUMP (z))                         \
-      cvar = (double) SCM_INUM (z);            \
+    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))                     \
@@ -295,6 +300,182 @@ SCM_API SCM scm_gentemp (SCM prefix, SCM obarray);
 
 #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*
+ */
+
+#define SCM_CELL_WORD_LOC(x, n)   ((scm_t_bits*)SCM_CELL_OBJECT_LOC((x),(n)))
+
+/* Users shouldn't know about INUMs.
+ */
+
+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)
+
+#define SCM_STRING_COERCE_0TERMINATION_X(x) (x)
+
+/* XXX - buggy interface, STR might not be large enough.
+
+   Converts the given Scheme string OBJ into a C string, containing a copy
+   of OBJ's content with a trailing null byte.  If LENP is non-NULL, set
+   *LENP to the string's length.
+
+   When STR is non-NULL it receives the copy and is returned by the function,
+   otherwise new memory is allocated and the caller is responsible for 
+   freeing it via free().  If out of memory, NULL is returned.
+
+   Note that Scheme strings may contain arbitrary data, including null
+   characters.  This means that null termination is not a reliable way to 
+   determine the length of the returned value.  However, the function always 
+   copies the complete contents of OBJ, and sets *LENP to the length of the
+   scheme string (if LENP is non-null).  
+*/
+SCM_API char *scm_c_string2str (SCM obj, char *str, size_t *lenp);
+
+/* XXX - buggy interface, you don't know how many bytes have been copied.
+
+   Copy LEN characters at START from the Scheme string OBJ to memory
+   at STR.  START is an index into OBJ; zero means the beginning of
+   the string.  STR has already been allocated by the caller.
+
+   If START + LEN is off the end of OBJ, silently truncate the source
+   region to fit the string.  If truncation occurs, the corresponding
+   area of STR is left unchanged.  
+*/
+SCM_API char *scm_c_substring2str (SCM obj, char *str, size_t start, size_t len);
+
+SCM_API char *scm_c_symbol2str (SCM obj, char *str, size_t *lenp);
+
+/* Deprecated because the names belong to what is now
+   scm_truncate_number and scm_round_number.
+*/
+SCM_API double scm_truncate (double x);
+SCM_API double scm_round (double x);
+
+/* Deprecated because we don't want people to access the internal
+   representation of strings directly.
+*/
+
+#define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \
+  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));\
+  } while (0)
+
+/* Deprecated because we don't want people to access the internals of
+   symbols directly.
+*/
+
+SCM_API char *SCM_SYMBOL_CHARS (SCM sym);
+SCM_API size_t SCM_SYMBOL_LENGTH (SCM sym);
+
+/* Deprecated because the macros used to evaluate the arguments more
+   than once and because the symbol of a keyword now has no dash.
+*/
+
+SCM_API int SCM_KEYWORDP (SCM obj);
+SCM_API SCM SCM_KEYWORDSYM (SCM keyword);
+
+/* Deprecated because we don't want to hand out unprotected pointers
+   to arrays, vectors, etc. */
+
+#define SCM_VECTOR_MAX_LENGTH ((1L << 24) - 1)
+
+SCM_API int SCM_VECTORP (SCM x);
+SCM_API unsigned long SCM_VECTOR_LENGTH (SCM x);
+SCM_API const SCM *SCM_VELTS (SCM x);
+SCM_API SCM *SCM_WRITABLE_VELTS (SCM x);
+SCM_API SCM SCM_VECTOR_REF (SCM x, size_t idx);
+SCM_API void SCM_VECTOR_SET (SCM x, size_t idx, SCM val);
+SCM_API SCM scm_vector_equal_p (SCM x, SCM y);
+
 void scm_i_init_deprecated (void);
 
 #endif