ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/microscheme/scheme.h
Revision: 1.3
Committed: Wed Nov 25 10:30:34 2015 UTC (8 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.2: +3 -2 lines
Log Message:
*** empty log message ***

File Contents

# Content
1
2 /* SCHEME.H */
3
4 #ifndef SCHEME_H
5 #define SCHEME_H
6
7 #include <inttypes.h>
8 #include <stdio.h>
9
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif
14
15 /*
16 * Default values for #define'd symbols
17 */
18 #ifndef STANDALONE /* If used as standalone interpreter */
19 # define STANDALONE 1
20 #endif
21
22 #define USE_STRCASECMP 1
23 #ifndef USE_STRLWR
24 # define USE_STRLWR 1
25 #endif
26 #define SCHEME_EXPORT static
27
28 #if USE_NO_FEATURES
29 # define USE_MULTIPLICITY 0
30 # define USE_MATH 0
31 # define USE_CHAR_CLASSIFIERS 0
32 # define USE_ASCII_NAMES 0
33 # define USE_PORTS 1
34 # define USE_STRING_PORTS 0
35 # define USE_ERROR_HOOK 0
36 # define USE_TRACING 0
37 # define USE_COLON_HOOK 0
38 # define USE_DL 0
39 # define USE_PLIST 0
40 # define USE_FLOAT 0
41 # define USE_ERROR_CHECKING 0
42 # define USE_PRINTF 0
43 #endif
44
45 /*
46 * Leave it defined if you want continuations, and also for the Sharp Zaurus.
47 * Undefine it if you only care about faster speed and not strict Scheme compatibility.
48 */
49 //#define USE_SCHEME_STACK
50
51 #if USE_DL
52 # define USE_INTERFACE 1
53 #endif
54
55 #ifndef USE_MULTIPLICITY
56 # define USE_MULTIPLICITY 1
57 #endif
58
59 #ifndef USE_FLOAT
60 # define USE_FLOAT 1
61 #endif
62
63 #ifndef USE_MATH /* If math support is needed */
64 # define USE_MATH 1
65 #endif
66
67 #ifndef USE_CHAR_CLASSIFIERS /* If char classifiers are needed */
68 # define USE_CHAR_CLASSIFIERS 1
69 #endif
70
71 #ifndef USE_ASCII_NAMES /* If extended escaped characters are needed */
72 # define USE_ASCII_NAMES 1
73 #endif
74
75 #ifndef USE_PORTS /* Enable ports */
76 # define USE_PORTS 1
77 #endif
78
79 #ifndef USE_STRING_PORTS /* Enable string ports */
80 # define USE_STRING_PORTS USE_PORTS
81 #endif
82
83 #ifndef USE_TRACING
84 # define USE_TRACING 1
85 #endif
86
87 #ifndef USE_PLIST
88 # define USE_PLIST 0
89 #endif
90
91 /* To force system errors through user-defined error handling (see *error-hook*) */
92 #ifndef USE_ERROR_HOOK
93 # define USE_ERROR_HOOK 1
94 #endif
95
96 #ifndef USE_COLON_HOOK /* Enable qualified qualifier */
97 # define USE_COLON_HOOK 1
98 #endif
99
100 #ifndef USE_ERROR_CHECKING
101 # define USE_ERROR_CHECKING 1
102 #endif
103
104 #ifndef USE_PRINTF
105 # define USE_PRINTF 1
106 #endif
107
108 #ifndef USE_STRLWR
109 # define USE_STRLWR 1
110 #endif
111
112 #ifndef INLINE
113 # define INLINE inline
114 #endif
115
116 #ifndef SHOW_ERROR_LINE /* Show error line in file */
117 # define SHOW_ERROR_LINE 1
118 #endif
119
120 #if USE_MULTIPLICITY
121 # define SCHEME_V sc
122 # define SCHEME_P scheme *SCHEME_V
123 # define SCHEME_P_ SCHEME_P,
124 # define SCHEME_A SCHEME_V
125 # define SCHEME_A_ SCHEME_A,
126 #else
127 # define SCHEME_V (&sc)
128 # define SCHEME_P
129 # define SCHEME_P_
130 # define SCHEME_A
131 # define SCHEME_A_
132 #endif
133
134 typedef struct scheme scheme;
135 typedef struct cell *pointer;
136
137 typedef void *(*func_alloc) (size_t);
138 typedef void (*func_dealloc) (void *);
139
140 typedef long IVALUE; /* this is not used consistently yet */
141
142 #if USE_FLOAT
143 typedef 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
151 typedef 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
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
175 /* Used for documentation purposes, to signal functions in 'interface' */
176 #define INTERFACE static
177
178 SCHEME_EXPORT scheme *scheme_init_new ();
179 SCHEME_EXPORT int scheme_init (SCHEME_P);
180 SCHEME_EXPORT void scheme_deinit (SCHEME_P);
181 void scheme_set_input_port_file (SCHEME_P_ int fin);
182 void 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);
184 void scheme_set_output_port_string (SCHEME_P_ char *start, char *past_the_end);
185 SCHEME_EXPORT void scheme_load_file (SCHEME_P_ int fin);
186 SCHEME_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);
188 SCHEME_EXPORT pointer scheme_apply0 (SCHEME_P_ const char *procname);
189 SCHEME_EXPORT pointer scheme_call (SCHEME_P_ pointer func, pointer args);
190 SCHEME_EXPORT pointer scheme_eval (SCHEME_P_ pointer obj);
191 void scheme_set_external_data (SCHEME_P_ void *p);
192 SCHEME_EXPORT void scheme_define (SCHEME_P_ pointer env, pointer symbol, pointer value);
193
194 typedef pointer (*foreign_func) (SCHEME_P_ pointer);
195
196 pointer xcons (SCHEME_P_ pointer a, pointer b, int immutable);
197 INTERFACE pointer mk_integer (SCHEME_P_ long num);
198 INTERFACE pointer mk_real (SCHEME_P_ RVALUE num);
199 INTERFACE pointer mk_symbol (SCHEME_P_ const char *name);
200 INTERFACE pointer gensym (SCHEME_P);
201 INTERFACE pointer mk_string (SCHEME_P_ const char *str);
202 INTERFACE 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);
204 INTERFACE pointer mk_character (SCHEME_P_ int c);
205 INTERFACE pointer mk_foreign_func (SCHEME_P_ foreign_func f);
206 INTERFACE void putstr (SCHEME_P_ const char *s);
207 INTERFACE int list_length (SCHEME_P_ pointer a);
208 INTERFACE int eqv (pointer a, pointer b);
209
210 #if !STANDALONE
211 typedef struct scheme_registerable
212 {
213 foreign_func f;
214 const char *name;
215 }
216 scheme_registerable;
217
218 void scheme_register_foreign_func_list (SCHEME_P_ scheme_registerable * list, int n);
219
220 #endif /* !STANDALONE */
221
222 #ifdef __cplusplus
223 }
224 #endif
225
226 #endif
227
228 /*
229 Local variables:
230 c-file-style: "k&r"
231 End:
232 */