Skip to content

Commit

Permalink
fix(ios): modify BOOL to bool for return types to fix JS representation
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Sep 8, 2020
1 parent 7aef532 commit 0b251e2
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 81 deletions.
2 changes: 1 addition & 1 deletion iphone/Classes/AnalyticsModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// Properties (and accessors)
READONLY_PROPERTY(NSString *, lastEvent, LastEvent);
PROPERTY(BOOL, optedOut, OptedOut);
PROPERTY(bool, optedOut, OptedOut);

// Methods
JSExportAs(featureEvent,
Expand Down
9 changes: 5 additions & 4 deletions iphone/Classes/AnalyticsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@import TitaniumKit.APSAnalytics;
@import TitaniumKit.TiBase;
@import TitaniumKit.TiUtils;
#import <objc/runtime.h>

extern BOOL const TI_APPLICATION_ANALYTICS;
static NSMutableArray *_filteredEvents;
Expand Down Expand Up @@ -111,17 +112,17 @@ - (void)filterEvents:(NSArray *)events
}
}

- (void)setOptedOut:(BOOL)optedOut
- (void)setOptedOut:(bool)optedOut
{
[[APSAnalytics sharedInstance] setOptedOut:optedOut];
}

- (BOOL)optedOut
- (bool)optedOut
{
return [[APSAnalytics sharedInstance] isOptedOut];
return [APSAnalytics.sharedInstance isOptedOut];
}

READWRITE_IMPL(BOOL, optedOut, OptedOut);
READWRITE_IMPL(bool, optedOut, OptedOut);

+ (BOOL)isEventFiltered:(NSString *)eventName
{
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/FilesystemModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ READONLY_PROPERTY(NSString *, tempDirectory, TempDirectory);
// TODO: Change JSValue* to TiFile* once TiFile is migrated
// Note that this accepts varargs, which we handle special in impl
- (JSValue *)getFile;
- (BOOL)isExternalStoragePresent;
- (bool)isExternalStoragePresent;
// TODO: Change JSValue* to TiFile* once TiFile is migrated
// Note that this accepts varargs, which we handle special in impl
- (JSValue *)openStream:(TiStreamMode)mode;
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/FilesystemModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ - (TiStreamMode)MODE_WRITE
return TI_WRITE;
}

