Remove unused macro UNMARKED_CELL_P()
[bpt/guile.git] / libguile / discouraged.c
CommitLineData
c71b0706
MV
1/* This file contains definitions for discouraged features. When you
2 discourage something, move it here when that is feasible.
3*/
4
2b829bbb 5/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
c71b0706
MV
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
92205699 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c71b0706
MV
20 */
21
22#include "libguile.h"
23
24#if (SCM_ENABLE_DISCOURAGED == 1)
25
e4c1d4cf
NJ
26SCM
27scm_short2num (short x)
28{
29 return scm_from_short (x);
30}
31
32SCM
33scm_ushort2num (unsigned short x)
34{
35 return scm_from_ushort (x);
36}
37
38SCM
39scm_int2num (int x)
40{
41 return scm_from_int (x);
42}
43
44SCM
45scm_uint2num (unsigned int x)
46{
47 return scm_from_uint (x);
48}
49
50SCM
51scm_long2num (long x)
52{
53 return scm_from_long (x);
54}
55
56SCM
57scm_ulong2num (unsigned long x)
58{
59 return scm_from_ulong (x);
60}
61
62SCM
63scm_size2num (size_t x)
64{
65 return scm_from_size_t (x);
66}
67
68SCM
69scm_ptrdiff2num (ptrdiff_t x)
70{
71 return scm_from_ssize_t (x);
72}
73
74short
75scm_num2short (SCM x, unsigned long pos, const char *s_caller)
76{
77 return scm_to_short (x);
78}
79
80unsigned short
81scm_num2ushort (SCM x, unsigned long pos, const char *s_caller)
82{
83 return scm_to_ushort (x);
84}
85
86int
87scm_num2int (SCM x, unsigned long pos, const char *s_caller)
88{
89 return scm_to_int (x);
90}
91
92unsigned int
93scm_num2uint (SCM x, unsigned long pos, const char *s_caller)
94{
95 return scm_to_uint (x);
96}
97
98long
99scm_num2long (SCM x, unsigned long pos, const char *s_caller)
100{
101 return scm_to_long (x);
102}
103
104unsigned long
105scm_num2ulong (SCM x, unsigned long pos, const char *s_caller)
106{
107 return scm_to_ulong (x);
108}
109
110size_t
111scm_num2size (SCM x, unsigned long pos, const char *s_caller)
112{
113 return scm_to_size_t (x);
114}
115
116ptrdiff_t
117scm_num2ptrdiff (SCM x, unsigned long pos, const char *s_caller)
118{
119 return scm_to_ssize_t (x);
120}
c71b0706
MV
121
122#if SCM_SIZEOF_LONG_LONG != 0
e4c1d4cf
NJ
123
124SCM
125scm_long_long2num (long long x)
126{
127 return scm_from_long_long (x);
128}
129
130SCM
131scm_ulong_long2num (unsigned long long x)
132{
133 return scm_from_ulong_long (x);
134}
135
136long long
137scm_num2long_long (SCM x, unsigned long pos, const char *s_caller)
138{
139 return scm_to_long_long (x);
140}
141
142unsigned long long
143scm_num2ulong_long (SCM x, unsigned long pos, const char *s_caller)
144{
145 return scm_to_ulong_long (x);
146}
147
c71b0706
MV
148#endif
149
55f26379
MV
150SCM
151scm_make_real (double x)
152{
153 return scm_from_double (x);
154}
155
156double
157scm_num2dbl (SCM a, const char *why)
158{
159 return scm_to_double (a);
160}
161
162SCM
163scm_float2num (float n)
164{
165 return scm_from_double ((double) n);
166}
167
168SCM
169scm_double2num (double n)
170{
171 return scm_from_double (n);
172}
c71b0706 173
8507ec80
MV
174SCM
175scm_make_complex (double x, double y)
176{
177 return scm_c_make_rectangular (x, y);
178}
179
3ee86942
MV
180SCM
181scm_mem2symbol (const char *mem, size_t len)
182{
183 return scm_from_locale_symboln (mem, len);
184}
185
186SCM
187scm_mem2uninterned_symbol (const char *mem, size_t len)
188{
189 return scm_make_symbol (scm_from_locale_stringn (mem, len));
190}
191
192SCM
193scm_str2symbol (const char *str)
194{
195 return scm_from_locale_symbol (str);
196}
197
198
199/* This function must only be applied to memory obtained via malloc,
200 since the GC is going to apply `free' to it when the string is
201 dropped.
202
203 Also, s[len] must be `\0', since we promise that strings are
204 null-terminated. Perhaps we could handle non-null-terminated
205 strings by claiming they're shared substrings of a string we just
206 made up. */
207SCM
208scm_take_str (char *s, size_t len)
209{
210 SCM answer = scm_from_locale_stringn (s, len);
211 free (s);
212 return answer;
213}
214
215/* `s' must be a malloc'd string. See scm_take_str. */
216SCM
217scm_take0str (char *s)
218{
219 return scm_take_locale_string (s);
220}
221
222SCM
223scm_mem2string (const char *src, size_t len)
224{
225 return scm_from_locale_stringn (src, len);
226}
227
228SCM
229scm_str2string (const char *src)
230{
231 return scm_from_locale_string (src);
232}
233
234SCM
235scm_makfrom0str (const char *src)
236{
237 if (!src) return SCM_BOOL_F;
238 return scm_from_locale_string (src);
239}
240
241SCM
242scm_makfrom0str_opt (const char *src)
243{
244 return scm_makfrom0str (src);
245}
246
247
248SCM
249scm_allocate_string (size_t len)
250{
251 return scm_i_make_string (len, NULL);
252}
253
265a7997
MV
254SCM_DEFINE (scm_make_keyword_from_dash_symbol, "make-keyword-from-dash-symbol", 1, 0, 0,
255 (SCM symbol),
256 "Make a keyword object from a @var{symbol} that starts with a dash.")
257#define FUNC_NAME s_scm_make_keyword_from_dash_symbol
258{
259 SCM dash_string, non_dash_symbol;
260
261 SCM_ASSERT (scm_is_symbol (symbol)
262 && ('-' == scm_i_symbol_chars(symbol)[0]),
263 symbol, SCM_ARG1, FUNC_NAME);
264
265 dash_string = scm_symbol_to_string (symbol);
266 non_dash_symbol =
267 scm_string_to_symbol (scm_c_substring (dash_string,
268 1,
269 scm_c_string_length (dash_string)));
270
271 return scm_symbol_to_keyword (non_dash_symbol);
272}
273#undef FUNC_NAME
274
275SCM_DEFINE (scm_keyword_dash_symbol, "keyword-dash-symbol", 1, 0, 0,
276 (SCM keyword),
277 "Return the dash symbol for @var{keyword}.\n"
278 "This is the inverse of @code{make-keyword-from-dash-symbol}.")
279#define FUNC_NAME s_scm_keyword_dash_symbol
280{
281 SCM symbol = scm_keyword_to_symbol (keyword);
282 SCM parts = scm_list_2 (scm_from_locale_string ("-"),
283 scm_symbol_to_string (symbol));
284 return scm_string_to_symbol (scm_string_append (parts));
285}
286#undef FUNC_NAME
287
288SCM
289scm_c_make_keyword (const char *s)
290{
291 return scm_from_locale_keyword (s);
292}
293
294
c71b0706
MV
295void
296scm_i_init_discouraged (void)
297{
298#include "libguile/discouraged.x"
299}
300
301#endif