recalculate the bounding boxes when drawing primatives via the libgerbv API
[geda-gerbv.git] / src / scheme.h
blob869d9502b02387cc26e610152a90cf355a72ba44
1 /* SCHEME.H */
3 /** \file scheme.h
4 \brief Header info for the TinyScheme compiler
5 \ingroup gerbv
6 */
8 #ifndef _SCHEME_H
9 #define _SCHEME_H
11 #include <stdio.h>
13 #ifdef HAVE_CONFIG_H
14 #include <config.h>
15 #endif
18 * Default values for #define'd symbols
20 #ifndef STANDALONE /* If used as standalone interpreter */
21 # define STANDALONE 1
22 #endif
25 #if !defined(_MSC_VER) && !defined(__MINGW32__)
26 # define USE_STRCASECMP 1
27 # define USE_STRLWR 1
28 # define SCHEME_EXPORT
29 #else
30 # define USE_STRCASECMP 0
31 # define USE_STRLWR 0
32 # if defined(__MINGW32__)
33 # define SCHEME_EXPORT
34 # else
35 # ifdef _SCHEME_SOURCE
36 # define SCHEME_EXPORT __declspec(dllexport)
37 # else
38 # define SCHEME_EXPORT __declspec(dllimport)
39 # endif
40 # endif
41 #endif
45 #if USE_NO_FEATURES
46 # define USE_MATH 0
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
53 # define USE_DL 0
54 # define USE_PLIST 0
55 #endif
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
63 #if USE_DL
64 # define USE_INTERFACE 1
65 #endif
68 #ifndef USE_MATH /* If math support is needed */
69 # define USE_MATH 1
70 #endif
72 #ifndef USE_CHAR_CLASSIFIERS /* If char classifiers are needed */
73 # define USE_CHAR_CLASSIFIERS 1
74 #endif
76 #ifndef USE_ASCII_NAMES /* If extended escaped characters are needed */
77 # define USE_ASCII_NAMES 1
78 #endif
80 #ifndef USE_STRING_PORTS /* Enable string ports */
81 # define USE_STRING_PORTS 1
82 #endif
84 #ifndef USE_TRACING
85 # define USE_TRACING 1
86 #endif
88 #ifndef USE_PLIST
89 # define USE_PLIST 0
90 #endif
92 /* To force system errors through user-defined error handling (see *error-hook*) */
93 #ifndef USE_ERROR_HOOK
94 # define USE_ERROR_HOOK 1
95 #endif
97 #ifndef USE_COLON_HOOK /* Enable qualified qualifier */
98 # define USE_COLON_HOOK 1
99 #endif
101 #ifndef USE_STRCASECMP /* stricmp for Unix */
102 # define USE_STRCASECMP 0
103 #endif
105 #ifndef USE_STRLWR
106 # define USE_STRLWR 1
107 #endif
109 #ifndef STDIO_ADDS_CR /* Define if DOS/Windows */
110 # define STDIO_ADDS_CR 0
111 #endif
113 #ifndef INLINE
114 # define INLINE
115 #endif
117 #ifndef USE_INTERFACE
118 # define USE_INTERFACE 0
119 #endif
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 */
128 typedef struct num {
129 char is_fixnum;
130 union {
131 long ivalue;
132 double rvalue;
133 } value;
134 } num;
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);
166 #if USE_INTERFACE
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);
226 #endif
228 #endif