- (BOOL)isExternalStoragePresent
- (bool)isExternalStoragePresent
{
//IOS treats the camera connection kit as just that, and does not allow
//R/W access to it, which is just as well as it'd mess up cameras.
Expand Down
18 changes: 9 additions & 9 deletions iphone/Classes/GeolocationModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ CONSTANT(NSNumber *, ERROR_REGION_MONITORING_FAILURE);
// Properties
PROPERTY(CLLocationAccuracy, accuracy, Accuracy);
PROPERTY(CLActivityType, activityType, ActivityType);
PROPERTY(BOOL, allowsBackgroundLocationUpdates, AllowsBackgroundLocationUpdates);
PROPERTY(bool, allowsBackgroundLocationUpdates, AllowsBackgroundLocationUpdates);
PROPERTY(CLLocationDistance, distanceFilter, DistanceFilter);
READONLY_PROPERTY(BOOL, hasCompass, HasCompass);
READONLY_PROPERTY(bool, hasCompass, HasCompass);
PROPERTY(CLLocationDegrees, headingFilter, HeadingFilter);
READONLY_PROPERTY(NSString *, lastGeolocation, LastGeolocation);
READONLY_PROPERTY(CLAuthorizationStatus, locationServicesAuthorization, LocationServicesAuthorization);
READONLY_PROPERTY(BOOL, locationServicesEnabled, LocationServicesEnabled);
PROPERTY(BOOL, pauseLocationUpdateAutomatically, PauseLocationUpdateAutomatically);
PROPERTY(BOOL, showBackgroundLocationIndicator, ShowBackgroundLocationIndicator);
PROPERTY(BOOL, showCalibration, ShowCalibration);
PROPERTY(BOOL, trackSignificantLocationChange, TrackSignificantLocationChange);
READONLY_PROPERTY(bool, locationServicesEnabled, LocationServicesEnabled);
PROPERTY(bool, pauseLocationUpdateAutomatically, PauseLocationUpdateAutomatically);
PROPERTY(bool, showBackgroundLocationIndicator, ShowBackgroundLocationIndicator);
PROPERTY(bool, showCalibration, ShowCalibration);
PROPERTY(bool, trackSignificantLocationChange, TrackSignificantLocationChange);

// methods
JSExportAs(forwardGeocoder,
Expand All @@ -74,7 +74,7 @@ JSExportAs(forwardGeocoder,
: (JSValue *)callback);
- (void)getCurrentHeading:(JSValue *)callback;
- (void)getCurrentPosition:(JSValue *)callback;
- (BOOL)hasLocationPermissions:(CLAuthorizationStatus)authorizationType;
- (bool)hasLocationPermissions:(CLAuthorizationStatus)authorizationType;
JSExportAs(requestLocationPermissions,
-(void)requestLocationPermissions
: (CLAuthorizationStatus)authorizationType withCallback
Expand All @@ -101,7 +101,7 @@ JSExportAs(reverseGeocoder,
BOOL trackingHeading;
BOOL trackingLocation;
BOOL trackSignificantLocationChange;
BOOL allowsBackgroundLocationUpdates;
bool allowsBackgroundLocationUpdates;
BOOL showBackgroundLocationIndicator;
JSManagedValue *authorizationCallback;
CLAuthorizationStatus requestedAuthorizationStatus;
Expand Down
24 changes: 12 additions & 12 deletions iphone/Classes/GeolocationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -625,14 +625,14 @@ - (void)setShowBackgroundLocationIndicator:(BOOL)value
DebugLog(@"[ERROR] The showBackgroundLocationIndicator property is only available on iOS 11.0+. Ignoring call ...");
}

READWRITE_IMPL(BOOL, showBackgroundLocationIndicator, ShowBackgroundLocationIndicator);
READWRITE_IMPL(bool, showBackgroundLocationIndicator, ShowBackgroundLocationIndicator);

- (BOOL)locationServicesEnabled
- (bool)locationServicesEnabled
{
return [CLLocationManager locationServicesEnabled];
}

GETTER_IMPL(BOOL, locationServicesEnabled, LocationServicesEnabled);
GETTER_IMPL(bool, locationServicesEnabled, LocationServicesEnabled);

- (CLAuthorizationStatus)locationServicesAuthorization
{
Expand All @@ -641,12 +641,12 @@ - (CLAuthorizationStatus)locationServicesAuthorization

GETTER_IMPL(CLAuthorizationStatus, locationServicesAuthorization, LocationServicesAuthorization);

- (BOOL)trackSignificantLocationChange
- (bool)trackSignificantLocationChange
{
return trackSignificantLocationChange;
}

- (void)setTrackSignificantLocationChange:(BOOL)newval
- (void)setTrackSignificantLocationChange:(bool)newval
{
if ([CLLocationManager significantLocationChangeMonitoringAvailable]) {
if (newval != trackSignificantLocationChange) {
Expand All @@ -672,7 +672,7 @@ - (void)setTrackSignificantLocationChange:(BOOL)newval
}
}

READWRITE_IMPL(BOOL, trackSignificantLocationChange, TrackSignificantLocationChange);
READWRITE_IMPL(bool, trackSignificantLocationChange, TrackSignificantLocationChange);

// Activity Type for CLlocationManager.
- (CLActivityType)activityType
Expand All @@ -694,12 +694,12 @@ - (void)setActivityType:(CLActivityType)value

// Flag to decide whether or not the app should continue to send location updates while the app is in background.

- (BOOL)pauseLocationUpdateAutomatically
- (bool)pauseLocationUpdateAutomatically
{
return pauseLocationUpdateAutomatically;
}

- (void)setPauseLocationUpdateAutomatically:(BOOL)value
- (void)setPauseLocationUpdateAutomatically:(bool)value
{
pauseLocationUpdateAutomatically = value;
TiThreadPerformOnMainThread(
Expand All @@ -709,7 +709,7 @@ - (void)setPauseLocationUpdateAutomatically:(BOOL)value
NO);
}

READWRITE_IMPL(BOOL, pauseLocationUpdateAutomatically, PauseLocationUpdateAutomatically);
READWRITE_IMPL(bool, pauseLocationUpdateAutomatically, PauseLocationUpdateAutomatically);

- (void)restart:(id)arg
{
Expand Down Expand Up @@ -766,7 +766,7 @@ - (CLLocationManager *)locationPermissionManager
return locationPermissionManager;
}

- (BOOL)hasLocationPermissions:(CLAuthorizationStatus)authorizationType
- (bool)hasLocationPermissions:(CLAuthorizationStatus)authorizationType
{
BOOL locationServicesEnabled = [CLLocationManager locationServicesEnabled];
CLAuthorizationStatus currentPermissionLevel = [CLLocationManager authorizationStatus];
Expand Down Expand Up @@ -847,9 +847,9 @@ - (void)requestLocationPermissions:(CLAuthorizationStatus)authorizationType with
}
}

READWRITE_IMPL(BOOL, allowsBackgroundLocationUpdates, AllowsBackgroundLocationUpdates);
READWRITE_IMPL(bool, allowsBackgroundLocationUpdates, AllowsBackgroundLocationUpdates);
GETTER_IMPL(NSString *, lastGeolocation, LastGeolocation);
READWRITE_IMPL(BOOL, showCalibration, ShowCalibration);
READWRITE_IMPL(bool, showCalibration, ShowCalibration);

#pragma mark Internal

Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/GestureModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
@protocol GestureExports <JSExport>

// Properties (and accessors)
READONLY_PROPERTY(BOOL, landscape, Landscape);
READONLY_PROPERTY(bool, landscape, Landscape);
READONLY_PROPERTY(NSNumber *, orientation, Orientation);
READONLY_PROPERTY(BOOL, portrait, Portrait);
READONLY_PROPERTY(bool, portrait, Portrait);

@end

Expand Down
8 changes: 4 additions & 4 deletions iphone/Classes/GestureModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ - (void)_listenerRemoved:(NSString *)type count:(int)count
}
}

- (BOOL)landscape
- (bool)landscape
{
return [TiUtils isOrientationLandscape];
}
GETTER_IMPL(BOOL, landscape, Landscape);
GETTER_IMPL(bool, landscape, Landscape);

- (BOOL)portrait
- (bool)portrait
{
return [TiUtils isOrientationPortait];
}
GETTER_IMPL(BOOL, portrait, Portrait);
GETTER_IMPL(bool, portrait, Portrait);

- (NSNumber *)orientation
{
Expand Down
10 changes: 5 additions & 5 deletions iphone/Classes/PlatformModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ READONLY_PROPERTY(NSString *, address, Address);
READONLY_PROPERTY(NSString *, architecture, Architecture);
READONLY_PROPERTY(NSNumber *, availableMemory, AvailableMemory);
READONLY_PROPERTY(NSNumber *, batteryLevel, BatteryLevel);
PROPERTY(BOOL, batteryMonitoring, BatteryMonitoring);
PROPERTY(bool, batteryMonitoring, BatteryMonitoring);
READONLY_PROPERTY(NSNumber *, batteryState, BatteryState);
READONLY_PROPERTY(TiPlatformDisplayCaps *, displayCaps, DisplayCaps);
@property (readonly) TiPlatformDisplayCaps *DisplayCaps;
READONLY_PROPERTY(NSString *, id, Id);
READONLY_PROPERTY(NSString *, identifierForAdvertising, IdentifierForAdvertising);
READONLY_PROPERTY(NSString *, identifierForVendor, IdentifierForVendor);
READONLY_PROPERTY(BOOL, isAdvertisingTrackingEnabled, IsAdvertisingTrackingEnabled);
READONLY_PROPERTY(bool, isAdvertisingTrackingEnabled, IsAdvertisingTrackingEnabled);
READONLY_PROPERTY(NSString *, locale, Locale);
READONLY_PROPERTY(NSString *, macaddress, Macaddress);
READONLY_PROPERTY(NSString *, manufacturer, Manufacturer);
Expand All @@ -51,12 +51,12 @@ READONLY_PROPERTY(NSNumber *, versionMinor, VersionMinor);
READONLY_PROPERTY(NSNumber *, versionPatch, VersionPatch);

// Methods
- (BOOL)canOpenURL:(NSString *)url;
- (bool)canOpenURL:(NSString *)url;
- (NSString *)createUUID;
- (BOOL)is24HourTimeFormat;
- (bool)is24HourTimeFormat;

JSExportAs(openURL,
-(BOOL)openURL
-(bool)openURL
: (NSString *)url withOptions
: (JSValue *)options andCallback
: (JSValue *)callback);
Expand Down
18 changes: 9 additions & 9 deletions iphone/Classes/PlatformModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ - (NSString *)identifierForVendor
GETTER_IMPL(NSString *, identifierForVendor, IdentifierForVendor);

#if defined(USE_TI_PLATFORMIDENTIFIERFORADVERTISING) || defined(USE_TI_PLATFORMGETIDENTIFIERFORADVERTISING)
- (BOOL)isAdvertisingTrackingEnabled
- (bool)isAdvertisingTrackingEnabled
{
return [[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled];
}
Expand All @@ -247,7 +247,7 @@ - (NSString *)identifierForAdvertising
return [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
}
#else
- (BOOL)isAdvertisingTrackingEnabled
- (bool)isAdvertisingTrackingEnabled
{
return NO;
}
Expand All @@ -258,7 +258,7 @@ - (NSString *)identifierForAdvertising
}
#endif

GETTER_IMPL(BOOL, isAdvertisingTrackingEnabled, IsAdvertisingTrackingEnabled);
GETTER_IMPL(bool, isAdvertisingTrackingEnabled, IsAdvertisingTrackingEnabled);
GETTER_IMPL(NSString *, identifierForAdvertising, IdentifierForAdvertising);

- (NSString *)id
Expand Down Expand Up @@ -315,7 +315,7 @@ - (NSNumber *)totalMemory
}
GETTER_IMPL(NSNumber *, availableMemory, AvailableMemory);

- (BOOL)openURL:(NSString *)url withOptions:(JSValue *)options andCallback:(JSValue *)callback
- (bool)openURL:(NSString *)url withOptions:(JSValue *)options andCallback:(JSValue *)callback
{
NSURL *newUrl = [TiUtils toURL:url proxy:self];
BOOL result = NO;
Expand Down Expand Up @@ -343,10 +343,10 @@ - (BOOL)openURL:(NSString *)url withOptions:(JSValue *)options andCallback:(JSVa
}];
}

return [NSNumber numberWithBool:result];
return result;
}

