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
//! 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::*;

/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatterkey?language=objc)
// NS_TYPED_ENUM
pub type CFNumberFormatterKey = CFString;

/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatter?language=objc)
#[doc(alias = "CFNumberFormatterRef")]
#[repr(C)]
pub struct CFNumberFormatter {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

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

unsafe impl ConcreteType for CFNumberFormatter {
    #[doc(alias = "CFNumberFormatterGetTypeID")]
    #[inline]
    fn type_id() -> CFTypeID {
        extern "C-unwind" {
            fn CFNumberFormatterGetTypeID() -> CFTypeID;
        }
        unsafe { CFNumberFormatterGetTypeID() }
    }
}

/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatterstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CFNumberFormatterStyle(pub CFIndex);
impl CFNumberFormatterStyle {
    #[doc(alias = "kCFNumberFormatterNoStyle")]
    pub const NoStyle: Self = Self(0);
    #[doc(alias = "kCFNumberFormatterDecimalStyle")]
    pub const DecimalStyle: Self = Self(1);
    #[doc(alias = "kCFNumberFormatterCurrencyStyle")]
    pub const CurrencyStyle: Self = Self(2);
    #[doc(alias = "kCFNumberFormatterPercentStyle")]
    pub const PercentStyle: Self = Self(3);
    #[doc(alias = "kCFNumberFormatterScientificStyle")]
    pub const ScientificStyle: Self = Self(4);
    #[doc(alias = "kCFNumberFormatterSpellOutStyle")]
    pub const SpellOutStyle: Self = Self(5);
    #[doc(alias = "kCFNumberFormatterOrdinalStyle")]
    pub const OrdinalStyle: Self = Self(6);
    #[doc(alias = "kCFNumberFormatterCurrencyISOCodeStyle")]
    pub const CurrencyISOCodeStyle: Self = Self(8);
    #[doc(alias = "kCFNumberFormatterCurrencyPluralStyle")]
    pub const CurrencyPluralStyle: Self = Self(9);
    #[doc(alias = "kCFNumberFormatterCurrencyAccountingStyle")]
    pub const CurrencyAccountingStyle: Self = Self(10);
}

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

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

impl CFNumberFormatter {
    /// # Safety
    ///
    /// - `allocator` might not allow `None`.
    /// - `locale` might not allow `None`.
    #[doc(alias = "CFNumberFormatterCreate")]
    #[cfg(feature = "CFLocale")]
    #[inline]
    pub unsafe fn new(
        allocator: Option<&CFAllocator>,
        locale: Option<&CFLocale>,
        style: CFNumberFormatterStyle,
    ) -> Option<CFRetained<CFNumberFormatter>> {
        extern "C-unwind" {
            fn CFNumberFormatterCreate(
                allocator: Option<&CFAllocator>,
                locale: Option<&CFLocale>,
                style: CFNumberFormatterStyle,
            ) -> Option<NonNull<CFNumberFormatter>>;
        }
        let ret = unsafe { CFNumberFormatterCreate(allocator, locale, style) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    #[doc(alias = "CFNumberFormatterGetLocale")]
    #[cfg(feature = "CFLocale")]
    #[inline]
    pub fn locale(&self) -> Option<CFRetained<CFLocale>> {
        extern "C-unwind" {
            fn CFNumberFormatterGetLocale(
                formatter: &CFNumberFormatter,
            ) -> Option<NonNull<CFLocale>>;
        }
        let ret = unsafe { CFNumberFormatterGetLocale(self) };
        ret.map(|ret| unsafe { CFRetained::retain(ret) })
    }

    #[doc(alias = "CFNumberFormatterGetStyle")]
    #[inline]
    pub fn style(&self) -> CFNumberFormatterStyle {
        extern "C-unwind" {
            fn CFNumberFormatterGetStyle(formatter: &CFNumberFormatter) -> CFNumberFormatterStyle;
        }
        unsafe { CFNumberFormatterGetStyle(self) }
    }

    #[doc(alias = "CFNumberFormatterGetFormat")]
    #[inline]
    pub fn format(&self) -> Option<CFRetained<CFString>> {
        extern "C-unwind" {
            fn CFNumberFormatterGetFormat(
                formatter: &CFNumberFormatter,
            ) -> Option<NonNull<CFString>>;
        }
        let ret = unsafe { CFNumberFormatterGetFormat(self) };
        ret.map(|ret| unsafe { CFRetained::retain(ret) })
    }

    /// # Safety
    ///
    /// `format_string` might not allow `None`.
    #[doc(alias = "CFNumberFormatterSetFormat")]
    #[inline]
    pub unsafe fn set_format(&self, format_string: Option<&CFString>) {
        extern "C-unwind" {
            fn CFNumberFormatterSetFormat(
                formatter: &CFNumberFormatter,
                format_string: Option<&CFString>,
            );
        }
        unsafe { CFNumberFormatterSetFormat(self, format_string) }
    }

    /// # Safety
    ///
    /// - `allocator` might not allow `None`.
    /// - `formatter` might not allow `None`.
    /// - `number` might not allow `None`.
    #[doc(alias = "CFNumberFormatterCreateStringWithNumber")]
    #[cfg(feature = "CFNumber")]
    #[inline]
    pub unsafe fn new_string_with_number(
        allocator: Option<&CFAllocator>,
        formatter: Option<&CFNumberFormatter>,
        number: Option<&CFNumber>,
    ) -> Option<CFRetained<CFString>> {
        extern "C-unwind" {
            fn CFNumberFormatterCreateStringWithNumber(
                allocator: Option<&CFAllocator>,
                formatter: Option<&CFNumberFormatter>,
                number: Option<&CFNumber>,
            ) -> Option<NonNull<CFString>>;
        }
        let ret = unsafe { CFNumberFormatterCreateStringWithNumber(allocator, formatter, number) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// # Safety
    ///
    /// - `allocator` might not allow `None`.
    /// - `formatter` might not allow `None`.
    /// - `value_ptr` must be a valid pointer.
    #[doc(alias = "CFNumberFormatterCreateStringWithValue")]
    #[cfg(feature = "CFNumber")]
    #[inline]
    pub unsafe fn new_string_with_value(
        allocator: Option<&CFAllocator>,
        formatter: Option<&CFNumberFormatter>,
        number_type: CFNumberType,
        value_ptr: *const c_void,
    ) -> Option<CFRetained<CFString>> {
        extern "C-unwind" {
            fn CFNumberFormatterCreateStringWithValue(
                allocator: Option<&CFAllocator>,
                formatter: Option<&CFNumberFormatter>,
                number_type: CFNumberType,
                value_ptr: *const c_void,
            ) -> Option<NonNull<CFString>>;
        }
        let ret = unsafe {
            CFNumberFormatterCreateStringWithValue(allocator, formatter, number_type, value_ptr)
        };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }
}

/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatteroptionflags?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CFNumberFormatterOptionFlags(pub CFOptionFlags);
bitflags::bitflags! {
    impl CFNumberFormatterOptionFlags: CFOptionFlags {
        #[doc(alias = "kCFNumberFormatterParseIntegersOnly")]
        const ParseIntegersOnly = 1;
    }
}

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

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

impl CFNumberFormatter {
    /// # Safety
    ///
    /// - `allocator` might not allow `None`.
    /// - `formatter` might not allow `None`.
    /// - `string` might not allow `None`.
    /// - `rangep` must be a valid pointer.
    #[doc(alias = "CFNumberFormatterCreateNumberFromString")]
    #[cfg(feature = "CFNumber")]
    #[inline]
    pub unsafe fn new_number_from_string(
        allocator: Option<&CFAllocator>,
        formatter: Option<&CFNumberFormatter>,
        string: Option<&CFString>,
        rangep: *mut CFRange,
        options: CFOptionFlags,
    ) -> Option<CFRetained<CFNumber>> {
        extern "C-unwind" {
            fn CFNumberFormatterCreateNumberFromString(
                allocator: Option<&CFAllocator>,
                formatter: Option<&CFNumberFormatter>,
                string: Option<&CFString>,
                rangep: *mut CFRange,
                options: CFOptionFlags,
            ) -> Option<NonNull<CFNumber>>;
        }
        let ret = unsafe {
            CFNumberFormatterCreateNumberFromString(allocator, formatter, string, rangep, options)
        };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// # Safety
    ///
    /// - `string` might not allow `None`.
    /// - `rangep` must be a valid pointer.
    /// - `value_ptr` must be a valid pointer.
    #[doc(alias = "CFNumberFormatterGetValueFromString")]
    #[cfg(feature = "CFNumber")]
    #[inline]
    pub unsafe fn value_from_string(
        &self,
        string: Option<&CFString>,
        rangep: *mut CFRange,
        number_type: CFNumberType,
        value_ptr: *mut c_void,
    ) -> bool {
        extern "C-unwind" {
            fn CFNumberFormatterGetValueFromString(
                formatter: &CFNumberFormatter,
                string: Option<&CFString>,
                rangep: *mut CFRange,
                number_type: CFNumberType,
                value_ptr: *mut c_void,
            ) -> Boolean;
        }
        let ret = unsafe {
            CFNumberFormatterGetValueFromString(self, string, rangep, number_type, value_ptr)
        };
        ret != 0
    }

    /// # Safety
    ///
    /// - `key` might not allow `None`.
    /// - `value` should be of the correct type.
    /// - `value` might not allow `None`.
    #[doc(alias = "CFNumberFormatterSetProperty")]
    #[inline]
    pub unsafe fn set_property(&self, key: Option<&CFNumberFormatterKey>, value: Option<&CFType>) {
        extern "C-unwind" {
            fn CFNumberFormatterSetProperty(
                formatter: &CFNumberFormatter,
                key: Option<&CFNumberFormatterKey>,
                value: Option<&CFType>,
            );
        }
        unsafe { CFNumberFormatterSetProperty(self, key, value) }
    }

    /// # Safety
    ///
    /// `key` might not allow `None`.
    #[doc(alias = "CFNumberFormatterCopyProperty")]
    #[inline]
    pub unsafe fn property(
        &self,
        key: Option<&CFNumberFormatterKey>,
    ) -> Option<CFRetained<CFType>> {
        extern "C-unwind" {
            fn CFNumberFormatterCopyProperty(
                formatter: &CFNumberFormatter,
                key: Option<&CFNumberFormatterKey>,
            ) -> Option<NonNull<CFType>>;
        }
        let ret = unsafe { CFNumberFormatterCopyProperty(self, key) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattercurrencycode?language=objc)
    pub static kCFNumberFormatterCurrencyCode: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterdecimalseparator?language=objc)
    pub static kCFNumberFormatterDecimalSeparator: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattercurrencydecimalseparator?language=objc)
    pub static kCFNumberFormatterCurrencyDecimalSeparator: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatteralwaysshowdecimalseparator?language=objc)
    pub static kCFNumberFormatterAlwaysShowDecimalSeparator: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattergroupingseparator?language=objc)
    pub static kCFNumberFormatterGroupingSeparator: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterusegroupingseparator?language=objc)
    pub static kCFNumberFormatterUseGroupingSeparator: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpercentsymbol?language=objc)
    pub static kCFNumberFormatterPercentSymbol: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterzerosymbol?language=objc)
    pub static kCFNumberFormatterZeroSymbol: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatternansymbol?language=objc)
    pub static kCFNumberFormatterNaNSymbol: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterinfinitysymbol?language=objc)
    pub static kCFNumberFormatterInfinitySymbol: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterminussign?language=objc)
    pub static kCFNumberFormatterMinusSign: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterplussign?language=objc)
    pub static kCFNumberFormatterPlusSign: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattercurrencysymbol?language=objc)
    pub static kCFNumberFormatterCurrencySymbol: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterexponentsymbol?language=objc)
    pub static kCFNumberFormatterExponentSymbol: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterminintegerdigits?language=objc)
    pub static kCFNumberFormatterMinIntegerDigits: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattermaxintegerdigits?language=objc)
    pub static kCFNumberFormatterMaxIntegerDigits: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterminfractiondigits?language=objc)
    pub static kCFNumberFormatterMinFractionDigits: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattermaxfractiondigits?language=objc)
    pub static kCFNumberFormatterMaxFractionDigits: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattergroupingsize?language=objc)
    pub static kCFNumberFormatterGroupingSize: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattersecondarygroupingsize?language=objc)
    pub static kCFNumberFormatterSecondaryGroupingSize: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterroundingmode?language=objc)
    pub static kCFNumberFormatterRoundingMode: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterroundingincrement?language=objc)
    pub static kCFNumberFormatterRoundingIncrement: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterformatwidth?language=objc)
    pub static kCFNumberFormatterFormatWidth: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpaddingposition?language=objc)
    pub static kCFNumberFormatterPaddingPosition: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpaddingcharacter?language=objc)
    pub static kCFNumberFormatterPaddingCharacter: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterdefaultformat?language=objc)
    pub static kCFNumberFormatterDefaultFormat: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattermultiplier?language=objc)
    pub static kCFNumberFormatterMultiplier: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpositiveprefix?language=objc)
    pub static kCFNumberFormatterPositivePrefix: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpositivesuffix?language=objc)
    pub static kCFNumberFormatterPositiveSuffix: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatternegativeprefix?language=objc)
    pub static kCFNumberFormatterNegativePrefix: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatternegativesuffix?language=objc)
    pub static kCFNumberFormatterNegativeSuffix: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpermillsymbol?language=objc)
    pub static kCFNumberFormatterPerMillSymbol: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterinternationalcurrencysymbol?language=objc)
    pub static kCFNumberFormatterInternationalCurrencySymbol: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattercurrencygroupingseparator?language=objc)
    pub static kCFNumberFormatterCurrencyGroupingSeparator: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterislenient?language=objc)
    pub static kCFNumberFormatterIsLenient: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterusesignificantdigits?language=objc)
    pub static kCFNumberFormatterUseSignificantDigits: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterminsignificantdigits?language=objc)
    pub static kCFNumberFormatterMinSignificantDigits: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattermaxsignificantdigits?language=objc)
    pub static kCFNumberFormatterMaxSignificantDigits: Option<&'static CFNumberFormatterKey>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattermingroupingdigits?language=objc)
    pub static kCFNumberFormatterMinGroupingDigits: Option<&'static CFNumberFormatterKey>;
}

