From 5afdd34ed00ed1de76b90a884e5b04bd699dc0af Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Thu, 28 Aug 2008 14:31:01 +0200 Subject: Listener: Add output stream stubs. --- MLKListenerController.h | 11 +++++++++++ MLKListenerController.m | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/MLKListenerController.h b/MLKListenerController.h index d9714dd..a5a7a4b 100644 --- a/MLKListenerController.h +++ b/MLKListenerController.h @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +#import "MLKStream.h" + #import @interface MLKListenerController : NSObject @@ -25,6 +27,15 @@ IBOutlet id outputTextView; IBOutlet id statusText; IBOutlet id submitButton; + + MLKStream *lispStream; + NSOutputStream *ostream; } + +- (id)init; +- (void)dealloc; + +- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)event; + - (IBAction)submit:(id)sender; @end diff --git a/MLKListenerController.m b/MLKListenerController.m index 4e238a7..696b08f 100644 --- a/MLKListenerController.m +++ b/MLKListenerController.m @@ -24,6 +24,27 @@ #import "util.h" @implementation MLKListenerController +- (id)init +{ + self = [super init]; + + ostream = [[NSOutputStream alloc] initToMemory]; + lispStream = [[MLKStream alloc] initWithOutputStream:ostream]; + [ostream setDelegate:self]; + [ostream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [ostream open]; + + return self; +} + +- (void)dealloc +{ + [ostream close]; + LDESTROY (ostream); + LDESTROY (lispStream); + [super dealloc]; +} + - (IBAction)submit:(id)sender { id object; @@ -101,4 +122,9 @@ [submitButton setEnabled:YES]; } + +- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)event +{ + NSLog (@"Heya!"); +} @end -- cgit v1.2.3