瀏覽代碼

Lint and cleanup source files.

Nikita Lutsenko 9 年之前
父節點
當前提交
3e5be70f1b

+ 0 - 32
SocketRocket.xcodeproj/project.pbxproj

@@ -851,7 +851,6 @@
 				2D42275D1BB4358C000C1A6C /* Sources */,
 				2D42275E1BB4358C000C1A6C /* Frameworks */,
 				2D42275F1BB4358C000C1A6C /* Headers */,
-				2D4227601BB4358C000C1A6C /* Resources */,
 			);
 			buildRules = (
 			);
@@ -869,7 +868,6 @@
 				3345DC831C52ACD70083CCB8 /* Sources */,
 				3345DC851C52ACD70083CCB8 /* Frameworks */,
 				3345DC891C52ACD70083CCB8 /* Headers */,
-				3345DC8C1C52ACD70083CCB8 /* Resources */,
 			);
 			buildRules = (
 			);
@@ -887,7 +885,6 @@
 				81D647601D2CA78800690609 /* Sources */,
 				81D647721D2CA78800690609 /* Frameworks */,
 				81D647761D2CA78800690609 /* Headers */,
-				81D647891D2CA78800690609 /* Resources */,
 			);
 			buildRules = (
 			);
@@ -925,7 +922,6 @@
 				F6396B85153E67EC00345B5E /* Sources */,
 				F668C87C153E91210044DBAC /* Frameworks */,
 				F668C87D153E91210044DBAC /* Headers */,
-				F668C87E153E91210044DBAC /* Resources */,
 			);
 			buildRules = (
 			);
@@ -986,27 +982,6 @@
 /* End PBXProject section */
 
 /* Begin PBXResourcesBuildPhase section */
