objc2-foundation 0.3.2

Bindings to the Foundation 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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

/// **************    Class    ***************
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaptablestrongmemory?language=objc)
#[cfg(feature = "NSPointerFunctions")]
pub static NSMapTableStrongMemory: NSPointerFunctionsOptions =
    NSPointerFunctionsOptions(NSPointerFunctionsOptions::StrongMemory.0);

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaptablezeroingweakmemory?language=objc)
#[cfg(feature = "NSPointerFunctions")]
#[deprecated = "GC no longer supported"]
pub static NSMapTableZeroingWeakMemory: NSPointerFunctionsOptions =
    NSPointerFunctionsOptions(NSPointerFunctionsOptions::ZeroingWeakMemory.0);

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaptablecopyin?language=objc)
#[cfg(feature = "NSPointerFunctions")]
pub static NSMapTableCopyIn: NSPointerFunctionsOptions =
    NSPointerFunctionsOptions(NSPointerFunctionsOptions::CopyIn.0);

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaptableobjectpointerpersonality?language=objc)
#[cfg(feature = "NSPointerFunctions")]
pub static NSMapTableObjectPointerPersonality: NSPointerFunctionsOptions =
    NSPointerFunctionsOptions(NSPointerFunctionsOptions::ObjectPointerPersonality.0);

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaptableweakmemory?language=objc)
#[cfg(feature = "NSPointerFunctions")]
pub static NSMapTableWeakMemory: NSPointerFunctionsOptions =
    NSPointerFunctionsOptions(NSPointerFunctionsOptions::WeakMemory.0);

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaptableoptions?language=objc)
pub type NSMapTableOptions = NSUInteger;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaptable?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSMapTable<KeyType: ?Sized = AnyObject, ObjectType: ?Sized = AnyObject>;
);

impl<KeyType: ?Sized + Message, ObjectType: ?Sized + Message> NSMapTable<KeyType, ObjectType> {
    /// Unchecked conversion of the generic parameters.
    ///
    /// # Safety
    ///
    /// The generics must be valid to reinterpret as the given types.
    #[inline]
    pub unsafe fn cast_unchecked<NewKeyType: ?Sized + Message, NewObjectType: ?Sized + Message>(
        &self,
    ) -> &NSMapTable<NewKeyType, NewObjectType> {
        unsafe { &*((self as *const Self).cast()) }
    }
}

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl<KeyType: ?Sized + NSCoding, ObjectType: ?Sized + NSCoding> NSCoding
        for NSMapTable<KeyType, ObjectType>
    {
    }
);

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl<KeyType: ?Sized, ObjectType: ?Sized> NSCopying for NSMapTable<KeyType, ObjectType> {}
);

#[cfg(feature = "NSObject")]
unsafe impl<KeyType: ?Sized + Message, ObjectType: ?Sized + Message> CopyingHelper
    for NSMapTable<KeyType, ObjectType>
{
    type Result = Self;
}

#[cfg(feature = "NSEnumerator")]
extern_conformance!(
    unsafe impl<KeyType: ?Sized, ObjectType: ?Sized> NSFastEnumeration
        for NSMapTable<KeyType, ObjectType>
    {
    }
);

extern_conformance!(
    unsafe impl<KeyType: ?Sized, ObjectType: ?Sized> NSObjectProtocol
        for NSMapTable<KeyType, ObjectType>
    {
    }
);

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl<KeyType: ?Sized + NSSecureCoding, ObjectType: ?Sized + NSSecureCoding>
        NSSecureCoding for NSMapTable<KeyType, ObjectType>
    {
    }
);

