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
//! 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 CLDeviceOrientation(pub c_int);
impl CLDeviceOrientation {
    #[doc(alias = "CLDeviceOrientationUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "CLDeviceOrientationPortrait")]
    pub const Portrait: Self = Self(1);
    #[doc(alias = "CLDeviceOrientationPortraitUpsideDown")]
    pub const PortraitUpsideDown: Self = Self(2);
    #[doc(alias = "CLDeviceOrientationLandscapeLeft")]
    pub const LandscapeLeft: Self = Self(3);
    #[doc(alias = "CLDeviceOrientationLandscapeRight")]
    pub const LandscapeRight: Self = Self(4);
    #[doc(alias = "CLDeviceOrientationFaceUp")]
    pub const FaceUp: Self = Self(5);
    #[doc(alias = "CLDeviceOrientationFaceDown")]
    pub const FaceDown: Self = Self(6);
}

unsafe impl Encode for CLDeviceOrientation {
    const ENCODING: Encoding = c_int::ENCODING;
}

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CLAuthorizationStatus(pub c_int);
impl CLAuthorizationStatus {
    pub const kCLAuthorizationStatusNotDetermined: Self = Self(0);
    pub const kCLAuthorizationStatusRestricted: Self = Self(1);
    pub const kCLAuthorizationStatusDenied: Self = Self(2);
    pub const kCLAuthorizationStatusAuthorizedAlways: Self = Self(3);
    pub const kCLAuthorizationStatusAuthorizedWhenInUse: Self = Self(4);
    #[deprecated = "Use kCLAuthorizationStatusAuthorizedAlways"]
    pub const kCLAuthorizationStatusAuthorized: Self =
        Self(CLAuthorizationStatus::kCLAuthorizationStatusAuthorizedAlways.0);
}

