1 /* Copyright (C) 1995,1996,1997,1998, 2000, 2001, 2006, 2008 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
23 /* Defining Scheme functions implemented by C functions --- subrs. */
25 #include "libguile/gh.h"
27 #if SCM_ENABLE_DEPRECATED
29 /* allows you to define new scheme primitives written in C */
31 gh_new_procedure (const char *proc_name, SCM (*fn) (),
32 int n_required_args, int n_optional_args, int varp)
34 return scm_c_define_gsubr (proc_name, n_required_args, n_optional_args,
39 gh_new_procedure0_0 (const char *proc_name, SCM (*fn) ())
41 return gh_new_procedure (proc_name, fn, 0, 0, 0);
45 gh_new_procedure0_1 (const char *proc_name, SCM (*fn) ())
47 return gh_new_procedure (proc_name, fn, 0, 1, 0);
51 gh_new_procedure0_2 (const char *proc_name, SCM (*fn) ())
53 return gh_new_procedure (proc_name, fn, 0, 2, 0);
57 gh_new_procedure1_0 (const char *proc_name, SCM (*fn) ())
59 return gh_new_procedure (proc_name, fn, 1, 0, 0);
63 gh_new_procedure1_1 (const char *proc_name, SCM (*fn) ())
65 return gh_new_procedure (proc_name, fn, 1, 1, 0);
69 gh_new_procedure1_2 (const char *proc_name, SCM (*fn) ())
71 return gh_new_procedure (proc_name, fn, 1, 2, 0);
75 gh_new_procedure2_0 (const char *proc_name, SCM (*fn) ())
77 return gh_new_procedure (proc_name, fn, 2, 0, 0);
81 gh_new_procedure2_1 (const char *proc_name, SCM (*fn) ())
83 return gh_new_procedure (proc_name, fn, 2, 1, 0);
87 gh_new_procedure2_2 (const char *proc_name, SCM (*fn) ())
89 return gh_new_procedure (proc_name, fn, 2, 2, 0);
93 gh_new_procedure3_0 (const char *proc_name, SCM (*fn) ())
95 return gh_new_procedure (proc_name, fn, 3, 0, 0);
99 gh_new_procedure4_0 (const char *proc_name, SCM (*fn) ())
101 return gh_new_procedure (proc_name, fn, 4, 0, 0);
105 gh_new_procedure5_0 (const char *proc_name, SCM (*fn) ())
107 return gh_new_procedure (proc_name, fn, 5, 0, 0);
110 /* some (possibly most) Scheme functions available from C */
112 gh_define (const char *name, SCM val)
114 scm_c_define (name, val);
115 return SCM_UNSPECIFIED;
119 /* Calling Scheme functions from C. */
122 gh_apply (SCM proc, SCM args)
124 return scm_apply (proc, args, SCM_EOL);
130 return scm_apply (proc, SCM_EOL, SCM_EOL);
134 gh_call1 (SCM proc, SCM arg)
136 return scm_apply (proc, arg, scm_listofnull);
140 gh_call2 (SCM proc, SCM arg1, SCM arg2)
142 return scm_apply (proc, arg1, scm_cons (arg2, scm_listofnull));
146 gh_call3 (SCM proc, SCM arg1, SCM arg2, SCM arg3)
148 return scm_apply (proc, arg1, scm_cons2 (arg2, arg3, scm_listofnull));
151 #endif /* SCM_ENABLE_DEPRECATED */