impl<KeyType: Message, ObjectType: Message> NSMapTable<KeyType, ObjectType> {
    extern_methods!(
        #[cfg(feature = "NSPointerFunctions")]
        #[unsafe(method(initWithKeyOptions:valueOptions:capacity:))]
        #[unsafe(method_family = init)]
        pub fn initWithKeyOptions_valueOptions_capacity(
            this: Allocated<Self>,
            key_options: NSPointerFunctionsOptions,
            value_options: NSPointerFunctionsOptions,
            initial_capacity: NSUInteger,
        ) -> Retained<Self>;

        #[cfg(feature = "NSPointerFunctions")]
        #[unsafe(method(initWithKeyPointerFunctions:valuePointerFunctions:capacity:))]
        #[unsafe(method_family = init)]
        pub fn initWithKeyPointerFunctions_valuePointerFunctions_capacity(
            this: Allocated<Self>,
            key_functions: &NSPointerFunctions,
            value_functions: &NSPointerFunctions,
            initial_capacity: NSUInteger,
        ) -> Retained<Self>;

        #[cfg(feature = "NSPointerFunctions")]
        #[unsafe(method(mapTableWithKeyOptions:valueOptions:))]
        #[unsafe(method_family = none)]
        pub fn mapTableWithKeyOptions_valueOptions(
            key_options: NSPointerFunctionsOptions,
            value_options: NSPointerFunctionsOptions,
        ) -> Retained<NSMapTable<KeyType, ObjectType>>;

        #[deprecated = "GC no longer supported"]
        #[unsafe(method(mapTableWithStrongToStrongObjects))]
        #[unsafe(method_family = none)]
        pub fn mapTableWithStrongToStrongObjects() -> Retained<AnyObject>;

        #[deprecated = "GC no longer supported"]
        #[unsafe(method(mapTableWithWeakToStrongObjects))]
        #[unsafe(method_family = none)]
        pub fn mapTableWithWeakToStrongObjects() -> Retained<AnyObject>;

        #[deprecated = "GC no longer supported"]
        #[unsafe(method(mapTableWithStrongToWeakObjects))]
        #[unsafe(method_family = none)]
        pub fn mapTableWithStrongToWeakObjects() -> Retained<AnyObject>;

        #[deprecated = "GC no longer supported"]
        #[unsafe(method(mapTableWithWeakToWeakObjects))]
        #[unsafe(method_family = none)]
        pub fn mapTableWithWeakToWeakObjects() -> Retained<AnyObject>;

        #[unsafe(method(strongToStrongObjectsMapTable))]
        #[unsafe(method_family = none)]
        pub fn strongToStrongObjectsMapTable() -> Retained<NSMapTable<KeyType, ObjectType>>;

        #[unsafe(method(weakToStrongObjectsMapTable))]
        #[unsafe(method_family = none)]
        pub fn weakToStrongObjectsMapTable() -> Retained<NSMapTable<KeyType, ObjectType>>;

        #[unsafe(method(strongToWeakObjectsMapTable))]
        #[unsafe(method_family = none)]
        pub fn strongToWeakObjectsMapTable() -> Retained<NSMapTable<KeyType, ObjectType>>;

        #[unsafe(method(weakToWeakObjectsMapTable))]
        #[unsafe(method_family = none)]
        pub fn weakToWeakObjectsMapTable() -> Retained<NSMapTable<KeyType, ObjectType>>;

        #[cfg(feature = "NSPointerFunctions")]
        #[unsafe(method(keyPointerFunctions))]
        #[unsafe(method_family = none)]
        pub fn keyPointerFunctions(&self) -> Retained<NSPointerFunctions>;

        #[cfg(feature = "NSPointerFunctions")]
        #[unsafe(method(valuePointerFunctions))]
        #[unsafe(method_family = none)]
        pub fn valuePointerFunctions(&self) -> Retained<NSPointerFunctions>;

        #[unsafe(method(objectForKey:))]
        #[unsafe(method_family = none)]
        pub fn objectForKey(&self, a_key: Option<&KeyType>) -> Option<Retained<ObjectType>>;

        #[unsafe(method(removeObjectForKey:))]
        #[unsafe(method_family = none)]
        pub fn removeObjectForKey(&self, a_key: Option<&KeyType>);

        #[unsafe(method(setObject:forKey:))]
        #[unsafe(method_family = none)]
        pub fn setObject_forKey(&self, an_object: Option<&ObjectType>, a_key: Option<&KeyType>);

        #[unsafe(method(count))]
        #[unsafe(method_family = none)]
        pub fn count(&self) -> NSUInteger;

        #[cfg(feature = "NSEnumerator")]
        /// # Safety
        ///
        /// The returned enumerator's underlying collection should not be mutated while in use.
        #[unsafe(method(keyEnumerator))]
        #[unsafe(method_family = none)]
        pub unsafe fn keyEnumerator(&self) -> Retained<NSEnumerator<KeyType>>;

        #[cfg(feature = "NSEnumerator")]
        /// # Safety
        ///
        /// The returned enumerator's underlying collection should not be mutated while in use.
        #[unsafe(method(objectEnumerator))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectEnumerator(&self) -> Option<Retained<NSEnumerator<ObjectType>>>;

        #[unsafe(method(removeAllObjects))]
        #[unsafe(method_family = none)]
        pub fn removeAllObjects(&self);

        #[cfg(feature = "NSDictionary")]
        #[unsafe(method(dictionaryRepresentation))]
        #[unsafe(method_family = none)]
        pub fn dictionaryRepresentation(&self) -> Retained<NSDictionary<KeyType, ObjectType>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl<KeyType: Message, ObjectType: Message> NSMapTable<KeyType, ObjectType> {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl<KeyType: Message, ObjectType: Message> DefaultRetained for NSMapTable<KeyType, ObjectType> {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

/// **************    void * Map table operations    ***************
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmapenumerator?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct NSMapEnumerator {
    pub(crate) _pi: NSUInteger,
    pub(crate) _si: NSUInteger,
    pub(crate) _bs: *mut c_void,
}

unsafe impl Encode for NSMapEnumerator {
    const ENCODING: Encoding = Encoding::Struct(
        "?",
        &[
            <NSUInteger>::ENCODING,
            <NSUInteger>::ENCODING,
            <*mut c_void>::ENCODING,
        ],
    );
}

unsafe impl RefEncode for NSMapEnumerator {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `table` generic should be of the correct type.
    pub fn NSResetMapTable(table: &NSMapTable);
}

/// # Safety
///
/// - `table1` generic should be of the correct type.
/// - `table2` generic should be of the correct type.
#[inline]
pub unsafe extern "C-unwind" fn NSCompareMapTables(
    table1: &NSMapTable,
    table2: &NSMapTable,
) -> bool {
    extern "C-unwind" {
        fn NSCompareMapTables(table1: &NSMapTable, table2: &NSMapTable) -> Bool;
    }
    unsafe { NSCompareMapTables(table1, table2) }.as_bool()
}

/// # Safety
///
/// - `table` generic should be of the correct type.
/// - `zone` must be a valid pointer or null.
#[cfg(feature = "NSZone")]
#[inline]
pub unsafe extern "C-unwind" fn NSCopyMapTableWithZone(
    table: &NSMapTable,
    zone: *mut NSZone,
) -> Retained<NSMapTable> {
    extern "C-unwind" {
        fn NSCopyMapTableWithZone(table: &NSMapTable, zone: *mut NSZone) -> *mut NSMapTable;
    }
    let ret = unsafe { NSCopyMapTableWithZone(table, zone) };
    unsafe { Retained::from_raw(ret) }
        .expect("function was marked as returning non-null, but actually returned NULL")
}

/// # Safety
///
/// - `table` generic should be of the correct type.
/// - `key` must be a valid pointer.
/// - `original_key` must be a valid pointer or null.
/// - `value` must be a valid pointer or null.
#[inline]
pub unsafe extern "C-unwind" fn NSMapMember(
    table: &NSMapTable,
    key: NonNull<c_void>,
    original_key: *mut *mut c_void,
    value: *mut *mut c_void,
) -> bool {
    extern "C-unwind" {
        fn NSMapMember(
            table: &NSMapTable,
            key: NonNull<c_void>,
            original_key: *mut *mut c_void,
            value: *mut *mut c_void,
        ) -> Bool;
    }
    unsafe { NSMapMember(table, key, original_key, value) }.as_bool()
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `table` generic should be of the correct type.
    /// - `key` must be a valid pointer or null.
    pub fn NSMapGet(table: &NSMapTable, key: *const c_void) -> *mut c_void;
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `table` generic should be of the correct type.
    /// - `key` must be a valid pointer or null.
    /// - `value` must be a valid pointer or null.
    pub fn NSMapInsert(table: &NSMapTable, key: *const c_void, value: *const c_void);
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `table` generic should be of the correct type.
    /// - `key` must be a valid pointer or null.
    /// - `value` must be a valid pointer or null.
    pub fn NSMapInsertKnownAbsent(table: &NSMapTable, key: *const c_void, value: *const c_void);
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `table` generic should be of the correct type.
    /// - `key` must be a valid pointer or null.
    /// - `value` must be a valid pointer or null.
    pub fn NSMapInsertIfAbsent(
        table: &NSMapTable,
        key: *const c_void,
        value: *const c_void,
    ) -> *mut c_void;
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `table` generic should be of the correct type.
    /// - `key` must be a valid pointer or null.
    pub fn NSMapRemove(table: &NSMapTable, key: *const c_void);
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `table` generic should be of the correct type.
    pub fn NSEnumerateMapTable(table: &NSMapTable) -> NSMapEnumerator;
}

/// # Safety
///
/// - `enumerator` must be a valid pointer.
/// - `key` must be a valid pointer or null.
/// - `value` must be a valid pointer or null.
#[inline]
pub unsafe extern "C-unwind" fn NSNextMapEnumeratorPair(
    enumerator: NonNull<NSMapEnumerator>,
    key: *mut *mut c_void,
    value: *mut *mut c_void,
) -> bool {
    extern "C-unwind" {
        fn NSNextMapEnumeratorPair(
            enumerator: NonNull<NSMapEnumerator>,
            key: *mut *mut c_void,
            value: *mut *mut c_void,
        ) -> Bool;
    }
    unsafe { NSNextMapEnumeratorPair(enumerator, key, value) }.as_bool()
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `enumerator` must be a valid pointer.
    pub fn NSEndMapTableEnumeration(enumerator: NonNull<NSMapEnumerator>);
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `table` generic should be of the correct type.
    pub fn NSCountMapTable(table: &NSMapTable) -> NSUInteger;
}

#[cfg(feature = "NSString")]
impl NSString {
    /// # Safety
    ///
    /// `table` generic should be of the correct type.
    #[doc(alias = "NSStringFromMapTable")]
    #[cfg(feature = "NSString")]
    #[inline]
    pub unsafe fn from_map_table(table: &NSMapTable) -> Retained<NSString> {
        extern "C-unwind" {
            fn NSStringFromMapTable(table: &NSMapTable) -> *mut NSString;
        }
        let ret = unsafe { NSStringFromMapTable(table) };
        unsafe { Retained::retain_autoreleased(ret) }
            .expect("function was marked as returning non-null, but actually returned NULL")
    }
}

/// # Safety
///
/// `table` generic should be of the correct type.
#[cfg(feature = "NSArray")]
#[inline]
pub unsafe extern "C-unwind" fn NSAllMapTableKeys(table: &NSMapTable) -> Retained<NSArray> {
    extern "C-unwind" {
        fn NSAllMapTableKeys(table: &NSMapTable) -> *mut NSArray;
    }
    let ret = unsafe { NSAllMapTableKeys(table) };
    unsafe { Retained::retain_autoreleased(ret) }
        .expect("function was marked as returning non-null, but actually returned NULL")
}

/// # Safety
///
/// `table` generic should be of the correct type.
#[cfg(feature = "NSArray")]
#[inline]
pub unsafe extern "C-unwind" fn NSAllMapTableValues(table: &NSMapTable) -> Retained<NSArray> {
    extern "C-unwind" {
        fn NSAllMapTableValues(table: &NSMapTable) -> *mut NSArray;
    }
    let ret = unsafe { NSAllMapTableValues(table) };
    unsafe { Retained::retain_autoreleased(ret) }
        .expect("function was marked as returning non-null, but actually returned NULL")
}

/// **************     Legacy     **************************************
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaptablekeycallbacks?language=objc)
#[cfg(feature = "NSString")]
#[repr(C)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct NSMapTableKeyCallBacks {
    pub hash:
        Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>) -> NSUInteger>,
    pub isEqual: Option<
        unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>, NonNull<c_void>) -> Bool,
    >,
    pub retain: Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>)>,
    pub release: Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>)>,
    pub describe:
        Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>) -> *mut NSString>,
    pub notAKeyMarker: *const c_void,
}

