Revision: 5786
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5786&view=rev
Author:   hofman
Date:     2009-09-22 23:56:35 +0000 (Tue, 22 Sep 2009)

Log Message:
-----------
rename a class factory method for pointer functions

Modified Paths:
--------------
    trunk/NSPointerFunctions_SKExtensions.h
    trunk/NSPointerFunctions_SKExtensions.m
    trunk/PDFAnnotationMarkup_SKExtensions.m
    trunk/PDFSelection_SKExtensions.m
    trunk/SKMainWindowController.m
    trunk/SKNotesDocument.m
    trunk/SKPDFSyncRecord.m
    trunk/SKPDFSynchronizerServer.m
    trunk/Skim.xcodeproj/project.pbxproj

Modified: trunk/NSPointerFunctions_SKExtensions.h
===================================================================
--- trunk/NSPointerFunctions_SKExtensions.h     2009-09-22 23:54:03 UTC (rev 
5785)
+++ trunk/NSPointerFunctions_SKExtensions.h     2009-09-22 23:56:35 UTC (rev 
5786)
@@ -41,7 +41,7 @@
 
 @interface NSPointerFunctions (SKExtensions)
 
-+ (id)strongObjectsPointerFunctions;
++ (id)strongObjectPointerFunctions;
 + (id)integerPointerFunctions;
 + (id)floatPointerFunctions;
 + (id)rectPointerFunctions;

Modified: trunk/NSPointerFunctions_SKExtensions.m
===================================================================
--- trunk/NSPointerFunctions_SKExtensions.m     2009-09-22 23:54:03 UTC (rev 
5785)
+++ trunk/NSPointerFunctions_SKExtensions.m     2009-09-22 23:56:35 UTC (rev 
5786)
@@ -77,7 +77,7 @@
     return hash;
 }
 
-+ (id)strongObjectsPointerFunctions {
++ (id)strongObjectPointerFunctions {
     return [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality];
 }
 

Modified: trunk/PDFAnnotationMarkup_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationMarkup_SKExtensions.m    2009-09-22 23:54:03 UTC (rev 
5785)
+++ trunk/PDFAnnotationMarkup_SKExtensions.m    2009-09-22 23:56:35 UTC (rev 
5786)
@@ -49,6 +49,7 @@
 #import "NSData_SKExtensions.h"
 #import "NSCharacterSet_SKExtensions.h"
 #import "SKRuntime.h"
+#import "NSPointerFunctions_SKExtensions.h"
 
 
 NSString *SKPDFAnnotationSelectionSpecifierKey = @"selectionSpecifier";
@@ -144,14 +145,10 @@
     lineRectsTable = [[NSMapTable alloc] 
initWithKeyOptions:NSMapTableZeroingWeakMemory | 
NSMapTableObjectPointerPersonality valueOptions:NSMapTableStrongMemory | 
NSMapTableObjectPointerPersonality capacity:0];
 }
 
-static NSUInteger rectSizeFunction(const void *item) { return sizeof(NSRect); }
-
 - (NSPointerArray *)lineRects {
     NSPointerArray *lineRects = [lineRectsTable objectForKey:self];
     if (lineRects == NULL) {
-        NSPointerFunctions *functions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsMallocMemory | 
NSPointerFunctionsCopyIn | NSPointerFunctionsStructPersonality];
-        [functions setSizeFunction:&rectSizeFunction];
-        lineRects = [[NSPointerArray alloc] 
initWithPointerFunctions:functions];
+        lineRects = [[NSPointerArray alloc] 
initWithPointerFunctions:[NSPointerFunctions rectPointerFunctions]];
         [lineRectsTable setObject:lineRects forKey:self];
         [lineRects release];;
     }

Modified: trunk/PDFSelection_SKExtensions.m
===================================================================
--- trunk/PDFSelection_SKExtensions.m   2009-09-22 23:54:03 UTC (rev 5785)
+++ trunk/PDFSelection_SKExtensions.m   2009-09-22 23:56:35 UTC (rev 5786)
@@ -42,6 +42,7 @@
 #import "PDFPage_SKExtensions.h"
 #import "SKStringConstants.h"
 #import "SKMainDocument.h"
