Revision: 28806
          http://sourceforge.net/p/bibdesk/svn/28806
Author:   hofman
Date:     2024-02-23 16:50:48 +0000 (Fri, 23 Feb 2024)
Log Message:
-----------
conveneince class factory for strong object pointer functions

Modified Paths:
--------------
    trunk/bibdesk/BDSKBibTeXParser.m
    trunk/bibdesk/BDSKDocumentInfoWindowController.m
    trunk/bibdesk/BDSKLineTextField.m
    trunk/bibdesk/BDSKMacroResolver.m
    trunk/bibdesk/BDSKPublicationsArray.m
    trunk/bibdesk/BDSKSearchGroup.m
    trunk/bibdesk/BDSKSharedGroup.m
    trunk/bibdesk/BibDocument.m
    trunk/bibdesk/NSPointerFunctions_BDSKExtensions.h
    trunk/bibdesk/NSPointerFunctions_BDSKExtensions.m

Modified: trunk/bibdesk/BDSKBibTeXParser.m
===================================================================
--- trunk/bibdesk/BDSKBibTeXParser.m    2024-02-23 14:36:48 UTC (rev 28805)
+++ trunk/bibdesk/BDSKBibTeXParser.m    2024-02-23 16:50:48 UTC (rev 28806)
@@ -186,7 +186,7 @@
     if (outGroups)
         *outGroups = groups = [NSMutableDictionary dictionary];
     if (outMacros)
-        *outMacros = macros = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] capacity:0];
+        *outMacros = macros = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
     if (outFrontMatter)
         *outFrontMatter = frontMatter = [NSMutableString string];
     if (outDocumentInfo)

Modified: trunk/bibdesk/BDSKDocumentInfoWindowController.m
===================================================================
--- trunk/bibdesk/BDSKDocumentInfoWindowController.m    2024-02-23 14:36:48 UTC 
(rev 28805)
+++ trunk/bibdesk/BDSKDocumentInfoWindowController.m    2024-02-23 16:50:48 UTC 
(rev 28806)
@@ -52,7 +52,7 @@
 - (instancetype)init {
     self = [super initWithWindowNibName:@"DocumentInfoWindow"];
     if (self) {
-        info = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] capacity:0];
+        info = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
         keys = nil;
         ignoreEdit = NO;
     }

Modified: trunk/bibdesk/BDSKLineTextField.m
===================================================================
--- trunk/bibdesk/BDSKLineTextField.m   2024-02-23 14:36:48 UTC (rev 28805)
+++ trunk/bibdesk/BDSKLineTextField.m   2024-02-23 16:50:48 UTC (rev 28806)
@@ -51,7 +51,7 @@
     if (heightPtr == NULL) {
         height = [font defaultViewLineHeight];
         if (heightTable == nil)
-            heightTable = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] valuePointerFunctions:[NSPointerFunctions 
floatPointerFunctions] capacity:0];
+            heightTable = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions floatPointerFunctions] capacity:0];
          NSMapInsert(heightTable, (__bridge void *)font, &height);
     } else {
         height = *heightPtr;

Modified: trunk/bibdesk/BDSKMacroResolver.m
===================================================================
--- trunk/bibdesk/BDSKMacroResolver.m   2024-02-23 14:36:48 UTC (rev 28805)
+++ trunk/bibdesk/BDSKMacroResolver.m   2024-02-23 16:50:48 UTC (rev 28806)
@@ -269,7 +269,7 @@
     // It is not quite correct because bibtex does discriminate,
     // but this is the best we can do.  The 
OFCreateCaseInsensitiveKeyMutableDictionary()
     // is used to create a dictionary with case-insensitive keys.
-    macroDefinitions = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] capacity:0];
+    macroDefinitions = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
     modification++;
 }
 
@@ -306,7 +306,7 @@
             [formatter setCalendar:[[NSCalendar alloc] 
initWithCalendarIdentifier:NSCalendarIdentifierGregorian]];
         NSString *shortMonthNames[12] = {@"jan", @"feb", @"mar", @"apr", 
@"may", @"jun", @"jul", @"aug", @"sep", @"oct", @"nov", @"dec"};
         NSArray *monthNames = [formatter standaloneMonthSymbols];
-        standardMacroDefinitions = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] capacity:0];
+        standardMacroDefinitions = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
         NSUInteger i;
         for (i = 0; i < 12; i++)
             [standardMacroDefinitions setObject:[monthNames objectAtIndex:i] 
forKey:shortMonthNames[i]];
@@ -329,7 +329,7 @@
 - (void)loadMacroDefinitions{
     NSUserDefaults*sud = [NSUserDefaults standardUserDefaults];
     
-    macroDefinitions = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] capacity:0];;
+    macroDefinitions = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];;
     
     NSDictionary *macros = [sud 
dictionaryForKey:BDSKGlobalMacroDefinitionsKey];
     NSString *value;
