22
22
*/
23
23
24
24
/* CFArray.c
25
- Copyright (c) 1998-2011 , Apple Inc. All rights reserved.
25
+ Copyright (c) 1998-2012 , Apple Inc. All rights reserved.
26
26
Responsibility: Christopher Kane
27
27
*/
28
28
31
31
#include "CFInternal.h"
32
32
#include <string.h>
33
33
34
+
34
35
const CFArrayCallBacks kCFTypeArrayCallBacks = {0 , __CFTypeCollectionRetain , __CFTypeCollectionRelease , CFCopyDescription , CFEqual };
35
36
static const CFArrayCallBacks __kCFNullArrayCallBacks = {0 , NULL , NULL , NULL , NULL };
36
37
@@ -314,6 +315,7 @@ static CFStringRef __CFArrayCopyDescription(CFTypeRef cf) {
314
315
static void __CFArrayDeallocate (CFTypeRef cf ) {
315
316
CFArrayRef array = (CFArrayRef )cf ;
316
317
BEGIN_MUTATION (array );
318
+ #if DEPLOYMENT_TARGET_MACOSX
317
319
// Under GC, keep contents alive when we know we can, either standard callbacks or NULL
318
320
// if (__CFBitfieldGetValue(cf->info, 5, 4)) return; // bits only ever set under GC
319
321
CFAllocatorRef allocator = __CFGetAllocator (array );
@@ -334,6 +336,7 @@ static void __CFArrayDeallocate(CFTypeRef cf) {
334
336
return ;
335
337
}
336
338
}
339
+ #endif
337
340
__CFArrayReleaseValues (array , CFRangeMake (0 , __CFArrayGetCount (array )), true);
338
341
END_MUTATION (array );
339
342
}
@@ -544,7 +547,7 @@ CFMutableArrayRef CFArrayCreateMutableCopy(CFAllocatorRef allocator, CFIndex cap
544
547
#endif
545
548
546
549
CFIndex CFArrayGetCount (CFArrayRef array ) {
547
- CF_OBJC_FUNCDISPATCH0 (__kCFArrayTypeID , CFIndex , array , " count" );
550
+ CF_OBJC_FUNCDISPATCHV (__kCFArrayTypeID , CFIndex , ( NSArray * ) array , count );
548
551
__CFGenericValidateType (array , __kCFArrayTypeID );
549
552
CHECK_FOR_MUTATION (array );
550
553
return __CFArrayGetCount (array );
@@ -582,7 +585,7 @@ Boolean CFArrayContainsValue(CFArrayRef array, CFRange range, const void *value)
582
585
}
583
586
584
587
const void * CFArrayGetValueAtIndex (CFArrayRef array , CFIndex idx ) {
585
- CF_OBJC_FUNCDISPATCH1 (__kCFArrayTypeID , void * , array , " objectAtIndex:" , idx );
588
+ CF_OBJC_FUNCDISPATCHV (__kCFArrayTypeID , const void * , ( NSArray * ) array , objectAtIndex :idx );
586
589
__CFGenericValidateType (array , __kCFArrayTypeID );
587
590
CFAssert2 (0 <= idx && idx < __CFArrayGetCount (array ), __kCFLogAssertion , "%s(): index (%d) out of bounds" , __PRETTY_FUNCTION__ , idx );
588
591
CHECK_FOR_MUTATION (array );
@@ -598,7 +601,7 @@ const void *_CFArrayCheckAndGetValueAtIndex(CFArrayRef array, CFIndex idx) {
598
601
599
602
600
603
void CFArrayGetValues (CFArrayRef array , CFRange range , const void * * values ) {
601
- CF_OBJC_FUNCDISPATCH2 (__kCFArrayTypeID , void , array , " getObjects:range:" , values , range );
604
+ CF_OBJC_FUNCDISPATCHV (__kCFArrayTypeID , void , ( NSArray * ) array , getObjects :( id * ) values range :NSMakeRange ( range . location , range . length ) );
602
605
__CFGenericValidateType (array , __kCFArrayTypeID );
603
606
__CFArrayValidateRange (array , range , __PRETTY_FUNCTION__ );
604
607
CFAssert1 (NULL != values , __kCFLogAssertion , "%s(): pointer to values may not be NULL" , __PRETTY_FUNCTION__ );
@@ -682,15 +685,16 @@ CFIndex CFArrayGetLastIndexOfValue(CFArrayRef array, CFRange range, const void *
682
685
}
683
686
684
687
void CFArrayAppendValue (CFMutableArrayRef array , const void * value ) {
685
- CF_OBJC_FUNCDISPATCH1 (__kCFArrayTypeID , void , array , "addObject:" , value );
688
+ CF_OBJC_FUNCDISPATCHV (__kCFArrayTypeID , void , (NSMutableArray * )array , addObject :(id )value );
689
+
686
690
__CFGenericValidateType (array , __kCFArrayTypeID );
687
691
CFAssert1 (__CFArrayGetType (array ) != __kCFArrayImmutable , __kCFLogAssertion , "%s(): array is immutable" , __PRETTY_FUNCTION__ );
688
692
CHECK_FOR_MUTATION (array );
689
693
_CFArrayReplaceValues (array , CFRangeMake (__CFArrayGetCount (array ), 0 ), & value , 1 );
690
694
}
691
695
692
696
void CFArraySetValueAtIndex (CFMutableArrayRef array , CFIndex idx , const void * value ) {
693
- CF_OBJC_FUNCDISPATCH2 (__kCFArrayTypeID , void , array , " setObject:atIndex:" , value , idx );
697
+ CF_OBJC_FUNCDISPATCHV (__kCFArrayTypeID , void , ( NSMutableArray * ) array , setObject :( id ) value atIndex :( NSUInteger ) idx );
694
698
__CFGenericValidateType (array , __kCFArrayTypeID );
695
699
CFAssert1 (__CFArrayGetType (array ) != __kCFArrayImmutable , __kCFLogAssertion , "%s(): array is immutable" , __PRETTY_FUNCTION__ );
696
700
CFAssert2 (0 <= idx && idx <= __CFArrayGetCount (array ), __kCFLogAssertion , "%s(): index (%d) out of bounds" , __PRETTY_FUNCTION__ , idx );
@@ -717,7 +721,7 @@ void CFArraySetValueAtIndex(CFMutableArrayRef array, CFIndex idx, const void *va
717
721
}
718
722
719
723
void CFArrayInsertValueAtIndex (CFMutableArrayRef array , CFIndex idx , const void * value ) {
720
- CF_OBJC_FUNCDISPATCH2 (__kCFArrayTypeID , void , array , " insertObject:atIndex:" , value , idx );
724
+ CF_OBJC_FUNCDISPATCHV (__kCFArrayTypeID , void , ( NSMutableArray * ) array , insertObject :( id ) value atIndex :( NSUInteger ) idx );
721
725
__CFGenericValidateType (array , __kCFArrayTypeID );
722
726
CFAssert1 (__CFArrayGetType (array ) != __kCFArrayImmutable , __kCFLogAssertion , "%s(): array is immutable" , __PRETTY_FUNCTION__ );
723
727
CFAssert2 (0 <= idx && idx <= __CFArrayGetCount (array ), __kCFLogAssertion , "%s(): index (%d) out of bounds" , __PRETTY_FUNCTION__ , idx );
@@ -730,7 +734,7 @@ void CFArrayInsertValueAtIndex(CFMutableArrayRef array, CFIndex idx, const void
730
734
void CFArrayExchangeValuesAtIndices (CFMutableArrayRef array , CFIndex idx1 , CFIndex idx2 ) {
731
735
const void * tmp ;
732
736
struct __CFArrayBucket * bucket1 , * bucket2 ;
733
- CF_OBJC_FUNCDISPATCH2 (__kCFArrayTypeID , void , array , " exchangeObjectAtIndex:withObjectAtIndex:" , idx1 , idx2 );
737
+ CF_OBJC_FUNCDISPATCHV (__kCFArrayTypeID , void , ( NSMutableArray * ) array , exchangeObjectAtIndex :( NSUInteger ) idx1 withObjectAtIndex :( NSUInteger ) idx2 );
734
738
__CFGenericValidateType (array , __kCFArrayTypeID );
735
739
CFAssert2 (0 <= idx1 && idx1 < __CFArrayGetCount (array ), __kCFLogAssertion , "%s(): index #1 (%d) out of bounds" , __PRETTY_FUNCTION__ , idx1 );
736
740
CFAssert2 (0 <= idx2 && idx2 < __CFArrayGetCount (array ), __kCFLogAssertion , "%s(): index #2 (%d) out of bounds" , __PRETTY_FUNCTION__ , idx2 );
@@ -748,7 +752,7 @@ void CFArrayExchangeValuesAtIndices(CFMutableArrayRef array, CFIndex idx1, CFInd
748
752
}
749
753
750
754
void CFArrayRemoveValueAtIndex (CFMutableArrayRef array , CFIndex idx ) {
751
- CF_OBJC_FUNCDISPATCH1 (__kCFArrayTypeID , void , array , " removeObjectAtIndex:" , idx );
755
+ CF_OBJC_FUNCDISPATCHV (__kCFArrayTypeID , void , ( NSMutableArray * ) array , removeObjectAtIndex :( NSUInteger ) idx );
752
756
__CFGenericValidateType (array , __kCFArrayTypeID );
753
757
CFAssert1 (__CFArrayGetType (array ) != __kCFArrayImmutable , __kCFLogAssertion , "%s(): array is immutable" , __PRETTY_FUNCTION__ );
754
758
CFAssert2 (0 <= idx && idx < __CFArrayGetCount (array ), __kCFLogAssertion , "%s(): index (%d) out of bounds" , __PRETTY_FUNCTION__ , idx );
@@ -757,7 +761,7 @@ void CFArrayRemoveValueAtIndex(CFMutableArrayRef array, CFIndex idx) {
757
761
}
758
762
759
763
void CFArrayRemoveAllValues (CFMutableArrayRef array ) {
760
- CF_OBJC_FUNCDISPATCH0 (__kCFArrayTypeID , void , array , " removeAllObjects" );
764
+ CF_OBJC_FUNCDISPATCHV (__kCFArrayTypeID , void , ( NSMutableArray * ) array , removeAllObjects );
761
765
__CFGenericValidateType (array , __kCFArrayTypeID );
762
766
CFAssert1 (__CFArrayGetType (array ) != __kCFArrayImmutable , __kCFLogAssertion , "%s(): array is immutable" , __PRETTY_FUNCTION__ );
763
767
CHECK_FOR_MUTATION (array );
@@ -905,7 +909,7 @@ void _CFArraySetCapacity(CFMutableArrayRef array, CFIndex cap) {
905
909
906
910
907
911
void CFArrayReplaceValues (CFMutableArrayRef array , CFRange range , const void * * newValues , CFIndex newCount ) {
908
- CF_OBJC_FUNCDISPATCH3 (__kCFArrayTypeID , void , array , " replaceObjectsInRange:withObjects:count:" , range , ( void * * )newValues , newCount );
912
+ CF_OBJC_FUNCDISPATCHV (__kCFArrayTypeID , void , ( NSMutableArray * ) array , replaceObjectsInRange :NSMakeRange ( range . location , range . length ) withObjects :( id * )newValues count :( NSUInteger ) newCount );
909
913
__CFGenericValidateType (array , __kCFArrayTypeID );
910
914
__CFArrayValidateRange (array , range , __PRETTY_FUNCTION__ );
911
915
CFAssert1 (__CFArrayGetType (array ) != __kCFArrayImmutable , __kCFLogAssertion , "%s(): array is immutable" , __PRETTY_FUNCTION__ );
@@ -1037,7 +1041,7 @@ void CFArraySortValues(CFMutableArrayRef array, CFRange range, CFComparatorFunct
1037
1041
Boolean immutable = false;
1038
1042
if (CF_IS_OBJC (__kCFArrayTypeID , array )) {
1039
1043
BOOL result ;
1040
- CF_OBJC_CALL1 ( BOOL , result , array , " isKindOfClass:" , objc_lookUpClass ( " NSMutableArray" ) );
1044
+ result = CF_OBJC_CALLV (( NSMutableArray * ) array , isKindOfClass :[ NSMutableArray class ] );
1041
1045
immutable = !result ;
1042
1046
} else if (__kCFArrayImmutable == __CFArrayGetType (array )) {
1043
1047
immutable = true;
0 commit comments