* discouraged.h, discouraged.c: New files.
[bpt/guile.git] / libguile / discouraged.h
1 /* This file contains definitions for discouraged features. When you
2 discourage something, move it here when that is feasible.
3
4 A discouraged feature is one that shouldn't be used in new code
5 since we have a better alternative now. However, there is nothing
6 wrong with using the old feature, so it is OK to continue to use
7 it.
8
9 Eventually, discouraged features can be deprecated since removing
10 them will make Guile simpler.
11 */
12
13 #ifndef SCM_DISCOURAGED_H
14 #define SCM_DISCOURAGED_H
15
16 /* Copyright (C) 2004 Free Software Foundation, Inc.
17 *
18 * This library is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU Lesser General Public
20 * License as published by the Free Software Foundation; either
21 * version 2.1 of the License, or (at your option) any later version.
22 *
23 * This library is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * Lesser General Public License for more details.
27 *
28 * You should have received a copy of the GNU Lesser General Public
29 * License along with this library; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 */
32
33 #include "libguile/__scm.h"
34
35 #if SCM_ENABLE_DISCOURAGED == 1
36
37 /* Discouraged because they do not follow the naming convention. That
38 is, they end in "P" but return a C boolean. Also, SCM_BOOLP
39 evaluates its argument twice.
40 */
41
42 #define SCM_FALSEP scm_is_false
43 #define SCM_NFALSEP scm_is_true
44 #define SCM_BOOLP scm_is_bool
45 #define SCM_EQ_P scm_is_eq
46
47
48 /* Convert from a C boolean to a SCM boolean value */
49 #define SCM_BOOL scm_from_bool
50
51 /* Convert from a C boolean to a SCM boolean value and negate it */
52 #define SCM_NEGATE_BOOL(f) scm_from_bool(!(f))
53
54 /* SCM_BOOL_NOT returns the other boolean.
55 * The order of ^s here is important for Borland C++ (!?!?!)
56 */
57 #define SCM_BOOL_NOT(x) (SCM_PACK (SCM_UNPACK (x) \
58 ^ (SCM_UNPACK (SCM_BOOL_T) \
59 ^ SCM_UNPACK (SCM_BOOL_F))))
60
61 /* scm_to_int, scm_from_int are the official functions to do the job,
62 but there is nothing wrong with using scm_num2int, etc.
63
64 These could be trivially defined via macros, but we leave them as
65 functions since existing code may take their addresses.
66 */
67
68 SCM_API SCM scm_short2num (short n);
69 SCM_API SCM scm_ushort2num (unsigned short n);
70 SCM_API SCM scm_int2num (int n);
71 SCM_API SCM scm_uint2num (unsigned int n);
72 SCM_API SCM scm_long2num (long n);
73 SCM_API SCM scm_ulong2num (unsigned long n);
74 SCM_API SCM scm_size2num (size_t n);
75 SCM_API SCM scm_ptrdiff2num (scm_t_ptrdiff n);
76 SCM_API short scm_num2short (SCM num, unsigned long int pos,
77 const char *s_caller);
78 SCM_API unsigned short scm_num2ushort (SCM num, unsigned long int pos,
79 const char *s_caller);
80 SCM_API int scm_num2int (SCM num, unsigned long int pos,
81 const char *s_caller);
82 SCM_API unsigned int scm_num2uint (SCM num, unsigned long int pos,
83 const char *s_caller);
84 SCM_API long scm_num2long (SCM num, unsigned long int pos,
85 const char *s_caller);
86 SCM_API unsigned long scm_num2ulong (SCM num, unsigned long int pos,
87 const char *s_caller);
88 SCM_API scm_t_ptrdiff scm_num2ptrdiff (SCM num, unsigned long int pos,
89 const char *s_caller);
90 SCM_API size_t scm_num2size (SCM num, unsigned long int pos,
91 const char *s_caller);
92 #if SCM_SIZEOF_LONG_LONG != 0
93 SCM_API SCM scm_long_long2num (long long sl);
94 SCM_API SCM scm_ulong_long2num (unsigned long long sl);
95 SCM_API long long scm_num2long_long (SCM num, unsigned long int pos,
96 const char *s_caller);
97 SCM_API unsigned long long scm_num2ulong_long (SCM num, unsigned long int pos,
98 const char *s_caller);
99 #endif
100
101 void scm_i_init_discouraged (void);
102
103 #endif /* SCM_ENABLE_DISCOURAGED == 1 */
104
105 #endif /* SCM_DISCOURAGED_H */