+#import "NSPointerFunctions_SKExtensions.h"
 
 #define ELLIPSIS_CHARACTER 0x2026
 
@@ -270,8 +271,6 @@
     
     NSMutableArray *rangeDicts = [NSMutableArray array];
     NSString *key = [specifier key];
-    NSPointerFunctions *functions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsMallocMemory | 
NSPointerFunctionsCopyIn | NSPointerFunctionsStructPersonality];
-    [functions setSizeFunction:&rangeSizeFunction];
     
     if ([key isEqualToString:@"characters"] || [key isEqualToString:@"words"] 
|| [key isEqualToString:@"paragraphs"] || [key 
isEqualToString:@"attributeRuns"]) {
         
@@ -284,7 +283,7 @@
             NSTextStorage *containerText = [dict objectForKey:@"text"];
             NSPointerArray *textRanges = [dict objectForKey:@"ranges"];
             NSUInteger ri, numRanges = [textRanges count];
-            NSPointerArray *ranges = [[NSPointerArray alloc] 
initWithPointerFunctions:functions];
+            NSPointerArray *ranges = [[NSPointerArray alloc] 
initWithPointerFunctions:[NSPointerFunctions rangePointerFunctions]];
             
             for (ri = 0; ri < numRanges; ri++) {
                 NSRange textRange = *(NSRange *)[textRanges pointerAtIndex:ri];
@@ -296,7 +295,7 @@
                 
                 // now get the ranges, which can be any kind of specifier
                 NSInteger startIndex, endIndex, i, count, *indices;
-                NSPointerArray *tmpRanges = [[NSPointerArray alloc] 
initWithPointerFunctions:functions];
+                NSPointerArray *tmpRanges = [[NSPointerArray alloc] 
initWithPointerFunctions:[NSPointerFunctions rangePointerFunctions]];
                 
                 if ([specifier isKindOfClass:[NSPropertySpecifier class]]) {
                     // this should be the full range of characters, words, or 
paragraphs
@@ -435,7 +434,7 @@
             NSTextStorage *containerText = [container valueForKey:key];
             if ([containerText isKindOfClass:[NSTextStorage class]] == NO || 
[containerText length] == 0)
                 continue;
-            NSPointerArray *ranges = [[NSPointerArray alloc] 
initWithPointerFunctions:functions];
+            NSPointerArray *ranges = [[NSPointerArray alloc] 
initWithPointerFunctions:[NSPointerFunctions rangePointerFunctions]];
             NSRange range = NSMakeRange(0, [containerText length]);
             [ranges addPointer:&range];
             NSMutableDictionary *dict = [[NSMutableDictionary alloc] 
initWithObjectsAndKeys:ranges, @"ranges", containerText, @"text", container, 
@"container", nil];

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2009-09-22 23:54:03 UTC (rev 5785)
+++ trunk/SKMainWindowController.m      2009-09-22 23:56:35 UTC (rev 5786)
@@ -99,6 +99,7 @@
 #import "NSView_SKExtensions.h"
 #import "NSResponder_SKExtensions.h"
 #import "PDFOutline_SKExtensions.h"
+#import "NSPointerFunctions_SKExtensions.h"
 
 #define MULTIPLICATION_SIGN_CHARACTER 0x00d7
 
@@ -201,8 +202,6 @@
         return [super automaticallyNotifiesObserversForKey:key];
 }
 
-static NSUInteger floatSizeFunction(const void *item) { return 
sizeof(CGFloat); }
-
 - (id)init {
     if (self = [super initWithWindowNibName:@"MainWindow"]) {
         mwcFlags.isPresentation = 0;
@@ -220,10 +219,7 @@
         dirtySnapshots = [[NSMutableArray alloc] init];
         pageLabels = [[NSMutableArray alloc] init];
         lastViewedPages = [[NSMutableArray alloc] init];
-        NSPointerFunctions *keyFunctions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPointerPersonality];
-        NSPointerFunctions *valueFunctions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsMallocMemory | 
NSPointerFunctionsCopyIn | NSPointerFunctionsStructPersonality];
-        [valueFunctions setSizeFunction:floatSizeFunction];
-        rowHeights = [[NSMapTable alloc] 
initWithKeyPointerFunctions:keyFunctions valuePointerFunctions:valueFunctions 
capacity:0];
+        rowHeights = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions floatPointerFunctions] capacity:0];
         savedNormalSetup = [[NSMutableDictionary alloc] init];
         mwcFlags.leftSidePaneState = SKThumbnailSidePaneState;
         mwcFlags.rightSidePaneState = SKNoteSidePaneState;

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2009-09-22 23:54:03 UTC (rev 5785)
+++ trunk/SKNotesDocument.m     2009-09-22 23:56:35 UTC (rev 5786)
@@ -60,6 +60,7 @@
 #import "SKAnnotationTypeImageCell.h"
 #import "SKPrintableView.h"
 #import "SKPDFView.h"
