deprecated.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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, 2009, 2010, 2011, 2012, 2013 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 License
  8. * as published by the Free Software Foundation; either version 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * 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
  19. * 02110-1301 USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. # include <config.h>
  23. #endif
  24. #define SCM_BUILDING_DEPRECATED_CODE
  25. #include "libguile/_scm.h"
  26. #include "libguile/deprecation.h"
  27. #if (SCM_ENABLE_DEPRECATED == 1)
  28. SCM
  29. scm_internal_dynamic_wind (scm_t_guard before,
  30. scm_t_inner inner,
  31. scm_t_guard after,
  32. void *inner_data,
  33. void *guard_data)
  34. {
  35. SCM ans;
  36. scm_c_issue_deprecation_warning
  37. ("`scm_internal_dynamic_wind' is deprecated. "
  38. "Use the `scm_dynwind_begin' / `scm_dynwind_end' API instead.");
  39. scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE);
  40. scm_dynwind_rewind_handler (before, guard_data, SCM_F_WIND_EXPLICITLY);
  41. scm_dynwind_unwind_handler (after, guard_data, SCM_F_WIND_EXPLICITLY);
  42. ans = inner (inner_data);
  43. scm_dynwind_end ();
  44. return ans;
  45. }
  46. SCM
  47. scm_immutable_cell (scm_t_bits car, scm_t_bits cdr)
  48. {
  49. scm_c_issue_deprecation_warning
  50. ("scm_immutable_cell is deprecated. Use scm_cell instead.");
  51. return scm_cell (car, cdr);
  52. }
  53. SCM
  54. scm_immutable_double_cell (scm_t_bits car, scm_t_bits cbr,
  55. scm_t_bits ccr, scm_t_bits cdr)
  56. {
  57. scm_c_issue_deprecation_warning
  58. ("scm_immutable_double_cell is deprecated. Use scm_double_cell instead.");
  59. return scm_double_cell (car, cbr, ccr, cdr);
  60. }
  61. SCM_DEFINE (scm_generalized_vector_p, "generalized-vector?", 1, 0, 0,
  62. (SCM obj),
  63. "Return @code{#t} if @var{obj} is a vector, string,\n"
  64. "bitvector, or uniform numeric vector.")
  65. #define FUNC_NAME s_scm_generalized_vector_p
  66. {
  67. scm_c_issue_deprecation_warning
  68. ("generalized-vector? is deprecated. Use array? and check the "
  69. "array-rank instead.");
  70. return scm_from_bool (scm_is_generalized_vector (obj));
  71. }
  72. #undef FUNC_NAME
  73. SCM_DEFINE (scm_generalized_vector_length, "generalized-vector-length", 1, 0, 0,
  74. (SCM v),
  75. "Return the length of the generalized vector @var{v}.")
  76. #define FUNC_NAME s_scm_generalized_vector_length
  77. {
  78. scm_c_issue_deprecation_warning
  79. ("generalized-vector-length is deprecated. Use array-length instead.");
  80. return scm_from_size_t (scm_c_generalized_vector_length (v));
  81. }
  82. #undef FUNC_NAME
  83. SCM_DEFINE (scm_generalized_vector_ref, "generalized-vector-ref", 2, 0, 0,
  84. (SCM v, SCM idx),
  85. "Return the element at index @var{idx} of the\n"
  86. "generalized vector @var{v}.")
  87. #define FUNC_NAME s_scm_generalized_vector_ref
  88. {
  89. scm_c_issue_deprecation_warning
  90. ("generalized-vector-ref is deprecated. Use array-ref instead.");
  91. return scm_c_generalized_vector_ref (v, scm_to_size_t (idx));
  92. }
  93. #undef FUNC_NAME
  94. SCM_DEFINE (scm_generalized_vector_set_x, "generalized-vector-set!", 3, 0, 0,
  95. (SCM v, SCM idx, SCM val),
  96. "Set the element at index @var{idx} of the\n"
  97. "generalized vector @var{v} to @var{val}.")
  98. #define FUNC_NAME s_scm_generalized_vector_set_x
  99. {
  100. scm_c_issue_deprecation_warning
  101. ("generalized-vector-set! is deprecated. Use array-set! instead. "
  102. "Note the change in argument order!");
  103. scm_c_generalized_vector_set_x (v, scm_to_size_t (idx), val);
  104. return SCM_UNSPECIFIED;
  105. }
  106. #undef FUNC_NAME
  107. SCM_DEFINE (scm_generalized_vector_to_list, "generalized-vector->list", 1, 0, 0,
  108. (SCM v),
  109. "Return a new list whose elements are the elements of the\n"
  110. "generalized vector @var{v}.")
  111. #define FUNC_NAME s_scm_generalized_vector_to_list
  112. {
  113. /* FIXME: This duplicates `array_to_list'. */
  114. SCM ret = SCM_EOL;
  115. long inc;
  116. ssize_t pos, i;
  117. scm_t_array_handle h;
  118. scm_c_issue_deprecation_warning
  119. ("generalized-vector->list is deprecated. Use array->list instead.");
  120. scm_generalized_vector_get_handle (v, &h);
  121. i = h.dims[0].ubnd - h.dims[0].lbnd + 1;
  122. inc = h.dims[0].inc;
  123. pos = (i - 1) * inc;
  124. for (; i > 0; i--, pos -= inc)
  125. ret = scm_cons (h.impl->vref (&h, h.base + pos), ret);
  126. scm_array_handle_release (&h);
  127. return ret;
  128. }
  129. #undef FUNC_NAME
  130. void
  131. scm_i_init_deprecated ()
  132. {
  133. #include "libguile/deprecated.x"
  134. }
  135. #endif