diff options
Diffstat (limited to 'libguile/procs.h')
-rw-r--r-- | libguile/procs.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libguile/procs.h b/libguile/procs.h index 469b735d9..7e445ad11 100644 --- a/libguile/procs.h +++ b/libguile/procs.h @@ -40,6 +40,46 @@ #define SCM_SET_SUBR_GENERIC(x, g) (*((SCM *) SCM_CELL_WORD_2 (x)) = (g)) #define SCM_SET_SUBR_GENERIC_LOC(x, g) (SCM_SET_CELL_WORD_2 (x, (scm_t_bits) g)) +/* Return the most suitable subr type for a subr with REQ required arguments, + OPT optional arguments, and REST (0 or 1) arguments. This has to be in + sync with `create_gsubr ()'. */ +#define SCM_SUBR_ARITY_TO_TYPE(req, opt, rest) \ + ((rest) == 0 \ + ? ((opt) == 0 \ + ? ((req) == 0 \ + ? scm_tc7_subr_0 \ + : ((req) == 1 \ + ? scm_tc7_subr_1 \ + : ((req) == 2 \ + ? scm_tc7_subr_2 \ + : ((req) == 3 \ + ? scm_tc7_subr_3 \ + : scm_tc7_gsubr \ + | (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U))))) \ + : ((opt) == 1 \ + ? ((req) == 0 \ + ? scm_tc7_subr_1o \ + : ((req) == 1 \ + ? scm_tc7_subr_2o \ + : scm_tc7_gsubr | \ + (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U))) \ + : scm_tc7_gsubr | \ + (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U))) \ + : ((rest) == 1 \ + ? ((opt) == 0 \ + ? ((req) == 0 \ + ? scm_tc7_lsubr \ + : ((req) == 2 \ + ? scm_tc7_lsubr_2 \ + : scm_tc7_gsubr \ + | (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U))) \ + : scm_tc7_gsubr \ + | (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U)) \ + : scm_tc7_gsubr \ + | (SCM_GSUBR_MAKTYPE (req, opt, rest) << 8U))) + + + /* Closures */ @@ -104,6 +144,9 @@ #define SCM_PROCEDURE(obj) SCM_CELL_OBJECT_1 (obj) #define SCM_SETTER(obj) SCM_CELL_OBJECT_2 (obj) + + + SCM_API SCM scm_c_make_subr (const char *name, long type, SCM (*fcn)()); SCM_API SCM scm_c_make_subr_with_generic (const char *name, long type, SCM (*fcn)(), SCM *gf); |