gscheme/VScheme.h

141 lines
2.4 KiB
C
Raw Permalink Normal View History

2022-08-05 05:28:40 -04:00
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import "SchemeTypes.h"
#import "Primitive.h"
#define GSCHEME @"GScheme by Marko Riedel, mriedel@neuearbeit.de\n"
typedef enum {
2022-08-05 05:28:41 -04:00
MODE_INTERACTIVE = 0,
2022-08-05 05:28:40 -04:00
MODE_EVALUATE,
MODE_LOAD
} PROCESS_MODE;
typedef enum {
2022-08-05 05:28:41 -04:00
DRAW_MOVE = 0,
2022-08-05 05:28:40 -04:00
DRAW_LINE,
2022-08-05 05:28:41 -04:00
DRAW_COLOR,
DRAW_CIRCLE,
FILL_CIRCLE,
DRAW_RECT,
FILL_RECT,
DRAW_FONT,
DRAW_STRING
2022-08-05 05:28:40 -04:00
} DRAW_INST;
typedef struct _DrawInst {
DRAW_INST what;
union {
NSPoint coord;
float color[3];
2022-08-05 05:28:41 -04:00
float radius;
NSFont *font;
NSString *string;
NSSize size;
2022-08-05 05:28:40 -04:00
} data;
} DrawInst;
@interface VScheme : NSObject
{
2022-08-05 05:28:41 -04:00
int errpos;
2022-08-05 05:28:40 -04:00
BOOL errflag;
NSString *errmsg;
NSMutableArray *codeStack;
NSMutableArray *pcStack;
NSMutableArray *argStack;
NSMutableArray *envStack;
2022-08-05 05:28:41 -04:00
id *curcodes;
2022-08-05 05:28:40 -04:00
int curpc;
2022-08-05 05:28:41 -04:00
int curlength;
2022-08-05 05:28:40 -04:00
2022-08-05 05:28:41 -04:00
BOOL hadOutput;
NSMutableString *output;
2022-08-05 05:28:40 -04:00
int maxcode, maxpc, maxarg, maxenv;
id delegate;
BOOL atImgStart;
NSPoint imgMin, imgMax;
2022-08-05 05:28:41 -04:00
NSPoint imgCur;
2022-08-05 05:28:40 -04:00
NSMutableArray *imgCodes;
2022-08-05 05:28:41 -04:00
NSFont *imgFont;
2022-08-05 05:28:40 -04:00
2022-08-05 05:28:41 -04:00
BOOL interrupted;
2022-08-05 05:28:40 -04:00
}
+ (NSString *)valToString:(id)item seen:(NSMutableSet *)mem;
+ (NSString *)valToString:(id)item;
+ printInstr:(Triple *)instr;
2022-08-05 05:28:41 -04:00
+ printCodes:(ByteCodes *)codes;
2022-08-05 05:28:40 -04:00
- init;
- delegate;
- setDelegate:(id)aDelegate;
- makeStartEnvironment;
- (int)maxcode;
- (int)maxpc;
- (int)maxarg;
- (int)maxenv;
- resetStacks;
- reset:(id)sender;
- appendToOutput:(NSString *)data;
- (NSString *)output;
- clearOutput;
2022-08-05 05:28:41 -04:00
- (NSSize)stringAtCurrentFont:(NSString *)str;
2022-08-05 05:28:40 -04:00
- recordImgInst:(DrawInst)inst;
- clearImage;
- produceImage;
- (NSMutableArray *)argStack;
- (NSMutableArray *)envStack;
- (NSMutableArray *)codeStack;
- (BOOL)errflag;
2022-08-05 05:28:41 -04:00
- (int)errpos;
2022-08-05 05:28:40 -04:00
- (NSString *)errmsg;
- args2list:(int)lower;
2022-08-05 05:28:41 -04:00
- pushByteCodes:(ByteCodes *)bcodes;
- interrupt:(id)sender;
- (BOOL)run:(ByteCodes *)prog mode:(PROCESS_MODE)pmode;
2022-08-05 05:28:40 -04:00
- special:(id)data output:(ByteCodes *)codes popenv:(int)ec;
- sequence:(id)data output:(ByteCodes *)codes popenv:(int)ec;
- compile:(id)data output:(ByteCodes *)codes popenv:(int)ec;
- (BOOL)compile:(id)data output:(ByteCodes *)codes;
2022-08-05 05:28:41 -04:00
- parse:(NSString *)scmText;
2022-08-05 05:28:40 -04:00
- (BOOL)processString:(NSString *)data mode:(PROCESS_MODE)pmode;
@end
@interface SCMImageView : NSView
{
NSImage *image;
}
- (id)initWithFrame:(NSRect)frameRect;
- (NSImage *)image;
- setImage:(NSImage *)anImage;
- (void)drawRect:(NSRect)aRect;
@end