diff options
author | Mark H Weaver <mhw@netris.org> | 2012-01-29 20:00:21 -0500 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2012-01-30 10:27:44 -0500 |
commit | 741b8a2300ef329cf5691a3c35b920df68f093e2 (patch) | |
tree | 4aaf25caa9e98f6169df16866b0af26eff286667 /libguile/eval.c | |
parent | adb8054c6d16d3c5869cd543dbd29c384af02ccd (diff) | |
download | guile-741b8a2300ef329cf5691a3c35b920df68f093e2.tar.gz |
Implement scm_call_varargs and scm_call_{7,8,9}
* libguile/eval.c (scm_call_7, scm_call_8, scm_call_9,
scm_call_varargs): New functions.
* libguile/eval.h: Add prototypes.
* doc/ref/api-evaluation.texi: Add documentation.
* test-suite/standalone/test-loose-ends.c: Add tests.
* NEWS: Add news entry.
Diffstat (limited to 'libguile/eval.c')
-rw-r--r-- | libguile/eval.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/libguile/eval.c b/libguile/eval.c index e008b3a08..70e303ab1 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -24,6 +24,7 @@ #endif #include <alloca.h> +#include <stdarg.h> #include "libguile/__scm.h" @@ -522,11 +523,56 @@ scm_call_6 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM arg4, SCM arg5, } SCM +scm_call_7 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM arg4, SCM arg5, + SCM arg6, SCM arg7) +{ + SCM args[] = { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }; + return scm_c_vm_run (scm_the_vm (), proc, args, 7); +} + +SCM +scm_call_8 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM arg4, SCM arg5, + SCM arg6, SCM arg7, SCM arg8) +{ + SCM args[] = { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }; + return scm_c_vm_run (scm_the_vm (), proc, args, 8); +} + +SCM +scm_call_9 (SCM proc, SCM arg1, SCM arg2, SCM arg3, SCM arg4, SCM arg5, + SCM arg6, SCM arg7, SCM arg8, SCM arg9) +{ + SCM args[] = { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }; + return scm_c_vm_run (scm_the_vm (), proc, args, 9); +} + +SCM scm_call_n (SCM proc, SCM *argv, size_t nargs) { return scm_c_vm_run (scm_the_vm (), proc, argv, nargs); } +SCM +scm_call_varargs (SCM proc, ...) +{ + va_list argp; + SCM *argv = NULL; + size_t i, nargs = 0; + + va_start (argp, proc); + while (!SCM_UNBNDP (va_arg (argp, SCM))) + nargs++; + va_end (argp); + + argv = alloca (nargs * sizeof (SCM)); + va_start (argp, proc); + for (i = 0; i < nargs; i++) + argv[i] = va_arg (argp, SCM); + va_end (argp); + + return scm_c_vm_run (scm_the_vm (), proc, argv, nargs); +} + /* Simple procedure applies */ |