Revision: 3852
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3852&view=rev
Author:   hofman
Date:     2008-05-06 02:08:06 -0700 (Tue, 06 May 2008)

Log Message:
-----------
Add convenience class factory methods for invocation.

Modified Paths:
--------------
    trunk/SKPSProgressController.m
    trunk/SKSheetController.m
    trunk/Skim.xcodeproj/project.pbxproj

Added Paths:
-----------
    trunk/NSInvocation_SKExtensions.h
    trunk/NSInvocation_SKExtensions.m

Added: trunk/NSInvocation_SKExtensions.h
===================================================================
--- trunk/NSInvocation_SKExtensions.h                           (rev 0)
+++ trunk/NSInvocation_SKExtensions.h   2008-05-06 09:08:06 UTC (rev 3852)
@@ -0,0 +1,45 @@
+//
+//  NSInvocation_SKExtensions.h
+//  Skim
+//
+//  Created by Christiaan Hofman on 5/6/08.
+/*
+ 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>
+
+
[EMAIL PROTECTED] NSInvocation (SKExtensions)
++ (id)invocationWithTarget:(id)target selector:(SEL)selector;
++ (id)invocationWithTarget:(id)target selector:(SEL)selector argument:(void 
*)argument;
[EMAIL PROTECTED]

Added: trunk/NSInvocation_SKExtensions.m
===================================================================
--- trunk/NSInvocation_SKExtensions.m                           (rev 0)
+++ trunk/NSInvocation_SKExtensions.m   2008-05-06 09:08:06 UTC (rev 3852)
@@ -0,0 +1,58 @@
+//
+//  NSInvocation_SKExtensions.m
+//  Skim
+//
+//  Created by Christiaan Hofman on 5/6/08.
+/*
+ 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 "NSInvocation_SKExtensions.h"
+
+
[EMAIL PROTECTED] NSInvocation (SKExtensions)
+
++ (id)invocationWithTarget:(id)target selector:(SEL)selector {
+    NSMethodSignature *ms = [target methodSignatureForSelector:selector];
+    NSInvocation *invocation = [self invocationWithMethodSignature:ms];
+    [invocation setTarget:target];
+    [invocation setSelector:selector];
+    return invocation;
+}
+
++ (id)invocationWithTarget:(id)target selector:(SEL)selector argument:(void 
*)argument {
+    NSInvocation *invocation = [self invocationWithTarget:target 
selector:selector];
+    [invocation setArgument:argument atIndex:2];
+    return invocation;
+}
+
[EMAIL PROTECTED]

Modified: trunk/SKPSProgressController.m
===================================================================
--- trunk/SKPSProgressController.m      2008-05-05 19:50:12 UTC (rev 3851)
+++ trunk/SKPSProgressController.m      2008-05-06 09:08:06 UTC (rev 3852)
@@ -40,6 +40,7 @@
 #import "NSString_SKExtensions.h"
 #import "NSTask_SKExtensions.h"
 #import "Files_SKExtensions.h"
+#import "NSInvocation_SKExtensions.h"
 
 static NSString *SKPSProgressProviderKey = @"provider";
 static NSString *SKPSProgressConsumerKey = @"consumer";
@@ -88,13 +89,8 @@
 {
     id delegate = (id)info;
     if (delegate && [delegate 
respondsToSelector:@selector(conversionCompleted:)]) {
-        NSMethodSignature *ms = [delegate 
methodSignatureForSelector:@selector(conversionCompleted:)];
-        NSInvocation *invocation = [NSInvocation 
invocationWithMethodSignature:ms];
-        [invocation setTarget:delegate];
-        [invocation setSelector:@selector(conversionCompleted:)];
-        
         BOOL val = (success == true);
-        [invocation setArgument:&val atIndex:2];
+        NSInvocation *invocation = [NSInvocation invocationWithTarget:delegate 
selector:@selector(conversionCompleted:) argument:&val];
         [invocation performSelectorOnMainThread:@selector(invoke) 
withObject:nil waitUntilDone:NO];
     }
 }
@@ -169,11 +165,7 @@
  
 - (void)stopModalOnMainThread:(BOOL)success {
     int val = (success ? SKConversionSucceeded : SKConversionFailed);
-    NSMethodSignature *ms = [NSApp 
methodSignatureForSelector:@selector(stopModalWithCode:)];
-    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:ms];
-    [invocation setTarget:NSApp];
-    [invocation setSelector:@selector(stopModalWithCode:)];
-    [invocation setArgument:&val atIndex:2];
+    NSInvocation *invocation = [NSInvocation invocationWithTarget:NSApp 
selector:@selector(stopModalWithCode:) argument:&val];
     [invocation performSelectorOnMainThread:@selector(invoke) withObject:nil 
waitUntilDone:NO];
 }
 
@@ -361,17 +353,13 @@
     NSArray *arguments = [commandName isEqualToString:@"dvipdf"] ? [NSArray 
arrayWithObjects:dviFile, outFile, nil] : [NSArray arrayWithObjects:@"-o", 
outFile, dviFile, nil];
     BOOL success = SKFileExistsAtPath(dviFile);
     
-    NSMethodSignature *ms;
     NSInvocation *invocation;
     
     if (success) {
         
         task = [[NSTask launchedTaskWithLaunchPath:commandPath 
arguments:arguments currentDirectoryPath:[dviFile 
stringByDeletingLastPathComponent]] retain];
         
-        ms = [self methodSignatureForSelector:@selector(conversionStarted)];
-        invocation = [NSInvocation invocationWithMethodSignature:ms];
-        [invocation setTarget:self];
-        [invocation setSelector:@selector(conversionStarted)];
+        invocation = [NSInvocation invocationWithTarget:self 
selector:@selector(conversionStarted)];
         [invocation performSelectorOnMainThread:@selector(invoke) 
withObject:nil waitUntilDone:NO];
         
         if (success) {
@@ -409,11 +397,7 @@
         if (success)
             [pdfData setData:outData];
         
-        ms = [self methodSignatureForSelector:@selector(conversionCompleted:)];
-        invocation = [NSInvocation invocationWithMethodSignature:ms];
-        [invocation setTarget:self];
-        [invocation setSelector:@selector(conversionCompleted:)];
-        [invocation setArgument:&success atIndex:2];
+        invocation = [NSInvocation invocationWithTarget:self 
selector:@selector(conversionCompleted:) argument:&success];
         [invocation performSelectorOnMainThread:@selector(invoke) 
withObject:nil waitUntilDone:NO];
         
         [self stopModalOnMainThread:success];

Modified: trunk/SKSheetController.m
===================================================================
--- trunk/SKSheetController.m   2008-05-05 19:50:12 UTC (rev 3851)
+++ trunk/SKSheetController.m   2008-05-06 09:08:06 UTC (rev 3852)
@@ -39,6 +39,7 @@
 #import "SKSheetController.h"
 #import "SKBookmarkController.h"
 #import "SKBookmark.h"
+#import "NSInvocation_SKExtensions.h"
 
 
 @implementation SKSheetController
@@ -70,12 +71,10 @@
        if(theModalDelegate != nil && theDidEndSelector != NULL){
                NSMethodSignature *signature = [theModalDelegate 
methodSignatureForSelector:theDidEndSelector];
         NSAssert2(nil != signature, @"%@ does not implement %@", 
theModalDelegate, NSStringFromSelector(theDidEndSelector));
-               NSInvocation *invocation = [NSInvocation 
invocationWithMethodSignature:signature];
-               [invocation setSelector:theDidEndSelector];
-               [invocation setArgument:&self atIndex:2];
+               NSInvocation *invocation = [NSInvocation 
invocationWithTarget:theModalDelegate selector:theDidEndSelector 
argument:&self];
                [invocation setArgument:&returnCode atIndex:3];
                [invocation setArgument:&theContextInfo atIndex:4];
-               [invocation invokeWithTarget:theModalDelegate];
+               [invocation invoke];
        }
 }
 

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2008-05-05 19:50:12 UTC (rev 
3851)
+++ trunk/Skim.xcodeproj/project.pbxproj        2008-05-06 09:08:06 UTC (rev 
3852)
@@ -47,6 +47,7 @@
                CE07158B0B8A3D6500733CC8 /* NoteDocument.icns in Resources */ = 
{isa = PBXBuildFile; fileRef = CE0715890B8A3D6300733CC8 /* NoteDocument.icns 
*/; };
                CE07158C0B8A3D6500733CC8 /* PDFDocument.icns in Resources */ = 
{isa = PBXBuildFile; fileRef = CE07158A0B8A3D6300733CC8 /* PDFDocument.icns */; 
};
                CE0859D20DAE912500760AFC /* SKSnapshotPageCell.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CE0859D10DAE912500760AFC /* 
SKSnapshotPageCell.m */; };
+               CE0EB4D60DD054DC0034DF92 /* NSInvocation_SKExtensions.m in 
Sources */ = {isa = PBXBuildFile; fileRef = CE0EB4D50DD054DC0034DF92 /* 
NSInvocation_SKExtensions.m */; };
                CE199DFD0D957A16009B2055 /* SKAnnotationTypeImageCell.m in 
Sources */ = {isa = PBXBuildFile; fileRef = CE199DFC0D957A16009B2055 /* 
SKAnnotationTypeImageCell.m */; };
                CE1ADB280C4BC6DE00071840 /* OpenGL.framework in Frameworks */ = 
{isa = PBXBuildFile; fileRef = CE1ADB170C4BC6DE00071840 /* OpenGL.framework */; 
};
                CE1ADEBF0C4C341100071840 /* SKTransitionController.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = CE1ADEBE0C4C341100071840 /* 
SKTransitionController.m */; };
@@ -421,6 +422,8 @@
                CE07158A0B8A3D6300733CC8 /* PDFDocument.icns */ = {isa = 
PBXFileReference; lastKnownFileType = image.icns; name = PDFDocument.icns; path 
= Images/PDFDocument.icns; sourceTree = "<group>"; };
                CE0859D00DAE912500760AFC /* SKSnapshotPageCell.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKSnapshotPageCell.h; sourceTree = "<group>"; };
                CE0859D10DAE912500760AFC /* SKSnapshotPageCell.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKSnapshotPageCell.m; sourceTree = "<group>"; };
+               CE0EB4D40DD054DC0034DF92 /* NSInvocation_SKExtensions.h */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; 
path = NSInvocation_SKExtensions.h; sourceTree = "<group>"; };
+               CE0EB4D50DD054DC0034DF92 /* NSInvocation_SKExtensions.m */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; path = NSInvocation_SKExtensions.m; sourceTree = "<group>"; 
};
                CE199DFB0D957A16009B2055 /* SKAnnotationTypeImageCell.h */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; 
