diff --git a/COPYING b/COPYING index 4e502a8..f287db7 100644 --- a/COPYING +++ b/COPYING @@ -2,30 +2,30 @@ Nutron Copyright (c) 2010, Jeff Buck All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name "Nutron" nor the names of its contributors may - be used to endorse or promote products derived from this software + * Neither the name "Nutron" nor the names of its contributors may + be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Nutronic/NutronicAppDelegate.m b/Nutronic/NutronicAppDelegate.m index 6b4dbd9..acd5168 100644 --- a/Nutronic/NutronicAppDelegate.m +++ b/Nutronic/NutronicAppDelegate.m @@ -15,7 +15,7 @@ @implementation NutronicAppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSRect frame = [_window frame]; - + frame = [[_window contentView] frame]; _nutronViewController = [[NutronViewController alloc] diff --git a/src/Nutron.m b/src/Nutron.m index 1494b98..b200d3d 100644 --- a/src/Nutron.m +++ b/src/Nutron.m @@ -40,7 +40,7 @@ + (NutronObjectViewWindowController*)inspect:(id)object withName:(NSString*)name + (NutronClassTextViewWindowController*)viewClass:(NSString*)className { - NutronClassTextViewWindowController* c = + NutronClassTextViewWindowController* c = [[[NutronClassTextViewWindowController alloc] initWithClassName:className] autorelease]; return c; @@ -48,9 +48,9 @@ + (NutronClassTextViewWindowController*)viewClass:(NSString*)className + (NutronClassOutlineViewWindowController*)outlineClass:(NSString*)className { - NutronClassOutlineViewWindowController* c = + NutronClassOutlineViewWindowController* c = [[[NutronClassOutlineViewWindowController alloc] initWithClassName:className] autorelease]; - + return c; } @@ -74,11 +74,11 @@ + (NutronWindowController*)nutron + (id)selectView { NutronViewSelector* vs = [[NutronViewSelector alloc] init]; - + id result = [vs selectView]; - + [vs release]; - + return result; } diff --git a/src/NutronCachedObject.h b/src/NutronCachedObject.h index a012e16..9432da5 100644 --- a/src/NutronCachedObject.h +++ b/src/NutronCachedObject.h @@ -26,15 +26,15 @@ id _cachedObject; id _parent; NSMutableArray* _children; - + NutronRuntimeIvar* _ivar; NSString* _key; int _index; - + NSString* _name; NSString* _type; id _value; - + BOOL _isExpanded; } diff --git a/src/NutronCachedObject.m b/src/NutronCachedObject.m index ba0d24c..38252e6 100644 --- a/src/NutronCachedObject.m +++ b/src/NutronCachedObject.m @@ -27,9 +27,9 @@ @implementation NutronCachedObject + (NutronCachedObject*)nutronCachedObjectForObject:(id)item withParent:(id)p key:(NSString*)k index:(int)i { NutronDebug(@"cachedObjectForObject: %@", item); - + NutronCachedObject* object = nil; - + if ([item isKindOfClass:[NSDictionary class]]) { object = [[[NutronCachedDictionary alloc] initWithObject:item parent:p key:k index:i] autorelease]; @@ -58,22 +58,22 @@ + (NutronCachedObject*)nutronCachedObjectForObject:(id)item withParent:(id)p key { assert(0); } - + return object; } - (id)initWithObject:(id)o parent:(id)p key:(NSString*)k index:(int)i { self = [super init]; - + if (self == nil) return nil; - + _object = [o retain]; _parent = [p retain]; _key = [k copy]; _index = i; - + return self; } @@ -85,14 +85,14 @@ - (void)dealloc [_children release]; [_ivar release]; [_key release]; - + [super dealloc]; } - (NSString*)name { return _key; - + if (_ivar) { return [_ivar name]; @@ -116,7 +116,7 @@ - (NSString*)type if (_object) { NSString* className = [_object className]; - + if ( _ivar && ( ([className isEqualToString:@"NSCFNumber"]) || ([className isEqualToString:@"NSNull"]))) @@ -161,7 +161,7 @@ - (id)value - (BOOL)isAtomicTypeEncoding:(NSString*)typeEncoding { - if ( ([typeEncoding isEqualToString:@"@"]) + if ( ([typeEncoding isEqualToString:@"@"]) || ([typeEncoding length] > 1)) { // typeEncoding length > 1 is a class name, so not atomic @@ -188,7 +188,7 @@ - (BOOL)isExpandable [_ivar name], typeEncoding, [_ivar runtimeType]); - + return ![self isAtomicTypeEncoding:typeEncoding]; } else if ([_object isKindOfClass:[NSObject class]]) @@ -205,7 +205,7 @@ - (NSArray*)children { if (_children) return _children; - + if (_object == nil) { return nil; @@ -221,7 +221,7 @@ - (NSArray*)children { // We're an object. Return ivars by default _children = [[NSMutableArray alloc] init]; - + NutronRuntimeClass* objectClass = nil; if ( [_object isKindOfClass:[NutronRuntimeClass class]] @@ -234,13 +234,13 @@ - (NSArray*)children { objectClass = [[[NutronRuntimeClass alloc] initWithName:[_object className]] autorelease]; } - + NSArray* ivarArray = nil; if (objectClass) { NSString* superclassName = [objectClass superclassName]; - + // If we have a super class, insert an isa object for superclass' ivars if ( superclassName && ![superclassName isEqualToString:@""] @@ -250,14 +250,14 @@ - (NSArray*)children initWithName:superclassName] autorelease]; - NutronCachedObject* isaChild = + NutronCachedObject* isaChild = [NutronCachedObject nutronCachedObjectForObject:superclass withParent:self key:kNutronCachedObjectKeyIsa index:-1]; [_children addObject:isaChild]; } - + // Insert our ivars id objectWithIvars = nil; id ivarParent = nil; @@ -269,7 +269,7 @@ - (NSArray*)children // Link to the parent object, as it is the one // we will query for ivar values. ivarArray = [_object ivars]; - + // Walk up the isa hierarchy until we find our root object id ancestor = _parent; while ( [[ancestor key] isKindOfClass:[NSString class]] @@ -277,7 +277,7 @@ - (NSArray*)children { ancestor = [ancestor parent]; } - + objectWithIvars = [ancestor object]; ivarParent = _parent; } @@ -295,7 +295,7 @@ - (NSArray*)children for (int i = 0; i < ivarCount; i++) { NutronRuntimeIvar* nutronIvar = [ivarArray objectAtIndex:i]; - + id ivarValue; NSString* ivarTypeEncoding = [nutronIvar typeEncoding]; @@ -311,7 +311,7 @@ - (NSArray*)children else { // Otherwise, we have a struct that we don't map yet. - ivarValue = [NSNull null]; + ivarValue = [NSNull null]; } } else @@ -319,15 +319,15 @@ - (NSArray*)children ivarValue = [objectWithIvars valueForIvar:[nutronIvar name]]; } - NutronCachedObject* child = [NutronCachedObject nutronCachedObjectForObject:ivarValue + NutronCachedObject* child = [NutronCachedObject nutronCachedObjectForObject:ivarValue withParent:ivarParent key:[nutronIvar name] index:i]; child.ivar = nutronIvar; - + [_children addObject:child]; } - + return _children; } else @@ -339,7 +339,7 @@ - (NSArray*)children - (int)numberOfChildren -{ +{ return [[self children] count]; } @@ -356,10 +356,10 @@ @implementation NutronCachedConcreteValue - (id)initWithObject:(id)o parent:(id)p key:(NSString*)k index:(int)i { self = [super initWithObject:o parent:p key:k index:i]; - + if (self == nil) return nil; - + return self; } @@ -391,12 +391,12 @@ @implementation NutronCachedSymbolTable - (id)initWithObject:(id)symbolTable parent:(id)p key:(NSString*)k index:(int)i { self = [super initWithObject:symbolTable parent:p key:k index:i]; - + if (self == nil) return nil; - + _cachedObject = [[[symbolTable all] sort] retain]; - + return self; } @@ -420,25 +420,25 @@ - (NSArray*)children { if (_children) return _children; - + int symbolCount = [_cachedObject count]; - + if (symbolCount == 0) return nil; - + _children = [[NSMutableArray alloc] initWithCapacity:symbolCount]; - + for (int i = 0; i < symbolCount; i++) { NuSymbol* symbol = [_cachedObject objectAtIndex:i]; - + NutronCachedObject* child = [NutronCachedObject nutronCachedObjectForObject:symbol withParent:self key:[symbol description] index:i]; [_children addObject:child]; } - + return _children; } @@ -455,14 +455,14 @@ @implementation NutronCachedDictionary - (id)initWithObject:(id)dictionary parent:(id)p key:(NSString*)k index:(int)i { self = [super initWithObject:dictionary parent:p key:k index:i]; - + if (self == nil) return nil; - + _cachedObject = [[[dictionary allKeys] sortedArrayUsingComparator:^(id a, id b) { return [[a stringValue] compare:[b stringValue]]; } ] retain]; - + return self; } @@ -485,19 +485,19 @@ - (NSArray*)children { if (_children) return _children; - + int keyCount = [_cachedObject count]; - + if (keyCount == 0) return nil; - + _children = [[NSMutableArray alloc] initWithCapacity:keyCount]; - + for (int i = 0; i < keyCount; i++) { // itemKey could be a string or a NuSymbol so use an id id itemKey = [_cachedObject objectAtIndex:i]; - + id value = [_object objectForKey:itemKey]; NutronCachedObject* child = [NutronCachedObject nutronCachedObjectForObject:value withParent:self @@ -505,7 +505,7 @@ - (NSArray*)children index:i]; [_children addObject:child]; } - + return _children; } @@ -522,10 +522,10 @@ @implementation NutronCachedArray - (id)initWithObject:(id)array parent:(id)p key:(NSString*)k index:(int)i { self = [super initWithObject:array parent:p key:k index:i]; - + if (self == nil) return nil; - + return self; } @@ -548,14 +548,14 @@ - (NSArray*)children { if (_children) return _children; - + int keyCount = [_object count]; - + if (keyCount == 0) return nil; - + _children = [[NSMutableArray alloc] initWithCapacity:keyCount]; - + for (int i = 0; i < keyCount; i++) { id itemKey = [NSString stringWithFormat:@"%d", i]; @@ -566,7 +566,7 @@ - (NSArray*)children index:i]; [_children addObject:child]; } - + return _children; } @@ -583,10 +583,10 @@ @implementation NutronCachedRuntimeObject - (id)initWithObject:(id)runtimeClass parent:(id)p key:(NSString*)k index:(int)i { self = [super initWithObject:runtimeClass parent:p key:k index:i]; - + if (self == nil) return nil; - + return self; } @@ -618,7 +618,7 @@ - (NSString*)type if ([_object isKindOfClass:[NutronRuntimeClass class]]) { return [_object name]; - } + } else if ( [[_parent object] isKindOfClass:[NutronRuntimeClass class]] || [[_parent object] isKindOfClass:[NutronRuntimeIvar class]] || [[_parent object] isKindOfClass:[NutronRuntimeProperty class]]) @@ -644,7 +644,7 @@ - (NSString*)type return @""; } } - + return @""; } @@ -664,11 +664,11 @@ - (BOOL)isExpandable { return ( [_object isKindOfClass:[NutronRuntimeClass class]] || [[_parent object] isKindOfClass:[NutronRuntimeClass class]] - || ( [_object isKindOfClass:[NutronRuntimeIvar class]] + || ( [_object isKindOfClass:[NutronRuntimeIvar class]] && ![self isAtomicTypeEncoding:[_object typeEncoding]]) - || ( [_object isKindOfClass:[NutronRuntimeProperty class]] + || ( [_object isKindOfClass:[NutronRuntimeProperty class]] && ![self isAtomicTypeEncoding:[(NutronRuntimeType*)[_object runtimeType] typeEncoding]])); - + // return (_object != nil) || ((_object == nil) && (_key != nil)); } @@ -710,13 +710,13 @@ - (int)numberOfChildren - (NSMutableArray*)childrenArrayForObjects:(NSArray*)array { int count = [array count]; - + NSMutableArray* childArray = [[NSMutableArray alloc] init]; for (int i = 0; i < count; i++) { id childObject = [array objectAtIndex:i]; - + NSString* childKey; if ([_key isEqualToString:kNutronCachedObjectKeyProtocols]) @@ -735,7 +735,7 @@ - (NSMutableArray*)childrenArrayForObjects:(NSArray*)array index:i] autorelease]; [childArray addObject:child]; } - + return [childArray autorelease]; } @@ -743,7 +743,7 @@ - (NSArray*)children { if (_children) return _children; - + if ( [_object isKindOfClass:[NutronRuntimeClass class]] || [_object isKindOfClass:[NutronRuntimeIvar class]] || [_object isKindOfClass:[NutronRuntimeProperty class]]) @@ -754,7 +754,7 @@ - (NSArray*)children id childObject = nil; id parentObject = nil; NSString* objectClassName; - + if ([_object isKindOfClass:[NutronRuntimeClass class]]) { objectClassName = [_object name]; @@ -764,18 +764,18 @@ - (NSArray*)children { objectClassName = [[_object runtimeType] className]; NutronRuntimeClass* nrc = [[[NutronRuntimeClass alloc] initWithName:objectClassName] autorelease]; - parentObject = [[[NutronCachedRuntimeObject alloc] initWithObject:nrc + parentObject = [[[NutronCachedRuntimeObject alloc] initWithObject:nrc parent:self key:kNutronCachedObjectKeyObject index:-1] autorelease]; } - + // If this class has a superclass, add it as an 'isa'-type item Class objectClass = NSClassFromString(objectClassName); if (objectClass != nil) { Class objectSuperClass = class_getSuperclass(objectClass); - + if (objectSuperClass != nil) { const char* szSuperclassName = class_getName(objectSuperClass); @@ -789,13 +789,13 @@ - (NSArray*)children [_children addObject:child]; } } - - child = [[[NutronCachedRuntimeObject alloc] initWithObject:childObject + + child = [[[NutronCachedRuntimeObject alloc] initWithObject:childObject parent:parentObject key:kNutronCachedObjectKeyIvars index:-1] autorelease]; [_children addObject:child]; - child = [[[NutronCachedRuntimeObject alloc] initWithObject:childObject + child = [[[NutronCachedRuntimeObject alloc] initWithObject:childObject parent:parentObject key:kNutronCachedObjectKeyProperties index:-1] autorelease]; @@ -835,7 +835,7 @@ - (NSArray*)children else if ([_key isEqualToString:kNutronCachedObjectKeyProtocols]) { _children = [[self childrenArrayForObjects:[[_parent object] protocols]] retain]; - } + } return _children; } diff --git a/src/NutronClassOutlineViewController.m b/src/NutronClassOutlineViewController.m index c593889..392ca47 100644 --- a/src/NutronClassOutlineViewController.m +++ b/src/NutronClassOutlineViewController.m @@ -33,13 +33,13 @@ - (void)setClassName:(NSString *)newClassName { return; } - + [_rootObject release]; - + if (newClassName) - { + { NutronRuntimeClass* nrc = [[[NutronRuntimeClass alloc] initWithName:newClassName] autorelease]; - + _rootObject = [[[NutronCachedRuntimeObject alloc] initWithObject:nrc parent:nil key:kNutronCachedObjectKeyObject @@ -55,7 +55,7 @@ - (void)setClassName:(NSString *)newClassName - (id)initWithFrame:(NSRect)frame className:(NSString*)aClassName { self = [super init]; - + if (self) { if (aClassName) @@ -67,12 +67,12 @@ - (id)initWithFrame:(NSRect)frame className:(NSString*)aClassName key:kNutronCachedObjectKeyObject index:-1] retain]; } - else + else { _rootObject = nil; } - _outlineView = [[NutronClassOutlineView alloc] + _outlineView = [[NutronClassOutlineView alloc] initWithFrame:NSMakeRect(0, 0, frame.size.width, @@ -111,7 +111,7 @@ - (void)dealloc [_scrollView release]; [_outlineView release]; [_rootObject release]; - + [super dealloc]; } @@ -120,9 +120,9 @@ - (void)refresh { [_outlineView reloadData]; [_outlineView expandItem:_rootObject]; - + NSArray* children = [_rootObject children]; - + for (NutronCachedObject* item in children) { if (![[item key] isEqualToString:kNutronCachedObjectKeyObject]) @@ -159,7 +159,7 @@ - (NSInteger)outlineView:(NSOutlineView*)ov numberOfChildrenOfItem:(id)item return 1; //object = _rootObject; } - + NutronDebug(@"# of children: item %@", object); return [object numberOfChildren]; } @@ -167,7 +167,7 @@ - (NSInteger)outlineView:(NSOutlineView*)ov numberOfChildrenOfItem:(id)item - (id)outlineView:(NSOutlineView *)ov child:(NSInteger)index ofItem:(id)item { NutronCachedObject* object = (NutronCachedObject*)item; - + if (object == nil) { return _rootObject; @@ -181,14 +181,14 @@ - (id)outlineView:(NSOutlineView *)ov child:(NSInteger)index ofItem:(id)item - (id)outlineView:(NSOutlineView *)ov objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { NutronDebug(@"objectValueForTableColumn:%@ byItem:%@", tableColumn, item); - + NutronCachedObject* object = (NutronCachedObject*)item; - + if (object == nil) object = _rootObject; - + NSString* columnIdentifier = [tableColumn identifier]; - + if ([columnIdentifier compare:@"Name"] == NSOrderedSame) { return [object name]; diff --git a/src/NutronClassOutlineViewWindowController.m b/src/NutronClassOutlineViewWindowController.m index 7b4e6eb..fdde535 100644 --- a/src/NutronClassOutlineViewWindowController.m +++ b/src/NutronClassOutlineViewWindowController.m @@ -24,20 +24,20 @@ - (id)initWithClassName:(NSString *)aClassName | NSUtilityWindowMask backing:NSBackingStoreBuffered defer:NO]]; - + if (!self) return nil; - + _className = [aClassName copy]; NSWindow* w = [self window]; NSRect frame = [w frame]; - + _classViewer = [[NutronClassOutlineViewController alloc] initWithFrame:frame className:_className]; - + [w setContentView:[_classViewer scrollView]]; - + [w center]; [w setTitle:[NSString stringWithFormat:@"Nutron Class Viewer - %@", _className]]; [w setDelegate:self]; @@ -46,7 +46,7 @@ - (id)initWithClassName:(NSString *)aClassName [w setFrameOrigin:NSMakePoint(frame.origin.x, 200)]; [w setMinSize:NSMakeSize(600, 100)]; [w makeKeyAndOrderFront:self]; - + return self; } @@ -55,7 +55,7 @@ - (void)dealloc [[self window] setDelegate:nil]; [_classViewer release]; [_className release]; - + [super dealloc]; } diff --git a/src/NutronClassTextView.m b/src/NutronClassTextView.m index 0ac4c80..d7e299d 100644 --- a/src/NutronClassTextView.m +++ b/src/NutronClassTextView.m @@ -14,8 +14,8 @@ @implementation NutronClassTextView - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; - - if (self) + + if (self) { } return self; diff --git a/src/NutronClassTextViewController.h b/src/NutronClassTextViewController.h index 4b5e152..07174bd 100644 --- a/src/NutronClassTextViewController.h +++ b/src/NutronClassTextViewController.h @@ -13,7 +13,7 @@ { NSTextView* _textView; NSScrollView* _scrollView; - + NSString* _className; NSString* _format; } diff --git a/src/NutronClassTextViewController.m b/src/NutronClassTextViewController.m index de297c7..92515d9 100644 --- a/src/NutronClassTextViewController.m +++ b/src/NutronClassTextViewController.m @@ -25,7 +25,7 @@ @implementation NutronClassTextViewController - (id)initWithFrame:(NSRect)frame { self = [super init]; - + if (self) { _textView = [[NutronClassTextView alloc] initWithFrame:NSMakeRect(0, @@ -40,7 +40,7 @@ - (id)initWithFrame:(NSRect)frame _scrollView = [[NSScrollView scrollViewWrappedAroundView:_textView withFrame:frame] retain]; } - + return self; } @@ -58,12 +58,12 @@ - (void)dumpClass { if ((_className == nil) || [_className isEqualToString:@""]) return; - + NutronRuntimeClass* nrc = [[[NutronRuntimeClass alloc] initWithName:_className] autorelease]; - + NSString* dump = [nrc objcDeclaration]; NSLog(@"dumpClass: %@\n%@", _className, dump); - + [_textView setString:dump]; // [[_textView textStorage] replaceCharactersInRange:NSMakeRange(0, [[_textView string] length]) // withString:dump]; @@ -103,7 +103,7 @@ - (void)setFormat:(NSString*)newFormat [_format release]; _format = [newFormat copy]; - + // Different format, regenerate the classdump } diff --git a/src/NutronClassTextViewWindowController.m b/src/NutronClassTextViewWindowController.m index b07891d..4a92b9c 100644 --- a/src/NutronClassTextViewWindowController.m +++ b/src/NutronClassTextViewWindowController.m @@ -16,7 +16,7 @@ @implementation NutronClassTextViewWindowController - (id)initWithClassName:(NSString*)aClassName { - self = [super initWithWindow:[[NSPanel alloc] + self = [super initWithWindow:[[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 600, 400) styleMask:NSTitledWindowMask | NSClosableWindowMask @@ -33,7 +33,7 @@ - (id)initWithClassName:(NSString*)aClassName NSWindow* w = [self window]; NSRect frame = [w frame]; - _textViewController = [[NutronClassTextViewController alloc] + _textViewController = [[NutronClassTextViewController alloc] initWithFrame:frame]; [w setContentView:[_textViewController scrollView]]; @@ -46,7 +46,7 @@ - (id)initWithClassName:(NSString*)aClassName [w setFrameOrigin:NSMakePoint(frame.origin.x, 500)]; [w setMinSize:NSMakeSize(600, 100)]; [w makeKeyAndOrderFront:self]; - + [_textViewController setFonts]; [_textViewController setClassName:_className]; @@ -56,7 +56,7 @@ - (id)initWithClassName:(NSString*)aClassName - (void)dealloc { [[self window] setDelegate:nil]; - + [_textViewController release]; [super dealloc]; } diff --git a/src/NutronConsoleView.m b/src/NutronConsoleView.m index 4e2ae4a..d2cce9b 100644 --- a/src/NutronConsoleView.m +++ b/src/NutronConsoleView.m @@ -14,7 +14,7 @@ @implementation NutronConsoleView - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; - + if (self == nil) return nil; @@ -28,7 +28,7 @@ - (void)keyDown:(NSEvent *)event if (([event modifierFlags] & NSControlKeyMask) != 0) { id cvd = (id)[self delegate]; - + switch ([event keyCode]) { case 0: @@ -40,7 +40,7 @@ - (void)keyDown:(NSEvent *)event break; } } - + [super keyDown:event]; } diff --git a/src/NutronConsoleViewController.h b/src/NutronConsoleViewController.h index e7a0b18..c4e626a 100644 --- a/src/NutronConsoleViewController.h +++ b/src/NutronConsoleViewController.h @@ -31,7 +31,7 @@ int _index; int _count; int _chunk; - + int _promptCounter; id _delegate; } diff --git a/src/NutronConsoleViewController.m b/src/NutronConsoleViewController.m index f8c9690..383ec15 100644 --- a/src/NutronConsoleViewController.m +++ b/src/NutronConsoleViewController.m @@ -50,7 +50,7 @@ - (id)initWithFrame:(NSRect)frame [_textView setDelegate:self]; _scrollView = [[NSScrollView scrollViewWrappedAroundView:_textView withFrame:frame] retain]; - + _startOfInput = 0; _insertionPoint = 0; _count = 0; @@ -65,8 +65,8 @@ - (id)initWithFrame:(NSRect)frame // Add the magic $$console symbole. print and puts depend on it being there NuSymbolTable* symbolTable = [[_parser context] objectForKey:SYMBOLS_KEY]; [[symbolTable symbolWithString:@"$$console"] setValue:self]; - - [self prompt]; + + [self prompt]; } return self; @@ -78,7 +78,7 @@ - (void)dealloc [_history release]; [_textView release]; [_scrollView release]; - + [super dealloc]; } @@ -86,9 +86,9 @@ - (void)setParser:(NuParser*)newParser { if (newParser == _parser) return; - + [_parser release]; - + _parser = [newParser retain]; // Add the magic $$console symbole. print and puts depend on it being there @@ -119,16 +119,16 @@ - (void)write:(NSString*)string int length = [string length]; _insertionPoint += length; _startOfInput += length; - + [_textView scrollRangeToVisible:NSMakeRange([self lengthOfTextView], 0)]; - + ++_count; - + if ((_count % _chunk) == 0) { [[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]]; } - + [self moveToEndOfInput]; } @@ -171,11 +171,11 @@ - (void)replaceLineWithNext { return; } - + int textLength = [self lengthOfTextView]; - + NSString* replacement; - + if (_index == (historyCount - 1)) { replacement = @""; @@ -184,9 +184,9 @@ - (void)replaceLineWithNext { replacement = [_history objectAtIndex:_index + 1]; } - + ++_index; - + [[_textView textStorage] replaceCharactersInRange:NSMakeRange(_startOfInput, textLength - _startOfInput) withString:replacement]; @@ -195,12 +195,12 @@ - (void)replaceLineWithNext - (BOOL)textView:(NSTextView*)textView shouldChangeTextInRange:(NSRange)range replacementString:(NSString*)replacement -{ +{ NSLayoutManager* layoutManager = [_textView layoutManager]; int textLength = [self lengthOfTextView]; int replacementLength = [replacement length]; NSTextStorage* textStorage = [_textView textStorage]; - + [layoutManager removeTemporaryAttribute:@"NSColor" forCharacterRange:NSMakeRange(0, textLength)]; [layoutManager removeTemporaryAttribute:@"NSBackgroundColor" forCharacterRange:NSMakeRange(0, textLength)]; [layoutManager removeTemporaryAttribute:@"NSFont" forCharacterRange:NSMakeRange(0, textLength)]; @@ -267,7 +267,7 @@ - (BOOL)textView:(NSTextView*)textView shouldChangeTextInRange:(NSRange)range re [layoutManager setTemporaryAttributes:highlight forCharacterRange:NSMakeRange(match, 1)]; } - + return NO; } else if ( (replacementLength > 0) @@ -275,29 +275,29 @@ - (BOOL)textView:(NSTextView*)textView shouldChangeTextInRange:(NSRange)range re { [textStorage replaceCharactersInRange:NSMakeRange(textLength, 0) withString:replacement]; [_textView setNeedsDisplay:YES]; - + NSString* stringToEvaluate = [self currentLine]; _startOfInput = [self lengthOfTextView]; - + int stringToEvaluateLength = [stringToEvaluate length]; - + if (stringToEvaluateLength > 1) { [_history addObject:[stringToEvaluate substringToIndex:(stringToEvaluateLength - 1)]]; _index = [_history count]; - + NSString* displayString; - + @try { id code = [_parser parse:stringToEvaluate]; - + if (![_parser incomplete]) { _insertionPoint = _startOfInput; id result = [_parser eval:code]; [[[_parser symbolTable] symbolWithString:@"!!"] setValue:result]; - + if ([result respondsToSelector:@selector(escapedStringRepresentation)]) { displayString = [result escapedStringRepresentation]; @@ -309,7 +309,7 @@ - (BOOL)textView:(NSTextView*)textView shouldChangeTextInRange:(NSRange)range re [self write:displayString]; [self write:@"\n"]; - + if (_delegate) { [_delegate commandProcessed:[stringToEvaluate substringToIndex:(stringToEvaluateLength - 1)] @@ -340,7 +340,7 @@ - (BOOL)textView:(NSTextView*)textView shouldChangeTextInRange:(NSRange)range re { _insertionPoint = _startOfInput; } - + [self prompt]; return NO; // we already inserted replacement } @@ -383,7 +383,7 @@ - (BOOL)textView:(NSTextView*)tv doCommandBySelector:(SEL)selector - (void)prompt { int savedInsertionPoint = _insertionPoint; - + if ([_parser incomplete]) { _insertionPoint = _startOfInput; @@ -393,7 +393,7 @@ - (void)prompt { [self write:[NSString stringWithFormat:@"%d > ", ++_promptCounter]]; } - + _insertionPoint = savedInsertionPoint; } diff --git a/src/NutronConsoleWindowController.m b/src/NutronConsoleWindowController.m index da7a1c5..d96f829 100644 --- a/src/NutronConsoleWindowController.m +++ b/src/NutronConsoleWindowController.m @@ -17,7 +17,7 @@ @implementation NutronConsoleWindowController - (id)init { - self = [super initWithWindow:[[NSPanel alloc] + self = [super initWithWindow:[[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 600, 200) styleMask:NSTitledWindowMask | NSClosableWindowMask @@ -32,7 +32,7 @@ - (id)init NSWindow* w = [self window]; NSRect frame = [w frame]; - _console = [[NutronConsoleViewController alloc] + _console = [[NutronConsoleViewController alloc] initWithFrame:frame]; [w setContentView:[_console scrollView]]; diff --git a/src/NutronExtensions.m b/src/NutronExtensions.m index 2e9e982..d0817b8 100644 --- a/src/NutronExtensions.m +++ b/src/NutronExtensions.m @@ -23,7 +23,7 @@ + (NSScrollView*)scrollViewWrappedAroundView:(NSView*)view withFrame:(NSRect)fra [sv setAutoresizingMask:(NSViewHeightSizable | NSViewWidthSizable)]; [sv setAutohidesScrollers:YES]; [sv setDocumentView:view]; - + return [sv autorelease]; } @@ -32,10 +32,10 @@ + (int)scrollerWidth // We'll use overlays in Lion SInt32 major = 0; (void)Gestalt(gestaltSystemVersionMajor, &major); - + SInt32 minor = 0; (void)Gestalt(gestaltSystemVersionMinor, &minor); - + if ((major == 10) && (minor >= 7)) return 0; else @@ -51,9 +51,9 @@ - (int)findOpeningParenForParenAt:(int)position backTo:(int)startOfInput int count = 0; int index = position; BOOL found = NO; - + char c = 0; - + while ((index >= startOfInput) && !found) { c = [[self string] characterAtIndex:index]; @@ -62,15 +62,15 @@ - (int)findOpeningParenForParenAt:(int)position backTo:(int)startOfInput case Nutron_LPAREN: --count; break; - + case Nutron_RPAREN: ++count; break; - + default: break; } - + if (count == 0) { found = YES; @@ -80,7 +80,7 @@ - (int)findOpeningParenForParenAt:(int)position backTo:(int)startOfInput --index; } } - + if (found) return index; else @@ -94,9 +94,9 @@ - (int)findClosingParenForParenAt:(int)position int index = position; int maxIndex = [self length]; BOOL found = NO; - + char c = 0; - + while ((index < maxIndex) && !found) { c = [[self string] characterAtIndex:index]; @@ -106,15 +106,15 @@ - (int)findClosingParenForParenAt:(int)position case Nutron_LPAREN: --count; break; - + case Nutron_RPAREN: ++count; break; - + default: break; } - + if (count == 0) { found = YES; @@ -124,7 +124,7 @@ - (int)findClosingParenForParenAt:(int)position ++index; } } - + if (found) return index; else diff --git a/src/NutronObjectView.m b/src/NutronObjectView.m index 63c50f7..1bf20c8 100644 --- a/src/NutronObjectView.m +++ b/src/NutronObjectView.m @@ -15,7 +15,7 @@ - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; - if (self) + if (self) { } diff --git a/src/NutronObjectViewController.h b/src/NutronObjectViewController.h index 7284ec9..0dcc293 100644 --- a/src/NutronObjectViewController.h +++ b/src/NutronObjectViewController.h @@ -22,7 +22,7 @@ NSScrollView* _scrollView; id _rootObject; - + id _delegate; } diff --git a/src/NutronObjectViewController.m b/src/NutronObjectViewController.m index 66b3706..301992f 100644 --- a/src/NutronObjectViewController.m +++ b/src/NutronObjectViewController.m @@ -31,7 +31,7 @@ - (id)initWithFrame:(NSRect)frame rootObject:(id)object name:(NSString*)name withParent:nil key:name index:-1] retain]; - + _outlineView = [[NutronObjectView alloc] initWithFrame:NSMakeRect(0, 0, frame.size.width, @@ -39,7 +39,7 @@ - (id)initWithFrame:(NSRect)frame rootObject:(id)object name:(NSString*)name [_outlineView setAutoresizingMask:(NSViewHeightSizable | NSViewWidthSizable)]; _scrollView = [[NSScrollView scrollViewWrappedAroundView:_outlineView withFrame:frame] retain]; - + [_outlineView setDelegate:self]; [_outlineView setDataSource:self]; [_outlineView setUsesAlternatingRowBackgroundColors:YES]; @@ -53,33 +53,33 @@ - (id)initWithFrame:(NSRect)frame rootObject:(id)object name:(NSString*)name selector:@selector(outlineViewItemDidExpand:) name:NSOutlineViewItemDidExpandNotification object:_outlineView]; - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(outlineViewItemDidCollapse:) name:NSOutlineViewItemDidCollapseNotification object:_outlineView]; NSTableColumn* tc; - + tc = [[NSTableColumn alloc] initWithIdentifier:@"Key"]; [[tc headerCell] setStringValue:@"Key"]; [tc setWidth:200.0]; [_outlineView addTableColumn:tc]; [_outlineView setOutlineTableColumn:tc]; [tc release]; - + tc = [[NSTableColumn alloc] initWithIdentifier:@"Type"]; [[tc headerCell] setStringValue:@"Type"]; [tc setWidth:200.0]; [_outlineView addTableColumn:tc]; [tc release]; - + tc = [[NSTableColumn alloc] initWithIdentifier:@"Value"]; [[tc headerCell] setStringValue:@"Value"]; [tc setWidth:300.0]; [_outlineView addTableColumn:tc]; [tc release]; - + [_outlineView reloadData]; [_outlineView expandItem:_rootObject]; } @@ -101,31 +101,31 @@ - (void)refreshNoExpand { id object = [_rootObject object]; id key = [_rootObject key]; - + [_rootObject release]; - + _rootObject = [[NutronCachedObject nutronCachedObjectForObject:object withParent:nil key:key index:-1] retain]; - - [_outlineView reloadData]; + + [_outlineView reloadData]; } - (NutronCachedObject*)searchArray:(NSArray*)array forKey:(id)key { int count = [array count]; int i = 0; - + while (i < count) { NutronCachedObject* item = [array objectAtIndex:i]; - + if ([[item key] isEqualTo:key]) return item; ++i; } - + return nil; } @@ -134,12 +134,12 @@ - (NutronCachedObject*)expandNode:(NutronCachedObject*)node selectedItem:(NutronCachedObject*)selectedItem { NutronCachedObject* itemToSelect = nil; - + if (refNode == selectedItem) { itemToSelect = node; } - + if (![refNode isExpanded]) { return itemToSelect; @@ -148,7 +148,7 @@ - (NutronCachedObject*)expandNode:(NutronCachedObject*)node { // Expand this node [_outlineView expandItem:node]; - + NSArray* nodeChildren = [node children]; // Expand each of the children @@ -160,9 +160,9 @@ - (NutronCachedObject*)expandNode:(NutronCachedObject*)node { if ([refChild isExpanded]) { - NutronCachedObject* returnItem = + NutronCachedObject* returnItem = [self expandNode:nodeChild withReferenceNode:refChild selectedItem:selectedItem]; - + if (returnItem) { itemToSelect = returnItem; @@ -186,10 +186,10 @@ - (void)refresh NutronCachedObject* selectedItem = [_outlineView itemAtRow:[_outlineView selectedRow]]; [self refreshNoExpand]; - + // Restore the expansion state of the outline view - NutronCachedObject* itemToSelect = [self expandNode:_rootObject - withReferenceNode:oldRoot + NutronCachedObject* itemToSelect = [self expandNode:_rootObject + withReferenceNode:oldRoot selectedItem:selectedItem]; if (itemToSelect) @@ -210,10 +210,10 @@ - (void)setRootObject:(id)newRoot withKey:(id)newKey { if (newRoot == [_rootObject object]) return; - + [_rootObject setObject:newRoot]; [_rootObject setKey:newKey]; - + [self refreshNoExpand]; [_outlineView expandItem:_rootObject]; @@ -225,13 +225,13 @@ - (void)setRootObject:(id)newRoot withKey:(id)newKey - (BOOL)outlineView:(NSOutlineView*)ov isItemExpandable:(id)item { NutronCachedObject* object = (NutronCachedObject*)item; - + if (object == nil) { return YES; //object = _rootObject; } - + NutronDebug(@"isItemExpandable %@", [object description]); return [object isExpandable]; } @@ -239,7 +239,7 @@ - (BOOL)outlineView:(NSOutlineView*)ov isItemExpandable:(id)item - (NSInteger)outlineView:(NSOutlineView*)ov numberOfChildrenOfItem:(id)item { NutronCachedObject* object = (NutronCachedObject*)item; - + if (object == nil) { //object = _rootObject; @@ -259,7 +259,7 @@ - (id)outlineView:(NSOutlineView *)ov child:(NSInteger)index ofItem:(id)item return _rootObject; //object = _rootObject; } - + NutronDebug(@"child:%d ofItem:%@", index, object); return [object childAtIndex:index]; } @@ -269,7 +269,7 @@ - (id)outlineView:(NSOutlineView *)ov objectValueForTableColumn:(NSTableColumn * NutronDebug(@"objectValueForTableColumn:%@ byItem:%@", tableColumn, item); NutronCachedObject* object = (NutronCachedObject*)item; - + if (object == nil) object = _rootObject; @@ -286,7 +286,7 @@ - (id)outlineView:(NSOutlineView *)ov objectValueForTableColumn:(NSTableColumn * else { id value = [object value]; - + if ([value respondsToSelector:@selector(description)]) return [value description]; else if ([value respondsToSelector:@selector(stringValue)]) diff --git a/src/NutronObjectViewWindowController.m b/src/NutronObjectViewWindowController.m index 579049a..f3427af 100644 --- a/src/NutronObjectViewWindowController.m +++ b/src/NutronObjectViewWindowController.m @@ -23,18 +23,18 @@ - (id)initWithRootObject:(id)object name:(NSString*)name | NSUtilityWindowMask backing:NSBackingStoreBuffered defer:NO]]; - + if (!self) return nil; - + NSWindow* w = [self window]; NSRect frame = [w frame]; - + _objectViewer = [[NutronObjectViewController alloc] - initWithFrame:frame + initWithFrame:frame rootObject:object name:name]; - + [w setContentView:[_objectViewer scrollView]]; [w center]; @@ -53,7 +53,7 @@ - (void)dealloc { [[self window] setDelegate:nil]; [_objectViewer release]; - + [super dealloc]; } diff --git a/src/NutronRuntime.h b/src/NutronRuntime.h index fb467ae..eb67dac 100644 --- a/src/NutronRuntime.h +++ b/src/NutronRuntime.h @@ -28,7 +28,7 @@ typedef enum tagNutronRuntimeMethodType } - (NSString*) mapTypeEncodingToObjcEncoding:(NSString*)encoding; -//- (NSString*) mapObjcEncodingToTypeEncoding:(NSString*)encoding withSuffix:(NSString*)suffix; +//- (NSString*) mapObjcEncodingToTypeEncoding:(NSString*)encoding withSuffix:(NSString*)suffix; - (id) initWithTypeEncoding:(NSString*)encoding; - (NSString*) className; @@ -95,22 +95,22 @@ typedef enum tagNutronRuntimeMethodType { NSString* _name; NSString* _attributes; - + NSString* _typeEncoding; NutronRuntimeType* _runtimeType; - + NSString* _getter; NSString* _setter; - + BOOL _isReadOnly; BOOL _isCopied; BOOL _isRetained; - + BOOL _isNonatomic; - + BOOL _isStrongRef; BOOL _isWeakRef; - + BOOL _isDynamic; BOOL _isSynthesized; NSString* _synthesizedIvar; @@ -155,7 +155,7 @@ typedef enum tagNutronRuntimeMethodType NSString* _name; NSString* _superclassName; NutronRuntimeClass* _superclass; - + NSMutableArray* _ivars; NSMutableArray* _properties; NSMutableArray* _classMethods; diff --git a/src/NutronRuntime.m b/src/NutronRuntime.m index b5aff5f..1c3c239 100644 --- a/src/NutronRuntime.m +++ b/src/NutronRuntime.m @@ -23,7 +23,7 @@ - (NSMutableArray*) toPlist { [a addObject:[item toPlist]]; } - + return a; } @end @@ -40,9 +40,9 @@ @implementation NutronRuntimeType + (NSString*) mapNativeType:(NSString*)typeEncoding { static NSDictionary* typeDictionary = nil; - + if (typeDictionary == nil) - { + { // From Objective-C 2.0 Programming Language, pg. 123 typeDictionary = [[NSDictionary dictionaryWithObjectsAndKeys: @"char", @"c", @@ -79,7 +79,7 @@ - (NSString*) mapTypeEncodingToObjcEncoding:(NSString*)encoding char c = [encoding characterAtIndex:0]; int idx; - switch (c) + switch (c) { case '@': if ([encoding length] == 1) @@ -98,7 +98,7 @@ - (NSString*) mapTypeEncodingToObjcEncoding:(NSString*)encoding // by the objc runtime. objcType = @"void (*functionPtr)()"; else - objcType = [NSString stringWithFormat:@"%@*", + objcType = [NSString stringWithFormat:@"%@*", [self mapTypeEncodingToObjcEncoding: [encoding substringFromIndex:1]]]; break; @@ -117,7 +117,7 @@ - (NSString*) mapTypeEncodingToObjcEncoding:(NSString*)encoding case '{': // struct: {tag="name1"type1"name2"type2} case '(': // union: (tag="name1"type1"name2"type2) - range = [encoding rangeOfString:@"=" + range = [encoding rangeOfString:@"=" options:NSLiteralSearch range:NSMakeRange(1, [encoding length] - 1)]; if (range.location == NSNotFound) @@ -157,10 +157,10 @@ - (NSString*) mapTypeEncodingToObjcEncoding:(NSString*)encoding - (id) initWithTypeEncoding:(NSString*)encoding { self = [super init]; - + if (self == nil) return nil; - + self.typeEncoding = encoding; //[encoding copy]; [self mapTypeEncodingToObjcEncoding:encoding]; @@ -170,7 +170,7 @@ - (id) initWithTypeEncoding:(NSString*)encoding - (NSString*) className { NSString* typecode = [self typeEncoding]; - + if ([typecode characterAtIndex:0] == '@') { if ([typecode length] == 1) @@ -182,7 +182,7 @@ - (NSString*) className { return nil; } - + } - (void) dealloc @@ -199,7 +199,7 @@ - (void)encodeWithCoder:(NSCoder *)coder - (id)initWithCoder:(NSCoder *)coder { self = [super init]; - + if (self == nil) return nil; @@ -220,7 +220,7 @@ - (NSMutableDictionary*) toPlist - (id) initWithPlist:(NSMutableDictionary*) plist { self = [super init]; - + if (self == nil) return nil; @@ -243,7 +243,7 @@ - (id) initWithJSON:(NSString*) json - (NSString*) description { return [NSString stringWithFormat:@"%@ (%@)", - [self typeEncoding], + [self typeEncoding], [self objcEncoding]]; } @@ -263,17 +263,17 @@ @implementation NutronRuntimeIvar - (id) initWithName:(NSString*)aName typeEncoding:(NSString*)aTypeEncoding offset:(long)anOffset { self = [super init]; - + if (self == nil) return nil; // properties = [[NSMutableDictionary alloc] init]; - + // [properties setValue:name forKey:@"name"]; // [properties setValue:typeEncoding forKey:@"typeEncoding"]; // [properties setValue:[NSNumber numberWithLong:offset] forKey:@"offset"]; - -// [properties setValue:[[NutronRuntimeType alloc] initWithTypeEncoding:typeEncoding] + +// [properties setValue:[[NutronRuntimeType alloc] initWithTypeEncoding:typeEncoding] // forKey:@"type"]; self.name = aName; @@ -304,7 +304,7 @@ - (void)encodeWithCoder:(NSCoder *)coder - (id)initWithCoder:(NSCoder *)coder { self = [super init]; - + if (self == nil) return nil; @@ -318,11 +318,11 @@ - (id)initWithCoder:(NSCoder *)coder - (NSMutableDictionary*) toPlist { NSMutableDictionary* d = [NSMutableDictionary dictionary]; - + [d setObject:_name forKey:@"name"]; [d setObject:_typeEncoding forKey:@"typeEncoding"]; [d setObject:[NSNumber numberWithInt:_offset] forKey:@"offset"]; - + return d; } @@ -330,7 +330,7 @@ - (NSMutableDictionary*) toPlist - (id) initWithPlist:(NSMutableDictionary*) plist { self = [super init]; - + if (self == nil) return nil; @@ -344,14 +344,14 @@ - (id) initWithPlist:(NSMutableDictionary*) plist - (NSString*) description { - return [NSString stringWithFormat:@" %@ %@ %@ %d", + return [NSString stringWithFormat:@" %@ %@ %@ %d", _name, _typeEncoding, [_runtimeType description], _offset]; -// [properties valueForKey:@"name"], +// [properties valueForKey:@"name"], // [properties valueForKey:@"typeEncoding"], -// [properties valueForKey:@"type.description"], +// [properties valueForKey:@"type.description"], // [properties valueForKey:@"offset"]]; } @@ -366,9 +366,9 @@ - (NSString*) objcDeclaration { [d appendString:[_runtimeType objcEncodingSuffix]]; } - + [d appendString:@";"]; - + return d; } @@ -383,8 +383,8 @@ - (NSString*) nuDeclaration { [d appendString:[_runtimeType objcEncodingSuffix]]; } - - return d; + + return d; } @end @@ -403,12 +403,12 @@ @implementation NutronRuntimeMethod - (id) init { self = [super init]; - + if (self == nil) return nil; _args = [[NSMutableArray alloc] init]; - + return self; } @@ -433,10 +433,10 @@ - (void)encodeWithCoder:(NSCoder *)coder - (id)initWithCoder:(NSCoder *)coder { self = [super init]; - + if (self == nil) return nil; - + self.name = [coder decodeObjectForKey:@"name"]; // selector = [coder decodeObjectForKey:@"selector"]; self.returnType = [coder decodeObjectForKey:@"returnType"]; @@ -450,7 +450,7 @@ - (id)initWithCoder:(NSCoder *)coder - (NSMutableDictionary*) toPlist { NSMutableDictionary* d = [NSMutableDictionary dictionary]; - + [d setObject:_name forKey:@"name"]; [d setObject:[_returnType toPlist] forKey:@"returnType"]; [d setObject:[NSNumber numberWithInt:_methodType] forKey:@"methodType"]; @@ -463,7 +463,7 @@ - (NSMutableDictionary*) toPlist - (id) initWithPlist:(NSMutableDictionary*) plist { self = [super init]; - + if (self == nil) return nil; @@ -487,14 +487,14 @@ - (void) addArgument:(NutronRuntimeType*)anArg - (NSString*) objcDeclarationRoot { NSMutableString* d = [NSMutableString string]; - + if (_methodType == NutronRuntimeMethodType_Instance) [d appendString:@"- "]; else [d appendString:@"+ "]; - + [d appendFormat:@"(%@) ", [_returnType objcEncoding]]; - + // Parse the method name to intersperse the arguments int idx = 0; int argIdx = 0; @@ -502,7 +502,7 @@ - (NSString*) objcDeclarationRoot int length = [_name length]; while (idx < length) - { + { NSString* fragment; NSRange range= [_name rangeOfString:@":" @@ -518,21 +518,21 @@ - (NSString*) objcDeclarationRoot fragment = [_name substringWithRange:NSMakeRange(idx, range.location - idx)]; idx = range.location + 1; } - + if (argIdx > 0) [d appendFormat:@" "]; [d appendFormat:@"%@", fragment]; - + if (range.location != NSNotFound) { [d appendFormat:@":(%@)arg%d", [[_args objectAtIndex:argIdx] objcEncoding], argIdx + 1]; } - + ++argIdx; } - return d; + return d; } @@ -553,14 +553,14 @@ - (NSString*) objcImplementation - (NSString*) nuDeclarationRoot { NSMutableString* d = [NSMutableString string]; - + if (_methodType == NutronRuntimeMethodType_Instance) [d appendString:@"(- "]; else [d appendString:@"(+ "]; - + [d appendFormat:@"(%@) ", [_returnType objcEncoding]]; - + // Parse the method name to intersperse the arguments int idx = 0; int argIdx = 0; @@ -568,7 +568,7 @@ - (NSString*) nuDeclarationRoot int length = [_name length]; while (idx < length) - { + { NSString* fragment; NSRange range= [_name rangeOfString:@":" @@ -584,17 +584,17 @@ - (NSString*) nuDeclarationRoot fragment = [_name substringWithRange:NSMakeRange(idx, range.location - idx)]; idx = range.location + 1; } - + if (argIdx > 0) [d appendFormat:@" "]; [d appendFormat:@"%@", fragment]; - + if (range.location != NSNotFound) { [d appendFormat:@":(%@)arg%d", [[_args objectAtIndex:argIdx] objcEncoding], argIdx + 1]; } - + ++argIdx; } @@ -612,7 +612,7 @@ - (NSString*) nuDeclaration [d appendString:[self nuDeclarationRoot]]; [d appendString:@" is nil)"]; - + return d; } @@ -624,7 +624,7 @@ - (NSString*) nuImplementation id numethod = [[[NuMethod alloc] initWithMethod:_method] autorelease]; id block = [numethod block]; - + if (block == nil) { [d appendString:@" is nil)"]; @@ -641,15 +641,15 @@ - (NSString*) nuImplementation - (NSString*) description { NSMutableString* d = [NSMutableString string]; - + [d appendFormat:@" (%@) %@", [_returnType objcEncoding], _name]; - + int i; for (i = 0; i < [_args count]; i++) { [d appendFormat:@" (%@)", [[_args objectAtIndex:i] objcEncoding]]; } - + return d; } @@ -677,7 +677,7 @@ @implementation NutronRuntimeProperty - (id) init { self = [super init]; - + if (self == nil) return nil; @@ -703,7 +703,7 @@ - (void)encodeWithCoder:(NSCoder *)coder - (id)initWithCoder:(NSCoder *)coder { self = [super init]; - + if (self == nil) return nil; @@ -717,7 +717,7 @@ - (id)initWithCoder:(NSCoder *)coder - (NSMutableDictionary*) toPlist { NSMutableDictionary* d = [NSMutableDictionary dictionary]; - + [d setObject:_name forKey:@"name"]; [d setObject:_attributes forKey:@"attributes"]; @@ -743,21 +743,21 @@ - (id) initWithPlist:(NSMutableDictionary*) plist - (id) initWithName:(NSString*)aName attributes:(NSString*)theAttributes { self = [super init]; - + if (self == nil) return nil; int idx = 0; int attrLength = [theAttributes length]; //NSLog(@"Property name = %@ attributes[%d] = %@", aName, attrLength, _attributes); - + self.name = aName; self.attributes = theAttributes; - + while (idx < attrLength) { char attribute = [theAttributes characterAtIndex:idx]; - + /* Get the rest of the attribute string, if there is any. */ NSRange range= [_attributes rangeOfString:@"," options:NSLiteralSearch @@ -769,11 +769,11 @@ - (id) initWithName:(NSString*)aName attributes:(NSString*)theAttributes range.location = attrLength; NSString* rest = [theAttributes substringWithRange:NSMakeRange(idx + 1, range.location - idx - 1)]; - - //NSLog(@" idx = %d attribute = %c rest = %@ range = {%d, %d}", + + //NSLog(@" idx = %d attribute = %c rest = %@ range = {%d, %d}", // idx, attribute, rest, range.location, range.length); - - switch (attribute) + + switch (attribute) { case 'T': self.runtimeType = [[[NutronRuntimeType alloc] initWithTypeEncoding:rest] autorelease]; @@ -802,11 +802,11 @@ - (id) initWithName:(NSString*)aName attributes:(NSString*)theAttributes case 'D': _isDynamic = YES; break; - + case '?': _isNonatomic = YES; break; - + case 'G': self.getter = rest; break; @@ -814,20 +814,20 @@ - (id) initWithName:(NSString*)aName attributes:(NSString*)theAttributes case 'S': self.setter = rest; break; - + case 'V': /* synthesized */ _isSynthesized = YES; _isDynamic = NO; /* properties default to Dynamic */ self.synthesizedIvar = rest; break; - + default: break; } - + idx = range.location + 1; } - + return self; } @@ -840,42 +840,42 @@ - (NSString*) objcDeclaration if (_isCopied) [a appendString:@"copy"]; - + if (_isRetained) [a appendString:@"retain"]; - + if (!_isCopied && !_isRetained) [a appendString:@"assign"]; // Default - + if (_isReadOnly) [a appendString:@", readonly"]; else [a appendString:@", readwrite"]; - + if (_isNonatomic) [a appendString:@", nonatomic"]; - + if ([_getter length] > 0) [a appendFormat:@", getter=%@", _getter]; - + if ([_setter length] > 0) [a appendFormat:@", setter=%@", _setter]; - + if (_isStrongRef) [x appendString:@" __strong"]; - + if (_isWeakRef) [x appendString:@" __weak"]; d = [NSString stringWithFormat:@"@property(%@) %@ %@;", a, [_runtimeType objcEncoding], _name]; - + return d; } - (NSString*) objcImplementation { NSMutableString* d = [[[NSMutableString alloc] init] autorelease]; - + if (_isSynthesized) [d appendString:@"@synthesize "]; @@ -883,14 +883,14 @@ - (NSString*) objcImplementation [d appendString:@"@dynamic "]; [d appendString:_name]; - + if (_isSynthesized && ![_synthesizedIvar isEqualToString:_name]) { [d appendFormat:@" = %@", _synthesizedIvar]; } - + [d appendString:@";"]; - + return d; } @@ -910,13 +910,13 @@ @implementation NutronRuntimeProtocol - (id)initWithName:(NSString*)theName { self = [super init]; - + if (self == nil) return nil; self = [super init]; self.name = theName; - + return self; } @@ -933,7 +933,7 @@ - (void)encodeWithCoder:(NSCoder *)coder - (id)initWithCoder:(NSCoder *)coder { self = [super init]; - + if (self == nil) return nil; @@ -946,7 +946,7 @@ - (id)initWithCoder:(NSCoder *)coder - (NSMutableDictionary*) toPlist { NSMutableDictionary* d = [NSMutableDictionary dictionary]; - + [d setObject:_name forKey:@"name"]; return d; @@ -955,7 +955,7 @@ - (NSMutableDictionary*) toPlist - (id) initWithPlist:(NSMutableDictionary*) plist { self = [super init]; - + if (self == nil) return nil; @@ -986,29 +986,29 @@ @implementation NutronRuntimeClass @synthesize classMethods = _classMethods; @synthesize protocols = _protocols; -- (void) buildMethodTable:(NSMutableArray*)table - forMethodType:(NutronRuntimeMethodType)methodType - fromList:(Method*)methodList +- (void) buildMethodTable:(NSMutableArray*)table + forMethodType:(NutronRuntimeMethodType)methodType + fromList:(Method*)methodList withCount:(int)methodCount { int i; int j; - + for (i = 0; i < methodCount; i++) { NutronRuntimeMethod* method = [[[NutronRuntimeMethod alloc] init] autorelease]; - + method.method = methodList[i]; method.name = [NSString stringWithCString:sel_getName(method_getName(methodList[i])) encoding:NSUTF8StringEncoding]; method.selector = method_getName(methodList[i]); method.methodType = methodType; - + char* szReturnType = method_copyReturnType(methodList[i]); method.returnType = [[[NutronRuntimeType alloc] initWithTypeEncoding: [NSString stringWithCString:szReturnType encoding:NSUTF8StringEncoding]] autorelease]; if (szReturnType) free(szReturnType); - + unsigned int argCount = method_getNumberOfArguments(methodList[i]); /* Arguments 0 and 1 are self and the selector number. Skip them. */ for (j = 2; j < argCount; j++) @@ -1017,13 +1017,13 @@ - (void) buildMethodTable:(NSMutableArray*)table NutronRuntimeType* argType = [[[NutronRuntimeType alloc] initWithTypeEncoding: [NSString stringWithCString:szArgType encoding:NSUTF8StringEncoding]] autorelease]; [method addArgument:argType]; - + if (szArgType) free(szArgType); } - + [table addObject:method]; - } + } } @@ -1042,7 +1042,7 @@ - (void)encodeWithCoder:(NSCoder *)coder - (id)initWithCoder:(NSCoder *)coder { self = [super init]; - + if (self == nil) return nil; @@ -1067,13 +1067,13 @@ - (void) dealloc [classMethods removeAllObjects]; [protocols removeAllObjects]; */ - + [_ivars release]; [_properties release]; [_instanceMethods release]; [_classMethods release]; [_protocols release]; - + [super dealloc]; } @@ -1081,22 +1081,22 @@ - (void) dealloc - (id) initWithName:(NSString*) aName { self = [super init]; - + if (self == nil) return nil; int i; - + self.name = aName; const char* szClassName = [aName UTF8String]; Class cls = objc_getClass(szClassName); Class supercls = class_getSuperclass(cls); - _superclassName = [[NSString stringWithCString:class_getName(supercls) + _superclassName = [[NSString stringWithCString:class_getName(supercls) encoding:NSUTF8StringEncoding] retain]; - - + + ////////////////////////////////////////////////////////////////////// Ivar *ivarList = NULL; unsigned int ivarCount; @@ -1111,7 +1111,7 @@ - (id) initWithName:(NSString*) aName encoding:NSUTF8StringEncoding]; long ivarOffset = ivar_getOffset(ivarList[i]); - NutronRuntimeIvar* ivar = [[[NutronRuntimeIvar alloc] + NutronRuntimeIvar* ivar = [[[NutronRuntimeIvar alloc] initWithName:ivarName typeEncoding:ivarTypeEncoding offset:ivarOffset] autorelease]; @@ -1127,7 +1127,7 @@ - (id) initWithName:(NSString*) aName _instanceMethods = [[NSMutableArray alloc] init]; instanceMethodList = class_copyMethodList(cls, &instanceMethodCount); - + [self buildMethodTable:_instanceMethods forMethodType:NutronRuntimeMethodType_Instance fromList:instanceMethodList @@ -1139,10 +1139,10 @@ - (id) initWithName:(NSString*) aName ////////////////////////////////////////////////////////////////////// Method* classMethodList = NULL; unsigned int classMethodCount; - + _classMethods = [[NSMutableArray alloc] init]; classMethodList = class_copyMethodList(object_getClass(cls), &classMethodCount); - + [self buildMethodTable:_classMethods forMethodType:NutronRuntimeMethodType_Class fromList:classMethodList @@ -1150,55 +1150,55 @@ - (id) initWithName:(NSString*) aName if (classMethodList) free(classMethodList); - + ////////////////////////////////////////////////////////////////////// objc_property_t* propertyList = NULL; unsigned int propertyCount; - + _properties = [[NSMutableArray alloc] init]; propertyList = class_copyPropertyList(cls, &propertyCount); - + for (i = 0; i < propertyCount; i++) { NSString* propertyName = [NSString stringWithCString:property_getName(propertyList[i]) encoding:NSUTF8StringEncoding]; NSString* attributes = [NSString stringWithCString:property_getAttributes(propertyList[i]) encoding:NSUTF8StringEncoding]; - - NutronRuntimeProperty* property = + + NutronRuntimeProperty* property = [[[NutronRuntimeProperty alloc] initWithName:propertyName attributes:attributes] autorelease]; [_properties addObject:property]; } - + if (propertyList) free(propertyList); ////////////////////////////////////////////////////////////////////// Protocol** protocolList = NULL; unsigned int protocolCount; - + _protocols = [[NSMutableArray alloc] init]; protocolList = class_copyProtocolList(cls, &protocolCount); - + for (i = 0; i < protocolCount; i++) { - NSString* protocolName = + NSString* protocolName = [NSString stringWithCString:protocol_getName(protocolList[i]) encoding:NSUTF8StringEncoding]; - + /* struct objc_method_description* protocolMethodList = NULL; unsigned int protocolMethodCount; - - protocolMethodList = - protocol_copyMethodDescriptionList(protocolList[i], + + protocolMethodList = + protocol_copyMethodDescriptionList(protocolList[i], YES, // required YES, // instance &protocolMethodCount); - + NSLog(@"protocol: %@ (%d)", protocolName, protocolMethodCount); - + for (j = 0; j < protocolMethodCount; j++) { NSLog(@" Method[%d]: name = %s types = %s", @@ -1206,20 +1206,20 @@ - (id) initWithName:(NSString*) aName protocolMethodList[j].name, protocolMethodList[j].types); } - + if (protocolMethodList) free(protocolMethodList); */ - - NutronRuntimeProtocol* protocol = + + NutronRuntimeProtocol* protocol = [[[NutronRuntimeProtocol alloc] initWithName:protocolName] autorelease]; [_protocols addObject:protocol]; } - + if (protocolList) free(protocolList); - + //jsbjsb // [self dump]; return self; @@ -1231,9 +1231,9 @@ - (NSString*) objcDeclaration // int j; NSMutableString* d = [[[NSMutableString alloc] init] autorelease]; - + [d appendFormat:@"@interface %@", _name]; - + if ([_superclassName length] > 0) [d appendFormat:@" : %@", _superclassName]; @@ -1245,13 +1245,13 @@ - (NSString*) objcDeclaration { if (i > 0) [d appendFormat:@","]; - + [d appendFormat:@" %@", [[_protocols objectAtIndex:i] name]]; } [d appendString:@" >"]; } - + [d appendString:@"\n{\n"]; for (i = 0; i < [_ivars count]; i++) @@ -1260,28 +1260,28 @@ - (NSString*) objcDeclaration } [d appendString:@"}\n\n"]; - + for (i = 0; i < [_properties count]; i++) { [d appendFormat:@"%@\n", [[_properties objectAtIndex:i] objcDeclaration]]; } - + [d appendString:@"\n"]; - + for (i = 0; i < [_classMethods count]; i++) { [d appendFormat:@"%@\n", [[_classMethods objectAtIndex:i] objcDeclaration]]; } [d appendString:@"\n"]; - + for (i = 0; i < [_instanceMethods count]; i++) { [d appendFormat:@"%@\n", [[_instanceMethods objectAtIndex:i] objcDeclaration]]; } [d appendString:@"\n"]; - + [d appendString:@"\n@end"]; return d; @@ -1292,9 +1292,9 @@ - (NSString*) nuDeclaration int i; NSMutableString* d = [[[NSMutableString alloc] init] autorelease]; - + [d appendFormat:@"(class %@", _name]; - + if ([_superclassName length] > 0) [d appendFormat:@" is %@\n", _superclassName]; @@ -1305,21 +1305,21 @@ - (NSString*) nuDeclaration } [d appendString:@" )\n\n"]; - + for (i = 0; i < [_classMethods count]; i++) { [d appendFormat:@" %@\n", [[_classMethods objectAtIndex:i] nuDeclaration]]; } [d appendString:@"\n"]; - + for (i = 0; i < [_instanceMethods count]; i++) { [d appendFormat:@" %@\n", [[_instanceMethods objectAtIndex:i] nuImplementation]]; } [d appendString:@"\n"]; - + [d appendString:@")\n"]; return d; @@ -1337,7 +1337,7 @@ - (void) dump { NSLog(@" %@", [ivar description]); } - + NSLog(@" %lu Class Methods:", [_classMethods count]); for (NutronRuntimeMethod* method in _classMethods) { @@ -1349,14 +1349,14 @@ - (void) dump { NSLog(@" %@", [method description]); } - + NSLog(@" %lu Properties:", [_properties count]); for (NutronRuntimeProperty* property in _properties) { NSLog(@" %@", [property objcDeclaration]); NSLog(@" %@", [property objcImplementation]); } - + NSLog(@" %lu Protocols:", [_protocols count]); for (NutronRuntimeProtocol* protocol in _protocols) { @@ -1368,13 +1368,13 @@ - (void) dump - (id)objectLookup:(NSMutableArray*)array withName:(NSString*)key { int i; - + for (i = 0; i < [array count]; i++) { if ([[[array objectAtIndex:i] name] isEqualToString:key]) return [array objectAtIndex:i]; } - + return nil; } @@ -1411,7 +1411,7 @@ - (NutronRuntimeProtocol*)protocolLookup:(NSString*) key - (NSMutableDictionary*) toPlist { NSMutableDictionary* d = [NSMutableDictionary dictionary]; - + [d setObject:_name forKey:@"classname"]; [d setObject:_superclassName forKey:@"superclassName"]; [d setObject:[_ivars toPlist] forKey:@"ivars"]; @@ -1419,7 +1419,7 @@ - (NSMutableDictionary*) toPlist [d setObject:[_classMethods toPlist] forKey:@"classMethods"]; [d setObject:[_instanceMethods toPlist] forKey:@"instanceMethods"]; [d setObject:[_protocols toPlist] forKey:@"protocols"]; - + return d; } diff --git a/src/NutronView.m b/src/NutronView.m index 3e2d7d5..3cf635d 100644 --- a/src/NutronView.m +++ b/src/NutronView.m @@ -14,7 +14,7 @@ @implementation NutronView - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; - + [self setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; [self setAutoresizesSubviews:YES]; diff --git a/src/NutronViewController.h b/src/NutronViewController.h index bcff874..f4e2086 100644 --- a/src/NutronViewController.h +++ b/src/NutronViewController.h @@ -24,7 +24,7 @@ NSSplitView* _lrSplitView; NSSplitView* _tbSplitView; - + NutronConsoleViewController* _consoleViewer; NutronObjectViewController* _objectViewer; NutronClassOutlineViewController* _classViewer; diff --git a/src/NutronViewController.m b/src/NutronViewController.m index d90d441..c9d452e 100644 --- a/src/NutronViewController.m +++ b/src/NutronViewController.m @@ -21,7 +21,7 @@ @implementation NutronViewController - (id)initWithFrame:(NSRect)frame object:(id)object name:(NSString*)name { self = [super init]; - + if (self == nil) return nil; @@ -36,7 +36,7 @@ - (id)initWithFrame:(NSRect)frame object:(id)object name:(NSString*)name float rightWidth = frame.size.width - leftWidth; float topHeight = frame.size.height * tbSplitRatio - kNutronSplitViewDividerThickness; float bottomHeight = frame.size.height - topHeight; - + // Create the splitter windows, first the left/right _lrSplitView = [[NSSplitView alloc] initWithFrame:NSMakeRect(0, 0, frame.size.width, frame.size.height)]; @@ -45,15 +45,15 @@ - (id)initWithFrame:(NSRect)frame object:(id)object name:(NSString*)name [_lrSplitView setDelegate:self]; [_lrSplitView setVertical:YES]; - - _tbSplitView = [[NSSplitView alloc] + + _tbSplitView = [[NSSplitView alloc] initWithFrame:NSMakeRect(0, 0, leftWidth, frame.size.height)]; [_tbSplitView setDelegate:self]; - + _consoleViewer = [[NutronConsoleViewController alloc] initWithFrame:NSMakeRect(0, 0, leftWidth, bottomHeight)]; [_consoleViewer setDelegate:self]; - + if (object == nil) { // Use the parser's context as default @@ -65,25 +65,25 @@ - (id)initWithFrame:(NSRect)frame object:(id)object name:(NSString*)name _object = [object retain]; _objectName = [name copy]; } - + _objectViewer = [[NutronObjectViewController alloc] initWithFrame:NSMakeRect(0, 0, leftWidth, topHeight) rootObject:_object name:_objectName]; [_objectViewer setDelegate:self]; - + _classViewer = [[NutronClassOutlineViewController alloc] initWithFrame:NSMakeRect(0, 0, rightWidth, frame.size.height) className:[_object className]]; - + [_tbSplitView addSubview:[_objectViewer scrollView]]; [_tbSplitView addSubview:[_consoleViewer scrollView]]; - + [_lrSplitView addSubview:_tbSplitView]; [_lrSplitView addSubview:[_classViewer scrollView]]; - + [_view addSubview:_lrSplitView]; - + return self; } @@ -101,14 +101,14 @@ - (void)dealloc { [_object release]; [_objectName release]; - + [_classViewer release]; [_objectViewer release]; [_consoleViewer release]; [_tbSplitView release]; [_lrSplitView release]; [_view release]; - + [super dealloc]; } @@ -136,7 +136,7 @@ - (void)itemSelectedWithKey:(NSString*)key type:(NSString*)type value:(id)value static const float kNutronSplitViewMinLHSWidth = 100.0; -- (CGFloat)splitView:(NSSplitView *)sv +- (CGFloat)splitView:(NSSplitView *)sv constrainMinCoordinate:(CGFloat)coord ofSubviewAt:(NSInteger)index { @@ -144,7 +144,7 @@ - (CGFloat)splitView:(NSSplitView *)sv } -- (CGFloat)splitView:(NSSplitView *)sv +- (CGFloat)splitView:(NSSplitView *)sv constrainMaxCoordinate:(CGFloat)coord ofSubviewAt:(NSInteger)index { diff --git a/src/NutronViewSelector.m b/src/NutronViewSelector.m index 1d87b10..f1c610d 100644 --- a/src/NutronViewSelector.m +++ b/src/NutronViewSelector.m @@ -25,14 +25,14 @@ @implementation NutronViewSelector - (id)init { self = [super init]; - + return self; } - (void)dealloc { [_selectedView release]; - + [super dealloc]; } @@ -49,7 +49,7 @@ - (id)selectView NSEvent *event; id view; - NSCursor *cursor = [NSCursor crosshairCursor]; + NSCursor *cursor = [NSCursor crosshairCursor]; NSDate *distantFuture = [NSDate distantFuture]; NSRect infoRect = NSMakeRect(0, 0, 290, 100); @@ -67,16 +67,16 @@ - (id)selectView [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; [infoView setDefaultParagraphStyle:paragraphStyle]; - NSPanel *infoWindow = [[[NSPanel alloc] initWithContentRect:infoRect + NSPanel *infoWindow = [[[NSPanel alloc] initWithContentRect:infoRect styleMask:NSHUDWindowMask | NSUtilityWindowMask /*| NSTitledWindowMask*/ - backing:NSBackingStoreBuffered - defer:NO] autorelease]; + backing:NSBackingStoreBuffered + defer:NO] autorelease]; [infoWindow setLevel:NSFloatingWindowLevel]; [infoWindow setContentView:infoView]; - - NSWindow *focusWindow = [[NSWindow alloc] initWithContentRect:NSZeroRect - styleMask:NSBorderlessWindowMask - backing:NSBackingStoreBuffered + + NSWindow *focusWindow = [[NSWindow alloc] initWithContentRect:NSZeroRect + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered defer:NO] ; [focusWindow setBackgroundColor:[NSColor redColor]]; // selectedTextBackgroundColor @@ -84,19 +84,19 @@ - (id)selectView [focusWindow setIgnoresMouseEvents:YES]; [cursor push]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(menuWillSendAction:) - name:NSMenuWillSendActionNotification + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(menuWillSendAction:) + name:NSMenuWillSendActionNotification object:nil]; do - { - [cursor push]; + { + [cursor push]; event = [NSApp nextEventMatchingMask:~0 untilDate:distantFuture inMode:NSEventTrackingRunLoopMode dequeue:YES]; [cursor pop]; if ([event type] == NSMouseMoved) - { - NSInteger windowCount; + { + NSInteger windowCount; NSInteger *windows; view = nil; @@ -108,11 +108,11 @@ - (id)selectView for (unsigned i = 0; i < windowCount; i++) { NSWindow *window = [NSApp windowWithWindowNumber:windows[i]]; - if ( window - && window != focusWindow + if ( window + && window != focusWindow && window != infoWindow) { - view = [[[window contentView] superview] + view = [[[window contentView] superview] hitTest:[window convertScreenToBase:[NSEvent mouseLocation]]]; if (view) @@ -174,8 +174,8 @@ - (id)selectView && !( [event type] == NSKeyDown && [[event characters] characterAtIndex:0] == ESCAPE)); - [[NSNotificationCenter defaultCenter] removeObserver:self - name:NSMenuWillSendActionNotification + [[NSNotificationCenter defaultCenter] removeObserver:self + name:NSMenuWillSendActionNotification object:nil]; [cursor pop]; [[focusWindow parentWindow] removeChildWindow:focusWindow]; @@ -193,7 +193,7 @@ - (id)selectView //[[self window] performSelector:@selector(makeKeyAndOrderFront:) withObject:nil afterDelay:0]; - [NSApp activateIgnoringOtherApps:YES]; + [NSApp activateIgnoringOtherApps:YES]; } return _selectedView; diff --git a/src/NutronWindowController.m b/src/NutronWindowController.m index 34a2cc5..b11474c 100644 --- a/src/NutronWindowController.m +++ b/src/NutronWindowController.m @@ -23,7 +23,7 @@ @implementation NutronWindowController - (id)initWithObject:(id)object andName:(NSString*)name; { - self = [super initWithWindow:[[NSPanel alloc] + self = [super initWithWindow:[[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 1000, 600) styleMask:NSTitledWindowMask | NSClosableWindowMask @@ -51,7 +51,7 @@ - (id)initWithObject:(id)object andName:(NSString*)name; [w setFrameOrigin:NSMakePoint(frame.origin.x, 80)]; [w setMinSize:NSMakeSize(600, 100)]; [w makeKeyAndOrderFront:self]; - + [_viewController postInitSetup]; [self addNutronMenu]; _isShowing = YES; @@ -61,7 +61,7 @@ - (id)initWithObject:(id)object andName:(NSString*)name; NuSymbolTable* symbolTable = [[parser context] objectForKey:SYMBOLS_KEY]; [[symbolTable symbolWithString:@"$$nutron"] setValue:self]; - + return self; } @@ -70,7 +70,7 @@ - (id)initWithParser:(id)parser { self = [self initWithObject:[parser context] andName:@"parser context"]; [_viewController setParser:parser]; - + return self; } @@ -122,13 +122,13 @@ - (void)dealloc { [windowMenu removeItem:_nutronMenuItem]; } - + [_nutronMenuItem release]; } - + [_viewController release]; [[self window] setDelegate:nil]; - + [super dealloc]; }