6 /* Copyright (C) 1995, 1996, 1998, 2000, 2001, 2006, 2008, 2009,
7 * 2010, 2011, 2013 Free Software Foundation, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 3 of
12 * the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 #include "libguile/__scm.h"
36 /* Max number of args to the C procedure backing a gsubr */
37 #define SCM_GSUBR_MAX 10
39 #define SCM_PRIMITIVE_P(x) (SCM_RTL_PROGRAM_P (x) && SCM_PROGRAM_IS_PRIMITIVE (x))
41 #define SCM_PRIMITIVE_GENERIC_P(x) (SCM_RTL_PROGRAM_P (x) && SCM_PROGRAM_IS_PRIMITIVE_GENERIC (x))
43 #define SCM_SUBRF(x) \
45 SCM_POINTER_VALUE (SCM_RTL_PROGRAM_FREE_VARIABLE_REF (x, 0)))
47 #define SCM_SUBR_NAME(x) (SCM_RTL_PROGRAM_FREE_VARIABLE_REF (x, 1))
49 #define SCM_SUBR_GENERIC(x) \
50 ((SCM *) SCM_POINTER_VALUE (SCM_RTL_PROGRAM_FREE_VARIABLE_REF (x, 2)))
52 #define SCM_SET_SUBR_GENERIC(x, g) \
53 (*SCM_SUBR_GENERIC (x) = (g))
57 SCM_INTERNAL
int scm_i_primitive_arity (SCM subr
, int *req
, int *opt
, int *rest
);
58 SCM_INTERNAL scm_t_uintptr
scm_i_primitive_call_ip (SCM subr
);
60 SCM_API SCM
scm_c_make_gsubr (const char *name
,
61 int req
, int opt
, int rst
, scm_t_subr fcn
);
62 SCM_API SCM
scm_c_make_gsubr_with_generic (const char *name
,
63 int req
, int opt
, int rst
,
64 scm_t_subr fcn
, SCM
*gf
);
65 SCM_API SCM
scm_c_define_gsubr (const char *name
,
66 int req
, int opt
, int rst
, scm_t_subr fcn
);
67 SCM_API SCM
scm_c_define_gsubr_with_generic (const char *name
,
68 int req
, int opt
, int rst
,
69 scm_t_subr fcn
, SCM
*gf
);
71 SCM_INTERNAL
void scm_init_gsubr (void);
73 #endif /* SCM_GSUBR_H */