edelib 1.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

Scheme.h
1 /*
2 * $Id$
3 *
4 * Scheme interpeter
5 * Copyright (c) 2005-2012 edelib authors
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef __EDELIB_SCHEME_H__
22 #define __EDELIB_SCHEME_H__
23
24 #ifndef SKIP_DOCS
25 # include "ts/scheme.h"
26 # include "ts/scheme-private.h"
27 #endif
28
49 typedef scheme edelib_scheme_t;
50
55 typedef pointer edelib_scheme_pointer_t;
56
64 scheme *edelib_scheme_init(void);
65
70 #define edelib_scheme_init_raw scheme_init_new
71
76 #define edelib_scheme_deinit scheme_deinit
77
82 #define edelib_scheme_load_file scheme_load_file
83
88 #define edelib_scheme_load_named_file scheme_load_named_file
89
94 #define edelib_scheme_load_string scheme_load_string
95
100 #define edelib_scheme_eval scheme_eval
101
106 #define edelib_scheme_apply0 scheme_apply0
107
112 #define edelib_scheme_set_external_data scheme_set_external_data
113
118 #define edelib_scheme_get_external_data(sc) (sc)->ext_data
119
124 #define edelib_scheme_define scheme_define
125
130 #define edelib_scheme_call scheme_call
131
136 #define edelib_scheme_set_input_port_file scheme_set_input_port_file
137
142 #define edelib_scheme_set_output_port_file scheme_set_output_port_file
143
148 #define edelib_scheme_set_input_port_string scheme_set_input_port_string
149
154 #define edelib_scheme_set_output_port_string scheme_set_output_port_string
155
160 #define edelib_scheme_gensym(sc) (sc)->vptr->gensym(sc)
161
166 #define edelib_scheme_cons(sc, a, b) _cons((sc), a, b, 0)
167
172 #define edelib_scheme_immutable_cons(sc, a, b) _cons((sc), a, b, 1)
173
178 #define edelib_scheme_reserve_cells(sc, n) (sc)->vptr->reserve_cells(sc, n)
179
184 #define edelib_scheme_mk_int(sc, num) (sc)->vptr->mk_integer(sc, num)
185
190 #define edelib_scheme_mk_double(sc, num) (sc)->vptr->mk_real(sc, num)
191
196 #define edelib_scheme_mk_symbol(sc, sym) (sc)->vptr->mk_symbol(sc, sym)
197
202 #define edelib_scheme_mk_string(sc, str) (sc)->vptr->mk_string(sc, str)
203
208 #define edelib_scheme_mk_string_counted(sc, str) (sc)->vptr->mk_counted_string(sc, str)
209 #define edelib_scheme_mk_character(sc, c) (sc)->vptr->mk_character(sc, c)
210 #define edelib_scheme_mk_vector(sc, len) (sc)->vptr->mk_vector(sc, len)
211 #define edelib_scheme_mk_foreign_func(sc, func) (sc)->vptr->mk_foreign_func(sc, func)
212 #define edelib_scheme_putstr(sc, str) (sc)->vptr->putstr(sc, str)
213 #define edelib_scheme_putcharacter(sc, c) (sc)->vptr->putcharacter(sc, c)
214
215 #define edelib_scheme_is_string(sc, p) (sc)->vptr->is_string(p)
216 #define edelib_scheme_string_value(sc, p) (sc)->vptr->string_value(p)
217 #define edelib_scheme_is_int(sc, p) (sc)->vptr->is_number(p)
218 #define edelib_scheme_int_value(sc, p) (int)((sc)->vptr->ivalue(p))
219 #define edelib_scheme_is_double(sc, p) (sc)->vptr->is_real(p)
220 #define edelib_scheme_double_value(sc, p) (sc)->vptr->rvalue(p)
221 #define edelib_scheme_is_char(sc, p) (sc)->vptr->is_character(p)
222 #define edelib_scheme_char_value(sc, p) (sc)->vptr->charvalue(p)
223 #define edelib_scheme_is_vector(sc, p) (sc)->vptr->is_vector(p)
224 #define edelib_scheme_vector_len(sc, p) (sc)->vptr->vector_length(p)
225 #define edelib_scheme_vector_fill(sc, vec, v) (sc)->vptr->fill_vector(vec, v)
226 #define edelib_scheme_vector_elem(sc, vec, i) (sc)->vptr->vector_elem(vec, i)
227 #define edelib_scheme_vector_elem_set(sc, vec, i, newel) (sc)->vptr->set_vector_elem(vec, i, newel)
228 #define edelib_scheme_is_port(sc, p) (sc)->vptr->is_port(p)
229 #define edelib_scheme_is_pair(sc, p) (sc)->vptr->is_pair(p)
230 #define edelib_scheme_pair_car(sc, p) (sc)->vptr->pair_car(p)
231 #define edelib_scheme_pair_cdr(sc, p) (sc)->vptr->pair_cdr(p)
232 #define edelib_scheme_car_set(sc, p, q) (sc)->vptr->set_car(p, q)
233 #define edelib_scheme_cdr_set(sc, p, q) (sc)->vptr->set_cdr(p, q)
234 #define edelib_scheme_is_symbol(sc, p) (sc)->vptr->is_symbol(p)
235 #define edelib_scheme_symname(sc, p) (sc)->vptr->symname(p)
236 #define edelib_scheme_is_syntax(sc, p) (sc)->vptr->is_syntax(p)
237 #define edelib_scheme_syntaxname(sc, p) (sc)->vptr->syntaxname(p)
238 #define edelib_scheme_is_proc(sc, p) (sc)->vptr->is_proc(p)
239 #define edelib_scheme_is_macro(sc, p) (sc)->vptr->is_macro(p)
240 #define edelib_scheme_is_foreign(sc, p) (sc)->vptr->is_foreign(p)
241 #define edelib_scheme_closure_code(sc, p) (sc)->vptr->closure_code(p)
242 #define edelib_scheme_closure_env(sc, p) (sc)->vptr->closure_env(p)
243
244 #define edelib_scheme_is_continuation(sc, p) (sc)->vptr->is_continuation(p)
245 #define edelib_scheme_is_promise(sc, p) (sc)->vptr->is_promise(p)
246 #define edelib_scheme_is_environment(sc, p) (sc)->vptr->is_environment(p)
247
248 #define edelib_scheme_is_immutable(sc, p) (sc)->vptr->is_immutable(p)
249 #define edelib_scheme_set_immutable(sc, p) (sc)->vptr->setimmutable(p)
250
256 #define EDELIB_SCHEME_DEFINE(sc, func_ptr, func_name) \
257 sc->vptr->scheme_define(sc, sc->global_env, \
258 sc->vptr->mk_symbol(sc, func_name), \
259 sc->vptr->mk_foreign_func(sc, func_ptr))
260
266 #define EDELIB_SCHEME_DEFINE2(sc, func_ptr, func_name, doc) \
267 do { \
268 scheme_load_string(sc, "(add-doc " #func_name " " #doc ")"); \
269 EDELIB_SCHEME_DEFINE(sc, func_ptr, func_name); \
270 } while(0)
271
272 #define EDELIB_SCHEME_OBJECT(sc) ((sc)->vptr)
273 #define EDELIB_SCHEME_GLOBAL_ENV(sc) ((sc)->global_env)
274
280 #define EDELIB_SCHEME_IS_NIL(sc, var) ((var) == sc->NIL)
281
282 #endif