@@ -349,7 +349,7 @@
 - (void)loadMacrosFromFiles{
     NSUserDefaults*sud = [NSUserDefaults standardUserDefaults];
     
-    fileMacroDefinitions = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] capacity:0];
+    fileMacroDefinitions = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
     
     for (NSString *file in [sud stringArrayForKey:BDSKGlobalMacroFilesKey]) {
         NSString *fileContent = [NSString stringWithContentsOfURL:[NSURL 
fileURLWithPath:file isDirectory:NO] guessedEncoding:0];

Modified: trunk/bibdesk/BDSKPublicationsArray.m
===================================================================
--- trunk/bibdesk/BDSKPublicationsArray.m       2024-02-23 14:36:48 UTC (rev 
28805)
+++ trunk/bibdesk/BDSKPublicationsArray.m       2024-02-23 16:50:48 UTC (rev 
28806)
@@ -91,7 +91,7 @@
         publications = [[NSMutableArray alloc] initWithArray:anArray];
         itemsForIdentifierURLs = [[NSMutableDictionary alloc] init];
         NSPointerFunctions *keyPointerFunctions = [NSPointerFunctions 
caseInsensitiveStringPointerFunctions];
-        NSPointerFunctions *valuePointerFunctions = [NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality];
+        NSPointerFunctions *valuePointerFunctions = [NSPointerFunctions 
strongObjectPointerFunctions];
         itemsForCiteKeys = [[NSMapTable alloc] 
initWithKeyPointerFunctions:keyPointerFunctions 
valuePointerFunctions:valuePointerFunctions capacity:0];
         searchIndexes = [[BDSKItemSearchIndexes alloc] init];
         if ([anArray count]) {

Modified: trunk/bibdesk/BDSKSearchGroup.m
===================================================================
--- trunk/bibdesk/BDSKSearchGroup.m     2024-02-23 14:36:48 UTC (rev 28805)
+++ trunk/bibdesk/BDSKSearchGroup.m     2024-02-23 16:50:48 UTC (rev 28806)
@@ -68,7 +68,7 @@
 
 + (void)initialize {
     BDSKINITIALIZE;
-    BDSKSearchGroupURLQueryKeys = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] capacity:14];
+    BDSKSearchGroupURLQueryKeys = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:14];
     NSString *keys[14] = {@"searchTerm", @"term", @"name", @"database", @"db", 
@"password", @"username", @"user", @"recordSyntax", @"syntax", 
@"resultEncoding", @"encoding", @"removeDiacritics", @"lite"};
     NSString *objects[14] = {@"searchTerm", @"searchTerm", @"name", 
@"database", @"database", @"password", @"username", @"username", 
@"recordSyntax", @"recordSyntax", @"resultEncoding", @"resultEncoding", 
@"removeDiacritics", @"lite"};
     NSUInteger i;

Modified: trunk/bibdesk/BDSKSharedGroup.m
===================================================================
--- trunk/bibdesk/BDSKSharedGroup.m     2024-02-23 14:36:48 UTC (rev 28805)
+++ trunk/bibdesk/BDSKSharedGroup.m     2024-02-23 16:50:48 UTC (rev 28806)
@@ -187,7 +187,7 @@
     if (macrosArchive) {
         NSDictionary *dict = [NSKeyedUnarchiver 
unarchiveObjectWithData:macrosArchive];
         if (dict) {
-            macros = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] capacity:0];
+            macros = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
             [dict enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString 
*value, BOOL *stop){
                 [macros setObject:[dict objectForKey:key] forKey:key];
             }];

Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2024-02-23 14:36:48 UTC (rev 28805)
+++ trunk/bibdesk/BibDocument.m 2024-02-23 16:50:48 UTC (rev 28806)
@@ -213,7 +213,7 @@
         groups = [(BDSKGroupsArray *)[BDSKGroupsArray alloc] 
initWithDocument:self];
         
         frontMatter = nil;
-        documentInfo = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] capacity:0];
+        documentInfo = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
         macroResolver = [[BDSKMacroResolver alloc] initWithOwner:self];
         
         openDate = [[NSDate alloc] init];
@@ -1853,7 +1853,7 @@
         [[NSFileManager defaultManager] removeItemAtURL:fileURL error:NULL];
     
     if (error == nil) {
-        NSMapTable *newDocInfo = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality] capacity:0];
+        NSMapTable *newDocInfo = [[NSMapTable alloc] 
initWithKeyPointerFunctions:[NSPointerFunctions 
caseInsensitiveStringPointerFunctions] 
valuePointerFunctions:[NSPointerFunctions strongObjectPointerFunctions] 
capacity:0];
         [newDocumentInfo enumerateKeysAndObjectsUsingBlock:^(NSString *key, 
NSString *value, BOOL *stop){
             [newDocInfo setObject:value forKey:key];
         }];

Modified: trunk/bibdesk/NSPointerFunctions_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSPointerFunctions_BDSKExtensions.h   2024-02-23 14:36:48 UTC 
(rev 28805)
+++ trunk/bibdesk/NSPointerFunctions_BDSKExtensions.h   2024-02-23 16:50:48 UTC 
(rev 28806)
@@ -41,6 +41,7 @@
 
 @interface NSPointerFunctions (BDSKExtensions)
 
+@property (class, nonatomic, readonly) NSPointerFunctions 
*strongObjectPointerFunctions;
 @property (class, nonatomic, readonly) NSPointerFunctions 
*caseInsensitiveStringPointerFunctions;
 @property (class, nonatomic, readonly) NSPointerFunctions 
*fuzzyAuthorPointerFunctions;
 @property (class, nonatomic, readonly) NSPointerFunctions 
*itemEqualityPointerFunctions;

Modified: trunk/bibdesk/NSPointerFunctions_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSPointerFunctions_BDSKExtensions.m   2024-02-23 14:36:48 UTC 
(rev 28805)
+++ trunk/bibdesk/NSPointerFunctions_BDSKExtensions.m   2024-02-23 16:50:48 UTC 
(rev 28806)
@@ -95,6 +95,11 @@
 
 @implementation NSPointerFunctions (BDSKExtensions)
 
++ (NSPointerFunctions *)strongObjectPointerFunctions {
+    NSPointerFunctions *pointerFunctions = [self 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality];
+    return pointerFunctions;
+}
+
 + (NSPointerFunctions *)caseInsensitiveStringPointerFunctions {
     NSPointerFunctions *pointerFunctions = [self 
pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory | 
NSPointerFunctionsObjectPersonality];
     [pointerFunctions setIsEqualFunction:&caseInsensitiveStringEqual];

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to