throw.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef SCM_THROW_H
  2. #define SCM_THROW_H
  3. /* Copyright 1995-1996,1998,2000,2006,2008,2010,2014,2017-2018
  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. typedef SCM (*scm_t_catch_body) (void *data);
  19. typedef SCM (*scm_t_catch_handler) (void *data,
  20. SCM tag, SCM throw_args);
  21. SCM_INTERNAL SCM scm_i_make_catch_body_closure (scm_t_catch_body body,
  22. void *body_data);
  23. SCM_INTERNAL SCM scm_i_make_catch_handler_closure (scm_t_catch_handler h,
  24. void *handler_data);
  25. SCM_API SCM scm_c_catch (SCM tag,
  26. scm_t_catch_body body,
  27. void *body_data,
  28. scm_t_catch_handler handler,
  29. void *handler_data,
  30. scm_t_catch_handler pre_unwind_handler,
  31. void *pre_unwind_handler_data);
  32. SCM_API SCM scm_c_with_throw_handler (SCM tag,
  33. scm_t_catch_body body,
  34. void *body_data,
  35. scm_t_catch_handler handler,
  36. void *handler_data,
  37. int lazy_catch_p);
  38. SCM_API SCM scm_internal_catch (SCM tag,
  39. scm_t_catch_body body,
  40. void *body_data,
  41. scm_t_catch_handler handler,
  42. void *handler_data);
  43. /* The first argument to scm_body_thunk should be a pointer to one of
  44. these. See the implementation of catch in throw.c. */
  45. struct scm_body_thunk_data
  46. {
  47. /* The tag being caught. We only use it to figure out what
  48. arguments to pass to the body procedure; see scm_catch_thunk_body for
  49. details. */
  50. SCM tag;
  51. /* The Scheme procedure object constituting the catch body.
  52. scm_body_by_proc invokes this. */
  53. SCM body_proc;
  54. };
  55. SCM_API SCM scm_body_thunk (void *);
  56. SCM_API SCM scm_handle_by_proc (void *, SCM, SCM);
  57. SCM_API SCM scm_handle_by_proc_catching_all (void *, SCM, SCM);
  58. SCM_API SCM scm_handle_by_message (void *, SCM, SCM);
  59. SCM_API SCM scm_handle_by_message_noexit (void *, SCM, SCM);
  60. SCM_API SCM scm_handle_by_throw (void *, SCM, SCM);
  61. SCM_API int scm_exit_status (SCM args);
  62. SCM_API SCM scm_catch_with_pre_unwind_handler (SCM tag, SCM thunk, SCM handler, SCM lazy_handler);
  63. SCM_API SCM scm_catch (SCM tag, SCM thunk, SCM handler);
  64. SCM_API SCM scm_with_throw_handler (SCM tag, SCM thunk, SCM handler);
  65. SCM_API SCM scm_ithrow (SCM key, SCM args, int no_return) SCM_NORETURN;
  66. /* This throws to the `stack-overflow' key, without running pre-unwind
  67. handlers. */
  68. SCM_API void scm_report_stack_overflow (void);
  69. /* This throws to the `out-of-memory' key, without running pre-unwind
  70. handlers. */
  71. SCM_API void scm_report_out_of_memory (void);
  72. SCM_API SCM scm_throw (SCM key, SCM args) SCM_NORETURN;
  73. SCM_INTERNAL void scm_init_throw (void);
  74. #endif /* SCM_THROW_H */