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

Comparing cvsroot/microscheme/scheme.h (file contents):
Revision 1.1 by root, Wed Nov 25 05:02:56 2015 UTC vs.
Revision 1.2 by root, Wed Nov 25 10:01:39 2015 UTC

1 1
2/* SCHEME.H */ 2/* SCHEME.H */
3 3
4#ifndef SCHEME_H 4#ifndef SCHEME_H
5# define SCHEME_H 5#define SCHEME_H
6 6
7# include <stdio.h> 7#include <stdio.h>
8 8
9# ifdef __cplusplus 9#ifdef __cplusplus
10extern "C" 10extern "C"
11{ 11{
12# endif 12#endif
13 13
14/* 14/*
15 * Default values for #define'd symbols 15 * Default values for #define'd symbols
16 */ 16 */
17# ifndef STANDALONE /* If used as standalone interpreter */ 17#ifndef STANDALONE /* If used as standalone interpreter */
18# define STANDALONE 1 18# define STANDALONE 1
19# endif 19#endif
20 20
21# define USE_STRCASECMP 1 21#define USE_STRCASECMP 1
22# ifndef USE_STRLWR 22#ifndef USE_STRLWR
23# define USE_STRLWR 1 23# define USE_STRLWR 1
24# endif 24#endif
25# define SCHEME_EXPORT static 25#define SCHEME_EXPORT static
26 26
27# if USE_NO_FEATURES 27#if USE_NO_FEATURES
28# define USE_MULTIPLICITY 0 28# define USE_MULTIPLICITY 0
29# define USE_MATH 0 29# define USE_MATH 0
30# define USE_CHAR_CLASSIFIERS 0 30# define USE_CHAR_CLASSIFIERS 0
31# define USE_ASCII_NAMES 0 31# define USE_ASCII_NAMES 0
32# define USE_PORTS 1 32# define USE_PORTS 1
33# define USE_STRING_PORTS 0 33# define USE_STRING_PORTS 0
34# define USE_ERROR_HOOK 0 34# define USE_ERROR_HOOK 0
35# define USE_TRACING 0 35# define USE_TRACING 0
36# define USE_COLON_HOOK 0 36# define USE_COLON_HOOK 0
37# define USE_DL 0 37# define USE_DL 0
38# define USE_PLIST 0 38# define USE_PLIST 0
39# define USE_FLOAT 0 39# define USE_FLOAT 0
40# define USE_ERROR_CHECKING 0 40# define USE_ERROR_CHECKING 0
41# define USE_PRINTF 0 41# define USE_PRINTF 0
42# endif 42#endif
43 43
44/* 44/*
45 * Leave it defined if you want continuations, and also for the Sharp Zaurus. 45 * Leave it defined if you want continuations, and also for the Sharp Zaurus.
46 * Undefine it if you only care about faster speed and not strict Scheme compatibility. 46 * Undefine it if you only care about faster speed and not strict Scheme compatibility.
47 */ 47 */
48//# define USE_SCHEME_STACK 48//#define USE_SCHEME_STACK
49 49
50# if USE_DL 50#if USE_DL
51# define USE_INTERFACE 1 51# define USE_INTERFACE 1
52# endif 52#endif
53 53
54# ifndef USE_MULTIPLICITY 54#ifndef USE_MULTIPLICITY
55# define USE_MULTIPLICITY 1 55# define USE_MULTIPLICITY 1
56# endif 56#endif
57 57
58# ifndef USE_FLOAT 58#ifndef USE_FLOAT
59# define USE_FLOAT 1 59# define USE_FLOAT 1
60# endif 60#endif
61 61
62# ifndef USE_MATH /* If math support is needed */ 62#ifndef USE_MATH /* If math support is needed */
63# define USE_MATH 1 63# define USE_MATH 1
64# endif 64#endif
65 65
66# ifndef USE_CHAR_CLASSIFIERS /* If char classifiers are needed */ 66#ifndef USE_CHAR_CLASSIFIERS /* If char classifiers are needed */
67# define USE_CHAR_CLASSIFIERS 1 67# define USE_CHAR_CLASSIFIERS 1
68# endif 68#endif
69 69
70# ifndef USE_ASCII_NAMES /* If extended escaped characters are needed */ 70#ifndef USE_ASCII_NAMES /* If extended escaped characters are needed */
71# define USE_ASCII_NAMES 1 71# define USE_ASCII_NAMES 1
72# endif 72#endif
73 73
74# ifndef USE_PORTS /* Enable ports */ 74#ifndef USE_PORTS /* Enable ports */
75# define USE_PORTS 1 75# define USE_PORTS 1
76# endif 76#endif
77 77
78# ifndef USE_STRING_PORTS /* Enable string ports */ 78#ifndef USE_STRING_PORTS /* Enable string ports */
79# define USE_STRING_PORTS USE_PORTS 79# define USE_STRING_PORTS USE_PORTS
80# endif 80#endif
81 81
82# ifndef USE_TRACING 82#ifndef USE_TRACING
83# define USE_TRACING 1 83# define USE_TRACING 1
84# endif 84#endif
85 85
86# ifndef USE_PLIST 86#ifndef USE_PLIST
87# define USE_PLIST 0 87# define USE_PLIST 0
88# endif 88#endif
89 89
90/* 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*) */
91# ifndef USE_ERROR_HOOK 91#ifndef USE_ERROR_HOOK
92# define USE_ERROR_HOOK 1 92# define USE_ERROR_HOOK 1
93# endif 93#endif
94 94
95# ifndef USE_COLON_HOOK /* Enable qualified qualifier */ 95#ifndef USE_COLON_HOOK /* Enable qualified qualifier */
96# define USE_COLON_HOOK 1 96# define USE_COLON_HOOK 1
97# endif 97#endif
98 98
99# ifndef USE_ERROR_CHECKING 99#ifndef USE_ERROR_CHECKING
100# define USE_ERROR_CHECKING 1 100# define USE_ERROR_CHECKING 1
101# endif 101#endif
102 102
103# ifndef USE_PRINTF 103#ifndef USE_PRINTF
104# define USE_PRINTF 1 104# define USE_PRINTF 1
105# endif 105#endif
106 106
107# ifndef USE_STRLWR 107#ifndef USE_STRLWR
108# define USE_STRLWR 1 108# define USE_STRLWR 1
109# endif 109#endif
110 110
111# ifndef INLINE 111#ifndef INLINE
112# define INLINE inline 112# define INLINE inline
113# endif 113#endif
114 114
115# ifndef SHOW_ERROR_LINE /* Show error line in file */ 115#ifndef SHOW_ERROR_LINE /* Show error line in file */
116# define SHOW_ERROR_LINE 1 116# define SHOW_ERROR_LINE 1
117# endif 117#endif
118 118
119# if USE_MULTIPLICITY 119#if USE_MULTIPLICITY
120# define SCHEME_V sc 120# define SCHEME_V sc
121# define SCHEME_P scheme *SCHEME_V 121# define SCHEME_P scheme *SCHEME_V
122# define SCHEME_P_ SCHEME_P, 122# define SCHEME_P_ SCHEME_P,
123# define SCHEME_A SCHEME_V 123# define SCHEME_A SCHEME_V
124# define SCHEME_A_ SCHEME_A, 124# define SCHEME_A_ SCHEME_A,
125# else 125#else
126# define SCHEME_V (&sc) 126# define SCHEME_V (&sc)
127# define SCHEME_P 127# define SCHEME_P
128# define SCHEME_P_ 128# define SCHEME_P_
129# define SCHEME_A 129# define SCHEME_A
130# define SCHEME_A_ 130# define SCHEME_A_
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); 136 typedef void *(*func_alloc) (size_t);
137 typedef void (*func_dealloc) (void *); 137 typedef void (*func_dealloc) (void *);
138 138
139 typedef long IVALUE; /* this is not used consistently yet */ 139 typedef long IVALUE; /* this is not used consistently yet */
140 140
141# if USE_FLOAT 141#if USE_FLOAT
142 typedef double RVALUE; 142 typedef double RVALUE;
143# define num_is_fixnum(n) (n).is_fixnum 143# define num_is_fixnum(n) (n).is_fixnum
144# define num_set_fixnum(n,f) (n).is_fixnum = (f) 144# define num_set_fixnum(n,f) (n).is_fixnum = (f)
145# define num_ivalue(n) (n.is_fixnum?(n).value.ivalue:(IVALUE)(n).value.rvalue) 145# define num_ivalue(n) (n).value.ivalue
146# define num_rvalue(n) (!n.is_fixnum?(n).value.rvalue:(RVALUE)(n).value.ivalue) 146# define num_rvalue(n) (n).value.rvalue
147# define num_set_ivalue(n,i) (n).value.ivalue = (i) 147# define num_set_ivalue(n,i) (n).value.ivalue = (i)
148# define num_set_rvalue(n,r) (n).value.rvalue = (r) 148# define num_set_rvalue(n,r) (n).value.rvalue = (r)
149# else 149#else
150 typedef long RVALUE; 150 typedef long RVALUE;
151# define num_is_fixnum(n) 1 151# define num_is_fixnum(n) 1
152# define num_set_fixnum(n,f) 0 152# define num_set_fixnum(n,f) 0
153# define num_ivalue(n) (n).value.ivalue 153# define num_ivalue(n) (n).value.ivalue
154# define num_rvalue(n) (n).value.ivalue 154# define num_rvalue(n) (n).value.ivalue
155# define num_set_ivalue(n,i) (n).value.ivalue = (i) 155# define num_set_ivalue(n,i) (n).value.ivalue = (i)
156# define num_set_rvalue(n,r) (n).value.ivalue = (r) 156# define num_set_rvalue(n,r) (n).value.ivalue = (r)
157# endif 157#endif
158 158
159/* num, for generic arithmetic */ 159/* num, for generic arithmetic */
160 typedef struct num 160 typedef struct num
161 { 161 {
162 union 162 union
163 { 163 {
164 long ivalue; 164 long ivalue;
165# if USE_FLOAT 165#if USE_FLOAT
166 RVALUE rvalue; 166 RVALUE rvalue;
167# endif 167#endif
168 } value; 168 } value;
169# if USE_FLOAT 169#if USE_FLOAT
170 char is_fixnum; 170 char is_fixnum;
171# endif 171#endif
172 } num; 172 } num;
173 173
174/* Used for documentation purposes, to signal functions in 'interface' */ 174/* Used for documentation purposes, to signal functions in 'interface' */
175# define INTERFACE static 175#define INTERFACE static
176 176
177 SCHEME_EXPORT scheme *scheme_init_new (); 177 SCHEME_EXPORT scheme *scheme_init_new ();
178 SCHEME_EXPORT int scheme_init (SCHEME_P); 178 SCHEME_EXPORT int scheme_init (SCHEME_P);
179 SCHEME_EXPORT void scheme_deinit (SCHEME_P); 179 SCHEME_EXPORT void scheme_deinit (SCHEME_P);
180 void scheme_set_input_port_file (SCHEME_P_ int fin); 180 void scheme_set_input_port_file (SCHEME_P_ int fin);
204 INTERFACE pointer mk_foreign_func (SCHEME_P_ foreign_func f); 204 INTERFACE pointer mk_foreign_func (SCHEME_P_ foreign_func f);
205 INTERFACE void putstr (SCHEME_P_ const char *s); 205 INTERFACE void putstr (SCHEME_P_ const char *s);
206 INTERFACE int list_length (SCHEME_P_ pointer a); 206 INTERFACE int list_length (SCHEME_P_ pointer a);
207 INTERFACE int eqv (pointer a, pointer b); 207 INTERFACE int eqv (pointer a, pointer b);
208 208
209# if !STANDALONE 209#if !STANDALONE
210 typedef struct scheme_registerable 210 typedef struct scheme_registerable
211 { 211 {
212 foreign_func f; 212 foreign_func f;
213 const char *name; 213 const char *name;
214 } 214 }
215 scheme_registerable; 215 scheme_registerable;
216 216
217 void scheme_register_foreign_func_list (SCHEME_P_ scheme_registerable * list, int n); 217 void scheme_register_foreign_func_list (SCHEME_P_ scheme_registerable * list, int n);
218 218
219# endif /* !STANDALONE */ 219#endif /* !STANDALONE */
220 220
221# ifdef __cplusplus 221#ifdef __cplusplus
222} 222}
223# endif 223#endif
224 224
225#endif 225#endif
226
227 226
228/* 227/*
229Local variables: 228Local variables:
230c-file-style: "k&r" 229c-file-style: "k&r"
231End: 230End:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines