objc2_core_foundation/generated/
CFBitVector.rs1use 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
12pub type CFBit = u32;
14
15#[doc(alias = "CFBitVectorRef")]
17#[repr(C)]
18pub struct CFBitVector {
19 inner: [u8; 0],
20 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
21}
22
23cf_type!(
24 unsafe impl CFBitVector {}
25);
26#[cfg(feature = "objc2")]
27cf_objc2_type!(
28 unsafe impl RefEncode<"__CFBitVector"> for CFBitVector {}
29);
30
31#[doc(alias = "CFMutableBitVectorRef")]
33#[repr(C)]
34pub struct CFMutableBitVector {
35 inner: [u8; 0],
36 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
37}
38
39cf_type!(
40 unsafe impl CFMutableBitVector: CFBitVector {}
41);
42#[cfg(feature = "objc2")]
43cf_objc2_type!(
44 unsafe impl RefEncode<"__CFBitVector"> for CFMutableBitVector {}
45);
46
47unsafe impl ConcreteType for CFBitVector {
48 #[doc(alias = "CFBitVectorGetTypeID")]
49 #[inline]
50 fn type_id() -> CFTypeID {
51 extern "C-unwind" {
52 fn CFBitVectorGetTypeID() -> CFTypeID;
53 }
54 unsafe { CFBitVectorGetTypeID() }
55 }
56}
57
58impl CFBitVector {
59 #[doc(alias = "CFBitVectorCreate")]
64 #[inline]
65 pub unsafe fn new(
66 allocator: Option<&CFAllocator>,
67 bytes: *const u8,
68 num_bits: CFIndex,
69 ) -> Option<CFRetained<CFBitVector>> {
70 extern "C-unwind" {
71 fn CFBitVectorCreate(
72 allocator: Option<&CFAllocator>,
73 bytes: *const u8,
74 num_bits: CFIndex,
75 ) -> Option<NonNull<CFBitVector>>;
76 }
77 let ret = unsafe { CFBitVectorCreate(allocator, bytes, num_bits) };
78 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
79 }
80
81 #[doc(alias = "CFBitVectorCreateCopy")]
86 #[inline]
87 pub unsafe fn new_copy(
88 allocator: Option<&CFAllocator>,
89 bv: Option<&CFBitVector>,
90 ) -> Option<CFRetained<CFBitVector>> {
91 extern "C-unwind" {
92 fn CFBitVectorCreateCopy(
93 allocator: Option<&CFAllocator>,
94 bv: Option<&CFBitVector>,
95 ) -> Option<NonNull<CFBitVector>>;
96 }
97 let ret = unsafe { CFBitVectorCreateCopy(allocator, bv) };
98 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
99 }
100}
101
102impl CFMutableBitVector {
103 #[doc(alias = "CFBitVectorCreateMutable")]
107 #[inline]
108 pub unsafe fn new(
109 allocator: Option<&CFAllocator>,
110 capacity: CFIndex,
111 ) -> Option<CFRetained<CFMutableBitVector>> {
112 extern "C-unwind" {
113 fn CFBitVectorCreateMutable(
114 allocator: Option<&CFAllocator>,
115 capacity: CFIndex,
116 ) -> Option<NonNull<CFMutableBitVector>>;
117 }
118 let ret = unsafe { CFBitVectorCreateMutable(allocator, capacity) };
119 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
120 }
121
122 #[doc(alias = "CFBitVectorCreateMutableCopy")]
127 #[inline]
128 pub unsafe fn new_copy(
129 allocator: Option<&CFAllocator>,
130 capacity: CFIndex,
131 bv: Option<&CFBitVector>,
132 ) -> Option<CFRetained<CFMutableBitVector>> {
133 extern "C-unwind" {
134 fn CFBitVectorCreateMutableCopy(
135 allocator: Option<&CFAllocator>,
136 capacity: CFIndex,
137 bv: Option<&CFBitVector>,
138 ) -> Option<NonNull<CFMutableBitVector>>;
139 }
140 let ret = unsafe { CFBitVectorCreateMutableCopy(allocator, capacity, bv) };
141 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
142 }
143}
144
145impl CFBitVector {
146 #[doc(alias = "CFBitVectorGetCount")]
147 #[inline]
148 pub fn count(&self) -> CFIndex {
149 extern "C-unwind" {
150 fn CFBitVectorGetCount(bv: &CFBitVector) -> CFIndex;
151 }
152 unsafe { CFBitVectorGetCount(self) }
153 }
154
155 #[doc(alias = "CFBitVectorGetCountOfBit")]
156 #[inline]
157 pub fn count_of_bit(&self, range: CFRange, value: CFBit) -> CFIndex {
158 extern "C-unwind" {
159 fn CFBitVectorGetCountOfBit(bv: &CFBitVector, range: CFRange, value: CFBit) -> CFIndex;
160 }
161 unsafe { CFBitVectorGetCountOfBit(self, range, value) }
162 }
163
164 #[doc(alias = "CFBitVectorContainsBit")]
165 #[inline]
166 pub fn contains_bit(&self, range: CFRange, value: CFBit) -> bool {
167 extern "C-unwind" {
168 fn CFBitVectorContainsBit(bv: &CFBitVector, range: CFRange, value: CFBit) -> Boolean;
169 }
170 let ret = unsafe { CFBitVectorContainsBit(self, range, value) };
171 ret != 0
172 }
173
174 #[doc(alias = "CFBitVectorGetBitAtIndex")]
175 #[inline]
176 pub fn bit_at_index(&self, idx: CFIndex) -> CFBit {
177 extern "C-unwind" {
178 fn CFBitVectorGetBitAtIndex(bv: &CFBitVector, idx: CFIndex) -> CFBit;
179 }
180 unsafe { CFBitVectorGetBitAtIndex(self, idx) }
181 }
182
183 #[doc(alias = "CFBitVectorGetBits")]
187 #[inline]
188 pub unsafe fn bits(&self, range: CFRange, bytes: *mut u8) {
189 extern "C-unwind" {
190 fn CFBitVectorGetBits(bv: &CFBitVector, range: CFRange, bytes: *mut u8);
191 }
192 unsafe { CFBitVectorGetBits(self, range, bytes) }
193 }
194
195 #[doc(alias = "CFBitVectorGetFirstIndexOfBit")]
196 #[inline]
197 pub fn first_index_of_bit(&self, range: CFRange, value: CFBit) -> CFIndex {
198 extern "C-unwind" {
199 fn CFBitVectorGetFirstIndexOfBit(
200 bv: &CFBitVector,
201 range: CFRange,
202 value: CFBit,
203 ) -> CFIndex;
204 }
205 unsafe { CFBitVectorGetFirstIndexOfBit(self, range, value) }
206 }
207
208 #[doc(alias = "CFBitVectorGetLastIndexOfBit")]
209 #[inline]
210 pub fn last_index_of_bit(&self, range: CFRange, value: CFBit) -> CFIndex {
211 extern "C-unwind" {
212 fn CFBitVectorGetLastIndexOfBit(
213 bv: &CFBitVector,
214 range: CFRange,
215 value: CFBit,
216 ) -> CFIndex;
217 }
218 unsafe { CFBitVectorGetLastIndexOfBit(self, range, value) }
219 }
220}
221
222impl CFMutableBitVector {
223 #[doc(alias = "CFBitVectorSetCount")]
227 #[inline]
228 pub unsafe fn set_count(bv: Option<&CFMutableBitVector>, count: CFIndex) {
229 extern "C-unwind" {
230 fn CFBitVectorSetCount(bv: Option<&CFMutableBitVector>, count: CFIndex);
231 }
232 unsafe { CFBitVectorSetCount(bv, count) }
233 }
234
235 #[doc(alias = "CFBitVectorFlipBitAtIndex")]
239 #[inline]
240 pub unsafe fn flip_bit_at_index(bv: Option<&CFMutableBitVector>, idx: CFIndex) {
241 extern "C-unwind" {
242 fn CFBitVectorFlipBitAtIndex(bv: Option<&CFMutableBitVector>, idx: CFIndex);
243 }
244 unsafe { CFBitVectorFlipBitAtIndex(bv, idx) }
245 }
246
247 #[doc(alias = "CFBitVectorFlipBits")]
251 #[inline]
252 pub unsafe fn flip_bits(bv: Option<&CFMutableBitVector>, range: CFRange) {
253 extern "C-unwind" {
254 fn CFBitVectorFlipBits(bv: Option<&CFMutableBitVector>, range: CFRange);
255 }
256 unsafe { CFBitVectorFlipBits(bv, range) }
257 }
258
259 #[doc(alias = "CFBitVectorSetBitAtIndex")]
263 #[inline]
264 pub unsafe fn set_bit_at_index(bv: Option<&CFMutableBitVector>, idx: CFIndex, value: CFBit) {
265 extern "C-unwind" {
266 fn CFBitVectorSetBitAtIndex(
267 bv: Option<&CFMutableBitVector>,
268 idx: CFIndex,
269 value: CFBit,
270 );
271 }
272 unsafe { CFBitVectorSetBitAtIndex(bv, idx, value) }
273 }
274
275 #[doc(alias = "CFBitVectorSetBits")]
279 #[inline]
280 pub unsafe fn set_bits(bv: Option<&CFMutableBitVector>, range: CFRange, value: CFBit) {
281 extern "C-unwind" {
282 fn CFBitVectorSetBits(bv: Option<&CFMutableBitVector>, range: CFRange, value: CFBit);
283 }
284 unsafe { CFBitVectorSetBits(bv, range, value) }
285 }
286
287 #[doc(alias = "CFBitVectorSetAllBits")]
291 #[inline]
292 pub unsafe fn set_all_bits(bv: Option<&CFMutableBitVector>, value: CFBit) {
293 extern "C-unwind" {
294 fn CFBitVectorSetAllBits(bv: Option<&CFMutableBitVector>, value: CFBit);
295 }
296 unsafe { CFBitVectorSetAllBits(bv, value) }
297 }
298}
299
300#[deprecated = "renamed to `CFBitVector::new`"]
301#[inline]
302pub unsafe extern "C-unwind" fn CFBitVectorCreate(
303 allocator: Option<&CFAllocator>,
304 bytes: *const u8,
305 num_bits: CFIndex,
306) -> Option<CFRetained<CFBitVector>> {
307 extern "C-unwind" {
308 fn CFBitVectorCreate(
309 allocator: Option<&CFAllocator>,
310 bytes: *const u8,
311 num_bits: CFIndex,
312 ) -> Option<NonNull<CFBitVector>>;
313 }
314 let ret = unsafe { CFBitVectorCreate(allocator, bytes, num_bits) };
315 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
316}
317
318#[deprecated = "renamed to `CFBitVector::new_copy`"]
319#[inline]
320pub unsafe extern "C-unwind" fn CFBitVectorCreateCopy(
321 allocator: Option<&CFAllocator>,
322 bv: Option<&CFBitVector>,
323) -> Option<CFRetained<CFBitVector>> {
324 extern "C-unwind" {
325 fn CFBitVectorCreateCopy(
326 allocator: Option<&CFAllocator>,
327 bv: Option<&CFBitVector>,
328 ) -> Option<NonNull<CFBitVector>>;
329 }
330 let ret = unsafe { CFBitVectorCreateCopy(allocator, bv) };
331 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
332}
333
334#[deprecated = "renamed to `CFMutableBitVector::new`"]
335#[inline]
336pub unsafe extern "C-unwind" fn CFBitVectorCreateMutable(
337 allocator: Option<&CFAllocator>,
338 capacity: CFIndex,
339) -> Option<CFRetained<CFMutableBitVector>> {
340 extern "C-unwind" {
341 fn CFBitVectorCreateMutable(
342 allocator: Option<&CFAllocator>,
343 capacity: CFIndex,
344 ) -> Option<NonNull<CFMutableBitVector>>;
345 }
346 let ret = unsafe { CFBitVectorCreateMutable(allocator, capacity) };
347 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
348}
349
350#[deprecated = "renamed to `CFMutableBitVector::new_copy`"]
351#[inline]
352pub unsafe extern "C-unwind" fn CFBitVectorCreateMutableCopy(
353 allocator: Option<&CFAllocator>,
354 capacity: CFIndex,
355 bv: Option<&CFBitVector>,
356) -> Option<CFRetained<CFMutableBitVector>> {
357 extern "C-unwind" {
358 fn CFBitVectorCreateMutableCopy(
359 allocator: Option<&CFAllocator>,
360 capacity: CFIndex,
361 bv: Option<&CFBitVector>,
362 ) -> Option<NonNull<CFMutableBitVector>>;
363 }
364 let ret = unsafe { CFBitVectorCreateMutableCopy(allocator, capacity, bv) };
365 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
366}
367
368#[deprecated = "renamed to `CFBitVector::count`"]
369#[inline]
370pub extern "C-unwind" fn CFBitVectorGetCount(bv: &CFBitVector) -> CFIndex {
371 extern "C-unwind" {
372 fn CFBitVectorGetCount(bv: &CFBitVector) -> CFIndex;
373 }
374 unsafe { CFBitVectorGetCount(bv) }
375}
376
377#[deprecated = "renamed to `CFBitVector::count_of_bit`"]
378#[inline]
379pub extern "C-unwind" fn CFBitVectorGetCountOfBit(
380 bv: &CFBitVector,
381 range: CFRange,
382 value: CFBit,
383) -> CFIndex {
384 extern "C-unwind" {
385 fn CFBitVectorGetCountOfBit(bv: &CFBitVector, range: CFRange, value: CFBit) -> CFIndex;
386 }
387 unsafe { CFBitVectorGetCountOfBit(bv, range, value) }
388}
389
390#[deprecated = "renamed to `CFBitVector::contains_bit`"]
391#[inline]
392pub extern "C-unwind" fn CFBitVectorContainsBit(
393 bv: &CFBitVector,
394 range: CFRange,
395 value: CFBit,
396) -> bool {
397 extern "C-unwind" {
398 fn CFBitVectorContainsBit(bv: &CFBitVector, range: CFRange, value: CFBit) -> Boolean;
399 }
400 let ret = unsafe { CFBitVectorContainsBit(bv, range, value) };
401 ret != 0
402}
403
404#[deprecated = "renamed to `CFBitVector::bit_at_index`"]
405#[inline]
406pub extern "C-unwind" fn CFBitVectorGetBitAtIndex(bv: &CFBitVector, idx: CFIndex) -> CFBit {
407 extern "C-unwind" {
408 fn CFBitVectorGetBitAtIndex(bv: &CFBitVector, idx: CFIndex) -> CFBit;
409 }
410 unsafe { CFBitVectorGetBitAtIndex(bv, idx) }
411}
412
413extern "C-unwind" {
414 #[deprecated = "renamed to `CFBitVector::bits`"]
415 pub fn CFBitVectorGetBits(bv: &CFBitVector, range: CFRange, bytes: *mut u8);
416}
417
418#[deprecated = "renamed to `CFBitVector::first_index_of_bit`"]
419#[inline]
420pub extern "C-unwind" fn CFBitVectorGetFirstIndexOfBit(
421 bv: &CFBitVector,
422 range: CFRange,
423 value: CFBit,
424) -> CFIndex {
425 extern "C-unwind" {
426 fn CFBitVectorGetFirstIndexOfBit(bv: &CFBitVector, range: CFRange, value: CFBit)
427 -> CFIndex;
428 }
429 unsafe { CFBitVectorGetFirstIndexOfBit(bv, range, value) }
430}
431
432#[deprecated = "renamed to `CFBitVector::last_index_of_bit`"]
433#[inline]
434pub extern "C-unwind" fn CFBitVectorGetLastIndexOfBit(
435 bv: &CFBitVector,
436 range: CFRange,
437 value: CFBit,
438) -> CFIndex {
439 extern "C-unwind" {
440 fn CFBitVectorGetLastIndexOfBit(bv: &CFBitVector, range: CFRange, value: CFBit) -> CFIndex;
441 }
442 unsafe { CFBitVectorGetLastIndexOfBit(bv, range, value) }
443}
444
445extern "C-unwind" {
446 #[deprecated = "renamed to `CFMutableBitVector::set_count`"]
447 pub fn CFBitVectorSetCount(bv: Option<&CFMutableBitVector>, count: CFIndex);
448}
449
450extern "C-unwind" {
451 #[deprecated = "renamed to `CFMutableBitVector::flip_bit_at_index`"]
452 pub fn CFBitVectorFlipBitAtIndex(bv: Option<&CFMutableBitVector>, idx: CFIndex);
453}
454
455extern "C-unwind" {
456 #[deprecated = "renamed to `CFMutableBitVector::flip_bits`"]
457 pub fn CFBitVectorFlipBits(bv: Option<&CFMutableBitVector>, range: CFRange);
458}
459
460extern "C-unwind" {
461 #[deprecated = "renamed to `CFMutableBitVector::set_bit_at_index`"]
462 pub fn CFBitVectorSetBitAtIndex(bv: Option<&CFMutableBitVector>, idx: CFIndex, value: CFBit);
463}
464
465extern "C-unwind" {
466 #[deprecated = "renamed to `CFMutableBitVector::set_bits`"]
467 pub fn CFBitVectorSetBits(bv: Option<&CFMutableBitVector>, range: CFRange, value: CFBit);
468}
469
470extern "C-unwind" {
471 #[deprecated = "renamed to `CFMutableBitVector::set_all_bits`"]
472 pub fn CFBitVectorSetAllBits(bv: Option<&CFMutableBitVector>, value: CFBit);
473}