Commit | Line | Data |
---|---|---|
19e2247d MV |
1 | /* This file contains definitions for deprecated features. When you |
2 | deprecate something, move it here when that is feasible. | |
3 | */ | |
4 | ||
5 | #ifndef SCM_DEPRECATED_H | |
6 | #define SCM_DEPRECATED_H | |
7 | ||
23d72566 | 8 | /* Copyright (C) 2003,2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
19e2247d | 9 | * |
73be1d9e | 10 | * This library is free software; you can redistribute it and/or |
53befeb7 NJ |
11 | * modify it under the terms of the GNU Lesser General Public License |
12 | * as published by the Free Software Foundation; either version 3 of | |
13 | * the License, or (at your option) any later version. | |
19e2247d | 14 | * |
53befeb7 NJ |
15 | * This library is distributed in the hope that it will be useful, but |
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
73be1d9e MV |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | * Lesser General Public License for more details. | |
19e2247d | 19 | * |
73be1d9e MV |
20 | * You should have received a copy of the GNU Lesser General Public |
21 | * License along with this library; if not, write to the Free Software | |
53befeb7 NJ |
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
23 | * 02110-1301 USA | |
73be1d9e | 24 | */ |
19e2247d MV |
25 | |
26 | #include "libguile/__scm.h" | |
55d30fac | 27 | #include "libguile/strings.h" |
19e2247d MV |
28 | |
29 | #if (SCM_ENABLE_DEPRECATED == 1) | |
30 | ||
7e6e6b37 DH |
31 | /* From eval.h: Macros for handling ilocs. These were deprecated in guile |
32 | * 1.7.0 on 2004-04-22. */ | |
33 | #define SCM_IFRINC (0x00000100L) | |
34 | #define SCM_ICDR (0x00080000L) | |
35 | #define SCM_IFRAME(n) ((long)((SCM_ICDR-SCM_IFRINC)>>8) \ | |
36 | & (SCM_UNPACK (n) >> 8)) | |
37 | #define SCM_IDIST(n) (SCM_UNPACK (n) >> 20) | |
38 | #define SCM_ICDRP(n) (SCM_ICDR & SCM_UNPACK (n)) | |
39 | ||
40 | ||
41 | /* From tags.h: Macros to access internal symbol names of isyms. Deprecated | |
42 | * in guile 1.7.0 on 2004-04-22. */ | |
43 | SCM_API char *scm_isymnames[]; | |
44 | #define SCM_ISYMNUM(n) 0 | |
45 | #define SCM_ISYMCHARS(n) "#@<deprecated>" | |
46 | ||
47 | ||
f03314f9 DH |
48 | /* From tags.h: Macro checking for two tc16 types that are allocated to differ |
49 | * only in the 's'-bit. Deprecated in guile 1.7.0 on 2003-09-21. */ | |
50 | #define SCM_TYP16S(x) (0xfeff & SCM_CELL_TYPE (x)) | |
51 | ||
52 | ||
0d5e3480 DH |
53 | /* From numbers.h: Macros checking for types, but avoiding a redundant check |
54 | * for !SCM_IMP. These were deprecated in guile 1.7.0 on 2003-09-06. */ | |
55 | #define SCM_SLOPPY_INEXACTP(x) (SCM_TYP16S (x) == scm_tc16_real) | |
56 | #define SCM_SLOPPY_REALP(x) (SCM_TYP16 (x) == scm_tc16_real) | |
57 | #define SCM_SLOPPY_COMPLEXP(x) (SCM_TYP16 (x) == scm_tc16_complex) | |
58 | ||
59 | ||
d0624e39 DH |
60 | /* From eval.h: Macros for handling ilocs. These were deprecated in guile |
61 | * 1.7.0 on 2003-06-04. */ | |
62 | #define SCM_ILOC00 SCM_MAKE_ITAG8(0L, scm_tc8_iloc) | |
63 | #define SCM_IDINC (0x00100000L) | |
64 | #define SCM_IDSTMSK (-SCM_IDINC) | |
65 | ||
66 | ||
e90c3a89 DH |
67 | /* From eval.h: Error messages of the evaluator. These were deprecated in |
68 | * guile 1.7.0 on 2003-06-02. */ | |
69 | SCM_API const char scm_s_expression[]; | |
70 | SCM_API const char scm_s_test[]; | |
71 | SCM_API const char scm_s_body[]; | |
72 | SCM_API const char scm_s_bindings[]; | |
73 | SCM_API const char scm_s_variable[]; | |
74 | SCM_API const char scm_s_clauses[]; | |
75 | SCM_API const char scm_s_formals[]; | |
76 | ||
77 | ||
78 | /* From eval.h: Helper macros for evaluation and application. These were | |
79 | * deprecated in guile 1.7.0 on 2003-06-02. */ | |
80 | #define SCM_EVALIM2(x) \ | |
2ad58b2a | 81 | ((scm_is_eq ((x), SCM_EOL) \ |
e90c3a89 DH |
82 | ? scm_misc_error (NULL, scm_s_expression, SCM_EOL), 0 \ |
83 | : 0), \ | |
84 | (x)) | |
85 | #define SCM_EVALIM(x, env) (SCM_ILOCP (x) \ | |
86 | ? *scm_ilookup ((x), env) \ | |
87 | : SCM_EVALIM2(x)) | |
434f2f7a DH |
88 | #define SCM_XEVAL(x, env) (scm_i_eval_x ((x), (env))) |
89 | #define SCM_XEVALCAR(x, env) (SCM_SYMBOLP (SCM_CAR (x)) \ | |
90 | ? *scm_lookupcar (x, env, 1) \ | |
91 | : scm_i_eval_x (SCM_CAR (x), (env))) | |
e90c3a89 DH |
92 | |
93 | ||
19e2247d MV |
94 | #define scm_substring_move_left_x scm_substring_move_x |
95 | #define scm_substring_move_right_x scm_substring_move_x | |
96 | ||
55d30fac | 97 | #define scm_sizet size_t |
19e2247d | 98 | |
55d30fac | 99 | SCM_API SCM scm_wta (SCM arg, const char *pos, const char *s_subr); |
19e2247d | 100 | |
55d30fac MV |
101 | #define SCM_WNA 8 |
102 | #define SCM_OUTOFRANGE 10 | |
103 | #define SCM_NALLOC 11 | |
19e2247d | 104 | |
55d30fac MV |
105 | SCM_API void scm_register_module_xxx (char *module_name, void *init_func); |
106 | SCM_API SCM scm_registered_modules (void); | |
107 | SCM_API SCM scm_clear_registered_modules (void); | |
19e2247d | 108 | |
a0454d72 MV |
109 | SCM_API SCM scm_protect_object (SCM obj); |
110 | SCM_API SCM scm_unprotect_object (SCM obj); | |
111 | ||
112 | #define SCM_SETAND_CAR(x, y) \ | |
113 | (SCM_SETCAR ((x), SCM_PACK (SCM_UNPACK (SCM_CAR (x)) & (y)))) | |
114 | #define SCM_SETOR_CAR(x, y)\ | |
115 | (SCM_SETCAR ((x), SCM_PACK (SCM_UNPACK (SCM_CAR (x)) | (y)))) | |
116 | #define SCM_SETAND_CDR(x, y)\ | |
117 | (SCM_SETCDR ((x), SCM_PACK (SCM_UNPACK (SCM_CDR (x)) & (y)))) | |
118 | #define SCM_SETOR_CDR(x, y)\ | |
119 | (SCM_SETCDR ((x), SCM_PACK (SCM_UNPACK (SCM_CDR (x)) | (y)))) | |
120 | #define SCM_FREEP(x) (SCM_FREE_CELL_P (x)) | |
121 | #define SCM_NFREEP(x) (!SCM_FREE_CELL_P (x)) | |
7aaf8dc9 MD |
122 | #define SCM_GC8MARKP(x) SCM_GC_MARK_P (x) |
123 | #define SCM_SETGC8MARK(x) SCM_SET_GC_MARK (x) | |
124 | #define SCM_CLRGC8MARK(x) SCM_CLEAR_GC_MARK (x) | |
a0454d72 MV |
125 | #define SCM_GCTYP16(x) SCM_TYP16 (x) |
126 | #define SCM_GCCDR(x) SCM_CDR (x) | |
127 | SCM_API void scm_remember (SCM * ptr); | |
128 | ||
129 | SCM_API SCM scm_the_root_module (void); | |
130 | SCM_API SCM scm_make_module (SCM name); | |
131 | SCM_API SCM scm_ensure_user_module (SCM name); | |
132 | SCM_API SCM scm_load_scheme_module (SCM name); | |
133 | ||
134 | #define scm_port scm_t_port | |
135 | #define scm_ptob_descriptor scm_t_ptob_descriptor | |
136 | #define scm_port_rw_active scm_t_port_rw_active | |
137 | ||
138 | SCM_API SCM scm_close_all_ports_except (SCM ports); | |
139 | ||
97f28fa4 MV |
140 | #define scm_rstate scm_t_rstate |
141 | #define scm_rng scm_t_rng | |
142 | ||
143 | #define SCM_SLOPPY_CONSP(x) ((1 & SCM_CELL_TYPE (x)) == 0) | |
144 | #define SCM_SLOPPY_NCONSP(x) (!SCM_SLOPPY_CONSP(x)) | |
145 | ||
146 | #define scm_tc7_ssymbol scm_tc7_symbol | |
147 | #define scm_tc7_msymbol scm_tc7_symbol | |
148 | #define scm_tcs_symbols scm_tc7_symbol | |
149 | ||
965445d4 MV |
150 | SCM_API SCM scm_makstr (size_t len, int); |
151 | SCM_API SCM scm_makfromstr (const char *src, size_t len, int); | |
152 | ||
153 | SCM_API SCM scm_variable_set_name_hint (SCM var, SCM hint); | |
154 | SCM_API SCM scm_builtin_variable (SCM name); | |
155 | ||
156 | SCM_API SCM scm_internal_with_fluids (SCM fluids, SCM vals, | |
157 | SCM (*cproc)(void *), void *cdata); | |
158 | ||
159 | SCM_API SCM scm_make_gsubr (const char *name, int req, int opt, int rst, | |
160 | SCM (*fcn)()); | |
161 | SCM_API SCM scm_make_gsubr_with_generic (const char *name, | |
162 | int req, | |
163 | int opt, | |
164 | int rst, | |
165 | SCM (*fcn)(), | |
166 | SCM *gf); | |
167 | ||
23d72566 | 168 | SCM_API SCM scm_create_hook (const char* name, int n_args); |
965445d4 MV |
169 | |
170 | #define SCM_LIST0 SCM_EOL | |
171 | #define SCM_LIST1(e0) scm_cons ((e0), SCM_EOL) | |
172 | #define SCM_LIST2(e0, e1) scm_cons2 ((e0), (e1), SCM_EOL) | |
173 | #define SCM_LIST3(e0, e1, e2) scm_cons ((e0), SCM_LIST2 ((e1), (e2))) | |
174 | #define SCM_LIST4(e0, e1, e2, e3)\ | |
175 | scm_cons2 ((e0), (e1), SCM_LIST2 ((e2), (e3))) | |
176 | #define SCM_LIST5(e0, e1, e2, e3, e4)\ | |
177 | scm_cons ((e0), SCM_LIST4 ((e1), (e2), (e3), (e4))) | |
178 | #define SCM_LIST6(e0, e1, e2, e3, e4, e5)\ | |
179 | scm_cons2 ((e0), (e1), SCM_LIST4 ((e2), (e3), (e4), (e5))) | |
180 | #define SCM_LIST7(e0, e1, e2, e3, e4, e5, e6)\ | |
181 | scm_cons ((e0), SCM_LIST6 ((e1), (e2), (e3), (e4), (e5), (e6))) | |
182 | #define SCM_LIST8(e0, e1, e2, e3, e4, e5, e6, e7)\ | |
183 | scm_cons2 ((e0), (e1), SCM_LIST6 ((e2), (e3), (e4), (e5), (e6), (e7))) | |
184 | #define SCM_LIST9(e0, e1, e2, e3, e4, e5, e6, e7, e8)\ | |
185 | scm_cons ((e0),\ | |
186 | SCM_LIST8 ((e1), (e2), (e3), (e4), (e5), (e6), (e7), (e8))) | |
187 | ||
188 | #define scm_listify scm_list_n | |
189 | ||
190 | SCM_API SCM scm_sloppy_memq (SCM x, SCM lst); | |
191 | SCM_API SCM scm_sloppy_memv (SCM x, SCM lst); | |
192 | SCM_API SCM scm_sloppy_member (SCM x, SCM lst); | |
193 | ||
194 | SCM_API SCM scm_read_and_eval_x (SCM port); | |
195 | ||
4abecea8 MV |
196 | #define scm_subr_entry scm_t_subr_entry |
197 | ||
198 | #define SCM_SUBR_DOC(x) SCM_BOOL_F | |
199 | ||
200 | SCM_API SCM scm_make_subr (const char *name, int type, SCM (*fcn) ()); | |
201 | SCM_API SCM scm_make_subr_with_generic (const char *name, | |
202 | int type, | |
203 | SCM (*fcn) (), | |
204 | SCM *gf); | |
205 | SCM_API SCM scm_make_subr_opt (const char *name, | |
206 | int type, | |
207 | SCM (*fcn) (), | |
208 | int set); | |
209 | ||
210 | SCM_API SCM scm_call_catching_errors (SCM (*thunk)(), SCM (*err_filter)(), | |
211 | void * closure); | |
212 | ||
213 | SCM_API long scm_make_smob_type_mfpe (char *name, size_t size, | |
214 | SCM (*mark) (SCM), | |
215 | size_t (*free) (SCM), | |
216 | int (*print) (SCM, SCM, | |
217 | scm_print_state*), | |
218 | SCM (*equalp) (SCM, SCM)); | |
219 | ||
220 | SCM_API void scm_set_smob_mfpe (long tc, | |
221 | SCM (*mark) (SCM), | |
222 | size_t (*free) (SCM), | |
223 | int (*print) (SCM, SCM, scm_print_state*), | |
224 | SCM (*equalp) (SCM, SCM)); | |
225 | ||
226 | SCM_API SCM scm_strprint_obj (SCM obj); | |
227 | SCM_API SCM scm_read_0str (char *expr); | |
228 | SCM_API SCM scm_eval_0str (const char *expr); | |
229 | ||
a725fa95 MV |
230 | SCM_API char *scm_i_object_chars (SCM); |
231 | ||
232 | #define SCM_CHARS(x) scm_i_object_chars(x) | |
233 | #define SCM_UCHARS(x) ((unsigned char *)SCM_CHARS(x)) | |
234 | ||
235 | SCM_API long scm_i_object_length (SCM); | |
236 | ||
237 | #define SCM_LENGTH(x) scm_i_object_length(x) | |
238 | ||
cc5c1b66 MV |
239 | #define scm_strhash(str, len, n) (scm_string_hash ((str), (len)) % (n)) |
240 | ||
241 | SCM_API SCM scm_sym2ovcell_soft (SCM sym, SCM obarray); | |
242 | SCM_API SCM scm_sym2ovcell (SCM sym, SCM obarray); | |
243 | SCM_API SCM scm_intern_obarray_soft (const char *name, size_t len, | |
244 | SCM obarray, unsigned int softness); | |
245 | SCM_API SCM scm_intern_obarray (const char *name, size_t len, SCM obarray); | |
246 | SCM_API SCM scm_symbol_value0 (const char *name); | |
247 | ||
248 | SCM_API SCM scm_string_to_obarray_symbol (SCM o, SCM s, SCM softp); | |
249 | SCM_API SCM scm_intern_symbol (SCM o, SCM s); | |
250 | SCM_API SCM scm_unintern_symbol (SCM o, SCM s); | |
251 | SCM_API SCM scm_symbol_binding (SCM o, SCM s); | |
252 | #if 0 | |
253 | /* This name has been reused for real uninterned symbols. */ | |
254 | SCM_API SCM scm_symbol_interned_p (SCM o, SCM s); | |
255 | #endif | |
256 | SCM_API SCM scm_symbol_bound_p (SCM o, SCM s); | |
257 | SCM_API SCM scm_symbol_set_x (SCM o, SCM s, SCM v); | |
258 | ||
259 | SCM_API SCM scm_gentemp (SCM prefix, SCM obarray); | |
260 | ||
8de7acbd MV |
261 | #define SCM_OPDIRP(x) (SCM_DIRP (x) && (SCM_DIR_OPEN_P (x))) |
262 | #define scm_fport scm_t_fport | |
263 | #define scm_option scm_t_option | |
264 | #define scm_srcprops scm_t_srcprops | |
265 | #define scm_srcprops_chunk scm_t_srcprops_chunk | |
266 | #define scm_info_frame scm_t_info_frame | |
267 | #define scm_stack scm_t_stack | |
268 | #define scm_array scm_t_array | |
269 | #define scm_array_dim scm_t_array_dim | |
270 | #define SCM_ARRAY_CONTIGUOUS SCM_ARRAY_FLAG_CONTIGUOUS | |
271 | #define SCM_FUNC_NAME (scm_makfrom0str (FUNC_NAME)) | |
272 | ||
273 | #define SCM_WTA(pos, scm) \ | |
274 | do { scm_wta (scm, (char *) pos, FUNC_NAME); } while (0) | |
275 | ||
276 | #define RETURN_SCM_WTA(pos, scm) \ | |
277 | do { return scm_wta (scm, (char *) pos, FUNC_NAME); } while (0) | |
278 | ||
279 | #define SCM_VALIDATE_NUMBER_COPY(pos, z, cvar) \ | |
280 | do { \ | |
3aa13a05 MV |
281 | if (SCM_I_INUMP (z)) \ |
282 | cvar = (double) SCM_I_INUM (z); \ | |
8de7acbd MV |
283 | else if (SCM_REALP (z)) \ |
284 | cvar = SCM_REAL_VALUE (z); \ | |
285 | else if (SCM_BIGP (z)) \ | |
286 | cvar = scm_i_big2dbl (z); \ | |
287 | else \ | |
288 | { \ | |
289 | cvar = 0.0; \ | |
290 | SCM_WRONG_TYPE_ARG (pos, z); \ | |
291 | } \ | |
292 | } while (0) | |
293 | ||
294 | #define SCM_VALIDATE_NUMBER_DEF_COPY(pos, number, def, cvar) \ | |
295 | do { \ | |
296 | if (SCM_UNBNDP (number)) \ | |
297 | cvar = def; \ | |
298 | else \ | |
299 | SCM_VALIDATE_NUMBER_COPY(pos, number, cvar); \ | |
300 | } while (0) | |
301 | ||
302 | #define SCM_VALIDATE_OPDIR(pos, port) SCM_MAKE_VALIDATE (pos, port, OPDIRP) | |
303 | ||
41a2f6fc MV |
304 | /* Deprecated because we can not safely cast a SCM* to a scm_t_bits* |
305 | */ | |
306 | ||
307 | #define SCM_CELL_WORD_LOC(x, n) ((scm_t_bits*)SCM_CELL_OBJECT_LOC((x),(n))) | |
308 | ||
8805b77d MV |
309 | /* Users shouldn't know about INUMs. |
310 | */ | |
311 | ||
fe78c51a MV |
312 | SCM_API SCM scm_i_makinum (scm_t_signed_bits val); |
313 | SCM_API int scm_i_inump (SCM obj); | |
314 | SCM_API scm_t_signed_bits scm_i_inum (SCM obj); | |
315 | ||
316 | #define SCM_MAKINUM(x) scm_i_makinum(x) | |
317 | #define SCM_INUM(x) scm_i_inum(x) | |
318 | #define SCM_INUMP(x) scm_i_inump(x) | |
319 | #define SCM_NINUMP(x) (!SCM_INUMP(x)) | |
3aa13a05 | 320 | |
8805b77d MV |
321 | #define SCM_VALIDATE_INUM(pos, k) SCM_MAKE_VALIDATE_MSG (pos, k, INUMP, "exact integer") |
322 | ||
323 | #define SCM_VALIDATE_INUM_COPY(pos, k, cvar) \ | |
324 | do { \ | |
3aa13a05 MV |
325 | SCM_ASSERT (SCM_I_INUMP (k), k, pos, FUNC_NAME); \ |
326 | cvar = SCM_I_INUM (k); \ | |
8805b77d MV |
327 | } while (0) |
328 | ||
329 | #define SCM_VALIDATE_BIGINT(pos, k) SCM_MAKE_VALIDATE_MSG (pos, k, BIGP, "bignum") | |
330 | ||
331 | #define SCM_VALIDATE_INUM_MIN(pos, k, min) \ | |
332 | do { \ | |
3aa13a05 MV |
333 | SCM_ASSERT (SCM_I_INUMP(k), k, pos, FUNC_NAME); \ |
334 | SCM_ASSERT_RANGE (pos, k, (SCM_I_INUM (k) >= min)); \ | |
8805b77d MV |
335 | } while (0) |
336 | ||
337 | #define SCM_VALIDATE_INUM_MIN_COPY(pos, k, min, cvar) \ | |
338 | do { \ | |
3aa13a05 MV |
339 | SCM_ASSERT (SCM_I_INUMP (k), k, pos, FUNC_NAME); \ |
340 | SCM_ASSERT_RANGE (pos, k, (SCM_I_INUM (k) >= min)); \ | |
8805b77d MV |
341 | cvar = SCM_INUM (k); \ |
342 | } while (0) | |
343 | ||
344 | #define SCM_VALIDATE_INUM_MIN_DEF_COPY(pos, k, min, default, cvar) \ | |
345 | do { \ | |
346 | if (SCM_UNBNDP (k)) \ | |
347 | k = SCM_I_MAKINUM (default); \ | |
3aa13a05 MV |
348 | SCM_ASSERT (SCM_I_INUMP (k), k, pos, FUNC_NAME); \ |
349 | SCM_ASSERT_RANGE (pos, k, (SCM_I_INUM (k) >= min)); \ | |
8805b77d MV |
350 | cvar = SCM_INUM (k); \ |
351 | } while (0) | |
352 | ||
353 | #define SCM_VALIDATE_INUM_DEF(pos, k, default) \ | |
354 | do { \ | |
355 | if (SCM_UNBNDP (k)) \ | |
356 | k = SCM_I_MAKINUM (default); \ | |
3aa13a05 | 357 | else SCM_ASSERT (SCM_I_INUMP (k), k, pos, FUNC_NAME); \ |
8805b77d MV |
358 | } while (0) |
359 | ||
360 | #define SCM_VALIDATE_INUM_DEF_COPY(pos, k, default, cvar) \ | |
361 | do { \ | |
362 | if (SCM_UNBNDP (k)) \ | |
363 | { \ | |
364 | k = SCM_I_MAKINUM (default); \ | |
365 | cvar = default; \ | |
366 | } \ | |
367 | else \ | |
368 | { \ | |
3aa13a05 | 369 | SCM_ASSERT (SCM_I_INUMP (k), k, pos, FUNC_NAME); \ |
8805b77d MV |
370 | cvar = SCM_INUM (k); \ |
371 | } \ | |
372 | } while (0) | |
373 | ||
374 | /* [low, high) */ | |
375 | #define SCM_VALIDATE_INUM_RANGE(pos, k, low, high) \ | |
3aa13a05 | 376 | do { SCM_ASSERT(SCM_I_INUMP(k), k, pos, FUNC_NAME); \ |
8805b77d | 377 | SCM_ASSERT_RANGE(pos, k, \ |
3aa13a05 MV |
378 | (SCM_I_INUM (k) >= low && \ |
379 | SCM_I_INUM (k) < high)); \ | |
8805b77d MV |
380 | } while (0) |
381 | ||
382 | #define SCM_VALIDATE_INUM_RANGE_COPY(pos, k, low, high, cvar) \ | |
383 | do { \ | |
384 | SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \ | |
385 | SCM_ASSERT_RANGE (pos, k, low <= SCM_INUM (k) && SCM_INUM (k) < high); \ | |
386 | cvar = SCM_INUM (k); \ | |
387 | } while (0) | |
388 | ||
c829a427 MV |
389 | #define SCM_STRING_COERCE_0TERMINATION_X(x) (x) |
390 | ||
391 | /* XXX - buggy interface, STR might not be large enough. | |
392 | ||
393 | Converts the given Scheme string OBJ into a C string, containing a copy | |
394 | of OBJ's content with a trailing null byte. If LENP is non-NULL, set | |
395 | *LENP to the string's length. | |
396 | ||
397 | When STR is non-NULL it receives the copy and is returned by the function, | |
398 | otherwise new memory is allocated and the caller is responsible for | |
399 | freeing it via free(). If out of memory, NULL is returned. | |
400 | ||
401 | Note that Scheme strings may contain arbitrary data, including null | |
402 | characters. This means that null termination is not a reliable way to | |
403 | determine the length of the returned value. However, the function always | |
404 | copies the complete contents of OBJ, and sets *LENP to the length of the | |
405 | scheme string (if LENP is non-null). | |
406 | */ | |
407 | SCM_API char *scm_c_string2str (SCM obj, char *str, size_t *lenp); | |
408 | ||
409 | /* XXX - buggy interface, you don't know how many bytes have been copied. | |
410 | ||
411 | Copy LEN characters at START from the Scheme string OBJ to memory | |
412 | at STR. START is an index into OBJ; zero means the beginning of | |
413 | the string. STR has already been allocated by the caller. | |
414 | ||
415 | If START + LEN is off the end of OBJ, silently truncate the source | |
416 | region to fit the string. If truncation occurs, the corresponding | |
417 | area of STR is left unchanged. | |
418 | */ | |
419 | SCM_API char *scm_c_substring2str (SCM obj, char *str, size_t start, size_t len); | |
8805b77d | 420 | |
3ee86942 MV |
421 | SCM_API char *scm_c_symbol2str (SCM obj, char *str, size_t *lenp); |
422 | ||
3101f40f MV |
423 | /* Deprecated because the names belong to what is now |
424 | scm_truncate_number and scm_round_number. | |
425 | */ | |
426 | SCM_API double scm_truncate (double x); | |
427 | SCM_API double scm_round (double x); | |
428 | ||
6f14f578 MV |
429 | /* Deprecated because we don't want people to access the internal |
430 | representation of strings directly. | |
431 | */ | |
432 | ||
433 | #define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \ | |
434 | do { \ | |
435 | SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \ | |
436 | cvar = SCM_STRING_CHARS(str); \ | |
437 | } while (0) | |
438 | ||
439 | /* validate a string and optional start/end arguments which default to | |
440 | 0/string-len. this is unrelated to the old shared substring | |
441 | support, so please do not deprecate it :) */ | |
442 | #define SCM_VALIDATE_SUBSTRING_SPEC_COPY(pos_str, str, c_str, \ | |
443 | pos_start, start, c_start,\ | |
444 | pos_end, end, c_end) \ | |
445 | do {\ | |
446 | SCM_VALIDATE_STRING_COPY (pos_str, str, c_str);\ | |
447 | c_start = SCM_UNBNDP(start)? 0 : scm_to_size_t (start);\ | |
448 | c_end = SCM_UNBNDP(end)? SCM_STRING_LENGTH(str) : scm_to_size_t (end);\ | |
449 | SCM_ASSERT_RANGE (pos_start, start,\ | |
450 | 0 <= c_start \ | |
451 | && (size_t) c_start <= SCM_STRING_LENGTH (str));\ | |
452 | SCM_ASSERT_RANGE (pos_end, end,\ | |
453 | c_start <= c_end \ | |
454 | && (size_t) c_end <= SCM_STRING_LENGTH (str));\ | |
455 | } while (0) | |
456 | ||
3ee86942 MV |
457 | /* Deprecated because we don't want people to access the internals of |
458 | symbols directly. | |
459 | */ | |
460 | ||
fe78c51a MV |
461 | SCM_API char *scm_i_deprecated_symbol_chars (SCM sym); |
462 | SCM_API size_t scm_i_deprecated_symbol_length (SCM sym); | |
463 | ||
464 | #define SCM_SYMBOL_CHARS(x) scm_i_deprecated_symbol_chars(x) | |
465 | #define SCM_SYMBOL_LENGTH(x) scm_i_deprecated_symbol_length(x) | |
6f14f578 | 466 | |
265a7997 MV |
467 | /* Deprecated because the macros used to evaluate the arguments more |
468 | than once and because the symbol of a keyword now has no dash. | |
469 | */ | |
470 | ||
fe78c51a MV |
471 | SCM_API int scm_i_keywordp (SCM obj); |
472 | SCM_API SCM scm_i_keywordsym (SCM keyword); | |
473 | ||
474 | #define SCM_KEYWORDP(x) scm_i_keywordp(x) | |
475 | #define SCM_KEYWORDSYM(x) scm_i_keywordsym(x) | |
265a7997 | 476 | |
354116f7 MV |
477 | /* Deprecated because we don't want to hand out unprotected pointers |
478 | to arrays, vectors, etc. */ | |
479 | ||
480 | #define SCM_VECTOR_MAX_LENGTH ((1L << 24) - 1) | |
481 | ||
fe78c51a MV |
482 | SCM_API int scm_i_vectorp (SCM x); |
483 | SCM_API unsigned long scm_i_vector_length (SCM x); | |
484 | SCM_API const SCM *scm_i_velts (SCM x); | |
485 | SCM_API SCM *scm_i_writable_velts (SCM x); | |
486 | SCM_API SCM scm_i_vector_ref (SCM x, size_t idx); | |
487 | SCM_API void scm_i_vector_set (SCM x, size_t idx, SCM val); | |
354116f7 | 488 | SCM_API SCM scm_vector_equal_p (SCM x, SCM y); |
265a7997 | 489 | |
fe78c51a MV |
490 | #define SCM_VECTORP(x) scm_i_vectorp(x) |
491 | #define SCM_VECTOR_LENGTH(x) scm_i_vector_length(x) | |
492 | #define SCM_VELTS(x) scm_i_velts(x) | |
493 | #define SCM_WRITABLE_VELTS(x) scm_i_writable_velts(x) | |
494 | #define SCM_VECTOR_REF(x,y) scm_i_vector_ref(x,y) | |
495 | #define SCM_VECTOR_SET(x,y,z) scm_i_vector_set(x,y,z) | |
1f366ef7 | 496 | |
fe78c51a | 497 | typedef scm_i_t_array scm_t_array; |
1f366ef7 | 498 | |
fe78c51a MV |
499 | SCM_API int scm_i_arrayp (SCM a); |
500 | SCM_API size_t scm_i_array_ndim (SCM a); | |
501 | SCM_API int scm_i_array_contp (SCM a); | |
502 | SCM_API scm_t_array *scm_i_array_mem (SCM a); | |
503 | SCM_API SCM scm_i_array_v (SCM a); | |
504 | SCM_API size_t scm_i_array_base (SCM a); | |
505 | SCM_API scm_t_array_dim *scm_i_array_dims (SCM a); | |
506 | ||
507 | #define SCM_ARRAYP(a) scm_i_arrayp(a) | |
508 | #define SCM_ARRAY_NDIM(a) scm_i_array_ndim(a) | |
509 | #define SCM_ARRAY_CONTP(a) scm_i_array_contp(a) | |
510 | #define SCM_ARRAY_MEM(a) scm_i_array_mem(a) | |
511 | #define SCM_ARRAY_V(a) scm_i_array_v(a) | |
512 | #define SCM_ARRAY_BASE(a) scm_i_array_base(a) | |
9cc49060 | 513 | #define SCM_ARRAY_DIMS(a) scm_i_array_dims(a) |
1f366ef7 | 514 | |
9de87eea MV |
515 | /* Deprecated because they should not be lvalues and we want people to |
516 | use the official interfaces. | |
517 | */ | |
518 | ||
519 | #define scm_cur_inp scm_i_cur_inp () | |
520 | #define scm_cur_outp scm_i_cur_outp () | |
521 | #define scm_cur_errp scm_i_cur_errp () | |
522 | #define scm_cur_loadp scm_i_cur_loadp () | |
523 | #define scm_progargs scm_i_progargs () | |
524 | #define scm_dynwinds scm_i_deprecated_dynwinds () | |
525 | #define scm_last_debug_frame scm_i_deprecated_last_debug_frame () | |
526 | #define scm_stack_base scm_i_stack_base () | |
527 | ||
528 | SCM_API SCM scm_i_cur_inp (void); | |
529 | SCM_API SCM scm_i_cur_outp (void); | |
530 | SCM_API SCM scm_i_cur_errp (void); | |
531 | SCM_API SCM scm_i_cur_loadp (void); | |
532 | SCM_API SCM scm_i_progargs (void); | |
533 | SCM_API SCM scm_i_deprecated_dynwinds (void); | |
534 | SCM_API scm_t_debug_frame *scm_i_deprecated_last_debug_frame (void); | |
535 | SCM_API SCM_STACKITEM *scm_i_stack_base (void); | |
536 | ||
537 | /* Deprecated because it evaluates its argument twice. | |
538 | */ | |
539 | #define SCM_FLUIDP(x) scm_i_fluidp (x) | |
540 | SCM_API int scm_i_fluidp (SCM x); | |
541 | ||
06c1d900 MV |
542 | /* In the old days, SCM_CRITICAL_SECTION_START stopped signal handlers |
543 | from running, since in those days the handler directly ran scheme | |
544 | code, and that had to be avoided when the heap was not in a | |
545 | consistent state etc. And since the scheme code could do a stack | |
546 | swapping new continuation etc, signals had to be deferred around | |
547 | various C library functions which were not safe or not known to be | |
548 | safe to swap away, which was a lot of stuff. | |
549 | ||
550 | These days signals are implemented with asyncs and don't directly | |
551 | run scheme code in the handler, but hold it until an SCM_TICK etc | |
552 | where it will be safe. This means interrupt protection is not | |
553 | needed and SCM_CRITICAL_SECTION_START / SCM_CRITICAL_SECTION_END is | |
554 | something of an anachronism. | |
555 | ||
556 | What past SCM_CRITICAL_SECTION_START usage also did though was | |
557 | indicate code that was not reentrant, ie. could not be reentered by | |
558 | signal handler code. The present definitions are a mutex lock, | |
559 | affording that reentrancy protection against the new guile 1.8 | |
560 | free-running posix threads. | |
9de87eea MV |
561 | |
562 | One big problem with the present defintions though is that code which | |
563 | throws an error from within a DEFER/ALLOW region will leave the | |
564 | defer_mutex locked and hence hang other threads that attempt to enter a | |
565 | similar DEFER/ALLOW region. | |
566 | */ | |
567 | ||
568 | SCM_API void scm_i_defer_ints_etc (void); | |
569 | #define SCM_DEFER_INTS scm_i_defer_ints_etc () | |
570 | #define SCM_ALLOW_INTS scm_i_defer_ints_etc () | |
571 | #define SCM_REDEFER_INTS scm_i_defer_ints_etc () | |
572 | #define SCM_REALLOW_INTS scm_i_defer_ints_etc () | |
573 | ||
06c1d900 MV |
574 | /* Deprecated since they are unnecessary and had not been documented. |
575 | */ | |
576 | SCM_API SCM scm_guard (SCM guardian, SCM obj, int throw_p); | |
577 | SCM_API SCM scm_get_one_zombie (SCM guardian); | |
578 | ||
579 | /* Deprecated since guardians no longer have these special features. | |
580 | */ | |
581 | SCM_API SCM scm_destroy_guardian_x (SCM guardian); | |
582 | SCM_API SCM scm_guardian_greedy_p (SCM guardian); | |
583 | SCM_API SCM scm_guardian_destroyed_p (SCM guardian); | |
584 | ||
55d30fac | 585 | void scm_i_init_deprecated (void); |
19e2247d | 586 | |
55d30fac | 587 | #endif |
19e2247d | 588 | |
55d30fac | 589 | #endif /* SCM_DEPRECATED_H */ |