From 86c8dc1f92cb4e0a730812d5944667aefca0cb2f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 5 Jan 2008 14:54:50 -0800 Subject: [PATCH] Synthesize new properties for class cross-referencing and SocketWrapper now init's with a DebuggerConnection * Source/DebuggerConnection.h: New property for the DebuggerWindowController * Source/DebuggerConnection.m: Synthesize new property and changed SocketWrapper's initializer * Source/DebuggerWindowController.h: New property for DebuggerConnection * Source/DebuggerWindowController.m: ditto * Source/SocketWrapper.h: The init method now takes a DebuggerConnection (and stores it) instead of a port * Source/SocketWrapper.m: ditto --- Source/DebuggerConnection.h | 1 + Source/DebuggerConnection.m | 4 ++-- Source/DebuggerWindowController.h | 2 ++ Source/DebuggerWindowController.m | 2 ++ Source/SocketWrapper.h | 6 +++++- Source/SocketWrapper.m | 5 +++-- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Source/DebuggerConnection.h b/Source/DebuggerConnection.h index 78baced..7a20be6 100644 --- a/Source/DebuggerConnection.h +++ b/Source/DebuggerConnection.h @@ -32,6 +32,7 @@ } @property(readonly) SocketWrapper *socket; +@property(readonly) DebuggerWindowController *windowController; // initializer - (id)initWithWindowController:(DebuggerWindowController *)wc port:(int)aPort session:(NSString *)aSession; diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index d264835..f267a8a 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -25,7 +25,7 @@ @implementation DebuggerConnection -@synthesize socket; +@synthesize socket, windowController; /** * Creates a new DebuggerConnection and initializes the socket from the given connection @@ -42,7 +42,7 @@ windowController = wc; // now that we have our host information, open the socket - socket = [[SocketWrapper alloc] initWithPort:port]; + socket = [[SocketWrapper alloc] initWithConnection:self]; [socket setDelegate:self]; [socket connect]; } diff --git a/Source/DebuggerWindowController.h b/Source/DebuggerWindowController.h index 09a7438..524fc5c 100644 --- a/Source/DebuggerWindowController.h +++ b/Source/DebuggerWindowController.h @@ -42,6 +42,8 @@ IBOutlet NSButton *reconnectButton; } +@property(readonly) DebuggerConnection *connection; + - (id)initWithPort:(int)aPort session:(NSString *)aSession; - (void)setStatus:(NSString *)aStatus; diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index e443136..87b4292 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -27,6 +27,8 @@ @implementation DebuggerWindowController +@synthesize connection; + /** * Initializes the window controller and sets the connection */ diff --git a/Source/SocketWrapper.h b/Source/SocketWrapper.h index 9e58d48..750e00b 100644 --- a/Source/SocketWrapper.h +++ b/Source/SocketWrapper.h @@ -16,15 +16,19 @@ #import +@class DebuggerConnection; + @interface SocketWrapper : NSObject { + DebuggerConnection *connection; + int port; int sock; id delegate; } -- (id)initWithPort:(int)aPort; +- (id)initWithConnection:(DebuggerConnection *)cnx; - (id)delegate; - (void)setDelegate:(id)aDelegate; diff --git a/Source/SocketWrapper.m b/Source/SocketWrapper.m index d0c0d64..0ae14e8 100644 --- a/Source/SocketWrapper.m +++ b/Source/SocketWrapper.m @@ -41,11 +41,12 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; /** * Initializes the socket wrapper with a host and port */ -- (id)initWithPort:(int)aPort +- (id)initWithConnection:(DebuggerConnection *)cnx { if (self = [super init]) { - port = aPort; + connection = cnx; + port = [connection port]; // the delegate notifications work funky because of threads. we register ourselves as the // observer and then pass up the messages that are actually from this object (as we can't only observe self due to threads) -- 2.43.5