1 /* Copyright (C) 1995,1996,1997,1998, 2000, 2001 Free Software Foundation, Inc.
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.
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.
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
20 /* Defining Scheme functions implemented by C functions --- subrs. */
22 #include "libguile/gh.h"
24 /* allows you to define new scheme primitives written in C */
26 gh_new_procedure (const char *proc_name
, SCM (*fn
) (),
27 int n_required_args
, int n_optional_args
, int varp
)
29 return scm_c_define_gsubr (proc_name
, n_required_args
, n_optional_args
,
34 gh_new_procedure0_0 (const char *proc_name
, SCM (*fn
) ())
36 return gh_new_procedure (proc_name
, fn
, 0, 0, 0);
40 gh_new_procedure0_1 (const char *proc_name
, SCM (*fn
) ())
42 return gh_new_procedure (proc_name
, fn
, 0, 1, 0);
46 gh_new_procedure0_2 (const char *proc_name
, SCM (*fn
) ())
48 return gh_new_procedure (proc_name
, fn
, 0, 2, 0);
52 gh_new_procedure1_0 (const char *proc_name
, SCM (*fn
) ())
54 return gh_new_procedure (proc_name
, fn
, 1, 0, 0);
58 gh_new_procedure1_1 (const char *proc_name
, SCM (*fn
) ())
60 return gh_new_procedure (proc_name
, fn
, 1, 1, 0);
64 gh_new_procedure1_2 (const char *proc_name
, SCM (*fn
) ())
66 return gh_new_procedure (proc_name
, fn
, 1, 2, 0);
70 gh_new_procedure2_0 (const char *proc_name
, SCM (*fn
) ())
72 return gh_new_procedure (proc_name
, fn
, 2, 0, 0);
76 gh_new_procedure2_1 (const char *proc_name
, SCM (*fn
) ())
78 return gh_new_procedure (proc_name
, fn
, 2, 1, 0);
82 gh_new_procedure2_2 (const char *proc_name
, SCM (*fn
) ())
84 return gh_new_procedure (proc_name
, fn
, 2, 2, 0);
88 gh_new_procedure3_0 (const char *proc_name
, SCM (*fn
) ())
90 return gh_new_procedure (proc_name
, fn
, 3, 0, 0);
94 gh_new_procedure4_0 (const char *proc_name
, SCM (*fn
) ())
96 return gh_new_procedure (proc_name
, fn
, 4, 0, 0);
100 gh_new_procedure5_0 (const char *proc_name
, SCM (*fn
) ())
102 return gh_new_procedure (proc_name
, fn
, 5, 0, 0);
105 /* some (possibly most) Scheme functions available from C */
107 gh_define (const char *name
, SCM val
)
109 scm_c_define (name
, val
);
110 return SCM_UNSPECIFIED
;
114 /* Calling Scheme functions from C. */
117 gh_apply (SCM proc
, SCM args
)
119 return scm_apply (proc
, args
, SCM_EOL
);
125 return scm_apply (proc
, SCM_EOL
, SCM_EOL
);
129 gh_call1 (SCM proc
, SCM arg
)
131 return scm_apply (proc
, arg
, scm_listofnull
);
135 gh_call2 (SCM proc
, SCM arg1
, SCM arg2
)
137 return scm_apply (proc
, arg1
, scm_cons (arg2
, scm_listofnull
));
141 gh_call3 (SCM proc
, SCM arg1
, SCM arg2
, SCM arg3
)
143 return scm_apply (proc
, arg1
, scm_cons2 (arg2
, arg3
, scm_listofnull
));