Revision: 4276 http://skim-app.svn.sourceforge.net/skim-app/?rev=4276&view=rev Author: hofman Date: 2008-07-22 13:30:36 +0000 (Tue, 22 Jul 2008)
Log Message: ----------- Rename files for method swizzling Modified Paths: -------------- trunk/NSCell_SKExtensions.m trunk/NSCharacterSet_SKExtensions.m trunk/NSScrollView_SKExtensions.m trunk/NSURL_SKExtensions.m trunk/PDFAnnotationLink_SKExtensions.m trunk/PDFAnnotationMarkup_SKExtensions.m trunk/PDFDisplayView_SKExtensions.m trunk/PDFDocument_SKExtensions.m trunk/PDFPage_SKExtensions.m trunk/SKApplicationController.m trunk/SKBookmark.m trunk/SKBookmarkController.m trunk/SKColorSwatch.m trunk/SKDocumentController.m trunk/SKFindTableView.m trunk/SKFontWell.m trunk/SKInfoWindowController.m trunk/SKLineWell.m trunk/SKMainWindowController.m trunk/SKNoteWindowController.m trunk/SKPDFView.m trunk/SKSnapshotPageCell.m trunk/SKSnapshotWindowController.m trunk/SKTemplateParser.m trunk/SKThumbnailTableView.m trunk/SKTypeSelectHelper.m trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/NSObject_SKExtensions.h trunk/NSObject_SKExtensions.m Removed Paths: ------------- trunk/SKUtilities.h trunk/SKUtilities.m Modified: trunk/NSCell_SKExtensions.m =================================================================== --- trunk/NSCell_SKExtensions.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/NSCell_SKExtensions.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -39,7 +39,7 @@ */ #import "NSCell_SKExtensions.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" @implementation NSCell (SKExtensions) Modified: trunk/NSCharacterSet_SKExtensions.m =================================================================== --- trunk/NSCharacterSet_SKExtensions.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/NSCharacterSet_SKExtensions.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -37,7 +37,7 @@ */ #import "NSCharacterSet_SKExtensions.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" @implementation NSCharacterSet (SKExtensions) Copied: trunk/NSObject_SKExtensions.h (from rev 4275, trunk/SKUtilities.h) =================================================================== --- trunk/NSObject_SKExtensions.h (rev 0) +++ trunk/NSObject_SKExtensions.h 2008-07-22 13:30:36 UTC (rev 4276) @@ -0,0 +1,66 @@ +// +// NSObject_SKExtensions.h +// Skim +// +// Created by Christiaan Hofman on 2/15/07. +/* + This software is Copyright (c) 2008 + Christiaan Hofman. All rights reserved. + + 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 + 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 + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + 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 POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + +#define OBINITIALIZE \ + do { \ + static BOOL hasBeenInitialized = NO; \ + [super initialize]; \ + if (hasBeenInitialized) \ + return; \ + hasBeenInitialized = YES;\ + } while (0); + + [EMAIL PROTECTED] NSObject (SKExtensions) + ++ (IMP)replaceMethodForSelector:(SEL)aSelector withMethod:(IMP)anImp; ++ (IMP)replaceInstanceMethodForSelector:(SEL)aSelector withMethod:(IMP)anImp; ++ (IMP)replaceMethodForSelector:(SEL)aSelector withMethodFromSelector:(SEL)impSelector; ++ (IMP)replaceInstanceMethodForSelector:(SEL)aSelector withInstanceMethodFromSelector:(SEL)impSelector; + ++ (void)exchangeMethodForSelector:(SEL)aSelector withMethodForSelector:(SEL)otherSelector; ++ (void)exchangeInstanceMethodForSelector:(SEL)aSelector withInstanceMethodForSelector:(SEL)otherSelector; + ++ (void)addMethod:(IMP)anImp typeEncoding:(const char *)types forSelector:(SEL)aSelector; ++ (void)addInstanceMethod:(IMP)anImp typeEncoding:(const char *)types forSelector:(SEL)aSelector; ++ (void)addMethodFromSelector:(SEL)impSelector forSelector:(SEL)aSelector; ++ (void)addInstanceMethodFromSelector:(SEL)impSelector forSelector:(SEL)aSelector; + [EMAIL PROTECTED] Copied: trunk/NSObject_SKExtensions.m (from rev 4275, trunk/SKUtilities.m) =================================================================== --- trunk/NSObject_SKExtensions.m (rev 0) +++ trunk/NSObject_SKExtensions.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -0,0 +1,204 @@ +// +// NSObject_SKExtensions.m +// Skim +// +// Created by Christiaan Hofman on 2/15/07. + +/* Some of the following functions are inspired by OmniBase/NSObject_SKExtensions.h and subject to the following copyright */ + +// Copyright 1997-2008 Omni Development, Inc. All rights reserved. +// +// This software may only be used and reproduced according to the +// terms in the file OmniSourceLicense.html, which should be +// distributed with this project and can also be found at +// <http://www.omnigroup.com/developer/sourcecode/sourcelicense/>. + +#import "NSObject_SKExtensions.h" +#import <Foundation/Foundation.h> +#import <objc/objc.h> +#import <objc/objc-class.h> +#import <objc/objc-runtime.h> + + +// wrappers around 10.5 only functions, use 10.4 API when the function is not defined + +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 + +extern void _objc_flush_caches(Class); + +static Class SK_object_getClass(id object) +{ + return object_getClass != NULL ? object_getClass(object) : object->isa; +} + +static IMP SK_method_getImplementation(Method aMethod) +{ + return method_getImplementation != NULL ? method_getImplementation(aMethod) : aMethod->method_imp; +} + +static IMP SK_method_setImplementation(Method aMethod, IMP anImp) +{ + if (method_setImplementation != NULL) { + return method_setImplementation(aMethod, anImp); + } else { + IMP oldImp = aMethod->method_imp; + aMethod->method_imp = anImp; + return oldImp; + } +} + +static const char *SK_method_getTypeEncoding(Method aMethod) +{ + return method_getTypeEncoding != NULL ? method_getTypeEncoding(aMethod) : aMethod->method_types; +} + +static Class SK_class_getSuperclass(Class aClass) +{ + return class_getSuperclass != NULL ? class_getSuperclass(aClass) : aClass->super_class; +} + +static void SK_class_addMethod(Class aClass, SEL selector, IMP methodImp, const char *methodTypes) +{ + if (class_addMethod != NULL) { + class_addMethod(aClass, selector, methodImp, methodTypes); + } else { + struct objc_method_list *newMethodList; + + newMethodList = (struct objc_method_list *) NSZoneMalloc(NSDefaultMallocZone(), sizeof(struct objc_method_list)); + + newMethodList->method_count = 1; + newMethodList->method_list[0].method_name = selector; + newMethodList->method_list[0].method_imp = methodImp; + newMethodList->method_list[0].method_types = (char *)methodTypes; + + class_addMethods(aClass, newMethodList); + + // Flush the method cache + _objc_flush_caches(aClass); + } +} + +#else + +static Class SK_object_getClass(id object) +{ + return object_getClass(object); +} + +static IMP SK_method_getImplementation(Method aMethod) +{ + return method_getImplementation(aMethod); +} + +static IMP SK_method_setImplementation(Method aMethod, IMP anImp) +{ + return method_setImplementation(aMethod, anImp); +} + +static const char *SK_method_getTypeEncoding(Method aMethod) +{ + return method_getTypeEncoding(aMethod); +} + +static Class SK_class_getSuperclass(Class aClass) +{ + return class_getSuperclass(aClass); +} + +static void SK_class_addMethod(Class aClass, SEL selector, IMP methodImp, const char *methodTypes) +{ + class_addMethod(aClass, selector, methodImp, methodTypes); +} + +#endif + +static Method SK_class_getMethod(Class aClass, SEL aSelector, BOOL isInstance) +{ + return isInstance ? class_getInstanceMethod(aClass, aSelector) : class_getClassMethod(aClass, aSelector); +} + +static IMP SKReplaceMethodImplementation(Class aClass, SEL aSelector, IMP anImp, BOOL isInstance) +{ + Method superMethod = NULL; + Method localMethod = SK_class_getMethod(aClass, aSelector, isInstance); + IMP oldImp = NULL; + Class superCls = Nil; + Class realClass = isInstance ? aClass : SK_object_getClass(aClass); + + if (localMethod) { + if (superCls = SK_class_getSuperclass(aClass)) + superMethod = SK_class_getMethod(superCls, aSelector, isInstance); + + if (superMethod == localMethod) { + // We are inheriting this method from the superclass. We do *not* want to clobber the superclass's Method structure as that would replace the implementation on a greater scope than the caller wanted. In this case, install a new method at this class and return the superclass's implementation as the old implementation (which it is). + oldImp = SK_method_getImplementation(localMethod); + SK_class_addMethod(realClass, aSelector, anImp, SK_method_getTypeEncoding(localMethod)); + } else { + // Replace the method in place + oldImp = SK_method_setImplementation(localMethod, anImp); + // We don't need to flush the method cach because the cache contains pointers to the Methods, so the cache is automatically updated + // See <http://kevin.sb.org/2006/11/16/objective-c-caching-and-method-swizzling/> + } + } + + return oldImp; +} + +static void SKRegisterMethodImplementation(Class aClass, SEL aSelector, IMP anImp, const char *types, BOOL isInstance) +{ + Class realClass = isInstance ? aClass : SK_object_getClass(aClass); + SK_class_addMethod(realClass, aSelector, anImp, types); +} + +static void SKRegisterMethodImplementationWithSelector(Class aClass, SEL aSelector, SEL impSelector, BOOL isInstance) +{ + Method method = SK_class_getMethod(aClass, impSelector, isInstance); + if (method) + SKRegisterMethodImplementation(aClass, aSelector, SK_method_getImplementation(method), SK_method_getTypeEncoding(method), isInstance); +} + [EMAIL PROTECTED] NSObject (SKExtensions) + ++ (IMP)replaceMethodForSelector:(SEL)aSelector withMethod:(IMP)anImp { + return SKReplaceMethodImplementation(self, aSelector, anImp, NO); +} + ++ (IMP)replaceInstanceMethodForSelector:(SEL)aSelector withMethod:(IMP)anImp { + return SKReplaceMethodImplementation(self, aSelector, anImp, YES); +} + ++ (IMP)replaceMethodForSelector:(SEL)aSelector withMethodFromSelector:(SEL)impSelector { + return [self replaceMethodForSelector:aSelector withMethod:[self methodForSelector:impSelector]]; +} + ++ (IMP)replaceInstanceMethodForSelector:(SEL)aSelector withInstanceMethodFromSelector:(SEL)impSelector { + return [self replaceInstanceMethodForSelector:aSelector withMethod:[self instanceMethodForSelector:impSelector]]; +} + ++ (void)exchangeMethodForSelector:(SEL)aSelector withMethodForSelector:(SEL)otherSelector { + IMP imp = [self replaceMethodForSelector:aSelector withMethodFromSelector:otherSelector]; + [self replaceMethodForSelector:otherSelector withMethod:imp]; +} + ++ (void)exchangeInstanceMethodForSelector:(SEL)aSelector withInstanceMethodForSelector:(SEL)otherSelector { + IMP imp = [self replaceInstanceMethodForSelector:aSelector withInstanceMethodFromSelector:otherSelector]; + [self replaceInstanceMethodForSelector:otherSelector withMethod:imp]; +} + ++ (void)addMethod:(IMP)anImp typeEncoding:(const char *)types forSelector:(SEL)aSelector { + SKRegisterMethodImplementation(self, aSelector, anImp, types, NO); +} + ++ (void)addInstanceMethod:(IMP)anImp typeEncoding:(const char *)types forSelector:(SEL)aSelector { + SKRegisterMethodImplementation(self, aSelector, anImp, types, YES); +} + ++ (void)addMethodFromSelector:(SEL)impSelector forSelector:(SEL)aSelector { + SKRegisterMethodImplementationWithSelector(self, aSelector, impSelector, NO); +} + ++ (void)addInstanceMethodFromSelector:(SEL)impSelector forSelector:(SEL)aSelector { + SKRegisterMethodImplementationWithSelector(self, aSelector, impSelector, YES); +} + [EMAIL PROTECTED] Modified: trunk/NSScrollView_SKExtensions.m =================================================================== --- trunk/NSScrollView_SKExtensions.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/NSScrollView_SKExtensions.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -37,7 +37,7 @@ */ #import "NSScrollView_SKExtensions.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #import "BDSKEdgeView.h" Modified: trunk/NSURL_SKExtensions.m =================================================================== --- trunk/NSURL_SKExtensions.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/NSURL_SKExtensions.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -37,7 +37,7 @@ */ #import "NSURL_SKExtensions.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" NSString *SKWeblocFilePboardType = @"CorePasteboardFlavorType 0x75726C20"; Modified: trunk/PDFAnnotationLink_SKExtensions.m =================================================================== --- trunk/PDFAnnotationLink_SKExtensions.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/PDFAnnotationLink_SKExtensions.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -37,7 +37,7 @@ */ #import "PDFAnnotationLink_SKExtensions.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" @interface PDFAnnotationLink (SKLeopardPrivate) Modified: trunk/PDFAnnotationMarkup_SKExtensions.m =================================================================== --- trunk/PDFAnnotationMarkup_SKExtensions.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/PDFAnnotationMarkup_SKExtensions.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -46,7 +46,7 @@ #import "NSUserDefaults_SKExtensions.h" #import "NSGeometry_SKExtensions.h" #import "SKCFCallbacks.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" NSString *SKPDFAnnotationSelectionSpecifierKey = @"selectionSpecifier"; Modified: trunk/PDFDisplayView_SKExtensions.m =================================================================== --- trunk/PDFDisplayView_SKExtensions.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/PDFDisplayView_SKExtensions.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -42,7 +42,7 @@ #import "PDFAnnotation_SKExtensions.h" #import "NSAttributedString_SKExtensions.h" #import "SKPDFDocument.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #import "SKAccessibilityProxyElement.h" @interface NSView (SKPDFDisplayViewprivateDeclarations) Modified: trunk/PDFDocument_SKExtensions.m =================================================================== --- trunk/PDFDocument_SKExtensions.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/PDFDocument_SKExtensions.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -38,7 +38,7 @@ #import "PDFDocument_SKExtensions.h" #import "PDFSelection_SKExtensions.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" @interface PDFDocument (SKPrivateDeclarations) Modified: trunk/PDFPage_SKExtensions.m =================================================================== --- trunk/PDFPage_SKExtensions.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/PDFPage_SKExtensions.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -42,7 +42,7 @@ #import "SKPDFDocument.h" #import "SKPDFView.h" #import "PDFSelection_SKExtensions.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #import "NSBitmapImageRep_SKExtensions.h" #import "SKStringConstants.h" #import "NSCharacterSet_SKExtensions.h" Modified: trunk/SKApplicationController.m =================================================================== --- trunk/SKApplicationController.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKApplicationController.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -65,7 +65,7 @@ #import "Files_SKExtensions.h" #import "NSTask_SKExtensions.h" #import "NSView_SKExtensions.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #import <SkimNotes/PDFAnnotation_SKNExtensions.h> #import "PDFAnnotation_SKExtensions.h" #import "PDFAnnotationLine_SKExtensions.h" Modified: trunk/SKBookmark.m =================================================================== --- trunk/SKBookmark.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKBookmark.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -39,7 +39,7 @@ #import "SKBookmark.h" #import "BDAlias.h" #import "NSImage_SKExtensions.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" NSString *SKBookmarkChangedNotification = @"SKBookmarkChangedNotification"; NSString *SKBookmarkWillBeRemovedNotification = @"SKBookmarkWillBeRemovedNotification"; Modified: trunk/SKBookmarkController.m =================================================================== --- trunk/SKBookmarkController.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKBookmarkController.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -50,7 +50,7 @@ #import "SKToolbarItem.h" #import "NSImage_SKExtensions.h" #import "SKStringConstants.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" static NSString *SKBookmarkRowsPboardType = @"SKBookmarkRowsPboardType"; Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKColorSwatch.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -37,7 +37,7 @@ */ #import "SKColorSwatch.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #import "NSColor_SKExtensions.h" #import <Carbon/Carbon.h> Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKDocumentController.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -43,7 +43,7 @@ #import "NSString_SKExtensions.h" #import "NSURL_SKExtensions.h" #import "SKStringConstants.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #import "SKApplicationController.h" static NSString *SKAutosaveIntervalKey = @"SKAutosaveInterval"; Modified: trunk/SKFindTableView.m =================================================================== --- trunk/SKFindTableView.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKFindTableView.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -38,7 +38,7 @@ #import "SKFindTableView.h" #import "SKStringConstants.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" @implementation SKFindTableView Modified: trunk/SKFontWell.m =================================================================== --- trunk/SKFontWell.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKFontWell.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -37,7 +37,7 @@ */ #import "SKFontWell.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" static NSString *SKNSFontPanelDescriptorsPboardType = @"NSFontPanelDescriptorsPboardType"; static NSString *SKNSFontPanelFamiliesPboardType = @"NSFontPanelFamiliesPboardType"; Modified: trunk/SKInfoWindowController.m =================================================================== --- trunk/SKInfoWindowController.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKInfoWindowController.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -39,7 +39,7 @@ #import "SKInfoWindowController.h" #import "SKPDFDocument.h" #import <Quartz/Quartz.h> -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" static NSString *SKInfoWindowFrameAutosaveName = @"SKInfoWindow"; Modified: trunk/SKLineWell.m =================================================================== --- trunk/SKLineWell.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKLineWell.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -38,7 +38,7 @@ #import "SKLineWell.h" #import "SKLineInspector.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" NSString *SKLineStylePboardType = @"SKLineStylePboardType"; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKMainWindowController.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -88,7 +88,7 @@ #import "SKSecondaryPDFView.h" #import "SKSheetController.h" #import "SKColorSwatch.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #import "SKApplicationController.h" #import "SKCFCallbacks.h" #import "NSSegmentedControl_SKExtensions.h" Modified: trunk/SKNoteWindowController.m =================================================================== --- trunk/SKNoteWindowController.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKNoteWindowController.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -48,7 +48,7 @@ #import "NSWindowController_SKExtensions.h" #import "NSUserDefaultsController_SKExtensions.h" #import "SKStringConstants.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #import "PDFPage_SKExtensions.h" static NSString *SKNoteWindowFrameAutosaveName = @"SKNoteWindow"; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKPDFView.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -61,7 +61,7 @@ #import <Carbon/Carbon.h> #import "NSGeometry_SKExtensions.h" #import "SKTypeSelectHelper.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #import "NSAffineTransform_SKExtensions.h" #import "BDSKEdgeView.h" #import "PDFDocument_SKExtensions.h" Modified: trunk/SKSnapshotPageCell.m =================================================================== --- trunk/SKSnapshotPageCell.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKSnapshotPageCell.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -37,7 +37,7 @@ */ #import "SKSnapshotPageCell.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" NSString *SKSnapshotPageCellLabelKey = @"label"; NSString *SKSnapshotPageCellHasWindowKey = @"hasWindow"; Modified: trunk/SKSnapshotWindowController.m =================================================================== --- trunk/SKSnapshotWindowController.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKSnapshotWindowController.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -50,7 +50,7 @@ #import "NSGeometry_SKExtensions.h" #import "PDFPage_SKExtensions.h" #import "SKSnapshotPageCell.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" NSString *SKSnapshotCurrentSetupKey = @"currentSetup"; Modified: trunk/SKTemplateParser.m =================================================================== --- trunk/SKTemplateParser.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKTemplateParser.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -40,7 +40,7 @@ #import "SKTag.h" #import "NSCharacterSet_SKExtensions.h" #import "NSString_SKExtensions.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #define START_TAG_OPEN_DELIM @"<$" #define END_TAG_OPEN_DELIM @"</$" Modified: trunk/SKThumbnailTableView.m =================================================================== --- trunk/SKThumbnailTableView.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKThumbnailTableView.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -37,7 +37,7 @@ */ #import "SKThumbnailTableView.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" #import "SKTypeSelectHelper.h" #import "NSColor_SKExtensions.h" Modified: trunk/SKTypeSelectHelper.m =================================================================== --- trunk/SKTypeSelectHelper.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKTypeSelectHelper.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -37,7 +37,7 @@ */ #import "SKTypeSelectHelper.h" -#import "SKUtilities.h" +#import "NSObject_SKExtensions.h" static NSString *SKWindowDidChangeFirstResponderNotification = @"SKWindowDidChangeFirstResponderNotification"; Deleted: trunk/SKUtilities.h =================================================================== --- trunk/SKUtilities.h 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKUtilities.h 2008-07-22 13:30:36 UTC (rev 4276) @@ -1,66 +0,0 @@ -// -// SKUtilities.h -// Skim -// -// Created by Christiaan Hofman on 2/15/07. -/* - This software is Copyright (c) 2008 - Christiaan Hofman. All rights reserved. - - 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 - 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 - the documentation and/or other materials provided with the - distribution. - - - Neither the name of Christiaan Hofman nor the names of any - 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 POSSIBILITY OF SUCH DAMAGE. - */ - -#import <Cocoa/Cocoa.h> - -#define OBINITIALIZE \ - do { \ - static BOOL hasBeenInitialized = NO; \ - [super initialize]; \ - if (hasBeenInitialized) \ - return; \ - hasBeenInitialized = YES;\ - } while (0); - - [EMAIL PROTECTED] NSObject (SKExtensions) - -+ (IMP)replaceMethodForSelector:(SEL)aSelector withMethod:(IMP)anImp; -+ (IMP)replaceInstanceMethodForSelector:(SEL)aSelector withMethod:(IMP)anImp; -+ (IMP)replaceMethodForSelector:(SEL)aSelector withMethodFromSelector:(SEL)impSelector; -+ (IMP)replaceInstanceMethodForSelector:(SEL)aSelector withInstanceMethodFromSelector:(SEL)impSelector; - -+ (void)exchangeMethodForSelector:(SEL)aSelector withMethodForSelector:(SEL)otherSelector; -+ (void)exchangeInstanceMethodForSelector:(SEL)aSelector withInstanceMethodForSelector:(SEL)otherSelector; - -+ (void)addMethod:(IMP)anImp typeEncoding:(const char *)types forSelector:(SEL)aSelector; -+ (void)addInstanceMethod:(IMP)anImp typeEncoding:(const char *)types forSelector:(SEL)aSelector; -+ (void)addMethodFromSelector:(SEL)impSelector forSelector:(SEL)aSelector; -+ (void)addInstanceMethodFromSelector:(SEL)impSelector forSelector:(SEL)aSelector; - [EMAIL PROTECTED] Deleted: trunk/SKUtilities.m =================================================================== --- trunk/SKUtilities.m 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/SKUtilities.m 2008-07-22 13:30:36 UTC (rev 4276) @@ -1,204 +0,0 @@ -// -// SKUtilities.m -// Skim -// -// Created by Christiaan Hofman on 2/15/07. - -/* Some of the following functions are inspired by OmniBase/SKUtilities.h and subject to the following copyright */ - -// Copyright 1997-2008 Omni Development, Inc. All rights reserved. -// -// This software may only be used and reproduced according to the -// terms in the file OmniSourceLicense.html, which should be -// distributed with this project and can also be found at -// <http://www.omnigroup.com/developer/sourcecode/sourcelicense/>. - -#import "SKUtilities.h" -#import <Foundation/Foundation.h> -#import <objc/objc.h> -#import <objc/objc-class.h> -#import <objc/objc-runtime.h> - - -// wrappers around 10.5 only functions, use 10.4 API when the function is not defined - -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - -extern void _objc_flush_caches(Class); - -static Class SK_object_getClass(id object) -{ - return object_getClass != NULL ? object_getClass(object) : object->isa; -} - -static IMP SK_method_getImplementation(Method aMethod) -{ - return method_getImplementation != NULL ? method_getImplementation(aMethod) : aMethod->method_imp; -} - -static IMP SK_method_setImplementation(Method aMethod, IMP anImp) -{ - if (method_setImplementation != NULL) { - return method_setImplementation(aMethod, anImp); - } else { - IMP oldImp = aMethod->method_imp; - aMethod->method_imp = anImp; - return oldImp; - } -} - -static const char *SK_method_getTypeEncoding(Method aMethod) -{ - return method_getTypeEncoding != NULL ? method_getTypeEncoding(aMethod) : aMethod->method_types; -} - -static Class SK_class_getSuperclass(Class aClass) -{ - return class_getSuperclass != NULL ? class_getSuperclass(aClass) : aClass->super_class; -} - -static void SK_class_addMethod(Class aClass, SEL selector, IMP methodImp, const char *methodTypes) -{ - if (class_addMethod != NULL) { - class_addMethod(aClass, selector, methodImp, methodTypes); - } else { - struct objc_method_list *newMethodList; - - newMethodList = (struct objc_method_list *) NSZoneMalloc(NSDefaultMallocZone(), sizeof(struct objc_method_list)); - - newMethodList->method_count = 1; - newMethodList->method_list[0].method_name = selector; - newMethodList->method_list[0].method_imp = methodImp; - newMethodList->method_list[0].method_types = (char *)methodTypes; - - class_addMethods(aClass, newMethodList); - - // Flush the method cache - _objc_flush_caches(aClass); - } -} - -#else - -static Class SK_object_getClass(id object) -{ - return object_getClass(object); -} - -static IMP SK_method_getImplementation(Method aMethod) -{ - return method_getImplementation(aMethod); -} - -static IMP SK_method_setImplementation(Method aMethod, IMP anImp) -{ - return method_setImplementation(aMethod, anImp); -} - -static const char *SK_method_getTypeEncoding(Method aMethod) -{ - return method_getTypeEncoding(aMethod); -} - -static Class SK_class_getSuperclass(Class aClass) -{ - return class_getSuperclass(aClass); -} - -static void SK_class_addMethod(Class aClass, SEL selector, IMP methodImp, const char *methodTypes) -{ - class_addMethod(aClass, selector, methodImp, methodTypes); -} - -#endif - -static Method SK_class_getMethod(Class aClass, SEL aSelector, BOOL isInstance) -{ - return isInstance ? class_getInstanceMethod(aClass, aSelector) : class_getClassMethod(aClass, aSelector); -} - -static IMP SKReplaceMethodImplementation(Class aClass, SEL aSelector, IMP anImp, BOOL isInstance) -{ - Method superMethod = NULL; - Method localMethod = SK_class_getMethod(aClass, aSelector, isInstance); - IMP oldImp = NULL; - Class superCls = Nil; - Class realClass = isInstance ? aClass : SK_object_getClass(aClass); - - if (localMethod) { - if (superCls = SK_class_getSuperclass(aClass)) - superMethod = SK_class_getMethod(superCls, aSelector, isInstance); - - if (superMethod == localMethod) { - // We are inheriting this method from the superclass. We do *not* want to clobber the superclass's Method structure as that would replace the implementation on a greater scope than the caller wanted. In this case, install a new method at this class and return the superclass's implementation as the old implementation (which it is). - oldImp = SK_method_getImplementation(localMethod); - SK_class_addMethod(realClass, aSelector, anImp, SK_method_getTypeEncoding(localMethod)); - } else { - // Replace the method in place - oldImp = SK_method_setImplementation(localMethod, anImp); - // We don't need to flush the method cach because the cache contains pointers to the Methods, so the cache is automatically updated - // See <http://kevin.sb.org/2006/11/16/objective-c-caching-and-method-swizzling/> - } - } - - return oldImp; -} - -static void SKRegisterMethodImplementation(Class aClass, SEL aSelector, IMP anImp, const char *types, BOOL isInstance) -{ - Class realClass = isInstance ? aClass : SK_object_getClass(aClass); - SK_class_addMethod(realClass, aSelector, anImp, types); -} - -static void SKRegisterMethodImplementationWithSelector(Class aClass, SEL aSelector, SEL impSelector, BOOL isInstance) -{ - Method method = SK_class_getMethod(aClass, impSelector, isInstance); - if (method) - SKRegisterMethodImplementation(aClass, aSelector, SK_method_getImplementation(method), SK_method_getTypeEncoding(method), isInstance); -} - [EMAIL PROTECTED] NSObject (SKExtensions) - -+ (IMP)replaceMethodForSelector:(SEL)aSelector withMethod:(IMP)anImp { - return SKReplaceMethodImplementation(self, aSelector, anImp, NO); -} - -+ (IMP)replaceInstanceMethodForSelector:(SEL)aSelector withMethod:(IMP)anImp { - return SKReplaceMethodImplementation(self, aSelector, anImp, YES); -} - -+ (IMP)replaceMethodForSelector:(SEL)aSelector withMethodFromSelector:(SEL)impSelector { - return [self replaceMethodForSelector:aSelector withMethod:[self methodForSelector:impSelector]]; -} - -+ (IMP)replaceInstanceMethodForSelector:(SEL)aSelector withInstanceMethodFromSelector:(SEL)impSelector { - return [self replaceInstanceMethodForSelector:aSelector withMethod:[self instanceMethodForSelector:impSelector]]; -} - -+ (void)exchangeMethodForSelector:(SEL)aSelector withMethodForSelector:(SEL)otherSelector { - IMP imp = [self replaceMethodForSelector:aSelector withMethodFromSelector:otherSelector]; - [self replaceMethodForSelector:otherSelector withMethod:imp]; -} - -+ (void)exchangeInstanceMethodForSelector:(SEL)aSelector withInstanceMethodForSelector:(SEL)otherSelector { - IMP imp = [self replaceInstanceMethodForSelector:aSelector withInstanceMethodFromSelector:otherSelector]; - [self replaceInstanceMethodForSelector:otherSelector withMethod:imp]; -} - -+ (void)addMethod:(IMP)anImp typeEncoding:(const char *)types forSelector:(SEL)aSelector { - SKRegisterMethodImplementation(self, aSelector, anImp, types, NO); -} - -+ (void)addInstanceMethod:(IMP)anImp typeEncoding:(const char *)types forSelector:(SEL)aSelector { - SKRegisterMethodImplementation(self, aSelector, anImp, types, YES); -} - -+ (void)addMethodFromSelector:(SEL)impSelector forSelector:(SEL)aSelector { - SKRegisterMethodImplementationWithSelector(self, aSelector, impSelector, NO); -} - -+ (void)addInstanceMethodFromSelector:(SEL)impSelector forSelector:(SEL)aSelector { - SKRegisterMethodImplementationWithSelector(self, aSelector, impSelector, YES); -} - [EMAIL PROTECTED] Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2008-07-22 13:24:49 UTC (rev 4275) +++ trunk/Skim.xcodeproj/project.pbxproj 2008-07-22 13:30:36 UTC (rev 4276) @@ -39,7 +39,7 @@ 8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; }; CE0463CB0B84D24300C11E4A /* SKApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = CE0463CA0B84D24300C11E4A /* SKApplication.m */; }; - CE0464A20B84E3E400C11E4A /* SKUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = CE0464A10B84E3E400C11E4A /* SKUtilities.m */; }; + CE0464A20B84E3E400C11E4A /* NSObject_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE0464A10B84E3E400C11E4A /* NSObject_SKExtensions.m */; }; CE070EA20B89039700733CC8 /* NSScrollView_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE070EA10B89039700733CC8 /* NSScrollView_SKExtensions.m */; }; CE0710170B89BDD600733CC8 /* BDSKCollapsibleView.m in Sources */ = {isa = PBXBuildFile; fileRef = CE0710120B89BDD600733CC8 /* BDSKCollapsibleView.m */; }; CE0710180B89BDD600733CC8 /* BDSKContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = CE0710140B89BDD600733CC8 /* BDSKContainerView.m */; }; @@ -444,8 +444,8 @@ A489FDE70BC8E94200BA14DD /* Italian */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = Italian; path = Italian.lproj/ZoomValues.strings; sourceTree = "<group>"; }; CE0463C90B84D24300C11E4A /* SKApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKApplication.h; sourceTree = "<group>"; }; CE0463CA0B84D24300C11E4A /* SKApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKApplication.m; sourceTree = "<group>"; }; - CE0464A00B84E3E400C11E4A /* SKUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKUtilities.h; sourceTree = "<group>"; }; - CE0464A10B84E3E400C11E4A /* SKUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKUtilities.m; sourceTree = "<group>"; }; + CE0464A00B84E3E400C11E4A /* NSObject_SKExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSObject_SKExtensions.h; sourceTree = "<group>"; }; + CE0464A10B84E3E400C11E4A /* NSObject_SKExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSObject_SKExtensions.m; sourceTree = "<group>"; }; CE070EA00B89039700733CC8 /* NSScrollView_SKExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSScrollView_SKExtensions.h; sourceTree = "<group>"; }; CE070EA10B89039700733CC8 /* NSScrollView_SKExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSScrollView_SKExtensions.m; sourceTree = "<group>"; }; CE0710110B89BDD600733CC8 /* BDSKCollapsibleView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = BDSKCollapsibleView.h; sourceTree = "<group>"; }; @@ -1033,7 +1033,6 @@ 45B113BF0B329A7E00DE0660 /* LICENSE */, 2A37F4ABFDCFA73011CA2CEA /* Classes */, 453DC2740B4F23E500A72509 /* Third Party Sources */, - CE2DE4D40B85DA1C00D0DA12 /* Miscellaneous */, 2A37F4AFFDCFA73011CA2CEA /* Other Sources */, CE4DA8CF0B9E157E0039E89C /* Help Sources */, 2A37F4B8FDCFA73011CA2CEA /* Resources */, @@ -1059,6 +1058,7 @@ CE070EC10B89063400733CC8 /* Foundation Categories */, CEE1776D0DBDF54000E6C317 /* AppKit Categories */, CEE177700DBDF60500E6C317 /* PDFKit Categories */, + CE2DE4D40B85DA1C00D0DA12 /* Miscellaneous */, ); name = Classes; sourceTree = "<group>"; @@ -1154,6 +1154,8 @@ CE0EB4D50DD054DC0034DF92 /* NSInvocation_SKExtensions.m */, CE3401E40E01388700A7FFE6 /* NSNumber_SKExtensions.h */, CE3401E50E01388700A7FFE6 /* NSNumber_SKExtensions.m */, + CE0464A00B84E3E400C11E4A /* NSObject_SKExtensions.h */, + CE0464A10B84E3E400C11E4A /* NSObject_SKExtensions.m */, CE6C03EE0BEDF759007BF0B5 /* NSParagraphStyle_SKExtensions.h */, CE6C03EF0BEDF759007BF0B5 /* NSParagraphStyle_SKExtensions.m */, CE1E301A0BDB9D5C0011D9DD /* NSScanner_SKExtensions.h */, @@ -1376,8 +1378,6 @@ CE64E8A20D92E670000AD050 /* SKCFCallBacks.m */, 45A3BD060B4F0770002B297F /* SKStringConstants.h */, 45A3BD070B4F0770002B297F /* SKStringConstants.m */, - CE0464A00B84E3E400C11E4A /* SKUtilities.h */, - CE0464A10B84E3E400C11E4A /* SKUtilities.m */, CE5BD6710C7ADF1500EBDCF7 /* SKTypeSelectHelper.h */, CE5BD6720C7ADF1500EBDCF7 /* SKTypeSelectHelper.m */, CEE54F8E0DA3FE9A0037169F /* SKUnarchiveFromDataArrayTransformer.h */, @@ -2006,7 +2006,7 @@ CE38ECD30B8093B200A1B779 /* NSString_SKExtensions.m in Sources */, F9CDD67B0B837A7F006363C3 /* SKPreferenceController.m in Sources */, CE0463CB0B84D24300C11E4A /* SKApplication.m in Sources */, - CE0464A20B84E3E400C11E4A /* SKUtilities.m in Sources */, + CE0464A20B84E3E400C11E4A /* NSObject_SKExtensions.m in Sources */, CE2DE4920B85D48F00D0DA12 /* SKThumbnail.m in Sources */, CE2DE49D0B85D4F400D0DA12 /* SKFullScreenWindow.m in Sources */, CE2DE4C60B85D78200D0DA12 /* SKMiniaturizeWindow.m in Sources */, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit