ae6ca955fd591a9d6b650f4847d6742da0b10cf5
[bpt/guile.git] / libguile / gh_funcs.c
1 /* Copyright (C) 1995,1996,1997,1998, 2000, 2001, 2006 Free Software Foundation, Inc.
2
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 \f
18
19 \f
20 /* Defining Scheme functions implemented by C functions --- subrs. */
21
22 #include "libguile/gh.h"
23
24 #if SCM_ENABLE_DEPRECATED
25
26 /* allows you to define new scheme primitives written in C */
27 SCM
28 gh_new_procedure (const char *proc_name, SCM (*fn) (),
29 int n_required_args, int n_optional_args, int varp)
30 {
31 return scm_c_define_gsubr (proc_name, n_required_args, n_optional_args,
32 varp, fn);
33 }
34
35 SCM
36 gh_new_procedure0_0 (const char *proc_name, SCM (*fn) ())
37 {
38 return gh_new_procedure (proc_name, fn, 0, 0, 0);
39 }
40
41 SCM
42 gh_new_procedure0_1 (const char *proc_name, SCM (*fn) ())
43 {
44 return gh_new_procedure (proc_name, fn, 0, 1, 0);
45 }
46
47 SCM
48 gh_new_procedure0_2 (const char *proc_name, SCM (*fn) ())
49 {
50 return gh_new_procedure (proc_name, fn, 0, 2, 0);
51 }
52
53 SCM
54 gh_new_procedure1_0 (const char *proc_name, SCM (*fn) ())
55 {
56 return gh_new_procedure (proc_name, fn, 1, 0, 0);
57 }
58
59 SCM
60 gh_new_procedure1_1 (const char *proc_name, SCM (*fn) ())
61 {
62 return gh_new_procedure (proc_name, fn, 1, 1, 0);
63 }
64
65 SCM
66 gh_new_procedure1_2 (const char *proc_name, SCM (*fn) ())
67 {
68 return gh_new_procedure (proc_name, fn, 1, 2, 0);
69 }
70
71 SCM
72 gh_new_procedure2_0 (const char *proc_name, SCM (*fn) ())
73 {
74 return gh_new_procedure (proc_name, fn, 2, 0, 0);
75 }
76
77 SCM
78 gh_new_procedure2_1 (const char *proc_name, SCM (*fn) ())
79 {
80 return gh_new_procedure (proc_name, fn, 2, 1, 0);
81 }
82
83 SCM
84 gh_new_procedure2_2 (const char *proc_name, SCM (*fn) ())
85 {
86 return gh_new_procedure (proc_name, fn, 2, 2, 0);
87 }
88
89 SCM
90 gh_new_procedure3_0 (const char *proc_name, SCM (*fn) ())
91 {
92 return gh_new_procedure (proc_name, fn, 3, 0, 0);
93 }
94
95 SCM
96 gh_new_procedure4_0 (const char *proc_name, SCM (*fn) ())
97 {
98 return gh_new_procedure (proc_name, fn, 4, 0, 0);
99 }
100
101 SCM
102 gh_new_procedure5_0 (const char *proc_name, SCM (*fn) ())
103 {
104 return gh_new_procedure (proc_name, fn, 5, 0, 0);
105 }
106
107 /* some (possibly most) Scheme functions available from C */
108 SCM
109 gh_define (const char *name, SCM val)
110 {
111 scm_c_define (name, val);
112 return SCM_UNSPECIFIED;
113 }
114
115 \f
116 /* Calling Scheme functions from C. */
117
118 SCM
119 gh_apply (SCM proc, SCM args)
120 {
121 return scm_apply (proc, args, SCM_EOL);
122 }
123
124 SCM
125 gh_call0 (SCM proc)
126 {
127 return scm_apply (proc, SCM_EOL, SCM_EOL);
128 }
129
130 SCM
131 gh_call1 (SCM proc, SCM arg)
132 {
133 return scm_apply (proc, arg, scm_listofnull);
134 }
135
136 SCM
137 gh_call2 (SCM proc, SCM arg1, SCM arg2)
138 {
139 return scm_apply (proc, arg1, scm_cons (arg2, scm_listofnull));
140 }
141
142 SCM
143 gh_call3 (SCM proc, SCM arg1, SCM arg2, SCM arg3)
144 {
145 return scm_apply (proc, arg1, scm_cons2 (arg2, arg3, scm_listofnull));
146 }
147
148 #endif /* SCM_ENABLE_DEPRECATED */
149
150 /*
151 Local Variables:
152 c-file-style: "gnu"
153 End:
154 */