* rework export svg/pdf/ps functionality to export images with 1:1 scale. Previously...
[geda-gerbv.git] / src / scheme-private.h
blob67ec9ad06bd3f97770ebbf0abb4f54caf22d3808
1 /* scheme-private.h */
3 /** \file scheme-private.h
4 \brief Private data for the TinyScheme compiler
5 \ingroup gerbv
6 */
8 #ifndef _SCHEME_PRIVATE_H
9 #define _SCHEME_PRIVATE_H
11 #include "scheme.h"
13 enum scheme_port_kind {
14 port_free=0,
15 port_file=1,
16 port_string=2,
17 port_input=16,
18 port_output=32
21 typedef struct port {
22 unsigned char kind;
23 union {
24 struct {
25 FILE *file;
26 int closeit;
27 } stdio;
28 struct {
29 char *start;
30 char *past_the_end;
31 char *curr;
32 } string;
33 } rep;
34 } port;
36 /* cell structure */
37 struct cell {
38 unsigned int _flag;
39 union {
40 struct {
41 char *_svalue;
42 int _length;
43 } _string;
44 num _number;
45 port *_port;
46 foreign_func _ff;
47 struct {
48 struct cell *_car;
49 struct cell *_cdr;
50 } _cons;
51 } _object;
54 struct scheme {
55 /* arrays for segments */
56 func_alloc malloc;
57 func_dealloc free;
59 /* return code */
60 int retcode;
61 int tracing;
63 #define CELL_SEGSIZE 5000 /* # of cells in one segment */
64 #define CELL_NSEGMENT 10 /* # of segments for cells */
65 char *alloc_seg[CELL_NSEGMENT];
66 pointer cell_seg[CELL_NSEGMENT];
67 int last_cell_seg;
69 /* We use 4 registers. */
70 pointer args; /* register for arguments of function */
71 pointer envir; /* stack register for current environment */
72 pointer code; /* register for current code */
73 pointer dump; /* stack register for next evaluation */
75 int interactive_repl; /* are we in an interactive REPL? */
77 struct cell _sink;
78 pointer sink; /* when mem. alloc. fails */
79 struct cell _NIL;
80 pointer NIL; /* special cell representing empty cell */
81 struct cell _HASHT;
82 pointer T; /* special cell representing #t */
83 struct cell _HASHF;
84 pointer F; /* special cell representing #f */
85 struct cell _EOF_OBJ;
86 pointer EOF_OBJ; /* special cell representing end-of-file object */
87 pointer oblist; /* pointer to symbol table */
88 pointer global_env; /* pointer to global environment */
90 /* global pointers to special symbols */
91 pointer LAMBDA; /* pointer to syntax lambda */
92 pointer QUOTE; /* pointer to syntax quote */
94 pointer QQUOTE; /* pointer to symbol quasiquote */
95 pointer UNQUOTE; /* pointer to symbol unquote */
96 pointer UNQUOTESP; /* pointer to symbol unquote-splicing */
97 pointer FEED_TO; /* => */
98 pointer COLON_HOOK; /* *colon-hook* */
99 pointer ERROR_HOOK; /* *error-hook* */
100 pointer SHARP_HOOK; /* *sharp-hook* */
102 pointer free_cell; /* pointer to top of free cells */
103 long fcells; /* # of free cells */
105 pointer inport;
106 pointer outport;
107 pointer save_inport;
108 pointer loadport;
110 #define MAXFIL 64
111 port load_stack[MAXFIL]; /* Stack of open files for port -1 (LOADing) */
112 int nesting_stack[MAXFIL];
113 int file_i;
114 int nesting;
116 char gc_verbose; /* if gc_verbose is not zero, print gc status */
117 char no_memory; /* Whether mem. alloc. has failed */
119 #define LINESIZE 1024
120 char linebuff[LINESIZE];
121 char strbuff[256];
123 FILE *tmpfp;
124 int tok;
125 int print_flag;
126 pointer value;
127 int op;
129 void *ext_data; /* For the benefit of foreign functions */
130 long gensym_cnt;
132 struct scheme_interface *vptr;
133 void *dump_base; /* pointer to base of allocated dump stack */
134 int dump_size; /* number of frames allocated for dump stack */
137 /* operator code */
138 enum scheme_opcodes {
139 #define _OP_DEF(A,B,C,D,E,OP) OP,
140 #include "opdefines.h"
141 OP_MAXDEFINED
145 #define cons(sc,a,b) _cons(sc,a,b,0)
146 #define immutable_cons(sc,a,b) _cons(sc,a,b,1)
148 int is_string(pointer p);
149 char *string_value(pointer p);
150 int is_number(pointer p);
151 num nvalue(pointer p);
152 long ivalue(pointer p);
153 double rvalue(pointer p);
154 int is_integer(pointer p);
155 int is_real(pointer p);
156 int is_character(pointer p);
157 long charvalue(pointer p);
158 int is_vector(pointer p);
160 int is_port(pointer p);
162 int is_pair(pointer p);
163 pointer pair_car(pointer p);
164 pointer pair_cdr(pointer p);
165 pointer set_car(pointer p, pointer q);
166 pointer set_cdr(pointer p, pointer q);
168 int is_symbol(pointer p);
169 char *symname(pointer p);
170 int hasprop(pointer p);
172 int is_syntax(pointer p);
173 int is_proc(pointer p);
174 int is_foreign(pointer p);
175 char *syntaxname(pointer p);
176 int is_closure(pointer p);
177 #ifdef USE_MACRO
178 int is_macro(pointer p);
179 #endif
180 pointer closure_code(pointer p);
181 pointer closure_env(pointer p);
183 int is_continuation(pointer p);
184 int is_promise(pointer p);
185 int is_environment(pointer p);
186 int is_immutable(pointer p);
187 void setimmutable(pointer p);
189 #endif