/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatterroundingmode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CFNumberFormatterRoundingMode(pub CFIndex);
impl CFNumberFormatterRoundingMode {
    #[doc(alias = "kCFNumberFormatterRoundCeiling")]
    pub const RoundCeiling: Self = Self(0);
    #[doc(alias = "kCFNumberFormatterRoundFloor")]
    pub const RoundFloor: Self = Self(1);
    #[doc(alias = "kCFNumberFormatterRoundDown")]
    pub const RoundDown: Self = Self(2);
    #[doc(alias = "kCFNumberFormatterRoundUp")]
    pub const RoundUp: Self = Self(3);
    #[doc(alias = "kCFNumberFormatterRoundHalfEven")]
    pub const RoundHalfEven: Self = Self(4);
    #[doc(alias = "kCFNumberFormatterRoundHalfDown")]
    pub const RoundHalfDown: Self = Self(5);
    #[doc(alias = "kCFNumberFormatterRoundHalfUp")]
    pub const RoundHalfUp: Self = Self(6);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatterpadposition?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CFNumberFormatterPadPosition(pub CFIndex);
impl CFNumberFormatterPadPosition {
    #[doc(alias = "kCFNumberFormatterPadBeforePrefix")]
    pub const BeforePrefix: Self = Self(0);
    #[doc(alias = "kCFNumberFormatterPadAfterPrefix")]
    pub const AfterPrefix: Self = Self(1);
    #[doc(alias = "kCFNumberFormatterPadBeforeSuffix")]
    pub const BeforeSuffix: Self = Self(2);
    #[doc(alias = "kCFNumberFormatterPadAfterSuffix")]
    pub const AfterSuffix: Self = Self(3);
}

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

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

impl CFNumberFormatter {
    /// # Safety
    ///
    /// - `currency_code` might not allow `None`.
    /// - `default_fraction_digits` must be a valid pointer.
    /// - `rounding_increment` must be a valid pointer.
    #[doc(alias = "CFNumberFormatterGetDecimalInfoForCurrencyCode")]
    #[inline]
    pub unsafe fn decimal_info_for_currency_code(
        currency_code: Option<&CFString>,
        default_fraction_digits: *mut i32,
        rounding_increment: *mut c_double,
    ) -> bool {
        extern "C-unwind" {
            fn CFNumberFormatterGetDecimalInfoForCurrencyCode(
                currency_code: Option<&CFString>,
                default_fraction_digits: *mut i32,
                rounding_increment: *mut c_double,
            ) -> Boolean;
        }
        let ret = unsafe {
            CFNumberFormatterGetDecimalInfoForCurrencyCode(
                currency_code,
                default_fraction_digits,
                rounding_increment,
            )
        };
        ret != 0
    }
}

#[cfg(feature = "CFLocale")]
#[deprecated = "renamed to `CFNumberFormatter::new`"]
#[inline]
pub unsafe extern "C-unwind" fn CFNumberFormatterCreate(
    allocator: Option<&CFAllocator>,
    locale: Option<&CFLocale>,
    style: CFNumberFormatterStyle,
) -> Option<CFRetained<CFNumberFormatter>> {
    extern "C-unwind" {
        fn CFNumberFormatterCreate(
            allocator: Option<&CFAllocator>,
            locale: Option<&CFLocale>,
            style: CFNumberFormatterStyle,
        ) -> Option<NonNull<CFNumberFormatter>>;
    }
    let ret = unsafe { CFNumberFormatterCreate(allocator, locale, style) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFLocale")]
#[deprecated = "renamed to `CFNumberFormatter::locale`"]
#[inline]
pub extern "C-unwind" fn CFNumberFormatterGetLocale(
    formatter: &CFNumberFormatter,
) -> Option<CFRetained<CFLocale>> {
    extern "C-unwind" {
        fn CFNumberFormatterGetLocale(formatter: &CFNumberFormatter) -> Option<NonNull<CFLocale>>;
    }
    let ret = unsafe { CFNumberFormatterGetLocale(formatter) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

#[deprecated = "renamed to `CFNumberFormatter::style`"]
#[inline]
pub extern "C-unwind" fn CFNumberFormatterGetStyle(
    formatter: &CFNumberFormatter,
) -> CFNumberFormatterStyle {
    extern "C-unwind" {
        fn CFNumberFormatterGetStyle(formatter: &CFNumberFormatter) -> CFNumberFormatterStyle;
    }
    unsafe { CFNumberFormatterGetStyle(formatter) }
}

#[deprecated = "renamed to `CFNumberFormatter::format`"]
#[inline]
pub extern "C-unwind" fn CFNumberFormatterGetFormat(
    formatter: &CFNumberFormatter,
) -> Option<CFRetained<CFString>> {
    extern "C-unwind" {
        fn CFNumberFormatterGetFormat(formatter: &CFNumberFormatter) -> Option<NonNull<CFString>>;
    }
    let ret = unsafe { CFNumberFormatterGetFormat(formatter) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFNumberFormatter::set_format`"]
    pub fn CFNumberFormatterSetFormat(
        formatter: &CFNumberFormatter,
        format_string: Option<&CFString>,
    );
}

#[cfg(feature = "CFNumber")]
#[deprecated = "renamed to `CFNumberFormatter::new_string_with_number`"]
#[inline]
pub unsafe extern "C-unwind" fn CFNumberFormatterCreateStringWithNumber(
    allocator: Option<&CFAllocator>,
    formatter: Option<&CFNumberFormatter>,
    number: Option<&CFNumber>,
) -> Option<CFRetained<CFString>> {
    extern "C-unwind" {
        fn CFNumberFormatterCreateStringWithNumber(
            allocator: Option<&CFAllocator>,
            formatter: Option<&CFNumberFormatter>,
            number: Option<&CFNumber>,
        ) -> Option<NonNull<CFString>>;
    }
    let ret = unsafe { CFNumberFormatterCreateStringWithNumber(allocator, formatter, number) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFNumber")]
#[deprecated = "renamed to `CFNumberFormatter::new_string_with_value`"]
#[inline]
pub unsafe extern "C-unwind" fn CFNumberFormatterCreateStringWithValue(
    allocator: Option<&CFAllocator>,
    formatter: Option<&CFNumberFormatter>,
    number_type: CFNumberType,
    value_ptr: *const c_void,
) -> Option<CFRetained<CFString>> {
    extern "C-unwind" {
        fn CFNumberFormatterCreateStringWithValue(
            allocator: Option<&CFAllocator>,
            formatter: Option<&CFNumberFormatter>,
            number_type: CFNumberType,
            value_ptr: *const c_void,
        ) -> Option<NonNull<CFString>>;
    }
    let ret = unsafe {
        CFNumberFormatterCreateStringWithValue(allocator, formatter, number_type, value_ptr)
    };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFNumber")]
#[deprecated = "renamed to `CFNumberFormatter::new_number_from_string`"]
#[inline]
pub unsafe extern "C-unwind" fn CFNumberFormatterCreateNumberFromString(
    allocator: Option<&CFAllocator>,
    formatter: Option<&CFNumberFormatter>,
    string: Option<&CFString>,
    rangep: *mut CFRange,
    options: CFOptionFlags,
) -> Option<CFRetained<CFNumber>> {
    extern "C-unwind" {
        fn CFNumberFormatterCreateNumberFromString(
            allocator: Option<&CFAllocator>,
            formatter: Option<&CFNumberFormatter>,
            string: Option<&CFString>,
            rangep: *mut CFRange,
            options: CFOptionFlags,
        ) -> Option<NonNull<CFNumber>>;
    }
    let ret = unsafe {
        CFNumberFormatterCreateNumberFromString(allocator, formatter, string, rangep, options)
    };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFNumber")]
#[deprecated = "renamed to `CFNumberFormatter::value_from_string`"]
#[inline]
pub unsafe extern "C-unwind" fn CFNumberFormatterGetValueFromString(
    formatter: &CFNumberFormatter,
    string: Option<&CFString>,
    rangep: *mut CFRange,
    number_type: CFNumberType,
    value_ptr: *mut c_void,
) -> bool {
    extern "C-unwind" {
        fn CFNumberFormatterGetValueFromString(
            formatter: &CFNumberFormatter,
            string: Option<&CFString>,
            rangep: *mut CFRange,
            number_type: CFNumberType,
            value_ptr: *mut c_void,
        ) -> Boolean;
    }
    let ret = unsafe {
        CFNumberFormatterGetValueFromString(formatter, string, rangep, number_type, value_ptr)
    };
    ret != 0
}

extern "C-unwind" {
    #[deprecated = "renamed to `CFNumberFormatter::set_property`"]
    pub fn CFNumberFormatterSetProperty(
        formatter: &CFNumberFormatter,
        key: Option<&CFNumberFormatterKey>,
        value: Option<&CFType>,
    );
}

#[deprecated = "renamed to `CFNumberFormatter::property`"]
#[inline]
pub unsafe extern "C-unwind" fn CFNumberFormatterCopyProperty(
    formatter: &CFNumberFormatter,
    key: Option<&CFNumberFormatterKey>,
) -> Option<CFRetained<CFType>> {
    extern "C-unwind" {
        fn CFNumberFormatterCopyProperty(
            formatter: &CFNumberFormatter,
            key: Option<&CFNumberFormatterKey>,
        ) -> Option<NonNull<CFType>>;
    }
    let ret = unsafe { CFNumberFormatterCopyProperty(formatter, key) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CFNumberFormatter::decimal_info_for_currency_code`"]
#[inline]
pub unsafe extern "C-unwind" fn CFNumberFormatterGetDecimalInfoForCurrencyCode(
    currency_code: Option<&CFString>,
    default_fraction_digits: *mut i32,
    rounding_increment: *mut c_double,
) -> bool {
    extern "C-unwind" {
        fn CFNumberFormatterGetDecimalInfoForCurrencyCode(
            currency_code: Option<&CFString>,
            default_fraction_digits: *mut i32,
            rounding_increment: *mut c_double,
        ) -> Boolean;
    }
    let ret = unsafe {
        CFNumberFormatterGetDecimalInfoForCurrencyCode(
            currency_code,
            default_fraction_digits,
            rounding_increment,
        )
    };
    ret != 0
}