Revision: 3617 http://skim-app.svn.sourceforge.net/skim-app/?rev=3617&view=rev Author: hofman Date: 2008-04-04 09:46:30 -0700 (Fri, 04 Apr 2008)
Log Message: ----------- Change order of implementations to avoid declaring replacement methods. Modified Paths: -------------- trunk/NSCell_SKExtensions.h trunk/NSCell_SKExtensions.m trunk/NSScrollView_SKExtensions.m trunk/NSURL_SKExtensions.m trunk/PDFDocument_SKExtensions.m trunk/PDFPage_SKExtensions.m trunk/SKFindTableView.m trunk/SKPDFView.m trunk/SKThumbnailTableView.m trunk/SKTypeSelectHelper.m Modified: trunk/NSCell_SKExtensions.h =================================================================== --- trunk/NSCell_SKExtensions.h 2008-04-04 16:32:21 UTC (rev 3616) +++ trunk/NSCell_SKExtensions.h 2008-04-04 16:46:30 UTC (rev 3617) @@ -42,5 +42,4 @@ @interface NSCell (SKExtensions) -- (NSColor *)replacementHighlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; @end Modified: trunk/NSCell_SKExtensions.m =================================================================== --- trunk/NSCell_SKExtensions.m 2008-04-04 16:32:21 UTC (rev 3616) +++ trunk/NSCell_SKExtensions.m 2008-04-04 16:46:30 UTC (rev 3617) @@ -47,10 +47,6 @@ static IMP originalHighlightColorWithFrameInView = NULL; -+ (void)load { - originalHighlightColorWithFrameInView = OBReplaceMethodImplementationWithSelector(self, @selector(highlightColorWithFrame:inView:), @selector(replacementHighlightColorWithFrame:inView:)); -} - - (NSColor *)replacementHighlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { if ([controlView respondsToSelector:@selector(highlightColor)]) return [(id)controlView highlightColor]; @@ -58,4 +54,8 @@ return originalHighlightColorWithFrameInView(self, _cmd, cellFrame, controlView); } ++ (void)load { + originalHighlightColorWithFrameInView = OBReplaceMethodImplementationWithSelector(self, @selector(highlightColorWithFrame:inView:), @selector(replacementHighlightColorWithFrame:inView:)); +} + @end Modified: trunk/NSScrollView_SKExtensions.m =================================================================== --- trunk/NSScrollView_SKExtensions.m 2008-04-04 16:32:21 UTC (rev 3616) +++ trunk/NSScrollView_SKExtensions.m 2008-04-04 16:46:30 UTC (rev 3617) @@ -41,17 +41,6 @@ #import "BDSKEdgeView.h" [EMAIL PROTECTED] NSScrollView (SKPrivateExtensions) - -- (BOOL)replacementHasHorizontalScroller; -- (BOOL)replacementHasVerticalScroller; -- (void)replacementSetHasHorizontalScroller:(BOOL)flag; -- (void)replacementSetHasVerticalScroller:(BOOL)flag; -- (void)replacementDealloc; -- (void)replacementTile; - [EMAIL PROTECTED] - @implementation NSScrollView (SKExtensions) static IMP originalSetHasHorizontalScroller = NULL; @@ -67,22 +56,6 @@ static CFMutableSetRef scrollViewsWithoutVerticalScrollers = NULL; static CFMutableDictionaryRef scrollViewSubcontrols = NULL; -+ (void)load{ - originalSetHasHorizontalScroller = OBReplaceMethodImplementationWithSelector(self, @selector(setHasHorizontalScroller:), @selector(replacementSetHasHorizontalScroller:)); - originalSetHasVerticalScroller = OBReplaceMethodImplementationWithSelector(self, @selector(setHasVerticalScroller:), @selector(replacementSetHasVerticalScroller:)); - originalHasHorizontalScroller = (typeof(originalHasHorizontalScroller))OBReplaceMethodImplementationWithSelector(self, @selector(hasHorizontalScroller), @selector(replacementHasHorizontalScroller)); - originalHasVerticalScroller = (typeof(originalHasVerticalScroller))OBReplaceMethodImplementationWithSelector(self, @selector(hasVerticalScroller), @selector(replacementHasVerticalScroller)); - originalDealloc = OBReplaceMethodImplementationWithSelector(self, @selector(dealloc), @selector(replacementDealloc)); - originalTile = OBReplaceMethodImplementationWithSelector(self, @selector(tile), @selector(replacementTile)); - - // set doesn't retain, so no retain cycles; pointer equality used to compare views - scrollViewsWithHorizontalScrollers = CFSetCreateMutable(CFAllocatorGetDefault(), 0, NULL); - scrollViewsWithoutHorizontalScrollers = CFSetCreateMutable(CFAllocatorGetDefault(), 0, NULL); - scrollViewsWithVerticalScrollers = CFSetCreateMutable(CFAllocatorGetDefault(), 0, NULL); - scrollViewsWithoutVerticalScrollers = CFSetCreateMutable(CFAllocatorGetDefault(), 0, NULL); - scrollViewSubcontrols = CFDictionaryCreateMutable(CFAllocatorGetDefault(), 0, NULL, &kCFTypeDictionaryValueCallBacks); -} - - (void)replacementDealloc; { CFSetRemoveValue(scrollViewsWithHorizontalScrollers, self); @@ -209,6 +182,21 @@ } } ++ (void)load{ + originalSetHasHorizontalScroller = OBReplaceMethodImplementationWithSelector(self, @selector(setHasHorizontalScroller:), @selector(replacementSetHasHorizontalScroller:)); + originalSetHasVerticalScroller = OBReplaceMethodImplementationWithSelector(self, @selector(setHasVerticalScroller:), @selector(replacementSetHasVerticalScroller:)); + originalHasHorizontalScroller = (typeof(originalHasHorizontalScroller))OBReplaceMethodImplementationWithSelector(self, @selector(hasHorizontalScroller), @selector(replacementHasHorizontalScroller)); + originalHasVerticalScroller = (typeof(originalHasVerticalScroller))OBReplaceMethodImplementationWithSelector(self, @selector(hasVerticalScroller), @selector(replacementHasVerticalScroller)); + originalDealloc = OBReplaceMethodImplementationWithSelector(self, @selector(dealloc), @selector(replacementDealloc)); + originalTile = OBReplaceMethodImplementationWithSelector(self, @selector(tile), @selector(replacementTile)); + + // set doesn't retain, so no retain cycles; pointer equality used to compare views + scrollViewsWithHorizontalScrollers = CFSetCreateMutable(CFAllocatorGetDefault(), 0, NULL); + scrollViewsWithoutHorizontalScrollers = CFSetCreateMutable(CFAllocatorGetDefault(), 0, NULL); + scrollViewsWithVerticalScrollers = CFSetCreateMutable(CFAllocatorGetDefault(), 0, NULL); + scrollViewsWithoutVerticalScrollers = CFSetCreateMutable(CFAllocatorGetDefault(), 0, NULL); + scrollViewSubcontrols = CFDictionaryCreateMutable(CFAllocatorGetDefault(), 0, NULL, &kCFTypeDictionaryValueCallBacks); +} - (NSArray *)subcontrols { return (NSArray *)CFDictionaryGetValue(scrollViewSubcontrols, self); Modified: trunk/NSURL_SKExtensions.m =================================================================== --- trunk/NSURL_SKExtensions.m 2008-04-04 16:32:21 UTC (rev 3616) +++ trunk/NSURL_SKExtensions.m 2008-04-04 16:46:30 UTC (rev 3617) @@ -41,21 +41,11 @@ NSString *SKWeblocFilePboardType = @"CorePasteboardFlavorType 0x75726C20"; [EMAIL PROTECTED] NSURL (SKPrivateExtensions) -- (id)replacementInitFileURLWithPath:(NSString *)path; -- (id)replacementInitWithString:(NSString *)URLString; [EMAIL PROTECTED] - @implementation NSURL (SKExtensions) static IMP originalInitFileURLWithPath = NULL; static IMP originalInitWithString = NULL; -+ (void)load { - originalInitFileURLWithPath = OBReplaceMethodImplementationWithSelector(self, @selector(initFileURLWithPath:), @selector(replacementInitFileURLWithPath:)); - originalInitWithString = OBReplaceMethodImplementationWithSelector(self, @selector(initWithString:), @selector(replacementInitWithString:)); -} - - (id)replacementInitFileURLWithPath:(NSString *)path { return path == nil ? nil : originalInitFileURLWithPath(self, _cmd, path); } @@ -64,6 +54,11 @@ return URLString == nil ? nil : originalInitWithString(self, _cmd, URLString); } ++ (void)load { + originalInitFileURLWithPath = OBReplaceMethodImplementationWithSelector(self, @selector(initFileURLWithPath:), @selector(replacementInitFileURLWithPath:)); + originalInitWithString = OBReplaceMethodImplementationWithSelector(self, @selector(initWithString:), @selector(replacementInitWithString:)); +} + + (NSURL *)URLFromPasteboardAnyType:(NSPasteboard *)pasteboard { NSString *pboardType = [pasteboard availableTypeFromArray:[NSArray arrayWithObjects:SKWeblocFilePboardType, NSURLPboardType, NSStringPboardType, nil]]; NSURL *theURL = nil; Modified: trunk/PDFDocument_SKExtensions.m =================================================================== --- trunk/PDFDocument_SKExtensions.m 2008-04-04 16:32:21 UTC (rev 3616) +++ trunk/PDFDocument_SKExtensions.m 2008-04-04 16:46:30 UTC (rev 3617) @@ -46,23 +46,10 @@ @end [EMAIL PROTECTED] PDFDocument (SKPrivateExtensions) -- (NSPrintOperation *)replacementGetPrintOperationForPrintInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)autoRotate; -- (void)replacementCleanupAfterPrintOperation:(NSPrintOperation *)printOperation; [EMAIL PROTECTED] - - @implementation PDFDocument (SKExtensions) static IMP originalGetPrintOperationForPrintInfo = NULL; -+ (void)load { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - if ([self instancesRespondToSelector:@selector(getPrintOperationForPrintInfo:autoRotate:)]) - originalGetPrintOperationForPrintInfo = OBReplaceMethodImplementationWithSelector(self, @selector(getPrintOperationForPrintInfo:autoRotate:), @selector(replacementGetPrintOperationForPrintInfo:autoRotate:)); - [pool release]; -} - - (NSPrintOperation *)replacementGetPrintOperationForPrintInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)autoRotate { NSPrintOperation *printOperation = originalGetPrintOperationForPrintInfo(self, _cmd, printInfo, autoRotate); BOOL suppressPrintPanel = [[[[printOperation printInfo] dictionary] objectForKey:@"SKSuppressPrintPanel"] boolValue]; @@ -86,6 +73,13 @@ return printOperation; } ++ (void)load { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + if ([self instancesRespondToSelector:@selector(getPrintOperationForPrintInfo:autoRotate:)]) + originalGetPrintOperationForPrintInfo = OBReplaceMethodImplementationWithSelector(self, @selector(getPrintOperationForPrintInfo:autoRotate:), @selector(replacementGetPrintOperationForPrintInfo:autoRotate:)); + [pool release]; +} + - (PDFSelection *)selectionByExtendingSelection:(PDFSelection *)selection toPage:(PDFPage *)page atPoint:(NSPoint)point { PDFSelection *sel = selection; NSArray *pages = [selection pages]; Modified: trunk/PDFPage_SKExtensions.m =================================================================== --- trunk/PDFPage_SKExtensions.m 2008-04-04 16:32:21 UTC (rev 3616) +++ trunk/PDFPage_SKExtensions.m 2008-04-04 16:46:30 UTC (rev 3617) @@ -46,17 +46,13 @@ #import "SKStringConstants.h" #import "NSCharacterSet_SKExtensions.h" #import "NSGeometry_SKExtensions.h" -#import "SKCFDictionaryCallBacks.h" +#import "SKCFCallBacks.h" NSString *SKPDFDocumentPageBoundsDidChangeNotification = @"SKPDFDocumentPageBoundsDidChangeNotification"; static NSString *SKAutoCropBoxMarginWidthKey = @"SKAutoCropBoxMarginWidth"; static NSString *SKAutoCropBoxMarginHeightKey = @"SKAutoCropBoxMarginHeight"; [EMAIL PROTECTED] PDFPage (SKReplacementMethods) -- (void)replacementDealloc; [EMAIL PROTECTED] - @implementation PDFPage (SKExtensions) #define FOREGROUND_BOX_MARGIN 10.0 @@ -65,16 +61,16 @@ static CFMutableDictionaryRef bboxCache = NULL; static IMP originalDealloc = NULL; -+ (void)load { - originalDealloc = OBReplaceMethodImplementationWithSelector(self, @selector(dealloc), @selector(replacementDealloc)); - bboxCache = CFDictionaryCreateMutable(NULL, 0, NULL, &SKNSRectDictionaryValueCallbacks); -} - - (void)replacementDealloc { CFDictionaryRemoveValue(bboxCache, self); originalDealloc(self, _cmd); } ++ (void)load { + originalDealloc = OBReplaceMethodImplementationWithSelector(self, @selector(dealloc), @selector(replacementDealloc)); + bboxCache = CFDictionaryCreateMutable(NULL, 0, NULL, &SKNSRectDictionaryValueCallbacks); +} + // mainly useful for drawing the box in a PDFView while debugging - (NSRect)foregroundBox { Modified: trunk/SKFindTableView.m =================================================================== --- trunk/SKFindTableView.m 2008-04-04 16:32:21 UTC (rev 3616) +++ trunk/SKFindTableView.m 2008-04-04 16:46:30 UTC (rev 3617) @@ -151,17 +151,12 @@ #pragma mark - @interface NSLevelIndicatorCell (SKExtensions) -- (void)replacementDrawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; @end @implementation NSLevelIndicatorCell (SKExtensions) static IMP originalDrawWithFrameInView = NULL; -+ (void)load { - originalDrawWithFrameInView = OBReplaceMethodImplementationWithSelector(self, @selector(drawWithFrame:inView:), @selector(replacementDrawWithFrame:inView:)); -} - // Drawing does not restrict the clip, while in discrete style it heavily uses gaussian blur, leading to unacceptable slow drawing // see <http://toxicsoftware.com/discrete-nslevelindicatorcell-too-slow/> - (void)replacementDrawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { @@ -176,4 +171,8 @@ [self setLevelIndicatorStyle:NSDiscreteCapacityLevelIndicatorStyle]; } ++ (void)load { + originalDrawWithFrameInView = OBReplaceMethodImplementationWithSelector(self, @selector(drawWithFrame:inView:), @selector(replacementDrawWithFrame:inView:)); +} + @end Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2008-04-04 16:32:21 UTC (rev 3616) +++ trunk/SKPDFView.m 2008-04-04 16:46:30 UTC (rev 3617) @@ -3894,18 +3894,12 @@ @end @interface PDFDisplayView (SKExtensions) -- (void)replacementPasswordEntered:(id)sender; @end @implementation PDFDisplayView (SKExtensions) static IMP originalPasswordEntered = NULL; -+ (void)load { - if ([self instancesRespondToSelector:@selector(passwordEntered:)]) - originalPasswordEntered = OBReplaceMethodImplementationWithSelector(self, @selector(passwordEntered:), @selector(replacementPasswordEntered:)); -} - - (void)replacementPasswordEntered:(id)sender { SKDocument *document = [[[self window] windowController] document]; originalPasswordEntered(self, _cmd, sender); @@ -3913,4 +3907,9 @@ [document savePasswordInKeychain:[sender stringValue]]; } ++ (void)load { + if ([self instancesRespondToSelector:@selector(passwordEntered:)]) + originalPasswordEntered = OBReplaceMethodImplementationWithSelector(self, @selector(passwordEntered:), @selector(replacementPasswordEntered:)); +} + @end Modified: trunk/SKThumbnailTableView.m =================================================================== --- trunk/SKThumbnailTableView.m 2008-04-04 16:32:21 UTC (rev 3616) +++ trunk/SKThumbnailTableView.m 2008-04-04 16:46:30 UTC (rev 3617) @@ -45,23 +45,22 @@ static NSString *SKScrollerDidScrollNotification = @"SKScrollerDidScrollNotification"; @interface NSScroller (SKExtensions) -- (void)replacementTrackKnob:(NSEvent *)theEvent; @end @implementation NSScroller (SKExtensions) static IMP originalTrackKnob = NULL; -+ (void)load { - originalTrackKnob = OBReplaceMethodImplementationWithSelector(self, @selector(trackKnob:), @selector(replacementTrackKnob:)); -} - - (void)replacementTrackKnob:(NSEvent *)theEvent { [[NSNotificationCenter defaultCenter] postNotificationName:SKScrollerWillScrollNotification object:self]; originalTrackKnob(self, _cmd, theEvent); [[NSNotificationCenter defaultCenter] postNotificationName:SKScrollerDidScrollNotification object:self]; } ++ (void)load { + originalTrackKnob = OBReplaceMethodImplementationWithSelector(self, @selector(trackKnob:), @selector(replacementTrackKnob:)); +} + @end @implementation SKThumbnailTableView Modified: trunk/SKTypeSelectHelper.m =================================================================== --- trunk/SKTypeSelectHelper.m 2008-04-04 16:32:21 UTC (rev 3616) +++ trunk/SKTypeSelectHelper.m 2008-04-04 16:46:30 UTC (rev 3617) @@ -48,10 +48,6 @@ - (BOOL)containsStringStartingAtWord:(NSString *)string options:(int)mask range:(NSRange)range; @end [EMAIL PROTECTED] NSWindow (SKTypeAheadHelperExtensions) -- (BOOL)replacementMakeFirstResponder:(NSResponder *)aResponder; [EMAIL PROTECTED] - #pragma mark - @interface SKTypeSelectHelper (SKPrivate) @@ -416,14 +412,13 @@ #pragma mark - [EMAIL PROTECTED] NSWindow (SKTypeAheadHelperExtensions) [EMAIL PROTECTED] + @implementation NSWindow (SKTypeAheadHelperExtensions) static BOOL (*originalMakeFirstResponder)(id, SEL, id) = NULL; -+ (void)load { - originalMakeFirstResponder = (typeof(originalMakeFirstResponder))OBReplaceMethodImplementationWithSelector(self, @selector(makeFirstResponder:), @selector(replacementMakeFirstResponder:)); -} - - (BOOL)replacementMakeFirstResponder:(NSResponder *)aResponder { id oldFirstResponder = [self firstResponder]; BOOL success = originalMakeFirstResponder(self, _cmd, aResponder); @@ -432,4 +427,8 @@ return success; } ++ (void)load { + originalMakeFirstResponder = (typeof(originalMakeFirstResponder))OBReplaceMethodImplementationWithSelector(self, @selector(makeFirstResponder:), @selector(replacementMakeFirstResponder:)); +} + @end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit