raw
tinyscheme_genesi...    1 /* SCHEME.H */
tinyscheme_genesi... 2
tinyscheme_genesi... 3 #ifndef _SCHEME_H
tinyscheme_genesi... 4 #define _SCHEME_H
tinyscheme_genesi... 5
tinyscheme_genesi... 6 #include <stdio.h>
tinyscheme_genesi... 7
tinyscheme_genesi... 8 #ifdef __cplusplus
tinyscheme_genesi... 9 extern "C" {
tinyscheme_genesi... 10 #endif
tinyscheme_genesi... 11
tinyscheme_genesi... 12 /*
tinyscheme_genesi... 13 * Default values for #define'd symbols
tinyscheme_genesi... 14 */
tinyscheme_genesi... 15 #ifndef STANDALONE /* If used as standalone interpreter */
tinyscheme_genesi... 16 # define STANDALONE 1
tinyscheme_genesi... 17 #endif
tinyscheme_genesi... 18
tinyscheme_genesi... 19 #ifndef _MSC_VER
tinyscheme_genesi... 20 # define USE_STRCASECMP 1
tinyscheme_genesi... 21 # ifndef USE_STRLWR
tinyscheme_genesi... 22 # define USE_STRLWR 1
tinyscheme_genesi... 23 # endif
tinyscheme_genesi... 24 # define SCHEME_EXPORT
tinyscheme_genesi... 25 #else
tinyscheme_genesi... 26 # define USE_STRCASECMP 0
tinyscheme_genesi... 27 # define USE_STRLWR 0
tinyscheme_genesi... 28 # ifdef _SCHEME_SOURCE
tinyscheme_genesi... 29 # define SCHEME_EXPORT __declspec(dllexport)
tinyscheme_genesi... 30 # else
tinyscheme_genesi... 31 # define SCHEME_EXPORT __declspec(dllimport)
tinyscheme_genesi... 32 # endif
tinyscheme_genesi... 33 #endif
tinyscheme_genesi... 34
tinyscheme_genesi... 35 #if USE_NO_FEATURES
tinyscheme_genesi... 36 # define USE_MATH 0
tinyscheme_genesi... 37 # define USE_CHAR_CLASSIFIERS 0
tinyscheme_genesi... 38 # define USE_ASCII_NAMES 0
tinyscheme_genesi... 39 # define USE_STRING_PORTS 0
tinyscheme_genesi... 40 # define USE_ERROR_HOOK 0
tinyscheme_genesi... 41 # define USE_TRACING 0
tinyscheme_genesi... 42 # define USE_COLON_HOOK 0
tinyscheme_genesi... 43 # define USE_DL 0
tinyscheme_genesi... 44 # define USE_PLIST 0
tinyscheme_genesi... 45 #endif
tinyscheme_genesi... 46
tinyscheme_genesi... 47 /*
tinyscheme_genesi... 48 * Leave it defined if you want continuations, and also for the Sharp Zaurus.
tinyscheme_genesi... 49 * Undefine it if you only care about faster speed and not strict Scheme compatibility.
tinyscheme_genesi... 50 */
tinyscheme_genesi... 51 #define USE_SCHEME_STACK
tinyscheme_genesi... 52
tinyscheme_genesi... 53 #if USE_DL
tinyscheme_genesi... 54 # define USE_INTERFACE 1
tinyscheme_genesi... 55 #endif
tinyscheme_genesi... 56
tinyscheme_genesi... 57
tinyscheme_genesi... 58 #ifndef USE_MATH /* If math support is needed */
tinyscheme_genesi... 59 # define USE_MATH 1
tinyscheme_genesi... 60 #endif
tinyscheme_genesi... 61
tinyscheme_genesi... 62 #ifndef USE_CHAR_CLASSIFIERS /* If char classifiers are needed */
tinyscheme_genesi... 63 # define USE_CHAR_CLASSIFIERS 1
tinyscheme_genesi... 64 #endif
tinyscheme_genesi... 65
tinyscheme_genesi... 66 #ifndef USE_ASCII_NAMES /* If extended escaped characters are needed */
tinyscheme_genesi... 67 # define USE_ASCII_NAMES 1
tinyscheme_genesi... 68 #endif
tinyscheme_genesi... 69
tinyscheme_genesi... 70 #ifndef USE_STRING_PORTS /* Enable string ports */
tinyscheme_genesi... 71 # define USE_STRING_PORTS 1
tinyscheme_genesi... 72 #endif
tinyscheme_genesi... 73
tinyscheme_genesi... 74 #ifndef USE_TRACING
tinyscheme_genesi... 75 # define USE_TRACING 1
tinyscheme_genesi... 76 #endif
tinyscheme_genesi... 77
tinyscheme_genesi... 78 #ifndef USE_PLIST
tinyscheme_genesi... 79 # define USE_PLIST 0
tinyscheme_genesi... 80 #endif
tinyscheme_genesi... 81
tinyscheme_genesi... 82 /* To force system errors through user-defined error handling (see *error-hook*) */
tinyscheme_genesi... 83 #ifndef USE_ERROR_HOOK
tinyscheme_genesi... 84 # define USE_ERROR_HOOK 1
tinyscheme_genesi... 85 #endif
tinyscheme_genesi... 86
tinyscheme_genesi... 87 #ifndef USE_COLON_HOOK /* Enable qualified qualifier */
tinyscheme_genesi... 88 # define USE_COLON_HOOK 1
tinyscheme_genesi... 89 #endif
tinyscheme_genesi... 90
tinyscheme_genesi... 91 #ifndef USE_STRCASECMP /* stricmp for Unix */
tinyscheme_genesi... 92 # define USE_STRCASECMP 0
tinyscheme_genesi... 93 #endif
tinyscheme_genesi... 94
tinyscheme_genesi... 95 #ifndef USE_STRLWR
tinyscheme_genesi... 96 # define USE_STRLWR 1
tinyscheme_genesi... 97 #endif
tinyscheme_genesi... 98
tinyscheme_genesi... 99 #ifndef STDIO_ADDS_CR /* Define if DOS/Windows */
tinyscheme_genesi... 100 # define STDIO_ADDS_CR 0
tinyscheme_genesi... 101 #endif
tinyscheme_genesi... 102
tinyscheme_genesi... 103 #ifndef INLINE
tinyscheme_genesi... 104 # define INLINE
tinyscheme_genesi... 105 #endif
tinyscheme_genesi... 106
tinyscheme_genesi... 107 #ifndef USE_INTERFACE
tinyscheme_genesi... 108 # define USE_INTERFACE 0
tinyscheme_genesi... 109 #endif
tinyscheme_genesi... 110
tinyscheme_genesi... 111 #ifndef SHOW_ERROR_LINE /* Show error line in file */
tinyscheme_genesi... 112 # define SHOW_ERROR_LINE 1
tinyscheme_genesi... 113 #endif
tinyscheme_genesi... 114
tinyscheme_genesi... 115 typedef struct scheme scheme;
tinyscheme_genesi... 116 typedef struct cell *pointer;
tinyscheme_genesi... 117
tinyscheme_genesi... 118 typedef void * (*func_alloc)(size_t);
tinyscheme_genesi... 119 typedef void (*func_dealloc)(void *);
tinyscheme_genesi... 120
tinyscheme_genesi... 121 /* num, for generic arithmetic */
tinyscheme_genesi... 122 typedef struct num {
tinyscheme_genesi... 123 char is_fixnum;
tinyscheme_genesi... 124 union {
tinyscheme_genesi... 125 long ivalue;
tinyscheme_genesi... 126 double rvalue;
tinyscheme_genesi... 127 } value;
tinyscheme_genesi... 128 } num;
tinyscheme_genesi... 129
tinyscheme_genesi... 130 SCHEME_EXPORT scheme *scheme_init_new();
tinyscheme_genesi... 131 SCHEME_EXPORT scheme *scheme_init_new_custom_alloc(func_alloc malloc, func_dealloc free);
tinyscheme_genesi... 132 SCHEME_EXPORT int scheme_init(scheme *sc);
tinyscheme_genesi... 133 SCHEME_EXPORT int scheme_init_custom_alloc(scheme *sc, func_alloc, func_dealloc);
tinyscheme_genesi... 134 SCHEME_EXPORT void scheme_deinit(scheme *sc);
tinyscheme_genesi... 135 void scheme_set_input_port_file(scheme *sc, FILE *fin);
tinyscheme_genesi... 136 void scheme_set_input_port_string(scheme *sc, char *start, char *past_the_end);
tinyscheme_genesi... 137 SCHEME_EXPORT void scheme_set_output_port_file(scheme *sc, FILE *fin);
tinyscheme_genesi... 138 void scheme_set_output_port_string(scheme *sc, char *start, char *past_the_end);
tinyscheme_genesi... 139 SCHEME_EXPORT void scheme_load_file(scheme *sc, FILE *fin);
tinyscheme_genesi... 140 SCHEME_EXPORT void scheme_load_named_file(scheme *sc, FILE *fin, const char *filename);
tinyscheme_genesi... 141 SCHEME_EXPORT void scheme_load_string(scheme *sc, const char *cmd);
tinyscheme_genesi... 142 SCHEME_EXPORT pointer scheme_apply0(scheme *sc, const char *procname);
tinyscheme_genesi... 143 SCHEME_EXPORT pointer scheme_call(scheme *sc, pointer func, pointer args);
tinyscheme_genesi... 144 SCHEME_EXPORT pointer scheme_eval(scheme *sc, pointer obj);
tinyscheme_genesi... 145 void scheme_set_external_data(scheme *sc, void *p);
tinyscheme_genesi... 146 SCHEME_EXPORT void scheme_define(scheme *sc, pointer env, pointer symbol, pointer value);
tinyscheme_genesi... 147
tinyscheme_genesi... 148 typedef pointer (*foreign_func)(scheme *, pointer);
tinyscheme_genesi... 149
tinyscheme_genesi... 150 pointer _cons(scheme *sc, pointer a, pointer b, int immutable);
tinyscheme_genesi... 151 pointer mk_integer(scheme *sc, long num);
tinyscheme_genesi... 152 pointer mk_real(scheme *sc, double num);
tinyscheme_genesi... 153 pointer mk_symbol(scheme *sc, const char *name);
tinyscheme_genesi... 154 pointer gensym(scheme *sc);
tinyscheme_genesi... 155 pointer mk_string(scheme *sc, const char *str);
tinyscheme_genesi... 156 pointer mk_counted_string(scheme *sc, const char *str, int len);
tinyscheme_genesi... 157 pointer mk_empty_string(scheme *sc, int len, char fill);
tinyscheme_genesi... 158 pointer mk_character(scheme *sc, int c);
tinyscheme_genesi... 159 pointer mk_foreign_func(scheme *sc, foreign_func f);
tinyscheme_genesi... 160 void putstr(scheme *sc, const char *s);
tinyscheme_genesi... 161 int list_length(scheme *sc, pointer a);
tinyscheme_genesi... 162 int eqv(pointer a, pointer b);
tinyscheme_genesi... 163
tinyscheme_genesi... 164
tinyscheme_genesi... 165 #if USE_INTERFACE
tinyscheme_genesi... 166 struct scheme_interface {
tinyscheme_genesi... 167 void (*scheme_define)(scheme *sc, pointer env, pointer symbol, pointer value);
tinyscheme_genesi... 168 pointer (*cons)(scheme *sc, pointer a, pointer b);
tinyscheme_genesi... 169 pointer (*immutable_cons)(scheme *sc, pointer a, pointer b);
tinyscheme_genesi... 170 pointer (*reserve_cells)(scheme *sc, int n);
tinyscheme_genesi... 171 pointer (*mk_integer)(scheme *sc, long num);
tinyscheme_genesi... 172 pointer (*mk_real)(scheme *sc, double num);
tinyscheme_genesi... 173 pointer (*mk_symbol)(scheme *sc, const char *name);
tinyscheme_genesi... 174 pointer (*gensym)(scheme *sc);
tinyscheme_genesi... 175 pointer (*mk_string)(scheme *sc, const char *str);
tinyscheme_genesi... 176 pointer (*mk_counted_string)(scheme *sc, const char *str, int len);
tinyscheme_genesi... 177 pointer (*mk_character)(scheme *sc, int c);
tinyscheme_genesi... 178 pointer (*mk_vector)(scheme *sc, int len);
tinyscheme_genesi... 179 pointer (*mk_foreign_func)(scheme *sc, foreign_func f);
tinyscheme_genesi... 180 void (*putstr)(scheme *sc, const char *s);
tinyscheme_genesi... 181 void (*putcharacter)(scheme *sc, int c);
tinyscheme_genesi... 182
tinyscheme_genesi... 183 int (*is_string)(pointer p);
tinyscheme_genesi... 184 char *(*string_value)(pointer p);
tinyscheme_genesi... 185 int (*is_number)(pointer p);
tinyscheme_genesi... 186 num (*nvalue)(pointer p);
tinyscheme_genesi... 187 long (*ivalue)(pointer p);
tinyscheme_genesi... 188 double (*rvalue)(pointer p);
tinyscheme_genesi... 189 int (*is_integer)(pointer p);
tinyscheme_genesi... 190 int (*is_real)(pointer p);
tinyscheme_genesi... 191 int (*is_character)(pointer p);
tinyscheme_genesi... 192 long (*charvalue)(pointer p);
tinyscheme_genesi... 193 int (*is_list)(scheme *sc, pointer p);
tinyscheme_genesi... 194 int (*is_vector)(pointer p);
tinyscheme_genesi... 195 int (*list_length)(scheme *sc, pointer vec);
tinyscheme_genesi... 196 long (*vector_length)(pointer vec);
tinyscheme_genesi... 197 void (*fill_vector)(pointer vec, pointer elem);
tinyscheme_genesi... 198 pointer (*vector_elem)(pointer vec, int ielem);
tinyscheme_genesi... 199 pointer (*set_vector_elem)(pointer vec, int ielem, pointer newel);
tinyscheme_genesi... 200 int (*is_port)(pointer p);
tinyscheme_genesi... 201
tinyscheme_genesi... 202 int (*is_pair)(pointer p);
tinyscheme_genesi... 203 pointer (*pair_car)(pointer p);
tinyscheme_genesi... 204 pointer (*pair_cdr)(pointer p);
tinyscheme_genesi... 205 pointer (*set_car)(pointer p, pointer q);
tinyscheme_genesi... 206 pointer (*set_cdr)(pointer p, pointer q);
tinyscheme_genesi... 207
tinyscheme_genesi... 208 int (*is_symbol)(pointer p);
tinyscheme_genesi... 209 char *(*symname)(pointer p);
tinyscheme_genesi... 210
tinyscheme_genesi... 211 int (*is_syntax)(pointer p);
tinyscheme_genesi... 212 int (*is_proc)(pointer p);
tinyscheme_genesi... 213 int (*is_foreign)(pointer p);
tinyscheme_genesi... 214 char *(*syntaxname)(pointer p);
tinyscheme_genesi... 215 int (*is_closure)(pointer p);
tinyscheme_genesi... 216 int (*is_macro)(pointer p);
tinyscheme_genesi... 217 pointer (*closure_code)(pointer p);
tinyscheme_genesi... 218 pointer (*closure_env)(pointer p);
tinyscheme_genesi... 219
tinyscheme_genesi... 220 int (*is_continuation)(pointer p);
tinyscheme_genesi... 221 int (*is_promise)(pointer p);
tinyscheme_genesi... 222 int (*is_environment)(pointer p);
tinyscheme_genesi... 223 int (*is_immutable)(pointer p);
tinyscheme_genesi... 224 void (*setimmutable)(pointer p);
tinyscheme_genesi... 225 void (*load_file)(scheme *sc, FILE *fin);
tinyscheme_genesi... 226 void (*load_string)(scheme *sc, const char *input);
tinyscheme_genesi... 227 };
tinyscheme_genesi... 228 #endif
tinyscheme_genesi... 229
tinyscheme_genesi... 230 #if !STANDALONE
tinyscheme_genesi... 231 typedef struct scheme_registerable
tinyscheme_genesi... 232 {
tinyscheme_genesi... 233 foreign_func f;
tinyscheme_genesi... 234 const char * name;
tinyscheme_genesi... 235 }
tinyscheme_genesi... 236 scheme_registerable;
tinyscheme_genesi... 237
tinyscheme_genesi... 238 void scheme_register_foreign_func_list(scheme * sc,
tinyscheme_genesi... 239 scheme_registerable * list,
tinyscheme_genesi... 240 int n);
tinyscheme_genesi... 241
tinyscheme_genesi... 242 #endif /* !STANDALONE */
tinyscheme_genesi... 243
tinyscheme_genesi... 244 #ifdef __cplusplus
tinyscheme_genesi... 245 }
tinyscheme_genesi... 246 #endif
tinyscheme_genesi... 247
tinyscheme_genesi... 248 #endif
tinyscheme_genesi... 249
tinyscheme_genesi... 250
tinyscheme_genesi... 251 /*
tinyscheme_genesi... 252 Local variables:
tinyscheme_genesi... 253 c-file-style: "k&r"
tinyscheme_genesi... 254 End:
tinyscheme_genesi... 255 */