- (BOOL)canOpenURL:(NSString *)arg
- (bool)canOpenURL:(NSString *)arg
{
NSURL *url = [TiUtils toURL:arg proxy:self];
return [[UIApplication sharedApplication] canOpenURL:url];
Expand All @@ -362,7 +362,7 @@ - (TiPlatformDisplayCaps *)DisplayCaps
return [self displayCaps];
}

- (void)setBatteryMonitoring:(BOOL)yn
- (void)setBatteryMonitoring:(bool)yn
{
if (![NSThread isMainThread]) {
TiThreadPerformOnMainThread(
Expand All @@ -374,7 +374,7 @@ - (void)setBatteryMonitoring:(BOOL)yn
[[UIDevice currentDevice] setBatteryMonitoringEnabled:yn];
}

- (BOOL)batteryMonitoring
- (bool)batteryMonitoring
{
if (![NSThread isMainThread]) {
__block BOOL result = NO;
Expand All @@ -387,7 +387,7 @@ - (BOOL)batteryMonitoring
}
return [UIDevice currentDevice].batteryMonitoringEnabled;
}
READWRITE_IMPL(BOOL, batteryMonitoring, BatteryMonitoring);
READWRITE_IMPL(bool, batteryMonitoring, BatteryMonitoring);

- (NSNumber *)batteryState
{
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiCalendarAttendee.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@protocol TiCalendarAttendeeExports <JSExport>

READONLY_PROPERTY(NSString *, email, Email);
READONLY_PROPERTY(BOOL, isOrganizer, IsOrganizer);
READONLY_PROPERTY(bool, isOrganizer, IsOrganizer);
READONLY_PROPERTY(NSString *, name, Name);
READONLY_PROPERTY(EKParticipantRole, role, Role);
READONLY_PROPERTY(EKParticipantStatus, status, Status);
Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/TiCalendarAttendee.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ - (EKParticipantStatus)status
}
GETTER_IMPL(EKParticipantStatus, status, Status);

- (BOOL)isOrganizer
- (bool)isOrganizer
{
return [[self participant] isCurrentUser];
}
GETTER_IMPL(BOOL, isOrganizer, IsOrganizer);
GETTER_IMPL(bool, isOrganizer, IsOrganizer);

@end

Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiCalendarCalendar.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@protocol TiCalendarCalendarExports <JSExport>
// properties (and accessors)
READONLY_PROPERTY(BOOL, hidden, Hidden);
READONLY_PROPERTY(bool, hidden, Hidden);
READONLY_PROPERTY(NSString *, id, Id);
READONLY_PROPERTY(NSString *, name, Name);
//READONLY_PROPERTY(BOOL, selected, Selected); // not implemented on iOS
Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/TiCalendarCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ - (NSString *)id
}
GETTER_IMPL(NSString *, id, Id);

- (BOOL)hidden
- (bool)hidden
{
if (![NSThread isMainThread]) {
__block BOOL result;
Expand All @@ -193,7 +193,7 @@ - (BOOL)hidden

return [[self calendar] isImmutable];
}
GETTER_IMPL(BOOL, hidden, Hidden);
GETTER_IMPL(bool, hidden, Hidden);

- (NSString *)name
{
Expand Down
Loading

0 comments on commit 0b251e2

Please sign in to comment.