objc2-core-foundation 0.3.2

Bindings to the CoreFoundation framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;

use crate::*;

/// This is the type of a reference to immutable CFCharacterSets.
///
/// This is toll-free bridged with `NSCharacterSet`.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfcharacterset?language=objc)
#[doc(alias = "CFCharacterSetRef")]
#[repr(C)]
pub struct CFCharacterSet {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

cf_type!(
    unsafe impl CFCharacterSet {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
    unsafe impl RefEncode<"__CFCharacterSet"> for CFCharacterSet {}
);

/// This is the type of a reference to mutable CFMutableCharacterSets.
///
/// This is toll-free bridged with `NSMutableCharacterSet`.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfmutablecharacterset?language=objc)
#[doc(alias = "CFMutableCharacterSetRef")]
#[repr(C)]
pub struct CFMutableCharacterSet {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

cf_type!(
    unsafe impl CFMutableCharacterSet: CFCharacterSet {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
    unsafe impl RefEncode<"__CFCharacterSet"> for CFMutableCharacterSet {}
);

/// Type of the predefined CFCharacterSet selector values.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfcharactersetpredefinedset?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CFCharacterSetPredefinedSet(pub CFIndex);
impl CFCharacterSetPredefinedSet {
    #[doc(alias = "kCFCharacterSetControl")]
    pub const Control: Self = Self(1);
    #[doc(alias = "kCFCharacterSetWhitespace")]
    pub const Whitespace: Self = Self(2);
    #[doc(alias = "kCFCharacterSetWhitespaceAndNewline")]
    pub const WhitespaceAndNewline: Self = Self(3);
    #[doc(alias = "kCFCharacterSetDecimalDigit")]
    pub const DecimalDigit: Self = Self(4);
    #[doc(alias = "kCFCharacterSetLetter")]
    pub const Letter: Self = Self(5);
    #[doc(alias = "kCFCharacterSetLowercaseLetter")]
    pub const LowercaseLetter: Self = Self(6);
    #[doc(alias = "kCFCharacterSetUppercaseLetter")]
    pub const UppercaseLetter: Self = Self(7);
    #[doc(alias = "kCFCharacterSetNonBase")]
    pub const NonBase: Self = Self(8);
    #[doc(alias = "kCFCharacterSetDecomposable")]
    pub const Decomposable: Self = Self(9);
    #[doc(alias = "kCFCharacterSetAlphaNumeric")]
    pub const AlphaNumeric: Self = Self(10);
    #[doc(alias = "kCFCharacterSetPunctuation")]
    pub const Punctuation: Self = Self(11);
    #[doc(alias = "kCFCharacterSetCapitalizedLetter")]
    pub const CapitalizedLetter: Self = Self(13);
    #[doc(alias = "kCFCharacterSetSymbol")]
    pub const Symbol: Self = Self(14);
    #[doc(alias = "kCFCharacterSetNewline")]
    pub const Newline: Self = Self(15);
    #[doc(alias = "kCFCharacterSetIllegal")]
    pub const Illegal: Self = Self(12);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CFCharacterSetPredefinedSet {
    const ENCODING: Encoding = CFIndex::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CFCharacterSetPredefinedSet {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

unsafe impl ConcreteType for CFCharacterSet {
    /// Returns the type identifier of all CFCharacterSet instances.
    #[doc(alias = "CFCharacterSetGetTypeID")]
    #[inline]
    fn type_id() -> CFTypeID {
        extern "C-unwind" {
            fn CFCharacterSetGetTypeID() -> CFTypeID;
        }
        unsafe { CFCharacterSetGetTypeID() }
    }
}

impl CFCharacterSet {
    /// Returns a predefined CFCharacterSet instance.
    ///
    /// Parameter `theSetIdentifier`: The CFCharacterSetPredefinedSet selector
    /// which specifies the predefined character set.  If the
    /// value is not in CFCharacterSetPredefinedSet, the behavior
    /// is undefined.
    ///
    /// Returns: A reference to the predefined immutable CFCharacterSet.
    /// This instance is owned by CF.
    #[doc(alias = "CFCharacterSetGetPredefined")]
    #[inline]
    pub fn predefined(
        the_set_identifier: CFCharacterSetPredefinedSet,
    ) -> Option<CFRetained<CFCharacterSet>> {
        extern "C-unwind" {
            fn CFCharacterSetGetPredefined(
                the_set_identifier: CFCharacterSetPredefinedSet,
            ) -> Option<NonNull<CFCharacterSet>>;
        }
        let ret = unsafe { CFCharacterSetGetPredefined(the_set_identifier) };
        ret.map(|ret| unsafe { CFRetained::retain(ret) })
    }

    /// Creates a new immutable character set with the values from the given range.
    ///
    /// Parameter `alloc`: The CFAllocator which should be used to allocate
    /// memory for the array and its storage for values. This
    /// parameter may be NULL in which case the current default
    /// CFAllocator is used. If this reference is not a valid
    /// CFAllocator, the behavior is undefined.
    ///
    /// Parameter `theRange`: The CFRange which should be used to specify the
    /// Unicode range the character set is filled with.  It
    /// accepts the range in 32-bit in the UTF-32 format.  The
    /// valid character point range is from 0x00000 to 0x10FFFF.
    /// If the range is outside of the valid Unicode character
    /// point, the behavior is undefined.
    ///
    /// Returns: A reference to the new immutable CFCharacterSet.
    ///
    /// # Safety
    ///
    /// `alloc` might not allow `None`.
    #[doc(alias = "CFCharacterSetCreateWithCharactersInRange")]
    #[inline]
    pub unsafe fn with_characters_in_range(
        alloc: Option<&CFAllocator>,
        the_range: CFRange,
    ) -> Option<CFRetained<CFCharacterSet>> {
        extern "C-unwind" {
            fn CFCharacterSetCreateWithCharactersInRange(
                alloc: Option<&CFAllocator>,
                the_range: CFRange,
            ) -> Option<NonNull<CFCharacterSet>>;
        }
        let ret = unsafe { CFCharacterSetCreateWithCharactersInRange(alloc, the_range) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Creates a new immutable character set with the values in the given string.
    ///
    /// Parameter `alloc`: The CFAllocator which should be used to allocate
    /// memory for the array and its storage for values. This
    /// parameter may be NULL in which case the current default
    /// CFAllocator is used. If this reference is not a valid
    /// CFAllocator, the behavior is undefined.
    ///
    /// Parameter `theString`: The CFString which should be used to specify
    /// the Unicode characters the character set is filled with.
    /// If this parameter is not a valid CFString, the behavior
    /// is undefined.
    ///
    /// Returns: A reference to the new immutable CFCharacterSet.
    ///
    /// # Safety
    ///
    /// - `alloc` might not allow `None`.
    /// - `the_string` might not allow `None`.
    #[doc(alias = "CFCharacterSetCreateWithCharactersInString")]
    #[inline]
    pub unsafe fn with_characters_in_string(
        alloc: Option<&CFAllocator>,
        the_string: Option<&CFString>,
    ) -> Option<CFRetained<CFCharacterSet>> {
        extern "C-unwind" {
            fn CFCharacterSetCreateWithCharactersInString(
                alloc: Option<&CFAllocator>,
                the_string: Option<&CFString>,
            ) -> Option<NonNull<CFCharacterSet>>;
        }
        let ret = unsafe { CFCharacterSetCreateWithCharactersInString(alloc, the_string) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Creates a new immutable character set with the bitmap representtion in the given data.
    ///
    /// Parameter `alloc`: The CFAllocator which should be used to allocate
    /// memory for the array and its storage for values. This
    /// parameter may be NULL in which case the current default
    /// CFAllocator is used. If this reference is not a valid
    /// CFAllocator, the behavior is undefined.
    ///
    /// Parameter `theData`: The CFData which should be used to specify the
    /// bitmap representation of the Unicode character points
    /// the character set is filled with.  The bitmap
    /// representation could contain all the Unicode character
    /// range starting from BMP to Plane 16.  The first 8192 bytes
    /// of the data represent the BMP range.  The BMP range 8192
    /// bytes can be followed by zero to sixteen 8192 byte
    /// bitmaps, each one with the plane index byte prepended.
    /// For example, the bitmap representing the BMP and Plane 2
    /// has the size of 16385 bytes (8192 bytes for BMP, 1 byte
    /// index + 8192 bytes bitmap for Plane 2).  The plane index
    /// byte, in this case, contains the integer value two.  If
    /// this parameter is not a valid CFData or it contains a
    /// Plane index byte outside of the valid Plane range
    /// (1 to 16), the behavior is undefined.
    ///
    /// Returns: A reference to the new immutable CFCharacterSet.
    ///
    /// # Safety
    ///
    /// - `alloc` might not allow `None`.
    /// - `the_data` might not allow `None`.
    #[doc(alias = "CFCharacterSetCreateWithBitmapRepresentation")]
    #[cfg(feature = "CFData")]
    #[inline]
    pub unsafe fn with_bitmap_representation(
        alloc: Option<&CFAllocator>,
        the_data: Option<&CFData>,
    ) -> Option<CFRetained<CFCharacterSet>> {
        extern "C-unwind" {
            fn CFCharacterSetCreateWithBitmapRepresentation(
                alloc: Option<&CFAllocator>,
                the_data: Option<&CFData>,
            ) -> Option<NonNull<CFCharacterSet>>;
        }
        let ret = unsafe { CFCharacterSetCreateWithBitmapRepresentation(alloc, the_data) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Creates a new immutable character set that is the invert of the specified character set.
    ///
    /// Parameter `alloc`: The CFAllocator which should be used to allocate
    /// memory for the array and its storage for values. This
    /// parameter may be NULL in which case the current default
    /// CFAllocator is used. If this reference is not a valid
    /// CFAllocator, the behavior is undefined.
    ///
    /// Parameter `theSet`: The CFCharacterSet which is to be inverted.  If this
    /// parameter is not a valid CFCharacterSet, the behavior is
    /// undefined.
    ///
    /// Returns: A reference to the new immutable CFCharacterSet.
    ///
    /// # Safety
    ///
    /// - `alloc` might not allow `None`.
    /// - `the_set` might not allow `None`.
    #[doc(alias = "CFCharacterSetCreateInvertedSet")]
    #[inline]
    pub unsafe fn new_inverted_set(
        alloc: Option<&CFAllocator>,
        the_set: Option<&CFCharacterSet>,
    ) -> Option<CFRetained<CFCharacterSet>> {
        extern "C-unwind" {
            fn CFCharacterSetCreateInvertedSet(
                alloc: Option<&CFAllocator>,
                the_set: Option<&CFCharacterSet>,
            ) -> Option<NonNull<CFCharacterSet>>;
        }
        let ret = unsafe { CFCharacterSetCreateInvertedSet(alloc, the_set) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Reports whether or not the character set is a superset of the character set specified as the second parameter.
    ///
    /// Parameter `theSet`: The character set to be checked for the membership of theOtherSet.
    /// If this parameter is not a valid CFCharacterSet, the behavior is undefined.
    ///
    /// Parameter `theOtherset`: The character set to be checked whether or not it is a subset of theSet.
    /// If this parameter is not a valid CFCharacterSet, the behavior is undefined.
    ///
    /// # Safety
    ///
    /// `the_otherset` might not allow `None`.
    #[doc(alias = "CFCharacterSetIsSupersetOfSet")]
    #[inline]
    pub unsafe fn is_superset_of_set(&self, the_otherset: Option<&CFCharacterSet>) -> bool {
        extern "C-unwind" {
            fn CFCharacterSetIsSupersetOfSet(
                the_set: &CFCharacterSet,
                the_otherset: Option<&CFCharacterSet>,
            ) -> Boolean;
        }
        let ret = unsafe { CFCharacterSetIsSupersetOfSet(self, the_otherset) };
        ret != 0
    }

    /// Reports whether or not the character set contains at least one member character in the specified plane.
    ///
    /// Parameter `theSet`: The character set to be checked for the membership.  If this
    /// parameter is not a valid CFCharacterSet, the behavior is undefined.
    ///
    /// Parameter `thePlane`: The plane number to be checked for the membership.
    /// The valid value range is from 0 to 16.  If the value is outside of the valid
    /// plane number range, the behavior is undefined.
    #[doc(alias = "CFCharacterSetHasMemberInPlane")]
    #[inline]
    pub unsafe fn has_member_in_plane(&self, the_plane: CFIndex) -> bool {
        extern "C-unwind" {
            fn CFCharacterSetHasMemberInPlane(
                the_set: &CFCharacterSet,
                the_plane: CFIndex,
            ) -> Boolean;
        }
        let ret = unsafe { CFCharacterSetHasMemberInPlane(self, the_plane) };
        ret != 0
    }
}

impl CFMutableCharacterSet {
    /// Creates a new empty mutable character set.
    ///
    /// Parameter `alloc`: The CFAllocator which should be used to allocate
    /// memory for the array and its storage for values. This
    /// parameter may be NULL in which case the current default
    /// CFAllocator is used. If this reference is not a valid
    /// CFAllocator, the behavior is undefined.
    ///
    /// Returns: A reference to the new mutable CFCharacterSet.
    ///
    /// # Safety
    ///
    /// `alloc` might not allow `None`.
    #[doc(alias = "CFCharacterSetCreateMutable")]
    #[inline]
    pub unsafe fn new(alloc: Option<&CFAllocator>) -> Option<CFRetained<CFMutableCharacterSet>> {
        extern "C-unwind" {
            fn CFCharacterSetCreateMutable(
                alloc: Option<&CFAllocator>,
            ) -> Option<NonNull<CFMutableCharacterSet>>;
        }
        let ret = unsafe { CFCharacterSetCreateMutable(alloc) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }
}

impl CFCharacterSet {
    /// Creates a new character set with the values from the given character set.  This function tries to compact the backing store where applicable.
    ///
    /// Parameter `alloc`: The CFAllocator which should be used to allocate
    /// memory for the array and its storage for values. This
    /// parameter may be NULL in which case the current default
    /// CFAllocator is used. If this reference is not a valid
    /// CFAllocator, the behavior is undefined.
    ///
    /// Parameter `theSet`: The CFCharacterSet which is to be copied.  If this
    /// parameter is not a valid CFCharacterSet, the behavior is
    /// undefined.
    ///
    /// Returns: A reference to the new CFCharacterSet.
    ///
    /// # Safety
    ///
    /// - `alloc` might not allow `None`.
    /// - `the_set` might not allow `None`.
    #[doc(alias = "CFCharacterSetCreateCopy")]
    #[inline]
    pub unsafe fn new_copy(
        alloc: Option<&CFAllocator>,
        the_set: Option<&CFCharacterSet>,
    ) -> Option<CFRetained<CFCharacterSet>> {
        extern "C-unwind" {
            fn CFCharacterSetCreateCopy(
                alloc: Option<&CFAllocator>,
                the_set: Option<&CFCharacterSet>,
            ) -> Option<NonNull<CFCharacterSet>>;
        }
        let ret = unsafe { CFCharacterSetCreateCopy(alloc, the_set) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }
}

impl CFMutableCharacterSet {
    /// Creates a new mutable character set with the values from the given character set.
    ///
    /// Parameter `alloc`: The CFAllocator which should be used to allocate
    /// memory for the array and its storage for values. This
    /// parameter may be NULL in which case the current default
    /// CFAllocator is used. If this reference is not a valid
    /// CFAllocator, the behavior is undefined.
    ///
    /// Parameter `theSet`: The CFCharacterSet which is to be copied.  If this
    /// parameter is not a valid CFCharacterSet, the behavior is
    /// undefined.
    ///
    /// Returns: A reference to the new mutable CFCharacterSet.
    ///
    /// # Safety
    ///
    /// - `alloc` might not allow `None`.
    /// - `the_set` might not allow `None`.
    #[doc(alias = "CFCharacterSetCreateMutableCopy")]
    #[inline]
    pub unsafe fn new_copy(
        alloc: Option<&CFAllocator>,
        the_set: Option<&CFCharacterSet>,
    ) -> Option<CFRetained<CFMutableCharacterSet>> {
        extern "C-unwind" {
            fn CFCharacterSetCreateMutableCopy(
                alloc: Option<&CFAllocator>,
                the_set: Option<&CFCharacterSet>,
            ) -> Option<NonNull<CFMutableCharacterSet>>;
        }
        let ret = unsafe { CFCharacterSetCreateMutableCopy(alloc, the_set) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }
}

impl CFCharacterSet {
    /// Reports whether or not the Unicode character is in the character set.
    ///
    /// Parameter `theSet`: The character set to be searched. If this parameter
    /// is not a valid CFCharacterSet, the behavior is undefined.
    ///
    /// Parameter `theChar`: The Unicode character for which to test against the
    /// character set.  Note that this function takes 16-bit Unicode
    /// character value; hence, it does not support access to the
    /// non-BMP planes.
    ///
    /// Returns: true, if the value is in the character set, otherwise false.
    #[doc(alias = "CFCharacterSetIsCharacterMember")]
    #[inline]
    pub fn is_character_member(&self, the_char: UniChar) -> bool {
        extern "C-unwind" {
            fn CFCharacterSetIsCharacterMember(
                the_set: &CFCharacterSet,
                the_char: UniChar,
            ) -> Boolean;
        }
        let ret = unsafe { CFCharacterSetIsCharacterMember(self, the_char) };
        ret != 0
    }

    /// Reports whether or not the UTF-32 character is in the character set.
    ///
    /// Parameter `theSet`: The character set to be searched. If this parameter
    /// is not a valid CFCharacterSet, the behavior is undefined.
    ///
    /// Parameter `theChar`: The UTF-32 character for which to test against the
    /// character set.
    ///
    /// Returns: true, if the value is in the character set, otherwise false.
    #[doc(alias = "CFCharacterSetIsLongCharacterMember")]
    #[inline]
    pub fn is_long_character_member(&self, the_char: UTF32Char) -> bool {
        extern "C-unwind" {
            fn CFCharacterSetIsLongCharacterMember(
                the_set: &CFCharacterSet,
                the_char: UTF32Char,
            ) -> Boolean;
        }
        let ret = unsafe { CFCharacterSetIsLongCharacterMember(self, the_char) };
        ret != 0
    }

    /// Creates a new immutable data with the bitmap representation from the given character set.
    ///
    /// Parameter `alloc`: The CFAllocator which should be used to allocate
    /// memory for the array and its storage for values. This
    /// parameter may be NULL in which case the current default
    /// CFAllocator is used. If this reference is not a valid
    /// CFAllocator, the behavior is undefined.
    ///
    /// Parameter `theSet`: The CFCharacterSet which is to be used create the
    /// bitmap representation from.  Refer to the comments for
    /// CFCharacterSetCreateWithBitmapRepresentation for the
    /// detailed discussion of the bitmap representation format.
    /// If this parameter is not a valid CFCharacterSet, the
    /// behavior is undefined.
    ///
    /// Returns: A reference to the new immutable CFData.
    ///
    /// # Safety
    ///
    /// - `alloc` might not allow `None`.
    /// - `the_set` might not allow `None`.
    #[doc(alias = "CFCharacterSetCreateBitmapRepresentation")]
    #[cfg(feature = "CFData")]
    #[inline]
    pub unsafe fn new_bitmap_representation(
        alloc: Option<&CFAllocator>,
        the_set: Option<&CFCharacterSet>,
    ) -> Option<CFRetained<CFData>> {
        extern "C-unwind" {
            fn CFCharacterSetCreateBitmapRepresentation(
                alloc: Option<&CFAllocator>,
                the_set: Option<&CFCharacterSet>,
            ) -> Option<NonNull<CFData>>;
        }
        let ret = unsafe { CFCharacterSetCreateBitmapRepresentation(alloc, the_set) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }
}

impl CFMutableCharacterSet {
    /// Adds the given range to the charaacter set.
    ///
    /// Parameter `theSet`: The character set to which the range is to be added.
    /// If this parameter is not a valid mutable CFCharacterSet,
    /// the behavior is undefined.
    ///
    /// Parameter `theRange`: The range to add to the character set.  It accepts
    /// the range in 32-bit in the UTF-32 format.  The valid
    /// character point range is from 0x00000 to 0x10FFFF.  If the
    /// range is outside of the valid Unicode character point,
    /// the behavior is undefined.
    ///
    /// # Safety
    ///
    /// `the_set` might not allow `None`.
    #[doc(alias = "CFCharacterSetAddCharactersInRange")]
    #[inline]
    pub unsafe fn add_characters_in_range(
        the_set: Option<&CFMutableCharacterSet>,
        the_range: CFRange,
    ) {
        extern "C-unwind" {
            fn CFCharacterSetAddCharactersInRange(
                the_set: Option<&CFMutableCharacterSet>,
                the_range: CFRange,
            );
        }
        unsafe { CFCharacterSetAddCharactersInRange(the_set, the_range) }
    }

    /// Removes the given range from the charaacter set.
    ///
    /// Parameter `theSet`: The character set from which the range is to be
    /// removed.  If this parameter is not a valid mutable
    /// CFCharacterSet, the behavior is undefined.
    ///
    /// Parameter `theRange`: The range to remove from the character set.
    /// It accepts the range in 32-bit in the UTF-32 format.
    /// The valid character point range is from 0x00000 to 0x10FFFF.
    /// If the range is outside of the valid Unicode character point,
    /// the behavior is undefined.
    ///
    /// # Safety
    ///
    /// `the_set` might not allow `None`.
    #[doc(alias = "CFCharacterSetRemoveCharactersInRange")]
    #[inline]
    pub unsafe fn remove_characters_in_range(
        the_set: Option<&CFMutableCharacterSet>,
        the_range: CFRange,
    ) {
        extern "C-unwind" {
            fn CFCharacterSetRemoveCharactersInRange(
                the_set: Option<&CFMutableCharacterSet>,
                the_range: CFRange,
            );
        }
        unsafe { CFCharacterSetRemoveCharactersInRange(the_set, the_range) }
    }

    /// Adds the characters in the given string to the charaacter set.
    ///
    /// Parameter `theSet`: The character set to which the characters in the
    /// string are to be added.  If this parameter is not a
    /// valid mutable CFCharacterSet, the behavior is undefined.
    ///
    /// Parameter `theString`: The string to add to the character set.
    /// If this parameter is not a valid CFString, the behavior
    /// is undefined.
    ///
    /// # Safety
    ///
    /// - `the_set` might not allow `None`.
    /// - `the_string` might not allow `None`.
    #[doc(alias = "CFCharacterSetAddCharactersInString")]
    #[inline]
    pub unsafe fn add_characters_in_string(
        the_set: Option<&CFMutableCharacterSet>,
        the_string: Option<&CFString>,
    ) {
        extern "C-unwind" {
            fn CFCharacterSetAddCharactersInString(
                the_set: Option<&CFMutableCharacterSet>,
                the_string: Option<&CFString>,
            );
        }
        unsafe { CFCharacterSetAddCharactersInString(the_set, the_string) }
    }

    /// Removes the characters in the given string from the charaacter set.
    ///
    /// Parameter `theSet`: The character set from which the characters in the
    /// string are to be remove.  If this parameter is not a
    /// valid mutable CFCharacterSet, the behavior is undefined.
    ///
    /// Parameter `theString`: The string to remove from the character set.
    /// If this parameter is not a valid CFString, the behavior
    /// is undefined.
    ///
    /// # Safety
    ///
    /// - `the_set` might not allow `None`.
    /// - `the_string` might not allow `None`.
    #[doc(alias = "CFCharacterSetRemoveCharactersInString")]
    #[inline]
    pub unsafe fn remove_characters_in_string(
        the_set: Option<&CFMutableCharacterSet>,
        the_string: Option<&CFString>,
    ) {
        extern "C-unwind" {
            fn CFCharacterSetRemoveCharactersInString(
                the_set: Option<&CFMutableCharacterSet>,
                the_string: Option<&CFString>,
            );
        }
        unsafe { CFCharacterSetRemoveCharactersInString(the_set, the_string) }
    }

    /// Forms the union with the given character set.
    ///
    /// Parameter `theSet`: The destination character set into which the
    /// union of the two character sets is stored.  If this
    /// parameter is not a valid mutable CFCharacterSet, the
    /// behavior is undefined.
    ///
    /// Parameter `theOtherSet`: The character set with which the union is
    /// formed.  If this parameter is not a valid CFCharacterSet,
    /// the behavior is undefined.
    ///
    /// # Safety
    ///
    /// - `the_set` might not allow `None`.
    /// - `the_other_set` might not allow `None`.
    #[doc(alias = "CFCharacterSetUnion")]
    #[inline]
    pub unsafe fn union(
        the_set: Option<&CFMutableCharacterSet>,
        the_other_set: Option<&CFCharacterSet>,
    ) {
        extern "C-unwind" {
            fn CFCharacterSetUnion(
                the_set: Option<&CFMutableCharacterSet>,
                the_other_set: Option<&CFCharacterSet>,
            );
        }
        unsafe { CFCharacterSetUnion(the_set, the_other_set) }
    }

    /// Forms the intersection with the given character set.
    ///
    /// Parameter `theSet`: The destination character set into which the
    /// intersection of the two character sets is stored.
    /// If this parameter is not a valid mutable CFCharacterSet,
    /// the behavior is undefined.
    ///
    /// Parameter `theOtherSet`: The character set with which the intersection
    /// is formed.  If this parameter is not a valid CFCharacterSet,
    /// the behavior is undefined.
    ///
    /// # Safety
    ///
    /// - `the_set` might not allow `None`.
    /// - `the_other_set` might not allow `None`.
    #[doc(alias = "CFCharacterSetIntersect")]
    #[inline]
    pub unsafe fn intersect(
        the_set: Option<&CFMutableCharacterSet>,
        the_other_set: Option<&CFCharacterSet>,
    ) {
        extern "C-unwind" {
            fn CFCharacterSetIntersect(
                the_set: Option<&CFMutableCharacterSet>,
                the_other_set: Option<&CFCharacterSet>,
            );
        }
        unsafe { CFCharacterSetIntersect(the_set, the_other_set) }
    }

    /// Inverts the content of the given character set.
    ///
    /// Parameter `theSet`: The character set to be inverted.
    /// If this parameter is not a valid mutable CFCharacterSet,
    /// the behavior is undefined.
    ///
    /// # Safety
    ///
    /// `the_set` might not allow `None`.
    #[doc(alias = "CFCharacterSetInvert")]
    #[inline]
    pub unsafe fn invert(the_set: Option<&CFMutableCharacterSet>) {
        extern "C-unwind" {
            fn CFCharacterSetInvert(the_set: Option<&CFMutableCharacterSet>);
        }
        unsafe { CFCharacterSetInvert(the_set) }
    }
}

#[deprecated = "renamed to `CFCharacterSet::predefined`"]
#[inline]
pub extern "C-unwind" fn CFCharacterSetGetPredefined(
    the_set_identifier: CFCharacterSetPredefinedSet,
) -> Option<CFRetained<CFCharacterSet>> {
    extern "C-unwind" {
        fn CFCharacterSetGetPredefined(
            the_set_identifier: CFCharacterSetPredefinedSet,
        ) -> Option<NonNull<CFCharacterSet>>;
    }
    let ret = unsafe { CFCharacterSetGetPredefined(the_set_identifier) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

#[deprecated = "renamed to `CFCharacterSet::with_characters_in_range`"]
#[inline]
pub unsafe extern "C-unwind" fn CFCharacterSetCreateWithCharactersInRange(
    alloc: Option<&CFAllocator>,
    the_range: CFRange,
) -> Option<CFRetained<CFCharacterSet>> {
    extern "C-unwind" {
        fn CFCharacterSetCreateWithCharactersInRange(
            alloc: Option<&CFAllocator>,
            the_range: CFRange,
        ) -> Option<NonNull<CFCharacterSet>>;
    }
    let ret = unsafe { CFCharacterSetCreateWithCharactersInRange(alloc, the_range) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CFCharacterSet::with_characters_in_string`"]
#[inline]
pub unsafe extern "C-unwind" fn CFCharacterSetCreateWithCharactersInString(
    alloc: Option<&CFAllocator>,
    the_string: Option<&CFString>,
) -> Option<CFRetained<CFCharacterSet>> {
    extern "C-unwind" {
        fn CFCharacterSetCreateWithCharactersInString(
            alloc: Option<&CFAllocator>,
            the_string: Option<&CFString>,
        ) -> Option<NonNull<CFCharacterSet>>;
    }
    let ret = unsafe { CFCharacterSetCreateWithCharactersInString(alloc, the_string) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFData")]
#[deprecated = "renamed to `CFCharacterSet::with_bitmap_representation`"]
#[inline]
pub unsafe extern "C-unwind" fn CFCharacterSetCreateWithBitmapRepresentation(
    alloc: Option<&CFAllocator>,
    the_data: Option<&CFData>,
) -> Option<CFRetained<CFCharacterSet>> {
    extern "C-unwind" {
        fn CFCharacterSetCreateWithBitmapRepresentation(
            alloc: Option<&CFAllocator>,
            the_data: Option<&CFData>,
        ) -> Option<NonNull<CFCharacterSet>>;
    }
    let ret = unsafe { CFCharacterSetCreateWithBitmapRepresentation(alloc, the_data) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CFCharacterSet::new_inverted_set`"]
#[inline]
pub unsafe extern "C-unwind" fn CFCharacterSetCreateInvertedSet(
    alloc: Option<&CFAllocator>,
    the_set: Option<&CFCharacterSet>,
) -> Option<CFRetained<CFCharacterSet>> {
    extern "C-unwind" {
        fn CFCharacterSetCreateInvertedSet(
            alloc: Option<&CFAllocator>,
            the_set: Option<&CFCharacterSet>,
        ) -> Option<NonNull<CFCharacterSet>>;
    }
    let ret = unsafe { CFCharacterSetCreateInvertedSet(alloc, the_set) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CFCharacterSet::is_superset_of_set`"]
#[inline]
pub unsafe extern "C-unwind" fn CFCharacterSetIsSupersetOfSet(
    the_set: &CFCharacterSet,
    the_otherset: Option<&CFCharacterSet>,
) -> bool {
    extern "C-unwind" {
        fn CFCharacterSetIsSupersetOfSet(
            the_set: &CFCharacterSet,
            the_otherset: Option<&CFCharacterSet>,
        ) -> Boolean;
    }
    let ret = unsafe { CFCharacterSetIsSupersetOfSet(the_set, the_otherset) };
    ret != 0
}

#[deprecated = "renamed to `CFCharacterSet::has_member_in_plane`"]
#[inline]
pub unsafe extern "C-unwind" fn CFCharacterSetHasMemberInPlane(
    the_set: &CFCharacterSet,
    the_plane: CFIndex,
) -> bool {
    extern "C-unwind" {
        fn CFCharacterSetHasMemberInPlane(the_set: &CFCharacterSet, the_plane: CFIndex) -> Boolean;
    }
    let ret = unsafe { CFCharacterSetHasMemberInPlane(the_set, the_plane) };
    ret != 0
}

#[deprecated = "renamed to `CFMutableCharacterSet::new`"]
#[inline]
pub unsafe extern "C-unwind" fn CFCharacterSetCreateMutable(
    alloc: Option<&CFAllocator>,
) -> Option<CFRetained<CFMutableCharacterSet>> {
    extern "C-unwind" {
        fn CFCharacterSetCreateMutable(
            alloc: Option<&CFAllocator>,
        ) -> Option<NonNull<CFMutableCharacterSet>>;
    }
    let ret = unsafe { CFCharacterSetCreateMutable(alloc) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CFCharacterSet::new_copy`"]
#[inline]
pub unsafe extern "C-unwind" fn CFCharacterSetCreateCopy(
    alloc: Option<&CFAllocator>,
    the_set: Option<&CFCharacterSet>,
) -> Option<CFRetained<CFCharacterSet>> {
    extern "C-unwind" {
        fn CFCharacterSetCreateCopy(
            alloc: Option<&CFAllocator>,
            the_set: Option<&CFCharacterSet>,
        ) -> Option<NonNull<CFCharacterSet>>;
    }
    let ret = unsafe { CFCharacterSetCreateCopy(alloc, the_set) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CFMutableCharacterSet::new_copy`"]
#[inline]
pub unsafe extern "C-unwind" fn CFCharacterSetCreateMutableCopy(
    alloc: Option<&CFAllocator>,
    the_set: Option<&CFCharacterSet>,
) -> Option<CFRetained<CFMutableCharacterSet>> {
    extern "C-unwind" {
        fn CFCharacterSetCreateMutableCopy(
            alloc: Option<&CFAllocator>,
            the_set: Option<&CFCharacterSet>,
        ) -> Option<NonNull<CFMutableCharacterSet>>;
    }
    let ret = unsafe { CFCharacterSetCreateMutableCopy(alloc, the_set) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CFCharacterSet::is_character_member`"]
#[inline]
pub extern "C-unwind" fn CFCharacterSetIsCharacterMember(
    the_set: &CFCharacterSet,
    the_char: UniChar,
) -> bool {
    extern "C-unwind" {
        fn CFCharacterSetIsCharacterMember(the_set: &CFCharacterSet, the_char: UniChar) -> Boolean;
    }
    let ret = unsafe { CFCharacterSetIsCharacterMember(the_set, the_char) };
    ret != 0
}

#[deprecated = "renamed to `CFCharacterSet::is_long_character_member`"]
#[inline]
pub extern "C-unwind" fn CFCharacterSetIsLongCharacterMember(
    the_set: &CFCharacterSet,
    the_char: UTF32Char,
) -> bool {
    extern "C-unwind" {
        fn CFCharacterSetIsLongCharacterMember(
            the_set: &CFCharacterSet,
            the_char: UTF32Char,
        ) -> Boolean;
    }
    let ret = unsafe { CFCharacterSetIsLongCharacterMember(the_set, the_char) };
    ret != 0
}

#[cfg(feature = "CFData")]
#[deprecated = "renamed to `CFCharacterSet::new_bitmap_representation`"]
#[inline]
pub unsafe extern "C-unwind" fn CFCharacterSetCreateBitmapRepresentation(
    alloc: Option<&CFAllocator>,
    the_set: Option<&CFCharacterSet>,
) -> Option<CFRetained<CFData>> {
    extern "C-unwind" {
        fn CFCharacterSetCreateBitmapRepresentation(
            alloc: Option<&CFAllocator>,
            the_set: Option<&CFCharacterSet>,
        ) -> Option<NonNull<CFData>>;
    }
    let ret = unsafe { CFCharacterSetCreateBitmapRepresentation(alloc, the_set) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFMutableCharacterSet::add_characters_in_range`"]
    pub fn CFCharacterSetAddCharactersInRange(
        the_set: Option<&CFMutableCharacterSet>,
        the_range: CFRange,
    );
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFMutableCharacterSet::remove_characters_in_range`"]
    pub fn CFCharacterSetRemoveCharactersInRange(
        the_set: Option<&CFMutableCharacterSet>,
        the_range: CFRange,
    );
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFMutableCharacterSet::add_characters_in_string`"]
    pub fn CFCharacterSetAddCharactersInString(
        the_set: Option<&CFMutableCharacterSet>,
        the_string: Option<&CFString>,
    );
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFMutableCharacterSet::remove_characters_in_string`"]
    pub fn CFCharacterSetRemoveCharactersInString(
        the_set: Option<&CFMutableCharacterSet>,
        the_string: Option<&CFString>,
    );
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFMutableCharacterSet::union`"]
    pub fn CFCharacterSetUnion(
        the_set: Option<&CFMutableCharacterSet>,
        the_other_set: Option<&CFCharacterSet>,
    );
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFMutableCharacterSet::intersect`"]
    pub fn CFCharacterSetIntersect(
        the_set: Option<&CFMutableCharacterSet>,
        the_other_set: Option<&CFCharacterSet>,
    );
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFMutableCharacterSet::invert`"]
    pub fn CFCharacterSetInvert(the_set: Option<&CFMutableCharacterSet>);
}