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