4 \brief Header info for the TinyScheme compiler
18 * Default values for #define'd symbols
20 #ifndef STANDALONE /* If used as standalone interpreter */
25 #if !defined(_MSC_VER) && !defined(__MINGW32__)
26 # define USE_STRCASECMP 1
28 # define SCHEME_EXPORT
30 # define USE_STRCASECMP 0
32 # if defined(__MINGW32__)
33 # define SCHEME_EXPORT
35 # ifdef _SCHEME_SOURCE
36 # define SCHEME_EXPORT __declspec(dllexport)
38 # define SCHEME_EXPORT __declspec(dllimport)
47 # define USE_CHAR_CLASSIFIERS 0
48 # define USE_ASCII_NAMES 0
49 # define USE_STRING_PORTS 0
50 # define USE_ERROR_HOOK 0
51 # define USE_TRACING 0
52 # define USE_COLON_HOOK 0
58 * Leave it defined if you want continuations, and also for the Sharp Zaurus.
59 * Undefine it if you only care about faster speed and not strict Scheme compatibility.
61 #define USE_SCHEME_STACK
64 # define USE_INTERFACE 1
68 #ifndef USE_MATH /* If math support is needed */
72 #ifndef USE_CHAR_CLASSIFIERS /* If char classifiers are needed */
73 # define USE_CHAR_CLASSIFIERS 1
76 #ifndef USE_ASCII_NAMES /* If extended escaped characters are needed */
77 # define USE_ASCII_NAMES 1
80 #ifndef USE_STRING_PORTS /* Enable string ports */
81 # define USE_STRING_PORTS 1
85 # define USE_TRACING 1
92 /* To force system errors through user-defined error handling (see *error-hook*) */
93 #ifndef USE_ERROR_HOOK
94 # define USE_ERROR_HOOK 1
97 #ifndef USE_COLON_HOOK /* Enable qualified qualifier */
98 # define USE_COLON_HOOK 1
101 #ifndef USE_STRCASECMP /* stricmp for Unix */
102 # define USE_STRCASECMP 0
106 # define USE_STRLWR 1
109 #ifndef STDIO_ADDS_CR /* Define if DOS/Windows */
110 # define STDIO_ADDS_CR 0
117 #ifndef USE_INTERFACE
118 # define USE_INTERFACE 0
121 typedef struct scheme scheme
;
122 typedef struct cell
*pointer
;
124 typedef void * (*func_alloc
)(size_t);
125 typedef void (*func_dealloc
)(void *);
127 /* num, for generic arithmetic */
136 SCHEME_EXPORT scheme
*scheme_init_new();
137 SCHEME_EXPORT scheme
*scheme_init_new_custom_alloc(func_alloc malloc
, func_dealloc free
);
138 SCHEME_EXPORT
int scheme_init(scheme
*sc
);
139 SCHEME_EXPORT
int scheme_init_custom_alloc(scheme
*sc
, func_alloc
, func_dealloc
);
140 SCHEME_EXPORT
void scheme_deinit(scheme
*sc
);
141 void scheme_set_input_port_file(scheme
*sc
, FILE *fin
);
142 void scheme_set_input_port_string(scheme
*sc
, char *start
, char *past_the_end
);
143 SCHEME_EXPORT
void scheme_set_output_port_file(scheme
*sc
, FILE *fin
);
144 void scheme_set_output_port_string(scheme
*sc
, char *start
, char *past_the_end
);
145 SCHEME_EXPORT
void scheme_load_file(scheme
*sc
, FILE *fin
);
146 SCHEME_EXPORT
void scheme_load_string(scheme
*sc
, const char *cmd
);
147 void scheme_apply0(scheme
*sc
, const char *procname
);
148 SCHEME_EXPORT pointer
scheme_apply1(scheme
*sc
, const char *procname
, pointer
);
149 void scheme_set_external_data(scheme
*sc
, void *p
);
150 SCHEME_EXPORT
void scheme_define(scheme
*sc
, pointer env
, pointer symbol
, pointer value
);
152 typedef pointer (*foreign_func
)(scheme
*, pointer
);
154 pointer
_cons(scheme
*sc
, pointer a
, pointer b
, int immutable
);
155 pointer
mk_integer(scheme
*sc
, long num
);
156 pointer
mk_real(scheme
*sc
, double num
);
157 pointer
mk_symbol(scheme
*sc
, const char *name
);
158 pointer
gensym(scheme
*sc
);
159 pointer
mk_string(scheme
*sc
, const char *str
);
160 pointer
mk_counted_string(scheme
*sc
, const char *str
, int len
);
161 pointer
mk_character(scheme
*sc
, int c
);
162 pointer
mk_foreign_func(scheme
*sc
, foreign_func f
);
163 void putstr(scheme
*sc
, const char *s
);
167 struct scheme_interface
{
168 void (*scheme_define
)(scheme
*sc
, pointer env
, pointer symbol
, pointer value
);
169 pointer (*cons
)(scheme
*sc
, pointer a
, pointer b
);
170 pointer (*immutable_cons
)(scheme
*sc
, pointer a
, pointer b
);
171 pointer (*mk_integer
)(scheme
*sc
, long num
);
172 pointer (*mk_real
)(scheme
*sc
, double num
);
173 pointer (*mk_symbol
)(scheme
*sc
, const char *name
);
174 pointer (*gensym
)(scheme
*sc
);
175 pointer (*mk_string
)(scheme
*sc
, const char *str
);
176 pointer (*mk_counted_string
)(scheme
*sc
, const char *str
, int len
);
177 pointer (*mk_character
)(scheme
*sc
, int c
);
178 pointer (*mk_vector
)(scheme
*sc
, int len
);
179 pointer (*mk_foreign_func
)(scheme
*sc
, foreign_func f
);
180 void (*putstr
)(scheme
*sc
, const char *s
);
181 void (*putcharacter
)(scheme
*sc
, int c
);
183 int (*is_string
)(pointer p
);
184 char *(*string_value
)(pointer p
);
185 int (*is_number
)(pointer p
);
186 num (*nvalue
)(pointer p
);
187 long (*ivalue
)(pointer p
);
188 double (*rvalue
)(pointer p
);
189 int (*is_integer
)(pointer p
);
190 int (*is_real
)(pointer p
);
191 int (*is_character
)(pointer p
);
192 long (*charvalue
)(pointer p
);
193 int (*is_vector
)(pointer p
);
194 long (*vector_length
)(pointer vec
);
195 void (*fill_vector
)(pointer vec
, pointer elem
);
196 pointer (*vector_elem
)(pointer vec
, int ielem
);
197 pointer (*set_vector_elem
)(pointer vec
, int ielem
, pointer newel
);
198 int (*is_port
)(pointer p
);
200 int (*is_pair
)(pointer p
);
201 pointer (*pair_car
)(pointer p
);
202 pointer (*pair_cdr
)(pointer p
);
203 pointer (*set_car
)(pointer p
, pointer q
);
204 pointer (*set_cdr
)(pointer p
, pointer q
);
206 int (*is_symbol
)(pointer p
);
207 char *(*symname
)(pointer p
);
209 int (*is_syntax
)(pointer p
);
210 int (*is_proc
)(pointer p
);
211 int (*is_foreign
)(pointer p
);
212 char *(*syntaxname
)(pointer p
);
213 int (*is_closure
)(pointer p
);
214 int (*is_macro
)(pointer p
);
215 pointer (*closure_code
)(pointer p
);
216 pointer (*closure_env
)(pointer p
);
218 int (*is_continuation
)(pointer p
);
219 int (*is_promise
)(pointer p
);
220 int (*is_environment
)(pointer p
);
221 int (*is_immutable
)(pointer p
);
222 void (*setimmutable
)(pointer p
);
223 void (*load_file
)(scheme
*sc
, FILE *fin
);
224 void (*load_string
)(scheme
*sc
, const char *input
);