ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/microscheme/scheme.h
(Generate patch)

Comparing microscheme/scheme.h (file contents):
Revision 1.3 by root, Wed Nov 25 10:30:34 2015 UTC vs.
Revision 1.9 by root, Mon Nov 30 13:07:34 2015 UTC

1/*
2 * µscheme
3 *
4 * Copyright (C) 2015 Marc Alexander Lehmann <uscheme@schmorp.de>
5 * do as you want with this, attribution appreciated.
6 */
1 7
2/* SCHEME.H */ 8/* SCHEME.H */
3 9
4#ifndef SCHEME_H 10#ifndef SCHEME_H
5#define SCHEME_H 11#define SCHEME_H
17 */ 23 */
18#ifndef STANDALONE /* If used as standalone interpreter */ 24#ifndef STANDALONE /* If used as standalone interpreter */
19# define STANDALONE 1 25# define STANDALONE 1
20#endif 26#endif
21 27
22#define USE_STRCASECMP 1
23#ifndef USE_STRLWR
24# define USE_STRLWR 1
25#endif
26#define SCHEME_EXPORT static 28#define SCHEME_EXPORT static
27 29
28#if USE_NO_FEATURES 30#if USE_NO_FEATURES
29# define USE_MULTIPLICITY 0 31# define USE_MULTIPLICITY 0
30# define USE_MATH 0 32# define USE_MATH 0
35# define USE_ERROR_HOOK 0 37# define USE_ERROR_HOOK 0
36# define USE_TRACING 0 38# define USE_TRACING 0
37# define USE_COLON_HOOK 0 39# define USE_COLON_HOOK 0
38# define USE_DL 0 40# define USE_DL 0
39# define USE_PLIST 0 41# define USE_PLIST 0
40# define USE_FLOAT 0 42# define USE_REAL 0
41# define USE_ERROR_CHECKING 0 43# define USE_ERROR_CHECKING 0
42# define USE_PRINTF 0 44# define USE_PRINTF 0
45# define USE_INTCACHE 0
43#endif 46#endif
44 47
45/* 48/*
46 * Leave it defined if you want continuations, and also for the Sharp Zaurus. 49 * Define: much slower, but somewhat smaller evaluation stack implemention, use more memory
47 * Undefine it if you only care about faster speed and not strict Scheme compatibility. 50 * Undefined: faster, somewhat bigger implementation, uses less memory at runtime
48 */ 51 */
49//#define USE_SCHEME_STACK 52/*#define USE_SCHEME_STACK*/
50
51#if USE_DL
52# define USE_INTERFACE 1
53#endif
54 53
55#ifndef USE_MULTIPLICITY 54#ifndef USE_MULTIPLICITY
56# define USE_MULTIPLICITY 1 55# define USE_MULTIPLICITY 1
57#endif 56#endif
58 57
59#ifndef USE_FLOAT 58#ifndef USE_REAL
60# define USE_FLOAT 1 59# define USE_REAL 1
61#endif 60#endif
62 61
63#ifndef USE_MATH /* If math support is needed */ 62#ifndef USE_MATH /* If math support is needed */
64# define USE_MATH 1 63# define USE_MATH 1
65#endif 64#endif
83#ifndef USE_TRACING 82#ifndef USE_TRACING
84# define USE_TRACING 1 83# define USE_TRACING 1
85#endif 84#endif
86 85
87#ifndef USE_PLIST 86#ifndef USE_PLIST
88# define USE_PLIST 0 87# define USE_PLIST 1
89#endif 88#endif
90 89
91/* To force system errors through user-defined error handling (see *error-hook*) */ 90/* To force system errors through user-defined error handling (see *error-hook*) */
92#ifndef USE_ERROR_HOOK 91#ifndef USE_ERROR_HOOK
93# define USE_ERROR_HOOK 1 92# define USE_ERROR_HOOK 1
103 102
104#ifndef USE_PRINTF 103#ifndef USE_PRINTF
105# define USE_PRINTF 1 104# define USE_PRINTF 1
106#endif 105#endif
107 106
108#ifndef USE_STRLWR 107#ifndef USE_IGNORECASE
109# define USE_STRLWR 1 108# define USE_IGNORECASE 1
110#endif 109#endif
111 110
112#ifndef INLINE 111#ifndef USE_INTCACHE
113# define INLINE inline 112# define USE_INTCACHE 1
114#endif 113#endif
115 114
116#ifndef SHOW_ERROR_LINE /* Show error line in file */ 115#ifndef SHOW_ERROR_LINE /* Show error line in file */
117# define SHOW_ERROR_LINE 1 116# define SHOW_ERROR_LINE 1
118#endif 117#endif
118
119#if !USE_REAL
120# undef USE_MATH
121# define USE_MATH 0
122#endif
123
124/* property lists currently broken to to symbol change*/
125#undef USE_PLIST
126#define USE_PLIST 0
119 127
120#if USE_MULTIPLICITY 128#if USE_MULTIPLICITY
121# define SCHEME_V sc 129# define SCHEME_V sc
122# define SCHEME_P scheme *SCHEME_V 130# define SCHEME_P scheme *SCHEME_V
123# define SCHEME_P_ SCHEME_P, 131# define SCHEME_P_ SCHEME_P,
129# define SCHEME_P_ 137# define SCHEME_P_
130# define SCHEME_A 138# define SCHEME_A
131# define SCHEME_A_ 139# define SCHEME_A_
132#endif 140#endif
133 141
134 typedef struct scheme scheme; 142typedef struct scheme scheme;
135 typedef struct cell *pointer; 143typedef struct cell *pointer;
136 144
137 typedef void *(*func_alloc) (size_t);
138 typedef void (*func_dealloc) (void *);
139
140 typedef long IVALUE; /* this is not used consistently yet */ 145typedef long IVALUE; /* this is not used consistently yet */
141 146#if USE_REAL
142#if USE_FLOAT
143 typedef double RVALUE; 147typedef double RVALUE;
144# define num_is_fixnum(n) (n).is_fixnum
145# define num_set_fixnum(n,f) (n).is_fixnum = (f)
146# define num_ivalue(n) (n).value.ivalue
147# define num_rvalue(n) (n).value.rvalue
148# define num_set_ivalue(n,i) (n).value.ivalue = (i)
149# define num_set_rvalue(n,r) (n).value.rvalue = (r)
150#else 148#else
151 typedef long RVALUE; 149typedef long RVALUE;
152# define num_is_fixnum(n) 1
153# define num_set_fixnum(n,f) 0
154# define num_ivalue(n) (n).value.ivalue
155# define num_rvalue(n) (n).value.ivalue
156# define num_set_ivalue(n,i) (n).value.ivalue = (i)
157# define num_set_rvalue(n,r) (n).value.ivalue = (r)
158#endif 150#endif
159
160/* num, for generic arithmetic */
161 typedef struct num
162 {
163 union
164 {
165 long ivalue;
166#if USE_FLOAT
167 RVALUE rvalue;
168#endif
169 } value;
170#if USE_FLOAT
171 char is_fixnum;
172#endif
173 } num;
174 151
175/* Used for documentation purposes, to signal functions in 'interface' */ 152/* Used for documentation purposes, to signal functions in 'interface' */
176#define INTERFACE static 153#define INTERFACE static
177 154
178 SCHEME_EXPORT scheme *scheme_init_new (); 155SCHEME_EXPORT scheme *scheme_init_new ();
179 SCHEME_EXPORT int scheme_init (SCHEME_P); 156SCHEME_EXPORT int scheme_init (SCHEME_P);
180 SCHEME_EXPORT void scheme_deinit (SCHEME_P); 157SCHEME_EXPORT void scheme_deinit (SCHEME_P);
181 void scheme_set_input_port_file (SCHEME_P_ int fin); 158void scheme_set_input_port_file (SCHEME_P_ int fin);
182 void scheme_set_input_port_string (SCHEME_P_ char *start, char *past_the_end); 159void scheme_set_input_port_string (SCHEME_P_ char *start, char *past_the_end);
183 SCHEME_EXPORT void scheme_set_output_port_file (SCHEME_P_ int fin); 160SCHEME_EXPORT void scheme_set_output_port_file (SCHEME_P_ int fin);
184 void scheme_set_output_port_string (SCHEME_P_ char *start, char *past_the_end); 161void scheme_set_output_port_string (SCHEME_P_ char *start, char *past_the_end);
185 SCHEME_EXPORT void scheme_load_file (SCHEME_P_ int fin); 162SCHEME_EXPORT void scheme_load_file (SCHEME_P_ int fin);
186 SCHEME_EXPORT void scheme_load_named_file (SCHEME_P_ int fin, const char *filename); 163SCHEME_EXPORT void scheme_load_named_file (SCHEME_P_ int fin, const char *filename);
187 SCHEME_EXPORT void scheme_load_string (SCHEME_P_ const char *cmd); 164SCHEME_EXPORT void scheme_load_string (SCHEME_P_ const char *cmd);
188 SCHEME_EXPORT pointer scheme_apply0 (SCHEME_P_ const char *procname); 165SCHEME_EXPORT pointer scheme_apply0 (SCHEME_P_ const char *procname);
189 SCHEME_EXPORT pointer scheme_call (SCHEME_P_ pointer func, pointer args); 166SCHEME_EXPORT pointer scheme_call (SCHEME_P_ pointer func, pointer args);
190 SCHEME_EXPORT pointer scheme_eval (SCHEME_P_ pointer obj); 167SCHEME_EXPORT pointer scheme_eval (SCHEME_P_ pointer obj);
191 void scheme_set_external_data (SCHEME_P_ void *p); 168void scheme_set_external_data (SCHEME_P_ void *p);
192 SCHEME_EXPORT void scheme_define (SCHEME_P_ pointer env, pointer symbol, pointer value); 169SCHEME_EXPORT void scheme_define (SCHEME_P_ pointer env, pointer symbol, pointer value);
193 170
194 typedef pointer (*foreign_func) (SCHEME_P_ pointer); 171typedef pointer (*foreign_func) (SCHEME_P_ pointer);
195 172
196 pointer xcons (SCHEME_P_ pointer a, pointer b, int immutable); 173pointer xcons (SCHEME_P_ pointer a, pointer b, int immutable);
197 INTERFACE pointer mk_integer (SCHEME_P_ long num); 174INTERFACE pointer mk_integer (SCHEME_P_ IVALUE n);
198 INTERFACE pointer mk_real (SCHEME_P_ RVALUE num); 175INTERFACE pointer mk_real (SCHEME_P_ RVALUE n);
199 INTERFACE pointer mk_symbol (SCHEME_P_ const char *name); 176INTERFACE pointer mk_symbol (SCHEME_P_ const char *name);
200 INTERFACE pointer gensym (SCHEME_P); 177INTERFACE pointer gensym (SCHEME_P);
201 INTERFACE pointer mk_string (SCHEME_P_ const char *str); 178INTERFACE pointer mk_string (SCHEME_P_ const char *str);
202 INTERFACE pointer mk_counted_string (SCHEME_P_ const char *str, uint32_t len); 179INTERFACE pointer mk_counted_string (SCHEME_P_ const char *str, uint32_t len);
203 INTERFACE pointer mk_empty_string (SCHEME_P_ uint32_t len, char fill); 180INTERFACE pointer mk_empty_string (SCHEME_P_ uint32_t len, char fill);
204 INTERFACE pointer mk_character (SCHEME_P_ int c); 181INTERFACE pointer mk_character (SCHEME_P_ int c);
205 INTERFACE pointer mk_foreign_func (SCHEME_P_ foreign_func f); 182INTERFACE pointer mk_foreign_func (SCHEME_P_ foreign_func f);
206 INTERFACE void putstr (SCHEME_P_ const char *s); 183INTERFACE void putstr (SCHEME_P_ const char *s);
207 INTERFACE int list_length (SCHEME_P_ pointer a); 184INTERFACE int list_length (SCHEME_P_ pointer a);
208 INTERFACE int eqv (pointer a, pointer b); 185INTERFACE int eqv (pointer a, pointer b);
209 186
210#if !STANDALONE 187#if !STANDALONE
211 typedef struct scheme_registerable 188typedef struct scheme_registerable
212 { 189{
213 foreign_func f; 190 foreign_func f;
214 const char *name; 191 const char *name;
215 }
216 scheme_registerable; 192} scheme_registerable;
217 193
218 void scheme_register_foreign_func_list (SCHEME_P_ scheme_registerable * list, int n); 194void scheme_register_foreign_func_list (SCHEME_P_ scheme_registerable * list, int n);
219
220#endif /* !STANDALONE */ 195#endif /* !STANDALONE */
221 196
222#ifdef __cplusplus 197#ifdef __cplusplus
223} 198}
224#endif 199#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines