1 #import <Foundation/Foundation.h>
2 #import <AppKit/AppKit.h>
3 
4 #import "SchemeTypes.h"
5 #import "Primitive.h"
6 
7 #define GSCHEME @"GScheme by Marko Riedel, mriedel@neuearbeit.de\n"
8 
9 typedef enum {
10     MODE_INTERACTIVE = 0,
11     MODE_EVALUATE,
12     MODE_LOAD
13 } PROCESS_MODE;
14 
15 typedef enum {
16     DRAW_MOVE = 0,
17     DRAW_LINE,
18     DRAW_COLOR,
19     DRAW_CIRCLE,
20     FILL_CIRCLE,
21     DRAW_RECT,
22     FILL_RECT,
23     DRAW_FONT,
24     DRAW_STRING
25 } DRAW_INST;
26 
27 typedef struct _DrawInst {
28     DRAW_INST what;
29     union {
30         NSPoint coord;
31         float color[3];
32 	float radius;
33 	NSFont *font;
34 	NSString *string;
35 	NSSize size;
36     } data;
37 } DrawInst;
38 
39 @interface VScheme : NSObject
40 {
41     int errpos;
42     BOOL errflag;
43     NSString *errmsg;
44 
45     NSMutableArray *codeStack;
46     NSMutableArray *pcStack;
47     NSMutableArray *argStack;
48     NSMutableArray *envStack;
49 
50     id *curcodes;
51     int curpc;
52     int curlength;
53 
54     BOOL hadOutput;
55     NSMutableString *output;
56 
57     int maxcode, maxpc, maxarg, maxenv;
58 
59     id delegate;
60 
61     BOOL atImgStart;
62     NSPoint imgMin, imgMax;
63     NSPoint imgCur;
64     NSMutableArray *imgCodes;
65     NSFont *imgFont;
66 
67     BOOL interrupted;
68 }
69 
70 + (NSString *)valToString:(id)item seen:(NSMutableSet *)mem;
71 + (NSString *)valToString:(id)item;
72 
73 + printInstr:(Triple *)instr;
74 + printCodes:(ByteCodes *)codes;
75 
76 - init;
77 
78 - delegate;
79 - setDelegate:(id)aDelegate;
80 
81 - makeStartEnvironment;
82 
83 - (int)maxcode;
84 - (int)maxpc;
85 - (int)maxarg;
86 - (int)maxenv;
87 
88 - resetStacks;
89 - reset:(id)sender;
90 
91 - appendToOutput:(NSString *)data;
92 - (NSString *)output;
93 - clearOutput;
94 
95 - (NSSize)stringAtCurrentFont:(NSString *)str;
96 - recordImgInst:(DrawInst)inst;
97 - clearImage;
98 - produceImage;
99 
100 - (NSMutableArray *)argStack;
101 - (NSMutableArray *)envStack;
102 - (NSMutableArray *)codeStack;
103 
104 - (BOOL)errflag;
105 - (int)errpos;
106 - (NSString *)errmsg;
107 
108 - args2list:(int)lower;
109 
110 - pushByteCodes:(ByteCodes *)bcodes;
111 
112 - interrupt:(id)sender;
113 - (BOOL)run:(ByteCodes *)prog mode:(PROCESS_MODE)pmode;
114 
115 - special:(id)data output:(ByteCodes *)codes popenv:(int)ec;
116 - sequence:(id)data output:(ByteCodes *)codes popenv:(int)ec;
117 - compile:(id)data output:(ByteCodes *)codes popenv:(int)ec;
118 
119 - (BOOL)compile:(id)data output:(ByteCodes *)codes;
120 
121 - parse:(NSString *)scmText;
122 - (BOOL)processString:(NSString *)data mode:(PROCESS_MODE)pmode;
123 
124 @end
125 
126 @interface SCMImageView : NSView
127 {
128     NSImage *image;
129 }
130 
131 - (id)initWithFrame:(NSRect)frameRect;
132 
133 - (NSImage *)image;
134 - setImage:(NSImage *)anImage;
135 
136 - (void)drawRect:(NSRect)aRect;
137 
138 @end
139 
140 
141