summaryrefslogtreecommitdiff
path: root/libguile/procs.h
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/procs.h')
-rw-r--r--libguile/procs.h68
1 files changed, 37 insertions, 31 deletions
diff --git a/libguile/procs.h b/libguile/procs.h
index e2dec99d0..18857c62e 100644
--- a/libguile/procs.h
+++ b/libguile/procs.h
@@ -39,37 +39,43 @@
#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 subr type corresponding to the given arity. If the arity
- doesn't match that of a subr (e.g., too many arguments), then -1 is
- returned. 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 \
- : -1)))) \
- : ((opt) == 1 \
- ? ((req) == 0 \
- ? scm_tc7_subr_1o \
- : ((req) == 1 \
- ? scm_tc7_subr_2o \
- : -1)) \
- : -1)) \
- : ((rest) == 1 \
- ? ((opt) == 0 \
- ? ((req) == 0 \
- ? scm_tc7_lsubr \
- : ((req) == 2 \
- ? scm_tc7_lsubr_2 \
- : -1)) \
- : -1) \
- : -1))
+/* 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)))