diff --git a/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m b/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m index 6cc2fc8fc..2fddc0e28 100644 --- a/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +++ b/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m @@ -499,7 +499,7 @@ - (void)addRowid:(int64_t)rowid isNew:(BOOL)isNew { __unsafe_unretained NSNumber *number = (NSNumber *)columnValue; - CFNumberType numberType = CFNumberGetType((CFNumberRef)number); + CFNumberType numberType = CFNumberGetType((__bridge CFNumberRef)number); if (numberType == kCFNumberFloat32Type || numberType == kCFNumberFloat64Type || diff --git a/YapDatabase/Internal/NSDictionary+YapDatabase.m b/YapDatabase/Internal/NSDictionary+YapDatabase.m index 98033f5bb..eba6e7f13 100644 --- a/YapDatabase/Internal/NSDictionary+YapDatabase.m +++ b/YapDatabase/Internal/NSDictionary+YapDatabase.m @@ -13,7 +13,7 @@ @implementation NSDictionary (YapDatabase) **/ - (BOOL)ydb_containsKey:(id)key { - return CFDictionaryContainsKey((CFDictionaryRef)self, (const void *)key); + return CFDictionaryContainsKey((__bridge CFDictionaryRef)self, (__bridge const void *)key); } @end diff --git a/YapDatabase/Internal/YapDatabasePrivate.h b/YapDatabase/Internal/YapDatabasePrivate.h index 2f57b0804..7dc788eae 100644 --- a/YapDatabase/Internal/YapDatabasePrivate.h +++ b/YapDatabase/Internal/YapDatabasePrivate.h @@ -463,7 +463,11 @@ static NSString *const ext_key_class = @"class"; @interface YapDatabaseReadWriteTransaction () { @public +#if OS_OBJECT_USE_OBJC NSMutableArray *completionQueueStack; +#else + NSMutableArray *completionQueueStack; +#endif NSMutableArray *completionBlockStack; BOOL rollback; diff --git a/YapDatabase/Utilities/YapBidirectionalCache.m b/YapDatabase/Utilities/YapBidirectionalCache.m index 7167a9427..b0814b9b8 100644 --- a/YapDatabase/Utilities/YapBidirectionalCache.m +++ b/YapDatabase/Utilities/YapBidirectionalCache.m @@ -178,8 +178,8 @@ - (void)setCountLimit:(NSUInteger)newCountLimit leastRecentCacheItem = leastRecentCacheItem->prev; leastRecentCacheItem->next = nil; - CFDictionaryRemoveValue(obj_key_dict, (const void *)(objToEvict)); // must be first - CFDictionaryRemoveValue(key_obj_dict, (const void *)(keyToEvict)); // must be second + CFDictionaryRemoveValue(obj_key_dict, (__bridge const void *)(objToEvict)); // must be first + CFDictionaryRemoveValue(key_obj_dict, (__bridge const void *)(keyToEvict)); // must be second evictedCacheItem->prev = nil; evictedCacheItem->next = nil; @@ -191,8 +191,8 @@ - (void)setCountLimit:(NSUInteger)newCountLimit leastRecentCacheItem = leastRecentCacheItem->prev; leastRecentCacheItem->next = nil; - CFDictionaryRemoveValue(obj_key_dict, (const void *)(objToEvict)); // must be first - CFDictionaryRemoveValue(key_obj_dict, (const void *)(keyToEvict)); // must be second + CFDictionaryRemoveValue(obj_key_dict, (__bridge const void *)(objToEvict)); // must be first + CFDictionaryRemoveValue(key_obj_dict, (__bridge const void *)(keyToEvict)); // must be second } #if YapBidirectionalCache_Enable_Statistics @@ -209,7 +209,7 @@ - (id)objectForKey:(id)key AssertAllowedKeyClass(key, allowedKeyClasses); #endif - __unsafe_unretained YapBidirectionalCacheItem *item = CFDictionaryGetValue(key_obj_dict, (const void *)key); + __unsafe_unretained YapBidirectionalCacheItem *item = (__bridge YapBidirectionalCacheItem *)CFDictionaryGetValue(key_obj_dict, (__bridge const void *)key); if (item) { if (item != mostRecentCacheItem) @@ -257,7 +257,7 @@ - (BOOL)containsKey:(id)key AssertAllowedKeyClass(key, allowedKeyClasses); #endif - return CFDictionaryContainsKey(key_obj_dict, (const void *)key); + return CFDictionaryContainsKey(key_obj_dict, (__bridge const void *)key); } - (id)keyForObject:(id)object @@ -266,7 +266,7 @@ - (id)keyForObject:(id)object AssertAllowedObjectClass(object, allowedObjectClasses); #endif - __unsafe_unretained YapBidirectionalCacheItem *item = CFDictionaryGetValue(obj_key_dict, (const void *)object); + __unsafe_unretained YapBidirectionalCacheItem *item = (__bridge YapBidirectionalCacheItem *)CFDictionaryGetValue(obj_key_dict, (__bridge const void *)object); if (item) { if (item != mostRecentCacheItem) @@ -314,7 +314,7 @@ - (BOOL)containsObject:(id)object AssertAllowedObjectClass(object, allowedObjectClasses); #endif - return CFDictionaryContainsKey(obj_key_dict, (const void *)object); + return CFDictionaryContainsKey(obj_key_dict, (__bridge const void *)object); } - (NSUInteger)count @@ -329,20 +329,20 @@ - (void)setObject:(id)object forKey:(id)key AssertAllowedObjectClass(object, allowedObjectClasses); #endif - __unsafe_unretained YapBidirectionalCacheItem *existingItem = CFDictionaryGetValue(key_obj_dict, (const void *)key); + __unsafe_unretained YapBidirectionalCacheItem *existingItem = (__bridge YapBidirectionalCacheItem *)CFDictionaryGetValue(key_obj_dict, (__bridge const void *)key); if (existingItem) { // Update item value if (!objCallBacks.equal((__bridge const void *)existingItem->obj, (__bridge const void *)object)) { - CFDictionaryRemoveValue(obj_key_dict, (const void *)existingItem->obj); + CFDictionaryRemoveValue(obj_key_dict, (__bridge const void *)existingItem->obj); if (objCallBacks.shouldCopy) existingItem->obj = [object copy]; else existingItem->obj = object; - CFDictionarySetValue(obj_key_dict, (const void *)existingItem->obj, (const void *)existingItem); + CFDictionarySetValue(obj_key_dict, (__bridge const void *)existingItem->obj, (__bridge const void *)existingItem); } if (existingItem != mostRecentCacheItem) @@ -408,8 +408,8 @@ - (void)setObject:(id)object forKey:(id)key // Add item to dicts - CFDictionarySetValue(key_obj_dict, (const void *)newKey, (const void *)newItem); - CFDictionarySetValue(obj_key_dict, (const void *)newItem->obj, (const void *)newItem); + CFDictionarySetValue(key_obj_dict, (__bridge const void *)newKey, (__bridge const void *)newItem); + CFDictionarySetValue(obj_key_dict, (__bridge const void *)newItem->obj, (__bridge const void *)newItem); // Add item to beginning of linked-list @@ -436,8 +436,8 @@ - (void)setObject:(id)object forKey:(id)key leastRecentCacheItem = leastRecentCacheItem->prev; leastRecentCacheItem->next = nil; - CFDictionaryRemoveValue(obj_key_dict, (const void *)(objToEvict)); // must be first - CFDictionaryRemoveValue(key_obj_dict, (const void *)(keyToEvict)); // must be second + CFDictionaryRemoveValue(obj_key_dict, (__bridge const void *)(objToEvict)); // must be first + CFDictionaryRemoveValue(key_obj_dict, (__bridge const void *)(keyToEvict)); // must be second evictedCacheItem->prev = nil; evictedCacheItem->next = nil; @@ -449,8 +449,8 @@ - (void)setObject:(id)object forKey:(id)key leastRecentCacheItem = leastRecentCacheItem->prev; leastRecentCacheItem->next = nil; - CFDictionaryRemoveValue(obj_key_dict, (const void *)(objToEvict)); // must be first - CFDictionaryRemoveValue(key_obj_dict, (const void *)(keyToEvict)); // must be second + CFDictionaryRemoveValue(obj_key_dict, (__bridge const void *)(objToEvict)); // must be first + CFDictionaryRemoveValue(key_obj_dict, (__bridge const void *)(keyToEvict)); // must be second } #if YapBidirectionalCache_Enable_Statistics @@ -501,7 +501,7 @@ - (void)removeObjectForKey:(id)key AssertAllowedKeyClass(key, allowedKeyClasses); #endif - __unsafe_unretained YapBidirectionalCacheItem *item = CFDictionaryGetValue(key_obj_dict, (const void *)key); + __unsafe_unretained YapBidirectionalCacheItem *item = (__bridge YapBidirectionalCacheItem *)CFDictionaryGetValue(key_obj_dict, (__bridge const void *)key); if (item) { if (item == mostRecentCacheItem) @@ -514,8 +514,8 @@ - (void)removeObjectForKey:(id)key else if (item->next) item->next->prev = item->prev; - CFDictionaryRemoveValue(obj_key_dict, (const void *)item->obj); // must be first - CFDictionaryRemoveValue(key_obj_dict, (const void *)item->key); // must be second + CFDictionaryRemoveValue(obj_key_dict, (__bridge const void *)item->obj); // must be first + CFDictionaryRemoveValue(key_obj_dict, (__bridge const void *)item->key); // must be second } } @@ -527,7 +527,7 @@ - (void)removeObjectsForKeys:(id )keys AssertAllowedKeyClass(key, allowedKeyClasses); #endif - __unsafe_unretained YapBidirectionalCacheItem *item = CFDictionaryGetValue(key_obj_dict, (const void *)key); + __unsafe_unretained YapBidirectionalCacheItem *item = (__bridge YapBidirectionalCacheItem *)CFDictionaryGetValue(key_obj_dict, (__bridge const void *)key); if (item) { if (item == mostRecentCacheItem) @@ -540,8 +540,8 @@ - (void)removeObjectsForKeys:(id )keys else if (item->next) item->next->prev = item->prev; - CFDictionaryRemoveValue(obj_key_dict, (const void *)item->obj); // must be first - CFDictionaryRemoveValue(key_obj_dict, (const void *)item->key); // must be second + CFDictionaryRemoveValue(obj_key_dict, (__bridge const void *)item->obj); // must be first + CFDictionaryRemoveValue(key_obj_dict, (__bridge const void *)item->key); // must be second } } } @@ -552,7 +552,7 @@ - (void)removeKeyForObject:(id)object AssertAllowedObjectClass(object, allowedObjectClasses); #endif - __unsafe_unretained YapBidirectionalCacheItem *item = CFDictionaryGetValue(obj_key_dict, (const void *)object); + __unsafe_unretained YapBidirectionalCacheItem *item = (__bridge YapBidirectionalCacheItem *)CFDictionaryGetValue(obj_key_dict, (__bridge const void *)object); if (item) { if (item == mostRecentCacheItem) @@ -565,8 +565,8 @@ - (void)removeKeyForObject:(id)object else if (item->next) item->next->prev = item->prev; - CFDictionaryRemoveValue(obj_key_dict, (const void *)item->obj); // must be first - CFDictionaryRemoveValue(key_obj_dict, (const void *)item->key); // must be second + CFDictionaryRemoveValue(obj_key_dict, (__bridge const void *)item->obj); // must be first + CFDictionaryRemoveValue(key_obj_dict, (__bridge const void *)item->key); // must be second } } @@ -578,7 +578,7 @@ - (void)removeKeysForObjects:(id )objects AssertAllowedObjectClass(object, allowedObjectClasses); #endif - __unsafe_unretained YapBidirectionalCacheItem *item = CFDictionaryGetValue(obj_key_dict, (const void *)object); + __unsafe_unretained YapBidirectionalCacheItem *item = (__bridge YapBidirectionalCacheItem *)CFDictionaryGetValue(obj_key_dict, (__bridge const void *)object); if (item) { if (item == mostRecentCacheItem) @@ -591,8 +591,8 @@ - (void)removeKeysForObjects:(id )objects else if (item->next) item->next->prev = item->prev; - CFDictionaryRemoveValue(obj_key_dict, (const void *)item->obj); // must be first - CFDictionaryRemoveValue(key_obj_dict, (const void *)item->key); // must be second + CFDictionaryRemoveValue(obj_key_dict, (__bridge const void *)item->obj); // must be first + CFDictionaryRemoveValue(key_obj_dict, (__bridge const void *)item->key); // must be second } } } diff --git a/YapDatabase/Utilities/YapCache.m b/YapDatabase/Utilities/YapCache.m index 034dbd620..cee73021c 100644 --- a/YapDatabase/Utilities/YapCache.m +++ b/YapDatabase/Utilities/YapCache.m @@ -152,7 +152,7 @@ - (void)setCountLimit:(NSUInteger)newCountLimit leastRecentCacheItem->next = nil; } - CFDictionaryRemoveValue(cfdict, (const void *)(keyToEvict)); + CFDictionaryRemoveValue(cfdict, (__bridge const void *)(keyToEvict)); #if YapCache_Enable_Statistics evictionCount++; @@ -168,7 +168,7 @@ - (id)objectForKey:(id)key AssertAllowedKeyClass(key, allowedKeyClasses); #endif - __unsafe_unretained YapCacheItem *item = CFDictionaryGetValue(cfdict, (const void *)key); + __unsafe_unretained YapCacheItem *item = (__bridge YapCacheItem *)CFDictionaryGetValue(cfdict, (__bridge const void *)key); if (item) { if (item != mostRecentCacheItem) @@ -216,7 +216,7 @@ - (BOOL)containsKey:(id)key AssertAllowedKeyClass(key, allowedKeyClasses); #endif - return CFDictionaryContainsKey(cfdict, (const void *)key); + return CFDictionaryContainsKey(cfdict, (__bridge const void *)key); } - (void)setObject:(id)object forKey:(id)key @@ -226,7 +226,7 @@ - (void)setObject:(id)object forKey:(id)key AssertAllowedObjectClass(object, allowedObjectClasses); #endif - __unsafe_unretained YapCacheItem *existingItem = CFDictionaryGetValue(cfdict, (const void *)key); + __unsafe_unretained YapCacheItem *existingItem = (__bridge YapCacheItem *)CFDictionaryGetValue(cfdict, (__bridge const void *)key); if (existingItem) { // Update item value @@ -283,7 +283,7 @@ - (void)setObject:(id)object forKey:(id)key } // Add item to set - CFDictionarySetValue(cfdict, (const void *)key, (const void *)newItem); + CFDictionarySetValue(cfdict, (__bridge const void *)key, (__bridge const void *)newItem); // Add item to beginning of linked-list @@ -320,7 +320,7 @@ - (void)setObject:(id)object forKey:(id)key leastRecentCacheItem->next = nil; } - CFDictionaryRemoveValue(cfdict, (const void *)(keyToEvict)); + CFDictionaryRemoveValue(cfdict, (__bridge const void *)(keyToEvict)); #if YapCache_Enable_Statistics evictionCount++; @@ -373,7 +373,7 @@ - (void)removeObjectForKey:(id)key AssertAllowedKeyClass(key, allowedKeyClasses); #endif - __unsafe_unretained YapCacheItem *item = CFDictionaryGetValue(cfdict, (const void *)key); + __unsafe_unretained YapCacheItem *item = (__bridge YapCacheItem *)CFDictionaryGetValue(cfdict, (__bridge const void *)key); if (item) { if (mostRecentCacheItem == item) @@ -386,7 +386,7 @@ - (void)removeObjectForKey:(id)key else if (item->next) item->next->prev = item->prev; - CFDictionaryRemoveValue(cfdict, (const void *)key); + CFDictionaryRemoveValue(cfdict, (__bridge const void *)key); } } @@ -398,7 +398,7 @@ - (void)removeObjectsForKeys:(id )keys AssertAllowedKeyClass(key, allowedKeyClasses); #endif - __unsafe_unretained YapCacheItem *item = CFDictionaryGetValue(cfdict, (const void *)key); + __unsafe_unretained YapCacheItem *item = (__bridge YapCacheItem *)CFDictionaryGetValue(cfdict, (__bridge const void *)key); if (item) { if (mostRecentCacheItem == item) @@ -411,7 +411,7 @@ - (void)removeObjectsForKeys:(id )keys else if (item->next) item->next->prev = item->prev; - CFDictionaryRemoveValue(cfdict, (const void *)key); + CFDictionaryRemoveValue(cfdict, (__bridge const void *)key); } } } diff --git a/YapDatabase/Utilities/YapSet.m b/YapDatabase/Utilities/YapSet.m index c45fbb06e..b7bfcc857 100644 --- a/YapDatabase/Utilities/YapSet.m +++ b/YapDatabase/Utilities/YapSet.m @@ -42,7 +42,7 @@ - (BOOL)containsObject:(id)object if (set) return [set containsObject:object]; else - return CFDictionaryContainsKey((__bridge CFDictionaryRef)dictionary, (const void *)object); + return CFDictionaryContainsKey((__bridge CFDictionaryRef)dictionary, (__bridge const void *)object); } - (BOOL)intersectsSet:(NSSet *)otherSet @@ -55,7 +55,7 @@ - (BOOL)intersectsSet:(NSSet *)otherSet { for (id object in otherSet) { - if (CFDictionaryContainsKey((__bridge CFDictionaryRef)dictionary, (const void *)object)) + if (CFDictionaryContainsKey((__bridge CFDictionaryRef)dictionary, (__bridge const void *)object)) return YES; } diff --git a/YapDatabase/YapDatabaseConnection.m b/YapDatabase/YapDatabaseConnection.m index 86962f15b..9548cc117 100644 --- a/YapDatabase/YapDatabaseConnection.m +++ b/YapDatabase/YapDatabaseConnection.m @@ -2024,7 +2024,11 @@ - (void)readWriteWithBlock:(void (NS_NOESCAPE^)(YapDatabaseReadWriteTransaction NSUInteger count = transaction->completionBlockStack.count; for (NSUInteger i = 0; i < count; i++) { +#if OS_OBJECT_USE_OBJC dispatch_queue_t stackItemQueue = transaction->completionQueueStack[i]; +#else + dispatch_queue_t stackItemQueue = (dispatch_queue_t)[transaction->completionQueueStack[i] pointerValue]; +#endif dispatch_block_t stackItemBlock = transaction->completionBlockStack[i]; dispatch_async(stackItemQueue, stackItemBlock); @@ -2239,7 +2243,11 @@ - (void)asyncReadWriteWithBlock:(void (^)(YapDatabaseReadWriteTransaction *trans NSUInteger count = transaction->completionBlockStack.count; for (NSUInteger i = 0; i < count; i++) { +#if OS_OBJECT_USE_OBJC dispatch_queue_t stackItemQueue = transaction->completionQueueStack[i]; +#else + dispatch_queue_t stackItemQueue = [transaction->completionQueueStack[i] pointerValue]; +#endif dispatch_block_t stackItemBlock = transaction->completionBlockStack[i]; dispatch_async(stackItemQueue, stackItemBlock); @@ -6034,7 +6042,7 @@ - (NSError *)_backupToPath:(NSString *)backupDatabasePath withStep:(int)nPages p // Loop through the backup process - BOOL cancelled = progress.cancelled; + BOOL cancelled = progress.isCancelled; if (!cancelled) { while ((status = sqlite3_backup_step(backup, nPages)) == SQLITE_OK) @@ -6047,7 +6055,7 @@ - (NSError *)_backupToPath:(NSString *)backupDatabasePath withStep:(int)nPages p progress.totalUnitCount = pagecount; progress.completedUnitCount = (pagecount - remaining); - cancelled = progress.cancelled; + cancelled = progress.isCancelled; if (cancelled) break; } } diff --git a/YapDatabase/YapDatabaseTransaction.m b/YapDatabase/YapDatabaseTransaction.m index efee742d1..089ebd9ac 100644 --- a/YapDatabase/YapDatabaseTransaction.m +++ b/YapDatabase/YapDatabaseTransaction.m @@ -6043,7 +6043,12 @@ - (void)addCompletionQueue:(dispatch_queue_t)completionQueue if (completionBlockStack == nil) completionBlockStack = [[NSMutableArray alloc] initWithCapacity:1]; +#if OS_OBJECT_USE_OBJC [completionQueueStack addObject:completionQueue]; +#else + dispatch_retain(completionQueue); + [completionQueueStack addObject:[NSValue valueWithPointer:completionQueue]]; +#endif [completionBlockStack addObject:completionBlock]; } @@ -6310,4 +6315,14 @@ - (void)removeAllValuesForExtension:(NSString *)extensionName FreeYapDatabaseString(&_extension); } +#if !OS_OBJECT_USE_OBJC +- (void)dealloc +{ + for (NSValue *value in completionBlockStack) { + dispatch_queue_t completionQueue = [value pointerValue]; + dispatch_release(completionQueue); + } +} +#endif + @end