diff options
author | Andy Wingo <wingo@pobox.com> | 2009-12-21 21:06:27 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-12-21 21:06:27 +0100 |
commit | 86fd6dff2a77150148ed7b3d9152e0a431070666 (patch) | |
tree | 566f285b090bfd155894cbf0b8e5e7dd7ba709b6 | |
parent | 700908288cdafd7d68dc2861e2348f38aeb38782 (diff) |
add scm_call_n, scm_c_run_hookn
* libguile/eval.h:
* libguile/eval.c (scm_call_n): New function, applies a function to an
array of args.
* libguile/hooks.h:
* libguile/hooks.c (scm_c_run_hookn): New function, runs a hook with an
array of args.
-rw-r--r-- | libguile/eval.c | 6 | ||||
-rw-r--r-- | libguile/eval.h | 1 | ||||
-rw-r--r-- | libguile/hooks.c | 11 | ||||
-rw-r--r-- | libguile/hooks.h | 3 |
4 files changed, 20 insertions, 1 deletions
diff --git a/libguile/eval.c b/libguile/eval.c index 48d1d74ef..65103a1b2 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -552,6 +552,12 @@ scm_call_4 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM arg4) return scm_c_vm_run (scm_the_vm (), proc, args, 4); } +SCM +scm_call_n (SCM proc, SCM *argv, size_t nargs) +{ + return scm_c_vm_run (scm_the_vm (), proc, argv, nargs); +} + /* Simple procedure applies */ diff --git a/libguile/eval.h b/libguile/eval.h index 6341f14b4..0715e04fb 100644 --- a/libguile/eval.h +++ b/libguile/eval.h @@ -69,6 +69,7 @@ SCM_API SCM scm_call_1 (SCM proc, SCM arg1); SCM_API SCM scm_call_2 (SCM proc, SCM arg1, SCM arg2); SCM_API SCM scm_call_3 (SCM proc, SCM arg1, SCM arg2, SCM arg3); SCM_API SCM scm_call_4 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM arg4); +SCM_API SCM scm_call_n (SCM proc, SCM *argv, size_t nargs); SCM_API SCM scm_apply_0 (SCM proc, SCM args); SCM_API SCM scm_apply_1 (SCM proc, SCM arg1, SCM args); SCM_API SCM scm_apply_2 (SCM proc, SCM arg1, SCM arg2, SCM args); diff --git a/libguile/hooks.c b/libguile/hooks.c index d7bf018be..abba606f7 100644 --- a/libguile/hooks.c +++ b/libguile/hooks.c @@ -276,6 +276,17 @@ scm_c_run_hook (SCM hook, SCM args) } } +void +scm_c_run_hookn (SCM hook, SCM *argv, size_t nargs) +{ + SCM procs = SCM_HOOK_PROCEDURES (hook); + while (SCM_NIMP (procs)) + { + scm_call_n (SCM_CAR (procs), argv, nargs); + procs = SCM_CDR (procs); + } +} + SCM_DEFINE (scm_hook_to_list, "hook->list", 1, 0, 0, (SCM hook), diff --git a/libguile/hooks.h b/libguile/hooks.h index 15b57fabb..dc930cb0a 100644 --- a/libguile/hooks.h +++ b/libguile/hooks.h @@ -3,7 +3,7 @@ #ifndef SCM_HOOKS_H #define SCM_HOOKS_H -/* Copyright (C) 1995,1996,1999,2000,2001, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1999,2000,2001, 2006, 2008, 2009 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -87,6 +87,7 @@ SCM_API SCM scm_remove_hook_x (SCM hook, SCM thunk); SCM_API SCM scm_reset_hook_x (SCM hook); SCM_API SCM scm_run_hook (SCM hook, SCM args); SCM_API void scm_c_run_hook (SCM hook, SCM args); +SCM_API void scm_c_run_hookn (SCM hook, SCM *argv, size_t nargs); SCM_API SCM scm_hook_to_list (SCM hook); SCM_INTERNAL void scm_init_hooks (void); |