edelib 0.0

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

- File List

Scheme.h
1 /*
2 * $Id$
3 *
4 * Scheme interpeter
5 * Copyright (c) 2005-2011 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
52 scheme *edelib_scheme_init(void);
53
58 #define edelib_scheme_init_raw scheme_init_new
59
64 #define edelib_scheme_deinit scheme_deinit
65
70 #define edelib_scheme_load_file scheme_load_file
71
76 #define edelib_scheme_load_string scheme_load_string
77
82 #define edelib_scheme_set_external_data scheme_set_external_data
83
88 #define edelib_scheme_get_external_data(sc) (sc)->ext_data
89
94 #define edelib_scheme_define scheme_define
95
100 #define edelib_scheme_call scheme_call
101
106 #define edelib_scheme_set_input_port_file scheme_set_input_port_file
107
112 #define edelib_scheme_set_output_port_file scheme_set_output_port_file
113
118 #define edelib_scheme_set_input_port_string scheme_set_input_port_string
119
124 #define edelib_scheme_set_output_port_string scheme_set_output_port_string
125
126 /* try to avoid vpr by using function like macros */
127 #define edelib_scheme_gensym(sc) (sc)->vptr->gensym(sc)
128 #define edelib_scheme_cons(sc, a, b) (sc)->vptr->cons(sc, a, b)
129 #define edelib_scheme_immutable_cons(sc, a, b) (sc)->vptr->immutable_cons(sc, a, b)
130 #define edelib_scheme_reserve_cells(sc, n) (sc)->vptr->reserve_cells(sc, n)
131 #define edelib_scheme_mk_int(sc, num) (sc)->vptr->mk_integer(sc, num)
132 #define edelib_scheme_mk_double(sc, num) (sc)->vptr->mk_real(sc, num)
133 #define edelib_scheme_mk_symbol(sc, sym) (sc)->vptr->mk_symbol(sc, sym)
134 #define edelib_scheme_mk_string(sc, str) (sc)->vptr->mk_string(sc, str)
135 #define edelib_scheme_mk_string_counted(sc, str) (sc)->vptr->mk_counted_string(sc, str)
136 #define edelib_scheme_mk_character(sc, c) (sc)->vptr->mk_character(sc, c)
137 #define edelib_scheme_mk_vector(sc, len) (sc)->vptr->mk_vector(sc, len)
138 #define edelib_scheme_mk_foreign_func(sc, func) (sc)->vptr->mk_foreign_func(sc, func)
139 #define edelib_scheme_putstr(sc, str) (sc)->vptr->putstr(sc, str)
140 #define edelib_scheme_putcharacter(sc, c) (sc)->vptr->putcharacter(sc, c)
141
142 #define edelib_scheme_is_string(sc, p) (sc)->vptr->is_string(p)
143 #define edelib_scheme_string_value(sc, p) (sc)->vptr->string_value(p)
144 #define edelib_scheme_is_int(sc, p) (sc)->vptr->is_number(p)
145 #define edelib_scheme_int_value(sc, p) (int)((sc)->vptr->ivalue(p))
146 #define edelib_scheme_is_double(sc, p) (sc)->vptr->is_real(p)
147 #define edelib_scheme_double_value(sc, p) (sc)->vptr->rvalue(p)
148 #define edelib_scheme_is_char(sc, p) (sc)->vptr->is_character(p)
149 #define edelib_scheme_char_value(sc, p) (sc)->vptr->charvalue(p)
150 #define edelib_scheme_is_vector(sc, p) (sc)->vptr->is_vector(p)
151 #define edelib_scheme_vector_len(sc, p) (sc)->vptr->vector_length(p)
152 #define edelib_scheme_vector_fill(sc, vec, v) (sc)->vptr->fill_vector(vec, v)
153 #define edelib_scheme_vector_elem(sc, vec, i) (sc)->vptr->vector_elem(vec, i)
154 #define edelib_scheme_vector_elem_set(sc, vec, i, newel) (sc)->vptr->set_vector_elem(vec, i, newel)
155 #define edelib_scheme_is_port(sc, p) (sc)->vptr->is_port(p)
156 #define edelib_scheme_is_pair(sc, p) (sc)->vptr->is_pair(p)
157 #define edelib_scheme_pair_car(sc, p) (sc)->vptr->pair_car(p)
158 #define edelib_scheme_pair_cdr(sc, p) (sc)->vptr->pair_cdr(p)
159 #define edelib_scheme_car_set(sc, p, q) (sc)->vptr->set_car(p, q)
160 #define edelib_scheme_cdr_set(sc, p, q) (sc)->vptr->set_cdr(p, q)
161 #define edelib_scheme_is_symbol(sc, p) (sc)->vptr->is_symbol(p)
162 #define edelib_scheme_symname(sc, p) (sc)->vptr->symname(p)
163 #define edelib_scheme_is_syntax(sc, p) (sc)->vptr->is_syntax(p)
164 #define edelib_scheme_syntaxname(sc, p) (sc)->vptr->syntaxname(p)
165 #define edelib_scheme_is_proc(sc, p) (sc)->vptr->is_proc(p)
166 #define edelib_scheme_is_macro(sc, p) (sc)->vptr->is_macro(p)
167 #define edelib_scheme_is_foreign(sc, p) (sc)->vptr->is_foreign(p)
168 #define edelib_scheme_closure_code(sc, p) (sc)->vptr->closure_code(p)
169 #define edelib_scheme_closure_env(sc, p) (sc)->vptr->closure_env(p)
170
171 #define edelib_scheme_is_continuation(sc, p) (sc)->vptr->is_continuation(p)
172 #define edelib_scheme_is_promise(sc, p) (sc)->vptr->is_promise(p)
173 #define edelib_scheme_is_environment(sc, p) (sc)->vptr->is_environment(p)
174
175 #define edelib_scheme_is_immutable(sc, p) (sc)->vptr->is_immutable(p)
176 #define edelib_scheme_set_immutable(sc, p) (sc)->vptr->setimmutable(p)
177
183 #define EDELIB_SCHEME_DEFINE(sc, func_ptr, func_name) \
184 sc->vptr->scheme_define(sc, sc->global_env, \
185 sc->vptr->mk_symbol(sc, func_name), \
186 sc->vptr->mk_foreign_func(sc, func_ptr))
187
193 #define EDELIB_SCHEME_DEFINE2(sc, func_ptr, func_name, doc) \
194 do { \
195 scheme_load_string(sc, "(add-doc " #func_name "," #doc ")"); \
196 EDELIB_SCHEME_DEFINE(sc, func_name, func_ptr); \
197 } while(0)
198
199 #define EDELIB_SCHEME_OBJECT(sc) ((sc)->vptr)
200 #define EDELIB_SCHEME_GLOBAL_ENV(sc) ((sc)->global_env)
201
207 #define EDELIB_SCHEME_IS_NIL(sc, var) ((var) == sc->NIL)
208
209 #endif