merge from 1.8
[bpt/guile.git] / libguile / deprecated.h
index 2794a50..9a0862c 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef SCM_DEPRECATED_H
 #define SCM_DEPRECATED_H
 
-/* Copyright (C) 2003,2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003,2004, 2005, 2006, 2007 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
@@ -19,7 +19,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include "libguile/__scm.h"
@@ -164,7 +164,7 @@ SCM_API SCM scm_make_gsubr_with_generic (const char *name,
                                         SCM (*fcn)(),
                                         SCM *gf);
 
-extern SCM scm_create_hook (const char* name, int n_args);
+SCM_API SCM scm_create_hook (const char* name, int n_args);
 
 #define SCM_LIST0 SCM_EOL
 #define SCM_LIST1(e0) scm_cons ((e0), SCM_EOL)
@@ -305,37 +305,17 @@ SCM_API SCM scm_gentemp (SCM prefix, SCM obarray);
 
 #define SCM_CELL_WORD_LOC(x, n)   ((scm_t_bits*)SCM_CELL_OBJECT_LOC((x),(n)))
 
-/* 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.
-*/
-
-#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
-
-
-/* Convert from a C boolean to a SCM boolean value */
-#define SCM_BOOL               scm_from_bool
-
-/* Convert from a C boolean to a SCM boolean value and negate it */
-#define SCM_NEGATE_BOOL(f)     scm_from_bool(!(f))
-
-/* 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))))
-
 /* 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);
+SCM_API SCM scm_i_makinum (scm_t_signed_bits val);
+SCM_API int scm_i_inump (SCM obj);
+SCM_API scm_t_signed_bits scm_i_inum (SCM obj);
+
+#define SCM_MAKINUM(x)   scm_i_makinum(x)
+#define SCM_INUM(x)      scm_i_inum(x)
+#define SCM_INUMP(x)     scm_i_inump(x)
+#define SCM_NINUMP(x)    (!SCM_INUMP(x))
 
 #define SCM_VALIDATE_INUM(pos, k) SCM_MAKE_VALIDATE_MSG (pos, k, INUMP, "exact integer")
 
@@ -405,6 +385,201 @@ SCM_API scm_t_signed_bits SCM_INUM (SCM obj);
     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_i_deprecated_symbol_chars (SCM sym);
+SCM_API size_t scm_i_deprecated_symbol_length (SCM sym);
+
+#define SCM_SYMBOL_CHARS(x)  scm_i_deprecated_symbol_chars(x)
+#define SCM_SYMBOL_LENGTH(x) scm_i_deprecated_symbol_length(x)
+
+/* 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_i_keywordp (SCM obj);
+SCM_API SCM scm_i_keywordsym (SCM keyword);
+
+#define SCM_KEYWORDP(x)   scm_i_keywordp(x)
+#define SCM_KEYWORDSYM(x) scm_i_keywordsym(x)
+
+/* 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_i_vectorp (SCM x);
+SCM_API unsigned long scm_i_vector_length (SCM x);
+SCM_API const SCM *scm_i_velts (SCM x);
+SCM_API SCM *scm_i_writable_velts (SCM x);
+SCM_API SCM scm_i_vector_ref (SCM x, size_t idx);
+SCM_API void scm_i_vector_set (SCM x, size_t idx, SCM val);
+SCM_API SCM scm_vector_equal_p (SCM x, SCM y);
+
+#define SCM_VECTORP(x)         scm_i_vectorp(x)
+#define SCM_VECTOR_LENGTH(x)   scm_i_vector_length(x)
+#define SCM_VELTS(x)           scm_i_velts(x)
+#define SCM_WRITABLE_VELTS(x)  scm_i_writable_velts(x)
+#define SCM_VECTOR_REF(x,y)    scm_i_vector_ref(x,y)
+#define SCM_VECTOR_SET(x,y,z)  scm_i_vector_set(x,y,z)
+
+typedef scm_i_t_array scm_t_array;
+
+SCM_API int scm_i_arrayp (SCM a);
+SCM_API size_t scm_i_array_ndim (SCM a);
+SCM_API int scm_i_array_contp (SCM a);
+SCM_API scm_t_array *scm_i_array_mem (SCM a);
+SCM_API SCM scm_i_array_v (SCM a);
+SCM_API size_t scm_i_array_base (SCM a);
+SCM_API scm_t_array_dim *scm_i_array_dims (SCM a);
+
+#define SCM_ARRAYP(a)      scm_i_arrayp(a)
+#define SCM_ARRAY_NDIM(a)  scm_i_array_ndim(a)
+#define SCM_ARRAY_CONTP(a) scm_i_array_contp(a)
+#define SCM_ARRAY_MEM(a)   scm_i_array_mem(a)
+#define SCM_ARRAY_V(a)     scm_i_array_v(a)
+#define SCM_ARRAY_BASE(a)  scm_i_array_base(a)
+#define SCM_ARRAY_DIMS(a)  scm_i_array_dims(a)
+
+/* Deprecated because they should not be lvalues and we want people to
+   use the official interfaces.
+ */
+
+#define scm_cur_inp           scm_i_cur_inp ()
+#define scm_cur_outp          scm_i_cur_outp ()
+#define scm_cur_errp          scm_i_cur_errp ()
+#define scm_cur_loadp         scm_i_cur_loadp ()
+#define scm_progargs          scm_i_progargs ()
+#define scm_dynwinds          scm_i_deprecated_dynwinds ()
+#define scm_last_debug_frame  scm_i_deprecated_last_debug_frame ()
+#define scm_stack_base        scm_i_stack_base ()
+
+SCM_API SCM scm_i_cur_inp (void);
+SCM_API SCM scm_i_cur_outp (void);
+SCM_API SCM scm_i_cur_errp (void);
+SCM_API SCM scm_i_cur_loadp (void);
+SCM_API SCM scm_i_progargs (void);
+SCM_API SCM scm_i_deprecated_dynwinds (void);
+SCM_API scm_t_debug_frame *scm_i_deprecated_last_debug_frame (void);
+SCM_API SCM_STACKITEM *scm_i_stack_base (void);
+
+/* Deprecated because it evaluates its argument twice.
+ */
+#define SCM_FLUIDP(x) scm_i_fluidp (x)
+SCM_API int scm_i_fluidp (SCM x);
+
+/* In the old days, SCM_CRITICAL_SECTION_START stopped signal handlers
+   from running, since in those days the handler directly ran scheme
+   code, and that had to be avoided when the heap was not in a
+   consistent state etc.  And since the scheme code could do a stack
+   swapping new continuation etc, signals had to be deferred around
+   various C library functions which were not safe or not known to be
+   safe to swap away, which was a lot of stuff.
+
+   These days signals are implemented with asyncs and don't directly
+   run scheme code in the handler, but hold it until an SCM_TICK etc
+   where it will be safe.  This means interrupt protection is not
+   needed and SCM_CRITICAL_SECTION_START / SCM_CRITICAL_SECTION_END is
+   something of an anachronism.
+
+   What past SCM_CRITICAL_SECTION_START usage also did though was
+   indicate code that was not reentrant, ie. could not be reentered by
+   signal handler code.  The present definitions are a mutex lock,
+   affording that reentrancy protection against the new guile 1.8
+   free-running posix threads.
+
+   One big problem with the present defintions though is that code which
+   throws an error from within a DEFER/ALLOW region will leave the
+   defer_mutex locked and hence hang other threads that attempt to enter a
+   similar DEFER/ALLOW region.
+*/
+
+SCM_API void scm_i_defer_ints_etc (void);
+#define SCM_DEFER_INTS scm_i_defer_ints_etc ()
+#define SCM_ALLOW_INTS scm_i_defer_ints_etc ()
+#define SCM_REDEFER_INTS scm_i_defer_ints_etc ()
+#define SCM_REALLOW_INTS scm_i_defer_ints_etc ()
+
+/* Deprecated since they are unnecessary and had not been documented.
+ */
+SCM_API SCM scm_guard (SCM guardian, SCM obj, int throw_p);
+SCM_API SCM scm_get_one_zombie (SCM guardian);
+
+/* Deprecated since guardians no longer have these special features.
+ */
+SCM_API SCM scm_destroy_guardian_x (SCM guardian);
+SCM_API SCM scm_guardian_greedy_p (SCM guardian);
+SCM_API SCM scm_guardian_destroyed_p (SCM guardian);
 
 void scm_i_init_deprecated (void);