Skip to content

Commit

Permalink
Reformat (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
f2prateek committed Jun 30, 2016
1 parent 8a1acca commit 3db0093
Show file tree
Hide file tree
Showing 42 changed files with 298 additions and 291 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Carthage
# Additionally, we NEED to check it in for Carthage support.
#
# Pods/
.clang-format
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGAliasPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
context:(NSDictionary *)context
integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGAliasPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ - (instancetype)initWithNewId:(NSString *)newId
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGGroupPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
context:(NSDictionary *)context
integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGGroupPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ - (instancetype)initWithGroupId:(NSString *)groupId
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGIdentifyPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
context:(NSDictionary *)context
integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGIdentifyPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ - (instancetype)initWithUserId:(NSString *)userId
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGIntegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@
- (void)applicationWillResignActive;
- (void)applicationDidBecomeActive;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGIntegrationFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
/** The key for which this factory can create an Integration. */
- (NSString *)key;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

- (instancetype)initWithContext:(NSDictionary *)context integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ - (instancetype)initWithContext:(NSDictionary *)context integrations:(NSDictiona
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGScreenPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
context:(NSDictionary *)context
integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGScreenPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ - (instancetype)initWithName:(NSString *)name
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGTrackPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
context:(NSDictionary *)context
integrations:(NSDictionary *)integrations;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGTrackPayload.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ - (instancetype)initWithEvent:(NSString *)event
return self;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/NSData+GZIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@

- (nullable NSData *)seg_gzippedData;

@end
@end
14 changes: 7 additions & 7 deletions Analytics/Classes/Internal/NSData+GZIP.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ - (NSData *)seg_gzippedDataWithCompressionLevel:(float)level
if (self.length == 0 || [self seg_isGzippedData]) {
return self;
}

void *libz = seg_libzOpen();
int (*deflateInit2_)(z_streamp, int, int, int, int, int, const char *, int) =
(int (*)(z_streamp, int, int, int, int, int, const char *, int))dlsym(libz, "deflateInit2_");
(int (*)(z_streamp, int, int, int, int, int, const char *, int))dlsym(libz, "deflateInit2_");
int (*deflate)(z_streamp, int) = (int (*)(z_streamp, int))dlsym(libz, "deflate");
int (*deflateEnd)(z_streamp) = (int (*)(z_streamp))dlsym(libz, "deflateEnd");

z_stream stream;
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
Expand All @@ -71,9 +71,9 @@ - (NSData *)seg_gzippedDataWithCompressionLevel:(float)level
stream.next_in = (Bytef *)(void *)self.bytes;
stream.total_out = 0;
stream.avail_out = 0;

static const NSUInteger ChunkSize = 16384;

NSMutableData *output = nil;
int compression = (level < 0.0f) ? Z_DEFAULT_COMPRESSION : (int)(roundf(level * 9));
if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK) {
Expand All @@ -89,7 +89,7 @@ - (NSData *)seg_gzippedDataWithCompressionLevel:(float)level
deflateEnd(&stream);
output.length = stream.total_out;
}

return output;
}

Expand All @@ -104,4 +104,4 @@ - (BOOL)seg_isGzippedData
return (self.length >= 2 && bytes[0] == 0x1f && bytes[1] == 0x8b);
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGAnalyticsRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ typedef void (^SEGAnalyticsRequestCompletionBlock)(void);
+ (instancetype)startWithURLRequest:(NSURLRequest *)urlRequest
completion:(SEGAnalyticsRequestCompletionBlock)completion;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGAnalyticsRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ - (NSIndexSet *)acceptableStatusCodes
return _acceptableStatusCodes;
}

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGAnalyticsUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ NSDictionary *SEGCoerceDictionary(NSDictionary *dict);

NSString *SEGIDFA(void);

