From 7c2a272af64d01386d76cbdce6f32ae603b295f0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 5 Jan 2008 17:14:00 -0800 Subject: [PATCH] The registers now have memory and stay expanded * Source/DebuggerWindowController.h: expandedRegisters is now an NSMutableSet * Source/DebuggerWindowController.m: ([DebuggerWindowController initWithPort:session:]): Change allocated type of expandedRegisters ([DebuggerWindowController setRegister:]): Finished logic for expanding remembered registers ([DebuggerWindowController outlineViewItemDidExpand:]): Use the "fullname" attribute to get the full variable name so scope is accounted for in expanded memory ([DebuggerWindowController outlineViewItemDidCollapse:]): ditto * Source/NSXMLElementAdditions.h: * Source/NSXMLElementAdditions.m: ([NSXMLElement(NSXMLElementAdditions) fullname]): New method --- Source/DebuggerWindowController.h | 2 +- Source/DebuggerWindowController.m | 25 +++++++++++-------------- Source/NSXMLElementAdditions.h | 1 + Source/NSXMLElementAdditions.m | 8 ++++++++ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Source/DebuggerWindowController.h b/Source/DebuggerWindowController.h index 524fc5c..583aa9d 100644 --- a/Source/DebuggerWindowController.h +++ b/Source/DebuggerWindowController.h @@ -27,7 +27,7 @@ IBOutlet NSTreeController *registerController; IBOutlet NSOutlineView *registerView; - NSMutableArray *expandedRegisters; + NSMutableSet *expandedRegisters; IBOutlet NSTextField *statusmsg; IBOutlet NSTextField *errormsg; diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index d29a29c..7a4e1ee 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -37,7 +37,7 @@ if (self = [super initWithWindowNibName:@"Debugger"]) { connection = [[DebuggerConnection alloc] initWithWindowController:self port:aPort session:aSession]; - expandedRegisters = [[NSMutableArray alloc] init]; + expandedRegisters = [[NSMutableSet alloc] init]; [[self window] makeKeyAndOrderFront:nil]; } return self; @@ -129,12 +129,6 @@ */ - (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"]; - */ // 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. // http://boredzo.org/blog/archives/2006-01-29/have-you-seen-this-crash says that this means nothing is @@ -145,11 +139,14 @@ [registerController setContent:nil]; [registerController setContent:[[elm rootElement] children]]; - /*for (NSTreeNode *node in expandedRegisters) + for (int i = 0; i < [registerView numberOfRows]; i++) { - [registerView expandItem:node]; - }*/ - NSLog(@"expanded items = %@", expandedRegisters); + NSTreeNode *node = [registerView itemAtRow:i]; + if ([expandedRegisters containsObject:[[node representedObject] fullname]]) + { + [registerView expandItem:node]; + } + } } /** @@ -252,10 +249,10 @@ // we're not a leaf but have no children. this must be beyond our depth, so go make us deeper if (![node isLeaf] && [[node childNodes] count] < 1) { - [connection getProperty:[[[node representedObject] attributeForName:@"fullname"] stringValue] forNode:node]; + [connection getProperty:[[node representedObject] fullname] forNode:node]; } - [expandedRegisters addObject:[[node representedObject] variable]]; + [expandedRegisters addObject:[[node representedObject] fullname]]; } /** @@ -263,7 +260,7 @@ */ - (void)outlineViewItemDidCollapse:(NSNotification *)notif { - [expandedRegisters removeObject:[[[[notif userInfo] objectForKey:@"NSObject"] representedObject] variable]]; + [expandedRegisters removeObject:[[[[notif userInfo] objectForKey:@"NSObject"] representedObject] fullname]]; } /** diff --git a/Source/NSXMLElementAdditions.h b/Source/NSXMLElementAdditions.h index 74f767c..13be465 100644 --- a/Source/NSXMLElementAdditions.h +++ b/Source/NSXMLElementAdditions.h @@ -18,6 +18,7 @@ @interface NSXMLElement (NSXMLElementAdditions) +- (NSString *)fullname; - (NSString *)variable; - (BOOL)isLeaf; - (NSString *)value; diff --git a/Source/NSXMLElementAdditions.m b/Source/NSXMLElementAdditions.m index 3010a12..8b66b6c 100644 --- a/Source/NSXMLElementAdditions.m +++ b/Source/NSXMLElementAdditions.m @@ -19,6 +19,14 @@ @implementation NSXMLElement (NSXMLElementAdditions) +/** + * Return's the property's full name + */ +- (NSString *)fullname +{ + return [[self attributeForName:@"fullname"] stringValue]; +} + /** * Return's the property's name from the attributes list */ -- 2.43.5