objc2_core_foundation/generated/
CFBitVector.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfbit?language=objc)
13pub type CFBit = u32;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfbitvector?language=objc)
16#[repr(C)]
17pub struct CFBitVector {
18    inner: [u8; 0],
19    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22cf_type!(
23    unsafe impl CFBitVector {}
24);
25#[cfg(feature = "objc2")]
26cf_objc2_type!(
27    unsafe impl RefEncode<"__CFBitVector"> for CFBitVector {}
28);
29
30/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfmutablebitvector?language=objc)
31#[repr(C)]
32pub struct CFMutableBitVector {
33    inner: [u8; 0],
34    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
35}
36
37cf_type!(
38    unsafe impl CFMutableBitVector: CFBitVector {}
39);
40#[cfg(feature = "objc2")]
41cf_objc2_type!(
42    unsafe impl RefEncode<"__CFBitVector"> for CFMutableBitVector {}
43);
44
45unsafe impl ConcreteType for CFBitVector {
46    #[doc(alias = "CFBitVectorGetTypeID")]
47    #[inline]
48    fn type_id() -> CFTypeID {
49        extern "C-unwind" {
50            fn CFBitVectorGetTypeID() -> CFTypeID;
51        }
52        unsafe { CFBitVectorGetTypeID() }
53    }
54}
55
56impl CFBitVector {
57    #[doc(alias = "CFBitVectorCreate")]
58    #[inline]
59    pub unsafe fn new(
60        allocator: Option<&CFAllocator>,
61        bytes: *const u8,
62        num_bits: CFIndex,
63    ) -> Option<CFRetained<CFBitVector>> {
64        extern "C-unwind" {
65            fn CFBitVectorCreate(
66                allocator: Option<&CFAllocator>,
67                bytes: *const u8,
68                num_bits: CFIndex,
69            ) -> Option<NonNull<CFBitVector>>;
70        }
71        let ret = unsafe { CFBitVectorCreate(allocator, bytes, num_bits) };
72        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
73    }
74
75    #[doc(alias = "CFBitVectorCreateCopy")]
76    #[inline]
77    pub unsafe fn new_copy(
78        allocator: Option<&CFAllocator>,
79        bv: Option<&CFBitVector>,
80    ) -> Option<CFRetained<CFBitVector>> {
81        extern "C-unwind" {
82            fn CFBitVectorCreateCopy(
83                allocator: Option<&CFAllocator>,
84                bv: Option<&CFBitVector>,
85            ) -> Option<NonNull<CFBitVector>>;
86        }
87        let ret = unsafe { CFBitVectorCreateCopy(allocator, bv) };
88        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
89    }
90}
91
92impl CFMutableBitVector {
93    #[doc(alias = "CFBitVectorCreateMutable")]
94    #[inline]
95    pub unsafe fn new(
96        allocator: Option<&CFAllocator>,
97        capacity: CFIndex,
98    ) -> Option<CFRetained<CFMutableBitVector>> {
99        extern "C-unwind" {
100            fn CFBitVectorCreateMutable(
101                allocator: Option<&CFAllocator>,
102                capacity: CFIndex,
103            ) -> Option<NonNull<CFMutableBitVector>>;
104        }
105        let ret = unsafe { CFBitVectorCreateMutable(allocator, capacity) };
106        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
107    }
108
109    #[doc(alias = "CFBitVectorCreateMutableCopy")]
110    #[inline]
111    pub unsafe fn new_copy(
112        allocator: Option<&CFAllocator>,
113        capacity: CFIndex,
114        bv: Option<&CFBitVector>,
115    ) -> Option<CFRetained<CFMutableBitVector>> {
116        extern "C-unwind" {
117            fn CFBitVectorCreateMutableCopy(
118                allocator: Option<&CFAllocator>,
119                capacity: CFIndex,
120                bv: Option<&CFBitVector>,
121            ) -> Option<NonNull<CFMutableBitVector>>;
122        }
123        let ret = unsafe { CFBitVectorCreateMutableCopy(allocator, capacity, bv) };
124        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
125    }
126}
127
128impl CFBitVector {
129    #[doc(alias = "CFBitVectorGetCount")]
130    #[inline]
131    pub unsafe fn count(self: &CFBitVector) -> CFIndex {
132        extern "C-unwind" {
133            fn CFBitVectorGetCount(bv: &CFBitVector) -> CFIndex;
134        }
135        unsafe { CFBitVectorGetCount(self) }
136    }
137
138    #[doc(alias = "CFBitVectorGetCountOfBit")]
139    #[inline]
140    pub unsafe fn count_of_bit(self: &CFBitVector, range: CFRange, value: CFBit) -> CFIndex {
141        extern "C-unwind" {
142            fn CFBitVectorGetCountOfBit(bv: &CFBitVector, range: CFRange, value: CFBit) -> CFIndex;
143        }
144        unsafe { CFBitVectorGetCountOfBit(self, range, value) }
145    }
146
147    #[doc(alias = "CFBitVectorContainsBit")]
148    #[inline]
149    pub unsafe fn contains_bit(self: &CFBitVector, range: CFRange, value: CFBit) -> bool {
150        extern "C-unwind" {
151            fn CFBitVectorContainsBit(bv: &CFBitVector, range: CFRange, value: CFBit) -> Boolean;
152        }
153        let ret = unsafe { CFBitVectorContainsBit(self, range, value) };
154        ret != 0
155    }
156
157    #[doc(alias = "CFBitVectorGetBitAtIndex")]
158    #[inline]
159    pub unsafe fn bit_at_index(self: &CFBitVector, idx: CFIndex) -> CFBit {
160        extern "C-unwind" {
161            fn CFBitVectorGetBitAtIndex(bv: &CFBitVector, idx: CFIndex) -> CFBit;
162        }
163        unsafe { CFBitVectorGetBitAtIndex(self, idx) }
164    }
165
166    #[doc(alias = "CFBitVectorGetBits")]
167    #[inline]
168    pub unsafe fn bits(self: &CFBitVector, range: CFRange, bytes: *mut u8) {
169        extern "C-unwind" {
170            fn CFBitVectorGetBits(bv: &CFBitVector, range: CFRange, bytes: *mut u8);
171        }
172        unsafe { CFBitVectorGetBits(self, range, bytes) }
173    }
174
175    #[doc(alias = "CFBitVectorGetFirstIndexOfBit")]
176    #[inline]
177    pub unsafe fn first_index_of_bit(self: &CFBitVector, range: CFRange, value: CFBit) -> CFIndex {
178        extern "C-unwind" {
179            fn CFBitVectorGetFirstIndexOfBit(
180                bv: &CFBitVector,
181                range: CFRange,
182                value: CFBit,
183            ) -> CFIndex;
184        }
185        unsafe { CFBitVectorGetFirstIndexOfBit(self, range, value) }
186    }
187
188    #[doc(alias = "CFBitVectorGetLastIndexOfBit")]
189    #[inline]
190    pub unsafe fn last_index_of_bit(self: &CFBitVector, range: CFRange, value: CFBit) -> CFIndex {
191        extern "C-unwind" {
192            fn CFBitVectorGetLastIndexOfBit(
193                bv: &CFBitVector,
194                range: CFRange,
195                value: CFBit,
196            ) -> CFIndex;
197        }
198        unsafe { CFBitVectorGetLastIndexOfBit(self, range, value) }
199    }
200}
201
202impl CFMutableBitVector {
203    #[doc(alias = "CFBitVectorSetCount")]
204    #[inline]
205    pub unsafe fn set_count(bv: Option<&CFMutableBitVector>, count: CFIndex) {
206        extern "C-unwind" {
207            fn CFBitVectorSetCount(bv: Option<&CFMutableBitVector>, count: CFIndex);
208        }
209        unsafe { CFBitVectorSetCount(bv, count) }
210    }
211
212    #[doc(alias = "CFBitVectorFlipBitAtIndex")]
213    #[inline]
214    pub unsafe fn flip_bit_at_index(bv: Option<&CFMutableBitVector>, idx: CFIndex) {
215        extern "C-unwind" {
216            fn CFBitVectorFlipBitAtIndex(bv: Option<&CFMutableBitVector>, idx: CFIndex);
217        }
218        unsafe { CFBitVectorFlipBitAtIndex(bv, idx) }
219    }
220
221    #[doc(alias = "CFBitVectorFlipBits")]
222    #[inline]
223    pub unsafe fn flip_bits(bv: Option<&CFMutableBitVector>, range: CFRange) {
224        extern "C-unwind" {
225            fn CFBitVectorFlipBits(bv: Option<&CFMutableBitVector>, range: CFRange);
226        }
227        unsafe { CFBitVectorFlipBits(bv, range) }
228    }
229
230    #[doc(alias = "CFBitVectorSetBitAtIndex")]
231    #[inline]
232    pub unsafe fn set_bit_at_index(bv: Option<&CFMutableBitVector>, idx: CFIndex, value: CFBit) {
233        extern "C-unwind" {
234            fn CFBitVectorSetBitAtIndex(
235                bv: Option<&CFMutableBitVector>,
236                idx: CFIndex,
237                value: CFBit,
238            );
239        }
240        unsafe { CFBitVectorSetBitAtIndex(bv, idx, value) }
241    }
242
243    #[doc(alias = "CFBitVectorSetBits")]
244    #[inline]
245    pub unsafe fn set_bits(bv: Option<&CFMutableBitVector>, range: CFRange, value: CFBit) {
246        extern "C-unwind" {
247            fn CFBitVectorSetBits(bv: Option<&CFMutableBitVector>, range: CFRange, value: CFBit);
248        }
249        unsafe { CFBitVectorSetBits(bv, range, value) }
250    }
251
252    #[doc(alias = "CFBitVectorSetAllBits")]
253    #[inline]
254    pub unsafe fn set_all_bits(bv: Option<&CFMutableBitVector>, value: CFBit) {
255        extern "C-unwind" {
256            fn CFBitVectorSetAllBits(bv: Option<&CFMutableBitVector>, value: CFBit);
257        }
258        unsafe { CFBitVectorSetAllBits(bv, value) }
259    }
260}
261
262#[deprecated = "renamed to `CFBitVector::new`"]
263#[inline]
264pub unsafe extern "C-unwind" fn CFBitVectorCreate(
265    allocator: Option<&CFAllocator>,
266    bytes: *const u8,
267    num_bits: CFIndex,
268) -> Option<CFRetained<CFBitVector>> {
269    extern "C-unwind" {
270        fn CFBitVectorCreate(
271            allocator: Option<&CFAllocator>,
272            bytes: *const u8,
273            num_bits: CFIndex,
274        ) -> Option<NonNull<CFBitVector>>;
275    }
276    let ret = unsafe { CFBitVectorCreate(allocator, bytes, num_bits) };
277    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
278}
279
280#[deprecated = "renamed to `CFBitVector::new_copy`"]
281#[inline]
282pub unsafe extern "C-unwind" fn CFBitVectorCreateCopy(
283    allocator: Option<&CFAllocator>,
284    bv: Option<&CFBitVector>,
285) -> Option<CFRetained<CFBitVector>> {
286    extern "C-unwind" {
287        fn CFBitVectorCreateCopy(
288            allocator: Option<&CFAllocator>,
289            bv: Option<&CFBitVector>,
290        ) -> Option<NonNull<CFBitVector>>;
291    }
292    let ret = unsafe { CFBitVectorCreateCopy(allocator, bv) };
293    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
294}
295
296#[deprecated = "renamed to `CFMutableBitVector::new`"]
297#[inline]
298pub unsafe extern "C-unwind" fn CFBitVectorCreateMutable(
299    allocator: Option<&CFAllocator>,
300    capacity: CFIndex,
301) -> Option<CFRetained<CFMutableBitVector>> {
302    extern "C-unwind" {
303        fn CFBitVectorCreateMutable(
304            allocator: Option<&CFAllocator>,
305            capacity: CFIndex,
306        ) -> Option<NonNull<CFMutableBitVector>>;
307    }
308    let ret = unsafe { CFBitVectorCreateMutable(allocator, capacity) };
309    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
310}
311
312#[deprecated = "renamed to `CFMutableBitVector::new_copy`"]
313#[inline]
314pub unsafe extern "C-unwind" fn CFBitVectorCreateMutableCopy(
315    allocator: Option<&CFAllocator>,
316    capacity: CFIndex,
317    bv: Option<&CFBitVector>,
318) -> Option<CFRetained<CFMutableBitVector>> {
319    extern "C-unwind" {
320        fn CFBitVectorCreateMutableCopy(
321            allocator: Option<&CFAllocator>,
322            capacity: CFIndex,
323            bv: Option<&CFBitVector>,
324        ) -> Option<NonNull<CFMutableBitVector>>;
325    }
326    let ret = unsafe { CFBitVectorCreateMutableCopy(allocator, capacity, bv) };
327    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
328}
329
330extern "C-unwind" {
331    #[deprecated = "renamed to `CFBitVector::count`"]
332    pub fn CFBitVectorGetCount(bv: &CFBitVector) -> CFIndex;
333}
334
335extern "C-unwind" {
336    #[deprecated = "renamed to `CFBitVector::count_of_bit`"]
337    pub fn CFBitVectorGetCountOfBit(bv: &CFBitVector, range: CFRange, value: CFBit) -> CFIndex;
338}
339
340#[deprecated = "renamed to `CFBitVector::contains_bit`"]
341#[inline]
342pub unsafe extern "C-unwind" fn CFBitVectorContainsBit(
343    bv: &CFBitVector,
344    range: CFRange,
345    value: CFBit,
346) -> bool {
347    extern "C-unwind" {
348        fn CFBitVectorContainsBit(bv: &CFBitVector, range: CFRange, value: CFBit) -> Boolean;
349    }
350    let ret = unsafe { CFBitVectorContainsBit(bv, range, value) };
351    ret != 0
352}
353
354extern "C-unwind" {
355    #[deprecated = "renamed to `CFBitVector::bit_at_index`"]
356    pub fn CFBitVectorGetBitAtIndex(bv: &CFBitVector, idx: CFIndex) -> CFBit;
357}
358
359extern "C-unwind" {
360    #[deprecated = "renamed to `CFBitVector::bits`"]
361    pub fn CFBitVectorGetBits(bv: &CFBitVector, range: CFRange, bytes: *mut u8);
362}
363
364extern "C-unwind" {
365    #[deprecated = "renamed to `CFBitVector::first_index_of_bit`"]
366    pub fn CFBitVectorGetFirstIndexOfBit(bv: &CFBitVector, range: CFRange, value: CFBit)
367        -> CFIndex;
368}
369
370extern "C-unwind" {
371    #[deprecated = "renamed to `CFBitVector::last_index_of_bit`"]
372    pub fn CFBitVectorGetLastIndexOfBit(bv: &CFBitVector, range: CFRange, value: CFBit) -> CFIndex;
373}
374
375extern "C-unwind" {
376    #[deprecated = "renamed to `CFMutableBitVector::set_count`"]
377    pub fn CFBitVectorSetCount(bv: Option<&CFMutableBitVector>, count: CFIndex);
378}
379
380extern "C-unwind" {
381    #[deprecated = "renamed to `CFMutableBitVector::flip_bit_at_index`"]
382    pub fn CFBitVectorFlipBitAtIndex(bv: Option<&CFMutableBitVector>, idx: CFIndex);
383}
384
385extern "C-unwind" {
386    #[deprecated = "renamed to `CFMutableBitVector::flip_bits`"]
387    pub fn CFBitVectorFlipBits(bv: Option<&CFMutableBitVector>, range: CFRange);
388}
389
390extern "C-unwind" {
391    #[deprecated = "renamed to `CFMutableBitVector::set_bit_at_index`"]
392    pub fn CFBitVectorSetBitAtIndex(bv: Option<&CFMutableBitVector>, idx: CFIndex, value: CFBit);
393}
394
395extern "C-unwind" {
396    #[deprecated = "renamed to `CFMutableBitVector::set_bits`"]
397    pub fn CFBitVectorSetBits(bv: Option<&CFMutableBitVector>, range: CFRange, value: CFBit);
398}
399
400extern "C-unwind" {
401    #[deprecated = "renamed to `CFMutableBitVector::set_all_bits`"]
402    pub fn CFBitVectorSetAllBits(bv: Option<&CFMutableBitVector>, value: CFBit);
403}