From eb19d0405f2fdbc17dda6a6677428c6c6453c0e6 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 4 Aug 2007 02:14:05 -0700 Subject: [PATCH] Cleaning up our use of private methods: Moving all private methods into class categories in the .m file, and removing the _ prefix as it is "reserved" for Apple (according to their guidelines). --- Source/DebuggerConnection.h | 3 --- Source/DebuggerConnection.m | 20 +++++++++++++------- Source/SocketWrapper.h | 5 ----- Source/SocketWrapper.m | 20 ++++++++++++++------ 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Source/DebuggerConnection.h b/Source/DebuggerConnection.h index 68fac53..10b6cad 100644 --- a/Source/DebuggerConnection.h +++ b/Source/DebuggerConnection.h @@ -45,7 +45,4 @@ - (void)refreshStatus; - (void)updateStackTraceAndRegisters; -// ================= internal private -- (NSString *)_createCommand: (NSString *)cmd; - @end diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index f5ce9ba..be8f377 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -16,6 +16,12 @@ #import "DebuggerConnection.h" +@interface DebuggerConnection (Private) + +- (NSString *)createCommand: (NSString *)cmd; + +@end + @implementation DebuggerConnection /** @@ -123,7 +129,7 @@ - (void)socketDidAccept { _connected = YES; - [_socket receive: @selector(_handshake:)]; + [_socket receive: @selector(handshake:)]; } /** @@ -138,7 +144,7 @@ * The initial packet handshake. This allows us to set things like the title of the window * and glean information about hte server we are debugging */ -- (void)_handshake: (NSData *)packet +- (void)handshake: (NSData *)packet { [self refreshStatus]; } @@ -147,7 +153,7 @@ * Handler used by dataReceived:deliverTo: for anytime the status command is issued. It sets * the window controller's status text */ -- (void)_updateStatus: (NSData *)packet +- (void)updateStatus: (NSData *)packet { NSXMLDocument *doc = [[NSXMLDocument alloc] initWithData: packet options: NSXMLDocumentTidyXML error: nil]; [_windowController setStatus: [[[[doc rootElement] attributeForName: @"status"] stringValue] capitalizedString]]; @@ -170,7 +176,7 @@ - (void)refreshStatus { [_socket send: [self _createCommand: @"status"]]; - [_socket receive: @selector(_updateStatus:)]; + [_socket receive: @selector(updateStatus:)]; } /** @@ -213,14 +219,14 @@ - (void)updateStackTraceAndRegisters { [_socket send: [self _createCommand: @"stack_get"]]; - [_socket receive: @selector(_stackReceived:)]; + [_socket receive: @selector(stackReceived:)]; } /** * Called by the dataReceived delivery delegate. This updates the window controller's data * for the stack trace */ -- (void)_stackReceived: (NSData *)packet +- (void)stackReceived: (NSData *)packet { NSXMLDocument *doc = [[NSXMLDocument alloc] initWithData: packet options: NSXMLDocumentTidyXML error: nil]; NSArray *children = [[doc rootElement] children]; @@ -242,7 +248,7 @@ /** * Helper method to create a string command with the -i automatically tacked on */ -- (NSString *)_createCommand: (NSString *)cmd +- (NSString *)createCommand: (NSString *)cmd { return [NSString stringWithFormat: @"%@ -i %@", cmd, _session]; } diff --git a/Source/SocketWrapper.h b/Source/SocketWrapper.h index 0dd5ddd..da3a8e7 100644 --- a/Source/SocketWrapper.h +++ b/Source/SocketWrapper.h @@ -35,11 +35,6 @@ - (NSString *)remoteHost; -// ============== internal functions for threading -- (void)_connect: (id)obj; -- (void)_postNotification: (NSString *)name withObject: (id)obj; -- (void)_postNotification: (NSString *)name withObject: (id)obj withDict: (NSMutableDictionary *)dict; - @end @interface NSObject (SocketWrapperDelegate) diff --git a/Source/SocketWrapper.m b/Source/SocketWrapper.m index c6f03ad..fba7b96 100644 --- a/Source/SocketWrapper.m +++ b/Source/SocketWrapper.m @@ -28,6 +28,14 @@ NSString *NsockDidAccept = @"SocketWrapper_DidAccept"; NSString *NsockDataReceived = @"SocketWrapper_DataReceived"; NSString *NsockDataSent = @"SocketWrapper_DataSent"; +@interface SocketWrapper (Private) + +- (void)connect: (id)obj; +- (void)postNotification: (NSString *)name withObject: (id)obj; +- (void)postNotification: (NSString *)name withObject: (id)obj withDict: (NSMutableDictionary *)dict; + +@end + @implementation SocketWrapper /** @@ -42,7 +50,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; // 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) // to our delegate, and not to all delegates - [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_sendMessageToDelegate:) name: nil object: nil]; + [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(sendMessageToDelegate:) name: nil object: nil]; } return self; } @@ -97,7 +105,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; * then the notification was sent from the same object in another thread and it passes the message along to the object's * delegate. Complicated enough? */ -- (void)_sendMessageToDelegate: (NSNotification *)notif +- (void)sendMessageToDelegate: (NSNotification *)notif { // this isn't us, so there's no point in continuing if ([[notif userInfo] objectForKey: sockNotificationDebuggerConnection] != _delegate) @@ -131,13 +139,13 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; */ - (void)connect { - [NSThread detachNewThreadSelector: @selector(_connect:) toTarget: self withObject: nil]; + [NSThread detachNewThreadSelector: @selector(connect:) toTarget: self withObject: nil]; } /** * This does the actual dirty work (in a separate thread) of connecting to a socket */ -- (void)_connect: (id)obj +- (void)connect: (id)obj { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -284,7 +292,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; /** * Helper method to simply post a notification to the default notification center with a given name and object */ -- (void)_postNotification: (NSString *)name withObject: (id)obj +- (void)postNotification: (NSString *)name withObject: (id)obj { [self _postNotification: name withObject: obj withDict: [NSMutableDictionary dictionary]]; } @@ -293,7 +301,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; * Another helper method to aid in the posting of notifications. This one should be used if you have additional * things for the userInfo. This automatically adds the sockNotificationDebuggerConnection key. */ -- (void)_postNotification: (NSString *)name withObject: (id)obj withDict: (NSMutableDictionary *)dict +- (void)postNotification: (NSString *)name withObject: (id)obj withDict: (NSMutableDictionary *)dict { [dict setValue: _delegate forKey: sockNotificationDebuggerConnection]; [[NSNotificationCenter defaultCenter] postNotificationName: name object: obj userInfo: dict]; -- 2.22.5