path = SKAnnotationTypeImageCell.h; sourceTree = "<group>"; };
                CE199DFC0D957A16009B2055 /* SKAnnotationTypeImageCell.m */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; path = SKAnnotationTypeImageCell.m; sourceTree = "<group>"; 
};
                CE1ADB170C4BC6DE00071840 /* OpenGL.framework */ = {isa = 
PBXFileReference; lastKnownFileType = wrapper.framework; name = 
OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; 
sourceTree = "<absolute>"; };
@@ -1099,6 +1102,8 @@
                                CEF839B10C77742A00A3AD51 /* 
Files_SKExtensions.m */,
                                CE5BEA160C7C635400EBDCF7 /* 
NSGeometry_SKExtensions.h */,
                                CE5BEA170C7C635400EBDCF7 /* 
NSGeometry_SKExtensions.m */,
+                               CE0EB4D40DD054DC0034DF92 /* 
NSInvocation_SKExtensions.h */,
+                               CE0EB4D50DD054DC0034DF92 /* 
NSInvocation_SKExtensions.m */,
                                CE6C03EE0BEDF759007BF0B5 /* 
NSParagraphStyle_SKExtensions.h */,
                                CE6C03EF0BEDF759007BF0B5 /* 
NSParagraphStyle_SKExtensions.m */,
                                CE1E301A0BDB9D5C0011D9DD /* 
NSScanner_SKExtensions.h */,
@@ -2047,6 +2052,7 @@
                                CEE177960DBE140900E6C317 /* 
SKAccessibilityProxyElement.m in Sources */,
                                CECB03D30DC7503A0000B16B /* 
SKGroupedSearchResult.m in Sources */,
                                CEEC0A0A0DCB2594003DD9B6 /* 
SKMainWindowController_UI.m in Sources */,
+                               CE0EB4D60DD054DC0034DF92 /* 
NSInvocation_SKExtensions.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };


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 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to