1 /* classes: h_files */ 2 3 #ifndef SCM_THROW_H 4 #define SCM_THROW_H 5 6 /* Copyright (C) 1995,1996,1998,2000, 2006, 2008, 2010, 2014 Free Software Foundation, Inc. 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public License 10 * as published by the Free Software Foundation; either version 3 of 11 * the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 * 02110-1301 USA 22 */ 23 24 25 26 #include "libguile/__scm.h" 27 28 29 30 typedef SCM (*scm_t_catch_body) (void *data); 31 typedef SCM (*scm_t_catch_handler) (void *data, 32 SCM tag, SCM throw_args); 33 34 SCM_INTERNAL SCM scm_i_make_catch_body_closure (scm_t_catch_body body, 35 void *body_data); 36 SCM_INTERNAL SCM scm_i_make_catch_handler_closure (scm_t_catch_handler h, 37 void *handler_data); 38 39 SCM_API SCM scm_c_catch (SCM tag, 40 scm_t_catch_body body, 41 void *body_data, 42 scm_t_catch_handler handler, 43 void *handler_data, 44 scm_t_catch_handler pre_unwind_handler, 45 void *pre_unwind_handler_data); 46 47 SCM_API SCM scm_c_with_throw_handler (SCM tag, 48 scm_t_catch_body body, 49 void *body_data, 50 scm_t_catch_handler handler, 51 void *handler_data, 52 int lazy_catch_p); 53 54 SCM_API SCM scm_internal_catch (SCM tag, 55 scm_t_catch_body body, 56 void *body_data, 57 scm_t_catch_handler handler, 58 void *handler_data); 59 60 /* The first argument to scm_body_thunk should be a pointer to one of 61 these. See the implementation of catch in throw.c. */ 62 struct scm_body_thunk_data 63 { 64 /* The tag being caught. We only use it to figure out what 65 arguments to pass to the body procedure; see scm_catch_thunk_body for 66 details. */ 67 SCM tag; 68 69 /* The Scheme procedure object constituting the catch body. 70 scm_body_by_proc invokes this. */ 71 SCM body_proc; 72 }; 73 74 SCM_API SCM scm_body_thunk (void *); 75 76 77 SCM_API SCM scm_handle_by_proc (void *, SCM, SCM); 78 SCM_API SCM scm_handle_by_proc_catching_all (void *, SCM, SCM); 79 SCM_API SCM scm_handle_by_message (void *, SCM, SCM); 80 SCM_API SCM scm_handle_by_message_noexit (void *, SCM, SCM); 81 SCM_API SCM scm_handle_by_throw (void *, SCM, SCM); 82 SCM_API int scm_exit_status (SCM args); 83 84 SCM_API SCM scm_catch_with_pre_unwind_handler (SCM tag, SCM thunk, SCM handler, SCM lazy_handler); 85 SCM_API SCM scm_catch (SCM tag, SCM thunk, SCM handler); 86 SCM_API SCM scm_with_throw_handler (SCM tag, SCM thunk, SCM handler); 87 SCM_API SCM scm_ithrow (SCM key, SCM args, int no_return); 88 89 /* This throws to the `stack-overflow' key, without running pre-unwind 90 handlers. */ 91 SCM_API void scm_report_stack_overflow (void); 92 93 /* This throws to the `out-of-memory' key, without running pre-unwind 94 handlers. */ 95 SCM_API void scm_report_out_of_memory (void); 96 97 SCM_API SCM scm_throw (SCM key, SCM args); 98 SCM_INTERNAL void scm_init_throw (void); 99 100 #endif /* SCM_THROW_H */ 101 102 /* 103 Local Variables: 104 c-file-style: "gnu" 105 End: 106 */ 107