unsafe impl Encode for CLAuthorizationStatus {
    const ENCODING: Encoding = c_int::ENCODING;
}

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CLAccuracyAuthorization(pub NSInteger);
impl CLAccuracyAuthorization {
    #[doc(alias = "CLAccuracyAuthorizationFullAccuracy")]
    pub const FullAccuracy: Self = Self(0);
    #[doc(alias = "CLAccuracyAuthorizationReducedAccuracy")]
    pub const ReducedAccuracy: Self = Self(1);
}

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

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CLActivityType(pub NSInteger);
impl CLActivityType {
    #[doc(alias = "CLActivityTypeOther")]
    pub const Other: Self = Self(1);
    #[doc(alias = "CLActivityTypeAutomotiveNavigation")]
    pub const AutomotiveNavigation: Self = Self(2);
    #[doc(alias = "CLActivityTypeFitness")]
    pub const Fitness: Self = Self(3);
    #[doc(alias = "CLActivityTypeOtherNavigation")]
    pub const OtherNavigation: Self = Self(4);
    #[doc(alias = "CLActivityTypeAirborne")]
    pub const Airborne: Self = Self(5);
}

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

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

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

    unsafe impl ClassType for CLLocationManager {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for CLLocationManager {}

extern_methods!(
    unsafe impl CLLocationManager {
        #[method(locationServicesEnabled)]
        pub unsafe fn locationServicesEnabled_class() -> bool;

        #[method(headingAvailable)]
        pub unsafe fn headingAvailable_class() -> bool;

        #[method(significantLocationChangeMonitoringAvailable)]
        pub unsafe fn significantLocationChangeMonitoringAvailable() -> bool;

        #[method(isMonitoringAvailableForClass:)]
        pub unsafe fn isMonitoringAvailableForClass(region_class: &AnyClass) -> bool;

        #[deprecated]
        #[method(regionMonitoringAvailable)]
        pub unsafe fn regionMonitoringAvailable() -> bool;

        #[deprecated = "Use +isMonitoringAvailableForClass: and -authorizationStatus instead"]
        #[method(regionMonitoringEnabled)]
        pub unsafe fn regionMonitoringEnabled() -> bool;

        #[method(isRangingAvailable)]
        pub unsafe fn isRangingAvailable() -> bool;

        #[method(authorizationStatus)]
        pub unsafe fn authorizationStatus(&self) -> CLAuthorizationStatus;

        #[deprecated]
        #[method(authorizationStatus)]
        pub unsafe fn authorizationStatus_class() -> CLAuthorizationStatus;

        #[method(accuracyAuthorization)]
        pub unsafe fn accuracyAuthorization(&self) -> CLAccuracyAuthorization;

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

        #[cfg(feature = "CLLocationManagerDelegate")]
        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn CLLocationManagerDelegate>>>;

        #[cfg(feature = "CLLocationManagerDelegate")]
        #[method(setDelegate:)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn CLLocationManagerDelegate>>,
        );

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

        #[deprecated = "Set the purpose string in Info.plist using key NSLocationUsageDescription"]
        #[method_id(@__retain_semantics Other purpose)]
        pub unsafe fn purpose(&self) -> Option<Retained<NSString>>;

        #[deprecated = "Set the purpose string in Info.plist using key NSLocationUsageDescription"]
        #[method(setPurpose:)]
        pub unsafe fn setPurpose(&self, purpose: Option<&NSString>);

        #[method(activityType)]
        pub unsafe fn activityType(&self) -> CLActivityType;

        #[method(setActivityType:)]
        pub unsafe fn setActivityType(&self, activity_type: CLActivityType);

        #[cfg(feature = "CLLocation")]
        #[method(distanceFilter)]
        pub unsafe fn distanceFilter(&self) -> CLLocationDistance;

        #[cfg(feature = "CLLocation")]
        #[method(setDistanceFilter:)]
        pub unsafe fn setDistanceFilter(&self, distance_filter: CLLocationDistance);

        #[cfg(feature = "CLLocation")]
        #[method(desiredAccuracy)]
        pub unsafe fn desiredAccuracy(&self) -> CLLocationAccuracy;

        #[cfg(feature = "CLLocation")]
        #[method(setDesiredAccuracy:)]
        pub unsafe fn setDesiredAccuracy(&self, desired_accuracy: CLLocationAccuracy);

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

        #[method(setPausesLocationUpdatesAutomatically:)]
        pub unsafe fn setPausesLocationUpdatesAutomatically(
            &self,
            pauses_location_updates_automatically: bool,
        );

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

        #[method(setAllowsBackgroundLocationUpdates:)]
        pub unsafe fn setAllowsBackgroundLocationUpdates(
            &self,
            allows_background_location_updates: bool,
        );

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

        #[method(setShowsBackgroundLocationIndicator:)]
        pub unsafe fn setShowsBackgroundLocationIndicator(
            &self,
            shows_background_location_indicator: bool,
        );

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

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

        #[cfg(feature = "CLLocation")]
        #[method(headingFilter)]
        pub unsafe fn headingFilter(&self) -> CLLocationDegrees;

        #[cfg(feature = "CLLocation")]
        #[method(setHeadingFilter:)]
        pub unsafe fn setHeadingFilter(&self, heading_filter: CLLocationDegrees);

        #[method(headingOrientation)]
        pub unsafe fn headingOrientation(&self) -> CLDeviceOrientation;

        #[method(setHeadingOrientation:)]
        pub unsafe fn setHeadingOrientation(&self, heading_orientation: CLDeviceOrientation);

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

        #[cfg(feature = "CLLocation")]
        #[method(maximumRegionMonitoringDistance)]
        pub unsafe fn maximumRegionMonitoringDistance(&self) -> CLLocationDistance;

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

        #[cfg(feature = "CLRegion")]
        #[deprecated = "Use -rangedBeaconConstraints"]
        #[method_id(@__retain_semantics Other rangedRegions)]
        pub unsafe fn rangedRegions(&self) -> Retained<NSSet<CLRegion>>;

        #[cfg(all(
            feature = "CLBeaconIdentityCondition",
            feature = "CLBeaconIdentityConstraint",
            feature = "CLCondition"
        ))]
        #[method_id(@__retain_semantics Other rangedBeaconConstraints)]
        pub unsafe fn rangedBeaconConstraints(&self)
            -> Retained<NSSet<CLBeaconIdentityConstraint>>;

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

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

        #[cfg(feature = "block2")]
        #[method(requestTemporaryFullAccuracyAuthorizationWithPurposeKey:completion:)]
        pub unsafe fn requestTemporaryFullAccuracyAuthorizationWithPurposeKey_completion(
            &self,
            purpose_key: &NSString,
            completion: Option<&block2::Block<dyn Fn(*mut NSError)>>,
        );

        #[method(requestTemporaryFullAccuracyAuthorizationWithPurposeKey:)]
        pub unsafe fn requestTemporaryFullAccuracyAuthorizationWithPurposeKey(
            &self,
            purpose_key: &NSString,
        );

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

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

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

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

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

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

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

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

        #[cfg(feature = "block2")]
        #[method(startMonitoringLocationPushesWithCompletion:)]
        pub unsafe fn startMonitoringLocationPushesWithCompletion(
            &self,
            completion: Option<&block2::Block<dyn Fn(*mut NSData, *mut NSError)>>,
        );

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

        #[cfg(all(feature = "CLLocation", feature = "CLRegion"))]
        #[deprecated]
        #[method(startMonitoringForRegion:desiredAccuracy:)]
        pub unsafe fn startMonitoringForRegion_desiredAccuracy(
            &self,
            region: &CLRegion,
            accuracy: CLLocationAccuracy,
        );

        #[cfg(feature = "CLRegion")]
        #[deprecated]
        #[method(stopMonitoringForRegion:)]
        pub unsafe fn stopMonitoringForRegion(&self, region: &CLRegion);

        #[cfg(feature = "CLRegion")]
        #[deprecated]
        #[method(startMonitoringForRegion:)]
        pub unsafe fn startMonitoringForRegion(&self, region: &CLRegion);

        #[cfg(feature = "CLRegion")]
        #[deprecated]
        #[method(requestStateForRegion:)]
        pub unsafe fn requestStateForRegion(&self, region: &CLRegion);

        #[cfg(all(feature = "CLBeaconRegion", feature = "CLRegion"))]
        #[deprecated = "Use -startRangingBeaconsSatisfyingConstraint:"]
        #[method(startRangingBeaconsInRegion:)]
        pub unsafe fn startRangingBeaconsInRegion(&self, region: &CLBeaconRegion);

        #[cfg(all(feature = "CLBeaconRegion", feature = "CLRegion"))]
        #[deprecated = "Use -stopRangingBeaconsSatisfyingConstraint:"]
        #[method(stopRangingBeaconsInRegion:)]
        pub unsafe fn stopRangingBeaconsInRegion(&self, region: &CLBeaconRegion);

        #[cfg(all(
            feature = "CLBeaconIdentityCondition",
            feature = "CLBeaconIdentityConstraint",
            feature = "CLCondition"
        ))]
        #[method(startRangingBeaconsSatisfyingConstraint:)]
        pub unsafe fn startRangingBeaconsSatisfyingConstraint(
            &self,
            constraint: &CLBeaconIdentityConstraint,
        );

        #[cfg(all(
            feature = "CLBeaconIdentityCondition",
            feature = "CLBeaconIdentityConstraint",
            feature = "CLCondition"
        ))]
        #[method(stopRangingBeaconsSatisfyingConstraint:)]
        pub unsafe fn stopRangingBeaconsSatisfyingConstraint(
            &self,
            constraint: &CLBeaconIdentityConstraint,
        );

        #[cfg(feature = "CLLocation")]
        #[deprecated = "You can remove calls to this method"]
        #[method(allowDeferredLocationUpdatesUntilTraveled:timeout:)]
        pub unsafe fn allowDeferredLocationUpdatesUntilTraveled_timeout(
            &self,
            distance: CLLocationDistance,
            timeout: NSTimeInterval,
        );

        #[deprecated = "You can remove calls to this method"]
        #[method(disallowDeferredLocationUpdates)]
        pub unsafe fn disallowDeferredLocationUpdates(&self);

        #[deprecated = "You can remove calls to this method"]
        #[method(deferredLocationUpdatesAvailable)]
        pub unsafe fn deferredLocationUpdatesAvailable() -> bool;

        #[cfg(all(feature = "CLLocation", feature = "block2"))]
        #[method(requestHistoricalLocationsWithPurposeKey:sampleCount:completionHandler:)]
        pub unsafe fn requestHistoricalLocationsWithPurposeKey_sampleCount_completionHandler(
            &self,
            purpose_key: &NSString,
            sample_count: NSInteger,
            handler: &block2::Block<dyn Fn(NonNull<NSArray<CLLocation>>, *mut NSError)>,
        );
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl CLLocationManager {
        #[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>;
    }
);