NSString *SEGEventNameForScreenTitle(NSString *title);
NSString *SEGEventNameForScreenTitle(NSString *title);
32 changes: 16 additions & 16 deletions Analytics/Classes/Internal/SEGAnalyticsUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
NSURL *SEGAnalyticsURLForFilename(NSString *filename)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *supportPath = [paths firstObject];
if (![[NSFileManager defaultManager] fileExistsAtPath:supportPath
isDirectory:NULL]) {
Expand Down Expand Up @@ -85,7 +85,7 @@ void SEGLog(NSString *format, ...)
{
if (!kAnalyticsLoggerShowLogs)
return;

va_list args;
va_start(args, format);
NSLogv(format, args);
Expand All @@ -103,14 +103,14 @@ static id SEGCoerceJSONObject(id obj)
[obj isKindOfClass:[NSNull class]]) {
return obj;
}

if ([obj isKindOfClass:[NSArray class]]) {
NSMutableArray *array = [NSMutableArray array];
for (id i in obj)
[array addObject:SEGCoerceJSONObject(i)];
return array;
}

if ([obj isKindOfClass:[NSDictionary class]]) {
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
for (NSString *key in obj) {
Expand All @@ -122,13 +122,13 @@ static id SEGCoerceJSONObject(id obj)
}
return dict;
}

if ([obj isKindOfClass:[NSDate class]])
return iso8601FormattedString(obj);

if ([obj isKindOfClass:[NSURL class]])
return [obj absoluteString];

// default to sending the object's description
SEGLog(@"warning: dictionary values should be valid json types. got: %@. "
@"coercing to: %@",
Expand All @@ -142,7 +142,7 @@ static void AssertDictionaryTypes(id dict)
for (id key in dict) {
assert([key isKindOfClass:[NSString class]]);
id value = dict[key];

assert([value isKindOfClass:[NSString class]] ||
[value isKindOfClass:[NSNumber class]] ||
[value isKindOfClass:[NSNull class]] ||
Expand Down Expand Up @@ -170,15 +170,15 @@ static void AssertDictionaryTypes(id dict)
if (identifierManager) {
SEL sharedManagerSelector = NSSelectorFromString(@"sharedManager");
id sharedManager =
((id (*)(id, SEL))
[identifierManager methodForSelector:sharedManagerSelector])(
identifierManager, sharedManagerSelector);
((id (*)(id, SEL))
[identifierManager methodForSelector:sharedManagerSelector])(
identifierManager, sharedManagerSelector);
SEL advertisingIdentifierSelector =
NSSelectorFromString(@"advertisingIdentifier");
NSSelectorFromString(@"advertisingIdentifier");
NSUUID *uuid =
((NSUUID * (*)(id, SEL))
[sharedManager methodForSelector:advertisingIdentifierSelector])(
sharedManager, advertisingIdentifierSelector);
((NSUUID * (*)(id, SEL))
[sharedManager methodForSelector:advertisingIdentifierSelector])(
sharedManager, advertisingIdentifierSelector);
idForAdvertiser = [uuid UUIDString];
}
return idForAdvertiser;
Expand All @@ -187,4 +187,4 @@ static void AssertDictionaryTypes(id dict)
NSString *SEGEventNameForScreenTitle(NSString *title)
{
return [[NSString alloc] initWithFormat:@"Viewed %@ Screen", title];
}
}
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGBluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
- (BOOL)hasKnownState;
- (BOOL)isEnabled;

@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGBluetooth.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ - (BOOL)isEnabled
}

- (void)centralManagerDidUpdateState:(id)central {}
@end
@end
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

- (void)startUpdatingLocation;

@end
@end
38 changes: 19 additions & 19 deletions Analytics/Classes/Internal/SEGLocation.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
#import <CoreLocation/CoreLocation.h>

#define LOCATION_STRING_PROPERTY(NAME, PLACEMARK_PROPERTY) \
-(NSString *)NAME \
{ \
__block NSString *result = nil; \
dispatch_sync(self.syncQueue, ^{ \
result = self.currentPlacemark.PLACEMARK_PROPERTY; \
}); \
return result; \
}
-(NSString *)NAME \
{ \
__block NSString *result = nil; \
dispatch_sync(self.syncQueue, ^{ \
result = self.currentPlacemark.PLACEMARK_PROPERTY; \
}); \
return result; \
}

#define LOCATION_NUMBER_PROPERTY(NAME, PLACEMARK_PROPERTY) \
-(NSNumber *)NAME \
{ \
__block NSNumber *result = nil; \
dispatch_sync(self.syncQueue, ^{ \
result = @(self.currentPlacemark.PLACEMARK_PROPERTY); \
}); \
return result; \
}
-(NSNumber *)NAME \
{ \
__block NSNumber *result = nil; \
dispatch_sync(self.syncQueue, ^{ \
result = @(self.currentPlacemark.PLACEMARK_PROPERTY); \
}); \
return result; \
}

#define LOCATION_AGE 300.0 // 5 minutes

Expand All @@ -40,7 +40,7 @@ @implementation SEGLocation
- (id)init
{
if (![CLLocationManager locationServicesEnabled]) return nil;

if (self = [super init]) {
self.geocoder = [[CLGeocoder alloc] init];
self.syncQueue = dispatch_queue_create("io.segment.location.syncQueue", NULL);
Expand Down Expand Up @@ -100,7 +100,7 @@ - (NSDictionary *)addressDictionary
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
if (!locations.count) return;

//https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html
CLLocation *location = [locations lastObject];
NSDate *eventDate = location.timestamp;
Expand Down Expand Up @@ -128,4 +128,4 @@ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *
SEGLog(@"error: %@", error);
}

@end
@end
6 changes: 3 additions & 3 deletions Analytics/Classes/Internal/SEGReachability.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
**/
#ifndef NS_ENUM
#define NS_ENUM(_type, _name) \
enum _name : _type _name; \
enum _name : _type
enum _name : _type _name; \
enum _name : _type
#endif

extern NSString *const kSEGReachabilityChangedNotification;
Expand Down Expand Up @@ -97,4 +97,4 @@ typedef void (^SEGNetworkUnreachable)(SEGReachability *reachability);
- (NSString *)currentReachabilityString;
- (NSString *)currentReachabilityFlags;

@end
@end
Loading

0 comments on commit 3db0093

Please sign in to comment.