2018-06-20 19:17:06 +02:00
|
|
|
|
/* Copyright 1995-1996,1998-2001,2003,2006,2008-2009,2011,2018
|
2018-06-20 20:01:49 +02:00
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
|
|
This file is part of Guile.
|
|
|
|
|
|
|
|
|
|
|
|
Guile is free software: you can redistribute it and/or modify it
|
|
|
|
|
|
under the terms of the GNU Lesser General Public License as published
|
|
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
|
|
Guile 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 Lesser General Public
|
|
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
License along with Guile. If not, see
|
|
|
|
|
|
<https://www.gnu.org/licenses/>. */
|
2000-04-21 23:13:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-06-20 18:31:24 +02:00
|
|
|
|
|
2008-09-13 15:35:27 +02:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
2000-04-21 23:13:26 +00:00
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
2018-06-20 18:31:24 +02:00
|
|
|
|
#include "boolean.h"
|
2018-06-20 17:19:31 +02:00
|
|
|
|
#include "eval.h"
|
2018-06-20 18:31:24 +02:00
|
|
|
|
#include "gsubr.h"
|
2018-06-20 17:19:31 +02:00
|
|
|
|
#include "list.h"
|
|
|
|
|
|
#include "numbers.h"
|
2018-06-20 18:31:24 +02:00
|
|
|
|
#include "pairs.h"
|
2018-06-20 17:19:31 +02:00
|
|
|
|
#include "ports.h"
|
|
|
|
|
|
#include "procprop.h"
|
|
|
|
|
|
#include "smob.h"
|
|
|
|
|
|
#include "strings.h"
|
2000-04-21 23:13:26 +00:00
|
|
|
|
|
2018-06-20 17:19:31 +02:00
|
|
|
|
#include "hooks.h"
|
2000-04-21 23:13:26 +00:00
|
|
|
|
|
2018-06-20 18:31:24 +02:00
|
|
|
|
|
2000-04-21 23:13:26 +00:00
|
|
|
|
|
|
|
|
|
|
/* Scheme level hooks
|
|
|
|
|
|
*
|
|
|
|
|
|
* A hook is basically a list of procedures to be called at well defined
|
|
|
|
|
|
* points in time.
|
|
|
|
|
|
*
|
2000-05-26 16:31:22 +00:00
|
|
|
|
* Hook arity is not a full member of this type and therefore lacks an
|
|
|
|
|
|
* accessor. It exists to aid debugging and is not intended to be used in
|
|
|
|
|
|
* programs.
|
2000-04-21 23:13:26 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_bits scm_tc16_hook;
|
2000-04-21 23:13:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2000-12-08 17:32:56 +00:00
|
|
|
|
hook_print (SCM hook, SCM port, scm_print_state *pstate)
|
2000-04-21 23:13:26 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM ls, name;
|
2016-04-26 23:07:28 +02:00
|
|
|
|
scm_puts ("#<hook ", port);
|
2000-04-21 23:13:26 +00:00
|
|
|
|
scm_intprint (SCM_HOOK_ARITY (hook), 10, port);
|
2016-04-26 23:01:14 +02:00
|
|
|
|
scm_putc (' ', port);
|
* variable.c, threads.c, struct.c, stackchk.c, smob.c, root.c,
print.c, ports.c, mallocs.c, hooks.c, hashtab.c, fports.c,
guardians.c, filesys.c, coop-pthreads.c, continuations.c: Use
scm_uintprint to print unsigned integers, raw heap words, and
adresses, using a cast to scm_t_bits to turn pointers into
integers.
2004-10-22 15:13:12 +00:00
|
|
|
|
scm_uintprint (SCM_UNPACK (hook), 16, port);
|
2000-04-21 23:13:26 +00:00
|
|
|
|
ls = SCM_HOOK_PROCEDURES (hook);
|
2011-10-24 17:22:47 +02:00
|
|
|
|
while (scm_is_pair (ls))
|
2000-04-21 23:13:26 +00:00
|
|
|
|
{
|
2016-04-26 23:01:14 +02:00
|
|
|
|
scm_putc (' ', port);
|
2000-04-21 23:13:26 +00:00
|
|
|
|
name = scm_procedure_name (SCM_CAR (ls));
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_true (name))
|
2000-04-21 23:13:26 +00:00
|
|
|
|
scm_iprin1 (name, port, pstate);
|
|
|
|
|
|
else
|
2016-04-26 23:01:14 +02:00
|
|
|
|
scm_putc ('?', port);
|
2000-04-21 23:13:26 +00:00
|
|
|
|
ls = SCM_CDR (ls);
|
|
|
|
|
|
}
|
2016-04-26 23:01:14 +02:00
|
|
|
|
scm_putc ('>', port);
|
2000-04-21 23:13:26 +00:00
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_make_hook, "make-hook", 0, 1, 0,
|
|
|
|
|
|
(SCM n_args),
|
2001-07-04 06:13:10 +00:00
|
|
|
|
"Create a hook for storing procedure of arity @var{n_args}.\n"
|
|
|
|
|
|
"@var{n_args} defaults to zero. The returned value is a hook\n"
|
|
|
|
|
|
"object to be used with the other hook procedures.")
|
2000-04-21 23:13:26 +00:00
|
|
|
|
#define FUNC_NAME s_scm_make_hook
|
|
|
|
|
|
{
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
unsigned int n;
|
2001-05-28 14:18:35 +00:00
|
|
|
|
|
|
|
|
|
|
if (SCM_UNBNDP (n_args))
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
n = 0;
|
2001-05-28 14:18:35 +00:00
|
|
|
|
else
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
n = scm_to_unsigned_integer (n_args, 0, 16);
|
2001-05-28 14:18:35 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_RETURN_NEWSMOB (scm_tc16_hook + (n << 16), SCM_UNPACK (SCM_EOL));
|
2000-04-21 23:13:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_hook_p, "hook?", 1, 0, 0,
|
|
|
|
|
|
(SCM x),
|
2001-04-09 16:07:15 +00:00
|
|
|
|
"Return @code{#t} if @var{x} is a hook, @code{#f} otherwise.")
|
2000-04-21 23:13:26 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hook_p
|
|
|
|
|
|
{
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_HOOKP (x));
|
2000-04-21 23:13:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_hook_empty_p, "hook-empty?", 1, 0, 0,
|
|
|
|
|
|
(SCM hook),
|
2001-04-09 16:07:15 +00:00
|
|
|
|
"Return @code{#t} if @var{hook} is an empty hook, @code{#f}\n"
|
|
|
|
|
|
"otherwise.")
|
2000-04-21 23:13:26 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hook_empty_p
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_HOOK (1, hook);
|
2004-09-22 17:41:37 +00:00
|
|
|
|
return scm_from_bool (scm_is_null (SCM_HOOK_PROCEDURES (hook)));
|
2000-04-21 23:13:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_add_hook_x, "add-hook!", 2, 1, 0,
|
|
|
|
|
|
(SCM hook, SCM proc, SCM append_p),
|
2001-02-16 15:04:23 +00:00
|
|
|
|
"Add the procedure @var{proc} to the hook @var{hook}. The\n"
|
|
|
|
|
|
"procedure is added to the end if @var{append_p} is true,\n"
|
2001-07-04 06:13:10 +00:00
|
|
|
|
"otherwise it is added to the front. The return value of this\n"
|
|
|
|
|
|
"procedure is not specified.")
|
2000-04-21 23:13:26 +00:00
|
|
|
|
#define FUNC_NAME s_scm_add_hook_x
|
|
|
|
|
|
{
|
eval.c closures are now applicable smobs, not tc3s
* libguile/debug.c (scm_procedure_name): Remove a SCM_CLOSUREP case and
some dead code.
(scm_procedure_module): Remove. This was introduced a few months ago
for the hygienic expander, but now it is no longer needed, as the
expander keeps track of this information itself.
* libguile/debug.h: Remove scm_procedure_module.
* libguile/eval.c: Instead of using tc3 closures, define a "boot
closure" applicable smob type, and represent closures with that. The
advantage is that after eval.scm is compiled, boot closures take up no
address space (besides a smob number) in the runtime, and require no
special cases in procedure dispatch.
* libguile/eval.h: Remove the internal functions scm_i_call_closure_0
and scm_closure_apply, and the public function scm_closure.
* libguile/gc.c (scm_storage_prehistory): No tc3_closure displacement
registration.
(scm_i_tag_name): Remove closure case, and a dead cclo case.
* libguile/vm.c (apply_foreign):
* libguile/print.c (iprin1):
* libguile/procs.c (scm_procedure_p, scm_procedure_documentation);
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (scm_class_of): Remove tc3_closure/tcs_closure cases.
* libguile/hash.c (scm_hasher):
* libguile/hooks.c (scm_add_hook_x): Use new scm_i_procedure_arity.
* libguile/macros.c (macro_print): Print all macros using the same code.
(scm_macro_transformer): Return any procedure, not just programs.
* libguile/procprop.h:
* libguile/procprop.c (scm_i_procedure_arity): Instead of returning a
list that the caller has to parse, have the same prototype as
scm_i_program_arity. An incompatible change, but it's an internal
function anyway.
(scm_procedure_properties, scm_set_procedure_properties)
(scm_procedure_property, scm_set_procedure_property): Remove closure
cases, and use scm_i_program_arity for arity.
* libguile/procs.h (SCM_CLOSUREP, SCM_CLOSCAR, SCM_CODE)
(SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS)
(SCM_CLOSURE_BODY, SCM_PROCPROPS, SCM_SETPROCPROPS, SCM_ENV)
(SCM_TOP_LEVEL): Remove these macros that pertain to boot closures
only. Only eval.c should know abut boot closures.
* libguile/procs.c (scm_closure_p): Remove this function. There is a
simple stub in deprecated.scm now.
(scm_thunk_p): Use scm_i_program_arity.
* libguile/tags.h (scm_tc3_closure): Remove. Yay, another tc3 to play
with!
(scm_tcs_closures): Remove.
* libguile/validate.h (SCM_VALIDATE_CLOSURE): Remove.
* module/ice-9/deprecated.scm (closure?): Add stub.
* module/ice-9/documentation.scm (object-documentation)
* module/ice-9/session.scm (help-doc, arity)
* module/oop/goops.scm (compute-getters-n-setters)
* module/oop/goops/describe.scm (describe)
* module/system/repl/describe.scm (display-object, display-type):
Remove calls to closure?.
2009-12-04 19:20:11 +01:00
|
|
|
|
SCM rest;
|
|
|
|
|
|
int n_args, p_req, p_opt, p_rest;
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_HOOK (1, hook);
|
eval.c closures are now applicable smobs, not tc3s
* libguile/debug.c (scm_procedure_name): Remove a SCM_CLOSUREP case and
some dead code.
(scm_procedure_module): Remove. This was introduced a few months ago
for the hygienic expander, but now it is no longer needed, as the
expander keeps track of this information itself.
* libguile/debug.h: Remove scm_procedure_module.
* libguile/eval.c: Instead of using tc3 closures, define a "boot
closure" applicable smob type, and represent closures with that. The
advantage is that after eval.scm is compiled, boot closures take up no
address space (besides a smob number) in the runtime, and require no
special cases in procedure dispatch.
* libguile/eval.h: Remove the internal functions scm_i_call_closure_0
and scm_closure_apply, and the public function scm_closure.
* libguile/gc.c (scm_storage_prehistory): No tc3_closure displacement
registration.
(scm_i_tag_name): Remove closure case, and a dead cclo case.
* libguile/vm.c (apply_foreign):
* libguile/print.c (iprin1):
* libguile/procs.c (scm_procedure_p, scm_procedure_documentation);
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (scm_class_of): Remove tc3_closure/tcs_closure cases.
* libguile/hash.c (scm_hasher):
* libguile/hooks.c (scm_add_hook_x): Use new scm_i_procedure_arity.
* libguile/macros.c (macro_print): Print all macros using the same code.
(scm_macro_transformer): Return any procedure, not just programs.
* libguile/procprop.h:
* libguile/procprop.c (scm_i_procedure_arity): Instead of returning a
list that the caller has to parse, have the same prototype as
scm_i_program_arity. An incompatible change, but it's an internal
function anyway.
(scm_procedure_properties, scm_set_procedure_properties)
(scm_procedure_property, scm_set_procedure_property): Remove closure
cases, and use scm_i_program_arity for arity.
* libguile/procs.h (SCM_CLOSUREP, SCM_CLOSCAR, SCM_CODE)
(SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS)
(SCM_CLOSURE_BODY, SCM_PROCPROPS, SCM_SETPROCPROPS, SCM_ENV)
(SCM_TOP_LEVEL): Remove these macros that pertain to boot closures
only. Only eval.c should know abut boot closures.
* libguile/procs.c (scm_closure_p): Remove this function. There is a
simple stub in deprecated.scm now.
(scm_thunk_p): Use scm_i_program_arity.
* libguile/tags.h (scm_tc3_closure): Remove. Yay, another tc3 to play
with!
(scm_tcs_closures): Remove.
* libguile/validate.h (SCM_VALIDATE_CLOSURE): Remove.
* module/ice-9/deprecated.scm (closure?): Add stub.
* module/ice-9/documentation.scm (object-documentation)
* module/ice-9/session.scm (help-doc, arity)
* module/oop/goops.scm (compute-getters-n-setters)
* module/oop/goops/describe.scm (describe)
* module/system/repl/describe.scm (display-object, display-type):
Remove calls to closure?.
2009-12-04 19:20:11 +01:00
|
|
|
|
SCM_ASSERT (scm_i_procedure_arity (proc, &p_req, &p_opt, &p_rest),
|
2000-04-21 23:13:26 +00:00
|
|
|
|
proc, SCM_ARG2, FUNC_NAME);
|
|
|
|
|
|
n_args = SCM_HOOK_ARITY (hook);
|
eval.c closures are now applicable smobs, not tc3s
* libguile/debug.c (scm_procedure_name): Remove a SCM_CLOSUREP case and
some dead code.
(scm_procedure_module): Remove. This was introduced a few months ago
for the hygienic expander, but now it is no longer needed, as the
expander keeps track of this information itself.
* libguile/debug.h: Remove scm_procedure_module.
* libguile/eval.c: Instead of using tc3 closures, define a "boot
closure" applicable smob type, and represent closures with that. The
advantage is that after eval.scm is compiled, boot closures take up no
address space (besides a smob number) in the runtime, and require no
special cases in procedure dispatch.
* libguile/eval.h: Remove the internal functions scm_i_call_closure_0
and scm_closure_apply, and the public function scm_closure.
* libguile/gc.c (scm_storage_prehistory): No tc3_closure displacement
registration.
(scm_i_tag_name): Remove closure case, and a dead cclo case.
* libguile/vm.c (apply_foreign):
* libguile/print.c (iprin1):
* libguile/procs.c (scm_procedure_p, scm_procedure_documentation);
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (scm_class_of): Remove tc3_closure/tcs_closure cases.
* libguile/hash.c (scm_hasher):
* libguile/hooks.c (scm_add_hook_x): Use new scm_i_procedure_arity.
* libguile/macros.c (macro_print): Print all macros using the same code.
(scm_macro_transformer): Return any procedure, not just programs.
* libguile/procprop.h:
* libguile/procprop.c (scm_i_procedure_arity): Instead of returning a
list that the caller has to parse, have the same prototype as
scm_i_program_arity. An incompatible change, but it's an internal
function anyway.
(scm_procedure_properties, scm_set_procedure_properties)
(scm_procedure_property, scm_set_procedure_property): Remove closure
cases, and use scm_i_program_arity for arity.
* libguile/procs.h (SCM_CLOSUREP, SCM_CLOSCAR, SCM_CODE)
(SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS)
(SCM_CLOSURE_BODY, SCM_PROCPROPS, SCM_SETPROCPROPS, SCM_ENV)
(SCM_TOP_LEVEL): Remove these macros that pertain to boot closures
only. Only eval.c should know abut boot closures.
* libguile/procs.c (scm_closure_p): Remove this function. There is a
simple stub in deprecated.scm now.
(scm_thunk_p): Use scm_i_program_arity.
* libguile/tags.h (scm_tc3_closure): Remove. Yay, another tc3 to play
with!
(scm_tcs_closures): Remove.
* libguile/validate.h (SCM_VALIDATE_CLOSURE): Remove.
* module/ice-9/deprecated.scm (closure?): Add stub.
* module/ice-9/documentation.scm (object-documentation)
* module/ice-9/session.scm (help-doc, arity)
* module/oop/goops.scm (compute-getters-n-setters)
* module/oop/goops/describe.scm (describe)
* module/system/repl/describe.scm (display-object, display-type):
Remove calls to closure?.
2009-12-04 19:20:11 +01:00
|
|
|
|
if (p_req > n_args || (!p_rest && p_req + p_opt < n_args))
|
2000-04-21 23:13:26 +00:00
|
|
|
|
scm_wrong_type_arg (FUNC_NAME, 2, proc);
|
|
|
|
|
|
rest = scm_delq_x (proc, SCM_HOOK_PROCEDURES (hook));
|
|
|
|
|
|
SCM_SET_HOOK_PROCEDURES (hook,
|
2004-07-06 10:59:25 +00:00
|
|
|
|
(!SCM_UNBNDP (append_p) && scm_is_true (append_p)
|
* list.h (scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5,
scm_list_n): New functions.
(SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4, SCM_LIST5,
SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9, scm_listify): Deprecated.
(lots of files): Use the new functions.
* goops.c (CALL_GF1, CALL_GF2, CALL_GF3, CALL_GF4): Use scm_call_N.
* strings.c: #include "libguile/deprecation.h".
2001-06-28 01:11:59 +00:00
|
|
|
|
? scm_append_x (scm_list_2 (rest, scm_list_1 (proc)))
|
2000-04-21 23:13:26 +00:00
|
|
|
|
: scm_cons (proc, rest)));
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_remove_hook_x, "remove-hook!", 2, 0, 0,
|
|
|
|
|
|
(SCM hook, SCM proc),
|
2001-07-04 06:13:10 +00:00
|
|
|
|
"Remove the procedure @var{proc} from the hook @var{hook}. The\n"
|
|
|
|
|
|
"return value of this procedure is not specified.")
|
2000-04-21 23:13:26 +00:00
|
|
|
|
#define FUNC_NAME s_scm_remove_hook_x
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_HOOK (1, hook);
|
|
|
|
|
|
SCM_SET_HOOK_PROCEDURES (hook,
|
|
|
|
|
|
scm_delq_x (proc, SCM_HOOK_PROCEDURES (hook)));
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_reset_hook_x, "reset-hook!", 1, 0, 0,
|
|
|
|
|
|
(SCM hook),
|
2001-07-04 06:13:10 +00:00
|
|
|
|
"Remove all procedures from the hook @var{hook}. The return\n"
|
|
|
|
|
|
"value of this procedure is not specified.")
|
2000-04-21 23:13:26 +00:00
|
|
|
|
#define FUNC_NAME s_scm_reset_hook_x
|
|
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_HOOK (1, hook);
|
2000-04-21 23:13:26 +00:00
|
|
|
|
SCM_SET_HOOK_PROCEDURES (hook, SCM_EOL);
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_run_hook, "run-hook", 1, 0, 1,
|
|
|
|
|
|
(SCM hook, SCM args),
|
2001-02-16 15:04:23 +00:00
|
|
|
|
"Apply all procedures from the hook @var{hook} to the arguments\n"
|
2001-04-09 16:07:15 +00:00
|
|
|
|
"@var{args}. The order of the procedure application is first to\n"
|
2001-07-04 06:13:10 +00:00
|
|
|
|
"last. The return value of this procedure is not specified.")
|
2000-04-21 23:13:26 +00:00
|
|
|
|
#define FUNC_NAME s_scm_run_hook
|
|
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_HOOK (1, hook);
|
2000-04-21 23:13:26 +00:00
|
|
|
|
if (scm_ilength (args) != SCM_HOOK_ARITY (hook))
|
|
|
|
|
|
SCM_MISC_ERROR ("Hook ~S requires ~A arguments",
|
2004-07-23 15:43:02 +00:00
|
|
|
|
scm_list_2 (hook, scm_from_int (SCM_HOOK_ARITY (hook))));
|
2000-04-21 23:13:26 +00:00
|
|
|
|
scm_c_run_hook (hook, args);
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_c_run_hook (SCM hook, SCM args)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM procs = SCM_HOOK_PROCEDURES (hook);
|
2011-10-24 17:22:47 +02:00
|
|
|
|
while (scm_is_pair (procs))
|
2000-04-21 23:13:26 +00:00
|
|
|
|
{
|
2001-06-26 15:46:40 +00:00
|
|
|
|
scm_apply_0 (SCM_CAR (procs), args);
|
2000-04-21 23:13:26 +00:00
|
|
|
|
procs = SCM_CDR (procs);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-12-21 21:06:27 +01:00
|
|
|
|
void
|
|
|
|
|
|
scm_c_run_hookn (SCM hook, SCM *argv, size_t nargs)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM procs = SCM_HOOK_PROCEDURES (hook);
|
2011-10-24 17:22:47 +02:00
|
|
|
|
while (scm_is_pair (procs))
|
2009-12-21 21:06:27 +01:00
|
|
|
|
{
|
|
|
|
|
|
scm_call_n (SCM_CAR (procs), argv, nargs);
|
|
|
|
|
|
procs = SCM_CDR (procs);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2000-04-21 23:13:26 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_hook_to_list, "hook->list", 1, 0, 0,
|
|
|
|
|
|
(SCM hook),
|
2001-02-16 15:04:23 +00:00
|
|
|
|
"Convert the procedure list of @var{hook} to a list.")
|
2000-04-21 23:13:26 +00:00
|
|
|
|
#define FUNC_NAME s_scm_hook_to_list
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_HOOK (1, hook);
|
|
|
|
|
|
return scm_list_copy (SCM_HOOK_PROCEDURES (hook));
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_init_hooks ()
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_tc16_hook = scm_make_smob_type ("hook", 0);
|
2000-12-08 17:32:56 +00:00
|
|
|
|
scm_set_smob_print (scm_tc16_hook, hook_print);
|
2018-06-20 17:19:31 +02:00
|
|
|
|
#include "hooks.x"
|
2000-04-21 23:13:26 +00:00
|
|
|
|
}
|