1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 20:30:28 +02:00

Allow the static initialization of subrs.

* libguile/Makefile.am (snarf-gsubr.h): New target.
  (BUILT_SOURCES, nodist_modinclude_HEADERS, MOSTLYCLEANFILES): Add
  `snarf-gsubr.h'.

* libguile/procs.h (SCM_SUBR_ARITY_TO_TYPE): New macro.

* libguile/snarf.h (SCM_DEFINE): Rename to...
  (SCM_DEFINE_GSUBR): this.
  (SCM_DEFINE_SUBR)[SCM_SUPPORT_STATIC_ALLOCATION]: New macro.
  (SCM_DEFINE_SUBR_reqX_optY_rstZ)[SCM_SUPPORT_STATIC_ALLOCATION]: New
  set of macros.
  (SCM_IMMUTABLE_SUBR): New macro.
This commit is contained in:
Ludovic Courtès 2009-01-31 21:52:30 +01:00
parent 6eca5d2b9b
commit 46f9baf49a
4 changed files with 124 additions and 6 deletions

View file

@ -51,6 +51,40 @@
#define SCM_CCLO_SUBR(x) (SCM_CCLO_REF ((x), 0))
#define SCM_SET_CCLO_SUBR(x, v) (SCM_CCLO_SET ((x), 0, (v)))
/* 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))
/* Closures
*/