deprecated.c 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506
  1. /* This file contains definitions for deprecated features. When you
  2. deprecate something, move it here when that is feasible.
  3. */
  4. /* Copyright (C) 2003, 2004, 2006, 2008 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifdef HAVE_CONFIG_H
  21. # include <config.h>
  22. #endif
  23. #include "libguile/_scm.h"
  24. #include "libguile/async.h"
  25. #include "libguile/deprecated.h"
  26. #include "libguile/discouraged.h"
  27. #include "libguile/deprecation.h"
  28. #include "libguile/snarf.h"
  29. #include "libguile/validate.h"
  30. #include "libguile/strings.h"
  31. #include "libguile/srfi-13.h"
  32. #include "libguile/modules.h"
  33. #include "libguile/eval.h"
  34. #include "libguile/smob.h"
  35. #include "libguile/procprop.h"
  36. #include "libguile/vectors.h"
  37. #include "libguile/hashtab.h"
  38. #include "libguile/struct.h"
  39. #include "libguile/variable.h"
  40. #include "libguile/fluids.h"
  41. #include "libguile/ports.h"
  42. #include "libguile/eq.h"
  43. #include "libguile/read.h"
  44. #include "libguile/strports.h"
  45. #include "libguile/smob.h"
  46. #include "libguile/alist.h"
  47. #include "libguile/keywords.h"
  48. #include "libguile/feature.h"
  49. #include <stdio.h>
  50. #include <string.h>
  51. #if (SCM_ENABLE_DEPRECATED == 1)
  52. /* From print.c: Internal symbol names of isyms. Deprecated in guile 1.7.0 on
  53. * 2004-04-22. */
  54. char *scm_isymnames[] =
  55. {
  56. "#@<deprecated>"
  57. };
  58. /* From eval.c: Error messages of the evaluator. These were deprecated in
  59. * guile 1.7.0 on 2003-06-02. */
  60. const char scm_s_expression[] = "missing or extra expression";
  61. const char scm_s_test[] = "bad test";
  62. const char scm_s_body[] = "bad body";
  63. const char scm_s_bindings[] = "bad bindings";
  64. const char scm_s_variable[] = "bad variable";
  65. const char scm_s_clauses[] = "bad or missing clauses";
  66. const char scm_s_formals[] = "bad formals";
  67. SCM_REGISTER_PROC(s_substring_move_left_x, "substring-move-left!", 5, 0, 0, scm_substring_move_x);
  68. SCM_REGISTER_PROC(s_substring_move_right_x, "substring-move-right!", 5, 0, 0, scm_substring_move_x);
  69. SCM
  70. scm_wta (SCM arg, const char *pos, const char *s_subr)
  71. {
  72. if (!s_subr || !*s_subr)
  73. s_subr = NULL;
  74. if ((~0x1fL) & (long) pos)
  75. {
  76. /* error string supplied. */
  77. scm_misc_error (s_subr, pos, scm_list_1 (arg));
  78. }
  79. else
  80. {
  81. /* numerical error code. */
  82. scm_t_bits error = (scm_t_bits) pos;
  83. switch (error)
  84. {
  85. case SCM_ARGn:
  86. scm_wrong_type_arg (s_subr, 0, arg);
  87. case SCM_ARG1:
  88. scm_wrong_type_arg (s_subr, 1, arg);
  89. case SCM_ARG2:
  90. scm_wrong_type_arg (s_subr, 2, arg);
  91. case SCM_ARG3:
  92. scm_wrong_type_arg (s_subr, 3, arg);
  93. case SCM_ARG4:
  94. scm_wrong_type_arg (s_subr, 4, arg);
  95. case SCM_ARG5:
  96. scm_wrong_type_arg (s_subr, 5, arg);
  97. case SCM_ARG6:
  98. scm_wrong_type_arg (s_subr, 6, arg);
  99. case SCM_ARG7:
  100. scm_wrong_type_arg (s_subr, 7, arg);
  101. case SCM_WNA:
  102. scm_wrong_num_args (arg);
  103. case SCM_OUTOFRANGE:
  104. scm_out_of_range (s_subr, arg);
  105. case SCM_NALLOC:
  106. scm_memory_error (s_subr);
  107. default:
  108. /* this shouldn't happen. */
  109. scm_misc_error (s_subr, "Unknown error", SCM_EOL);
  110. }
  111. }
  112. return SCM_UNSPECIFIED;
  113. }
  114. /* Module registry
  115. */
  116. /* We can't use SCM objects here. One should be able to call
  117. SCM_REGISTER_MODULE from a C++ constructor for a static
  118. object. This happens before main and thus before libguile is
  119. initialized. */
  120. struct moddata {
  121. struct moddata *link;
  122. char *module_name;
  123. void *init_func;
  124. };
  125. static struct moddata *registered_mods = NULL;
  126. void
  127. scm_register_module_xxx (char *module_name, void *init_func)
  128. {
  129. struct moddata *md;
  130. scm_c_issue_deprecation_warning
  131. ("`scm_register_module_xxx' is deprecated. Use extensions instead.");
  132. /* XXX - should we (and can we) DEFER_INTS here? */
  133. for (md = registered_mods; md; md = md->link)
  134. if (!strcmp (md->module_name, module_name))
  135. {
  136. md->init_func = init_func;
  137. return;
  138. }
  139. md = (struct moddata *) malloc (sizeof (struct moddata));
  140. if (md == NULL)
  141. {
  142. fprintf (stderr,
  143. "guile: can't register module (%s): not enough memory",
  144. module_name);
  145. return;
  146. }
  147. md->module_name = module_name;
  148. md->init_func = init_func;
  149. md->link = registered_mods;
  150. registered_mods = md;
  151. }
  152. SCM_DEFINE (scm_registered_modules, "c-registered-modules", 0, 0, 0,
  153. (),
  154. "Return a list of the object code modules that have been imported into\n"
  155. "the current Guile process. Each element of the list is a pair whose\n"
  156. "car is the name of the module, and whose cdr is the function handle\n"
  157. "for that module's initializer function. The name is the string that\n"
  158. "has been passed to scm_register_module_xxx.")
  159. #define FUNC_NAME s_scm_registered_modules
  160. {
  161. SCM res;
  162. struct moddata *md;
  163. res = SCM_EOL;
  164. for (md = registered_mods; md; md = md->link)
  165. res = scm_cons (scm_cons (scm_from_locale_string (md->module_name),
  166. scm_from_ulong ((unsigned long) md->init_func)),
  167. res);
  168. return res;
  169. }
  170. #undef FUNC_NAME
  171. SCM_DEFINE (scm_clear_registered_modules, "c-clear-registered-modules", 0, 0, 0,
  172. (),
  173. "Destroy the list of modules registered with the current Guile process.\n"
  174. "The return value is unspecified. @strong{Warning:} this function does\n"
  175. "not actually unlink or deallocate these modules, but only destroys the\n"
  176. "records of which modules have been loaded. It should therefore be used\n"
  177. "only by module bookkeeping operations.")
  178. #define FUNC_NAME s_scm_clear_registered_modules
  179. {
  180. struct moddata *md1, *md2;
  181. SCM_CRITICAL_SECTION_START;
  182. for (md1 = registered_mods; md1; md1 = md2)
  183. {
  184. md2 = md1->link;
  185. free (md1);
  186. }
  187. registered_mods = NULL;
  188. SCM_CRITICAL_SECTION_END;
  189. return SCM_UNSPECIFIED;
  190. }
  191. #undef FUNC_NAME
  192. void
  193. scm_remember (SCM *ptr)
  194. {
  195. scm_c_issue_deprecation_warning ("`scm_remember' is deprecated. "
  196. "Use the `scm_remember_upto_here*' family of functions instead.");
  197. }
  198. SCM
  199. scm_protect_object (SCM obj)
  200. {
  201. scm_c_issue_deprecation_warning ("`scm_protect_object' is deprecated. "
  202. "Use `scm_gc_protect_object' instead.");
  203. return scm_gc_protect_object (obj);
  204. }
  205. SCM
  206. scm_unprotect_object (SCM obj)
  207. {
  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);
  211. }
  212. SCM_SYMBOL (scm_sym_app, "app");
  213. SCM_SYMBOL (scm_sym_modules, "modules");
  214. static SCM module_prefix = SCM_BOOL_F;
  215. static SCM make_modules_in_var;
  216. static SCM beautify_user_module_x_var;
  217. static SCM try_module_autoload_var;
  218. static void
  219. init_module_stuff ()
  220. {
  221. #define PERM(x) scm_permanent_object(x)
  222. if (module_prefix == SCM_BOOL_F)
  223. {
  224. module_prefix = PERM (scm_list_2 (scm_sym_app, scm_sym_modules));
  225. make_modules_in_var = PERM (scm_c_lookup ("make-modules-in"));
  226. beautify_user_module_x_var =
  227. PERM (scm_c_lookup ("beautify-user-module!"));
  228. try_module_autoload_var = PERM (scm_c_lookup ("try-module-autoload"));
  229. }
  230. }
  231. SCM
  232. scm_the_root_module ()
  233. {
  234. init_module_stuff ();
  235. scm_c_issue_deprecation_warning ("`scm_the_root_module' is deprecated. "
  236. "Use `scm_c_resolve_module (\"guile\")' "
  237. "instead.");
  238. return scm_c_resolve_module ("guile");
  239. }
  240. static SCM
  241. scm_module_full_name (SCM name)
  242. {
  243. init_module_stuff ();
  244. if (scm_is_eq (SCM_CAR (name), scm_sym_app))
  245. return name;
  246. else
  247. return scm_append (scm_list_2 (module_prefix, name));
  248. }
  249. SCM
  250. scm_make_module (SCM name)
  251. {
  252. init_module_stuff ();
  253. scm_c_issue_deprecation_warning ("`scm_make_module' is deprecated. "
  254. "Use `scm_c_define_module instead.");
  255. return scm_call_2 (SCM_VARIABLE_REF (make_modules_in_var),
  256. scm_the_root_module (),
  257. scm_module_full_name (name));
  258. }
  259. SCM
  260. scm_ensure_user_module (SCM module)
  261. {
  262. init_module_stuff ();
  263. scm_c_issue_deprecation_warning ("`scm_ensure_user_module' is deprecated. "
  264. "Use `scm_c_define_module instead.");
  265. scm_call_1 (SCM_VARIABLE_REF (beautify_user_module_x_var), module);
  266. return SCM_UNSPECIFIED;
  267. }
  268. SCM
  269. scm_load_scheme_module (SCM name)
  270. {
  271. init_module_stuff ();
  272. scm_c_issue_deprecation_warning ("`scm_load_scheme_module' is deprecated. "
  273. "Use `scm_c_resolve_module instead.");
  274. return scm_call_1 (SCM_VARIABLE_REF (try_module_autoload_var), name);
  275. }
  276. /* This is implemented in C solely for SCM_COERCE_OUTPORT ... */
  277. static void
  278. maybe_close_port (void *data, SCM port)
  279. {
  280. SCM except_set = (SCM) data;
  281. while (!scm_is_null (except_set))
  282. {
  283. SCM p = SCM_COERCE_OUTPORT (SCM_CAR (except_set));
  284. if (scm_is_eq (p, port))
  285. return;
  286. except_set = SCM_CDR (except_set);
  287. }
  288. scm_close_port (port);
  289. }
  290. SCM_DEFINE (scm_close_all_ports_except, "close-all-ports-except", 0, 0, 1,
  291. (SCM ports),
  292. "[DEPRECATED] Close all open file ports used by the interpreter\n"
  293. "except for those supplied as arguments. This procedure\n"
  294. "was intended to be used before an exec call to close file descriptors\n"
  295. "which are not needed in the new process. However it has the\n"
  296. "undesirable side effect of flushing buffers, so it's deprecated.\n"
  297. "Use port-for-each instead.")
  298. #define FUNC_NAME s_scm_close_all_ports_except
  299. {
  300. SCM p;
  301. SCM_VALIDATE_REST_ARGUMENT (ports);
  302. for (p = ports; !scm_is_null (p); p = SCM_CDR (p))
  303. SCM_VALIDATE_OPPORT (SCM_ARG1, SCM_COERCE_OUTPORT (SCM_CAR (p)));
  304. scm_c_port_for_each (maybe_close_port, ports);
  305. return SCM_UNSPECIFIED;
  306. }
  307. #undef FUNC_NAME
  308. SCM_DEFINE (scm_variable_set_name_hint, "variable-set-name-hint!", 2, 0, 0,
  309. (SCM var, SCM hint),
  310. "Do not use this function.")
  311. #define FUNC_NAME s_scm_variable_set_name_hint
  312. {
  313. SCM_VALIDATE_VARIABLE (1, var);
  314. SCM_VALIDATE_SYMBOL (2, hint);
  315. scm_c_issue_deprecation_warning
  316. ("'variable-set-name-hint!' is deprecated. Do not use it.");
  317. return SCM_UNSPECIFIED;
  318. }
  319. #undef FUNC_NAME
  320. SCM_DEFINE (scm_builtin_variable, "builtin-variable", 1, 0, 0,
  321. (SCM name),
  322. "Do not use this function.")
  323. #define FUNC_NAME s_scm_builtin_variable
  324. {
  325. SCM_VALIDATE_SYMBOL (1,name);
  326. scm_c_issue_deprecation_warning ("`builtin-variable' is deprecated. "
  327. "Use module system operations instead.");
  328. return scm_sym2var (name, SCM_BOOL_F, SCM_BOOL_T);
  329. }
  330. #undef FUNC_NAME
  331. SCM
  332. scm_makstr (size_t len, int dummy)
  333. {
  334. scm_c_issue_deprecation_warning
  335. ("'scm_makstr' is deprecated. Use 'scm_c_make_string' instead.");
  336. return scm_c_make_string (len, SCM_UNDEFINED);
  337. }
  338. SCM
  339. scm_makfromstr (const char *src, size_t len, int dummy SCM_UNUSED)
  340. {
  341. scm_c_issue_deprecation_warning ("`scm_makfromstr' is deprecated. "
  342. "Use `scm_from_locale_stringn' instead.");
  343. return scm_from_locale_stringn (src, len);
  344. }
  345. SCM
  346. scm_internal_with_fluids (SCM fluids, SCM values, SCM (*cproc) (), void *cdata)
  347. {
  348. scm_c_issue_deprecation_warning ("`scm_internal_with_fluids' is deprecated. "
  349. "Use `scm_c_with_fluids' instead.");
  350. return scm_c_with_fluids (fluids, values, cproc, cdata);
  351. }
  352. SCM
  353. scm_make_gsubr (const char *name, int req, int opt, int rst, SCM (*fcn)())
  354. {
  355. scm_c_issue_deprecation_warning
  356. ("`scm_make_gsubr' is deprecated. Use `scm_c_define_gsubr' instead.");
  357. return scm_c_define_gsubr (name, req, opt, rst, fcn);
  358. }
  359. SCM
  360. scm_make_gsubr_with_generic (const char *name,
  361. int req, int opt, int rst,
  362. SCM (*fcn)(), SCM *gf)
  363. {
  364. scm_c_issue_deprecation_warning
  365. ("`scm_make_gsubr_with_generic' is deprecated. "
  366. "Use `scm_c_define_gsubr_with_generic' instead.");
  367. return scm_c_define_gsubr_with_generic (name, req, opt, rst, fcn, gf);
  368. }
  369. SCM
  370. scm_create_hook (const char *name, int n_args)
  371. {
  372. scm_c_issue_deprecation_warning
  373. ("'scm_create_hook' is deprecated. "
  374. "Use 'scm_make_hook' and 'scm_c_define' instead.");
  375. {
  376. SCM hook = scm_make_hook (scm_from_int (n_args));
  377. scm_c_define (name, hook);
  378. return scm_permanent_object (hook);
  379. }
  380. }
  381. SCM_DEFINE (scm_sloppy_memq, "sloppy-memq", 2, 0, 0,
  382. (SCM x, SCM lst),
  383. "This procedure behaves like @code{memq}, but does no type or error checking.\n"
  384. "Its use is recommended only in writing Guile internals,\n"
  385. "not for high-level Scheme programs.")
  386. #define FUNC_NAME s_scm_sloppy_memq
  387. {
  388. scm_c_issue_deprecation_warning
  389. ("'sloppy-memq' is deprecated. Use 'memq' instead.");
  390. for(; scm_is_pair (lst); lst = SCM_CDR(lst))
  391. {
  392. if (scm_is_eq (SCM_CAR (lst), x))
  393. return lst;
  394. }
  395. return lst;
  396. }
  397. #undef FUNC_NAME
  398. SCM_DEFINE (scm_sloppy_memv, "sloppy-memv", 2, 0, 0,
  399. (SCM x, SCM lst),
  400. "This procedure behaves like @code{memv}, but does no type or error checking.\n"
  401. "Its use is recommended only in writing Guile internals,\n"
  402. "not for high-level Scheme programs.")
  403. #define FUNC_NAME s_scm_sloppy_memv
  404. {
  405. scm_c_issue_deprecation_warning
  406. ("'sloppy-memv' is deprecated. Use 'memv' instead.");
  407. for(; scm_is_pair (lst); lst = SCM_CDR(lst))
  408. {
  409. if (! scm_is_false (scm_eqv_p (SCM_CAR (lst), x)))
  410. return lst;
  411. }
  412. return lst;
  413. }
  414. #undef FUNC_NAME
  415. SCM_DEFINE (scm_sloppy_member, "sloppy-member", 2, 0, 0,
  416. (SCM x, SCM lst),
  417. "This procedure behaves like @code{member}, but does no type or error checking.\n"
  418. "Its use is recommended only in writing Guile internals,\n"
  419. "not for high-level Scheme programs.")
  420. #define FUNC_NAME s_scm_sloppy_member
  421. {
  422. scm_c_issue_deprecation_warning
  423. ("'sloppy-member' is deprecated. Use 'member' instead.");
  424. for(; scm_is_pair (lst); lst = SCM_CDR(lst))
  425. {
  426. if (! scm_is_false (scm_equal_p (SCM_CAR (lst), x)))
  427. return lst;
  428. }
  429. return lst;
  430. }
  431. #undef FUNC_NAME
  432. SCM_SYMBOL (scm_end_of_file_key, "end-of-file");
  433. SCM_DEFINE (scm_read_and_eval_x, "read-and-eval!", 0, 1, 0,
  434. (SCM port),
  435. "Read a form from @var{port} (standard input by default), and evaluate it\n"
  436. "(memoizing it in the process) in the top-level environment. If no data\n"
  437. "is left to be read from @var{port}, an @code{end-of-file} error is\n"
  438. "signalled.")
  439. #define FUNC_NAME s_scm_read_and_eval_x
  440. {
  441. SCM form;
  442. scm_c_issue_deprecation_warning
  443. ("'read-and-eval!' is deprecated. Use 'read' and 'eval' instead.");
  444. form = scm_read (port);
  445. if (SCM_EOF_OBJECT_P (form))
  446. scm_ithrow (scm_end_of_file_key, SCM_EOL, 1);
  447. return scm_eval_x (form, scm_current_module ());
  448. }
  449. #undef FUNC_NAME
  450. SCM
  451. scm_make_subr_opt (const char *name, int type, SCM (*fcn) (), int set)
  452. {
  453. scm_c_issue_deprecation_warning
  454. ("`scm_make_subr_opt' is deprecated. Use `scm_c_make_subr' or "
  455. "`scm_c_define_subr' instead.");
  456. if (set)
  457. return scm_c_define_subr (name, type, fcn);
  458. else
  459. return scm_c_make_subr (name, type, fcn);
  460. }
  461. SCM
  462. scm_make_subr (const char *name, int type, SCM (*fcn) ())
  463. {
  464. scm_c_issue_deprecation_warning
  465. ("`scm_make_subr' is deprecated. Use `scm_c_define_subr' instead.");
  466. return scm_c_define_subr (name, type, fcn);
  467. }
  468. SCM
  469. scm_make_subr_with_generic (const char *name, int type, SCM (*fcn) (), SCM *gf)
  470. {
  471. scm_c_issue_deprecation_warning
  472. ("`scm_make_subr_with_generic' is deprecated. Use "
  473. "`scm_c_define_subr_with_generic' instead.");
  474. return scm_c_define_subr_with_generic (name, type, fcn, gf);
  475. }
  476. /* Call thunk(closure) underneath a top-level error handler.
  477. * If an error occurs, pass the exitval through err_filter and return it.
  478. * If no error occurs, return the value of thunk.
  479. */
  480. #ifdef _UNICOS
  481. typedef int setjmp_type;
  482. #else
  483. typedef long setjmp_type;
  484. #endif
  485. struct cce_handler_data {
  486. SCM (*err_filter) ();
  487. void *closure;
  488. };
  489. static SCM
  490. invoke_err_filter (void *d, SCM tag, SCM args)
  491. {
  492. struct cce_handler_data *data = (struct cce_handler_data *)d;
  493. return data->err_filter (SCM_BOOL_F, data->closure);
  494. }
  495. SCM
  496. scm_call_catching_errors (SCM (*thunk)(), SCM (*err_filter)(), void *closure)
  497. {
  498. scm_c_issue_deprecation_warning
  499. ("'scm_call_catching_errors' is deprecated. "
  500. "Use 'scm_internal_catch' instead.");
  501. {
  502. struct cce_handler_data data;
  503. data.err_filter = err_filter;
  504. data.closure = closure;
  505. return scm_internal_catch (SCM_BOOL_T,
  506. (scm_t_catch_body)thunk, closure,
  507. (scm_t_catch_handler)invoke_err_filter, &data);
  508. }
  509. }
  510. long
  511. scm_make_smob_type_mfpe (char *name, size_t size,
  512. SCM (*mark) (SCM),
  513. size_t (*free) (SCM),
  514. int (*print) (SCM, SCM, scm_print_state *),
  515. SCM (*equalp) (SCM, SCM))
  516. {
  517. scm_c_issue_deprecation_warning
  518. ("'scm_make_smob_type_mfpe' is deprecated. "
  519. "Use 'scm_make_smob_type' plus 'scm_set_smob_*' instead.");
  520. {
  521. long answer = scm_make_smob_type (name, size);
  522. scm_set_smob_mfpe (answer, mark, free, print, equalp);
  523. return answer;
  524. }
  525. }
  526. void
  527. scm_set_smob_mfpe (long tc,
  528. SCM (*mark) (SCM),
  529. size_t (*free) (SCM),
  530. int (*print) (SCM, SCM, scm_print_state *),
  531. SCM (*equalp) (SCM, SCM))
  532. {
  533. scm_c_issue_deprecation_warning
  534. ("'scm_set_smob_mfpe' is deprecated. "
  535. "Use 'scm_set_smob_mark' instead, for example.");
  536. if (mark) scm_set_smob_mark (tc, mark);
  537. if (free) scm_set_smob_free (tc, free);
  538. if (print) scm_set_smob_print (tc, print);
  539. if (equalp) scm_set_smob_equalp (tc, equalp);
  540. }
  541. SCM
  542. scm_read_0str (char *expr)
  543. {
  544. scm_c_issue_deprecation_warning
  545. ("scm_read_0str is deprecated. Use scm_c_read_string instead.");
  546. return scm_c_read_string (expr);
  547. }
  548. SCM
  549. scm_eval_0str (const char *expr)
  550. {
  551. scm_c_issue_deprecation_warning
  552. ("scm_eval_0str is deprecated. Use scm_c_eval_string instead.");
  553. return scm_c_eval_string (expr);
  554. }
  555. SCM
  556. scm_strprint_obj (SCM obj)
  557. {
  558. scm_c_issue_deprecation_warning
  559. ("scm_strprint_obj is deprecated. Use scm_object_to_string instead.");
  560. return scm_object_to_string (obj, SCM_UNDEFINED);
  561. }
  562. char *
  563. scm_i_object_chars (SCM obj)
  564. {
  565. scm_c_issue_deprecation_warning
  566. ("SCM_CHARS is deprecated. See the manual for alternatives.");
  567. if (SCM_STRINGP (obj))
  568. return SCM_STRING_CHARS (obj);
  569. if (SCM_SYMBOLP (obj))
  570. return SCM_SYMBOL_CHARS (obj);
  571. abort ();
  572. }
  573. long
  574. scm_i_object_length (SCM obj)
  575. {
  576. scm_c_issue_deprecation_warning
  577. ("SCM_LENGTH is deprecated. "
  578. "Use scm_c_string_length instead, for example, or see the manual.");
  579. if (SCM_STRINGP (obj))
  580. return SCM_STRING_LENGTH (obj);
  581. if (SCM_SYMBOLP (obj))
  582. return SCM_SYMBOL_LENGTH (obj);
  583. if (SCM_VECTORP (obj))
  584. return SCM_VECTOR_LENGTH (obj);
  585. abort ();
  586. }
  587. SCM
  588. scm_sym2ovcell_soft (SCM sym, SCM obarray)
  589. {
  590. SCM lsym, z;
  591. size_t hash = scm_i_symbol_hash (sym) % SCM_VECTOR_LENGTH (obarray);
  592. scm_c_issue_deprecation_warning ("`scm_sym2ovcell_soft' is deprecated. "
  593. "Use hashtables instead.");
  594. SCM_CRITICAL_SECTION_START;
  595. for (lsym = SCM_VECTOR_REF (obarray, hash);
  596. SCM_NIMP (lsym);
  597. lsym = SCM_CDR (lsym))
  598. {
  599. z = SCM_CAR (lsym);
  600. if (scm_is_eq (SCM_CAR (z), sym))
  601. {
  602. SCM_CRITICAL_SECTION_END;
  603. return z;
  604. }
  605. }
  606. SCM_CRITICAL_SECTION_END;
  607. return SCM_BOOL_F;
  608. }
  609. SCM
  610. scm_sym2ovcell (SCM sym, SCM obarray)
  611. #define FUNC_NAME "scm_sym2ovcell"
  612. {
  613. SCM answer;
  614. scm_c_issue_deprecation_warning ("`scm_sym2ovcell' is deprecated. "
  615. "Use hashtables instead.");
  616. answer = scm_sym2ovcell_soft (sym, obarray);
  617. if (scm_is_true (answer))
  618. return answer;
  619. SCM_MISC_ERROR ("uninterned symbol: ~S", scm_list_1 (sym));
  620. return SCM_UNSPECIFIED; /* not reached */
  621. }
  622. #undef FUNC_NAME
  623. /* Intern a symbol whose name is the LEN characters at NAME in OBARRAY.
  624. OBARRAY should be a vector of lists, indexed by the name's hash
  625. value, modulo OBARRAY's length. Each list has the form
  626. ((SYMBOL . VALUE) ...), where SYMBOL is a symbol, and VALUE is the
  627. value associated with that symbol (in the current module? in the
  628. system module?)
  629. To "intern" a symbol means: if OBARRAY already contains a symbol by
  630. that name, return its (SYMBOL . VALUE) pair; otherwise, create a
  631. new symbol, add the pair (SYMBOL . SCM_UNDEFINED) to the
  632. appropriate list of the OBARRAY, and return the pair.
  633. If softness is non-zero, don't create a symbol if it isn't already
  634. in OBARRAY; instead, just return #f.
  635. If OBARRAY is SCM_BOOL_F, create a symbol listed in no obarray and
  636. return (SYMBOL . SCM_UNDEFINED). */
  637. SCM
  638. scm_intern_obarray_soft (const char *name,size_t len,SCM obarray,unsigned int softness)
  639. {
  640. SCM symbol = scm_from_locale_symboln (name, len);
  641. size_t raw_hash = scm_i_symbol_hash (symbol);
  642. size_t hash;
  643. SCM lsym;
  644. scm_c_issue_deprecation_warning ("`scm_intern_obarray_soft' is deprecated. "
  645. "Use hashtables instead.");
  646. if (scm_is_false (obarray))
  647. {
  648. if (softness)
  649. return SCM_BOOL_F;
  650. else
  651. return scm_cons (symbol, SCM_UNDEFINED);
  652. }
  653. hash = raw_hash % SCM_VECTOR_LENGTH (obarray);
  654. for (lsym = SCM_VECTOR_REF(obarray, hash);
  655. SCM_NIMP (lsym); lsym = SCM_CDR (lsym))
  656. {
  657. SCM a = SCM_CAR (lsym);
  658. SCM z = SCM_CAR (a);
  659. if (scm_is_eq (z, symbol))
  660. return a;
  661. }
  662. if (softness)
  663. {
  664. return SCM_BOOL_F;
  665. }
  666. else
  667. {
  668. SCM cell = scm_cons (symbol, SCM_UNDEFINED);
  669. SCM slot = SCM_VECTOR_REF (obarray, hash);
  670. SCM_VECTOR_SET (obarray, hash, scm_cons (cell, slot));
  671. return cell;
  672. }
  673. }
  674. SCM
  675. scm_intern_obarray (const char *name,size_t len,SCM obarray)
  676. {
  677. scm_c_issue_deprecation_warning ("`scm_intern_obarray' is deprecated. "
  678. "Use hashtables instead.");
  679. return scm_intern_obarray_soft (name, len, obarray, 0);
  680. }
  681. /* Lookup the value of the symbol named by the nul-terminated string
  682. NAME in the current module. */
  683. SCM
  684. scm_symbol_value0 (const char *name)
  685. {
  686. scm_c_issue_deprecation_warning ("`scm_symbol_value0' is deprecated. "
  687. "Use `scm_lookup' instead.");
  688. return scm_variable_ref (scm_c_lookup (name));
  689. }
  690. SCM_DEFINE (scm_string_to_obarray_symbol, "string->obarray-symbol", 2, 1, 0,
  691. (SCM o, SCM s, SCM softp),
  692. "Intern a new symbol in @var{obarray}, a symbol table, with name\n"
  693. "@var{string}.\n\n"
  694. "If @var{obarray} is @code{#f}, use the default system symbol table. If\n"
  695. "@var{obarray} is @code{#t}, the symbol should not be interned in any\n"
  696. "symbol table; merely return the pair (@var{symbol}\n"
  697. ". @var{#<undefined>}).\n\n"
  698. "The @var{soft?} argument determines whether new symbol table entries\n"
  699. "should be created when the specified symbol is not already present in\n"
  700. "@var{obarray}. If @var{soft?} is specified and is a true value, then\n"
  701. "new entries should not be added for symbols not already present in the\n"
  702. "table; instead, simply return @code{#f}.")
  703. #define FUNC_NAME s_scm_string_to_obarray_symbol
  704. {
  705. SCM vcell;
  706. SCM answer;
  707. int softness;
  708. SCM_VALIDATE_STRING (2, s);
  709. SCM_ASSERT (scm_is_bool (o) || SCM_VECTORP (o), o, SCM_ARG1, FUNC_NAME);
  710. scm_c_issue_deprecation_warning ("`string->obarray-symbol' is deprecated. "
  711. "Use hashtables instead.");
  712. softness = (!SCM_UNBNDP (softp) && scm_is_true(softp));
  713. /* iron out some screwy calling conventions */
  714. if (scm_is_false (o))
  715. {
  716. /* nothing interesting to do here. */
  717. return scm_string_to_symbol (s);
  718. }
  719. else if (scm_is_eq (o, SCM_BOOL_T))
  720. o = SCM_BOOL_F;
  721. vcell = scm_intern_obarray_soft (scm_i_string_chars (s),
  722. scm_i_string_length (s),
  723. o,
  724. softness);
  725. if (scm_is_false (vcell))
  726. return vcell;
  727. answer = SCM_CAR (vcell);
  728. return answer;
  729. }
  730. #undef FUNC_NAME
  731. SCM_DEFINE (scm_intern_symbol, "intern-symbol", 2, 0, 0,
  732. (SCM o, SCM s),
  733. "Add a new symbol to @var{obarray} with name @var{string}, bound to an\n"
  734. "unspecified initial value. The symbol table is not modified if a symbol\n"
  735. "with this name is already present.")
  736. #define FUNC_NAME s_scm_intern_symbol
  737. {
  738. size_t hval;
  739. SCM_VALIDATE_SYMBOL (2,s);
  740. if (scm_is_false (o))
  741. return SCM_UNSPECIFIED;
  742. scm_c_issue_deprecation_warning ("`intern-symbol' is deprecated. "
  743. "Use hashtables instead.");
  744. SCM_VALIDATE_VECTOR (1,o);
  745. hval = scm_i_symbol_hash (s) % SCM_VECTOR_LENGTH (o);
  746. /* If the symbol is already interned, simply return. */
  747. SCM_CRITICAL_SECTION_START;
  748. {
  749. SCM lsym;
  750. SCM sym;
  751. for (lsym = SCM_VECTOR_REF (o, hval);
  752. SCM_NIMP (lsym);
  753. lsym = SCM_CDR (lsym))
  754. {
  755. sym = SCM_CAR (lsym);
  756. if (scm_is_eq (SCM_CAR (sym), s))
  757. {
  758. SCM_CRITICAL_SECTION_END;
  759. return SCM_UNSPECIFIED;
  760. }
  761. }
  762. SCM_VECTOR_SET (o, hval,
  763. scm_acons (s, SCM_UNDEFINED,
  764. SCM_VECTOR_REF (o, hval)));
  765. }
  766. SCM_CRITICAL_SECTION_END;
  767. return SCM_UNSPECIFIED;
  768. }
  769. #undef FUNC_NAME
  770. SCM_DEFINE (scm_unintern_symbol, "unintern-symbol", 2, 0, 0,
  771. (SCM o, SCM s),
  772. "Remove the symbol with name @var{string} from @var{obarray}. This\n"
  773. "function returns @code{#t} if the symbol was present and @code{#f}\n"
  774. "otherwise.")
  775. #define FUNC_NAME s_scm_unintern_symbol
  776. {
  777. size_t hval;
  778. scm_c_issue_deprecation_warning ("`unintern-symbol' is deprecated. "
  779. "Use hashtables instead.");
  780. SCM_VALIDATE_SYMBOL (2,s);
  781. if (scm_is_false (o))
  782. return SCM_BOOL_F;
  783. SCM_VALIDATE_VECTOR (1,o);
  784. hval = scm_i_symbol_hash (s) % SCM_VECTOR_LENGTH (o);
  785. SCM_CRITICAL_SECTION_START;
  786. {
  787. SCM lsym_follow;
  788. SCM lsym;
  789. SCM sym;
  790. for (lsym = SCM_VECTOR_REF (o, hval), lsym_follow = SCM_BOOL_F;
  791. SCM_NIMP (lsym);
  792. lsym_follow = lsym, lsym = SCM_CDR (lsym))
  793. {
  794. sym = SCM_CAR (lsym);
  795. if (scm_is_eq (SCM_CAR (sym), s))
  796. {
  797. /* Found the symbol to unintern. */
  798. if (scm_is_false (lsym_follow))
  799. SCM_VECTOR_SET (o, hval, lsym);
  800. else
  801. SCM_SETCDR (lsym_follow, SCM_CDR(lsym));
  802. SCM_CRITICAL_SECTION_END;
  803. return SCM_BOOL_T;
  804. }
  805. }
  806. }
  807. SCM_CRITICAL_SECTION_END;
  808. return SCM_BOOL_F;
  809. }
  810. #undef FUNC_NAME
  811. SCM_DEFINE (scm_symbol_binding, "symbol-binding", 2, 0, 0,
  812. (SCM o, SCM s),
  813. "Look up in @var{obarray} the symbol whose name is @var{string}, and\n"
  814. "return the value to which it is bound. If @var{obarray} is @code{#f},\n"
  815. "use the global symbol table. If @var{string} is not interned in\n"
  816. "@var{obarray}, an error is signalled.")
  817. #define FUNC_NAME s_scm_symbol_binding
  818. {
  819. SCM vcell;
  820. scm_c_issue_deprecation_warning ("`symbol-binding' is deprecated. "
  821. "Use hashtables instead.");
  822. SCM_VALIDATE_SYMBOL (2,s);
  823. if (scm_is_false (o))
  824. return scm_variable_ref (scm_lookup (s));
  825. SCM_VALIDATE_VECTOR (1,o);
  826. vcell = scm_sym2ovcell (s, o);
  827. return SCM_CDR(vcell);
  828. }
  829. #undef FUNC_NAME
  830. #if 0
  831. SCM_DEFINE (scm_symbol_interned_p, "symbol-interned?", 2, 0, 0,
  832. (SCM o, SCM s),
  833. "Return @code{#t} if @var{obarray} contains a symbol with name\n"
  834. "@var{string}, and @code{#f} otherwise.")
  835. #define FUNC_NAME s_scm_symbol_interned_p
  836. {
  837. SCM vcell;
  838. scm_c_issue_deprecation_warning ("`symbol-interned?' is deprecated. "
  839. "Use hashtables instead.");
  840. SCM_VALIDATE_SYMBOL (2,s);
  841. if (scm_is_false (o))
  842. {
  843. SCM var = scm_sym2var (s, SCM_BOOL_F, SCM_BOOL_F);
  844. if (var != SCM_BOOL_F)
  845. return SCM_BOOL_T;
  846. return SCM_BOOL_F;
  847. }
  848. SCM_VALIDATE_VECTOR (1,o);
  849. vcell = scm_sym2ovcell_soft (s, o);
  850. return (SCM_NIMP(vcell)
  851. ? SCM_BOOL_T
  852. : SCM_BOOL_F);
  853. }
  854. #undef FUNC_NAME
  855. #endif
  856. SCM_DEFINE (scm_symbol_bound_p, "symbol-bound?", 2, 0, 0,
  857. (SCM o, SCM s),
  858. "Return @code{#t} if @var{obarray} contains a symbol with name\n"
  859. "@var{string} bound to a defined value. This differs from\n"
  860. "@var{symbol-interned?} in that the mere mention of a symbol\n"
  861. "usually causes it to be interned; @code{symbol-bound?}\n"
  862. "determines whether a symbol has been given any meaningful\n"
  863. "value.")
  864. #define FUNC_NAME s_scm_symbol_bound_p
  865. {
  866. SCM vcell;
  867. scm_c_issue_deprecation_warning ("`symbol-bound?' is deprecated. "
  868. "Use hashtables instead.");
  869. SCM_VALIDATE_SYMBOL (2,s);
  870. if (scm_is_false (o))
  871. {
  872. SCM var = scm_sym2var (s, SCM_BOOL_F, SCM_BOOL_F);
  873. if (SCM_VARIABLEP(var) && !SCM_UNBNDP(SCM_VARIABLE_REF(var)))
  874. return SCM_BOOL_T;
  875. return SCM_BOOL_F;
  876. }
  877. SCM_VALIDATE_VECTOR (1,o);
  878. vcell = scm_sym2ovcell_soft (s, o);
  879. return scm_from_bool (SCM_NIMP (vcell) && !SCM_UNBNDP (SCM_CDR (vcell)));
  880. }
  881. #undef FUNC_NAME
  882. SCM_DEFINE (scm_symbol_set_x, "symbol-set!", 3, 0, 0,
  883. (SCM o, SCM s, SCM v),
  884. "Find the symbol in @var{obarray} whose name is @var{string}, and rebind\n"
  885. "it to @var{value}. An error is signalled if @var{string} is not present\n"
  886. "in @var{obarray}.")
  887. #define FUNC_NAME s_scm_symbol_set_x
  888. {
  889. SCM vcell;
  890. scm_c_issue_deprecation_warning ("`symbol-set!' is deprecated. "
  891. "Use the module system instead.");
  892. SCM_VALIDATE_SYMBOL (2,s);
  893. if (scm_is_false (o))
  894. {
  895. scm_define (s, v);
  896. return SCM_UNSPECIFIED;
  897. }
  898. SCM_VALIDATE_VECTOR (1,o);
  899. vcell = scm_sym2ovcell (s, o);
  900. SCM_SETCDR (vcell, v);
  901. return SCM_UNSPECIFIED;
  902. }
  903. #undef FUNC_NAME
  904. #define MAX_PREFIX_LENGTH 30
  905. static int gentemp_counter;
  906. SCM_DEFINE (scm_gentemp, "gentemp", 0, 2, 0,
  907. (SCM prefix, SCM obarray),
  908. "Create a new symbol with a name unique in an obarray.\n"
  909. "The name is constructed from an optional string @var{prefix}\n"
  910. "and a counter value. The default prefix is @code{t}. The\n"
  911. "@var{obarray} is specified as a second optional argument.\n"
  912. "Default is the system obarray where all normal symbols are\n"
  913. "interned. The counter is increased by 1 at each\n"
  914. "call. There is no provision for resetting the counter.")
  915. #define FUNC_NAME s_scm_gentemp
  916. {
  917. char buf[MAX_PREFIX_LENGTH + SCM_INTBUFLEN];
  918. char *name = buf;
  919. int len, n_digits;
  920. scm_c_issue_deprecation_warning ("`gentemp' is deprecated. "
  921. "Use `gensym' instead.");
  922. if (SCM_UNBNDP (prefix))
  923. {
  924. name[0] = 't';
  925. len = 1;
  926. }
  927. else
  928. {
  929. SCM_VALIDATE_STRING (1, prefix);
  930. len = scm_i_string_length (prefix);
  931. if (len > MAX_PREFIX_LENGTH)
  932. name = SCM_MUST_MALLOC (MAX_PREFIX_LENGTH + SCM_INTBUFLEN);
  933. strncpy (name, scm_i_string_chars (prefix), len);
  934. }
  935. if (SCM_UNBNDP (obarray))
  936. return scm_gensym (prefix);
  937. else
  938. SCM_ASSERT ((scm_is_vector (obarray) || SCM_I_WVECTP (obarray)),
  939. obarray,
  940. SCM_ARG2,
  941. FUNC_NAME);
  942. do
  943. n_digits = scm_iint2str (gentemp_counter++, 10, &name[len]);
  944. while (scm_is_true (scm_intern_obarray_soft (name,
  945. len + n_digits,
  946. obarray,
  947. 1)));
  948. {
  949. SCM vcell = scm_intern_obarray_soft (name,
  950. len + n_digits,
  951. obarray,
  952. 0);
  953. if (name != buf)
  954. scm_must_free (name);
  955. return SCM_CAR (vcell);
  956. }
  957. }
  958. #undef FUNC_NAME
  959. SCM
  960. scm_i_makinum (scm_t_signed_bits val)
  961. {
  962. scm_c_issue_deprecation_warning
  963. ("SCM_MAKINUM is deprecated. Use scm_from_int or similar instead.");
  964. return SCM_I_MAKINUM (val);
  965. }
  966. int
  967. scm_i_inump (SCM obj)
  968. {
  969. scm_c_issue_deprecation_warning
  970. ("SCM_INUMP is deprecated. Use scm_is_integer or similar instead.");
  971. return SCM_I_INUMP (obj);
  972. }
  973. scm_t_signed_bits
  974. scm_i_inum (SCM obj)
  975. {
  976. scm_c_issue_deprecation_warning
  977. ("SCM_INUM is deprecated. Use scm_to_int or similar instead.");
  978. return scm_to_intmax (obj);
  979. }
  980. char *
  981. scm_c_string2str (SCM obj, char *str, size_t *lenp)
  982. {
  983. scm_c_issue_deprecation_warning
  984. ("scm_c_string2str is deprecated. Use scm_to_locale_stringbuf or similar instead.");
  985. if (str == NULL)
  986. {
  987. char *result = scm_to_locale_string (obj);
  988. if (lenp)
  989. *lenp = scm_i_string_length (obj);
  990. return result;
  991. }
  992. else
  993. {
  994. /* Pray that STR is large enough.
  995. */
  996. size_t len = scm_to_locale_stringbuf (obj, str, SCM_I_SIZE_MAX);
  997. str[len] = '\0';
  998. if (lenp)
  999. *lenp = len;
  1000. return str;
  1001. }
  1002. }
  1003. char *
  1004. scm_c_substring2str (SCM obj, char *str, size_t start, size_t len)
  1005. {
  1006. scm_c_issue_deprecation_warning
  1007. ("scm_c_substring2str is deprecated. Use scm_substring plus scm_to_locale_stringbuf instead.");
  1008. if (start)
  1009. obj = scm_substring (obj, scm_from_size_t (start), SCM_UNDEFINED);
  1010. scm_to_locale_stringbuf (obj, str, len);
  1011. return str;
  1012. }
  1013. /* Converts the given Scheme symbol OBJ into a C string, containing a copy
  1014. of OBJ's content with a trailing null byte. If LENP is non-NULL, set
  1015. *LENP to the string's length.
  1016. When STR is non-NULL it receives the copy and is returned by the function,
  1017. otherwise new memory is allocated and the caller is responsible for
  1018. freeing it via free(). If out of memory, NULL is returned.
  1019. Note that Scheme symbols may contain arbitrary data, including null
  1020. characters. This means that null termination is not a reliable way to
  1021. determine the length of the returned value. However, the function always
  1022. copies the complete contents of OBJ, and sets *LENP to the length of the
  1023. scheme symbol (if LENP is non-null). */
  1024. char *
  1025. scm_c_symbol2str (SCM obj, char *str, size_t *lenp)
  1026. {
  1027. return scm_c_string2str (scm_symbol_to_string (obj), str, lenp);
  1028. }
  1029. double
  1030. scm_truncate (double x)
  1031. {
  1032. scm_c_issue_deprecation_warning
  1033. ("scm_truncate is deprecated. Use scm_c_truncate instead.");
  1034. return scm_c_truncate (x);
  1035. }
  1036. double
  1037. scm_round (double x)
  1038. {
  1039. scm_c_issue_deprecation_warning
  1040. ("scm_round is deprecated. Use scm_c_round instead.");
  1041. return scm_c_round (x);
  1042. }
  1043. char *
  1044. scm_i_deprecated_symbol_chars (SCM sym)
  1045. {
  1046. scm_c_issue_deprecation_warning
  1047. ("SCM_SYMBOL_CHARS is deprecated. Use scm_symbol_to_string.");
  1048. return (char *)scm_i_symbol_chars (sym);
  1049. }
  1050. size_t
  1051. scm_i_deprecated_symbol_length (SCM sym)
  1052. {
  1053. scm_c_issue_deprecation_warning
  1054. ("SCM_SYMBOL_LENGTH is deprecated. Use scm_symbol_to_string.");
  1055. return scm_i_symbol_length (sym);
  1056. }
  1057. int
  1058. scm_i_keywordp (SCM obj)
  1059. {
  1060. scm_c_issue_deprecation_warning
  1061. ("SCM_KEYWORDP is deprecated. Use scm_is_keyword instead.");
  1062. return scm_is_keyword (obj);
  1063. }
  1064. SCM
  1065. scm_i_keywordsym (SCM keyword)
  1066. {
  1067. scm_c_issue_deprecation_warning
  1068. ("SCM_KEYWORDSYM is deprecated. See scm_keyword_to_symbol instead.");
  1069. return scm_keyword_dash_symbol (keyword);
  1070. }
  1071. int
  1072. scm_i_vectorp (SCM x)
  1073. {
  1074. scm_c_issue_deprecation_warning
  1075. ("SCM_VECTORP is deprecated. Use scm_is_vector instead.");
  1076. return SCM_I_IS_VECTOR (x);
  1077. }
  1078. unsigned long
  1079. scm_i_vector_length (SCM x)
  1080. {
  1081. scm_c_issue_deprecation_warning
  1082. ("SCM_VECTOR_LENGTH is deprecated. Use scm_c_vector_length instead.");
  1083. return SCM_I_VECTOR_LENGTH (x);
  1084. }
  1085. const SCM *
  1086. scm_i_velts (SCM x)
  1087. {
  1088. scm_c_issue_deprecation_warning
  1089. ("SCM_VELTS is deprecated. Use scm_vector_elements instead.");
  1090. return SCM_I_VECTOR_ELTS (x);
  1091. }
  1092. SCM *
  1093. scm_i_writable_velts (SCM x)
  1094. {
  1095. scm_c_issue_deprecation_warning
  1096. ("SCM_WRITABLE_VELTS is deprecated. "
  1097. "Use scm_vector_writable_elements instead.");
  1098. return SCM_I_VECTOR_WELTS (x);
  1099. }
  1100. SCM
  1101. scm_i_vector_ref (SCM x, size_t idx)
  1102. {
  1103. scm_c_issue_deprecation_warning
  1104. ("SCM_VECTOR_REF is deprecated. "
  1105. "Use scm_c_vector_ref or scm_vector_elements instead.");
  1106. return scm_c_vector_ref (x, idx);
  1107. }
  1108. void
  1109. scm_i_vector_set (SCM x, size_t idx, SCM val)
  1110. {
  1111. scm_c_issue_deprecation_warning
  1112. ("SCM_VECTOR_SET is deprecated. "
  1113. "Use scm_c_vector_set_x or scm_vector_writable_elements instead.");
  1114. scm_c_vector_set_x (x, idx, val);
  1115. }
  1116. SCM
  1117. scm_vector_equal_p (SCM x, SCM y)
  1118. {
  1119. scm_c_issue_deprecation_warning
  1120. ("scm_vector_euqal_p is deprecated. "
  1121. "Use scm_equal_p instead.");
  1122. return scm_equal_p (x, y);
  1123. }
  1124. int
  1125. scm_i_arrayp (SCM a)
  1126. {
  1127. scm_c_issue_deprecation_warning
  1128. ("SCM_ARRAYP is deprecated. Use scm_is_array instead.");
  1129. return SCM_I_ARRAYP(a) || SCM_I_ENCLOSED_ARRAYP(a);
  1130. }
  1131. size_t
  1132. scm_i_array_ndim (SCM a)
  1133. {
  1134. scm_c_issue_deprecation_warning
  1135. ("SCM_ARRAY_NDIM is deprecated. "
  1136. "Use scm_c_array_rank or scm_array_handle_rank instead.");
  1137. return scm_c_array_rank (a);
  1138. }
  1139. int
  1140. scm_i_array_contp (SCM a)
  1141. {
  1142. scm_c_issue_deprecation_warning
  1143. ("SCM_ARRAY_CONTP is deprecated. Do not use it.");
  1144. return SCM_I_ARRAY_CONTP (a);
  1145. }
  1146. scm_t_array *
  1147. scm_i_array_mem (SCM a)
  1148. {
  1149. scm_c_issue_deprecation_warning
  1150. ("SCM_ARRAY_MEM is deprecated. Do not use it.");
  1151. return (scm_t_array *)SCM_I_ARRAY_MEM (a);
  1152. }
  1153. SCM
  1154. scm_i_array_v (SCM a)
  1155. {
  1156. /* We could use scm_shared_array_root here, but it is better to move
  1157. them away from expecting vectors as the basic storage for arrays.
  1158. */
  1159. scm_c_issue_deprecation_warning
  1160. ("SCM_ARRAY_V is deprecated. Do not use it.");
  1161. return SCM_I_ARRAY_V (a);
  1162. }
  1163. size_t
  1164. scm_i_array_base (SCM a)
  1165. {
  1166. scm_c_issue_deprecation_warning
  1167. ("SCM_ARRAY_BASE is deprecated. Do not use it.");
  1168. return SCM_I_ARRAY_BASE (a);
  1169. }
  1170. scm_t_array_dim *
  1171. scm_i_array_dims (SCM a)
  1172. {
  1173. scm_c_issue_deprecation_warning
  1174. ("SCM_ARRAY_DIMS is deprecated. Use scm_array_handle_dims instead.");
  1175. return SCM_I_ARRAY_DIMS (a);
  1176. }
  1177. SCM
  1178. scm_i_cur_inp (void)
  1179. {
  1180. scm_c_issue_deprecation_warning
  1181. ("scm_cur_inp is deprecated. Use scm_current_input_port instead.");
  1182. return scm_current_input_port ();
  1183. }
  1184. SCM
  1185. scm_i_cur_outp (void)
  1186. {
  1187. scm_c_issue_deprecation_warning
  1188. ("scm_cur_outp is deprecated. Use scm_current_output_port instead.");
  1189. return scm_current_output_port ();
  1190. }
  1191. SCM
  1192. scm_i_cur_errp (void)
  1193. {
  1194. scm_c_issue_deprecation_warning
  1195. ("scm_cur_errp is deprecated. Use scm_current_error_port instead.");
  1196. return scm_current_error_port ();
  1197. }
  1198. SCM
  1199. scm_i_cur_loadp (void)
  1200. {
  1201. scm_c_issue_deprecation_warning
  1202. ("scm_cur_loadp is deprecated. Use scm_current_load_port instead.");
  1203. return scm_current_load_port ();
  1204. }
  1205. SCM
  1206. scm_i_progargs (void)
  1207. {
  1208. scm_c_issue_deprecation_warning
  1209. ("scm_progargs is deprecated. Use scm_program_arguments instead.");
  1210. return scm_program_arguments ();
  1211. }
  1212. SCM
  1213. scm_i_deprecated_dynwinds (void)
  1214. {
  1215. scm_c_issue_deprecation_warning
  1216. ("scm_dynwinds is deprecated. Do not use it.");
  1217. return scm_i_dynwinds ();
  1218. }
  1219. scm_t_debug_frame *
  1220. scm_i_deprecated_last_debug_frame (void)
  1221. {
  1222. scm_c_issue_deprecation_warning
  1223. ("scm_last_debug_frame is deprecated. Do not use it.");
  1224. return scm_i_last_debug_frame ();
  1225. }
  1226. SCM_STACKITEM *
  1227. scm_i_stack_base (void)
  1228. {
  1229. scm_c_issue_deprecation_warning
  1230. ("scm_stack_base is deprecated. Do not use it.");
  1231. return SCM_I_CURRENT_THREAD->base;
  1232. }
  1233. int
  1234. scm_i_fluidp (SCM x)
  1235. {
  1236. scm_c_issue_deprecation_warning
  1237. ("SCM_FLUIDP is deprecated. Use scm_is_fluid instead.");
  1238. return scm_is_fluid (x);
  1239. }
  1240. void
  1241. scm_i_defer_ints_etc ()
  1242. {
  1243. scm_c_issue_deprecation_warning
  1244. ("SCM_DEFER_INTS etc are deprecated. "
  1245. "Use a mutex instead if appropriate.");
  1246. }
  1247. SCM
  1248. scm_guard (SCM guardian, SCM obj, int throw_p)
  1249. {
  1250. scm_c_issue_deprecation_warning
  1251. ("scm_guard is deprecated. Use scm_call_1 instead.");
  1252. return scm_call_1 (guardian, obj);
  1253. }
  1254. SCM
  1255. scm_get_one_zombie (SCM guardian)
  1256. {
  1257. scm_c_issue_deprecation_warning
  1258. ("scm_guard is deprecated. Use scm_call_0 instead.");
  1259. return scm_call_0 (guardian);
  1260. }
  1261. SCM_DEFINE (scm_guardian_destroyed_p, "guardian-destroyed?", 1, 0, 0,
  1262. (SCM guardian),
  1263. "Return @code{#t} if @var{guardian} has been destroyed, otherwise @code{#f}.")
  1264. #define FUNC_NAME s_scm_guardian_destroyed_p
  1265. {
  1266. scm_c_issue_deprecation_warning
  1267. ("'guardian-destroyed?' is deprecated.");
  1268. return SCM_BOOL_F;
  1269. }
  1270. #undef FUNC_NAME
  1271. SCM_DEFINE (scm_guardian_greedy_p, "guardian-greedy?", 1, 0, 0,
  1272. (SCM guardian),
  1273. "Return @code{#t} if @var{guardian} is a greedy guardian, otherwise @code{#f}.")
  1274. #define FUNC_NAME s_scm_guardian_greedy_p
  1275. {
  1276. scm_c_issue_deprecation_warning
  1277. ("'guardian-greedy?' is deprecated.");
  1278. return SCM_BOOL_F;
  1279. }
  1280. #undef FUNC_NAME
  1281. SCM_DEFINE (scm_destroy_guardian_x, "destroy-guardian!", 1, 0, 0,
  1282. (SCM guardian),
  1283. "Destroys @var{guardian}, by making it impossible to put any more\n"
  1284. "objects in it or get any objects from it. It also unguards any\n"
  1285. "objects guarded by @var{guardian}.")
  1286. #define FUNC_NAME s_scm_destroy_guardian_x
  1287. {
  1288. scm_c_issue_deprecation_warning
  1289. ("'destroy-guardian!' is deprecated and ineffective.");
  1290. return SCM_UNSPECIFIED;
  1291. }
  1292. #undef FUNC_NAME
  1293. void
  1294. scm_i_init_deprecated ()
  1295. {
  1296. #include "libguile/deprecated.x"
  1297. }
  1298. #endif