Simplify the (system foreign) API.
[bpt/guile.git] / libguile / gsubr.h
1 /* classes: h_files */
2
3 #ifndef SCM_GSUBR_H
4 #define SCM_GSUBR_H
5
6 /* Copyright (C) 1995,1996,1998,2000,2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23
24 \f
25
26 #include "libguile/__scm.h"
27
28
29 \f
30
31
32 SCM_API SCM scm_subr_objcode_trampoline (unsigned int nreq,
33 unsigned int nopt,
34 unsigned int rest);
35
36
37 /* Subrs
38 */
39
40 /* Max number of args to the C procedure backing a gsubr */
41 #define SCM_GSUBR_MAX 10
42
43 #define SCM_PRIMITIVE_P(x) (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_PRIMITIVE (x))
44
45 #define SCM_PRIMITIVE_GENERIC_P(x) (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_PRIMITIVE_GENERIC (x))
46
47 #define SCM_SUBRF(x) \
48 ((SCM (*) (void)) \
49 SCM_FOREIGN_POINTER (SCM_SIMPLE_VECTOR_REF (SCM_PROGRAM_OBJTABLE (x), 0)))
50
51 #define SCM_SUBR_NAME(x) (SCM_SIMPLE_VECTOR_REF (SCM_PROGRAM_OBJTABLE (x), 1))
52
53 #define SCM_SUBR_GENERIC(x) \
54 ((SCM *) \
55 SCM_FOREIGN_POINTER (SCM_SIMPLE_VECTOR_REF (SCM_PROGRAM_OBJTABLE (x), 2)))
56
57 #define SCM_SET_SUBR_GENERIC(x, g) \
58 (*SCM_SUBR_GENERIC (x) = (g))
59
60 \f
61
62 SCM_API SCM scm_c_make_gsubr (const char *name,
63 int req, int opt, int rst, SCM (*fcn) ());
64 SCM_API SCM scm_c_make_gsubr_with_generic (const char *name,
65 int req, int opt, int rst,
66 SCM (*fcn) (), SCM *gf);
67 SCM_API SCM scm_c_define_gsubr (const char *name,
68 int req, int opt, int rst, SCM (*fcn) ());
69 SCM_API SCM scm_c_define_gsubr_with_generic (const char *name,
70 int req, int opt, int rst,
71 SCM (*fcn) (), SCM *gf);
72
73 SCM_INTERNAL void scm_init_gsubr (void);
74
75 #endif /* SCM_GSUBR_H */
76
77 /*
78 Local Variables:
79 c-file-style: "gnu"
80 End:
81 */