From d46c3926789f9394b427fdf8da3ad62fa90d7cdd Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 4 Jan 2008 14:08:37 -0800 Subject: [PATCH] Reworking the code to use NSTreeNode instead of the hidden proxy objects --- MacGDBp.xcodeproj/project.pbxproj | 4 ++-- Source/DebuggerConnection.h | 4 ++-- Source/DebuggerConnection.m | 8 ++++---- Source/DebuggerWindowController.h | 2 +- Source/DebuggerWindowController.m | 30 +++++++++--------------------- 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/MacGDBp.xcodeproj/project.pbxproj b/MacGDBp.xcodeproj/project.pbxproj index 1b0c461..b520caa 100644 --- a/MacGDBp.xcodeproj/project.pbxproj +++ b/MacGDBp.xcodeproj/project.pbxproj @@ -314,7 +314,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; }; name = Debug; }; @@ -325,7 +325,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; }; name = Release; }; diff --git a/Source/DebuggerConnection.h b/Source/DebuggerConnection.h index 4eb1a51..72e1baf 100644 --- a/Source/DebuggerConnection.h +++ b/Source/DebuggerConnection.h @@ -28,7 +28,7 @@ SocketWrapper *socket; - id depthFetchElement; + id depthFetchNode; } // initializer @@ -51,6 +51,6 @@ - (void)updateStackTraceAndRegisters; // helpers -- (void)getProperty:(NSString *)property forElement:(NSXMLElement *)elm; +- (void)getProperty:(NSString *)property forNode:(NSTreeNode *)elm; @end diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index 8c19d38..ca385c5 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -275,10 +275,10 @@ * 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 forNode:(NSTreeNode *)node { [socket send:[self createCommand:[NSString stringWithFormat:@"property_get -n \"%@\"", property]]]; - depthFetchElement = elm; + depthFetchNode = node; [socket receive:@selector(propertyReceived:)]; } @@ -299,8 +299,8 @@ NSXMLElement *parent = (NSXMLElement *)[[doc rootElement] childAtIndex:0]; NSArray *children = [parent children]; [parent setChildren:nil]; - [windowController addChildren:children toNode:depthFetchElement]; - depthFetchElement = nil; + [windowController addChildren:children toNode:depthFetchNode]; + depthFetchNode = nil; } /** diff --git a/Source/DebuggerWindowController.h b/Source/DebuggerWindowController.h index f8495af..4de562a 100644 --- a/Source/DebuggerWindowController.h +++ b/Source/DebuggerWindowController.h @@ -49,7 +49,7 @@ - (void)setStack:(NSArray *)node; - (void)setRegister:(NSXMLDocument *)reg; -- (void)addChildren:(NSArray *)children toNode:(id)node; +- (void)addChildren:(NSArray *)children toNode:(NSTreeNode *)node; - (IBAction)run:(id)sender; - (IBAction)stepIn:(id)sender; diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index aa16692..3253be5 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -156,13 +156,9 @@ [registerController setContent:nil]; [registerController setContent:[[elm rootElement] children]]; - for (int i = 0; i < [registerView numberOfRows]; i++) + for (NSTreeNode *node in expandedRegisters) { - int index = [expandedRegisters indexOfObject:[[[registerView itemAtRow:i] observedObject] variable]]; - if (index != NSNotFound) - { - [registerView expandItem:[registerView itemAtRow:i]]; - } + [registerView expandItem:node]; } } @@ -261,38 +257,30 @@ */ - (void)outlineViewItemDidExpand:(NSNotification *)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"]; - NSXMLElement *obj = [notifObj observedObject]; + NSTreeNode *node = [[notif userInfo] objectForKey:@"NSObject"]; // 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) + if (![node isLeaf] && [[node childNodes] count] < 1) { - [connection getProperty:[[obj attributeForName:@"fullname"] stringValue] forElement:notifObj]; + [connection getProperty:[[[node representedObject] attributeForName:@"fullname"] stringValue] forNode:node]; } - [expandedRegisters addObject:[obj variable]]; + [expandedRegisters addObject:node]; } /** * Called when an item was collapsed. This allows us to remove it from the list of expanded items */ -- (void)outlineViewItemDidCollapse:(id)notif +- (void)outlineViewItemDidCollapse:(NSNotification *)notif { - [expandedRegisters removeObject:[[[[notif userInfo] objectForKey:@"NSObject"] observedObject] variable]]; - NSLog(@"outlineViewDidCollapse:%@", notif); + [expandedRegisters removeObject:[[notif userInfo] objectForKey:@"NSObject"]]; } /** * 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:(NSTreeNode *)node { - NSLog(@"addChildren node:%@", node); - // XXX: this may break like in outlineViewItemDidExpand: NSIndexPath *masterPath = [node indexPath]; for (int i = 0; i < [children count]; i++) { -- 2.22.5