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