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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
#[cfg(feature = "block2")]
use block2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSFetchRequestResultType(pub NSUInteger);
impl NSFetchRequestResultType {
    pub const NSManagedObjectResultType: Self = Self(0x00);
    pub const NSManagedObjectIDResultType: Self = Self(0x01);
    pub const NSDictionaryResultType: Self = Self(0x02);
    pub const NSCountResultType: Self = Self(0x04);
}

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

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

extern_protocol!(
    pub unsafe trait NSFetchRequestResult: NSObjectProtocol {}

    unsafe impl ProtocolType for dyn NSFetchRequestResult {}
);

unsafe impl NSFetchRequestResult for NSNumber {}

unsafe impl NSFetchRequestResult for NSDictionary {}

extern_methods!(
    /// NSFetchedResultSupport
    #[cfg(feature = "NSManagedObject")]
    unsafe impl NSManagedObject {}
);

#[cfg(feature = "NSManagedObject")]
unsafe impl NSFetchRequestResult for NSManagedObject {}

extern_methods!(
    /// NSFetchedResultSupport
    #[cfg(feature = "NSManagedObjectID")]
    unsafe impl NSManagedObjectID {}
);

#[cfg(feature = "NSManagedObjectID")]
unsafe impl NSFetchRequestResult for NSManagedObjectID {}

__inner_extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSPersistentStoreRequest")]
    pub struct NSFetchRequest<ResultType: ?Sized = AnyObject> {
        __superclass: NSPersistentStoreRequest,
        _inner0: PhantomData<*mut ResultType>,
        notunwindsafe: PhantomData<&'static mut ()>,
    }

    #[cfg(feature = "NSPersistentStoreRequest")]
    unsafe impl<ResultType: ?Sized + Message> ClassType for NSFetchRequest<ResultType> {
        #[inherits(NSObject)]
        type Super = NSPersistentStoreRequest;
        type Mutability = InteriorMutable;

        fn as_super(&self) -> &Self::Super {
            &self.__superclass
        }

        fn as_super_mut(&mut self) -> &mut Self::Super {
            &mut self.__superclass
        }
    }
);

#[cfg(feature = "NSPersistentStoreRequest")]
unsafe impl<ResultType: ?Sized + NSCoding> NSCoding for NSFetchRequest<ResultType> {}

#[cfg(feature = "NSPersistentStoreRequest")]
unsafe impl<ResultType: ?Sized + IsIdCloneable> NSCopying for NSFetchRequest<ResultType> {}

#[cfg(feature = "NSPersistentStoreRequest")]
unsafe impl<ResultType: ?Sized> NSObjectProtocol for NSFetchRequest<ResultType> {}

extern_methods!(
    #[cfg(feature = "NSPersistentStoreRequest")]
    unsafe impl<ResultType: Message> NSFetchRequest<ResultType> {
        #[method_id(@__retain_semantics Other fetchRequestWithEntityName:)]
        pub unsafe fn fetchRequestWithEntityName(entity_name: &NSString) -> Id<Self>;

        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics Init initWithEntityName:)]
        pub unsafe fn initWithEntityName(this: Allocated<Self>, entity_name: &NSString)
            -> Id<Self>;

        #[method_id(@__retain_semantics Other execute:_)]
        pub unsafe fn execute(&self) -> Result<Id<NSArray<ResultType>>, Id<NSError>>;

        #[cfg(feature = "NSEntityDescription")]
        #[method_id(@__retain_semantics Other entity)]
        pub unsafe fn entity(&self) -> Option<Id<NSEntityDescription>>;

        #[cfg(feature = "NSEntityDescription")]
        #[method(setEntity:)]
        pub unsafe fn setEntity(&self, entity: Option<&NSEntityDescription>);

        #[method_id(@__retain_semantics Other entityName)]
        pub unsafe fn entityName(&self) -> Option<Id<NSString>>;

        #[method_id(@__retain_semantics Other predicate)]
        pub unsafe fn predicate(&self) -> Option<Id<NSPredicate>>;

        #[method(setPredicate:)]
        pub unsafe fn setPredicate(&self, predicate: Option<&NSPredicate>);

        #[method_id(@__retain_semantics Other sortDescriptors)]
        pub unsafe fn sortDescriptors(&self) -> Option<Id<NSArray<NSSortDescriptor>>>;

        #[method(setSortDescriptors:)]
        pub unsafe fn setSortDescriptors(
            &self,
            sort_descriptors: Option<&NSArray<NSSortDescriptor>>,
        );

        #[method(fetchLimit)]
        pub unsafe fn fetchLimit(&self) -> NSUInteger;

        #[method(setFetchLimit:)]
        pub unsafe fn setFetchLimit(&self, fetch_limit: NSUInteger);

        #[cfg(feature = "NSPersistentStore")]
        #[method_id(@__retain_semantics Other affectedStores)]
        pub unsafe fn affectedStores(&self) -> Option<Id<NSArray<NSPersistentStore>>>;

        #[cfg(feature = "NSPersistentStore")]
        #[method(setAffectedStores:)]
        pub unsafe fn setAffectedStores(
            &self,
            affected_stores: Option<&NSArray<NSPersistentStore>>,
        );

        #[method(resultType)]
        pub unsafe fn resultType(&self) -> NSFetchRequestResultType;

        #[method(setResultType:)]
        pub unsafe fn setResultType(&self, result_type: NSFetchRequestResultType);

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

        #[method(setIncludesSubentities:)]
        pub unsafe fn setIncludesSubentities(&self, includes_subentities: bool);

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

        #[method(setIncludesPropertyValues:)]
        pub unsafe fn setIncludesPropertyValues(&self, includes_property_values: bool);

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

        #[method(setReturnsObjectsAsFaults:)]
        pub unsafe fn setReturnsObjectsAsFaults(&self, returns_objects_as_faults: bool);

        #[method_id(@__retain_semantics Other relationshipKeyPathsForPrefetching)]
        pub unsafe fn relationshipKeyPathsForPrefetching(&self) -> Option<Id<NSArray<NSString>>>;

        #[method(setRelationshipKeyPathsForPrefetching:)]
        pub unsafe fn setRelationshipKeyPathsForPrefetching(
            &self,
            relationship_key_paths_for_prefetching: Option<&NSArray<NSString>>,
        );

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

        #[method(setIncludesPendingChanges:)]
        pub unsafe fn setIncludesPendingChanges(&self, includes_pending_changes: bool);

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

        #[method(setReturnsDistinctResults:)]
        pub unsafe fn setReturnsDistinctResults(&self, returns_distinct_results: bool);

        #[method_id(@__retain_semantics Other propertiesToFetch)]
        pub unsafe fn propertiesToFetch(&self) -> Option<Id<NSArray>>;

        #[method(setPropertiesToFetch:)]
        pub unsafe fn setPropertiesToFetch(&self, properties_to_fetch: Option<&NSArray>);

        #[method(fetchOffset)]
        pub unsafe fn fetchOffset(&self) -> NSUInteger;

        #[method(setFetchOffset:)]
        pub unsafe fn setFetchOffset(&self, fetch_offset: NSUInteger);

        #[method(fetchBatchSize)]
        pub unsafe fn fetchBatchSize(&self) -> NSUInteger;

        #[method(setFetchBatchSize:)]
        pub unsafe fn setFetchBatchSize(&self, fetch_batch_size: NSUInteger);

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

        #[method(setShouldRefreshRefetchedObjects:)]
        pub unsafe fn setShouldRefreshRefetchedObjects(
            &self,
            should_refresh_refetched_objects: bool,
        );

        #[method_id(@__retain_semantics Other propertiesToGroupBy)]
        pub unsafe fn propertiesToGroupBy(&self) -> Option<Id<NSArray>>;

        #[method(setPropertiesToGroupBy:)]
        pub unsafe fn setPropertiesToGroupBy(&self, properties_to_group_by: Option<&NSArray>);

        #[method_id(@__retain_semantics Other havingPredicate)]
        pub unsafe fn havingPredicate(&self) -> Option<Id<NSPredicate>>;

        #[method(setHavingPredicate:)]
        pub unsafe fn setHavingPredicate(&self, having_predicate: Option<&NSPredicate>);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "NSPersistentStoreRequest")]
    unsafe impl<ResultType: Message> NSFetchRequest<ResultType> {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);

