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

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIFindSessionSearchResultDisplayStyle(pub NSInteger);
impl UIFindSessionSearchResultDisplayStyle {
    #[doc(alias = "UIFindSessionSearchResultDisplayStyleCurrentAndTotal")]
    pub const CurrentAndTotal: Self = Self(0);
    #[doc(alias = "UIFindSessionSearchResultDisplayStyleTotal")]
    pub const Total: Self = Self(1);
    #[doc(alias = "UIFindSessionSearchResultDisplayStyleNone")]
    pub const None: Self = Self(2);
}

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

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITextSearchMatchMethod(pub NSInteger);
impl UITextSearchMatchMethod {
    #[doc(alias = "UITextSearchMatchMethodContains")]
    pub const Contains: Self = Self(0);
    #[doc(alias = "UITextSearchMatchMethodStartsWith")]
    pub const StartsWith: Self = Self(1);
    #[doc(alias = "UITextSearchMatchMethodFullWord")]
    pub const FullWord: Self = Self(2);
}

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

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

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UITextSearchOptions;

    unsafe impl ClassType for UITextSearchOptions {
        type Super = NSObject;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSObjectProtocol for UITextSearchOptions {}

extern_methods!(
    unsafe impl UITextSearchOptions {
        #[method(wordMatchMethod)]
        pub unsafe fn wordMatchMethod(&self) -> UITextSearchMatchMethod;

        #[method(stringCompareOptions)]
        pub unsafe fn stringCompareOptions(&self) -> NSStringCompareOptions;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UITextSearchOptions {
        #[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(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UIFindSession;

    unsafe impl ClassType for UIFindSession {
        type Super = NSObject;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSObjectProtocol for UIFindSession {}

extern_methods!(
    unsafe impl UIFindSession {
        #[method(resultCount)]
        pub unsafe fn resultCount(&self) -> NSInteger;

        #[method(highlightedResultIndex)]
        pub unsafe fn highlightedResultIndex(&self) -> NSInteger;

        #[method(searchResultDisplayStyle)]
        pub unsafe fn searchResultDisplayStyle(&self) -> UIFindSessionSearchResultDisplayStyle;

        #[method(setSearchResultDisplayStyle:)]
        pub unsafe fn setSearchResultDisplayStyle(
            &self,
            search_result_display_style: UIFindSessionSearchResultDisplayStyle,
        );

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

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

        #[method(performSearchWithQuery:options:)]
        pub unsafe fn performSearchWithQuery_options(
            &self,
            query: &NSString,
            options: Option<&UITextSearchOptions>,
        );

        #[method(performSingleReplacementWithSearchQuery:replacementString:options:)]
        pub unsafe fn performSingleReplacementWithSearchQuery_replacementString_options(
            &self,
            search_query: &NSString,
            replacement_string: &NSString,
            options: Option<&UITextSearchOptions>,
        );

        #[method(replaceAllInstancesOfSearchQuery:withReplacementString:options:)]
        pub unsafe fn replaceAllInstancesOfSearchQuery_withReplacementString_options(
            &self,
            search_query: &NSString,
            replacement_string: &NSString,
            options: Option<&UITextSearchOptions>,
        );

        #[cfg(feature = "UITextInput")]
        #[method(highlightNextResultInDirection:)]
        pub unsafe fn highlightNextResultInDirection(&self, direction: UITextStorageDirection);

        #[method(invalidateFoundResults)]
        pub unsafe fn invalidateFoundResults(&self);

        #[deprecated]
        #[method(allowsReplacement)]
        pub unsafe fn allowsReplacement(&self) -> bool;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UIFindSession {
        #[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(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UITextSearchingFindSession;

    unsafe impl ClassType for UITextSearchingFindSession {
        #[inherits(NSObject)]
        type Super = UIFindSession;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSObjectProtocol for UITextSearchingFindSession {}

extern_methods!(
    unsafe impl UITextSearchingFindSession {
        #[cfg(feature = "UITextSearching")]
        #[method_id(@__retain_semantics Other searchableObject)]
        pub unsafe fn searchableObject(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UITextSearching>>>;

        #[cfg(feature = "UITextSearching")]
        #[method_id(@__retain_semantics Init initWithSearchableObject:)]
        pub unsafe fn initWithSearchableObject(
            this: Allocated<Self>,
            searchable_object: &ProtocolObject<dyn UITextSearching>,
        ) -> Retained<Self>;

        #[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(mtm: MainThreadMarker) -> Retained<Self>;
    }
);