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 | ||
118ff892 | 5 | /* Copyright (C) 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. |
19e2247d | 6 | * |
73be1d9e | 7 | * This library is free software; you can redistribute it and/or |
53befeb7 NJ |
8 | * modify it under the terms of the GNU Lesser General Public License |
9 | * as published by the Free Software Foundation; either version 3 of | |
10 | * the License, or (at your option) any later version. | |
19e2247d | 11 | * |
53befeb7 NJ |
12 | * This library is distributed in the hope that it will be useful, but |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
73be1d9e MV |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Lesser General Public License for more details. | |
19e2247d | 16 | * |
73be1d9e MV |
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 | |
53befeb7 NJ |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
20 | * 02110-1301 USA | |
73be1d9e | 21 | */ |
19e2247d | 22 | |
dbb605f5 LC |
23 | #ifdef HAVE_CONFIG_H |
24 | # include <config.h> | |
25 | #endif | |
26 | ||
0eb934f1 LC |
27 | #define SCM_BUILDING_DEPRECATED_CODE |
28 | ||
19e2247d | 29 | #include "libguile/_scm.h" |
4e047c3e | 30 | #include "libguile/async.h" |
a2689737 AW |
31 | #include "libguile/arrays.h" |
32 | #include "libguile/array-map.h" | |
33 | #include "libguile/generalized-arrays.h" | |
34 | #include "libguile/bytevectors.h" | |
35 | #include "libguile/bitvectors.h" | |
19e2247d | 36 | #include "libguile/deprecated.h" |
55d30fac | 37 | #include "libguile/deprecation.h" |
19e2247d MV |
38 | #include "libguile/snarf.h" |
39 | #include "libguile/validate.h" | |
40 | #include "libguile/strings.h" | |
c44ca4fe | 41 | #include "libguile/srfi-13.h" |
a0454d72 MV |
42 | #include "libguile/modules.h" |
43 | #include "libguile/eval.h" | |
44 | #include "libguile/smob.h" | |
45 | #include "libguile/procprop.h" | |
46 | #include "libguile/vectors.h" | |
47 | #include "libguile/hashtab.h" | |
48 | #include "libguile/struct.h" | |
49 | #include "libguile/variable.h" | |
50 | #include "libguile/fluids.h" | |
51 | #include "libguile/ports.h" | |
965445d4 MV |
52 | #include "libguile/eq.h" |
53 | #include "libguile/read.h" | |
a2689737 | 54 | #include "libguile/r6rs-ports.h" |
4abecea8 MV |
55 | #include "libguile/strports.h" |
56 | #include "libguile/smob.h" | |
cc5c1b66 | 57 | #include "libguile/alist.h" |
db74ed03 | 58 | #include "libguile/keywords.h" |
3452e666 | 59 | #include "libguile/socket.h" |
9de87eea | 60 | #include "libguile/feature.h" |
a2689737 | 61 | #include "libguile/uniform.h" |
19e2247d | 62 | |
ad79736c | 63 | #include <math.h> |
55d30fac MV |
64 | #include <stdio.h> |
65 | #include <string.h> | |
66 | ||
3452e666 LC |
67 | #include <arpa/inet.h> |
68 | ||
19e2247d MV |
69 | #if (SCM_ENABLE_DEPRECATED == 1) |
70 | ||
7e6e6b37 DH |
71 | /* From print.c: Internal symbol names of isyms. Deprecated in guile 1.7.0 on |
72 | * 2004-04-22. */ | |
73 | char *scm_isymnames[] = | |
74 | { | |
75 | "#@<deprecated>" | |
76 | }; | |
77 | ||
78 | ||
19e2247d MV |
79 | SCM_REGISTER_PROC(s_substring_move_left_x, "substring-move-left!", 5, 0, 0, scm_substring_move_x); |
80 | ||
81 | SCM_REGISTER_PROC(s_substring_move_right_x, "substring-move-right!", 5, 0, 0, scm_substring_move_x); | |
82 | ||
55d30fac MV |
83 | SCM |
84 | scm_wta (SCM arg, const char *pos, const char *s_subr) | |
85 | { | |
86 | if (!s_subr || !*s_subr) | |
87 | s_subr = NULL; | |
88 | if ((~0x1fL) & (long) pos) | |
89 | { | |
90 | /* error string supplied. */ | |
91 | scm_misc_error (s_subr, pos, scm_list_1 (arg)); | |
92 | } | |
93 | else | |
94 | { | |
95 | /* numerical error code. */ | |
96 | scm_t_bits error = (scm_t_bits) pos; | |
97 | ||
98 | switch (error) | |
99 | { | |
100 | case SCM_ARGn: | |
101 | scm_wrong_type_arg (s_subr, 0, arg); | |
102 | case SCM_ARG1: | |
103 | scm_wrong_type_arg (s_subr, 1, arg); | |
104 | case SCM_ARG2: | |
105 | scm_wrong_type_arg (s_subr, 2, arg); | |
106 | case SCM_ARG3: | |
107 | scm_wrong_type_arg (s_subr, 3, arg); | |
108 | case SCM_ARG4: | |
109 | scm_wrong_type_arg (s_subr, 4, arg); | |
110 | case SCM_ARG5: | |
111 | scm_wrong_type_arg (s_subr, 5, arg); | |
112 | case SCM_ARG6: | |
113 | scm_wrong_type_arg (s_subr, 6, arg); | |
114 | case SCM_ARG7: | |
115 | scm_wrong_type_arg (s_subr, 7, arg); | |
116 | case SCM_WNA: | |
117 | scm_wrong_num_args (arg); | |
118 | case SCM_OUTOFRANGE: | |
119 | scm_out_of_range (s_subr, arg); | |
120 | case SCM_NALLOC: | |
121 | scm_memory_error (s_subr); | |
122 | default: | |
123 | /* this shouldn't happen. */ | |
124 | scm_misc_error (s_subr, "Unknown error", SCM_EOL); | |
125 | } | |
126 | } | |
127 | return SCM_UNSPECIFIED; | |
128 | } | |
129 | ||
130 | /* Module registry | |
131 | */ | |
132 | ||
133 | /* We can't use SCM objects here. One should be able to call | |
134 | SCM_REGISTER_MODULE from a C++ constructor for a static | |
135 | object. This happens before main and thus before libguile is | |
136 | initialized. */ | |
137 | ||
138 | struct moddata { | |
139 | struct moddata *link; | |
140 | char *module_name; | |
141 | void *init_func; | |
142 | }; | |
143 | ||
144 | static struct moddata *registered_mods = NULL; | |
145 | ||
146 | void | |
147 | scm_register_module_xxx (char *module_name, void *init_func) | |
148 | { | |
149 | struct moddata *md; | |
150 | ||
151 | scm_c_issue_deprecation_warning | |
152 | ("`scm_register_module_xxx' is deprecated. Use extensions instead."); | |
153 | ||
154 | /* XXX - should we (and can we) DEFER_INTS here? */ | |
155 | ||
156 | for (md = registered_mods; md; md = md->link) | |
157 | if (!strcmp (md->module_name, module_name)) | |
158 | { | |
159 | md->init_func = init_func; | |
160 | return; | |
161 | } | |
162 | ||
163 | md = (struct moddata *) malloc (sizeof (struct moddata)); | |
164 | if (md == NULL) | |
165 | { | |
166 | fprintf (stderr, | |
167 | "guile: can't register module (%s): not enough memory", | |
168 | module_name); | |
169 | return; | |
170 | } | |
171 | ||
172 | md->module_name = module_name; | |
173 | md->init_func = init_func; | |
174 | md->link = registered_mods; | |
175 | registered_mods = md; | |
176 | } | |
177 | ||
178 | SCM_DEFINE (scm_registered_modules, "c-registered-modules", 0, 0, 0, | |
179 | (), | |
180 | "Return a list of the object code modules that have been imported into\n" | |
181 | "the current Guile process. Each element of the list is a pair whose\n" | |
182 | "car is the name of the module, and whose cdr is the function handle\n" | |
183 | "for that module's initializer function. The name is the string that\n" | |
184 | "has been passed to scm_register_module_xxx.") | |
185 | #define FUNC_NAME s_scm_registered_modules | |
186 | { | |
187 | SCM res; | |
188 | struct moddata *md; | |
189 | ||
190 | res = SCM_EOL; | |
191 | for (md = registered_mods; md; md = md->link) | |
3ee86942 | 192 | res = scm_cons (scm_cons (scm_from_locale_string (md->module_name), |
c71b0706 | 193 | scm_from_ulong ((unsigned long) md->init_func)), |
55d30fac MV |
194 | res); |
195 | return res; | |
196 | } | |
197 | #undef FUNC_NAME | |
198 | ||
199 | SCM_DEFINE (scm_clear_registered_modules, "c-clear-registered-modules", 0, 0, 0, | |
200 | (), | |
201 | "Destroy the list of modules registered with the current Guile process.\n" | |
202 | "The return value is unspecified. @strong{Warning:} this function does\n" | |
203 | "not actually unlink or deallocate these modules, but only destroys the\n" | |
204 | "records of which modules have been loaded. It should therefore be used\n" | |
205 | "only by module bookkeeping operations.") | |
206 | #define FUNC_NAME s_scm_clear_registered_modules | |
207 | { | |
208 | struct moddata *md1, *md2; | |
209 | ||
9de87eea | 210 | SCM_CRITICAL_SECTION_START; |
55d30fac MV |
211 | |
212 | for (md1 = registered_mods; md1; md1 = md2) | |
213 | { | |
214 | md2 = md1->link; | |
215 | free (md1); | |
216 | } | |
217 | registered_mods = NULL; | |
218 | ||
9de87eea | 219 | SCM_CRITICAL_SECTION_END; |
55d30fac MV |
220 | return SCM_UNSPECIFIED; |
221 | } | |
222 | #undef FUNC_NAME | |
223 | ||
a0454d72 MV |
224 | void |
225 | scm_remember (SCM *ptr) | |
226 | { | |
227 | scm_c_issue_deprecation_warning ("`scm_remember' is deprecated. " | |
228 | "Use the `scm_remember_upto_here*' family of functions instead."); | |
229 | } | |
230 | ||
231 | SCM | |
232 | scm_protect_object (SCM obj) | |
233 | { | |
234 | scm_c_issue_deprecation_warning ("`scm_protect_object' is deprecated. " | |
235 | "Use `scm_gc_protect_object' instead."); | |
236 | return scm_gc_protect_object (obj); | |
237 | } | |
238 | ||
239 | SCM | |
240 | scm_unprotect_object (SCM obj) | |
241 | { | |
242 | scm_c_issue_deprecation_warning ("`scm_unprotect_object' is deprecated. " | |
243 | "Use `scm_gc_unprotect_object' instead."); | |
244 | return scm_gc_unprotect_object (obj); | |
245 | } | |
246 | ||
247 | SCM_SYMBOL (scm_sym_app, "app"); | |
248 | SCM_SYMBOL (scm_sym_modules, "modules"); | |
249 | static SCM module_prefix = SCM_BOOL_F; | |
250 | static SCM make_modules_in_var; | |
251 | static SCM beautify_user_module_x_var; | |
252 | static SCM try_module_autoload_var; | |
253 | ||
254 | static void | |
255 | init_module_stuff () | |
256 | { | |
36722c63 | 257 | if (scm_is_false (module_prefix)) |
a0454d72 | 258 | { |
f39448c5 AW |
259 | module_prefix = scm_list_2 (scm_sym_app, scm_sym_modules); |
260 | make_modules_in_var = scm_c_lookup ("make-modules-in"); | |
a0454d72 | 261 | beautify_user_module_x_var = |
f39448c5 AW |
262 | scm_c_lookup ("beautify-user-module!"); |
263 | try_module_autoload_var = scm_c_lookup ("try-module-autoload"); | |
a0454d72 MV |
264 | } |
265 | } | |
266 | ||
a0454d72 MV |
267 | static SCM |
268 | scm_module_full_name (SCM name) | |
269 | { | |
270 | init_module_stuff (); | |
bc36d050 | 271 | if (scm_is_eq (SCM_CAR (name), scm_sym_app)) |
a0454d72 MV |
272 | return name; |
273 | else | |
274 | return scm_append (scm_list_2 (module_prefix, name)); | |
275 | } | |
276 | ||
277 | SCM | |
278 | scm_make_module (SCM name) | |
279 | { | |
280 | init_module_stuff (); | |
281 | scm_c_issue_deprecation_warning ("`scm_make_module' is deprecated. " | |
282 | "Use `scm_c_define_module instead."); | |
283 | ||
284 | return scm_call_2 (SCM_VARIABLE_REF (make_modules_in_var), | |
285 | scm_the_root_module (), | |
286 | scm_module_full_name (name)); | |
287 | } | |
288 | ||
289 | SCM | |
290 | scm_ensure_user_module (SCM module) | |
291 | { | |
292 | init_module_stuff (); | |
293 | scm_c_issue_deprecation_warning ("`scm_ensure_user_module' is deprecated. " | |
294 | "Use `scm_c_define_module instead."); | |
295 | ||
296 | scm_call_1 (SCM_VARIABLE_REF (beautify_user_module_x_var), module); | |
297 | return SCM_UNSPECIFIED; | |
298 | } | |
299 | ||
300 | SCM | |
301 | scm_load_scheme_module (SCM name) | |
302 | { | |
303 | init_module_stuff (); | |
304 | scm_c_issue_deprecation_warning ("`scm_load_scheme_module' is deprecated. " | |
305 | "Use `scm_c_resolve_module instead."); | |
306 | ||
307 | return scm_call_1 (SCM_VARIABLE_REF (try_module_autoload_var), name); | |
308 | } | |
309 | ||
310 | /* This is implemented in C solely for SCM_COERCE_OUTPORT ... */ | |
311 | ||
312 | static void | |
313 | maybe_close_port (void *data, SCM port) | |
314 | { | |
36722c63 | 315 | SCM except_set = PTR2SCM (data); |
a0454d72 | 316 | |
6eadcdab | 317 | while (!scm_is_null (except_set)) |
a0454d72 | 318 | { |
6eadcdab | 319 | SCM p = SCM_COERCE_OUTPORT (SCM_CAR (except_set)); |
bc36d050 | 320 | if (scm_is_eq (p, port)) |
a0454d72 | 321 | return; |
6eadcdab | 322 | except_set = SCM_CDR (except_set); |
a0454d72 MV |
323 | } |
324 | ||
325 | scm_close_port (port); | |
326 | } | |
327 | ||
328 | SCM_DEFINE (scm_close_all_ports_except, "close-all-ports-except", 0, 0, 1, | |
329 | (SCM ports), | |
330 | "[DEPRECATED] Close all open file ports used by the interpreter\n" | |
331 | "except for those supplied as arguments. This procedure\n" | |
332 | "was intended to be used before an exec call to close file descriptors\n" | |
333 | "which are not needed in the new process. However it has the\n" | |
334 | "undesirable side effect of flushing buffers, so it's deprecated.\n" | |
335 | "Use port-for-each instead.") | |
336 | #define FUNC_NAME s_scm_close_all_ports_except | |
337 | { | |
338 | SCM p; | |
339 | SCM_VALIDATE_REST_ARGUMENT (ports); | |
36722c63 | 340 | |
d2e53ed6 | 341 | for (p = ports; !scm_is_null (p); p = SCM_CDR (p)) |
a0454d72 MV |
342 | SCM_VALIDATE_OPPORT (SCM_ARG1, SCM_COERCE_OUTPORT (SCM_CAR (p))); |
343 | ||
36722c63 | 344 | scm_c_port_for_each (maybe_close_port, SCM2PTR (ports)); |
a0454d72 MV |
345 | |
346 | return SCM_UNSPECIFIED; | |
347 | } | |
348 | #undef FUNC_NAME | |
55d30fac | 349 | |
965445d4 MV |
350 | SCM_DEFINE (scm_variable_set_name_hint, "variable-set-name-hint!", 2, 0, 0, |
351 | (SCM var, SCM hint), | |
352 | "Do not use this function.") | |
353 | #define FUNC_NAME s_scm_variable_set_name_hint | |
354 | { | |
355 | SCM_VALIDATE_VARIABLE (1, var); | |
356 | SCM_VALIDATE_SYMBOL (2, hint); | |
357 | scm_c_issue_deprecation_warning | |
358 | ("'variable-set-name-hint!' is deprecated. Do not use it."); | |
359 | return SCM_UNSPECIFIED; | |
360 | } | |
361 | #undef FUNC_NAME | |
362 | ||
363 | SCM_DEFINE (scm_builtin_variable, "builtin-variable", 1, 0, 0, | |
364 | (SCM name), | |
365 | "Do not use this function.") | |
366 | #define FUNC_NAME s_scm_builtin_variable | |
367 | { | |
368 | SCM_VALIDATE_SYMBOL (1,name); | |
369 | scm_c_issue_deprecation_warning ("`builtin-variable' is deprecated. " | |
370 | "Use module system operations instead."); | |
371 | return scm_sym2var (name, SCM_BOOL_F, SCM_BOOL_T); | |
372 | } | |
373 | #undef FUNC_NAME | |
374 | ||
375 | SCM | |
376 | scm_makstr (size_t len, int dummy) | |
377 | { | |
378 | scm_c_issue_deprecation_warning | |
3ee86942 MV |
379 | ("'scm_makstr' is deprecated. Use 'scm_c_make_string' instead."); |
380 | return scm_c_make_string (len, SCM_UNDEFINED); | |
965445d4 MV |
381 | } |
382 | ||
383 | SCM | |
384 | scm_makfromstr (const char *src, size_t len, int dummy SCM_UNUSED) | |
385 | { | |
386 | scm_c_issue_deprecation_warning ("`scm_makfromstr' is deprecated. " | |
3ee86942 | 387 | "Use `scm_from_locale_stringn' instead."); |
965445d4 | 388 | |
3ee86942 | 389 | return scm_from_locale_stringn (src, len); |
965445d4 MV |
390 | } |
391 | ||
392 | SCM | |
393 | scm_internal_with_fluids (SCM fluids, SCM values, SCM (*cproc) (), void *cdata) | |
394 | { | |
395 | scm_c_issue_deprecation_warning ("`scm_internal_with_fluids' is deprecated. " | |
396 | "Use `scm_c_with_fluids' instead."); | |
397 | ||
398 | return scm_c_with_fluids (fluids, values, cproc, cdata); | |
399 | } | |
400 | ||
401 | SCM | |
402 | scm_make_gsubr (const char *name, int req, int opt, int rst, SCM (*fcn)()) | |
403 | { | |
404 | scm_c_issue_deprecation_warning | |
405 | ("`scm_make_gsubr' is deprecated. Use `scm_c_define_gsubr' instead."); | |
406 | ||
407 | return scm_c_define_gsubr (name, req, opt, rst, fcn); | |
408 | } | |
409 | ||
410 | SCM | |
411 | scm_make_gsubr_with_generic (const char *name, | |
412 | int req, int opt, int rst, | |
413 | SCM (*fcn)(), SCM *gf) | |
414 | { | |
415 | scm_c_issue_deprecation_warning | |
416 | ("`scm_make_gsubr_with_generic' is deprecated. " | |
417 | "Use `scm_c_define_gsubr_with_generic' instead."); | |
418 | ||
419 | return scm_c_define_gsubr_with_generic (name, req, opt, rst, fcn, gf); | |
420 | } | |
421 | ||
422 | SCM | |
423 | scm_create_hook (const char *name, int n_args) | |
424 | { | |
425 | scm_c_issue_deprecation_warning | |
426 | ("'scm_create_hook' is deprecated. " | |
427 | "Use 'scm_make_hook' and 'scm_c_define' instead."); | |
428 | { | |
7888309b | 429 | SCM hook = scm_make_hook (scm_from_int (n_args)); |
965445d4 | 430 | scm_c_define (name, hook); |
838aa000 | 431 | return hook; |
965445d4 MV |
432 | } |
433 | } | |
434 | ||
435 | SCM_DEFINE (scm_sloppy_memq, "sloppy-memq", 2, 0, 0, | |
436 | (SCM x, SCM lst), | |
437 | "This procedure behaves like @code{memq}, but does no type or error checking.\n" | |
438 | "Its use is recommended only in writing Guile internals,\n" | |
439 | "not for high-level Scheme programs.") | |
440 | #define FUNC_NAME s_scm_sloppy_memq | |
441 | { | |
442 | scm_c_issue_deprecation_warning | |
443 | ("'sloppy-memq' is deprecated. Use 'memq' instead."); | |
444 | ||
d2e53ed6 | 445 | for(; scm_is_pair (lst); lst = SCM_CDR(lst)) |
965445d4 | 446 | { |
bc36d050 | 447 | if (scm_is_eq (SCM_CAR (lst), x)) |
965445d4 MV |
448 | return lst; |
449 | } | |
450 | return lst; | |
451 | } | |
452 | #undef FUNC_NAME | |
453 | ||
454 | ||
455 | SCM_DEFINE (scm_sloppy_memv, "sloppy-memv", 2, 0, 0, | |
456 | (SCM x, SCM lst), | |
457 | "This procedure behaves like @code{memv}, but does no type or error checking.\n" | |
458 | "Its use is recommended only in writing Guile internals,\n" | |
459 | "not for high-level Scheme programs.") | |
460 | #define FUNC_NAME s_scm_sloppy_memv | |
461 | { | |
462 | scm_c_issue_deprecation_warning | |
463 | ("'sloppy-memv' is deprecated. Use 'memv' instead."); | |
464 | ||
d2e53ed6 | 465 | for(; scm_is_pair (lst); lst = SCM_CDR(lst)) |
965445d4 | 466 | { |
7888309b | 467 | if (! scm_is_false (scm_eqv_p (SCM_CAR (lst), x))) |
965445d4 MV |
468 | return lst; |
469 | } | |
470 | return lst; | |
471 | } | |
472 | #undef FUNC_NAME | |
473 | ||
474 | ||
475 | SCM_DEFINE (scm_sloppy_member, "sloppy-member", 2, 0, 0, | |
476 | (SCM x, SCM lst), | |
477 | "This procedure behaves like @code{member}, but does no type or error checking.\n" | |
478 | "Its use is recommended only in writing Guile internals,\n" | |
479 | "not for high-level Scheme programs.") | |
480 | #define FUNC_NAME s_scm_sloppy_member | |
481 | { | |
482 | scm_c_issue_deprecation_warning | |
483 | ("'sloppy-member' is deprecated. Use 'member' instead."); | |
484 | ||
d2e53ed6 | 485 | for(; scm_is_pair (lst); lst = SCM_CDR(lst)) |
965445d4 | 486 | { |
7888309b | 487 | if (! scm_is_false (scm_equal_p (SCM_CAR (lst), x))) |
965445d4 MV |
488 | return lst; |
489 | } | |
490 | return lst; | |
491 | } | |
492 | #undef FUNC_NAME | |
493 | ||
494 | SCM_SYMBOL (scm_end_of_file_key, "end-of-file"); | |
495 | ||
496 | SCM_DEFINE (scm_read_and_eval_x, "read-and-eval!", 0, 1, 0, | |
497 | (SCM port), | |
498 | "Read a form from @var{port} (standard input by default), and evaluate it\n" | |
499 | "(memoizing it in the process) in the top-level environment. If no data\n" | |
500 | "is left to be read from @var{port}, an @code{end-of-file} error is\n" | |
501 | "signalled.") | |
502 | #define FUNC_NAME s_scm_read_and_eval_x | |
503 | { | |
f8ba2197 DH |
504 | SCM form; |
505 | ||
965445d4 MV |
506 | scm_c_issue_deprecation_warning |
507 | ("'read-and-eval!' is deprecated. Use 'read' and 'eval' instead."); | |
508 | ||
f8ba2197 | 509 | form = scm_read (port); |
965445d4 MV |
510 | if (SCM_EOF_OBJECT_P (form)) |
511 | scm_ithrow (scm_end_of_file_key, SCM_EOL, 1); | |
512 | return scm_eval_x (form, scm_current_module ()); | |
513 | } | |
514 | #undef FUNC_NAME | |
515 | ||
4abecea8 MV |
516 | /* Call thunk(closure) underneath a top-level error handler. |
517 | * If an error occurs, pass the exitval through err_filter and return it. | |
518 | * If no error occurs, return the value of thunk. | |
519 | */ | |
520 | ||
521 | #ifdef _UNICOS | |
522 | typedef int setjmp_type; | |
523 | #else | |
524 | typedef long setjmp_type; | |
525 | #endif | |
526 | ||
527 | struct cce_handler_data { | |
528 | SCM (*err_filter) (); | |
529 | void *closure; | |
530 | }; | |
531 | ||
532 | static SCM | |
533 | invoke_err_filter (void *d, SCM tag, SCM args) | |
534 | { | |
535 | struct cce_handler_data *data = (struct cce_handler_data *)d; | |
536 | return data->err_filter (SCM_BOOL_F, data->closure); | |
537 | } | |
538 | ||
539 | SCM | |
540 | scm_call_catching_errors (SCM (*thunk)(), SCM (*err_filter)(), void *closure) | |
541 | { | |
542 | scm_c_issue_deprecation_warning | |
543 | ("'scm_call_catching_errors' is deprecated. " | |
544 | "Use 'scm_internal_catch' instead."); | |
545 | ||
546 | { | |
547 | struct cce_handler_data data; | |
548 | data.err_filter = err_filter; | |
549 | data.closure = closure; | |
550 | return scm_internal_catch (SCM_BOOL_T, | |
551 | (scm_t_catch_body)thunk, closure, | |
552 | (scm_t_catch_handler)invoke_err_filter, &data); | |
553 | } | |
554 | } | |
555 | ||
556 | long | |
557 | scm_make_smob_type_mfpe (char *name, size_t size, | |
558 | SCM (*mark) (SCM), | |
559 | size_t (*free) (SCM), | |
560 | int (*print) (SCM, SCM, scm_print_state *), | |
561 | SCM (*equalp) (SCM, SCM)) | |
562 | { | |
563 | scm_c_issue_deprecation_warning | |
564 | ("'scm_make_smob_type_mfpe' is deprecated. " | |
565 | "Use 'scm_make_smob_type' plus 'scm_set_smob_*' instead."); | |
566 | ||
567 | { | |
568 | long answer = scm_make_smob_type (name, size); | |
569 | scm_set_smob_mfpe (answer, mark, free, print, equalp); | |
570 | return answer; | |
571 | } | |
572 | } | |
573 | ||
574 | void | |
575 | scm_set_smob_mfpe (long tc, | |
576 | SCM (*mark) (SCM), | |
577 | size_t (*free) (SCM), | |
578 | int (*print) (SCM, SCM, scm_print_state *), | |
579 | SCM (*equalp) (SCM, SCM)) | |
580 | { | |
581 | scm_c_issue_deprecation_warning | |
582 | ("'scm_set_smob_mfpe' is deprecated. " | |
583 | "Use 'scm_set_smob_mark' instead, for example."); | |
584 | ||
585 | if (mark) scm_set_smob_mark (tc, mark); | |
586 | if (free) scm_set_smob_free (tc, free); | |
587 | if (print) scm_set_smob_print (tc, print); | |
588 | if (equalp) scm_set_smob_equalp (tc, equalp); | |
589 | } | |
590 | ||
3051344b LC |
591 | size_t |
592 | scm_smob_free (SCM obj) | |
593 | { | |
594 | long n = SCM_SMOBNUM (obj); | |
595 | ||
596 | scm_c_issue_deprecation_warning | |
597 | ("`scm_smob_free' is deprecated. " | |
598 | "It is no longer needed."); | |
599 | ||
600 | if (scm_smobs[n].size > 0) | |
4dc2165b | 601 | scm_gc_free ((void *) SCM_SMOB_DATA_1 (obj), |
3051344b LC |
602 | scm_smobs[n].size, SCM_SMOBNAME (n)); |
603 | return 0; | |
604 | } | |
605 | ||
4abecea8 MV |
606 | SCM |
607 | scm_read_0str (char *expr) | |
608 | { | |
609 | scm_c_issue_deprecation_warning | |
610 | ("scm_read_0str is deprecated. Use scm_c_read_string instead."); | |
611 | ||
612 | return scm_c_read_string (expr); | |
613 | } | |
614 | ||
615 | SCM | |
616 | scm_eval_0str (const char *expr) | |
617 | { | |
618 | scm_c_issue_deprecation_warning | |
619 | ("scm_eval_0str is deprecated. Use scm_c_eval_string instead."); | |
620 | ||
621 | return scm_c_eval_string (expr); | |
622 | } | |
623 | ||
624 | SCM | |
625 | scm_strprint_obj (SCM obj) | |
626 | { | |
627 | scm_c_issue_deprecation_warning | |
628 | ("scm_strprint_obj is deprecated. Use scm_object_to_string instead."); | |
629 | return scm_object_to_string (obj, SCM_UNDEFINED); | |
630 | } | |
631 | ||
a725fa95 MV |
632 | char * |
633 | scm_i_object_chars (SCM obj) | |
634 | { | |
635 | scm_c_issue_deprecation_warning | |
636 | ("SCM_CHARS is deprecated. See the manual for alternatives."); | |
637 | if (SCM_STRINGP (obj)) | |
638 | return SCM_STRING_CHARS (obj); | |
639 | if (SCM_SYMBOLP (obj)) | |
640 | return SCM_SYMBOL_CHARS (obj); | |
641 | abort (); | |
642 | } | |
643 | ||
644 | long | |
645 | scm_i_object_length (SCM obj) | |
646 | { | |
647 | scm_c_issue_deprecation_warning | |
648 | ("SCM_LENGTH is deprecated. " | |
649 | "Use scm_c_string_length instead, for example, or see the manual."); | |
650 | if (SCM_STRINGP (obj)) | |
651 | return SCM_STRING_LENGTH (obj); | |
652 | if (SCM_SYMBOLP (obj)) | |
653 | return SCM_SYMBOL_LENGTH (obj); | |
654 | if (SCM_VECTORP (obj)) | |
655 | return SCM_VECTOR_LENGTH (obj); | |
656 | abort (); | |
657 | } | |
658 | ||
cc5c1b66 MV |
659 | SCM |
660 | scm_sym2ovcell_soft (SCM sym, SCM obarray) | |
661 | { | |
662 | SCM lsym, z; | |
3ee86942 | 663 | size_t hash = scm_i_symbol_hash (sym) % SCM_VECTOR_LENGTH (obarray); |
cc5c1b66 MV |
664 | |
665 | scm_c_issue_deprecation_warning ("`scm_sym2ovcell_soft' is deprecated. " | |
666 | "Use hashtables instead."); | |
667 | ||
9de87eea | 668 | SCM_CRITICAL_SECTION_START; |
cc5c1b66 MV |
669 | for (lsym = SCM_VECTOR_REF (obarray, hash); |
670 | SCM_NIMP (lsym); | |
671 | lsym = SCM_CDR (lsym)) | |
672 | { | |
673 | z = SCM_CAR (lsym); | |
bc36d050 | 674 | if (scm_is_eq (SCM_CAR (z), sym)) |
cc5c1b66 | 675 | { |
9de87eea | 676 | SCM_CRITICAL_SECTION_END; |
cc5c1b66 MV |
677 | return z; |
678 | } | |
679 | } | |
9de87eea | 680 | SCM_CRITICAL_SECTION_END; |
cc5c1b66 MV |
681 | return SCM_BOOL_F; |
682 | } | |
683 | ||
684 | ||
685 | SCM | |
686 | scm_sym2ovcell (SCM sym, SCM obarray) | |
687 | #define FUNC_NAME "scm_sym2ovcell" | |
688 | { | |
689 | SCM answer; | |
690 | ||
691 | scm_c_issue_deprecation_warning ("`scm_sym2ovcell' is deprecated. " | |
692 | "Use hashtables instead."); | |
693 | ||
694 | answer = scm_sym2ovcell_soft (sym, obarray); | |
7888309b | 695 | if (scm_is_true (answer)) |
cc5c1b66 MV |
696 | return answer; |
697 | SCM_MISC_ERROR ("uninterned symbol: ~S", scm_list_1 (sym)); | |
698 | return SCM_UNSPECIFIED; /* not reached */ | |
699 | } | |
700 | #undef FUNC_NAME | |
701 | ||
702 | ||
703 | /* Intern a symbol whose name is the LEN characters at NAME in OBARRAY. | |
704 | ||
705 | OBARRAY should be a vector of lists, indexed by the name's hash | |
706 | value, modulo OBARRAY's length. Each list has the form | |
707 | ((SYMBOL . VALUE) ...), where SYMBOL is a symbol, and VALUE is the | |
708 | value associated with that symbol (in the current module? in the | |
709 | system module?) | |
710 | ||
711 | To "intern" a symbol means: if OBARRAY already contains a symbol by | |
712 | that name, return its (SYMBOL . VALUE) pair; otherwise, create a | |
713 | new symbol, add the pair (SYMBOL . SCM_UNDEFINED) to the | |
714 | appropriate list of the OBARRAY, and return the pair. | |
715 | ||
716 | If softness is non-zero, don't create a symbol if it isn't already | |
717 | in OBARRAY; instead, just return #f. | |
718 | ||
719 | If OBARRAY is SCM_BOOL_F, create a symbol listed in no obarray and | |
720 | return (SYMBOL . SCM_UNDEFINED). */ | |
721 | ||
722 | ||
7f594642 MG |
723 | static SCM |
724 | intern_obarray_soft (SCM symbol, SCM obarray, unsigned int softness) | |
cc5c1b66 | 725 | { |
3ee86942 | 726 | size_t raw_hash = scm_i_symbol_hash (symbol); |
cc5c1b66 MV |
727 | size_t hash; |
728 | SCM lsym; | |
729 | ||
7888309b | 730 | if (scm_is_false (obarray)) |
cc5c1b66 MV |
731 | { |
732 | if (softness) | |
733 | return SCM_BOOL_F; | |
734 | else | |
735 | return scm_cons (symbol, SCM_UNDEFINED); | |
736 | } | |
737 | ||
738 | hash = raw_hash % SCM_VECTOR_LENGTH (obarray); | |
739 | ||
740 | for (lsym = SCM_VECTOR_REF(obarray, hash); | |
741 | SCM_NIMP (lsym); lsym = SCM_CDR (lsym)) | |
742 | { | |
743 | SCM a = SCM_CAR (lsym); | |
744 | SCM z = SCM_CAR (a); | |
bc36d050 | 745 | if (scm_is_eq (z, symbol)) |
cc5c1b66 MV |
746 | return a; |
747 | } | |
748 | ||
749 | if (softness) | |
750 | { | |
751 | return SCM_BOOL_F; | |
752 | } | |
753 | else | |
754 | { | |
755 | SCM cell = scm_cons (symbol, SCM_UNDEFINED); | |
756 | SCM slot = SCM_VECTOR_REF (obarray, hash); | |
757 | ||
758 | SCM_VECTOR_SET (obarray, hash, scm_cons (cell, slot)); | |
759 | ||
760 | return cell; | |
761 | } | |
762 | } | |
763 | ||
764 | ||
7f594642 MG |
765 | SCM |
766 | scm_intern_obarray_soft (const char *name, size_t len, SCM obarray, | |
767 | unsigned int softness) | |
768 | { | |
769 | SCM symbol = scm_from_locale_symboln (name, len); | |
770 | ||
771 | scm_c_issue_deprecation_warning ("`scm_intern_obarray_soft' is deprecated. " | |
772 | "Use hashtables instead."); | |
773 | ||
774 | return intern_obarray_soft (symbol, obarray, softness); | |
775 | } | |
776 | ||
cc5c1b66 MV |
777 | SCM |
778 | scm_intern_obarray (const char *name,size_t len,SCM obarray) | |
779 | { | |
780 | scm_c_issue_deprecation_warning ("`scm_intern_obarray' is deprecated. " | |
781 | "Use hashtables instead."); | |
782 | ||
783 | return scm_intern_obarray_soft (name, len, obarray, 0); | |
784 | } | |
785 | ||
786 | /* Lookup the value of the symbol named by the nul-terminated string | |
787 | NAME in the current module. */ | |
788 | SCM | |
789 | scm_symbol_value0 (const char *name) | |
790 | { | |
791 | scm_c_issue_deprecation_warning ("`scm_symbol_value0' is deprecated. " | |
792 | "Use `scm_lookup' instead."); | |
793 | ||
794 | return scm_variable_ref (scm_c_lookup (name)); | |
795 | } | |
796 | ||
797 | SCM_DEFINE (scm_string_to_obarray_symbol, "string->obarray-symbol", 2, 1, 0, | |
798 | (SCM o, SCM s, SCM softp), | |
799 | "Intern a new symbol in @var{obarray}, a symbol table, with name\n" | |
800 | "@var{string}.\n\n" | |
801 | "If @var{obarray} is @code{#f}, use the default system symbol table. If\n" | |
802 | "@var{obarray} is @code{#t}, the symbol should not be interned in any\n" | |
803 | "symbol table; merely return the pair (@var{symbol}\n" | |
804 | ". @var{#<undefined>}).\n\n" | |
805 | "The @var{soft?} argument determines whether new symbol table entries\n" | |
806 | "should be created when the specified symbol is not already present in\n" | |
807 | "@var{obarray}. If @var{soft?} is specified and is a true value, then\n" | |
808 | "new entries should not be added for symbols not already present in the\n" | |
809 | "table; instead, simply return @code{#f}.") | |
810 | #define FUNC_NAME s_scm_string_to_obarray_symbol | |
811 | { | |
812 | SCM vcell; | |
813 | SCM answer; | |
814 | int softness; | |
815 | ||
816 | SCM_VALIDATE_STRING (2, s); | |
7888309b | 817 | SCM_ASSERT (scm_is_bool (o) || SCM_VECTORP (o), o, SCM_ARG1, FUNC_NAME); |
cc5c1b66 MV |
818 | |
819 | scm_c_issue_deprecation_warning ("`string->obarray-symbol' is deprecated. " | |
820 | "Use hashtables instead."); | |
821 | ||
7888309b | 822 | softness = (!SCM_UNBNDP (softp) && scm_is_true(softp)); |
cc5c1b66 | 823 | /* iron out some screwy calling conventions */ |
7888309b | 824 | if (scm_is_false (o)) |
cc5c1b66 MV |
825 | { |
826 | /* nothing interesting to do here. */ | |
827 | return scm_string_to_symbol (s); | |
828 | } | |
bc36d050 | 829 | else if (scm_is_eq (o, SCM_BOOL_T)) |
cc5c1b66 MV |
830 | o = SCM_BOOL_F; |
831 | ||
7f594642 | 832 | vcell = intern_obarray_soft (scm_string_to_symbol (s), o, softness); |
7888309b | 833 | if (scm_is_false (vcell)) |
cc5c1b66 MV |
834 | return vcell; |
835 | answer = SCM_CAR (vcell); | |
836 | return answer; | |
837 | } | |
838 | #undef FUNC_NAME | |
839 | ||
840 | SCM_DEFINE (scm_intern_symbol, "intern-symbol", 2, 0, 0, | |
841 | (SCM o, SCM s), | |
842 | "Add a new symbol to @var{obarray} with name @var{string}, bound to an\n" | |
843 | "unspecified initial value. The symbol table is not modified if a symbol\n" | |
844 | "with this name is already present.") | |
845 | #define FUNC_NAME s_scm_intern_symbol | |
846 | { | |
847 | size_t hval; | |
848 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 849 | if (scm_is_false (o)) |
cc5c1b66 MV |
850 | return SCM_UNSPECIFIED; |
851 | ||
852 | scm_c_issue_deprecation_warning ("`intern-symbol' is deprecated. " | |
853 | "Use hashtables instead."); | |
854 | ||
855 | SCM_VALIDATE_VECTOR (1,o); | |
3ee86942 | 856 | hval = scm_i_symbol_hash (s) % SCM_VECTOR_LENGTH (o); |
cc5c1b66 | 857 | /* If the symbol is already interned, simply return. */ |
9de87eea | 858 | SCM_CRITICAL_SECTION_START; |
cc5c1b66 MV |
859 | { |
860 | SCM lsym; | |
861 | SCM sym; | |
862 | for (lsym = SCM_VECTOR_REF (o, hval); | |
863 | SCM_NIMP (lsym); | |
864 | lsym = SCM_CDR (lsym)) | |
865 | { | |
866 | sym = SCM_CAR (lsym); | |
bc36d050 | 867 | if (scm_is_eq (SCM_CAR (sym), s)) |
cc5c1b66 | 868 | { |
9de87eea | 869 | SCM_CRITICAL_SECTION_END; |
cc5c1b66 MV |
870 | return SCM_UNSPECIFIED; |
871 | } | |
872 | } | |
873 | SCM_VECTOR_SET (o, hval, | |
874 | scm_acons (s, SCM_UNDEFINED, | |
875 | SCM_VECTOR_REF (o, hval))); | |
876 | } | |
9de87eea | 877 | SCM_CRITICAL_SECTION_END; |
cc5c1b66 MV |
878 | return SCM_UNSPECIFIED; |
879 | } | |
880 | #undef FUNC_NAME | |
881 | ||
882 | SCM_DEFINE (scm_unintern_symbol, "unintern-symbol", 2, 0, 0, | |
883 | (SCM o, SCM s), | |
884 | "Remove the symbol with name @var{string} from @var{obarray}. This\n" | |
885 | "function returns @code{#t} if the symbol was present and @code{#f}\n" | |
886 | "otherwise.") | |
887 | #define FUNC_NAME s_scm_unintern_symbol | |
888 | { | |
889 | size_t hval; | |
890 | ||
891 | scm_c_issue_deprecation_warning ("`unintern-symbol' is deprecated. " | |
892 | "Use hashtables instead."); | |
893 | ||
894 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 895 | if (scm_is_false (o)) |
cc5c1b66 MV |
896 | return SCM_BOOL_F; |
897 | SCM_VALIDATE_VECTOR (1,o); | |
3ee86942 | 898 | hval = scm_i_symbol_hash (s) % SCM_VECTOR_LENGTH (o); |
9de87eea | 899 | SCM_CRITICAL_SECTION_START; |
cc5c1b66 MV |
900 | { |
901 | SCM lsym_follow; | |
902 | SCM lsym; | |
903 | SCM sym; | |
904 | for (lsym = SCM_VECTOR_REF (o, hval), lsym_follow = SCM_BOOL_F; | |
905 | SCM_NIMP (lsym); | |
906 | lsym_follow = lsym, lsym = SCM_CDR (lsym)) | |
907 | { | |
908 | sym = SCM_CAR (lsym); | |
bc36d050 | 909 | if (scm_is_eq (SCM_CAR (sym), s)) |
cc5c1b66 MV |
910 | { |
911 | /* Found the symbol to unintern. */ | |
7888309b | 912 | if (scm_is_false (lsym_follow)) |
cc5c1b66 MV |
913 | SCM_VECTOR_SET (o, hval, lsym); |
914 | else | |
915 | SCM_SETCDR (lsym_follow, SCM_CDR(lsym)); | |
9de87eea | 916 | SCM_CRITICAL_SECTION_END; |
cc5c1b66 MV |
917 | return SCM_BOOL_T; |
918 | } | |
919 | } | |
920 | } | |
9de87eea | 921 | SCM_CRITICAL_SECTION_END; |
cc5c1b66 MV |
922 | return SCM_BOOL_F; |
923 | } | |
924 | #undef FUNC_NAME | |
925 | ||
926 | SCM_DEFINE (scm_symbol_binding, "symbol-binding", 2, 0, 0, | |
927 | (SCM o, SCM s), | |
928 | "Look up in @var{obarray} the symbol whose name is @var{string}, and\n" | |
929 | "return the value to which it is bound. If @var{obarray} is @code{#f},\n" | |
930 | "use the global symbol table. If @var{string} is not interned in\n" | |
931 | "@var{obarray}, an error is signalled.") | |
932 | #define FUNC_NAME s_scm_symbol_binding | |
933 | { | |
934 | SCM vcell; | |
935 | ||
936 | scm_c_issue_deprecation_warning ("`symbol-binding' is deprecated. " | |
937 | "Use hashtables instead."); | |
938 | ||
939 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 940 | if (scm_is_false (o)) |
cc5c1b66 MV |
941 | return scm_variable_ref (scm_lookup (s)); |
942 | SCM_VALIDATE_VECTOR (1,o); | |
943 | vcell = scm_sym2ovcell (s, o); | |
944 | return SCM_CDR(vcell); | |
945 | } | |
946 | #undef FUNC_NAME | |
947 | ||
948 | #if 0 | |
949 | SCM_DEFINE (scm_symbol_interned_p, "symbol-interned?", 2, 0, 0, | |
950 | (SCM o, SCM s), | |
951 | "Return @code{#t} if @var{obarray} contains a symbol with name\n" | |
952 | "@var{string}, and @code{#f} otherwise.") | |
953 | #define FUNC_NAME s_scm_symbol_interned_p | |
954 | { | |
955 | SCM vcell; | |
956 | ||
957 | scm_c_issue_deprecation_warning ("`symbol-interned?' is deprecated. " | |
958 | "Use hashtables instead."); | |
959 | ||
960 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 961 | if (scm_is_false (o)) |
cc5c1b66 MV |
962 | { |
963 | SCM var = scm_sym2var (s, SCM_BOOL_F, SCM_BOOL_F); | |
964 | if (var != SCM_BOOL_F) | |
965 | return SCM_BOOL_T; | |
966 | return SCM_BOOL_F; | |
967 | } | |
968 | SCM_VALIDATE_VECTOR (1,o); | |
969 | vcell = scm_sym2ovcell_soft (s, o); | |
970 | return (SCM_NIMP(vcell) | |
971 | ? SCM_BOOL_T | |
972 | : SCM_BOOL_F); | |
973 | } | |
974 | #undef FUNC_NAME | |
975 | #endif | |
976 | ||
977 | SCM_DEFINE (scm_symbol_bound_p, "symbol-bound?", 2, 0, 0, | |
978 | (SCM o, SCM s), | |
979 | "Return @code{#t} if @var{obarray} contains a symbol with name\n" | |
980 | "@var{string} bound to a defined value. This differs from\n" | |
981 | "@var{symbol-interned?} in that the mere mention of a symbol\n" | |
982 | "usually causes it to be interned; @code{symbol-bound?}\n" | |
983 | "determines whether a symbol has been given any meaningful\n" | |
984 | "value.") | |
985 | #define FUNC_NAME s_scm_symbol_bound_p | |
986 | { | |
987 | SCM vcell; | |
988 | ||
989 | scm_c_issue_deprecation_warning ("`symbol-bound?' is deprecated. " | |
990 | "Use hashtables instead."); | |
991 | ||
992 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 993 | if (scm_is_false (o)) |
cc5c1b66 MV |
994 | { |
995 | SCM var = scm_sym2var (s, SCM_BOOL_F, SCM_BOOL_F); | |
996 | if (SCM_VARIABLEP(var) && !SCM_UNBNDP(SCM_VARIABLE_REF(var))) | |
997 | return SCM_BOOL_T; | |
998 | return SCM_BOOL_F; | |
999 | } | |
1000 | SCM_VALIDATE_VECTOR (1,o); | |
1001 | vcell = scm_sym2ovcell_soft (s, o); | |
7888309b | 1002 | return scm_from_bool (SCM_NIMP (vcell) && !SCM_UNBNDP (SCM_CDR (vcell))); |
cc5c1b66 MV |
1003 | } |
1004 | #undef FUNC_NAME | |
1005 | ||
1006 | ||
1007 | SCM_DEFINE (scm_symbol_set_x, "symbol-set!", 3, 0, 0, | |
1008 | (SCM o, SCM s, SCM v), | |
1009 | "Find the symbol in @var{obarray} whose name is @var{string}, and rebind\n" | |
1010 | "it to @var{value}. An error is signalled if @var{string} is not present\n" | |
1011 | "in @var{obarray}.") | |
1012 | #define FUNC_NAME s_scm_symbol_set_x | |
1013 | { | |
1014 | SCM vcell; | |
1015 | ||
1016 | scm_c_issue_deprecation_warning ("`symbol-set!' is deprecated. " | |
1017 | "Use the module system instead."); | |
1018 | ||
1019 | SCM_VALIDATE_SYMBOL (2,s); | |
7888309b | 1020 | if (scm_is_false (o)) |
cc5c1b66 MV |
1021 | { |
1022 | scm_define (s, v); | |
1023 | return SCM_UNSPECIFIED; | |
1024 | } | |
1025 | SCM_VALIDATE_VECTOR (1,o); | |
1026 | vcell = scm_sym2ovcell (s, o); | |
1027 | SCM_SETCDR (vcell, v); | |
1028 | return SCM_UNSPECIFIED; | |
1029 | } | |
1030 | #undef FUNC_NAME | |
1031 | ||
1032 | #define MAX_PREFIX_LENGTH 30 | |
1033 | ||
1034 | static int gentemp_counter; | |
1035 | ||
1036 | SCM_DEFINE (scm_gentemp, "gentemp", 0, 2, 0, | |
1037 | (SCM prefix, SCM obarray), | |
1038 | "Create a new symbol with a name unique in an obarray.\n" | |
1039 | "The name is constructed from an optional string @var{prefix}\n" | |
1040 | "and a counter value. The default prefix is @code{t}. The\n" | |
1041 | "@var{obarray} is specified as a second optional argument.\n" | |
1042 | "Default is the system obarray where all normal symbols are\n" | |
1043 | "interned. The counter is increased by 1 at each\n" | |
1044 | "call. There is no provision for resetting the counter.") | |
1045 | #define FUNC_NAME s_scm_gentemp | |
1046 | { | |
1047 | char buf[MAX_PREFIX_LENGTH + SCM_INTBUFLEN]; | |
1048 | char *name = buf; | |
806f1ded MG |
1049 | int n_digits; |
1050 | size_t len; | |
cc5c1b66 MV |
1051 | |
1052 | scm_c_issue_deprecation_warning ("`gentemp' is deprecated. " | |
1053 | "Use `gensym' instead."); | |
1054 | ||
1055 | if (SCM_UNBNDP (prefix)) | |
1056 | { | |
1057 | name[0] = 't'; | |
1058 | len = 1; | |
1059 | } | |
1060 | else | |
1061 | { | |
1062 | SCM_VALIDATE_STRING (1, prefix); | |
3ee86942 | 1063 | len = scm_i_string_length (prefix); |
806f1ded | 1064 | name = scm_to_locale_stringn (prefix, &len); |
7f594642 | 1065 | name = scm_realloc (name, len + SCM_INTBUFLEN); |
cc5c1b66 MV |
1066 | } |
1067 | ||
1068 | if (SCM_UNBNDP (obarray)) | |
1069 | return scm_gensym (prefix); | |
1070 | else | |
4057a3e0 | 1071 | SCM_ASSERT ((scm_is_vector (obarray) || SCM_I_WVECTP (obarray)), |
cc5c1b66 MV |
1072 | obarray, |
1073 | SCM_ARG2, | |
1074 | FUNC_NAME); | |
1075 | do | |
1076 | n_digits = scm_iint2str (gentemp_counter++, 10, &name[len]); | |
7888309b | 1077 | while (scm_is_true (scm_intern_obarray_soft (name, |
cc5c1b66 MV |
1078 | len + n_digits, |
1079 | obarray, | |
1080 | 1))); | |
1081 | { | |
1082 | SCM vcell = scm_intern_obarray_soft (name, | |
1083 | len + n_digits, | |
1084 | obarray, | |
1085 | 0); | |
1086 | if (name != buf) | |
7f594642 | 1087 | free (name); |
cc5c1b66 MV |
1088 | return SCM_CAR (vcell); |
1089 | } | |
1090 | } | |
1091 | #undef FUNC_NAME | |
1092 | ||
7888309b | 1093 | SCM |
fe78c51a | 1094 | scm_i_makinum (scm_t_signed_bits val) |
7888309b MV |
1095 | { |
1096 | scm_c_issue_deprecation_warning | |
1097 | ("SCM_MAKINUM is deprecated. Use scm_from_int or similar instead."); | |
3aa13a05 MV |
1098 | return SCM_I_MAKINUM (val); |
1099 | } | |
1100 | ||
1101 | int | |
fe78c51a | 1102 | scm_i_inump (SCM obj) |
3aa13a05 MV |
1103 | { |
1104 | scm_c_issue_deprecation_warning | |
1105 | ("SCM_INUMP is deprecated. Use scm_is_integer or similar instead."); | |
1106 | return SCM_I_INUMP (obj); | |
1107 | } | |
1108 | ||
1109 | scm_t_signed_bits | |
fe78c51a | 1110 | scm_i_inum (SCM obj) |
3aa13a05 MV |
1111 | { |
1112 | scm_c_issue_deprecation_warning | |
1113 | ("SCM_INUM is deprecated. Use scm_to_int or similar instead."); | |
1114 | return scm_to_intmax (obj); | |
7888309b | 1115 | } |
7888309b | 1116 | |
c829a427 MV |
1117 | char * |
1118 | scm_c_string2str (SCM obj, char *str, size_t *lenp) | |
1119 | { | |
1120 | scm_c_issue_deprecation_warning | |
1121 | ("scm_c_string2str is deprecated. Use scm_to_locale_stringbuf or similar instead."); | |
1122 | ||
1123 | if (str == NULL) | |
1124 | { | |
1125 | char *result = scm_to_locale_string (obj); | |
1126 | if (lenp) | |
3ee86942 | 1127 | *lenp = scm_i_string_length (obj); |
c829a427 MV |
1128 | return result; |
1129 | } | |
1130 | else | |
1131 | { | |
1132 | /* Pray that STR is large enough. | |
1133 | */ | |
1134 | size_t len = scm_to_locale_stringbuf (obj, str, SCM_I_SIZE_MAX); | |
1135 | str[len] = '\0'; | |
1136 | if (lenp) | |
1137 | *lenp = len; | |
1138 | return str; | |
1139 | } | |
1140 | } | |
1141 | ||
1142 | char * | |
1143 | scm_c_substring2str (SCM obj, char *str, size_t start, size_t len) | |
1144 | { | |
1145 | scm_c_issue_deprecation_warning | |
1146 | ("scm_c_substring2str is deprecated. Use scm_substring plus scm_to_locale_stringbuf instead."); | |
1147 | ||
1148 | if (start) | |
1149 | obj = scm_substring (obj, scm_from_size_t (start), SCM_UNDEFINED); | |
1150 | ||
1151 | scm_to_locale_stringbuf (obj, str, len); | |
1152 | return str; | |
1153 | } | |
1154 | ||
3ee86942 MV |
1155 | /* Converts the given Scheme symbol OBJ into a C string, containing a copy |
1156 | of OBJ's content with a trailing null byte. If LENP is non-NULL, set | |
1157 | *LENP to the string's length. | |
1158 | ||
1159 | When STR is non-NULL it receives the copy and is returned by the function, | |
1160 | otherwise new memory is allocated and the caller is responsible for | |
1161 | freeing it via free(). If out of memory, NULL is returned. | |
1162 | ||
1163 | Note that Scheme symbols may contain arbitrary data, including null | |
1164 | characters. This means that null termination is not a reliable way to | |
1165 | determine the length of the returned value. However, the function always | |
1166 | copies the complete contents of OBJ, and sets *LENP to the length of the | |
1167 | scheme symbol (if LENP is non-null). */ | |
1168 | char * | |
1169 | scm_c_symbol2str (SCM obj, char *str, size_t *lenp) | |
1170 | { | |
1171 | return scm_c_string2str (scm_symbol_to_string (obj), str, lenp); | |
1172 | } | |
1173 | ||
3101f40f MV |
1174 | double |
1175 | scm_truncate (double x) | |
1176 | { | |
1177 | scm_c_issue_deprecation_warning | |
1178 | ("scm_truncate is deprecated. Use scm_c_truncate instead."); | |
1179 | return scm_c_truncate (x); | |
1180 | } | |
1181 | ||
1182 | double | |
1183 | scm_round (double x) | |
1184 | { | |
1185 | scm_c_issue_deprecation_warning | |
1186 | ("scm_round is deprecated. Use scm_c_round instead."); | |
1187 | return scm_c_round (x); | |
1188 | } | |
1189 | ||
6fc4d012 AW |
1190 | SCM |
1191 | scm_sys_expt (SCM x, SCM y) | |
1192 | { | |
1193 | scm_c_issue_deprecation_warning | |
1194 | ("scm_sys_expt is deprecated. Use scm_expt instead."); | |
1195 | return scm_expt (x, y); | |
1196 | } | |
1197 | ||
ad79736c AW |
1198 | double |
1199 | scm_asinh (double x) | |
1200 | { | |
1201 | scm_c_issue_deprecation_warning | |
1202 | ("scm_asinh is deprecated. Use asinh instead."); | |
1203 | #if HAVE_ASINH | |
1204 | return asinh (x); | |
1205 | #else | |
1206 | return log (x + sqrt (x * x + 1)); | |
1207 | #endif | |
1208 | } | |
1209 | ||
1210 | double | |
1211 | scm_acosh (double x) | |
1212 | { | |
1213 | scm_c_issue_deprecation_warning | |
1214 | ("scm_acosh is deprecated. Use acosh instead."); | |
1215 | #if HAVE_ACOSH | |
1216 | return acosh (x); | |
1217 | #else | |
1218 | return log (x + sqrt (x * x - 1)); | |
1219 | #endif | |
1220 | } | |
1221 | ||
1222 | double | |
1223 | scm_atanh (double x) | |
1224 | { | |
1225 | scm_c_issue_deprecation_warning | |
1226 | ("scm_atanh is deprecated. Use atanh instead."); | |
1227 | #if HAVE_ATANH | |
1228 | return atanh (x); | |
1229 | #else | |
1230 | return 0.5 * log ((1 + x) / (1 - x)); | |
1231 | #endif | |
1232 | } | |
1233 | ||
1234 | SCM | |
1235 | scm_sys_atan2 (SCM z1, SCM z2) | |
1236 | { | |
1237 | scm_c_issue_deprecation_warning | |
1238 | ("scm_sys_atan2 is deprecated. Use scm_atan instead."); | |
1239 | return scm_atan (z1, z2); | |
1240 | } | |
1241 | ||
3ee86942 | 1242 | char * |
fe78c51a | 1243 | scm_i_deprecated_symbol_chars (SCM sym) |
3ee86942 MV |
1244 | { |
1245 | scm_c_issue_deprecation_warning | |
1246 | ("SCM_SYMBOL_CHARS is deprecated. Use scm_symbol_to_string."); | |
1247 | ||
ba16a103 | 1248 | return (char *)scm_i_symbol_chars (sym); |
3ee86942 MV |
1249 | } |
1250 | ||
1251 | size_t | |
fe78c51a | 1252 | scm_i_deprecated_symbol_length (SCM sym) |
3ee86942 MV |
1253 | { |
1254 | scm_c_issue_deprecation_warning | |
1255 | ("SCM_SYMBOL_LENGTH is deprecated. Use scm_symbol_to_string."); | |
ba16a103 | 1256 | return scm_i_symbol_length (sym); |
3ee86942 MV |
1257 | } |
1258 | ||
265a7997 | 1259 | int |
fe78c51a | 1260 | scm_i_keywordp (SCM obj) |
265a7997 MV |
1261 | { |
1262 | scm_c_issue_deprecation_warning | |
1263 | ("SCM_KEYWORDP is deprecated. Use scm_is_keyword instead."); | |
1264 | return scm_is_keyword (obj); | |
1265 | } | |
1266 | ||
1267 | SCM | |
fe78c51a | 1268 | scm_i_keywordsym (SCM keyword) |
265a7997 MV |
1269 | { |
1270 | scm_c_issue_deprecation_warning | |
1271 | ("SCM_KEYWORDSYM is deprecated. See scm_keyword_to_symbol instead."); | |
1272 | return scm_keyword_dash_symbol (keyword); | |
1273 | } | |
1274 | ||
354116f7 | 1275 | int |
fe78c51a | 1276 | scm_i_vectorp (SCM x) |
354116f7 MV |
1277 | { |
1278 | scm_c_issue_deprecation_warning | |
1279 | ("SCM_VECTORP is deprecated. Use scm_is_vector instead."); | |
1280 | return SCM_I_IS_VECTOR (x); | |
1281 | } | |
1282 | ||
1283 | unsigned long | |
fe78c51a | 1284 | scm_i_vector_length (SCM x) |
354116f7 MV |
1285 | { |
1286 | scm_c_issue_deprecation_warning | |
1287 | ("SCM_VECTOR_LENGTH is deprecated. Use scm_c_vector_length instead."); | |
1288 | return SCM_I_VECTOR_LENGTH (x); | |
1289 | } | |
1290 | ||
1291 | const SCM * | |
fe78c51a | 1292 | scm_i_velts (SCM x) |
354116f7 MV |
1293 | { |
1294 | scm_c_issue_deprecation_warning | |
1295 | ("SCM_VELTS is deprecated. Use scm_vector_elements instead."); | |
1296 | return SCM_I_VECTOR_ELTS (x); | |
1297 | } | |
1298 | ||
1299 | SCM * | |
fe78c51a | 1300 | scm_i_writable_velts (SCM x) |
354116f7 MV |
1301 | { |
1302 | scm_c_issue_deprecation_warning | |
1303 | ("SCM_WRITABLE_VELTS is deprecated. " | |
1304 | "Use scm_vector_writable_elements instead."); | |
1305 | return SCM_I_VECTOR_WELTS (x); | |
1306 | } | |
1307 | ||
1308 | SCM | |
fe78c51a | 1309 | scm_i_vector_ref (SCM x, size_t idx) |
354116f7 MV |
1310 | { |
1311 | scm_c_issue_deprecation_warning | |
1312 | ("SCM_VECTOR_REF is deprecated. " | |
1313 | "Use scm_c_vector_ref or scm_vector_elements instead."); | |
1314 | return scm_c_vector_ref (x, idx); | |
1315 | } | |
1316 | ||
1317 | void | |
fe78c51a | 1318 | scm_i_vector_set (SCM x, size_t idx, SCM val) |
354116f7 MV |
1319 | { |
1320 | scm_c_issue_deprecation_warning | |
1321 | ("SCM_VECTOR_SET is deprecated. " | |
1322 | "Use scm_c_vector_set_x or scm_vector_writable_elements instead."); | |
1323 | scm_c_vector_set_x (x, idx, val); | |
1324 | } | |
1325 | ||
1326 | SCM | |
1327 | scm_vector_equal_p (SCM x, SCM y) | |
1328 | { | |
1329 | scm_c_issue_deprecation_warning | |
1330 | ("scm_vector_euqal_p is deprecated. " | |
1331 | "Use scm_equal_p instead."); | |
1332 | return scm_equal_p (x, y); | |
1333 | } | |
1334 | ||
a2689737 AW |
1335 | SCM_DEFINE (scm_uniform_vector_read_x, "uniform-vector-read!", 1, 3, 0, |
1336 | (SCM uvec, SCM port_or_fd, SCM start, SCM end), | |
1337 | "Fill the elements of @var{uvec} by reading\n" | |
1338 | "raw bytes from @var{port-or-fdes}, using host byte order.\n\n" | |
1339 | "The optional arguments @var{start} (inclusive) and @var{end}\n" | |
1340 | "(exclusive) allow a specified region to be read,\n" | |
1341 | "leaving the remainder of the vector unchanged.\n\n" | |
1342 | "When @var{port-or-fdes} is a port, all specified elements\n" | |
1343 | "of @var{uvec} are attempted to be read, potentially blocking\n" | |
ffb62a43 | 1344 | "while waiting for more input or end-of-file.\n" |
a2689737 AW |
1345 | "When @var{port-or-fd} is an integer, a single call to\n" |
1346 | "read(2) is made.\n\n" | |
1347 | "An error is signalled when the last element has only\n" | |
1348 | "been partially filled before reaching end-of-file or in\n" | |
1349 | "the single call to read(2).\n\n" | |
1350 | "@code{uniform-vector-read!} returns the number of elements\n" | |
1351 | "read.\n\n" | |
1352 | "@var{port-or-fdes} may be omitted, in which case it defaults\n" | |
1353 | "to the value returned by @code{(current-input-port)}.") | |
1354 | #define FUNC_NAME s_scm_uniform_vector_read_x | |
1355 | { | |
73d1aaaf LC |
1356 | SCM result; |
1357 | size_t c_width, c_start, c_end; | |
1358 | ||
a2689737 | 1359 | SCM_VALIDATE_BYTEVECTOR (SCM_ARG1, uvec); |
1f366ef7 | 1360 | |
73d1aaaf | 1361 | scm_c_issue_deprecation_warning |
a2689737 AW |
1362 | ("`uniform-vector-read!' is deprecated. Use `get-bytevector-n!' from\n" |
1363 | "`(rnrs io ports)' instead."); | |
1f366ef7 | 1364 | |
73d1aaaf LC |
1365 | if (SCM_UNBNDP (port_or_fd)) |
1366 | port_or_fd = scm_current_input_port (); | |
1367 | ||
1368 | c_width = scm_to_size_t (scm_uniform_vector_element_size (uvec)); | |
1369 | ||
1370 | c_start = SCM_UNBNDP (start) ? 0 : scm_to_size_t (start); | |
1371 | c_start *= c_width; | |
1f366ef7 | 1372 | |
73d1aaaf LC |
1373 | c_end = SCM_UNBNDP (end) ? SCM_BYTEVECTOR_LENGTH (uvec) : scm_to_size_t (end); |
1374 | c_end *= c_width; | |
1375 | ||
1376 | result = scm_get_bytevector_n_x (port_or_fd, uvec, | |
1377 | scm_from_size_t (c_start), | |
1378 | scm_from_size_t (c_end - c_start)); | |
1379 | ||
1380 | if (SCM_EOF_OBJECT_P (result)) | |
1381 | result = SCM_INUM0; | |
1382 | ||
1383 | return result; | |
1f366ef7 | 1384 | } |
a2689737 | 1385 | #undef FUNC_NAME |
1f366ef7 | 1386 | |
a2689737 AW |
1387 | SCM_DEFINE (scm_uniform_vector_write, "uniform-vector-write", 1, 3, 0, |
1388 | (SCM uvec, SCM port_or_fd, SCM start, SCM end), | |
1389 | "Write the elements of @var{uvec} as raw bytes to\n" | |
1390 | "@var{port-or-fdes}, in the host byte order.\n\n" | |
1391 | "The optional arguments @var{start} (inclusive)\n" | |
1392 | "and @var{end} (exclusive) allow\n" | |
1393 | "a specified region to be written.\n\n" | |
1394 | "When @var{port-or-fdes} is a port, all specified elements\n" | |
1395 | "of @var{uvec} are attempted to be written, potentially blocking\n" | |
1396 | "while waiting for more room.\n" | |
1397 | "When @var{port-or-fd} is an integer, a single call to\n" | |
1398 | "write(2) is made.\n\n" | |
1399 | "An error is signalled when the last element has only\n" | |
1400 | "been partially written in the single call to write(2).\n\n" | |
1401 | "The number of objects actually written is returned.\n" | |
1402 | "@var{port-or-fdes} may be\n" | |
1403 | "omitted, in which case it defaults to the value returned by\n" | |
1404 | "@code{(current-output-port)}.") | |
1405 | #define FUNC_NAME s_scm_uniform_vector_write | |
1406 | { | |
73d1aaaf LC |
1407 | size_t c_width, c_start, c_end; |
1408 | ||
a2689737 | 1409 | SCM_VALIDATE_BYTEVECTOR (SCM_ARG1, uvec); |
a2689737 | 1410 | |
73d1aaaf | 1411 | scm_c_issue_deprecation_warning |
a2689737 AW |
1412 | ("`uniform-vector-write' is deprecated. Use `put-bytevector' from\n" |
1413 | "`(rnrs io ports)' instead."); | |
1414 | ||
73d1aaaf LC |
1415 | if (SCM_UNBNDP (port_or_fd)) |
1416 | port_or_fd = scm_current_output_port (); | |
1417 | ||
1418 | port_or_fd = SCM_COERCE_OUTPORT (port_or_fd); | |
1419 | ||
1420 | c_width = scm_to_size_t (scm_uniform_vector_element_size (uvec)); | |
1421 | ||
1422 | c_start = SCM_UNBNDP (start) ? 0 : scm_to_size_t (start); | |
1423 | c_start *= c_width; | |
1424 | ||
1425 | c_end = SCM_UNBNDP (end) ? SCM_BYTEVECTOR_LENGTH (uvec) : scm_to_size_t (end); | |
1426 | c_end *= c_width; | |
a2689737 AW |
1427 | |
1428 | return scm_put_bytevector (port_or_fd, uvec, | |
73d1aaaf LC |
1429 | scm_from_size_t (c_start), |
1430 | scm_from_size_t (c_end - c_start)); | |
1f366ef7 | 1431 | } |
a2689737 | 1432 | #undef FUNC_NAME |
1f366ef7 | 1433 | |
a2689737 AW |
1434 | static SCM |
1435 | scm_ra2contig (SCM ra, int copy) | |
1436 | { | |
1437 | SCM ret; | |
1438 | long inc = 1; | |
1439 | size_t k, len = 1; | |
1440 | for (k = SCM_I_ARRAY_NDIM (ra); k--;) | |
1441 | len *= SCM_I_ARRAY_DIMS (ra)[k].ubnd - SCM_I_ARRAY_DIMS (ra)[k].lbnd + 1; | |
1442 | k = SCM_I_ARRAY_NDIM (ra); | |
1443 | if (SCM_I_ARRAY_CONTP (ra) && ((0 == k) || (1 == SCM_I_ARRAY_DIMS (ra)[k - 1].inc))) | |
1444 | { | |
1445 | if (!scm_is_bitvector (SCM_I_ARRAY_V (ra))) | |
1446 | return ra; | |
1447 | if ((len == scm_c_bitvector_length (SCM_I_ARRAY_V (ra)) && | |
1448 | 0 == SCM_I_ARRAY_BASE (ra) % SCM_LONG_BIT && | |
1449 | 0 == len % SCM_LONG_BIT)) | |
1450 | return ra; | |
1451 | } | |
1452 | ret = scm_i_make_array (k); | |
1453 | SCM_I_ARRAY_BASE (ret) = 0; | |
1454 | while (k--) | |
1455 | { | |
1456 | SCM_I_ARRAY_DIMS (ret)[k].lbnd = SCM_I_ARRAY_DIMS (ra)[k].lbnd; | |
1457 | SCM_I_ARRAY_DIMS (ret)[k].ubnd = SCM_I_ARRAY_DIMS (ra)[k].ubnd; | |
1458 | SCM_I_ARRAY_DIMS (ret)[k].inc = inc; | |
1459 | inc *= SCM_I_ARRAY_DIMS (ra)[k].ubnd - SCM_I_ARRAY_DIMS (ra)[k].lbnd + 1; | |
1460 | } | |
1461 | SCM_I_ARRAY_V (ret) = | |
1462 | scm_make_generalized_vector (scm_array_type (ra), scm_from_size_t (inc), | |
1463 | SCM_UNDEFINED); | |
1464 | if (copy) | |
1465 | scm_array_copy_x (ra, ret); | |
1466 | return ret; | |
1467 | } | |
1468 | ||
1469 | SCM_DEFINE (scm_uniform_array_read_x, "uniform-array-read!", 1, 3, 0, | |
1470 | (SCM ura, SCM port_or_fd, SCM start, SCM end), | |
1471 | "@deffnx {Scheme Procedure} uniform-vector-read! uve [port-or-fdes] [start] [end]\n" | |
1472 | "Attempt to read all elements of @var{ura}, in lexicographic order, as\n" | |
1473 | "binary objects from @var{port-or-fdes}.\n" | |
1474 | "If an end of file is encountered,\n" | |
1475 | "the objects up to that point are put into @var{ura}\n" | |
1476 | "(starting at the beginning) and the remainder of the array is\n" | |
1477 | "unchanged.\n\n" | |
1478 | "The optional arguments @var{start} and @var{end} allow\n" | |
1479 | "a specified region of a vector (or linearized array) to be read,\n" | |
1480 | "leaving the remainder of the vector unchanged.\n\n" | |
1481 | "@code{uniform-array-read!} returns the number of objects read.\n" | |
1482 | "@var{port-or-fdes} may be omitted, in which case it defaults to the value\n" | |
1483 | "returned by @code{(current-input-port)}.") | |
1484 | #define FUNC_NAME s_scm_uniform_array_read_x | |
1485 | { | |
1486 | if (SCM_UNBNDP (port_or_fd)) | |
1487 | port_or_fd = scm_current_input_port (); | |
1488 | ||
1489 | if (scm_is_uniform_vector (ura)) | |
1490 | { | |
1491 | return scm_uniform_vector_read_x (ura, port_or_fd, start, end); | |
1492 | } | |
1493 | else if (SCM_I_ARRAYP (ura)) | |
1494 | { | |
1495 | size_t base, vlen, cstart, cend; | |
1496 | SCM cra, ans; | |
1497 | ||
1498 | cra = scm_ra2contig (ura, 0); | |
1499 | base = SCM_I_ARRAY_BASE (cra); | |
1500 | vlen = SCM_I_ARRAY_DIMS (cra)->inc * | |
1501 | (SCM_I_ARRAY_DIMS (cra)->ubnd - SCM_I_ARRAY_DIMS (cra)->lbnd + 1); | |
1502 | ||
1503 | cstart = 0; | |
1504 | cend = vlen; | |
1505 | if (!SCM_UNBNDP (start)) | |
1506 | { | |
1507 | cstart = scm_to_unsigned_integer (start, 0, vlen); | |
1508 | if (!SCM_UNBNDP (end)) | |
1509 | cend = scm_to_unsigned_integer (end, cstart, vlen); | |
1510 | } | |
1511 | ||
1512 | ans = scm_uniform_vector_read_x (SCM_I_ARRAY_V (cra), port_or_fd, | |
1513 | scm_from_size_t (base + cstart), | |
1514 | scm_from_size_t (base + cend)); | |
1515 | ||
1516 | if (!scm_is_eq (cra, ura)) | |
1517 | scm_array_copy_x (cra, ura); | |
1518 | return ans; | |
1519 | } | |
1520 | else | |
1521 | scm_wrong_type_arg_msg (NULL, 0, ura, "array"); | |
1f366ef7 | 1522 | } |
a2689737 | 1523 | #undef FUNC_NAME |
1f366ef7 | 1524 | |
a2689737 AW |
1525 | SCM_DEFINE (scm_uniform_array_write, "uniform-array-write", 1, 3, 0, |
1526 | (SCM ura, SCM port_or_fd, SCM start, SCM end), | |
1527 | "Writes all elements of @var{ura} as binary objects to\n" | |
1528 | "@var{port-or-fdes}.\n\n" | |
1529 | "The optional arguments @var{start}\n" | |
1530 | "and @var{end} allow\n" | |
1531 | "a specified region of a vector (or linearized array) to be written.\n\n" | |
1532 | "The number of objects actually written is returned.\n" | |
1533 | "@var{port-or-fdes} may be\n" | |
1534 | "omitted, in which case it defaults to the value returned by\n" | |
1535 | "@code{(current-output-port)}.") | |
1536 | #define FUNC_NAME s_scm_uniform_array_write | |
1537 | { | |
1538 | if (SCM_UNBNDP (port_or_fd)) | |
1539 | port_or_fd = scm_current_output_port (); | |
1540 | ||
1541 | if (scm_is_uniform_vector (ura)) | |
1542 | { | |
1543 | return scm_uniform_vector_write (ura, port_or_fd, start, end); | |
1544 | } | |
1545 | else if (SCM_I_ARRAYP (ura)) | |
1546 | { | |
1547 | size_t base, vlen, cstart, cend; | |
1548 | SCM cra, ans; | |
1549 | ||
1550 | cra = scm_ra2contig (ura, 1); | |
1551 | base = SCM_I_ARRAY_BASE (cra); | |
1552 | vlen = SCM_I_ARRAY_DIMS (cra)->inc * | |
1553 | (SCM_I_ARRAY_DIMS (cra)->ubnd - SCM_I_ARRAY_DIMS (cra)->lbnd + 1); | |
1554 | ||
1555 | cstart = 0; | |
1556 | cend = vlen; | |
1557 | if (!SCM_UNBNDP (start)) | |
1558 | { | |
1559 | cstart = scm_to_unsigned_integer (start, 0, vlen); | |
1560 | if (!SCM_UNBNDP (end)) | |
1561 | cend = scm_to_unsigned_integer (end, cstart, vlen); | |
1562 | } | |
1563 | ||
1564 | ans = scm_uniform_vector_write (SCM_I_ARRAY_V (cra), port_or_fd, | |
1565 | scm_from_size_t (base + cstart), | |
1566 | scm_from_size_t (base + cend)); | |
1567 | ||
1568 | return ans; | |
1569 | } | |
1570 | else | |
1571 | scm_wrong_type_arg_msg (NULL, 0, ura, "array"); | |
1f366ef7 | 1572 | } |
a2689737 | 1573 | #undef FUNC_NAME |
1f366ef7 | 1574 | |
9de87eea MV |
1575 | SCM |
1576 | scm_i_cur_inp (void) | |
1577 | { | |
1578 | scm_c_issue_deprecation_warning | |
1579 | ("scm_cur_inp is deprecated. Use scm_current_input_port instead."); | |
1580 | return scm_current_input_port (); | |
1581 | } | |
1582 | ||
1583 | SCM | |
1584 | scm_i_cur_outp (void) | |
1585 | { | |
1586 | scm_c_issue_deprecation_warning | |
1587 | ("scm_cur_outp is deprecated. Use scm_current_output_port instead."); | |
1588 | return scm_current_output_port (); | |
1589 | } | |
1590 | ||
1591 | SCM | |
1592 | scm_i_cur_errp (void) | |
1593 | { | |
1594 | scm_c_issue_deprecation_warning | |
1595 | ("scm_cur_errp is deprecated. Use scm_current_error_port instead."); | |
1596 | return scm_current_error_port (); | |
1597 | } | |
1598 | ||
1599 | SCM | |
1600 | scm_i_cur_loadp (void) | |
1601 | { | |
1602 | scm_c_issue_deprecation_warning | |
1603 | ("scm_cur_loadp is deprecated. Use scm_current_load_port instead."); | |
1604 | return scm_current_load_port (); | |
1605 | } | |
1606 | ||
1607 | SCM | |
1608 | scm_i_progargs (void) | |
1609 | { | |
1610 | scm_c_issue_deprecation_warning | |
1611 | ("scm_progargs is deprecated. Use scm_program_arguments instead."); | |
1612 | return scm_program_arguments (); | |
1613 | } | |
1614 | ||
1615 | SCM | |
1616 | scm_i_deprecated_dynwinds (void) | |
1617 | { | |
1618 | scm_c_issue_deprecation_warning | |
1619 | ("scm_dynwinds is deprecated. Do not use it."); | |
1620 | return scm_i_dynwinds (); | |
1621 | } | |
1622 | ||
9de87eea MV |
1623 | SCM_STACKITEM * |
1624 | scm_i_stack_base (void) | |
1625 | { | |
1626 | scm_c_issue_deprecation_warning | |
1627 | ("scm_stack_base is deprecated. Do not use it."); | |
1628 | return SCM_I_CURRENT_THREAD->base; | |
1629 | } | |
1630 | ||
1631 | int | |
1632 | scm_i_fluidp (SCM x) | |
1633 | { | |
1634 | scm_c_issue_deprecation_warning | |
1635 | ("SCM_FLUIDP is deprecated. Use scm_is_fluid instead."); | |
1636 | return scm_is_fluid (x); | |
1637 | } | |
1638 | ||
3452e666 LC |
1639 | \f |
1640 | /* Networking. */ | |
1641 | ||
1040b205 LC |
1642 | #ifdef HAVE_NETWORKING |
1643 | ||
1644 | SCM_DEFINE (scm_inet_aton, "inet-aton", 1, 0, 0, | |
3452e666 LC |
1645 | (SCM address), |
1646 | "Convert an IPv4 Internet address from printable string\n" | |
1647 | "(dotted decimal notation) to an integer. E.g.,\n\n" | |
1648 | "@lisp\n" | |
1649 | "(inet-aton \"127.0.0.1\") @result{} 2130706433\n" | |
1650 | "@end lisp") | |
1651 | #define FUNC_NAME s_scm_inet_aton | |
1652 | { | |
1653 | scm_c_issue_deprecation_warning | |
1654 | ("`inet-aton' is deprecated. Use `inet-pton' instead."); | |
1655 | ||
1656 | return scm_inet_pton (scm_from_int (AF_INET), address); | |
1657 | } | |
1658 | #undef FUNC_NAME | |
1659 | ||
1660 | ||
1040b205 | 1661 | SCM_DEFINE (scm_inet_ntoa, "inet-ntoa", 1, 0, 0, |
3452e666 LC |
1662 | (SCM inetid), |
1663 | "Convert an IPv4 Internet address to a printable\n" | |
1664 | "(dotted decimal notation) string. E.g.,\n\n" | |
1665 | "@lisp\n" | |
1666 | "(inet-ntoa 2130706433) @result{} \"127.0.0.1\"\n" | |
1667 | "@end lisp") | |
1668 | #define FUNC_NAME s_scm_inet_ntoa | |
1669 | { | |
1670 | scm_c_issue_deprecation_warning | |
1671 | ("`inet-ntoa' is deprecated. Use `inet-ntop' instead."); | |
1672 | ||
1673 | return scm_inet_ntop (scm_from_int (AF_INET), inetid); | |
1674 | } | |
1675 | #undef FUNC_NAME | |
1676 | ||
1040b205 | 1677 | #endif /* HAVE_NETWORKING */ |
3452e666 LC |
1678 | |
1679 | \f | |
9de87eea MV |
1680 | void |
1681 | scm_i_defer_ints_etc () | |
1682 | { | |
1683 | scm_c_issue_deprecation_warning | |
2b829bbb | 1684 | ("SCM_DEFER_INTS etc are deprecated. " |
9de87eea MV |
1685 | "Use a mutex instead if appropriate."); |
1686 | } | |
1687 | ||
b8ec9dab LC |
1688 | int |
1689 | scm_i_mask_ints (void) | |
1690 | { | |
1691 | scm_c_issue_deprecation_warning ("`scm_mask_ints' is deprecated."); | |
1692 | return (SCM_I_CURRENT_THREAD->block_asyncs != 0); | |
1693 | } | |
1694 | ||
1695 | \f | |
06c1d900 MV |
1696 | SCM |
1697 | scm_guard (SCM guardian, SCM obj, int throw_p) | |
1698 | { | |
1699 | scm_c_issue_deprecation_warning | |
1700 | ("scm_guard is deprecated. Use scm_call_1 instead."); | |
1701 | ||
1702 | return scm_call_1 (guardian, obj); | |
1703 | } | |
1704 | ||
1705 | SCM | |
1706 | scm_get_one_zombie (SCM guardian) | |
1707 | { | |
1708 | scm_c_issue_deprecation_warning | |
1709 | ("scm_guard is deprecated. Use scm_call_0 instead."); | |
1710 | ||
1711 | return scm_call_0 (guardian); | |
1712 | } | |
1713 | ||
1714 | SCM_DEFINE (scm_guardian_destroyed_p, "guardian-destroyed?", 1, 0, 0, | |
1715 | (SCM guardian), | |
1716 | "Return @code{#t} if @var{guardian} has been destroyed, otherwise @code{#f}.") | |
1717 | #define FUNC_NAME s_scm_guardian_destroyed_p | |
1718 | { | |
1719 | scm_c_issue_deprecation_warning | |
1720 | ("'guardian-destroyed?' is deprecated."); | |
1721 | return SCM_BOOL_F; | |
1722 | } | |
1723 | #undef FUNC_NAME | |
1724 | ||
1725 | SCM_DEFINE (scm_guardian_greedy_p, "guardian-greedy?", 1, 0, 0, | |
1726 | (SCM guardian), | |
1727 | "Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}.") | |
1728 | #define FUNC_NAME s_scm_guardian_greedy_p | |
1729 | { | |
1730 | scm_c_issue_deprecation_warning | |
1731 | ("'guardian-greedy?' is deprecated."); | |
1732 | return SCM_BOOL_F; | |
1733 | } | |
1734 | #undef FUNC_NAME | |
1735 | ||
1736 | SCM_DEFINE (scm_destroy_guardian_x, "destroy-guardian!", 1, 0, 0, | |
1737 | (SCM guardian), | |
1738 | "Destroys @var{guardian}, by making it impossible to put any more\n" | |
1739 | "objects in it or get any objects from it. It also unguards any\n" | |
1740 | "objects guarded by @var{guardian}.") | |
1741 | #define FUNC_NAME s_scm_destroy_guardian_x | |
1742 | { | |
1743 | scm_c_issue_deprecation_warning | |
1744 | ("'destroy-guardian!' is deprecated and ineffective."); | |
1745 | return SCM_UNSPECIFIED; | |
1746 | } | |
1747 | #undef FUNC_NAME | |
1748 | ||
760fb97d LC |
1749 | \f |
1750 | /* GC-related things. */ | |
1751 | ||
1752 | unsigned long scm_mallocated, scm_mtrigger; | |
1753 | size_t scm_max_segment_size; | |
1754 | ||
1755 | #if defined (GUILE_DEBUG) || defined (GUILE_DEBUG_FREELIST) | |
1756 | SCM | |
1757 | scm_map_free_list (void) | |
1758 | { | |
1759 | return SCM_EOL; | |
1760 | } | |
1761 | #endif | |
1762 | ||
1763 | #if defined (GUILE_DEBUG_FREELIST) | |
1764 | SCM | |
1765 | scm_gc_set_debug_check_freelist_x (SCM flag) | |
1766 | { | |
1767 | return SCM_UNSPECIFIED; | |
1768 | } | |
1769 | #endif | |
1770 | ||
1771 | \f | |
a3e92377 AW |
1772 | /* Trampolines |
1773 | * | |
1774 | * Trampolines were an intent to speed up calling the same Scheme procedure many | |
1775 | * times from C. | |
1776 | * | |
1777 | * However, this was the wrong thing to optimize; if you really know what you're | |
1778 | * calling, call its function directly, otherwise you're in Scheme-land, and we | |
1779 | * have many better tricks there (inlining, for example, which can remove the | |
1780 | * need for closures and free variables). | |
1781 | * | |
1782 | * Also, in the normal debugging case, trampolines were being computed but not | |
1783 | * used. Silliness. | |
1784 | */ | |
1785 | ||
1786 | scm_t_trampoline_0 | |
1787 | scm_trampoline_0 (SCM proc) | |
1788 | { | |
1789 | scm_c_issue_deprecation_warning | |
1790 | ("`scm_trampoline_0' is deprecated. Just use `scm_call_0' instead."); | |
1791 | return scm_call_0; | |
1792 | } | |
1793 | ||
1794 | scm_t_trampoline_1 | |
1795 | scm_trampoline_1 (SCM proc) | |
1796 | { | |
1797 | scm_c_issue_deprecation_warning | |
1798 | ("`scm_trampoline_1' is deprecated. Just use `scm_call_1' instead."); | |
1799 | return scm_call_1; | |
1800 | } | |
1801 | ||
1802 | scm_t_trampoline_2 | |
1803 | scm_trampoline_2 (SCM proc) | |
1804 | { | |
1805 | scm_c_issue_deprecation_warning | |
1806 | ("`scm_trampoline_2' is deprecated. Just use `scm_call_2' instead."); | |
1807 | return scm_call_2; | |
1808 | } | |
1809 | ||
97812f4d AW |
1810 | int |
1811 | scm_i_subr_p (SCM x) | |
1812 | { | |
1813 | scm_c_issue_deprecation_warning ("`scm_subr_p' is deprecated. Use SCM_PRIMITIVE_P instead."); | |
1814 | return SCM_PRIMITIVE_P (x); | |
1815 | } | |
1816 | ||
a3e92377 | 1817 | \f |
e10cf6b9 AW |
1818 | |
1819 | SCM | |
1820 | scm_internal_lazy_catch (SCM tag, scm_t_catch_body body, void *body_data, scm_t_catch_handler handler, void *handler_data) | |
1821 | { | |
1822 | scm_c_issue_deprecation_warning | |
1823 | ("`scm_internal_lazy_catch' is no longer supported. Instead this call will\n" | |
1824 | "dispatch to `scm_c_with_throw_handler'. Your handler will be invoked from\n" | |
1825 | "within the dynamic context of the corresponding `throw'.\n" | |
1826 | "\nTHIS COULD CHANGE YOUR PROGRAM'S BEHAVIOR.\n\n" | |
1827 | "Please modify your program to use `scm_c_with_throw_handler' directly,\n" | |
1828 | "and adapt it (if necessary) to expect to be within the dynamic context\n" | |
1829 | "of the throw."); | |
1830 | return scm_c_with_throw_handler (tag, body, body_data, handler, handler_data, 0); | |
1831 | } | |
1832 | ||
1833 | SCM_DEFINE (scm_lazy_catch, "lazy-catch", 3, 0, 0, | |
1834 | (SCM key, SCM thunk, SCM handler), | |
1835 | "This behaves exactly like @code{catch}, except that it does\n" | |
1836 | "not unwind the stack before invoking @var{handler}.\n" | |
1837 | "If the @var{handler} procedure returns normally, Guile\n" | |
1838 | "rethrows the same exception again to the next innermost catch,\n" | |
1839 | "lazy-catch or throw handler. If the @var{handler} exits\n" | |
1840 | "non-locally, that exit determines the continuation.") | |
1841 | #define FUNC_NAME s_scm_lazy_catch | |
1842 | { | |
1843 | struct scm_body_thunk_data c; | |
1844 | ||
1845 | SCM_ASSERT (scm_is_symbol (key) || scm_is_eq (key, SCM_BOOL_T), | |
1846 | key, SCM_ARG1, FUNC_NAME); | |
1847 | ||
1848 | c.tag = key; | |
1849 | c.body_proc = thunk; | |
1850 | ||
1851 | scm_c_issue_deprecation_warning | |
1852 | ("`lazy-catch' is no longer supported. Instead this call will dispatch\n" | |
1853 | "to `with-throw-handler'. Your handler will be invoked from within the\n" | |
1854 | "dynamic context of the corresponding `throw'.\n" | |
1855 | "\nTHIS COULD CHANGE YOUR PROGRAM'S BEHAVIOR.\n\n" | |
1856 | "Please modify your program to use `with-throw-handler' directly, and\n" | |
1857 | "adapt it (if necessary) to expect to be within the dynamic context of\n" | |
1858 | "the throw."); | |
1859 | ||
1860 | return scm_c_with_throw_handler (key, | |
1861 | scm_body_thunk, &c, | |
1862 | scm_handle_by_proc, &handler, 0); | |
1863 | } | |
1864 | #undef FUNC_NAME | |
1865 | ||
1866 | ||
1867 | \f | |
a587d6a9 AW |
1868 | |
1869 | ||
1870 | SCM | |
1871 | scm_raequal (SCM ra0, SCM ra1) | |
1872 | { | |
1873 | return scm_array_equal_p (ra0, ra1); | |
1874 | } | |
1875 | ||
1876 | ||
1877 | \f | |
43cd9cec AW |
1878 | |
1879 | ||
1880 | SCM_DEFINE (scm_dynamic_args_call, "dynamic-args-call", 3, 0, 0, | |
1881 | (SCM func, SCM dobj, SCM args), | |
1882 | "Call the C function indicated by @var{func} and @var{dobj},\n" | |
1883 | "just like @code{dynamic-call}, but pass it some arguments and\n" | |
1884 | "return its return value. The C function is expected to take\n" | |
1885 | "two arguments and return an @code{int}, just like @code{main}:\n" | |
1886 | "@smallexample\n" | |
1887 | "int c_func (int argc, char **argv);\n" | |
1888 | "@end smallexample\n\n" | |
1889 | "The parameter @var{args} must be a list of strings and is\n" | |
1890 | "converted into an array of @code{char *}. The array is passed\n" | |
1891 | "in @var{argv} and its size in @var{argc}. The return value is\n" | |
1892 | "converted to a Scheme number and returned from the call to\n" | |
1893 | "@code{dynamic-args-call}.") | |
1894 | #define FUNC_NAME s_scm_dynamic_args_call | |
1895 | { | |
1896 | int (*fptr) (int argc, char **argv); | |
1897 | int result, argc; | |
1898 | char **argv; | |
1899 | ||
1900 | if (scm_is_string (func)) | |
08969a24 AW |
1901 | { |
1902 | #if HAVE_MODULES | |
1903 | func = scm_dynamic_func (func, dobj); | |
1904 | #else | |
1905 | scm_misc_error ("dynamic-args-call", | |
1906 | "dynamic-func not available to resolve ~S", | |
1907 | scm_list_1 (func)); | |
1908 | #endif | |
1909 | } | |
5b46a8c2 | 1910 | SCM_VALIDATE_POINTER (SCM_ARG1, func); |
43cd9cec | 1911 | |
5b46a8c2 | 1912 | fptr = SCM_POINTER_VALUE (func); |
43cd9cec AW |
1913 | |
1914 | argv = scm_i_allocate_string_pointers (args); | |
1915 | for (argc = 0; argv[argc]; argc++) | |
1916 | ; | |
1917 | result = (*fptr) (argc, argv); | |
1918 | ||
1919 | return scm_from_int (result); | |
1920 | } | |
1921 | #undef FUNC_NAME | |
1922 | ||
1923 | ||
1924 | \f | |
1925 | ||
cc00f447 AW |
1926 | |
1927 | int | |
1928 | scm_badargsp (SCM formals, SCM args) | |
1929 | { | |
1930 | scm_c_issue_deprecation_warning | |
1931 | ("`scm_badargsp' is deprecated. Copy it into your project if you need it."); | |
1932 | ||
1933 | while (!scm_is_null (formals)) | |
1934 | { | |
1935 | if (!scm_is_pair (formals)) | |
1936 | return 0; | |
1937 | if (scm_is_null (args)) | |
1938 | return 1; | |
1939 | formals = scm_cdr (formals); | |
1940 | args = scm_cdr (args); | |
1941 | } | |
1942 | return !scm_is_null (args) ? 1 : 0; | |
1943 | } | |
1944 | ||
1945 | \f | |
1946 | ||
ec16eb78 AW |
1947 | /* scm_internal_stack_catch |
1948 | Use this one if you want debugging information to be stored in | |
1949 | the-last-stack on error. */ | |
1950 | ||
1951 | static SCM | |
1952 | ss_handler (void *data SCM_UNUSED, SCM tag, SCM throw_args) | |
1953 | { | |
1954 | /* In the stack */ | |
1955 | scm_fluid_set_x (scm_variable_ref | |
1956 | (scm_c_module_lookup | |
1957 | (scm_c_resolve_module ("ice-9 save-stack"), | |
1958 | "the-last-stack")), | |
1959 | scm_make_stack (SCM_BOOL_T, SCM_EOL)); | |
1960 | /* Throw the error */ | |
1961 | return scm_throw (tag, throw_args); | |
1962 | } | |
1963 | ||
1964 | struct cwss_data | |
1965 | { | |
1966 | SCM tag; | |
1967 | scm_t_catch_body body; | |
1968 | void *data; | |
1969 | }; | |
1970 | ||
1971 | static SCM | |
1972 | cwss_body (void *data) | |
1973 | { | |
1974 | struct cwss_data *d = data; | |
1975 | return scm_c_with_throw_handler (d->tag, d->body, d->data, ss_handler, NULL, 0); | |
1976 | } | |
1977 | ||
1978 | SCM | |
1979 | scm_internal_stack_catch (SCM tag, | |
1980 | scm_t_catch_body body, | |
1981 | void *body_data, | |
1982 | scm_t_catch_handler handler, | |
1983 | void *handler_data) | |
1984 | { | |
1985 | struct cwss_data d; | |
1986 | d.tag = tag; | |
1987 | d.body = body; | |
1988 | d.data = body_data; | |
1989 | scm_c_issue_deprecation_warning | |
1990 | ("`scm_internal_stack_catch' is deprecated. Talk to guile-devel if you see this message."); | |
1991 | return scm_internal_catch (tag, cwss_body, &d, handler, handler_data); | |
1992 | } | |
1993 | ||
1994 | \f | |
1995 | ||
220058a8 AW |
1996 | SCM |
1997 | scm_short2num (short x) | |
1998 | { | |
1999 | scm_c_issue_deprecation_warning | |
2000 | ("`scm_short2num' is deprecated. Use scm_from_short instead."); | |
2001 | return scm_from_short (x); | |
2002 | } | |
2003 | ||
2004 | SCM | |
2005 | scm_ushort2num (unsigned short x) | |
2006 | { | |
2007 | scm_c_issue_deprecation_warning | |
2008 | ("`scm_ushort2num' is deprecated. Use scm_from_ushort instead."); | |
2009 | return scm_from_ushort (x); | |
2010 | } | |
2011 | ||
2012 | SCM | |
2013 | scm_int2num (int x) | |
2014 | { | |
2015 | scm_c_issue_deprecation_warning | |
2016 | ("`scm_int2num' is deprecated. Use scm_from_int instead."); | |
2017 | return scm_from_int (x); | |
2018 | } | |
2019 | ||
2020 | SCM | |
2021 | scm_uint2num (unsigned int x) | |
2022 | { | |
2023 | scm_c_issue_deprecation_warning | |
2024 | ("`scm_uint2num' is deprecated. Use scm_from_uint instead."); | |
2025 | return scm_from_uint (x); | |
2026 | } | |
2027 | ||
2028 | SCM | |
2029 | scm_long2num (long x) | |
2030 | { | |
2031 | scm_c_issue_deprecation_warning | |
2032 | ("`scm_long2num' is deprecated. Use scm_from_long instead."); | |
2033 | return scm_from_long (x); | |
2034 | } | |
2035 | ||
2036 | SCM | |
2037 | scm_ulong2num (unsigned long x) | |
2038 | { | |
2039 | scm_c_issue_deprecation_warning | |
2040 | ("`scm_ulong2num' is deprecated. Use scm_from_ulong instead."); | |
2041 | return scm_from_ulong (x); | |
2042 | } | |
2043 | ||
2044 | SCM | |
2045 | scm_size2num (size_t x) | |
2046 | { | |
2047 | scm_c_issue_deprecation_warning | |
2048 | ("`scm_size2num' is deprecated. Use scm_from_size_t instead."); | |
2049 | return scm_from_size_t (x); | |
2050 | } | |
2051 | ||
2052 | SCM | |
2053 | scm_ptrdiff2num (ptrdiff_t x) | |
2054 | { | |
2055 | scm_c_issue_deprecation_warning | |
2056 | ("`scm_ptrdiff2num' is deprecated. Use scm_from_ssize_t instead."); | |
2057 | return scm_from_ssize_t (x); | |
2058 | } | |
2059 | ||
2060 | short | |
2061 | scm_num2short (SCM x, unsigned long pos, const char *s_caller) | |
2062 | { | |
2063 | scm_c_issue_deprecation_warning | |
2064 | ("`scm_num2short' is deprecated. Use scm_to_short instead."); | |
2065 | return scm_to_short (x); | |
2066 | } | |
2067 | ||
2068 | unsigned short | |
2069 | scm_num2ushort (SCM x, unsigned long pos, const char *s_caller) | |
2070 | { | |
2071 | scm_c_issue_deprecation_warning | |
2072 | ("`scm_num2ushort' is deprecated. Use scm_to_ushort instead."); | |
2073 | return scm_to_ushort (x); | |
2074 | } | |
2075 | ||
2076 | int | |
2077 | scm_num2int (SCM x, unsigned long pos, const char *s_caller) | |
2078 | { | |
2079 | scm_c_issue_deprecation_warning | |
2080 | ("`scm_num2int' is deprecated. Use scm_to_int instead."); | |
2081 | return scm_to_int (x); | |
2082 | } | |
2083 | ||
2084 | unsigned int | |
2085 | scm_num2uint (SCM x, unsigned long pos, const char *s_caller) | |
2086 | { | |
2087 | scm_c_issue_deprecation_warning | |
2088 | ("`scm_num2uint' is deprecated. Use scm_to_uint instead."); | |
2089 | return scm_to_uint (x); | |
2090 | } | |
2091 | ||
2092 | long | |
2093 | scm_num2long (SCM x, unsigned long pos, const char *s_caller) | |
2094 | { | |
2095 | scm_c_issue_deprecation_warning | |
2096 | ("`scm_num2long' is deprecated. Use scm_to_long instead."); | |
2097 | return scm_to_long (x); | |
2098 | } | |
2099 | ||
2100 | unsigned long | |
2101 | scm_num2ulong (SCM x, unsigned long pos, const char *s_caller) | |
2102 | { | |
2103 | scm_c_issue_deprecation_warning | |
2104 | ("`scm_num2ulong' is deprecated. Use scm_to_ulong instead."); | |
2105 | return scm_to_ulong (x); | |
2106 | } | |
2107 | ||
2108 | size_t | |
2109 | scm_num2size (SCM x, unsigned long pos, const char *s_caller) | |
2110 | { | |
2111 | scm_c_issue_deprecation_warning | |
2112 | ("`scm_num2size' is deprecated. Use scm_to_size_t instead."); | |
2113 | return scm_to_size_t (x); | |
2114 | } | |
2115 | ||
2116 | ptrdiff_t | |
2117 | scm_num2ptrdiff (SCM x, unsigned long pos, const char *s_caller) | |
2118 | { | |
2119 | scm_c_issue_deprecation_warning | |
2120 | ("`scm_num2ptrdiff' is deprecated. Use scm_to_ssize_t instead."); | |
2121 | return scm_to_ssize_t (x); | |
2122 | } | |
2123 | ||
2124 | #if SCM_SIZEOF_LONG_LONG != 0 | |
2125 | ||
2126 | SCM | |
2127 | scm_long_long2num (long long x) | |
2128 | { | |
2129 | scm_c_issue_deprecation_warning | |
2130 | ("`scm_long_long2num' is deprecated. Use scm_from_long_long instead."); | |
2131 | return scm_from_long_long (x); | |
2132 | } | |
2133 | ||
2134 | SCM | |
2135 | scm_ulong_long2num (unsigned long long x) | |
2136 | { | |
2137 | scm_c_issue_deprecation_warning | |
2138 | ("`scm_ulong_long2num' is deprecated. Use scm_from_ulong_long instead."); | |
2139 | return scm_from_ulong_long (x); | |
2140 | } | |
2141 | ||
2142 | long long | |
2143 | scm_num2long_long (SCM x, unsigned long pos, const char *s_caller) | |
2144 | { | |
2145 | scm_c_issue_deprecation_warning | |
2146 | ("`scm_num2long_long' is deprecated. Use scm_to_long_long instead."); | |
2147 | return scm_to_long_long (x); | |
2148 | } | |
2149 | ||
2150 | unsigned long long | |
2151 | scm_num2ulong_long (SCM x, unsigned long pos, const char *s_caller) | |
2152 | { | |
2153 | scm_c_issue_deprecation_warning | |
2154 | ("`scm_num2ulong_long' is deprecated. Use scm_from_ulong_long instead."); | |
2155 | return scm_to_ulong_long (x); | |
2156 | } | |
2157 | ||
2158 | #endif | |
2159 | ||
2160 | SCM | |
2161 | scm_make_real (double x) | |
2162 | { | |
2163 | scm_c_issue_deprecation_warning | |
2164 | ("`scm_make_real' is deprecated. Use scm_from_double instead."); | |
2165 | return scm_from_double (x); | |
2166 | } | |
2167 | ||
2168 | double | |
2169 | scm_num2dbl (SCM a, const char *why) | |
2170 | { | |
2171 | scm_c_issue_deprecation_warning | |
2172 | ("`scm_num2dbl' is deprecated. Use scm_to_double instead."); | |
2173 | return scm_to_double (a); | |
2174 | } | |
2175 | ||
2176 | SCM | |
2177 | scm_float2num (float n) | |
2178 | { | |
2179 | scm_c_issue_deprecation_warning | |
2180 | ("`scm_float2num' is deprecated. Use scm_from_double instead."); | |
2181 | return scm_from_double ((double) n); | |
2182 | } | |
2183 | ||
2184 | SCM | |
2185 | scm_double2num (double n) | |
2186 | { | |
2187 | scm_c_issue_deprecation_warning | |
2188 | ("`scm_double2num' is deprecated. Use scm_from_double instead."); | |
2189 | return scm_from_double (n); | |
2190 | } | |
2191 | ||
2192 | SCM | |
2193 | scm_make_complex (double x, double y) | |
2194 | { | |
2195 | scm_c_issue_deprecation_warning | |
2196 | ("`scm_make_complex' is deprecated. Use scm_c_make_rectangular instead."); | |
2197 | return scm_c_make_rectangular (x, y); | |
2198 | } | |
2199 | ||
2200 | SCM | |
2201 | scm_mem2symbol (const char *mem, size_t len) | |
2202 | { | |
2203 | scm_c_issue_deprecation_warning | |
2204 | ("`scm_mem2symbol' is deprecated. Use scm_from_locale_symboln instead."); | |
2205 | return scm_from_locale_symboln (mem, len); | |
2206 | } | |
2207 | ||
2208 | SCM | |
2209 | scm_mem2uninterned_symbol (const char *mem, size_t len) | |
2210 | { | |
2211 | scm_c_issue_deprecation_warning | |
2212 | ("`scm_mem2uninterned_symbol' is deprecated. " | |
2213 | "Use scm_make_symbol and scm_from_locale_symboln instead."); | |
2214 | return scm_make_symbol (scm_from_locale_stringn (mem, len)); | |
2215 | } | |
2216 | ||
2217 | SCM | |
2218 | scm_str2symbol (const char *str) | |
2219 | { | |
2220 | scm_c_issue_deprecation_warning | |
2221 | ("`scm_str2symbol' is deprecated. Use scm_from_locale_symbol instead."); | |
2222 | return scm_from_locale_symbol (str); | |
2223 | } | |
2224 | ||
2225 | ||
2226 | /* This function must only be applied to memory obtained via malloc, | |
2227 | since the GC is going to apply `free' to it when the string is | |
2228 | dropped. | |
2229 | ||
2230 | Also, s[len] must be `\0', since we promise that strings are | |
2231 | null-terminated. Perhaps we could handle non-null-terminated | |
2232 | strings by claiming they're shared substrings of a string we just | |
2233 | made up. */ | |
2234 | SCM | |
2235 | scm_take_str (char *s, size_t len) | |
2236 | { | |
2237 | scm_c_issue_deprecation_warning | |
2238 | ("`scm_take_str' is deprecated. Use scm_take_locale_stringn instead."); | |
2239 | return scm_take_locale_stringn (s, len); | |
2240 | } | |
2241 | ||
2242 | /* `s' must be a malloc'd string. See scm_take_str. */ | |
2243 | SCM | |
2244 | scm_take0str (char *s) | |
2245 | { | |
2246 | scm_c_issue_deprecation_warning | |
2247 | ("`scm_take0str' is deprecated. Use scm_take_locale_string instead."); | |
2248 | return scm_take_locale_string (s); | |
2249 | } | |
2250 | ||
2251 | SCM | |
2252 | scm_mem2string (const char *src, size_t len) | |
2253 | { | |
2254 | scm_c_issue_deprecation_warning | |
2255 | ("`scm_mem2string' is deprecated. Use scm_from_locale_stringn instead."); | |
2256 | return scm_from_locale_stringn (src, len); | |
2257 | } | |
2258 | ||
2259 | SCM | |
2260 | scm_str2string (const char *src) | |
2261 | { | |
2262 | scm_c_issue_deprecation_warning | |
2263 | ("`scm_str2string' is deprecated. Use scm_from_locale_string instead."); | |
2264 | return scm_from_locale_string (src); | |
2265 | } | |
2266 | ||
2267 | SCM | |
2268 | scm_makfrom0str (const char *src) | |
2269 | { | |
2270 | scm_c_issue_deprecation_warning | |
2271 | ("`scm_makfrom0str' is deprecated." | |
2272 | "Use scm_from_locale_string instead, but check for NULL first."); | |
2273 | if (!src) return SCM_BOOL_F; | |
2274 | return scm_from_locale_string (src); | |
2275 | } | |
2276 | ||
2277 | SCM | |
2278 | scm_makfrom0str_opt (const char *src) | |
2279 | { | |
2280 | scm_c_issue_deprecation_warning | |
2281 | ("`scm_makfrom0str_opt' is deprecated." | |
2282 | "Use scm_from_locale_string instead, but check for NULL first."); | |
2283 | return scm_makfrom0str (src); | |
2284 | } | |
2285 | ||
2286 | ||
2287 | SCM | |
2288 | scm_allocate_string (size_t len) | |
2289 | { | |
2290 | scm_c_issue_deprecation_warning | |
2291 | ("`scm_allocate_string' is deprecated. Use scm_c_make_string instead."); | |
190d4b0d | 2292 | return scm_i_make_string (len, NULL, 0); |
220058a8 AW |
2293 | } |
2294 | ||
2295 | SCM_DEFINE (scm_make_keyword_from_dash_symbol, "make-keyword-from-dash-symbol", 1, 0, 0, | |
2296 | (SCM symbol), | |
2297 | "Make a keyword object from a @var{symbol} that starts with a dash.") | |
2298 | #define FUNC_NAME s_scm_make_keyword_from_dash_symbol | |
2299 | { | |
2300 | SCM dash_string, non_dash_symbol; | |
2301 | ||
2302 | scm_c_issue_deprecation_warning | |
2303 | ("`scm_make_keyword_from_dash_symbol' is deprecated. Don't use dash symbols."); | |
2304 | ||
2305 | SCM_ASSERT (scm_is_symbol (symbol) | |
2306 | && (scm_i_symbol_ref (symbol, 0) == '-'), | |
2307 | symbol, SCM_ARG1, FUNC_NAME); | |
2308 | ||
2309 | dash_string = scm_symbol_to_string (symbol); | |
2310 | non_dash_symbol = | |
2311 | scm_string_to_symbol (scm_c_substring (dash_string, | |
2312 | 1, | |
2313 | scm_c_string_length (dash_string))); | |
2314 | ||
2315 | return scm_symbol_to_keyword (non_dash_symbol); | |
2316 | } | |
2317 | #undef FUNC_NAME | |
2318 | ||
2319 | SCM_DEFINE (scm_keyword_dash_symbol, "keyword-dash-symbol", 1, 0, 0, | |
2320 | (SCM keyword), | |
2321 | "Return the dash symbol for @var{keyword}.\n" | |
2322 | "This is the inverse of @code{make-keyword-from-dash-symbol}.") | |
2323 | #define FUNC_NAME s_scm_keyword_dash_symbol | |
2324 | { | |
2325 | SCM symbol = scm_keyword_to_symbol (keyword); | |
2326 | SCM parts = scm_list_2 (scm_from_locale_string ("-"), | |
2327 | scm_symbol_to_string (symbol)); | |
2328 | scm_c_issue_deprecation_warning | |
2329 | ("`scm_keyword_dash_symbol' is deprecated. Don't use dash symbols."); | |
2330 | ||
2331 | return scm_string_to_symbol (scm_string_append (parts)); | |
2332 | } | |
2333 | #undef FUNC_NAME | |
2334 | ||
2335 | SCM | |
2336 | scm_c_make_keyword (const char *s) | |
2337 | { | |
2338 | scm_c_issue_deprecation_warning | |
2339 | ("`scm_c_make_keyword' is deprecated. Use scm_from_locale_keyword instead."); | |
2340 | return scm_from_locale_keyword (s); | |
2341 | } | |
2342 | ||
8a4ed2dd AW |
2343 | unsigned int |
2344 | scm_thread_sleep (unsigned int t) | |
2345 | { | |
2346 | scm_c_issue_deprecation_warning | |
2347 | ("`scm_thread_sleep' is deprecated. Use scm_std_sleep instead."); | |
2348 | return scm_std_sleep (t); | |
2349 | } | |
2350 | ||
2351 | unsigned long | |
2352 | scm_thread_usleep (unsigned long t) | |
2353 | { | |
2354 | scm_c_issue_deprecation_warning | |
2355 | ("`scm_thread_usleep' is deprecated. Use scm_std_usleep instead."); | |
2356 | return scm_std_usleep (t); | |
2357 | } | |
2358 | ||
2359 | int scm_internal_select (int fds, | |
2360 | SELECT_TYPE *rfds, | |
2361 | SELECT_TYPE *wfds, | |
2362 | SELECT_TYPE *efds, | |
2363 | struct timeval *timeout) | |
2364 | { | |
2365 | scm_c_issue_deprecation_warning | |
2366 | ("`scm_internal_select' is deprecated. Use scm_std_select instead."); | |
2367 | return scm_std_select (fds, rfds, wfds, efds, timeout); | |
2368 | } | |
2369 | ||
220058a8 AW |
2370 | \f |
2371 | ||
cd28785f AW |
2372 | #ifdef HAVE_CUSERID |
2373 | ||
2374 | # if !HAVE_DECL_CUSERID | |
2375 | extern char *cuserid (char *); | |
2376 | # endif | |
2377 | ||
2378 | SCM_DEFINE (scm_cuserid, "cuserid", 0, 0, 0, | |
2379 | (void), | |
2380 | "Return a string containing a user name associated with the\n" | |
2381 | "effective user id of the process. Return @code{#f} if this\n" | |
2382 | "information cannot be obtained.") | |
2383 | #define FUNC_NAME s_scm_cuserid | |
2384 | { | |
2385 | char buf[L_cuserid]; | |
2386 | char * p; | |
2387 | ||
2388 | scm_c_issue_deprecation_warning | |
2389 | ("`cuserid' is deprecated. Use `(passwd:name (getpwuid (geteuid)))' instead."); | |
2390 | ||
2391 | p = cuserid (buf); | |
2392 | if (!p || !*p) | |
2393 | return SCM_BOOL_F; | |
2394 | return scm_from_locale_string (p); | |
2395 | } | |
2396 | #undef FUNC_NAME | |
2397 | #endif /* HAVE_CUSERID */ | |
2398 | ||
2399 | \f | |
2400 | ||
79488112 AW |
2401 | /* {Properties} |
2402 | */ | |
2403 | ||
2404 | static SCM properties_whash; | |
2405 | ||
2406 | SCM_DEFINE (scm_primitive_make_property, "primitive-make-property", 1, 0, 0, | |
2407 | (SCM not_found_proc), | |
2408 | "Create a @dfn{property token} that can be used with\n" | |
2409 | "@code{primitive-property-ref} and @code{primitive-property-set!}.\n" | |
2410 | "See @code{primitive-property-ref} for the significance of\n" | |
2411 | "@var{not_found_proc}.") | |
2412 | #define FUNC_NAME s_scm_primitive_make_property | |
2413 | { | |
2414 | scm_c_issue_deprecation_warning | |
2415 | ("`primitive-make-property' is deprecated. Use object properties."); | |
2416 | ||
36722c63 | 2417 | if (!scm_is_false (not_found_proc)) |
79488112 AW |
2418 | SCM_VALIDATE_PROC (SCM_ARG1, not_found_proc); |
2419 | return scm_cons (not_found_proc, SCM_EOL); | |
2420 | } | |
2421 | #undef FUNC_NAME | |
2422 | ||
2423 | ||
2424 | SCM_DEFINE (scm_primitive_property_ref, "primitive-property-ref", 2, 0, 0, | |
2425 | (SCM prop, SCM obj), | |
2426 | "Return the property @var{prop} of @var{obj}.\n" | |
2427 | "\n" | |
2428 | "When no value has yet been associated with @var{prop} and\n" | |
2429 | "@var{obj}, the @var{not-found-proc} from @var{prop} is used. A\n" | |
2430 | "call @code{(@var{not-found-proc} @var{prop} @var{obj})} is made\n" | |
2431 | "and the result set as the property value. If\n" | |
2432 | "@var{not-found-proc} is @code{#f} then @code{#f} is the\n" | |
2433 | "property value.") | |
2434 | #define FUNC_NAME s_scm_primitive_property_ref | |
2435 | { | |
4466db75 | 2436 | SCM alist; |
79488112 AW |
2437 | |
2438 | scm_c_issue_deprecation_warning | |
2439 | ("`primitive-property-ref' is deprecated. Use object properties."); | |
2440 | ||
2441 | SCM_VALIDATE_CONS (SCM_ARG1, prop); | |
2442 | ||
4466db75 AW |
2443 | alist = scm_hashq_ref (properties_whash, obj, SCM_EOL); |
2444 | if (scm_is_pair (alist)) | |
79488112 | 2445 | { |
4466db75 | 2446 | SCM assoc = scm_assq (prop, alist); |
79488112 AW |
2447 | if (scm_is_true (assoc)) |
2448 | return SCM_CDR (assoc); | |
2449 | } | |
2450 | ||
2451 | if (scm_is_false (SCM_CAR (prop))) | |
2452 | return SCM_BOOL_F; | |
2453 | else | |
2454 | { | |
2455 | SCM val = scm_call_2 (SCM_CAR (prop), prop, obj); | |
4466db75 AW |
2456 | scm_hashq_set_x (properties_whash, obj, |
2457 | scm_acons (prop, val, alist)); | |
79488112 AW |
2458 | return val; |
2459 | } | |
2460 | } | |
2461 | #undef FUNC_NAME | |
2462 | ||
2463 | ||
2464 | SCM_DEFINE (scm_primitive_property_set_x, "primitive-property-set!", 3, 0, 0, | |
2465 | (SCM prop, SCM obj, SCM val), | |
2466 | "Set the property @var{prop} of @var{obj} to @var{val}.") | |
2467 | #define FUNC_NAME s_scm_primitive_property_set_x | |
2468 | { | |
4466db75 | 2469 | SCM alist, assoc; |
79488112 AW |
2470 | |
2471 | scm_c_issue_deprecation_warning | |
2472 | ("`primitive-property-set!' is deprecated. Use object properties."); | |
2473 | ||
2474 | SCM_VALIDATE_CONS (SCM_ARG1, prop); | |
4466db75 AW |
2475 | alist = scm_hashq_ref (properties_whash, obj, SCM_EOL); |
2476 | assoc = scm_assq (prop, alist); | |
2477 | if (scm_is_pair (assoc)) | |
79488112 AW |
2478 | SCM_SETCDR (assoc, val); |
2479 | else | |
4466db75 AW |
2480 | scm_hashq_set_x (properties_whash, obj, |
2481 | scm_acons (prop, val, alist)); | |
79488112 AW |
2482 | return SCM_UNSPECIFIED; |
2483 | } | |
2484 | #undef FUNC_NAME | |
2485 | ||
2486 | ||
2487 | SCM_DEFINE (scm_primitive_property_del_x, "primitive-property-del!", 2, 0, 0, | |
2488 | (SCM prop, SCM obj), | |
2489 | "Remove any value associated with @var{prop} and @var{obj}.") | |
2490 | #define FUNC_NAME s_scm_primitive_property_del_x | |
2491 | { | |
4466db75 | 2492 | SCM alist; |
79488112 AW |
2493 | |
2494 | scm_c_issue_deprecation_warning | |
2495 | ("`primitive-property-del!' is deprecated. Use object properties."); | |
2496 | ||
2497 | SCM_VALIDATE_CONS (SCM_ARG1, prop); | |
4466db75 AW |
2498 | alist = scm_hashq_ref (properties_whash, obj, SCM_EOL); |
2499 | if (scm_is_pair (alist)) | |
2500 | scm_hashq_set_x (properties_whash, obj, scm_assq_remove_x (alist, prop)); | |
79488112 AW |
2501 | return SCM_UNSPECIFIED; |
2502 | } | |
2503 | #undef FUNC_NAME | |
2504 | ||
2505 | \f | |
2506 | ||
d1c4720c AW |
2507 | SCM |
2508 | scm_whash_get_handle (SCM whash, SCM key) | |
2509 | { | |
2510 | scm_c_issue_deprecation_warning | |
2511 | ("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead."); | |
2512 | ||
2513 | return scm_hashq_get_handle (whash, key); | |
2514 | } | |
2515 | ||
2516 | int | |
2517 | SCM_WHASHFOUNDP (SCM h) | |
2518 | { | |
2519 | scm_c_issue_deprecation_warning | |
2520 | ("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead."); | |
2521 | ||
2522 | return scm_is_true (h); | |
2523 | } | |
2524 | ||
2525 | SCM | |
2526 | SCM_WHASHREF (SCM whash, SCM handle) | |
2527 | { | |
2528 | scm_c_issue_deprecation_warning | |
2529 | ("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead."); | |
2530 | ||
2531 | return SCM_CDR (handle); | |
2532 | } | |
2533 | ||
2534 | void | |
2535 | SCM_WHASHSET (SCM whash, SCM handle, SCM obj) | |
2536 | { | |
2537 | scm_c_issue_deprecation_warning | |
2538 | ("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead."); | |
2539 | ||
2540 | SCM_SETCDR (handle, obj); | |
2541 | } | |
2542 | ||
2543 | SCM | |
2544 | scm_whash_create_handle (SCM whash, SCM key) | |
2545 | { | |
2546 | scm_c_issue_deprecation_warning | |
2547 | ("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead."); | |
2548 | ||
2549 | return scm_hashq_create_handle_x (whash, key, SCM_UNSPECIFIED); | |
2550 | } | |
2551 | ||
2552 | SCM | |
2553 | scm_whash_lookup (SCM whash, SCM obj) | |
2554 | { | |
2555 | scm_c_issue_deprecation_warning | |
2556 | ("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead."); | |
2557 | ||
2558 | return scm_hashq_ref (whash, obj, SCM_BOOL_F); | |
2559 | } | |
2560 | ||
2561 | void | |
2562 | scm_whash_insert (SCM whash, SCM key, SCM obj) | |
2563 | { | |
2564 | scm_c_issue_deprecation_warning | |
2565 | ("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead."); | |
2566 | ||
2567 | scm_hashq_set_x (whash, key, obj); | |
2568 | } | |
2569 | ||
2570 | \f | |
79488112 | 2571 | |
f3c6a02c AW |
2572 | SCM scm_struct_table = SCM_BOOL_F; |
2573 | ||
2574 | SCM | |
2575 | scm_struct_create_handle (SCM obj) | |
2576 | { | |
2577 | scm_c_issue_deprecation_warning | |
2578 | ("`scm_struct_create_handle' is deprecated, and has no effect."); | |
2579 | ||
2580 | return scm_cons (obj, scm_cons (SCM_BOOL_F, SCM_BOOL_F)); | |
2581 | } | |
2582 | ||
2583 | \f | |
2584 | ||
b2feee6b AW |
2585 | SCM |
2586 | scm_internal_dynamic_wind (scm_t_guard before, | |
2587 | scm_t_inner inner, | |
2588 | scm_t_guard after, | |
2589 | void *inner_data, | |
2590 | void *guard_data) | |
2591 | { | |
2592 | SCM ans; | |
2593 | ||
2594 | scm_c_issue_deprecation_warning | |
2595 | ("`scm_internal_dynamic_wind' is deprecated. " | |
2596 | "Use the `scm_dynwind_begin' / `scm_dynwind_end' API instead."); | |
2597 | ||
2598 | scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE); | |
2599 | scm_dynwind_rewind_handler (before, guard_data, SCM_F_WIND_EXPLICITLY); | |
2600 | scm_dynwind_unwind_handler (after, guard_data, SCM_F_WIND_EXPLICITLY); | |
2601 | ans = inner (inner_data); | |
2602 | scm_dynwind_end (); | |
2603 | return ans; | |
2604 | } | |
2605 | ||
2606 | \f | |
2607 | ||
65619ebe AW |
2608 | SCM |
2609 | scm_immutable_cell (scm_t_bits car, scm_t_bits cdr) | |
2610 | { | |
2611 | scm_c_issue_deprecation_warning | |
2612 | ("scm_immutable_cell is deprecated. Use scm_cell instead."); | |
2613 | ||
2614 | return scm_cell (car, cdr); | |
2615 | } | |
2616 | ||
2617 | SCM | |
2618 | scm_immutable_double_cell (scm_t_bits car, scm_t_bits cbr, | |
2619 | scm_t_bits ccr, scm_t_bits cdr) | |
2620 | { | |
2621 | scm_c_issue_deprecation_warning | |
2622 | ("scm_immutable_double_cell is deprecated. Use scm_double_cell instead."); | |
2623 | ||
2624 | return scm_double_cell (car, cbr, ccr, cdr); | |
2625 | } | |
2626 | ||
4f5fb351 AW |
2627 | \f |
2628 | ||
2629 | ||
2630 | scm_t_bits | |
2631 | scm_i_deprecated_asrtgo (scm_t_bits condition) | |
2632 | { | |
2633 | scm_c_issue_deprecation_warning | |
2634 | ("SCM_ASRTGO is deprecated. Use `if (!condition) goto label;' directly."); | |
2635 | ||
2636 | return condition; | |
2637 | } | |
2638 | ||
65619ebe AW |
2639 | |
2640 | \f | |
2641 | ||
62e15979 AW |
2642 | |
2643 | /* scm_sym2var | |
2644 | * | |
2645 | * looks up the variable bound to SYM according to PROC. PROC should be | |
2646 | * a `eval closure' of some module. | |
2647 | * | |
2648 | * When no binding exists, and DEFINEP is true, create a new binding | |
2649 | * with a initial value of SCM_UNDEFINED. Return `#f' when DEFINEP as | |
2650 | * false and no binding exists. | |
2651 | * | |
2652 | * When PROC is `#f', it is ignored and the binding is searched for in | |
2653 | * the scm_pre_modules_obarray (a `eq' hash table). | |
2654 | */ | |
2655 | ||
e8049408 | 2656 | SCM |
62e15979 AW |
2657 | scm_sym2var (SCM sym, SCM proc, SCM definep) |
2658 | #define FUNC_NAME "scm_sym2var" | |
2659 | { | |
2660 | SCM var; | |
2661 | ||
e8049408 | 2662 | if (scm_is_true (definep)) |
62e15979 AW |
2663 | scm_c_issue_deprecation_warning |
2664 | ("scm_sym2var is deprecated. Use scm_define or scm_module_define\n" | |
2665 | "to define variables. In some rare cases you may need\n" | |
2666 | "scm_module_ensure_local_variable."); | |
2667 | else | |
2668 | scm_c_issue_deprecation_warning | |
2669 | ("scm_sym2var is deprecated. Use scm_module_variable to look up\n" | |
2670 | "variables."); | |
2671 | ||
2672 | if (SCM_NIMP (proc)) | |
2673 | { | |
2674 | if (SCM_EVAL_CLOSURE_P (proc)) | |
2675 | { | |
2676 | /* Bypass evaluator in the standard case. */ | |
2677 | var = scm_eval_closure_lookup (proc, sym, definep); | |
2678 | } | |
2679 | else | |
2680 | var = scm_call_2 (proc, sym, definep); | |
2681 | } | |
2682 | else | |
2683 | { | |
2684 | if (scm_is_false (definep)) | |
2685 | var = scm_module_variable (scm_the_root_module (), sym); | |
2686 | else | |
2687 | var = scm_module_ensure_local_variable (scm_the_root_module (), sym); | |
2688 | } | |
2689 | ||
2690 | if (scm_is_true (var) && !SCM_VARIABLEP (var)) | |
2691 | SCM_MISC_ERROR ("~S is not bound to a variable", scm_list_1 (sym)); | |
2692 | ||
2693 | return var; | |
2694 | } | |
2695 | #undef FUNC_NAME | |
2696 | ||
3f48638c AW |
2697 | SCM |
2698 | scm_lookup_closure_module (SCM proc) | |
2699 | { | |
2700 | scm_c_issue_deprecation_warning | |
2701 | ("Eval closures are deprecated. See \"Accessing Modules From C\" in\n" | |
2702 | "the manual, for replacements."); | |
2703 | ||
2704 | if (scm_is_false (proc)) | |
2705 | return scm_the_root_module (); | |
2706 | else if (SCM_EVAL_CLOSURE_P (proc)) | |
2707 | return SCM_PACK (SCM_SMOB_DATA (proc)); | |
2708 | else | |
2709 | /* FIXME: The `module' property is no longer set on eval closures, as it | |
2710 | introduced a circular reference that precludes garbage collection of | |
2711 | modules with the current weak hash table semantics (see | |
2712 | http://lists.gnu.org/archive/html/guile-devel/2009-01/msg00102.html and | |
2713 | http://thread.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/2465 | |
2714 | for details). Since it doesn't appear to be used (only in this | |
2715 | function, which has 1 caller), we no longer extend | |
2716 | `set-module-eval-closure!' to set the `module' property. */ | |
2717 | abort (); | |
2718 | } | |
2719 | ||
2720 | SCM | |
2721 | scm_module_lookup_closure (SCM module) | |
2722 | { | |
2723 | scm_c_issue_deprecation_warning | |
2724 | ("Eval closures are deprecated. See \"Accessing Modules From C\" in\n" | |
2725 | "the manual, for replacements."); | |
2726 | ||
2727 | if (scm_is_false (module)) | |
2728 | return SCM_BOOL_F; | |
2729 | else | |
2730 | return SCM_MODULE_EVAL_CLOSURE (module); | |
2731 | } | |
2732 | ||
2733 | SCM | |
2734 | scm_current_module_lookup_closure () | |
2735 | { | |
2736 | scm_c_issue_deprecation_warning | |
2737 | ("Eval closures are deprecated. See \"Accessing Modules From C\" in\n" | |
2738 | "the manual, for replacements."); | |
2739 | ||
2740 | if (scm_module_system_booted_p) | |
2741 | return scm_module_lookup_closure (scm_current_module ()); | |
2742 | else | |
2743 | return SCM_BOOL_F; | |
2744 | } | |
2745 | ||
2de74cb5 AW |
2746 | scm_t_bits scm_tc16_eval_closure; |
2747 | ||
2748 | #define SCM_F_EVAL_CLOSURE_INTERFACE (1<<0) | |
2749 | #define SCM_EVAL_CLOSURE_INTERFACE_P(e) \ | |
2750 | (SCM_SMOB_FLAGS (e) & SCM_F_EVAL_CLOSURE_INTERFACE) | |
2751 | ||
2752 | /* NOTE: This function may be called by a smob application | |
2753 | or from another C function directly. */ | |
2754 | SCM | |
2755 | scm_eval_closure_lookup (SCM eclo, SCM sym, SCM definep) | |
2756 | { | |
2757 | SCM module = SCM_PACK (SCM_SMOB_DATA (eclo)); | |
2758 | ||
2759 | scm_c_issue_deprecation_warning | |
2760 | ("Eval closures are deprecated. See \"Accessing Modules From C\" in\n" | |
2761 | "the manual, for replacements."); | |
2762 | ||
2763 | if (scm_is_true (definep)) | |
2764 | { | |
2765 | if (SCM_EVAL_CLOSURE_INTERFACE_P (eclo)) | |
2766 | return SCM_BOOL_F; | |
2767 | return scm_module_ensure_local_variable (module, sym); | |
2768 | } | |
2769 | else | |
2770 | return scm_module_variable (module, sym); | |
2771 | } | |
2772 | ||
2773 | SCM_DEFINE (scm_standard_eval_closure, "standard-eval-closure", 1, 0, 0, | |
2774 | (SCM module), | |
2775 | "Return an eval closure for the module @var{module}.") | |
2776 | #define FUNC_NAME s_scm_standard_eval_closure | |
2777 | { | |
2778 | scm_c_issue_deprecation_warning | |
2779 | ("Eval closures are deprecated. See \"Accessing Modules From C\" in\n" | |
2780 | "the manual, for replacements."); | |
2781 | ||
2782 | SCM_RETURN_NEWSMOB (scm_tc16_eval_closure, SCM_UNPACK (module)); | |
2783 | } | |
2784 | #undef FUNC_NAME | |
2785 | ||
2786 | ||
2787 | SCM_DEFINE (scm_standard_interface_eval_closure, | |
2788 | "standard-interface-eval-closure", 1, 0, 0, | |
2789 | (SCM module), | |
2790 | "Return a interface eval closure for the module @var{module}. " | |
2791 | "Such a closure does not allow new bindings to be added.") | |
2792 | #define FUNC_NAME s_scm_standard_interface_eval_closure | |
2793 | { | |
2794 | scm_c_issue_deprecation_warning | |
2795 | ("Eval closures are deprecated. See \"Accessing Modules From C\" in\n" | |
2796 | "the manual, for replacements."); | |
2797 | ||
2798 | SCM_RETURN_NEWSMOB (scm_tc16_eval_closure | (SCM_F_EVAL_CLOSURE_INTERFACE<<16), | |
2799 | SCM_UNPACK (module)); | |
2800 | } | |
2801 | #undef FUNC_NAME | |
2802 | ||
2803 | SCM_DEFINE (scm_eval_closure_module, | |
2804 | "eval-closure-module", 1, 0, 0, | |
2805 | (SCM eval_closure), | |
2806 | "Return the module associated with this eval closure.") | |
2807 | /* the idea is that eval closures are really not the way to do things, they're | |
2808 | superfluous given our module system. this function lets mmacros migrate away | |
2809 | from eval closures. */ | |
2810 | #define FUNC_NAME s_scm_eval_closure_module | |
2811 | { | |
2812 | scm_c_issue_deprecation_warning | |
2813 | ("Eval closures are deprecated. See \"Accessing Modules From C\" in\n" | |
2814 | "the manual, for replacements."); | |
2815 | ||
2816 | SCM_MAKE_VALIDATE_MSG (SCM_ARG1, eval_closure, EVAL_CLOSURE_P, | |
2817 | "eval-closure"); | |
2818 | return SCM_SMOB_OBJECT (eval_closure); | |
2819 | } | |
2820 | #undef FUNC_NAME | |
2821 | ||
62e15979 AW |
2822 | |
2823 | \f | |
2824 | ||
d1927913 AW |
2825 | SCM_DEFINE (scm_struct_vtable_tag, "struct-vtable-tag", 1, 0, 0, |
2826 | (SCM handle), | |
2827 | "Return the vtable tag of the structure @var{handle}.") | |
2828 | #define FUNC_NAME s_scm_struct_vtable_tag | |
2829 | { | |
2830 | SCM_VALIDATE_VTABLE (1, handle); | |
2831 | scm_c_issue_deprecation_warning | |
2832 | ("struct-vtable-tag is deprecated. What were you doing with it anyway?"); | |
2833 | ||
2834 | return scm_from_unsigned_integer | |
2835 | (((scm_t_bits)SCM_STRUCT_DATA (handle)) >> 3); | |
2836 | } | |
2837 | #undef FUNC_NAME | |
2838 | ||
2839 | ||
2840 | \f | |
2841 | ||
118ff892 AW |
2842 | SCM_DEFINE (scm_generalized_vector_p, "generalized-vector?", 1, 0, 0, |
2843 | (SCM obj), | |
2844 | "Return @code{#t} if @var{obj} is a vector, string,\n" | |
2845 | "bitvector, or uniform numeric vector.") | |
2846 | #define FUNC_NAME s_scm_generalized_vector_p | |
2847 | { | |
2848 | scm_c_issue_deprecation_warning | |
2849 | ("generalized-vector? is deprecated. Use array? and check the " | |
2850 | "array-rank instead."); | |
2851 | return scm_from_bool (scm_is_generalized_vector (obj)); | |
2852 | } | |
2853 | #undef FUNC_NAME | |
2854 | ||
2855 | SCM_DEFINE (scm_generalized_vector_length, "generalized-vector-length", 1, 0, 0, | |
2856 | (SCM v), | |
2857 | "Return the length of the generalized vector @var{v}.") | |
2858 | #define FUNC_NAME s_scm_generalized_vector_length | |
2859 | { | |
2860 | scm_c_issue_deprecation_warning | |
2861 | ("generalized-vector-length is deprecated. Use array-length instead."); | |
2862 | return scm_from_size_t (scm_c_generalized_vector_length (v)); | |
2863 | } | |
2864 | #undef FUNC_NAME | |
2865 | ||
2866 | SCM_DEFINE (scm_generalized_vector_ref, "generalized-vector-ref", 2, 0, 0, | |
2867 | (SCM v, SCM idx), | |
2868 | "Return the element at index @var{idx} of the\n" | |
2869 | "generalized vector @var{v}.") | |
2870 | #define FUNC_NAME s_scm_generalized_vector_ref | |
2871 | { | |
2872 | scm_c_issue_deprecation_warning | |
2873 | ("generalized-vector-ref is deprecated. Use array-ref instead."); | |
2874 | return scm_c_generalized_vector_ref (v, scm_to_size_t (idx)); | |
2875 | } | |
2876 | #undef FUNC_NAME | |
2877 | ||
2878 | SCM_DEFINE (scm_generalized_vector_set_x, "generalized-vector-set!", 3, 0, 0, | |
2879 | (SCM v, SCM idx, SCM val), | |
2880 | "Set the element at index @var{idx} of the\n" | |
2881 | "generalized vector @var{v} to @var{val}.") | |
2882 | #define FUNC_NAME s_scm_generalized_vector_set_x | |
2883 | { | |
2884 | scm_c_issue_deprecation_warning | |
2885 | ("generalized-vector-set! is deprecated. Use array-set! instead. " | |
2886 | "Note the change in argument order!"); | |
2887 | scm_c_generalized_vector_set_x (v, scm_to_size_t (idx), val); | |
2888 | return SCM_UNSPECIFIED; | |
2889 | } | |
2890 | #undef FUNC_NAME | |
2891 | ||
2892 | SCM_DEFINE (scm_generalized_vector_to_list, "generalized-vector->list", 1, 0, 0, | |
2893 | (SCM v), | |
2894 | "Return a new list whose elements are the elements of the\n" | |
2895 | "generalized vector @var{v}.") | |
2896 | #define FUNC_NAME s_scm_generalized_vector_to_list | |
2897 | { | |
2898 | /* FIXME: This duplicates `array_to_list'. */ | |
2899 | SCM ret = SCM_EOL; | |
2900 | long inc; | |
2901 | ssize_t pos, i; | |
2902 | scm_t_array_handle h; | |
2903 | ||
2904 | scm_c_issue_deprecation_warning | |
2905 | ("generalized-vector->list is deprecated. Use array->list instead."); | |
2906 | ||
2907 | scm_generalized_vector_get_handle (v, &h); | |
2908 | ||
2909 | i = h.dims[0].ubnd - h.dims[0].lbnd + 1; | |
2910 | inc = h.dims[0].inc; | |
2911 | pos = (i - 1) * inc; | |
2912 | ||
2913 | for (; i > 0; i--, pos -= inc) | |
2914 | ret = scm_cons (h.impl->vref (&h, h.base + pos), ret); | |
2915 | ||
2916 | scm_array_handle_release (&h); | |
2917 | return ret; | |
2918 | } | |
2919 | #undef FUNC_NAME | |
2920 | ||
2921 | ||
2922 | \f | |
2923 | ||
19e2247d MV |
2924 | void |
2925 | scm_i_init_deprecated () | |
2926 | { | |
79488112 | 2927 | properties_whash = scm_make_weak_key_hash_table (SCM_UNDEFINED); |
f3c6a02c | 2928 | scm_struct_table = scm_make_hash_table (SCM_UNDEFINED); |
2de74cb5 AW |
2929 | scm_tc16_eval_closure = scm_make_smob_type ("eval-closure", 0); |
2930 | scm_set_smob_apply (scm_tc16_eval_closure, scm_eval_closure_lookup, 2, 0, 0); | |
2931 | ||
19e2247d MV |
2932 | #include "libguile/deprecated.x" |
2933 | } | |
2934 | ||
2935 | #endif |