throw.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef SCM_THROW_H
  2. #define SCM_THROW_H
  3. /* Copyright 1995-1996,1998,2000,2006,2008,2010,2014,2017-2019
  4. Free Software Foundation, Inc.
  5. This file is part of Guile.
  6. Guile is free software: you can redistribute it and/or modify it
  7. under the terms of the GNU Lesser General Public License as published
  8. by the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Guile is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  13. License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with Guile. If not, see
  16. <https://www.gnu.org/licenses/>. */
  17. #include "libguile/scm.h"
  18. #include "libguile/exceptions.h"
  19. typedef scm_t_thunk scm_t_catch_body;
  20. typedef SCM (*scm_t_catch_handler) (void *data,
  21. SCM tag, SCM throw_args);
  22. SCM_INTERNAL SCM scm_i_make_catch_handler (scm_t_catch_handler h, void *data);
  23. SCM_API SCM scm_c_catch (SCM tag,
  24. scm_t_catch_body body,
  25. void *body_data,
  26. scm_t_catch_handler handler,
  27. void *handler_data,
  28. scm_t_catch_handler pre_unwind_handler,
  29. void *pre_unwind_handler_data);
  30. SCM_API SCM scm_c_with_throw_handler (SCM tag,
  31. scm_t_catch_body body,
  32. void *body_data,
  33. scm_t_catch_handler handler,
  34. void *handler_data,
  35. int lazy_catch_p);
  36. SCM_API SCM scm_internal_catch (SCM tag,
  37. scm_t_catch_body body,
  38. void *body_data,
  39. scm_t_catch_handler handler,
  40. void *handler_data);
  41. /* The first argument to scm_body_thunk should be a pointer to one of
  42. these. See the implementation of catch in throw.c. */
  43. struct scm_body_thunk_data
  44. {
  45. /* The tag being caught. We only use it to figure out what
  46. arguments to pass to the body procedure; see scm_catch_thunk_body for
  47. details. */
  48. SCM tag;
  49. /* The Scheme procedure object constituting the catch body.
  50. scm_body_by_proc invokes this. */
  51. SCM body_proc;
  52. };
  53. SCM_API SCM scm_body_thunk (void *);
  54. SCM_API SCM scm_handle_by_proc (void *, SCM, SCM);
  55. SCM_API SCM scm_handle_by_proc_catching_all (void *, SCM, SCM);
  56. SCM_API SCM scm_handle_by_message (void *, SCM, SCM);
  57. SCM_API SCM scm_handle_by_message_noexit (void *, SCM, SCM);
  58. SCM_API SCM scm_handle_by_throw (void *, SCM, SCM);
  59. SCM_API int scm_exit_status (SCM args);
  60. SCM_API SCM scm_catch_with_pre_unwind_handler (SCM tag, SCM thunk, SCM handler, SCM lazy_handler);
  61. SCM_API SCM scm_catch (SCM tag, SCM thunk, SCM handler);
  62. SCM_API SCM scm_with_throw_handler (SCM tag, SCM thunk, SCM handler);
  63. SCM_API SCM scm_ithrow (SCM key, SCM args, int no_return) SCM_NORETURN;
  64. SCM_API SCM scm_throw (SCM key, SCM args) SCM_NORETURN;
  65. SCM_INTERNAL void scm_init_throw (void);
  66. #endif /* SCM_THROW_H */