+#import "NSPointerFunctions_SKExtensions.h"
 
 #define SKNotesDocumentWindowFrameAutosaveName @"SKNotesDocumentWindow"
 
@@ -75,17 +76,12 @@
 #define TYPE_COLUMNID @"type"
 #define PAGE_COLUMNID @"page"
 
-static NSUInteger floatSizeFunction(const void *item) { return 
sizeof(CGFloat); }
-
 @implementation SKNotesDocument
 
 - (id)init {
     if (self = [super init]) {
         notes = [[NSMutableArray alloc] initWithCapacity:10];
-        NSPointerFunctions *keyFunctions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPointerPersonality];
-        NSPointerFunctions *valueFunctions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsMallocMemory | 
NSPointerFunctionsCopyIn | NSPointerFunctionsStructPersonality];
-        [valueFunctions setSizeFunction:floatSizeFunction];
-        rowHeights = [[NSMapTable alloc] 
initWithKeyPointerFunctions:keyFunctions valuePointerFunctions:valueFunctions 
capacity:0];
+        rowHeights = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions floatPointerFunctions] capacity:0];
         caseInsensitiveSearch = YES;
     }
     return self;

Modified: trunk/SKPDFSyncRecord.m
===================================================================
--- trunk/SKPDFSyncRecord.m     2009-09-22 23:54:03 UTC (rev 5785)
+++ trunk/SKPDFSyncRecord.m     2009-09-22 23:56:35 UTC (rev 5786)
@@ -37,6 +37,7 @@
  */
 
 #import "SKPDFSyncRecord.h"
+#import "NSPointerFunctions_SKExtensions.h"
 
 
 @implementation SKPDFSyncRecord
@@ -114,9 +115,7 @@
 
 - (id)init {
     if (self = [super init]) {
-        NSPointerFunctions *keyFunctions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsOpaqueMemory | 
NSPointerFunctionsIntegerPersonality];
-        NSPointerFunctions *valueFunctions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality];
-        records = [[NSMapTable alloc] initWithKeyPointerFunctions:keyFunctions 
valuePointerFunctions:valueFunctions capacity:0];
+        records = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions integerPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
     }
     return self;
 }

Modified: trunk/SKPDFSynchronizerServer.m
===================================================================
--- trunk/SKPDFSynchronizerServer.m     2009-09-22 23:54:03 UTC (rev 5785)
+++ trunk/SKPDFSynchronizerServer.m     2009-09-22 23:56:35 UTC (rev 5786)
@@ -46,6 +46,7 @@
 #import "NSFileManager_SKExtensions.h"
 #import "NSString_SKExtensions.h"
 #import "SKRuntime.h"
+#import "NSPointerFunctions_SKExtensions.h"
 
 #define PDFSYNC_TO_PDF(coord) ((CGFloat)coord / 65536.0)
 
