… | |
… | |
131 | #endif |
131 | #endif |
132 | |
132 | |
133 | typedef struct scheme scheme; |
133 | typedef struct scheme scheme; |
134 | typedef struct cell *pointer; |
134 | typedef struct cell *pointer; |
135 | |
135 | |
136 | typedef void *(*func_alloc) (size_t); |
|
|
137 | typedef void (*func_dealloc) (void *); |
|
|
138 | |
|
|
139 | typedef long IVALUE; /* this is not used consistently yet */ |
136 | typedef long IVALUE; /* this is not used consistently yet */ |
140 | |
|
|
141 | #if USE_REAL |
137 | #if USE_REAL |
142 | typedef double RVALUE; |
138 | typedef double RVALUE; |
143 | # define num_is_fixnum(n) (n).is_fixnum |
|
|
144 | # define num_set_fixnum(n,f) (n).is_fixnum = (f) |
|
|
145 | # define num_ivalue(n) (n).value.ivalue |
|
|
146 | # define num_rvalue(n) (n).value.rvalue |
|
|
147 | # define num_set_ivalue(n,i) (n).value.ivalue = (i) |
|
|
148 | # define num_set_rvalue(n,r) (n).value.rvalue = (r) |
|
|
149 | #else |
139 | #else |
150 | typedef long RVALUE; |
140 | typedef long RVALUE; |
151 | # define num_is_fixnum(n) 1 |
|
|
152 | # define num_set_fixnum(n,f) 0 |
|
|
153 | # define num_ivalue(n) (n).value.ivalue |
|
|
154 | # define num_rvalue(n) (n).value.ivalue |
|
|
155 | # define num_set_ivalue(n,i) (n).value.ivalue = (i) |
|
|
156 | # define num_set_rvalue(n,r) (n).value.ivalue = (r) |
|
|
157 | #endif |
141 | #endif |
158 | |
|
|
159 | /* num, for generic arithmetic */ |
|
|
160 | typedef struct num |
|
|
161 | { |
|
|
162 | union |
|
|
163 | { |
|
|
164 | IVALUE ivalue; |
|
|
165 | #if USE_REAL |
|
|
166 | RVALUE rvalue; |
|
|
167 | #endif |
|
|
168 | } value; |
|
|
169 | #if USE_REAL |
|
|
170 | char is_fixnum; |
|
|
171 | #endif |
|
|
172 | } num; |
|
|
173 | |
142 | |
174 | /* Used for documentation purposes, to signal functions in 'interface' */ |
143 | /* Used for documentation purposes, to signal functions in 'interface' */ |
175 | #define INTERFACE static |
144 | #define INTERFACE static |
176 | |
145 | |
177 | SCHEME_EXPORT scheme *scheme_init_new (); |
146 | SCHEME_EXPORT scheme *scheme_init_new (); |
… | |
… | |
191 | SCHEME_EXPORT void scheme_define (SCHEME_P_ pointer env, pointer symbol, pointer value); |
160 | SCHEME_EXPORT void scheme_define (SCHEME_P_ pointer env, pointer symbol, pointer value); |
192 | |
161 | |
193 | typedef pointer (*foreign_func) (SCHEME_P_ pointer); |
162 | typedef pointer (*foreign_func) (SCHEME_P_ pointer); |
194 | |
163 | |
195 | pointer xcons (SCHEME_P_ pointer a, pointer b, int immutable); |
164 | pointer xcons (SCHEME_P_ pointer a, pointer b, int immutable); |
196 | INTERFACE pointer mk_integer (SCHEME_P_ long num); |
165 | INTERFACE pointer mk_integer (SCHEME_P_ IVALUE n); |
197 | INTERFACE pointer mk_real (SCHEME_P_ RVALUE num); |
166 | INTERFACE pointer mk_real (SCHEME_P_ RVALUE n); |
198 | INTERFACE pointer mk_symbol (SCHEME_P_ const char *name); |
167 | INTERFACE pointer mk_symbol (SCHEME_P_ const char *name); |
199 | INTERFACE pointer gensym (SCHEME_P); |
168 | INTERFACE pointer gensym (SCHEME_P); |
200 | INTERFACE pointer mk_string (SCHEME_P_ const char *str); |
169 | INTERFACE pointer mk_string (SCHEME_P_ const char *str); |
201 | INTERFACE pointer mk_counted_string (SCHEME_P_ const char *str, uint32_t len); |
170 | INTERFACE pointer mk_counted_string (SCHEME_P_ const char *str, uint32_t len); |
202 | INTERFACE pointer mk_empty_string (SCHEME_P_ uint32_t len, char fill); |
171 | INTERFACE pointer mk_empty_string (SCHEME_P_ uint32_t len, char fill); |