mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 04:40:29 +02:00
use separate data pointers, to allow them to be designed independently and reused. (scm_body_thunk, scm_handle_by_proc, scm_handle_by_message): Renamed from catch_body, catch_handler, and uncaught_throw; made generically useful. (struct scm_catch_body_data): Renamed from catch_body_data; moved to throw.h. (scm_catch): Use the above. (scm_throw): Don't bother printing a message for an uncaught throw; we establish a default handler in init. * throw.h (scm_internal_catch): Prototype updated. (scm_body_thunk, scm_handle_by_proc, scm_handle_by_message): New decls. (struct scm_body_thunk_data): New structure, used as data argument to scm_body_thunk. * init.c (struct main_func_closure): New structure, packaging up the data to pass to the user's main function. (scm_boot_guile): Create one. Pass it to scm_boot_guile_1. (scm_boot_guile_1): Pass it through to invoke_main_func. Use scm_internal_catch to establish a catch-all handler, using scm_handle_by_message. This replaces the special-case code in scm_throw. (invoke_main_func): Body function for scm_internal_catch; invoke the user's main function, using the main_func_closure pointer to decide what to pass it. * root.c (struct cwdr_body_data): Remove handler_proc member. (cwdr): Use scm_handle_by_proc instead of cwdr_handler. (cwdr_handler): Removed.
86 lines
3.3 KiB
C
86 lines
3.3 KiB
C
/* classes: h_files */
|
||
|
||
#ifndef THROWH
|
||
#define THROWH
|
||
/* Copyright (C) 1995,1996 Free Software Foundation, Inc.
|
||
*
|
||
* This program is free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2, or (at your option)
|
||
* any later version.
|
||
*
|
||
* This program is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU General Public License
|
||
* along with this software; see the file COPYING. If not, write to
|
||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
*
|
||
* As a special exception, the Free Software Foundation gives permission
|
||
* for additional uses of the text contained in its release of GUILE.
|
||
*
|
||
* The exception is that, if you link the GUILE library with other files
|
||
* to produce an executable, this does not by itself cause the
|
||
* resulting executable to be covered by the GNU General Public License.
|
||
* Your use of that executable is in no way restricted on account of
|
||
* linking the GUILE library code into it.
|
||
*
|
||
* This exception does not however invalidate any other reasons why
|
||
* the executable file might be covered by the GNU General Public License.
|
||
*
|
||
* This exception applies only to the code released by the
|
||
* Free Software Foundation under the name GUILE. If you copy
|
||
* code from other Free Software Foundation releases into a copy of
|
||
* GUILE, as the General Public License permits, the exception does
|
||
* not apply to the code that you add in this way. To avoid misleading
|
||
* anyone as to the status of such modified files, you must delete
|
||
* this exception notice from them.
|
||
*
|
||
* If you write modifications of your own for GUILE, it is your choice
|
||
* whether to permit this exception to apply to your modifications.
|
||
* If you do not wish that, delete this exception notice.
|
||
*/
|
||
|
||
|
||
#include "libguile/__scm.h"
|
||
|
||
|
||
|
||
typedef SCM (*scm_catch_body_t) SCM_P ((void *data, SCM jmpbuf));
|
||
typedef SCM (*scm_catch_handler_t) SCM_P ((void *data,
|
||
SCM tag, SCM throw_args));
|
||
|
||
extern SCM scm_internal_catch SCM_P ((SCM tag,
|
||
scm_catch_body_t body,
|
||
void *body_data,
|
||
scm_catch_handler_t handler,
|
||
void *handler_data));
|
||
|
||
/* The first argument to scm_body_thunk should be a pointer to one of
|
||
these. See the implementation of catch in throw.c. */
|
||
struct scm_body_thunk_data
|
||
{
|
||
/* The tag being caught. We only use it to figure out what
|
||
arguments to pass to the body procedure; see scm_catch_thunk_body for
|
||
details. */
|
||
SCM tag;
|
||
|
||
/* The Scheme procedure object constituting the catch body.
|
||
scm_body_by_proc invokes this. */
|
||
SCM body_proc;
|
||
};
|
||
|
||
extern SCM scm_body_thunk SCM_P ((void *, SCM));
|
||
|
||
|
||
extern SCM scm_handle_by_proc SCM_P ((void *, SCM, SCM));
|
||
extern SCM scm_handle_by_message SCM_P ((void *, SCM, SCM));
|
||
|
||
extern SCM scm_catch SCM_P ((SCM tag, SCM thunk, SCM handler));
|
||
extern SCM scm_lazy_catch SCM_P ((SCM tag, SCM thunk, SCM handler));
|
||
extern SCM scm_ithrow SCM_P ((SCM key, SCM args, int noreturn));
|
||
extern SCM scm_throw SCM_P ((SCM key, SCM args));
|
||
extern void scm_init_throw SCM_P ((void));
|
||
#endif /* THROWH */
|