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

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPersonNameComponentsFormatterStyle(pub NSInteger);
impl NSPersonNameComponentsFormatterStyle {
    #[doc(alias = "NSPersonNameComponentsFormatterStyleDefault")]
    pub const Default: Self = Self(0);
    #[doc(alias = "NSPersonNameComponentsFormatterStyleShort")]
    pub const Short: Self = Self(1);
    #[doc(alias = "NSPersonNameComponentsFormatterStyleMedium")]
    pub const Medium: Self = Self(2);
    #[doc(alias = "NSPersonNameComponentsFormatterStyleLong")]
    pub const Long: Self = Self(3);
    #[doc(alias = "NSPersonNameComponentsFormatterStyleAbbreviated")]
    pub const Abbreviated: Self = Self(4);
}

unsafe impl Encode for NSPersonNameComponentsFormatterStyle {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPersonNameComponentsFormatterOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSPersonNameComponentsFormatterOptions: NSUInteger {
        const NSPersonNameComponentsFormatterPhonetic = 1<<1;
    }
}

unsafe impl Encode for NSPersonNameComponentsFormatterOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSFormatter")]
    pub struct NSPersonNameComponentsFormatter;

    #[cfg(feature = "NSFormatter")]
    unsafe impl ClassType for NSPersonNameComponentsFormatter {
        #[inherits(NSObject)]
        type Super = NSFormatter;
        type Mutability = InteriorMutable;
    }
);

#[cfg(feature = "NSFormatter")]
unsafe impl Send for NSPersonNameComponentsFormatter {}

#[cfg(feature = "NSFormatter")]
unsafe impl Sync for NSPersonNameComponentsFormatter {}

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl NSCoding for NSPersonNameComponentsFormatter {}

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl NSCopying for NSPersonNameComponentsFormatter {}

#[cfg(feature = "NSFormatter")]
unsafe impl NSObjectProtocol for NSPersonNameComponentsFormatter {}

extern_methods!(
    #[cfg(feature = "NSFormatter")]
    unsafe impl NSPersonNameComponentsFormatter {
        #[method(style)]
        pub unsafe fn style(&self) -> NSPersonNameComponentsFormatterStyle;

        #[method(setStyle:)]
        pub unsafe fn setStyle(&self, style: NSPersonNameComponentsFormatterStyle);

        #[method(isPhonetic)]
        pub unsafe fn isPhonetic(&self) -> bool;

        #[method(setPhonetic:)]
        pub unsafe fn setPhonetic(&self, phonetic: bool);

        #[cfg(feature = "NSLocale")]
        #[method_id(@__retain_semantics Other locale)]
        pub unsafe fn locale(&self) -> Retained<NSLocale>;

        #[cfg(feature = "NSLocale")]
        #[method(setLocale:)]
        pub unsafe fn setLocale(&self, locale: Option<&NSLocale>);

        #[cfg(all(feature = "NSPersonNameComponents", feature = "NSString"))]
        #[method_id(@__retain_semantics Other localizedStringFromPersonNameComponents:style:options:)]
        pub unsafe fn localizedStringFromPersonNameComponents_style_options(
            components: &NSPersonNameComponents,
            name_format_style: NSPersonNameComponentsFormatterStyle,
            name_options: NSPersonNameComponentsFormatterOptions,
        ) -> Retained<NSString>;

        #[cfg(all(feature = "NSPersonNameComponents", feature = "NSString"))]
        #[method_id(@__retain_semantics Other stringFromPersonNameComponents:)]
        pub unsafe fn stringFromPersonNameComponents(
            &self,
            components: &NSPersonNameComponents,
        ) -> Retained<NSString>;

        #[cfg(all(feature = "NSAttributedString", feature = "NSPersonNameComponents"))]
        #[method_id(@__retain_semantics Other annotatedStringFromPersonNameComponents:)]
        pub unsafe fn annotatedStringFromPersonNameComponents(
            &self,
            components: &NSPersonNameComponents,
        ) -> Retained<NSAttributedString>;

        #[cfg(all(feature = "NSPersonNameComponents", feature = "NSString"))]
        #[method_id(@__retain_semantics Other personNameComponentsFromString:)]
        pub unsafe fn personNameComponentsFromString(
            &self,
            string: &NSString,
        ) -> Option<Retained<NSPersonNameComponents>>;

        #[cfg(feature = "NSString")]
        #[method(getObjectValue:forString:errorDescription:)]
        pub unsafe fn getObjectValue_forString_errorDescription(
            &self,
            obj: Option<&mut Option<Retained<AnyObject>>>,
            string: &NSString,
            error: Option<&mut Option<Retained<NSString>>>,
        ) -> bool;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "NSFormatter")]
    unsafe impl NSPersonNameComponentsFormatter {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentKey: &'static NSString;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentGivenName: &'static NSString;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentFamilyName: &'static NSString;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentMiddleName: &'static NSString;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentPrefix: &'static NSString;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentSuffix: &'static NSString;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentNickname: &'static NSString;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentDelimiter: &'static NSString;
}