1 /* This file contains definitions for deprecated features. When you
2 deprecate something, move it here when that is feasible.
5 /* Copyright (C) 2003 Free Software Foundation, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
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
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "libguile/_scm.h"
23 #include "libguile/deprecated.h"
24 #include "libguile/deprecation.h"
25 #include "libguile/snarf.h"
26 #include "libguile/validate.h"
27 #include "libguile/strings.h"
28 #include "libguile/strop.h"
29 #include "libguile/modules.h"
30 #include "libguile/eval.h"
31 #include "libguile/smob.h"
32 #include "libguile/procprop.h"
33 #include "libguile/vectors.h"
34 #include "libguile/hashtab.h"
35 #include "libguile/struct.h"
36 #include "libguile/variable.h"
37 #include "libguile/fluids.h"
38 #include "libguile/ports.h"
43 #if (SCM_ENABLE_DEPRECATED == 1)
45 SCM_REGISTER_PROC(s_substring_move_left_x
, "substring-move-left!", 5, 0, 0, scm_substring_move_x
);
47 SCM_REGISTER_PROC(s_substring_move_right_x
, "substring-move-right!", 5, 0, 0, scm_substring_move_x
);
50 scm_wta (SCM arg
, const char *pos
, const char *s_subr
)
52 if (!s_subr
|| !*s_subr
)
54 if ((~0x1fL
) & (long) pos
)
56 /* error string supplied. */
57 scm_misc_error (s_subr
, pos
, scm_list_1 (arg
));
61 /* numerical error code. */
62 scm_t_bits error
= (scm_t_bits
) pos
;
67 scm_wrong_type_arg (s_subr
, 0, arg
);
69 scm_wrong_type_arg (s_subr
, 1, arg
);
71 scm_wrong_type_arg (s_subr
, 2, arg
);
73 scm_wrong_type_arg (s_subr
, 3, arg
);
75 scm_wrong_type_arg (s_subr
, 4, arg
);
77 scm_wrong_type_arg (s_subr
, 5, arg
);
79 scm_wrong_type_arg (s_subr
, 6, arg
);
81 scm_wrong_type_arg (s_subr
, 7, arg
);
83 scm_wrong_num_args (arg
);
85 scm_out_of_range (s_subr
, arg
);
87 scm_memory_error (s_subr
);
89 /* this shouldn't happen. */
90 scm_misc_error (s_subr
, "Unknown error", SCM_EOL
);
93 return SCM_UNSPECIFIED
;
99 /* We can't use SCM objects here. One should be able to call
100 SCM_REGISTER_MODULE from a C++ constructor for a static
101 object. This happens before main and thus before libguile is
105 struct moddata
*link
;
110 static struct moddata
*registered_mods
= NULL
;
113 scm_register_module_xxx (char *module_name
, void *init_func
)
117 scm_c_issue_deprecation_warning
118 ("`scm_register_module_xxx' is deprecated. Use extensions instead.");
120 /* XXX - should we (and can we) DEFER_INTS here? */
122 for (md
= registered_mods
; md
; md
= md
->link
)
123 if (!strcmp (md
->module_name
, module_name
))
125 md
->init_func
= init_func
;
129 md
= (struct moddata
*) malloc (sizeof (struct moddata
));
133 "guile: can't register module (%s): not enough memory",
138 md
->module_name
= module_name
;
139 md
->init_func
= init_func
;
140 md
->link
= registered_mods
;
141 registered_mods
= md
;
144 SCM_DEFINE (scm_registered_modules
, "c-registered-modules", 0, 0, 0,
146 "Return a list of the object code modules that have been imported into\n"
147 "the current Guile process. Each element of the list is a pair whose\n"
148 "car is the name of the module, and whose cdr is the function handle\n"
149 "for that module's initializer function. The name is the string that\n"
150 "has been passed to scm_register_module_xxx.")
151 #define FUNC_NAME s_scm_registered_modules
157 for (md
= registered_mods
; md
; md
= md
->link
)
158 res
= scm_cons (scm_cons (scm_makfrom0str (md
->module_name
),
159 scm_ulong2num ((unsigned long) md
->init_func
)),
165 SCM_DEFINE (scm_clear_registered_modules
, "c-clear-registered-modules", 0, 0, 0,
167 "Destroy the list of modules registered with the current Guile process.\n"
168 "The return value is unspecified. @strong{Warning:} this function does\n"
169 "not actually unlink or deallocate these modules, but only destroys the\n"
170 "records of which modules have been loaded. It should therefore be used\n"
171 "only by module bookkeeping operations.")
172 #define FUNC_NAME s_scm_clear_registered_modules
174 struct moddata
*md1
, *md2
;
178 for (md1
= registered_mods
; md1
; md1
= md2
)
183 registered_mods
= NULL
;
186 return SCM_UNSPECIFIED
;
191 scm_remember (SCM
*ptr
)
193 scm_c_issue_deprecation_warning ("`scm_remember' is deprecated. "
194 "Use the `scm_remember_upto_here*' family of functions instead.");
198 scm_protect_object (SCM obj
)
200 scm_c_issue_deprecation_warning ("`scm_protect_object' is deprecated. "
201 "Use `scm_gc_protect_object' instead.");
202 return scm_gc_protect_object (obj
);
206 scm_unprotect_object (SCM obj
)
208 scm_c_issue_deprecation_warning ("`scm_unprotect_object' is deprecated. "
209 "Use `scm_gc_unprotect_object' instead.");
210 return scm_gc_unprotect_object (obj
);
213 SCM_SYMBOL (scm_sym_app
, "app");
214 SCM_SYMBOL (scm_sym_modules
, "modules");
215 static SCM module_prefix
= SCM_BOOL_F
;
216 static SCM make_modules_in_var
;
217 static SCM beautify_user_module_x_var
;
218 static SCM try_module_autoload_var
;
223 #define PERM(x) scm_permanent_object(x)
225 if (module_prefix
== SCM_BOOL_F
)
227 module_prefix
= PERM (scm_list_2 (scm_sym_app
, scm_sym_modules
));
228 make_modules_in_var
= PERM (scm_c_lookup ("make-modules-in"));
229 beautify_user_module_x_var
=
230 PERM (scm_c_lookup ("beautify-user-module!"));
231 try_module_autoload_var
= PERM (scm_c_lookup ("try-module-autoload"));
236 scm_the_root_module ()
238 init_module_stuff ();
239 scm_c_issue_deprecation_warning ("`scm_the_root_module' is deprecated. "
240 "Use `scm_c_resolve_module (\"guile\")' "
243 return scm_c_resolve_module ("guile");
247 scm_module_full_name (SCM name
)
249 init_module_stuff ();
250 if (SCM_EQ_P (SCM_CAR (name
), scm_sym_app
))
253 return scm_append (scm_list_2 (module_prefix
, name
));
257 scm_make_module (SCM name
)
259 init_module_stuff ();
260 scm_c_issue_deprecation_warning ("`scm_make_module' is deprecated. "
261 "Use `scm_c_define_module instead.");
263 return scm_call_2 (SCM_VARIABLE_REF (make_modules_in_var
),
264 scm_the_root_module (),
265 scm_module_full_name (name
));
269 scm_ensure_user_module (SCM module
)
271 init_module_stuff ();
272 scm_c_issue_deprecation_warning ("`scm_ensure_user_module' is deprecated. "
273 "Use `scm_c_define_module instead.");
275 scm_call_1 (SCM_VARIABLE_REF (beautify_user_module_x_var
), module
);
276 return SCM_UNSPECIFIED
;
280 scm_load_scheme_module (SCM name
)
282 init_module_stuff ();
283 scm_c_issue_deprecation_warning ("`scm_load_scheme_module' is deprecated. "
284 "Use `scm_c_resolve_module instead.");
286 return scm_call_1 (SCM_VARIABLE_REF (try_module_autoload_var
), name
);
289 /* This is implemented in C solely for SCM_COERCE_OUTPORT ... */
292 maybe_close_port (void *data
, SCM port
)
294 SCM except
= (SCM
)data
;
296 while (!SCM_NULLP (except
))
298 SCM p
= SCM_COERCE_OUTPORT (SCM_CAR (except
));
299 if (SCM_EQ_P (p
, port
))
301 except
= SCM_CDR (except
);
304 scm_close_port (port
);
307 SCM_DEFINE (scm_close_all_ports_except
, "close-all-ports-except", 0, 0, 1,
309 "[DEPRECATED] Close all open file ports used by the interpreter\n"
310 "except for those supplied as arguments. This procedure\n"
311 "was intended to be used before an exec call to close file descriptors\n"
312 "which are not needed in the new process. However it has the\n"
313 "undesirable side effect of flushing buffers, so it's deprecated.\n"
314 "Use port-for-each instead.")
315 #define FUNC_NAME s_scm_close_all_ports_except
318 SCM_VALIDATE_REST_ARGUMENT (ports
);
320 for (p
= ports
; !SCM_NULLP (p
); p
= SCM_CDR (p
))
321 SCM_VALIDATE_OPPORT (SCM_ARG1
, SCM_COERCE_OUTPORT (SCM_CAR (p
)));
323 scm_c_port_for_each (maybe_close_port
, ports
);
325 return SCM_UNSPECIFIED
;
330 scm_i_init_deprecated ()
332 #include "libguile/deprecated.x"