#[cfg(feature = "NSString")]
unsafe impl Encode for NSMapTableKeyCallBacks {
    const ENCODING: Encoding = Encoding::Struct("?", &[
        <Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>,NonNull<c_void>,) -> NSUInteger>>::ENCODING,
        <Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>,NonNull<c_void>,NonNull<c_void>,) -> Bool>>::ENCODING,
        <Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>,NonNull<c_void>,)>>::ENCODING,
        <Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>,NonNull<c_void>,)>>::ENCODING,
        <Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>,NonNull<c_void>,) -> *mut NSString>>::ENCODING,
        <*const c_void>::ENCODING,
    ]);
}

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

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaptablevaluecallbacks?language=objc)
#[cfg(feature = "NSString")]
#[repr(C)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct NSMapTableValueCallBacks {
    pub retain: Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>)>,
    pub release: Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>)>,
    pub describe:
        Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>) -> *mut NSString>,
}

#[cfg(feature = "NSString")]
unsafe impl Encode for NSMapTableValueCallBacks {
    const ENCODING: Encoding = Encoding::Struct(
        "?",
        &[
            <Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>)>>::ENCODING,
            <Option<unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>)>>::ENCODING,
            <Option<
                unsafe extern "C-unwind" fn(NonNull<NSMapTable>, NonNull<c_void>) -> *mut NSString,
            >>::ENCODING,
        ],
    );
}

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

