1 /* Copyright (c) 2005, David Leonard. All rights reserved. */ 2 3 #ifndef _SEE_h_system_ 4 #define _SEE_h_system_ 5 6 struct SEE_interpreter; 7 struct SEE_throw_location; 8 struct SEE_context; 9 struct SEE_code; 10 struct SEE_value; 11 struct SEE_regex_engine; 12 13 #include <see/interpreter.h> /* for enum SEE_trace_event */ 14 #include <see/type.h> 15 16 struct SEE_system { 17 18 /* Interpreter field defaults */ 19 const char *default_locale; /* default: NULL */ 20 int default_recursion_limit; /* default: -1 (no limit) */ 21 void (*default_trace)(struct SEE_interpreter *, 22 struct SEE_throw_location *, 23 struct SEE_context *, 24 enum SEE_trace_event); /* default: NULL */ 25 int default_compat_flags; 26 27 unsigned int (*random_seed)(void); 28 29 /* Fatal error handler */ 30 void (*abort)(struct SEE_interpreter *, 31 const char *) SEE_dead; 32 33 /* Periodic execution callback */ 34 void (*periodic)(struct SEE_interpreter *); 35 36 /* Memory allocator */ 37 void *(*malloc)(struct SEE_interpreter *, SEE_size_t, 38 const char *, int); 39 void *(*malloc_finalize)(struct SEE_interpreter *, SEE_size_t, 40 void (*)(struct SEE_interpreter *, void *, void *), void *, 41 const char *, int); 42 void *(*malloc_string)(struct SEE_interpreter *, SEE_size_t, 43 const char *, int); 44 45 void (*free)(struct SEE_interpreter *, void *, 46 const char *, int); 47 void (*mem_exhausted)(struct SEE_interpreter *) SEE_dead; 48 void (*gcollect)(struct SEE_interpreter *); 49 50 /* Security domain tracking */ 51 void *(*transit_sec_domain)(struct SEE_interpreter *, void *); 52 53 /* Bytecode backend */ 54 struct SEE_code *(*code_alloc)(struct SEE_interpreter *); 55 56 /* Host object constructor hook. Called for 'new Object(o)'. */ 57 void (*object_construct)(struct SEE_interpreter *interp, 58 struct SEE_object *self, struct SEE_object *thisobj, 59 int argc, struct SEE_value **argv, struct SEE_value *res); 60 61 /* Default regex engine to use (experimental) */ 62 const struct SEE_regex_engine *default_regex_engine; 63 }; 64 65 extern struct SEE_system SEE_system; 66 67 void SEE_init(void); /* no-op; reserved for API 3.0 */ 68 69 #define SEE_ABORT(interp, msg) (*SEE_system.abort)(interp, msg) 70 71 /* The following two functions are experimental and may change */ 72 const char **SEE_regex_engine_list(void); 73 const struct SEE_regex_engine *SEE_regex_engine(const char *name); 74 75 #endif /* _SEE_h_system_ */ 76