gh_eval.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* Copyright (C) 1995,1996,1997,1998, 2000, 2001, 2006, 2008 Free Software Foundation, Inc.
  2. * This library is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU Lesser General Public
  4. * License as published by the Free Software Foundation; either
  5. * version 2.1 of the License, or (at your option) any later version.
  6. *
  7. * This library is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. * Lesser General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU Lesser General Public
  13. * License along with this library; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  15. */
  16. /* routines to evaluate Scheme code */
  17. #ifdef HAVE_CONFIG_H
  18. # include <config.h>
  19. #endif
  20. #include "libguile/gh.h"
  21. #if SCM_ENABLE_DEPRECATED
  22. typedef SCM (*gh_eval_t) (void *data, SCM jmpbuf);
  23. /* Evaluate the string; toss the value. */
  24. SCM
  25. gh_eval_str (const char *scheme_code)
  26. {
  27. return scm_c_eval_string (scheme_code);
  28. }
  29. /* evaluate the file by passing it to the lower level scm_primitive_load() */
  30. SCM
  31. gh_eval_file (const char *fname)
  32. {
  33. return scm_primitive_load (gh_str02scm (fname));
  34. }
  35. static SCM
  36. eval_str_wrapper (void *data)
  37. {
  38. /* gh_eval_t real_eval_proc = (gh_eval_t) (* ((gh_eval_t *) data)); */
  39. char *scheme_code = (char *) data;
  40. return gh_eval_str (scheme_code);
  41. }
  42. SCM
  43. gh_eval_str_with_catch (const char *scheme_code, scm_t_catch_handler handler)
  44. {
  45. /* FIXME: not there yet */
  46. return gh_catch (SCM_BOOL_T, (scm_t_catch_body) eval_str_wrapper, (void *) scheme_code,
  47. (scm_t_catch_handler) handler, (void *) scheme_code);
  48. }
  49. SCM
  50. gh_eval_str_with_standard_handler (const char *scheme_code)
  51. {
  52. return gh_eval_str_with_catch (scheme_code, gh_standard_handler);
  53. }
  54. SCM
  55. gh_eval_str_with_stack_saving_handler (const char *scheme_code)
  56. {
  57. return scm_internal_stack_catch (SCM_BOOL_T,
  58. (scm_t_catch_body) eval_str_wrapper,
  59. (void *) scheme_code,
  60. (scm_t_catch_handler)
  61. gh_standard_handler,
  62. (void *) scheme_code);
  63. }
  64. static SCM
  65. eval_file_wrapper (void *data)
  66. {
  67. /* gh_eval_t real_eval_proc = (gh_eval_t) (* ((gh_eval_t *) data)); */
  68. char *scheme_code = (char *) data;
  69. return gh_eval_file (scheme_code);
  70. }
  71. SCM
  72. gh_eval_file_with_catch (const char *scheme_code, scm_t_catch_handler handler)
  73. {
  74. /* FIXME: not there yet */
  75. return gh_catch (SCM_BOOL_T, (scm_t_catch_body) eval_file_wrapper,
  76. (void *) scheme_code, (scm_t_catch_handler) handler,
  77. (void *) scheme_code);
  78. }
  79. SCM
  80. gh_eval_file_with_standard_handler (const char *scheme_code)
  81. {
  82. return gh_eval_file_with_catch (scheme_code, gh_standard_handler);
  83. }
  84. #endif /* SCM_ENABLE_DEPRECATED */
  85. /*
  86. Local Variables:
  87. c-file-style: "gnu"
  88. End:
  89. */