/// # Safety
///
/// - `key_call_backs` struct field 1 must be implemented correctly.
/// - `key_call_backs` struct field 2 must be implemented correctly.
/// - `key_call_backs` struct field 3 must be implemented correctly.
/// - `key_call_backs` struct field 4 must be implemented correctly.
/// - `key_call_backs` struct field 5 must be implemented correctly.
/// - `key_call_backs` struct field 6 must be a valid pointer or null.
/// - `value_call_backs` struct field 1 must be implemented correctly.
/// - `value_call_backs` struct field 2 must be implemented correctly.
/// - `value_call_backs` struct field 3 must be implemented correctly.
/// - `zone` must be a valid pointer or null.
#[cfg(all(feature = "NSString", feature = "NSZone"))]
#[inline]
pub unsafe extern "C-unwind" fn NSCreateMapTableWithZone(
    key_call_backs: NSMapTableKeyCallBacks,
    value_call_backs: NSMapTableValueCallBacks,
    capacity: NSUInteger,
    zone: *mut NSZone,
) -> Retained<NSMapTable> {
    extern "C-unwind" {
        fn NSCreateMapTableWithZone(
            key_call_backs: NSMapTableKeyCallBacks,
            value_call_backs: NSMapTableValueCallBacks,
            capacity: NSUInteger,
            zone: *mut NSZone,
        ) -> *mut NSMapTable;
    }
    let ret = unsafe { NSCreateMapTableWithZone(key_call_backs, value_call_backs, capacity, zone) };
    unsafe { Retained::from_raw(ret) }
        .expect("function was marked as returning non-null, but actually returned NULL")
}

