Skip to content

Commit f58166d

Browse files
authored
Auto merge of #491 - ldm0:more_array, r=jdm
Add more functions to CFArray None
2 parents 669cb0c + 09763eb commit f58166d

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

core-foundation-sys/src/array.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99

1010
use std::os::raw::c_void;
1111

12-
use base::{CFRange, CFIndex, CFAllocatorRef, CFTypeID, Boolean};
12+
use base::{CFRange, CFIndex, CFAllocatorRef, CFTypeID, Boolean, CFComparisonResult};
1313
use string::CFStringRef;
1414

1515
pub type CFArrayRetainCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void;
1616
pub type CFArrayReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void);
1717
pub type CFArrayCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef;
1818
pub type CFArrayEqualCallBack = extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean;
19+
pub type CFArrayApplierFunction = extern "C" fn(value: *const c_void, context: *mut c_void);
20+
pub type CFComparatorFunction = extern "C" fn(val1: *const c_void, val2: *const c_void) -> CFComparisonResult;
1921

2022
#[repr(C)]
2123
#[derive(Clone, Copy)]
@@ -31,25 +33,35 @@ pub struct CFArrayCallBacks {
3133
pub struct __CFArray(c_void);
3234

3335
pub type CFArrayRef = *const __CFArray;
36+
pub type CFMutableArrayRef = *mut __CFArray;
3437

3538
extern {
3639
/*
3740
* CFArray.h
3841
*/
3942
pub static kCFTypeArrayCallBacks: CFArrayCallBacks;
4043

41-
pub fn CFArrayCreate(allocator: CFAllocatorRef, values: *const *const c_void,
42-
numValues: CFIndex, callBacks: *const CFArrayCallBacks) -> CFArrayRef;
44+
pub fn CFArrayGetTypeID() -> CFTypeID;
45+
pub fn CFArrayCreate(allocator: CFAllocatorRef, values: *const *const c_void, numValues: CFIndex, callBacks: *const CFArrayCallBacks) -> CFArrayRef;
4346
pub fn CFArrayCreateCopy(allocator: CFAllocatorRef , theArray: CFArrayRef) -> CFArrayRef;
44-
45-
// CFArrayBSearchValues
46-
// CFArrayContainsValue
47+
pub fn CFArrayCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex, callBacks: *const CFArrayCallBacks) -> CFMutableArrayRef;
48+
pub fn CFArrayCreateMutableCopy(allocator: CFAllocatorRef, capacity: CFIndex, theArray: CFArrayRef)-> CFMutableArrayRef;
4749
pub fn CFArrayGetCount(theArray: CFArrayRef) -> CFIndex;
48-
// CFArrayGetCountOfValue
49-
// CFArrayGetFirstIndexOfValue
50-
// CFArrayGetLastIndexOfValue
51-
pub fn CFArrayGetValues(theArray: CFArrayRef, range: CFRange, values: *mut *const c_void);
50+
pub fn CFArrayGetCountOfValue(theArray: CFArrayRef, range: CFRange, value: *const c_void) -> CFIndex;
51+
pub fn CFArrayContainsValue(theArray: CFArrayRef, range: CFRange, value: *const c_void) -> Boolean;
5252
pub fn CFArrayGetValueAtIndex(theArray: CFArrayRef, idx: CFIndex) -> *const c_void;
53-
// CFArrayApplyFunction
54-
pub fn CFArrayGetTypeID() -> CFTypeID;
53+
pub fn CFArrayGetValues(theArray: CFArrayRef, range: CFRange, values: *mut *const c_void);
54+
pub fn CFArrayApplyFunction(theArray: CFArrayRef, range: CFRange, applier: CFArrayApplierFunction, context: *mut c_void);
55+
pub fn CFArrayGetFirstIndexOfValue(theArray: CFArrayRef, range: CFRange, value: *const c_void) -> CFIndex;
56+
pub fn CFArrayGetLastIndexOfValue(theArray: CFArrayRef, range: CFRange, value: *const c_void) -> CFIndex;
57+
pub fn CFArrayBSearchValues(theArray: CFArrayRef, range: CFRange, value: *const c_void, comparator: CFComparatorFunction, context: *mut c_void) -> CFIndex;
58+
pub fn CFArrayAppendValue(theArray: CFMutableArrayRef, value: *const c_void);
59+
pub fn CFArrayInsertValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex, value: *const c_void);
60+
pub fn CFArraySetValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex, value: *const c_void);
61+
pub fn CFArrayRemoveValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex);
62+
pub fn CFArrayRemoveAllValues(theArray: CFMutableArrayRef);
63+
pub fn CFArrayReplaceValues(theArray: CFMutableArrayRef, range: CFRange, newValues: *mut *const c_void, newCount: CFIndex);
64+
pub fn CFArrayExchangeValuesAtIndices(theArray: CFMutableArrayRef, idx1: CFIndex, idx2: CFIndex);
65+
pub fn CFArraySortValues(theArray: CFMutableArrayRef, range: CFRange, comparator: CFComparatorFunction, context: *mut c_void);
66+
pub fn CFArrayAppendArray(theArray: CFMutableArrayRef, otherArray: CFArrayRef, otherRange: CFRange );
5567
}

0 commit comments

Comments
 (0)