#[cfg(all(feature = "NSPersistentStoreResult", feature = "block2"))]
pub type NSPersistentStoreAsynchronousFetchResultCompletionBlock =
    *mut Block<dyn Fn(NonNull<NSAsynchronousFetchResult>)>;

__inner_extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSPersistentStoreRequest")]
    pub struct NSAsynchronousFetchRequest<ResultType: ?Sized = AnyObject> {
        __superclass: NSPersistentStoreRequest,
        _inner0: PhantomData<*mut ResultType>,
        notunwindsafe: PhantomData<&'static mut ()>,
    }

    #[cfg(feature = "NSPersistentStoreRequest")]
    unsafe impl<ResultType: ?Sized + Message> ClassType for NSAsynchronousFetchRequest<ResultType> {
        #[inherits(NSObject)]
        type Super = NSPersistentStoreRequest;
        type Mutability = InteriorMutable;

        fn as_super(&self) -> &Self::Super {
            &self.__superclass
        }

        fn as_super_mut(&mut self) -> &mut Self::Super {
            &mut self.__superclass
        }
    }
);

#[cfg(feature = "NSPersistentStoreRequest")]
unsafe impl<ResultType: ?Sized + IsIdCloneable> NSCopying
    for NSAsynchronousFetchRequest<ResultType>
{
}

#[cfg(feature = "NSPersistentStoreRequest")]
unsafe impl<ResultType: ?Sized> NSObjectProtocol for NSAsynchronousFetchRequest<ResultType> {}

extern_methods!(
    #[cfg(feature = "NSPersistentStoreRequest")]
    unsafe impl<ResultType: Message> NSAsynchronousFetchRequest<ResultType> {
        #[method_id(@__retain_semantics Other fetchRequest)]
        pub unsafe fn fetchRequest(&self) -> Id<NSFetchRequest<ResultType>>;

        #[cfg(all(feature = "NSPersistentStoreResult", feature = "block2"))]
        #[method(completionBlock)]
        pub unsafe fn completionBlock(
            &self,
        ) -> NSPersistentStoreAsynchronousFetchResultCompletionBlock;

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

        #[method(setEstimatedResultCount:)]
        pub unsafe fn setEstimatedResultCount(&self, estimated_result_count: NSInteger);

        #[cfg(all(feature = "NSPersistentStoreResult", feature = "block2"))]
        #[method_id(@__retain_semantics Init initWithFetchRequest:completionBlock:)]
        pub unsafe fn initWithFetchRequest_completionBlock(
            this: Allocated<Self>,
            request: &NSFetchRequest<ResultType>,
            blk: Option<&Block<dyn Fn(NonNull<NSAsynchronousFetchResult<ResultType>>)>>,
        ) -> Id<Self>;
    }
);

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

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