/// # Safety
///
/// - `key_call_backs` struct field 1 must be implemented correctly.
/// - `key_call_backs` struct field 2 must be implemented correctly.
/// - `key_call_backs` struct field 3 must be implemented correctly.
/// - `key_call_backs` struct field 4 must be implemented correctly.
/// - `key_call_backs` struct field 5 must be implemented correctly.
/// - `key_call_backs` struct field 6 must be a valid pointer or null.
/// - `value_call_backs` struct field 1 must be implemented correctly.
/// - `value_call_backs` struct field 2 must be implemented correctly.
/// - `value_call_backs` struct field 3 must be implemented correctly.
#[cfg(feature = "NSString")]
#[inline]
pub unsafe extern "C-unwind" fn NSCreateMapTable(
    key_call_backs: NSMapTableKeyCallBacks,
    value_call_backs: NSMapTableValueCallBacks,
    capacity: NSUInteger,
) -> Retained<NSMapTable> {
    extern "C-unwind" {
        fn NSCreateMapTable(
            key_call_backs: NSMapTableKeyCallBacks,
            value_call_backs: NSMapTableValueCallBacks,
            capacity: NSUInteger,
        ) -> *mut NSMapTable;
    }
    let ret = unsafe { NSCreateMapTable(key_call_backs, value_call_backs, capacity) };
    unsafe { Retained::from_raw(ret) }
        .expect("function was marked as returning non-null, but actually returned NULL")
}