@@ -62,46 +63,6 @@
 
 #pragma mark -
 
-#define STACK_BUFFER_SIZE 256
-
-static BOOL caseInsensitiveStringEqual(const void *item1, const void *item2, 
NSUInteger (*size)(const void *item)) {
-    return (CFStringGetLength(item1) == CFStringGetLength(item2) && 
CFStringCompareWithOptions(item1, item2, CFRangeMake(0, 
CFStringGetLength(item1)), kCFCompareCaseInsensitive) == kCFCompareEqualTo);
-}
-
-static NSUInteger caseInsensitiveStringHash(const void *item, NSUInteger 
(*size)(const void *item)) {
-    if(item == NULL) return 0;
-    
-    uint32_t hash = 0;
-    CFAllocatorRef allocator = CFGetAllocator(item);
-    CFIndex len = CFStringGetLength(item);
-    
-    // use a generous length, in case the lowercase changes the number of 
characters
-    UniChar *buffer, stackBuffer[STACK_BUFFER_SIZE];
-    if (len + 10 >= STACK_BUFFER_SIZE)
-        buffer = (UniChar *)CFAllocatorAllocate(allocator, (len + 10) * 
sizeof(UniChar), 0);
-    else
-        buffer = stackBuffer;
-    CFStringGetCharacters(item, CFRangeMake(0, len), buffer);
-    
-    // If we create the string with external characters, 
CFStringGetCharactersPtr is guaranteed to succeed; since we're going to call 
CFStringGetCharacters anyway in fastHash if CFStringGetCharactsPtr fails, let's 
do it now when we lowercase the string
-    CFMutableStringRef mutableString = 
CFStringCreateMutableWithExternalCharactersNoCopy(allocator, buffer, len, len + 
10, (buffer != stackBuffer ? allocator : kCFAllocatorNull));
-    CFStringLowercase(mutableString, NULL);
-    hash = CFHash(mutableString);
-    // if we used the allocator, this should free the buffer for us
-    CFRelease(mutableString);
-    return hash;
-}
-
-static NSMapTable *createCaseInsensitiveStringKeysMapTable() {
-    NSPointerFunctions *keyFunctions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality];
-    NSPointerFunctions *valueFunctions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality];
-    [valueFunctions setIsEqualFunction:&caseInsensitiveStringEqual];
-    [valueFunctions setHashFunction:&caseInsensitiveStringHash];
-    return [[NSMapTable alloc] initWithKeyPointerFunctions:keyFunctions 
valuePointerFunctions:valueFunctions capacity:0];
-}
-
-#pragma mark -
-
 @implementation SKPDFSynchronizerServer
 
 + (void)initialize {
@@ -335,7 +296,7 @@
     if (lines)
         [lines removeAllObjects];
     else
-        lines = createCaseInsensitiveStringKeysMapTable();
+        lines = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
     
     [self setSyncFileName:theFileName];
     isPdfsync = YES;
@@ -576,7 +537,7 @@
         if (filenames)
             [filenames removeAllObjects];
         else
-            filenames = createCaseInsensitiveStringKeysMapTable();
+            filenames = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
         NSString *filename;
         synctex_node_t node = synctex_scanner_input(scanner);
         do {

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2009-09-22 23:54:03 UTC (rev 
5785)
+++ trunk/Skim.xcodeproj/project.pbxproj        2009-09-22 23:56:35 UTC (rev 
5786)
@@ -111,6 +111,7 @@
                CE41B2A70C08CFA900E36EB7 /* NSArray_SKExtensions.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = CE41B2A50C08CFA900E36EB7 /* 
NSArray_SKExtensions.m */; };
                CE41B2CC0C08D17100E36EB7 /* NSValue_SKExtensions.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = CE41B2CA0C08D17100E36EB7 /* 
NSValue_SKExtensions.m */; };
                CE4294A30BBD29120016FDC2 /* SKReadingBar.m in Sources */ = {isa 
= PBXBuildFile; fileRef = CE4294A20BBD29120016FDC2 /* SKReadingBar.m */; };
+               CE42B8EC106996C60091F588 /* NSPointerFunctions_SKExtensions.m 
in Sources */ = {isa = PBXBuildFile; fileRef = CE42B8EB106996C60091F588 /* 
NSPointerFunctions_SKExtensions.m */; };
                CE4373B40BB5440E00A56987 /* PSDocument.icns in Resources */ = 
{isa = PBXBuildFile; fileRef = CE4373B30BB5440E00A56987 /* PSDocument.icns */; 
};
                CE4642E50DF5CBD900CFD8D2 /* PDFAnnotationText_SKExtensions.m in 
Sources */ = {isa = PBXBuildFile; fileRef = CE4642E40DF5CBD900CFD8D2 /* 
PDFAnnotationText_SKExtensions.m */; };
                CE4643CF0DF6B5A400CFD8D2 /* SKJoinCommand.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CE4643CE0DF6B5A400CFD8D2 /* SKJoinCommand.m */; 
};
@@ -673,6 +674,8 @@
                CE41B2CA0C08D17100E36EB7 /* NSValue_SKExtensions.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= NSValue_SKExtensions.m; sourceTree = "<group>"; };
                CE4294A10BBD29120016FDC2 /* SKReadingBar.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKReadingBar.h; sourceTree = "<group>"; };
                CE4294A20BBD29120016FDC2 /* SKReadingBar.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKReadingBar.m; sourceTree = "<group>"; };
+               CE42B8EA106996C60091F588 /* NSPointerFunctions_SKExtensions.h 
*/ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.h; path = NSPointerFunctions_SKExtensions.h; sourceTree = 
"<group>"; };
+               CE42B8EB106996C60091F588 /* NSPointerFunctions_SKExtensions.m 
*/ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; path = NSPointerFunctions_SKExtensions.m; sourceTree = 
"<group>"; };
                CE4373B30BB5440E00A56987 /* PSDocument.icns */ = {isa = 
PBXFileReference; lastKnownFileType = image.icns; path = PSDocument.icns; 
sourceTree = "<group>"; };
                CE4642E30DF5CBD900CFD8D2 /* PDFAnnotationText_SKExtensions.h */ 
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.h; path = PDFAnnotationText_SKExtensions.h; sourceTree = 
"<group>"; };
                CE4642E40DF5CBD900CFD8D2 /* PDFAnnotationText_SKExtensions.m */ 
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; path = PDFAnnotationText_SKExtensions.m; sourceTree = 
"<group>"; };
@@ -1135,6 +1138,8 @@
                                CE3401E50E01388700A7FFE6 /* 
NSNumber_SKExtensions.m */,
                                CE6C03EE0BEDF759007BF0B5 /* 
NSParagraphStyle_SKExtensions.h */,
                                CE6C03EF0BEDF759007BF0B5 /* 
NSParagraphStyle_SKExtensions.m */,
+                               CE42B8EA106996C60091F588 /* 
NSPointerFunctions_SKExtensions.h */,
+                               CE42B8EB106996C60091F588 /* 
NSPointerFunctions_SKExtensions.m */,
                                CE1E301A0BDB9D5C0011D9DD /* 
NSScanner_SKExtensions.h */,
                                CE1E301B0BDB9D5C0011D9DD /* 
NSScanner_SKExtensions.m */,
                                CE38ECD10B8093B200A1B779 /* 
NSString_SKExtensions.h */,
@@ -2124,6 +2129,7 @@
                                CE5BB0CF10515CCC00161B87 /* SKPDFDocument.m in 
Sources */,
                                CE5BB0D310515D3100161B87 /* SKPDFPage.m in 
Sources */,
                                CE5BB21610517AEF00161B87 /* 
NSFileManager_SKExtensions.m in Sources */,
+                               CE42B8EC106996C60091F588 /* 
NSPointerFunctions_SKExtensions.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to