-		2D4227601BB4358C000C1A6C /* Resources */ = {
-			isa = PBXResourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		3345DC8C1C52ACD70083CCB8 /* Resources */ = {
-			isa = PBXResourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		81D647891D2CA78800690609 /* Resources */ = {
-			isa = PBXResourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
 		F62417E114D52F3C003CE997 /* Resources */ = {
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -1017,13 +992,6 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
-		F668C87E153E91210044DBAC /* Resources */ = {
-			isa = PBXResourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
 		F6BDA7FF145900D200FE3253 /* Resources */ = {
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;

+ 1 - 1
SocketRocket/Internal/Delegate/SRDelegateController.h

@@ -9,7 +9,7 @@
 
 #import <Foundation/Foundation.h>
 
-#import "SRWebSocket.h"
+#import <SocketRocket/SRWebSocket.h>
 
 NS_ASSUME_NONNULL_BEGIN
 

+ 1 - 1
SocketRocket/Internal/Delegate/SRDelegateController.m

@@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (nonatomic, strong, readonly) dispatch_queue_t accessQueue;
 
-@property (atomic, readwrite) SRDelegateAvailableMethods availableDelegateMethods;
+@property (atomic, assign, readwrite) SRDelegateAvailableMethods availableDelegateMethods;
 
 @end
 

+ 4 - 3
SocketRocket/Internal/Proxy/SRProxyConnect.m

@@ -8,11 +8,12 @@
 //
 
 #import "SRProxyConnect.h"
-#import "SRError.h"
+
 #import "NSRunLoop+SRWebSocket.h"
-#import "SRURLUtilities.h"
-#import "SRLog.h"
 #import "SRConstants.h"
+#import "SRError.h"
+#import "SRLog.h"
+#import "SRURLUtilities.h"
 
 @interface SRProxyConnect() <NSStreamDelegate>
 

+ 4 - 10
SocketRocket/Internal/RunLoop/SRRunLoopThread.m

@@ -12,21 +12,15 @@
 #import "SRRunLoopThread.h"
 
 @interface SRRunLoopThread ()
+{
+    dispatch_group_t _waitGroup;
+}
 
 @property (nonatomic, strong, readwrite) NSRunLoop *runLoop;
 
 @end
 
-@implementation SRRunLoopThread {
-    dispatch_group_t _waitGroup;
-}
-
-- (void)dealloc
-{
-#if !OS_OBJECT_USE_OBJC_RETAIN_RELEASE
-    dispatch_release(_waitGroup);
-#endif
-}
+@implementation SRRunLoopThread
 
 + (instancetype)sharedThread
 {

+ 0 - 1
SocketRocket/Internal/SRConstants.h

@@ -24,4 +24,3 @@ typedef NS_ENUM(NSInteger, SROpCode)
  Default buffer size that is used for reading/writing to streams.
  */
 extern size_t SRDefaultBufferSize(void);
-

+ 2 - 1
SocketRocket/Internal/Security/SRPinningSecurityPolicy.h

@@ -8,7 +8,8 @@
 //
 
 #import <Foundation/Foundation.h>
-#import "SRSecurityPolicy.h"
+
+#import <SocketRocket/SRSecurityPolicy.h>
 
 NS_ASSUME_NONNULL_BEGIN
 

+ 1 - 0
SocketRocket/Internal/Utilities/SRError.m

@@ -8,6 +8,7 @@
 //
 
 #import "SRError.h"
+
 #import "SRWebSocket.h"
 
 NS_ASSUME_NONNULL_BEGIN

+ 2 - 2
SocketRocket/NSURLRequest+SRWebSocket.h

@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
 /**
  An array of pinned `SecCertificateRef` SSL certificates that `SRWebSocket` will use for validation.
  */
-@property (nullable, nonatomic, strong, readonly) NSArray *SR_SSLPinnedCertificates;
+@property (nullable, nonatomic, copy, readonly) NSArray *SR_SSLPinnedCertificates;
 
 @end
 
@@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
 /**
  An array of pinned `SecCertificateRef` SSL certificates that `SRWebSocket` will use for validation.
  */
-@property (nullable, nonatomic, strong) NSArray *SR_SSLPinnedCertificates;
+@property (nullable, nonatomic, copy) NSArray *SR_SSLPinnedCertificates;
 
 @end
 

+ 5 - 3
SocketRocket/NSURLRequest+SRWebSocket.m

@@ -17,11 +17,13 @@ extern void import_NSURLRequest_SRWebSocket() { }
 
 NS_ASSUME_NONNULL_BEGIN
 
+static NSString *const SRSSLPinnnedCertificatesKey = @"SocketRocket_SSLPinnedCertificates";
+
 @implementation NSURLRequest (SRWebSocket)
 
 - (nullable NSArray *)SR_SSLPinnedCertificates
 {
-    return [NSURLProtocol propertyForKey:@"SR_SSLPinnedCertificates" inRequest:self];
+    return [NSURLProtocol propertyForKey:SRSSLPinnnedCertificatesKey inRequest:self];
 }
 
 @end
@@ -30,12 +32,12 @@ NS_ASSUME_NONNULL_BEGIN
 
 - (nullable NSArray *)SR_SSLPinnedCertificates
 {
-    return [NSURLProtocol propertyForKey:@"SR_SSLPinnedCertificates" inRequest:self];
+    return [NSURLProtocol propertyForKey:SRSSLPinnnedCertificatesKey inRequest:self];
 }
 
 - (void)setSR_SSLPinnedCertificates:(nullable NSArray *)SR_SSLPinnedCertificates
 {
-    [NSURLProtocol setProperty:SR_SSLPinnedCertificates forKey:@"SR_SSLPinnedCertificates" inRequest:self];
+    [NSURLProtocol setProperty:[SR_SSLPinnedCertificates copy] forKey:SRSSLPinnnedCertificatesKey inRequest:self];
 }
 
 @end

+ 5 - 5
SocketRocket/SRWebSocket.h

@@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger, SRReadyState) {
 };
 
 typedef NS_ENUM(NSInteger, SRStatusCode) {
-    // 0999: Reserved and not used.
+    // 0-999: Reserved and not used.
     SRStatusCodeNormal = 1000,
     SRStatusCodeGoingAway = 1001,
     SRStatusCodeProtocolError = 1002,
@@ -38,10 +38,10 @@ typedef NS_ENUM(NSInteger, SRStatusCode) {
     SRStatusCodeTryAgainLater = 1013,
     // 1014: Reserved for future use by the WebSocket standard.
     SRStatusCodeTLSHandshake = 1015,
-    // 10161999: Reserved for future use by the WebSocket standard.
-    // 20002999: Reserved for use by WebSocket extensions.
-    // 30003999: Available for use by libraries and frameworks. May not be used by applications. Available for registration at the IANA via first-come, first-serve.
-    // 40004999: Available for use by applications.
+    // 1016-1999: Reserved for future use by the WebSocket standard.
+    // 2000-2999: Reserved for use by WebSocket extensions.
+    // 3000-3999: Available for use by libraries and frameworks. May not be used by applications. Available for registration at the IANA via first-come, first-serve.
+    // 4000-4999: Available for use by applications.
 };
 
 @class SRWebSocket;

+ 7 - 7
SocketRocket/SRWebSocket.m

@@ -1570,28 +1570,28 @@ static inline int32_t validate_dispatch_data_partial_string(NSData *data) {
     if (codepoint == -1) {
         // Check to see if the last byte is valid or whether it was just continuing
         if (!U8_IS_LEAD(str[lastOffset]) || U8_COUNT_TRAIL_BYTES(str[lastOffset]) + lastOffset < (int32_t)size) {
-            
+
             size = -1;
         } else {
             uint8_t leadByte = str[lastOffset];
             U8_MASK_LEAD_BYTE(leadByte, U8_COUNT_TRAIL_BYTES(leadByte));
-            
+
             for (int i = lastOffset + 1; i < offset; i++) {
                 if (U8_IS_SINGLE(str[i]) || U8_IS_LEAD(str[i]) || !U8_IS_TRAIL(str[i])) {
                     size = -1;
                 }
             }
-            
+
             if (size != -1) {
                 size = lastOffset;
             }
         }
     }
-    
+
     if (size != -1 && ![[NSString alloc] initWithBytesNoCopy:(char *)[data bytes] length:size encoding:NSUTF8StringEncoding freeWhenDone:NO]) {
         size = -1;
     }
-    
+
     return size;
 }
 
@@ -1600,14 +1600,14 @@ static inline int32_t validate_dispatch_data_partial_string(NSData *data) {
 // This is a hack, and probably not optimal
 static inline int32_t validate_dispatch_data_partial_string(NSData *data) {
     static const int maxCodepointSize = 3;
-    
+
     for (int i = 0; i < maxCodepointSize; i++) {
         NSString *str = [[NSString alloc] initWithBytesNoCopy:(char *)data.bytes length:data.length - i encoding:NSUTF8StringEncoding freeWhenDone:NO];
         if (str) {
             return (int32_t)data.length - i;
         }
     }
-    
+
     return -1;
 }
 

+ 5 - 5
SocketRocket/SocketRocket.h

@@ -1,15 +1,15 @@
 //
 // Copyright 2012 Square Inc.
 // Portions Copyright (c) 2016-present, Facebook, Inc.
-// 
+//
 // All rights reserved.
-// 
+//
 // This source code is licensed under the BSD-style license found in the
-// LICENSE file in the root directory of this source tree. An additional grant 
+// LICENSE file in the root directory of this source tree. An additional grant
 // of patent rights can be found in the PATENTS file in the same directory.
 //
 
-#import <SocketRocket/SRWebSocket.h>
-#import <SocketRocket/SRSecurityPolicy.h>
 #import <SocketRocket/NSRunLoop+SRWebSocket.h>
 #import <SocketRocket/NSURLRequest+SRWebSocket.h>
+#import <SocketRocket/SRSecurityPolicy.h>
+#import <SocketRocket/SRWebSocket.h>