-
+ 282012705842DD4C1341549F5E82BF092274697D51F5DD6B557E9F0D6E25AB16DEA0A1825C19329CE72A5F85511D25BCF636D015CB6926F381348EF9A372DC8C
tinyscheme/scheme.h
(0 . 0)(1 . 255)
7765 /* SCHEME.H */
7766
7767 #ifndef _SCHEME_H
7768 #define _SCHEME_H
7769
7770 #include <stdio.h>
7771
7772 #ifdef __cplusplus
7773 extern "C" {
7774 #endif
7775
7776 /*
7777 * Default values for #define'd symbols
7778 */
7779 #ifndef STANDALONE /* If used as standalone interpreter */
7780 # define STANDALONE 1
7781 #endif
7782
7783 #ifndef _MSC_VER
7784 # define USE_STRCASECMP 1
7785 # ifndef USE_STRLWR
7786 # define USE_STRLWR 1
7787 # endif
7788 # define SCHEME_EXPORT
7789 #else
7790 # define USE_STRCASECMP 0
7791 # define USE_STRLWR 0
7792 # ifdef _SCHEME_SOURCE
7793 # define SCHEME_EXPORT __declspec(dllexport)
7794 # else
7795 # define SCHEME_EXPORT __declspec(dllimport)
7796 # endif
7797 #endif
7798
7799 #if USE_NO_FEATURES
7800 # define USE_MATH 0
7801 # define USE_CHAR_CLASSIFIERS 0
7802 # define USE_ASCII_NAMES 0
7803 # define USE_STRING_PORTS 0
7804 # define USE_ERROR_HOOK 0
7805 # define USE_TRACING 0
7806 # define USE_COLON_HOOK 0
7807 # define USE_DL 0
7808 # define USE_PLIST 0
7809 #endif
7810
7811 /*
7812 * Leave it defined if you want continuations, and also for the Sharp Zaurus.
7813 * Undefine it if you only care about faster speed and not strict Scheme compatibility.
7814 */
7815 #define USE_SCHEME_STACK
7816
7817 #if USE_DL
7818 # define USE_INTERFACE 1
7819 #endif
7820
7821
7822 #ifndef USE_MATH /* If math support is needed */
7823 # define USE_MATH 1
7824 #endif
7825
7826 #ifndef USE_CHAR_CLASSIFIERS /* If char classifiers are needed */
7827 # define USE_CHAR_CLASSIFIERS 1
7828 #endif
7829
7830 #ifndef USE_ASCII_NAMES /* If extended escaped characters are needed */
7831 # define USE_ASCII_NAMES 1
7832 #endif
7833
7834 #ifndef USE_STRING_PORTS /* Enable string ports */
7835 # define USE_STRING_PORTS 1
7836 #endif
7837
7838 #ifndef USE_TRACING
7839 # define USE_TRACING 1
7840 #endif
7841
7842 #ifndef USE_PLIST
7843 # define USE_PLIST 0
7844 #endif
7845
7846 /* To force system errors through user-defined error handling (see *error-hook*) */
7847 #ifndef USE_ERROR_HOOK
7848 # define USE_ERROR_HOOK 1
7849 #endif
7850
7851 #ifndef USE_COLON_HOOK /* Enable qualified qualifier */
7852 # define USE_COLON_HOOK 1
7853 #endif
7854
7855 #ifndef USE_STRCASECMP /* stricmp for Unix */
7856 # define USE_STRCASECMP 0
7857 #endif
7858
7859 #ifndef USE_STRLWR
7860 # define USE_STRLWR 1
7861 #endif
7862
7863 #ifndef STDIO_ADDS_CR /* Define if DOS/Windows */
7864 # define STDIO_ADDS_CR 0
7865 #endif
7866
7867 #ifndef INLINE
7868 # define INLINE
7869 #endif
7870
7871 #ifndef USE_INTERFACE
7872 # define USE_INTERFACE 0
7873 #endif
7874
7875 #ifndef SHOW_ERROR_LINE /* Show error line in file */
7876 # define SHOW_ERROR_LINE 1
7877 #endif
7878
7879 typedef struct scheme scheme;
7880 typedef struct cell *pointer;
7881
7882 typedef void * (*func_alloc)(size_t);
7883 typedef void (*func_dealloc)(void *);
7884
7885 /* num, for generic arithmetic */
7886 typedef struct num {
7887 char is_fixnum;
7888 union {
7889 long ivalue;
7890 double rvalue;
7891 } value;
7892 } num;
7893
7894 SCHEME_EXPORT scheme *scheme_init_new();
7895 SCHEME_EXPORT scheme *scheme_init_new_custom_alloc(func_alloc malloc, func_dealloc free);
7896 SCHEME_EXPORT int scheme_init(scheme *sc);
7897 SCHEME_EXPORT int scheme_init_custom_alloc(scheme *sc, func_alloc, func_dealloc);
7898 SCHEME_EXPORT void scheme_deinit(scheme *sc);
7899 void scheme_set_input_port_file(scheme *sc, FILE *fin);
7900 void scheme_set_input_port_string(scheme *sc, char *start, char *past_the_end);
7901 SCHEME_EXPORT void scheme_set_output_port_file(scheme *sc, FILE *fin);
7902 void scheme_set_output_port_string(scheme *sc, char *start, char *past_the_end);
7903 SCHEME_EXPORT void scheme_load_file(scheme *sc, FILE *fin);
7904 SCHEME_EXPORT void scheme_load_named_file(scheme *sc, FILE *fin, const char *filename);
7905 SCHEME_EXPORT void scheme_load_string(scheme *sc, const char *cmd);
7906 SCHEME_EXPORT pointer scheme_apply0(scheme *sc, const char *procname);
7907 SCHEME_EXPORT pointer scheme_call(scheme *sc, pointer func, pointer args);
7908 SCHEME_EXPORT pointer scheme_eval(scheme *sc, pointer obj);
7909 void scheme_set_external_data(scheme *sc, void *p);
7910 SCHEME_EXPORT void scheme_define(scheme *sc, pointer env, pointer symbol, pointer value);
7911
7912 typedef pointer (*foreign_func)(scheme *, pointer);
7913
7914 pointer _cons(scheme *sc, pointer a, pointer b, int immutable);
7915 pointer mk_integer(scheme *sc, long num);
7916 pointer mk_real(scheme *sc, double num);
7917 pointer mk_symbol(scheme *sc, const char *name);
7918 pointer gensym(scheme *sc);
7919 pointer mk_string(scheme *sc, const char *str);
7920 pointer mk_counted_string(scheme *sc, const char *str, int len);
7921 pointer mk_empty_string(scheme *sc, int len, char fill);
7922 pointer mk_character(scheme *sc, int c);
7923 pointer mk_foreign_func(scheme *sc, foreign_func f);
7924 void putstr(scheme *sc, const char *s);
7925 int list_length(scheme *sc, pointer a);
7926 int eqv(pointer a, pointer b);
7927
7928
7929 #if USE_INTERFACE
7930 struct scheme_interface {
7931 void (*scheme_define)(scheme *sc, pointer env, pointer symbol, pointer value);
7932 pointer (*cons)(scheme *sc, pointer a, pointer b);
7933 pointer (*immutable_cons)(scheme *sc, pointer a, pointer b);
7934 pointer (*reserve_cells)(scheme *sc, int n);
7935 pointer (*mk_integer)(scheme *sc, long num);
7936 pointer (*mk_real)(scheme *sc, double num);
7937 pointer (*mk_symbol)(scheme *sc, const char *name);
7938 pointer (*gensym)(scheme *sc);
7939 pointer (*mk_string)(scheme *sc, const char *str);
7940 pointer (*mk_counted_string)(scheme *sc, const char *str, int len);
7941 pointer (*mk_character)(scheme *sc, int c);
7942 pointer (*mk_vector)(scheme *sc, int len);
7943 pointer (*mk_foreign_func)(scheme *sc, foreign_func f);
7944 void (*putstr)(scheme *sc, const char *s);
7945 void (*putcharacter)(scheme *sc, int c);
7946
7947 int (*is_string)(pointer p);
7948 char *(*string_value)(pointer p);
7949 int (*is_number)(pointer p);
7950 num (*nvalue)(pointer p);
7951 long (*ivalue)(pointer p);
7952 double (*rvalue)(pointer p);
7953 int (*is_integer)(pointer p);
7954 int (*is_real)(pointer p);
7955 int (*is_character)(pointer p);
7956 long (*charvalue)(pointer p);
7957 int (*is_list)(scheme *sc, pointer p);
7958 int (*is_vector)(pointer p);
7959 int (*list_length)(scheme *sc, pointer vec);
7960 long (*vector_length)(pointer vec);
7961 void (*fill_vector)(pointer vec, pointer elem);
7962 pointer (*vector_elem)(pointer vec, int ielem);
7963 pointer (*set_vector_elem)(pointer vec, int ielem, pointer newel);
7964 int (*is_port)(pointer p);
7965
7966 int (*is_pair)(pointer p);
7967 pointer (*pair_car)(pointer p);
7968 pointer (*pair_cdr)(pointer p);
7969 pointer (*set_car)(pointer p, pointer q);
7970 pointer (*set_cdr)(pointer p, pointer q);
7971
7972 int (*is_symbol)(pointer p);
7973 char *(*symname)(pointer p);
7974
7975 int (*is_syntax)(pointer p);
7976 int (*is_proc)(pointer p);
7977 int (*is_foreign)(pointer p);
7978 char *(*syntaxname)(pointer p);
7979 int (*is_closure)(pointer p);
7980 int (*is_macro)(pointer p);
7981 pointer (*closure_code)(pointer p);
7982 pointer (*closure_env)(pointer p);
7983
7984 int (*is_continuation)(pointer p);
7985 int (*is_promise)(pointer p);
7986 int (*is_environment)(pointer p);
7987 int (*is_immutable)(pointer p);
7988 void (*setimmutable)(pointer p);
7989 void (*load_file)(scheme *sc, FILE *fin);
7990 void (*load_string)(scheme *sc, const char *input);
7991 };
7992 #endif
7993
7994 #if !STANDALONE
7995 typedef struct scheme_registerable
7996 {
7997 foreign_func f;
7998 const char * name;
7999 }
8000 scheme_registerable;
8001
8002 void scheme_register_foreign_func_list(scheme * sc,
8003 scheme_registerable * list,
8004 int n);
8005
8006 #endif /* !STANDALONE */
8007
8008 #ifdef __cplusplus
8009 }
8010 #endif
8011
8012 #endif
8013
8014
8015 /*
8016 Local variables:
8017 c-file-style: "k&r"
8018 End:
8019 */