extern "C" {
    /// **************    Common map table key callbacks    ***************
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsintegermapkeycallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSIntegerMapKeyCallBacks: NSMapTableKeyCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnonownedpointermapkeycallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSNonOwnedPointerMapKeyCallBacks: NSMapTableKeyCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnonownedpointerornullmapkeycallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSNonOwnedPointerOrNullMapKeyCallBacks: NSMapTableKeyCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnonretainedobjectmapkeycallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSNonRetainedObjectMapKeyCallBacks: NSMapTableKeyCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsobjectmapkeycallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSObjectMapKeyCallBacks: NSMapTableKeyCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsownedpointermapkeycallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSOwnedPointerMapKeyCallBacks: NSMapTableKeyCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsintmapkeycallbacks?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated = "Not supported"]
    pub static NSIntMapKeyCallBacks: NSMapTableKeyCallBacks;
}

extern "C" {
    /// **************    Common map table value callbacks    ***************
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsintegermapvaluecallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSIntegerMapValueCallBacks: NSMapTableValueCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnonownedpointermapvaluecallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSNonOwnedPointerMapValueCallBacks: NSMapTableValueCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsobjectmapvaluecallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSObjectMapValueCallBacks: NSMapTableValueCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnonretainedobjectmapvaluecallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSNonRetainedObjectMapValueCallBacks: NSMapTableValueCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsownedpointermapvaluecallbacks?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSOwnedPointerMapValueCallBacks: NSMapTableValueCallBacks;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsintmapvaluecallbacks?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated = "Not supported"]
    pub static NSIntMapValueCallBacks: NSMapTableValueCallBacks;
}

#[cfg(feature = "NSString")]
#[deprecated = "renamed to `NSString::from_map_table`"]
#[inline]
pub unsafe extern "C-unwind" fn NSStringFromMapTable(table: &NSMapTable) -> Retained<NSString> {
    extern "C-unwind" {
        fn NSStringFromMapTable(table: &NSMapTable) -> *mut NSString;
    }
    let ret = unsafe { NSStringFromMapTable(table) };
    unsafe { Retained::retain_autoreleased(ret) }
        .expect("function was marked as returning non-null, but actually returned NULL")
}