/* * µscheme * * Copyright (C) 2015 Marc Alexander Lehmann * do as you want with this, attribution appreciated. */ /* SCHEME.H */ #ifndef SCHEME_H #define SCHEME_H #include #include #ifdef __cplusplus extern "C" { #endif /* * Default values for #define'd symbols */ #ifndef STANDALONE /* If used as standalone interpreter */ # define STANDALONE 1 #endif #define SCHEME_EXPORT static #if USE_NO_FEATURES # define USE_MULTIPLICITY 0 # define USE_MATH 0 # define USE_CHAR_CLASSIFIERS 0 # define USE_ASCII_NAMES 0 # define USE_PORTS 1 # define USE_STRING_PORTS 0 # define USE_ERROR_HOOK 0 # define USE_TRACING 0 # define USE_COLON_HOOK 0 # define USE_DL 0 # define USE_PLIST 0 # define USE_REAL 0 # define USE_ERROR_CHECKING 0 # define USE_PRINTF 0 #endif /* * Define: much slower, but somewhat smaller evaluation stack implemention, use more memory * Undefined: faster, somewhat bigger implementation, uses less memory at runtime */ /*#define USE_SCHEME_STACK*/ #ifndef USE_MULTIPLICITY # define USE_MULTIPLICITY 1 #endif #ifndef USE_REAL # define USE_REAL 1 #endif #ifndef USE_MATH /* If math support is needed */ # define USE_MATH 1 #endif #ifndef USE_CHAR_CLASSIFIERS /* If char classifiers are needed */ # define USE_CHAR_CLASSIFIERS 1 #endif #ifndef USE_ASCII_NAMES /* If extended escaped characters are needed */ # define USE_ASCII_NAMES 1 #endif #ifndef USE_PORTS /* Enable ports */ # define USE_PORTS 1 #endif #ifndef USE_STRING_PORTS /* Enable string ports */ # define USE_STRING_PORTS USE_PORTS #endif #ifndef USE_TRACING # define USE_TRACING 1 #endif #ifndef USE_PLIST # define USE_PLIST 0 #endif /* To force system errors through user-defined error handling (see *error-hook*) */ #ifndef USE_ERROR_HOOK # define USE_ERROR_HOOK 1 #endif #ifndef USE_COLON_HOOK /* Enable qualified qualifier */ # define USE_COLON_HOOK 1 #endif #ifndef USE_ERROR_CHECKING # define USE_ERROR_CHECKING 1 #endif #ifndef USE_PRINTF # define USE_PRINTF 1 #endif #ifndef USE_IGNORECASE # define USE_IGNORECASE 1 #endif #ifndef SHOW_ERROR_LINE /* Show error line in file */ # define SHOW_ERROR_LINE 1 #endif #if !USE_REAL # undef USE_MATH # define USE_MATH 0 #endif #if USE_MULTIPLICITY # define SCHEME_V sc # define SCHEME_P scheme *SCHEME_V # define SCHEME_P_ SCHEME_P, # define SCHEME_A SCHEME_V # define SCHEME_A_ SCHEME_A, #else # define SCHEME_V (&sc) # define SCHEME_P # define SCHEME_P_ # define SCHEME_A # define SCHEME_A_ #endif typedef struct scheme scheme; typedef struct cell *pointer; typedef long IVALUE; /* this is not used consistently yet */ #if USE_REAL typedef double RVALUE; #else typedef long RVALUE; #endif /* Used for documentation purposes, to signal functions in 'interface' */ #define INTERFACE static SCHEME_EXPORT scheme *scheme_init_new (); SCHEME_EXPORT int scheme_init (SCHEME_P); SCHEME_EXPORT void scheme_deinit (SCHEME_P); void scheme_set_input_port_file (SCHEME_P_ int fin); void scheme_set_input_port_string (SCHEME_P_ char *start, char *past_the_end); SCHEME_EXPORT void scheme_set_output_port_file (SCHEME_P_ int fin); void scheme_set_output_port_string (SCHEME_P_ char *start, char *past_the_end); SCHEME_EXPORT void scheme_load_file (SCHEME_P_ int fin); SCHEME_EXPORT void scheme_load_named_file (SCHEME_P_ int fin, const char *filename); SCHEME_EXPORT void scheme_load_string (SCHEME_P_ const char *cmd); SCHEME_EXPORT pointer scheme_apply0 (SCHEME_P_ const char *procname); SCHEME_EXPORT pointer scheme_call (SCHEME_P_ pointer func, pointer args); SCHEME_EXPORT pointer scheme_eval (SCHEME_P_ pointer obj); void scheme_set_external_data (SCHEME_P_ void *p); SCHEME_EXPORT void scheme_define (SCHEME_P_ pointer env, pointer symbol, pointer value); typedef pointer (*foreign_func) (SCHEME_P_ pointer); pointer xcons (SCHEME_P_ pointer a, pointer b, int immutable); INTERFACE pointer mk_integer (SCHEME_P_ IVALUE n); INTERFACE pointer mk_real (SCHEME_P_ RVALUE n); INTERFACE pointer mk_symbol (SCHEME_P_ const char *name); INTERFACE pointer gensym (SCHEME_P); INTERFACE pointer mk_string (SCHEME_P_ const char *str); INTERFACE pointer mk_counted_string (SCHEME_P_ const char *str, uint32_t len); INTERFACE pointer mk_empty_string (SCHEME_P_ uint32_t len, char fill); INTERFACE pointer mk_character (SCHEME_P_ int c); INTERFACE pointer mk_foreign_func (SCHEME_P_ foreign_func f); INTERFACE void putstr (SCHEME_P_ const char *s); INTERFACE int list_length (SCHEME_P_ pointer a); INTERFACE int eqv (pointer a, pointer b); #if !STANDALONE typedef struct scheme_registerable { foreign_func f; const char *name; } scheme_registerable; void scheme_register_foreign_func_list (SCHEME_P_ scheme_registerable * list, int n); #endif /* !STANDALONE */ #ifdef __cplusplus } #endif #endif /* Local variables: c-file-style: "k&r" End: */