summaryrefslogtreecommitdiff
path: root/libguile/root.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@red-bean.com>1996-12-21 04:48:21 +0000
committerJim Blandy <jimb@red-bean.com>1996-12-21 04:48:21 +0000
commit816a6f06c852efd6065bf9d2a943eb6896795f8d (patch)
treee50449b0bfd5171ae8b8668ace9cf48b02291f61 /libguile/root.c
parent370312ae6e74756a825f3eeed0e227c568142f16 (diff)
downloadguile-816a6f06c852efd6065bf9d2a943eb6896795f8d.tar.gz
* throw.c (scm_internal_catch): Make body funcs and handler funcs
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.
Diffstat (limited to 'libguile/root.c')
-rw-r--r--libguile/root.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/libguile/root.c b/libguile/root.c
index b79e7b72b..7546ecbd5 100644
--- a/libguile/root.c
+++ b/libguile/root.c
@@ -178,8 +178,8 @@ static int n_dynamic_roots = 0;
/* cwdr fills out one of these structures, and then passes a pointer
- to it through scm_internal_catch to the cwdr_body and cwdr_handler
- functions, to tell them how to behave.
+ to it through scm_internal_catch to the cwdr_body function, to tell
+ it how to behave.
A cwdr is a lot like a catch, except there is no tag (all
exceptions are caught), and the body procedure takes the arguments
@@ -192,15 +192,15 @@ struct cwdr_body_data {
/* Scheme procedure to use as body of cwdr. */
SCM body_proc;
-
- /* Scheme procedure to call if a throw occurs within the cwdr. */
- SCM handler_proc;
};
/* Invoke the body of a cwdr, assuming that the throw handler has
already been set up. DATA points to a struct set up by cwdr that
- says what proc to call, and what args to apply it to. */
+ says what proc to call, and what args to apply it to.
+
+ With a little thought, we could replace this with scm_body_thunk,
+ but I don't want to mess with that at the moment. */
static SCM cwdr_body SCM_P ((void *, SCM));
static SCM
@@ -212,19 +212,6 @@ cwdr_body (void *data, SCM jmpbuf)
}
-/* Invoke the handler of a cwdr. DATA points to a struct set up by
- cwdr that says what proc to call to handle the throw. */
-static SCM cwdr_handler SCM_P ((void *, SCM, SCM));
-
-static SCM
-cwdr_handler (void *data, SCM tag, SCM throw_args)
-{
- struct cwdr_body_data *c = (struct cwdr_body_data *) data;
-
- return scm_apply (c->handler_proc, scm_cons (tag, throw_args), SCM_EOL);
-}
-
-
static SCM cwdr SCM_P ((SCM thunk, SCM a1, SCM args, SCM handler, SCM_STACKITEM *stack_start));
/* This is the basic code for new root creation.
@@ -282,9 +269,10 @@ cwdr (proc, a1, args, handler, stack_start)
c.a1 = a1;
c.args = args;
c.body_proc = proc;
- c.handler_proc = handler;
- answer = scm_internal_catch (SCM_BOOL_T, cwdr_body, cwdr_handler, &c);
+ answer = scm_internal_catch (SCM_BOOL_T,
+ cwdr_body, &c,
+ scm_handle_by_proc, &handler);
}
scm_dowinds (old_winds, - scm_ilength (old_winds));