From 48022096ee56de046900df9d3fedafe3e650c87b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 4 Jan 2008 02:03:38 -0800 Subject: [PATCH] Removing the extra spacing after colons in function arguments --- Source/AppDelegate.h | 6 +- Source/AppDelegate.m | 18 ++-- Source/ConnectWindowController.h | 2 +- Source/ConnectWindowController.m | 20 ++--- Source/DebuggerConnection.h | 4 +- Source/DebuggerConnection.m | 102 +++++++++++----------- Source/DebuggerWindowController.h | 22 ++--- Source/DebuggerWindowController.m | 140 +++++++++++++++--------------- Source/NSXMLElementAdditions.m | 14 +-- Source/SocketWrapper.h | 14 +-- Source/SocketWrapper.m | 78 ++++++++--------- 11 files changed, 210 insertions(+), 210 deletions(-) diff --git a/Source/AppDelegate.h b/Source/AppDelegate.h index 29eafb7..9e1b352 100644 --- a/Source/AppDelegate.h +++ b/Source/AppDelegate.h @@ -23,9 +23,9 @@ } -- (void)registerConnection: (DebuggerConnection *)cnx; -- (void)unregisterConnection: (DebuggerConnection *)cnx; +- (void)registerConnection:(DebuggerConnection *)cnx; +- (void)unregisterConnection:(DebuggerConnection *)cnx; -- (IBAction)showConnectionWindow: (id)sender; +- (IBAction)showConnectionWindow:(id)sender; @end diff --git a/Source/AppDelegate.m b/Source/AppDelegate.m index 668ab00..1d1ebf2 100644 --- a/Source/AppDelegate.m +++ b/Source/AppDelegate.m @@ -34,7 +34,7 @@ /** * Called when the application is going to go away */ -- (void)applicationWillTerminate: (NSNotification *)aNotification +- (void)applicationWillTerminate:(NSNotification *)aNotification { [connections release]; } @@ -42,33 +42,33 @@ /** * When the application has finished loading, show the connection dialog */ -- (void)applicationDidFinishLaunching: (NSNotification *)notif +- (void)applicationDidFinishLaunching:(NSNotification *)notif { - [self showConnectionWindow: self]; + [self showConnectionWindow:self]; } /** * Adds an object to the connections array */ -- (void)registerConnection: (DebuggerConnection *)cnx +- (void)registerConnection:(DebuggerConnection *)cnx { - [connections addObject: cnx]; + [connections addObject:cnx]; } /** * Removes a given connection from the connections array */ -- (void)unregisterConnection: (DebuggerConnection *)cnx +- (void)unregisterConnection:(DebuggerConnection *)cnx { - [connections removeObject: cnx]; + [connections removeObject:cnx]; } /** * Shows the connection window */ -- (IBAction)showConnectionWindow: (id)sender +- (IBAction)showConnectionWindow:(id)sender { - [[[ConnectWindowController sharedController] window] makeKeyAndOrderFront: self]; + [[[ConnectWindowController sharedController] window] makeKeyAndOrderFront:self]; } @end diff --git a/Source/ConnectWindowController.h b/Source/ConnectWindowController.h index f69bce7..bbdb704 100644 --- a/Source/ConnectWindowController.h +++ b/Source/ConnectWindowController.h @@ -25,6 +25,6 @@ + (id)sharedController; -- (IBAction)connect: (id)sender; +- (IBAction)connect:(id)sender; @end diff --git a/Source/ConnectWindowController.m b/Source/ConnectWindowController.m index 872b398..4d24eef 100644 --- a/Source/ConnectWindowController.m +++ b/Source/ConnectWindowController.m @@ -28,13 +28,13 @@ static id instance = nil; if (!instance) { - instance = [[ConnectWindowController alloc] initWithWindowNibName: @"Connect"]; + instance = [[ConnectWindowController alloc] initWithWindowNibName:@"Connect"]; [instance window]; - [[NSNotificationCenter defaultCenter] addObserver: instance - selector: @selector(applicationWillTerminate:) - name: NSApplicationWillTerminateNotification - object: NSApp]; + [[NSNotificationCenter defaultCenter] addObserver:instance + selector:@selector(applicationWillTerminate:) + name:NSApplicationWillTerminateNotification + object:NSApp]; } return instance; @@ -43,7 +43,7 @@ /** * Called when the applicaion is about to terminate so we can release itself */ -- (void)applicationWillTerminate: (NSNotification *)notif +- (void)applicationWillTerminate:(NSNotification *)notif { [self release]; } @@ -51,12 +51,12 @@ /** * Creates a new DebuggerConnection object (and then completely forgets about it) and then close the window */ -- (IBAction)connect: (id)sender +- (IBAction)connect:(id)sender { - DebuggerConnection *cnx = [[DebuggerConnection alloc] initWithPort: [_port intValue] session: [_session stringValue]]; - [[NSApp delegate] registerConnection: cnx]; + DebuggerConnection *cnx = [[DebuggerConnection alloc] initWithPort:[_port intValue] session:[_session stringValue]]; + [[NSApp delegate] registerConnection:cnx]; [cnx release]; - [[self window] orderOut: self]; + [[self window] orderOut:self]; } @end diff --git a/Source/DebuggerConnection.h b/Source/DebuggerConnection.h index 1a31084..0531ce8 100644 --- a/Source/DebuggerConnection.h +++ b/Source/DebuggerConnection.h @@ -32,7 +32,7 @@ } // initializer -- (id)initWithPort: (int)port session: (NSString *)session; +- (id)initWithPort:(int)port session:(NSString *)session; - (void)windowDidClose; @@ -51,6 +51,6 @@ - (void)updateStackTraceAndRegisters; // helpers -- (void)getProperty: (NSString *)property forElement: (NSXMLElement *)elm; +- (void)getProperty:(NSString *)property forElement:(NSXMLElement *)elm; @end diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index 7b1aef7..b2d3da5 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -19,7 +19,7 @@ @interface DebuggerConnection (Private) -- (NSString *)createCommand: (NSString *)cmd; +- (NSString *)createCommand:(NSString *)cmd; @end @@ -29,7 +29,7 @@ * Creates a new DebuggerConnection and initializes the socket from the given connection * paramters. */ -- (id)initWithPort: (int)port session: (NSString *)session +- (id)initWithPort:(int)port session:(NSString *)session { if (self = [super init]) { @@ -37,13 +37,13 @@ _session = [session retain]; _connected = NO; - _windowController = [[DebuggerWindowController alloc] initWithConnection: self]; - [[_windowController window] makeKeyAndOrderFront: self]; + _windowController = [[DebuggerWindowController alloc] initWithConnection:self]; + [[_windowController window] makeKeyAndOrderFront:self]; // now that we have our host information, open the socket - _socket = [[SocketWrapper alloc] initWithPort: port]; - [_socket setDelegate: self]; - [_windowController setStatus: @"Connecting"]; + _socket = [[SocketWrapper alloc] initWithPort:port]; + [_socket setDelegate:self]; + [_windowController setStatus:@"Connecting"]; [_socket connect]; } return self; @@ -55,7 +55,7 @@ */ - (void)windowDidClose { - [[NSApp delegate] unregisterConnection: self]; + [[NSApp delegate] unregisterConnection:self]; } /** @@ -109,22 +109,22 @@ /** * SocketWrapper delegate method that is called whenever new data is received */ -- (void)dataReceived: (NSData *)response deliverTo: (SEL)selector +- (void)dataReceived:(NSData *)response deliverTo:(SEL)selector { - NSXMLDocument *doc = [[NSXMLDocument alloc] initWithData: response options: NSXMLDocumentTidyXML error: nil]; + NSXMLDocument *doc = [[NSXMLDocument alloc] initWithData:response options:NSXMLDocumentTidyXML error:nil]; // check and see if there's an error - NSArray *error = [[doc rootElement] elementsForName: @"error"]; + NSArray *error = [[doc rootElement] elementsForName:@"error"]; if ([error count] > 0) { - [_windowController setError: [[[[error objectAtIndex: 0] children] objectAtIndex: 0] stringValue]]; + [_windowController setError:[[[[error objectAtIndex:0] children] objectAtIndex:0] stringValue]]; return; } // if the caller of [_socket receive:] specified a deliverTo, just forward the message to them if (selector != nil) { - [self performSelector: selector withObject: doc]; + [self performSelector:selector withObject:doc]; } [doc release]; @@ -134,7 +134,7 @@ * SocketWrapper delegate method that is called after data is sent. This really * isn't useful for much. */ -- (void)dataSent: (NSString *)data +- (void)dataSent:(NSString *)data {} /** @@ -144,22 +144,22 @@ - (void)socketDidAccept { _connected = YES; - [_socket receive: @selector(handshake:)]; + [_socket receive:@selector(handshake:)]; } /** * Receives errors from the SocketWrapper and updates the display */ -- (void)errorEncountered: (NSError *)error +- (void)errorEncountered:(NSError *)error { - [_windowController setError: [error domain]]; + [_windowController setError:[error domain]]; } /** * 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: (NSXMLDocument *)doc +- (void)handshake:(NSXMLDocument *)doc { [self refreshStatus]; } @@ -168,12 +168,12 @@ * Handler used by dataReceived:deliverTo: for anytime the status command is issued. It sets * the window controller's status text */ -- (void)updateStatus: (NSXMLDocument *)doc +- (void)updateStatus:(NSXMLDocument *)doc { - NSString *status = [[[doc rootElement] attributeForName: @"status"] stringValue]; - [_windowController setStatus: [status capitalizedString]]; + NSString *status = [[[doc rootElement] attributeForName:@"status"] stringValue]; + [_windowController setStatus:[status capitalizedString]]; - if ([status isEqualToString: @"break"]) + if ([status isEqualToString:@"break"]) { [self updateStackTraceAndRegisters]; } @@ -184,7 +184,7 @@ */ - (void)run { - [_socket send: [self createCommand: @"run"]]; + [_socket send:[self createCommand:@"run"]]; [self refreshStatus]; } @@ -194,8 +194,8 @@ */ - (void)refreshStatus { - [_socket send: [self createCommand: @"status"]]; - [_socket receive: @selector(updateStatus:)]; + [_socket send:[self createCommand:@"status"]]; + [_socket receive:@selector(updateStatus:)]; } /** @@ -203,8 +203,8 @@ */ - (void)stepIn { - [_socket send: [self createCommand: @"step_into"]]; - [_socket receive: nil]; + [_socket send:[self createCommand:@"step_into"]]; + [_socket receive:nil]; [self refreshStatus]; } @@ -213,8 +213,8 @@ */ - (void)stepOut { - [_socket send: [self createCommand: @"step_out"]]; - [_socket receive: nil]; + [_socket send:[self createCommand:@"step_out"]]; + [_socket receive:nil]; [self refreshStatus]; } @@ -223,8 +223,8 @@ */ - (void)stepOver { - [_socket send: [self createCommand: @"step_over"]]; - [_socket receive: nil]; + [_socket send:[self createCommand:@"step_over"]]; + [_socket receive:nil]; [self refreshStatus]; } @@ -234,58 +234,58 @@ */ - (void)updateStackTraceAndRegisters { - [_socket send: [self createCommand: @"stack_get"]]; - [_socket receive: @selector(stackReceived:)]; + [_socket send:[self createCommand:@"stack_get"]]; + [_socket receive:@selector(stackReceived:)]; - [_socket send: [self createCommand: @"context_get"]]; - [_socket receive: @selector(registerReceived:)]; + [_socket send:[self createCommand:@"context_get"]]; + [_socket receive:@selector(registerReceived:)]; } /** * Called by the dataReceived delivery delegate. This updates the window controller's data * for the stack trace */ -- (void)stackReceived: (NSXMLDocument *)doc +- (void)stackReceived:(NSXMLDocument *)doc { NSArray *children = [[doc rootElement] children]; NSMutableArray *stack = [NSMutableArray array]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; for (int i = 0; i < [children count]; i++) { - NSArray *attrs = [[children objectAtIndex: i] attributes]; + NSArray *attrs = [[children objectAtIndex:i] attributes]; for (int j = 0; j < [attrs count]; j++) { - [dict setValue: [[attrs objectAtIndex: j] stringValue] forKey: [[attrs objectAtIndex: j] name]]; + [dict setValue:[[attrs objectAtIndex:j] stringValue] forKey:[[attrs objectAtIndex:j] name]]; } - [stack addObject: dict]; + [stack addObject:dict]; dict = [NSMutableDictionary dictionary]; } - [_windowController setStack: stack]; + [_windowController setStack:stack]; } /** * Called when we have a new register to display */ -- (void)registerReceived: (NSXMLDocument *)doc +- (void)registerReceived:(NSXMLDocument *)doc { - [_windowController setRegister: doc]; + [_windowController setRegister:doc]; } /** * Tells the debugger engine to get a specifc property. This also takes in the NSXMLElement * that requested it so that the child can be attached in the delivery. */ -- (void)getProperty: (NSString *)property forElement: (NSXMLElement *)elm +- (void)getProperty:(NSString *)property forElement:(NSXMLElement *)elm { - [_socket send: [self createCommand: [NSString stringWithFormat: @"property_get -n \"%@\"", property]]]; + [_socket send:[self createCommand:[NSString stringWithFormat:@"property_get -n \"%@\"", property]]]; _depthFetchElement = elm; - [_socket receive: @selector(propertyReceived:)]; + [_socket receive:@selector(propertyReceived:)]; } /** * Called when a property is received. This then adds the result as children to the passed object */ -- (void)propertyReceived: (NSXMLDocument *)doc +- (void)propertyReceived:(NSXMLDocument *)doc { /* @@ -296,19 +296,19 @@ */ // we now have to detach all the children so we can insert them into another document - NSXMLElement *parent = (NSXMLElement *)[[doc rootElement] childAtIndex: 0]; + NSXMLElement *parent = (NSXMLElement *)[[doc rootElement] childAtIndex:0]; NSArray *children = [parent children]; - [parent setChildren: nil]; - [_windowController addChildren: children toNode: _depthFetchElement]; + [parent setChildren:nil]; + [_windowController addChildren:children toNode:_depthFetchElement]; _depthFetchElement = nil; } /** * 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]; + return [NSString stringWithFormat:@"%@ -i %@", cmd, _session]; } @end diff --git a/Source/DebuggerWindowController.h b/Source/DebuggerWindowController.h index 9cef6d8..e5ee466 100644 --- a/Source/DebuggerWindowController.h +++ b/Source/DebuggerWindowController.h @@ -42,19 +42,19 @@ IBOutlet NSButton *_reconnectButton; } -- (id)initWithConnection: (DebuggerConnection *)cnx; +- (id)initWithConnection:(DebuggerConnection *)cnx; -- (void)setStatus: (NSString *)status; -- (void)setError: (NSString *)error; -- (void)setStack: (NSArray *)node; -- (void)setRegister: (NSXMLDocument *)reg; +- (void)setStatus:(NSString *)status; +- (void)setError:(NSString *)error; +- (void)setStack:(NSArray *)node; +- (void)setRegister:(NSXMLDocument *)reg; -- (void)addChildren: (NSArray *)children toNode: (id)node; +- (void)addChildren:(NSArray *)children toNode:(id)node; -- (IBAction)run: (id)sender; -- (IBAction)stepIn: (id)sender; -- (IBAction)stepOut: (id)sender; -- (IBAction)stepOver: (id)sender; -- (IBAction)reconnect: (id)sender; +- (IBAction)run:(id)sender; +- (IBAction)stepIn:(id)sender; +- (IBAction)stepOut:(id)sender; +- (IBAction)stepOver:(id)sender; +- (IBAction)reconnect:(id)sender; @end diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index d2ea2bd..38748e3 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -30,9 +30,9 @@ /** * Initializes the window controller and sets the connection */ -- (id)initWithConnection: (DebuggerConnection *)cnx +- (id)initWithConnection:(DebuggerConnection *)cnx { - if (self = [super initWithWindowNibName: @"Debugger"]) + if (self = [super initWithWindowNibName:@"Debugger"]) { _connection = cnx; _expandedRegisters = [[NSMutableArray alloc] init]; @@ -46,18 +46,18 @@ - (void)awakeFromNib { // set up the scroller for the source viewer - [_sourceViewer setMaxSize: NSMakeSize(FLT_MAX, FLT_MAX)]; - [[_sourceViewer textContainer] setContainerSize: NSMakeSize(FLT_MAX, FLT_MAX)]; - [[_sourceViewer textContainer] setWidthTracksTextView: NO]; - [_sourceViewer setHorizontallyResizable: YES]; - [_sourceViewerScroller setHasHorizontalScroller: YES]; + [_sourceViewer setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)]; + [[_sourceViewer textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)]; + [[_sourceViewer textContainer] setWidthTracksTextView:NO]; + [_sourceViewer setHorizontallyResizable:YES]; + [_sourceViewerScroller setHasHorizontalScroller:YES]; [_sourceViewerScroller display]; } /** * Called when the window is going to be closed so we can clean up all of our stuff */ -- (void)windowWillClose: (NSNotification *)aNotification +- (void)windowWillClose:(NSNotification *)aNotification { [_connection windowDidClose]; } @@ -75,46 +75,46 @@ /** * Sets the status and clears any error message */ -- (void)setStatus: (NSString *)status +- (void)setStatus:(NSString *)status { - [_error setHidden: YES]; - [_status setStringValue: status]; - [[self window] setTitle: [NSString stringWithFormat: @"GDBp @ %@:%d/%@", [_connection remoteHost], [_connection port], [_connection session]]]; + [_error setHidden:YES]; + [_status setStringValue:status]; + [[self window] setTitle:[NSString stringWithFormat:@"GDBp @ %@:%d/%@", [_connection remoteHost], [_connection port], [_connection session]]]; - [_stepInButton setEnabled: NO]; - [_stepOutButton setEnabled: NO]; - [_stepOverButton setEnabled: NO]; - [_runButton setEnabled: NO]; - [_reconnectButton setEnabled: NO]; + [_stepInButton setEnabled:NO]; + [_stepOutButton setEnabled:NO]; + [_stepOverButton setEnabled:NO]; + [_runButton setEnabled:NO]; + [_reconnectButton setEnabled:NO]; if ([_connection isConnected]) { - if ([status isEqualToString: @"Starting"]) + if ([status isEqualToString:@"Starting"]) { - [_stepInButton setEnabled: YES]; - [_runButton setEnabled: YES]; + [_stepInButton setEnabled:YES]; + [_runButton setEnabled:YES]; } } else { - [_reconnectButton setEnabled: YES]; + [_reconnectButton setEnabled:YES]; } } /** * Sets the status to be "Error" and then displays the error message */ -- (void)setError: (NSString *)error +- (void)setError:(NSString *)error { - [_error setStringValue: error]; - [self setStatus: @"Error"]; - [_error setHidden: NO]; + [_error setStringValue:error]; + [self setStatus:@"Error"]; + [_error setHidden:NO]; } /** * Sets the root node element of the stacktrace */ -- (void)setStack: (NSArray *)stack +- (void)setStack:(NSArray *)stack { if (_stack != nil) { @@ -126,11 +126,11 @@ if ([_stack count] > 1) { - [_stepOutButton setEnabled: YES]; + [_stepOutButton setEnabled:YES]; } - [_stepInButton setEnabled: YES]; - [_stepOverButton setEnabled: YES]; - [_runButton setEnabled: YES]; + [_stepInButton setEnabled:YES]; + [_stepOverButton setEnabled:YES]; + [_runButton setEnabled:YES]; [self updateSourceViewer]; } @@ -138,13 +138,13 @@ /** * Sets the stack root element so that the NSOutlineView can display it */ -- (void)setRegister: (NSXMLDocument *)elm +- (void)setRegister:(NSXMLDocument *)elm { /* - [_registerController willChangeValueForKey: @"rootElement.children"]; - [_registerController unbind: @"contentArray"]; - [_registerController bind: @"contentArray" toObject: elm withKeyPath: @"rootElement.children" options: nil]; - [_registerController didChangeValueForKey: @"rootElement.children"]; + [_registerController willChangeValueForKey:@"rootElement.children"]; + [_registerController unbind:@"contentArray"]; + [_registerController bind:@"contentArray" toObject:elm withKeyPath:@"rootElement.children" options:nil]; + [_registerController didChangeValueForKey:@"rootElement.children"]; */ // XXX: Doing anything short of this will cause bindings to crash spectacularly for no reason whatsoever, and // in seemingly arbitrary places. The class that crashes is _NSKeyValueObservationInfoCreateByRemoving. @@ -153,15 +153,15 @@ // sh!t when used with NSTreeController. http://www.cocoadev.com/index.pl?NSTreeControllerBugOrDeveloperError // was the inspiration for this fix (below) but the author says that inserting does not work too well, but // that's okay for us as we just need to replace the entire thing. - [_registerController setContent: nil]; - [_registerController setContent: [[elm rootElement] children]]; + [_registerController setContent:nil]; + [_registerController setContent:[[elm rootElement] children]]; for (int i = 0; i < [_registerView numberOfRows]; i++) { - int index = [_expandedRegisters indexOfObject: [[[_registerView itemAtRow: i] observedObject] variable]]; + int index = [_expandedRegisters indexOfObject:[[[_registerView itemAtRow:i] observedObject] variable]]; if (index != NSNotFound) { - [_registerView expandItem: [_registerView itemAtRow: i]]; + [_registerView expandItem:[_registerView itemAtRow:i]]; } } } @@ -169,7 +169,7 @@ /** * Forwards the message to run script execution to the connection */ -- (IBAction)run: (id)sender +- (IBAction)run:(id)sender { [_connection run]; } @@ -177,7 +177,7 @@ /** * Tells the connection to ask the server to reconnect */ -- (IBAction)reconnect: (id)sender +- (IBAction)reconnect:(id)sender { } @@ -185,7 +185,7 @@ /** * Forwards the message to "step in" to the connection */ -- (IBAction)stepIn: (id)sender +- (IBAction)stepIn:(id)sender { [_connection stepIn]; } @@ -193,7 +193,7 @@ /** * Forwards the message to "step out" to the connection */ -- (IBAction)stepOut: (id)sender +- (IBAction)stepOut:(id)sender { [_connection stepOut]; } @@ -201,7 +201,7 @@ /** * Forwards the message to "step over" to the connection */ -- (IBAction)stepOver: (id)sender +- (IBAction)stepOver:(id)sender { [_connection stepOver]; } @@ -210,7 +210,7 @@ * NSTableView delegate method that informs the controller that the stack selection did change and that * we should update the source viewer */ -- (void)tableViewSelectionDidChange: (NSNotification *)notif +- (void)tableViewSelectionDidChange:(NSNotification *)notif { [self updateSourceViewer]; } @@ -223,80 +223,80 @@ int selection = [_stackController selectionIndex]; if (selection == NSNotFound) { - [_sourceViewer setString: @""]; + [_sourceViewer setString:@""]; return; } // get the filename and then set the text - NSString *filename = [[_stack objectAtIndex: selection] valueForKey: @"filename"]; - filename = [[NSURL URLWithString: filename] path]; - NSString *text = [NSString stringWithContentsOfFile: filename]; - [_sourceViewer setString: text]; + NSString *filename = [[_stack objectAtIndex:selection] valueForKey:@"filename"]; + filename = [[NSURL URLWithString:filename] path]; + NSString *text = [NSString stringWithContentsOfFile:filename]; + [_sourceViewer setString:text]; // go through the document until we find the NSRange for the line we want - int destination = [[[_stack objectAtIndex: selection] valueForKey: @"lineno"] intValue]; + int destination = [[[_stack objectAtIndex:selection] valueForKey:@"lineno"] intValue]; int rangeIndex = 0; for (int line = 0; line < destination; line++) { - rangeIndex = NSMaxRange([text lineRangeForRange: NSMakeRange(rangeIndex, 0)]); + rangeIndex = NSMaxRange([text lineRangeForRange:NSMakeRange(rangeIndex, 0)]); } // now get the true start/end markers for it unsigned lineStart, lineEnd; - [text getLineStart: &lineStart end: NULL contentsEnd: &lineEnd forRange: NSMakeRange(rangeIndex - 1, 0)]; + [text getLineStart:&lineStart end:NULL contentsEnd:&lineEnd forRange:NSMakeRange(rangeIndex - 1, 0)]; NSRange lineRange = NSMakeRange(lineStart, lineEnd - lineStart); // colorize it so the user knows which line we're on in the stack - [[_sourceViewer textStorage] setAttributes: [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects: [NSColor redColor], [NSColor yellowColor], nil] - forKeys: [NSArray arrayWithObjects: NSForegroundColorAttributeName, NSBackgroundColorAttributeName, nil]] - range: lineRange]; - [_sourceViewer scrollRangeToVisible: [text lineRangeForRange: NSMakeRange(lineStart, lineEnd - lineStart)]]; + [[_sourceViewer textStorage] setAttributes:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[NSColor redColor], [NSColor yellowColor], nil] + forKeys:[NSArray arrayWithObjects:NSForegroundColorAttributeName, NSBackgroundColorAttributeName, nil]] + range:lineRange]; + [_sourceViewer scrollRangeToVisible:[text lineRangeForRange:NSMakeRange(lineStart, lineEnd - lineStart)]]; // make sure the font stays Monaco - [_sourceViewer setFont: [NSFont fontWithName: @"Monaco" size: 10.0]]; + [_sourceViewer setFont:[NSFont fontWithName:@"Monaco" size:10.0]]; } /** * Called whenver an item is expanded. This allows us to determine if we need to fetch deeper */ -- (void)outlineViewItemDidExpand: (NSNotification *)notif +- (void)outlineViewItemDidExpand:(NSNotification *)notif { - NSLog(@"notification expanded: %@", notif); + NSLog(@"notification expanded:%@", notif); // XXX: This very well may break because NSTreeController sends us a _NSArrayControllerTreeNode object // which is presumably private, and thus this is not a reliable method for getting the object. But // we damn well need it, so f!ck the rules and we're using it. - id notifObj = [[notif userInfo] objectForKey: @"NSObject"]; + id notifObj = [[notif userInfo] objectForKey:@"NSObject"]; NSXMLElement *obj = [notifObj observedObject]; // we're not a leaf but have no children. this must be beyond our depth, so go make us deeper if (![obj isLeaf] && [[obj children] count] < 1) { - [_connection getProperty: [[obj attributeForName: @"fullname"] stringValue] forElement: notifObj]; + [_connection getProperty:[[obj attributeForName:@"fullname"] stringValue] forElement:notifObj]; } - [_expandedRegisters addObject: [obj variable]]; + [_expandedRegisters addObject:[obj variable]]; } /** * Called when an item was collapsed. This allows us to remove it from the list of expanded items */ -- (void)outlineViewItemDidCollapse: (id)notif +- (void)outlineViewItemDidCollapse:(id)notif { - [_expandedRegisters removeObject: [[[[notif userInfo] objectForKey: @"NSObject"] observedObject] variable]]; - NSLog(@"outlineViewDidCollapse: %@", notif); + [_expandedRegisters removeObject:[[[[notif userInfo] objectForKey:@"NSObject"] observedObject] variable]]; + NSLog(@"outlineViewDidCollapse:%@", notif); } /** * Updates the register view by reinserting a given node back into the outline view */ -- (void)addChildren: (NSArray *)children toNode: (id)node +- (void)addChildren:(NSArray *)children toNode:(id)node { - NSLog(@"addChildren node: %@", node); - // XXX: this may break like in outlineViewItemDidExpand: + NSLog(@"addChildren node:%@", node); + // XXX: this may break like in outlineViewItemDidExpand: NSIndexPath *masterPath = [node indexPath]; for (int i = 0; i < [children count]; i++) { - [_registerController insertObject: [children objectAtIndex: i] atArrangedObjectIndexPath: [masterPath indexPathByAddingIndex: i]]; + [_registerController insertObject:[children objectAtIndex:i] atArrangedObjectIndexPath:[masterPath indexPathByAddingIndex:i]]; } [_registerController rearrangeObjects]; diff --git a/Source/NSXMLElementAdditions.m b/Source/NSXMLElementAdditions.m index c9451ed..3010a12 100644 --- a/Source/NSXMLElementAdditions.m +++ b/Source/NSXMLElementAdditions.m @@ -24,7 +24,7 @@ */ - (NSString *)variable { - return [[self attributeForName: @"name"] stringValue]; + return [[self attributeForName:@"name"] stringValue]; } /** @@ -32,7 +32,7 @@ */ - (BOOL)isLeaf { - return ([[[self attributeForName: @"children"] stringValue] intValue] == 0); + return ([[[self attributeForName:@"children"] stringValue] intValue] == 0); } /** @@ -47,10 +47,10 @@ } // base64 encoded data - if ([[[self attributeForName: @"encoding"] stringValue] isEqualToString: @"base64"]) + if ([[[self attributeForName:@"encoding"] stringValue] isEqualToString:@"base64"]) { - char *str = (char *)[[self stringValue] cStringUsingEncoding: NSASCIIStringEncoding]; - int strlen = [[self stringValue] lengthOfBytesUsingEncoding: NSASCIIStringEncoding]; + char *str = (char *)[[self stringValue] cStringUsingEncoding:NSASCIIStringEncoding]; + int strlen = [[self stringValue] lengthOfBytesUsingEncoding:NSASCIIStringEncoding]; char *data; size_t datalen; @@ -60,7 +60,7 @@ NSLog(@"error in converting %@ to base64", self); } - return [NSString stringWithCString: data length: datalen]; + return [NSString stringWithCString:data length:datalen]; } // just a normal string @@ -72,7 +72,7 @@ */ - (NSString *)type { - return [[self attributeForName: @"type"] stringValue]; + return [[self attributeForName:@"type"] stringValue]; } @end diff --git a/Source/SocketWrapper.h b/Source/SocketWrapper.h index da3a8e7..ae5116c 100644 --- a/Source/SocketWrapper.h +++ b/Source/SocketWrapper.h @@ -24,14 +24,14 @@ id _delegate; } -- (id)initWithPort: (int)port; +- (id)initWithPort:(int)port; - (id)delegate; -- (void)setDelegate: (id)delegate; +- (void)setDelegate:(id)delegate; - (void)connect; -- (void)receive: (SEL)selector; -- (void)send: (NSString *)data; +- (void)receive:(SEL)selector; +- (void)send:(NSString *)data; - (NSString *)remoteHost; @@ -40,14 +40,14 @@ @interface NSObject (SocketWrapperDelegate) // error -- (void)errorEncountered: (NSError *)error; +- (void)errorEncountered:(NSError *)error; // connection components - (void)socketDidBind; - (void)socketDidAccept; // data handlers -- (void)dataReceived: (NSData *)response deliverTo: (SEL)selector; -- (void)dataSent: (NSString *)sent; +- (void)dataReceived:(NSData *)response deliverTo:(SEL)selector; +- (void)dataSent:(NSString *)sent; @end diff --git a/Source/SocketWrapper.m b/Source/SocketWrapper.m index 5e80c25..097e719 100644 --- a/Source/SocketWrapper.m +++ b/Source/SocketWrapper.m @@ -30,9 +30,9 @@ 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; +- (void)connect:(id)obj; +- (void)postNotification:(NSString *)name withObject:(id)obj; +- (void)postNotification:(NSString *)name withObject:(id)obj withDict:(NSMutableDictionary *)dict; @end @@ -41,7 +41,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; /** * Initializes the socket wrapper with a host and port */ -- (id)initWithPort: (int)port +- (id)initWithPort:(int)port { if (self = [super init]) { @@ -50,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; } @@ -60,7 +60,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; */ - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver: self]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; close(_socket); [super dealloc]; @@ -77,7 +77,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; /** * Sets the delegate but does *not* retain it */ -- (void)setDelegate: (id)delegate +- (void)setDelegate:(id)delegate { _delegate = delegate; } @@ -92,12 +92,12 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; if (getpeername(_socket, (struct sockaddr *)&addr, &addrLength) < 0) { - [self postNotification: NsockError withObject: [NSError errorWithDomain: @"Could not get remote hostname." code: -1 userInfo: nil]]; + [self postNotification:NsockError withObject:[NSError errorWithDomain:@"Could not get remote hostname." code:-1 userInfo:nil]]; } char *name = inet_ntoa(addr.sin_addr); - return [NSString stringWithUTF8String: name]; + return [NSString stringWithUTF8String:name]; } /** @@ -106,10 +106,10 @@ 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) + if ([[notif userInfo] objectForKey:sockNotificationDebuggerConnection] != _delegate) { return; } @@ -122,15 +122,15 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; } else if (name == NsockDataReceived) { - [_delegate dataReceived: [notif object] deliverTo: NSSelectorFromString([[notif userInfo] objectForKey: sockNotificationReceiver])]; + [_delegate dataReceived:[notif object] deliverTo:NSSelectorFromString([[notif userInfo] objectForKey:sockNotificationReceiver])]; } else if (name == NsockDataSent) { - [_delegate dataSent: [notif object]]; + [_delegate dataSent:[notif object]]; } else if (name == NsockError) { - [_delegate errorEncountered: [NSError errorWithDomain: [notif object] code: -1 userInfo: nil]]; + [_delegate errorEncountered:[NSError errorWithDomain:[notif object] code:-1 userInfo:nil]]; } } @@ -140,13 +140,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]; @@ -171,7 +171,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; if (tries >= 5) { close(socketOpen); - [self postNotification: NsockError withObject: @"Could not bind to socket"]; + [self postNotification:NsockError withObject:@"Could not bind to socket"]; return; } NSLog(@"couldn't bind to the socket... trying again in 5"); @@ -182,7 +182,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; // now we just have to keep our ears open if (listen(socketOpen, 0) == -1) { - [self postNotification: NsockError withObject: @"Could not use bound socket for listening"]; + [self postNotification:NsockError withObject:@"Could not use bound socket for listening"]; } // accept a connection @@ -192,14 +192,14 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; if (_socket < 0) { close(socketOpen); - [self postNotification: NsockError withObject: @"Client failed to accept remote socket"]; + [self postNotification:NsockError withObject:@"Client failed to accept remote socket"]; return; } // we're done listening now that we have a connection close(socketOpen); - [self postNotification: NsockDidAccept withObject: nil]; + [self postNotification:NsockDidAccept withObject:nil]; [pool release]; } @@ -212,7 +212,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; * * The paramater is an optional selector which the delegate method dataReceived:deliverTo: should forward to */ -- (void)receive: (SEL)selector +- (void)receive:(SEL)selector { // create a buffer char buffer[1024]; @@ -245,7 +245,7 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; memmove(packet, &buffer[i], recvd - i); // convert bytes to NSData - [data appendBytes: packet length: recvd - i]; + [data appendBytes:packet length:recvd - i]; // check if we have a partial packet if (length + i > sizeof(buffer)) @@ -255,65 +255,65 @@ NSString *NsockDataSent = @"SocketWrapper_DataSent"; int latest = recv(_socket, &buffer, sizeof(buffer), 0); if (latest < 1) { - [self postNotification: NsockError withObject: @"Socket closed or could not be read"]; + [self postNotification:NsockError withObject:@"Socket closed or could not be read"]; return; } - [data appendBytes: buffer length: latest]; + [data appendBytes:buffer length:latest]; recvd += latest; } } - //NSLog(@"data = %@", [[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease]); + //NSLog(@"data = %@", [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]); if (selector != nil) { - [self postNotification: NsockDataReceived - withObject: data - withDict: [NSMutableDictionary dictionaryWithObject: NSStringFromSelector(selector) forKey: sockNotificationReceiver]]; + [self postNotification:NsockDataReceived + withObject:data + withDict:[NSMutableDictionary dictionaryWithObject:NSStringFromSelector(selector) forKey:sockNotificationReceiver]]; } else { - [self postNotification: NsockDataReceived withObject: data]; + [self postNotification:NsockDataReceived withObject:data]; } } /** * Sends a given NSString over the socket */ -- (void)send: (NSString *)data +- (void)send:(NSString *)data { - data = [NSString stringWithFormat: @"%@\0", data]; + data = [NSString stringWithFormat:@"%@\0", data]; int sent = send(_socket, [data UTF8String], [data length], 0); if (sent < 0) { - [self postNotification: NsockError withObject: @"Failed to write data to socket"]; + [self postNotification:NsockError withObject:@"Failed to write data to socket"]; return; } if (sent < [data length]) { // TODO - do we really need to worry about partial sends with the lenght of our commands? - NSLog(@"FAIL: only partial packet was sent; sent %d bytes", sent); + NSLog(@"FAIL:only partial packet was sent; sent %d bytes", sent); } - [self postNotification: NsockDataSent withObject: [data substringToIndex: sent]]; + [self postNotification:NsockDataSent withObject:[data substringToIndex:sent]]; } /** * 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]]; + [self postNotification:name withObject:obj withDict:[NSMutableDictionary dictionary]]; } /** * 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]; + [dict setValue:_delegate forKey:sockNotificationDebuggerConnection]; + [[NSNotificationCenter defaultCenter] postNotificationName:name object:obj userInfo:dict]; } @end -- 2.43.5