From 1b8c41520cd4da99c4a236cc225adf1b6ba0a6d9 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 4 Aug 2007 23:46:07 -0700 Subject: [PATCH] Moving the depth checker from NSXMLElementAdditions.m to be in DebuggerWindowController * Source/NSXMLElementAdditions.m: ([NSXMLElement isLeaf]): Moved the checking to see if we need to fetch more * Source/NSXMLElementAdditions.h: New header file for linking * Source/DebuggerWindowController.m: ([DebuggerWindowController outlineViewItemDidExpand:]): New method that handles the depth checking * MacGDBp.xcodeproj: Project changes for NSXMLElementAdditions.h --- MacGDBp.xcodeproj/project.pbxproj | 2 ++ Source/DebuggerWindowController.m | 28 ++++++++++++++++++++++++++++ Source/NSXMLElementAdditions.h | 26 ++++++++++++++++++++++++++ Source/NSXMLElementAdditions.m | 21 ++------------------- 4 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 Source/NSXMLElementAdditions.h diff --git a/MacGDBp.xcodeproj/project.pbxproj b/MacGDBp.xcodeproj/project.pbxproj index 0069bfb..a9c4e98 100644 --- a/MacGDBp.xcodeproj/project.pbxproj +++ b/MacGDBp.xcodeproj/project.pbxproj @@ -39,6 +39,7 @@ 1E35FC750C6579CA0030F527 /* NSXMLElementAdditions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = NSXMLElementAdditions.m; path = Source/NSXMLElementAdditions.m; sourceTree = ""; }; 1E35FE9F0C6599040030F527 /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = base64.h; path = Source/base64.h; sourceTree = ""; }; 1E35FEA00C6599040030F527 /* base64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = base64.c; path = Source/base64.c; sourceTree = ""; }; + 1E35FFB00C65A74C0030F527 /* NSXMLElementAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSXMLElementAdditions.h; path = Source/NSXMLElementAdditions.h; sourceTree = ""; }; 1EEEE93E0C618B70000C0732 /* SocketWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SocketWrapper.h; path = Source/SocketWrapper.h; sourceTree = ""; }; 1EEEE93F0C618B70000C0732 /* SocketWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SocketWrapper.m; path = Source/SocketWrapper.m; sourceTree = ""; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -75,6 +76,7 @@ 1E02C5F50C610724006F1752 /* DebuggerWindowController.m */, 1EEEE93E0C618B70000C0732 /* SocketWrapper.h */, 1EEEE93F0C618B70000C0732 /* SocketWrapper.m */, + 1E35FFB00C65A74C0030F527 /* NSXMLElementAdditions.h */, 1E35FC750C6579CA0030F527 /* NSXMLElementAdditions.m */, ); name = Classes; diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index f1dad03..c4cc03e 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -16,6 +16,7 @@ #import "DebuggerWindowController.h" #import "DebuggerConnection.h" +#import "NSXMLElementAdditions.h" @interface DebuggerWindowController (Private) @@ -148,6 +149,7 @@ */ - (void)tableViewSelectionDidChange: (NSNotification *)notif { + NSLog(@"selection changed"); [self updateSourceViewer]; } /** @@ -191,4 +193,30 @@ [_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 +{ + // 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. + NSXMLElement *obj = [[[notif userInfo] objectForKey: @"NSObject"] observedObject]; + + // hmm... 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) + { + // count upwards to see how deep we should go + int depth = 0; + NSXMLElement *elm = obj; + while (elm != nil) + { + depth++; + elm = (NSXMLElement *)[elm parent]; + } + NSLog(@"let's go to depth %d for %@", depth, obj); + } +} + @end diff --git a/Source/NSXMLElementAdditions.h b/Source/NSXMLElementAdditions.h new file mode 100644 index 0000000..74f767c --- /dev/null +++ b/Source/NSXMLElementAdditions.h @@ -0,0 +1,26 @@ +/* + * MacGDBp + * Copyright (c) 2002 - 2007, Blue Static + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; if not, + * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#import + +@interface NSXMLElement (NSXMLElementAdditions) + +- (NSString *)variable; +- (BOOL)isLeaf; +- (NSString *)value; +- (NSString *)type; + +@end diff --git a/Source/NSXMLElementAdditions.m b/Source/NSXMLElementAdditions.m index 6b0c7dc..c9451ed 100644 --- a/Source/NSXMLElementAdditions.m +++ b/Source/NSXMLElementAdditions.m @@ -32,24 +32,7 @@ */ - (BOOL)isLeaf { - BOOL leaf = ([[[self attributeForName: @"children"] stringValue] intValue] == 0); - - // hmm... we're not a leaf but have no children. this must be beyond our depth, so go make us - // deeper - if (!leaf && [[self children] count] < 1) - { - // count upwards to see how deep we should go - int depth = 0; - NSXMLElement *elm = self; - while (elm != nil) - { - depth++; - elm = (NSXMLElement *)[elm parent]; - } - NSLog(@"let's go to depth %d for %@", depth, self); - } - - return leaf; + return ([[[self attributeForName: @"children"] stringValue] intValue] == 0); } /** @@ -92,4 +75,4 @@ return [[self attributeForName: @"type"] stringValue]; } -@end \ No newline at end of file +@end -- 2.22.5