1 /* Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
8 * This program 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
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this software; see the file COPYING. If not, write to
15 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
16 * Boston, MA 02111-1307 USA
18 * As a special exception, the Free Software Foundation gives permission
19 * for additional uses of the text contained in its release of GUILE.
21 * The exception is that, if you link the GUILE library with other files
22 * to produce an executable, this does not by itself cause the
23 * resulting executable to be covered by the GNU General Public License.
24 * Your use of that executable is in no way restricted on account of
25 * linking the GUILE library code into it.
27 * This exception does not however invalidate any other reasons why
28 * the executable file might be covered by the GNU General Public License.
30 * This exception applies only to the code released by the
31 * Free Software Foundation under the name GUILE. If you copy
32 * code from other Free Software Foundation releases into a copy of
33 * GUILE, as the General Public License permits, the exception does
34 * not apply to the code that you add in this way. To avoid misleading
35 * anyone as to the status of such modified files, you must delete
36 * this exception notice from them.
38 * If you write modifications of your own for GUILE, it is your choice
39 * whether to permit this exception to apply to your modifications.
40 * If you do not wish that, delete this exception notice. */
50 /* gcc has extern inline functions that are basically as fast as macros */
53 # define EXTINL extern inline
59 void gh_enter(int argc
, char *argv
[], void (*c_main_prog
)());
61 SCM
gh_catch(SCM tag
, scm_catch_body_t body
, void *body_data
,
62 scm_catch_handler_t handler
, void *handler_data
);
64 /* SCM gh_catch_with_saved_stack (SCM tag, scm_catch_body_t body, */
65 /* void *body_data, scm_catch_handler_t handler, */
66 /* void *handler_data); */
67 SCM
gh_standard_handler(void *data
, SCM tag
, SCM throw_args
);
69 SCM
gh_repl_handler(void *data
, SCM tag
, SCM throw_args
);
70 void gh_enter_repl(int argc
, char *argv
[], void (*init_proc
)());
73 SCM
gh_eval_str(char *scheme_code
);
74 SCM
gh_eval_str_with_catch(char *scheme_code
, scm_catch_handler_t handler
);
75 SCM
gh_eval_str_with_standard_handler(char *scheme_code
);
76 SCM
gh_eval_str_with_stack_saving_handler(char *scheme_code
);
78 SCM
gh_eval_file(char *fname
);
79 #define gh_load(fname) gh_eval_file(fname)
80 SCM
gh_eval_file_with_catch(char *scheme_code
, scm_catch_handler_t handler
);
81 SCM
gh_eval_file_with_standard_handler(char *scheme_code
);
83 #define gh_defer_ints() SCM_DEFER_INTS
84 #define gh_allow_ints() SCM_ALLOW_INTS
86 SCM
gh_new_procedure(char *proc_name
, SCM (*fn
)(),
87 int n_required_args
, int n_optional_args
, int varp
);
88 SCM
gh_new_procedure0_0(char *proc_name
, SCM (*fn
)());
89 SCM
gh_new_procedure0_1(char *proc_name
, SCM (*fn
)());
90 SCM
gh_new_procedure0_2(char *proc_name
, SCM (*fn
)());
91 SCM
gh_new_procedure1_0(char *proc_name
, SCM (*fn
)());
92 SCM
gh_new_procedure1_1(char *proc_name
, SCM (*fn
)());
93 SCM
gh_new_procedure1_2(char *proc_name
, SCM (*fn
)());
94 SCM
gh_new_procedure2_0(char *proc_name
, SCM (*fn
)());
95 SCM
gh_new_procedure2_1(char *proc_name
, SCM (*fn
)());
96 SCM
gh_new_procedure2_2(char *proc_name
, SCM (*fn
)());
97 SCM
gh_new_procedure3_0(char *proc_name
, SCM (*fn
)());
98 SCM
gh_new_procedure4_0(char *proc_name
, SCM (*fn
)());
99 SCM
gh_new_procedure5_0(char *proc_name
, SCM (*fn
)());
101 /* C to Scheme conversion */
102 SCM
gh_bool2scm(int x
);
103 SCM
gh_int2scm(int x
);
104 SCM
gh_ulong2scm(unsigned long x
);
105 SCM
gh_long2scm(long x
);
106 SCM
gh_double2scm(double x
);
107 SCM
gh_char2scm(char c
);
108 SCM
gh_str2scm(char *s
, int len
);
109 SCM
gh_str02scm(char *s
);
110 void gh_set_substr(char *src
, SCM dst
, int start
, int len
);
111 SCM
gh_symbol2scm(char *symbol_str
);
114 /* Scheme to C conversion */
115 int gh_scm2bool(SCM obj
);
116 int gh_scm2int(SCM obj
);
117 unsigned long gh_scm2ulong(SCM obj
);
118 long gh_scm2long(SCM obj
);
119 char gh_scm2char(SCM obj
);
120 double gh_scm2double(SCM obj
);
121 char *gh_scm2newstr(SCM str
, int *lenp
);
122 void gh_get_substr(SCM src
, char *dst
, int start
, int len
);
123 char *gh_symbol2newstr(SCM sym
, int *lenp
);
125 /* type predicates: tell you if an SCM object has a given type */
126 int gh_boolean_p(SCM val
);
127 int gh_symbol_p(SCM val
);
128 int gh_char_p(SCM val
);
129 int gh_vector_p(SCM val
);
130 int gh_pair_p(SCM val
);
131 int gh_number_p(SCM val
);
132 int gh_string_p(SCM val
);
133 int gh_procedure_p(SCM val
);
134 int gh_list_p(SCM val
);
135 int gh_inexact_p(SCM val
);
136 int gh_exact_p(SCM val
);
138 /* more predicates */
139 int gh_eq_p(SCM x
, SCM y
);
140 int gh_eqv_p(SCM x
, SCM y
);
141 int gh_equal_p(SCM x
, SCM y
);
143 /* standard Scheme procedures available from C */
145 SCM
gh_define(char *name
, SCM val
);
147 /* vector manipulation routines */
148 /* note that gh_vector() does not behave quite like the Scheme (vector
149 obj1 obj2 ...), because the interpreter engine does not pass the
150 data element by element, but rather as a list. thus, gh_vector()
151 ends up being identical to gh_list_to_vector() */
152 #define gh_vector(ls) scm_vector(ls)
153 SCM
gh_make_vector(SCM length
, SCM val
);
154 SCM
gh_vset(SCM vec
, SCM pos
, SCM val
);
155 SCM
gh_vref(SCM vec
, SCM pos
);
156 SCM
gh_vector_set(SCM vec
, SCM pos
, SCM val
);
157 SCM
gh_vector_ref(SCM vec
, SCM pos
);
158 unsigned long gh_vector_length(SCM v
);
159 #define gh_list_to_vector(ls) scm_vector(ls)
160 #define gh_vector_to_list(v) scm_vector_to_list(ls)
162 SCM
gh_lookup (char *sname
);
163 SCM
gh_module_lookup (SCM vector
, char *sname
);
165 SCM
gh_cons(SCM x
, SCM y
);
166 #define gh_list scm_listify
167 unsigned long gh_length(SCM l
);
186 /* Calling Scheme functions from C. */
187 SCM
gh_apply (SCM proc
, SCM ls
);
188 SCM
gh_call0 (SCM proc
);
189 SCM
gh_call1 (SCM proc
, SCM arg
);
190 SCM
gh_call2 (SCM proc
, SCM arg1
, SCM arg2
);
191 SCM
gh_call3 (SCM proc
, SCM arg1
, SCM arg2
, SCM arg3
);
193 /* reading and writing Scheme objects. */
194 void gh_display (SCM x
);
195 void gh_newline (void);
197 /* void gh_gc_mark(SCM) : mark an SCM as in use. */
198 /* void gh_defer_ints() : don't interrupt code section. */
199 /* void gh_allow_ints() : see gh_defer_ints(). */
200 /* void gh_new_cell(SCM, int tag) : initialize SCM to be of type 'tag' */
201 /* int gh_type_p(SCM, tag) : test if SCM is of type 'tag' */
202 /* SCM gh_intern(char*) : get symbol corresponding to c-string.*/
203 /* void gh_set_ext_data(SCM, void*) : set extension data on SCM */
204 /* void *gh_get_ext_data(SCM) : return extension data from SCM. */
206 /* void gh_assert(int cond, char *msg, SCM obj); */