diff --git a/iOS/FlipperKit/FBCxxFollyDynamicConvert/FBCxxFollyDynamicConvert.mm b/iOS/FlipperKit/FBCxxFollyDynamicConvert/FBCxxFollyDynamicConvert.mm index f3c9324aa25..979d38c374f 100644 --- a/iOS/FlipperKit/FBCxxFollyDynamicConvert/FBCxxFollyDynamicConvert.mm +++ b/iOS/FlipperKit/FBCxxFollyDynamicConvert/FBCxxFollyDynamicConvert.mm @@ -134,5 +134,5 @@ id convertFollyDynamicToId(const folly::dynamic& dyn) { return nil; } -} -} +} // namespace cxxutils +} // namespace facebook diff --git a/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/SKFLEXNetworkLib/SKFLEXNetworkObserver.mm b/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/SKFLEXNetworkLib/SKFLEXNetworkObserver.mm index 6ce54f074f9..eeed768f6e8 100644 --- a/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/SKFLEXNetworkLib/SKFLEXNetworkObserver.mm +++ b/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/SKFLEXNetworkLib/SKFLEXNetworkObserver.mm @@ -446,51 +446,54 @@ + (void)injectIntoNSURLConnectionSynchronousClassMethod { SEL selector = @selector(sendSynchronousRequest:returningResponse:error:); SEL swizzledSelector = [SKFLEXUtility swizzledSelectorForSelector:selector]; - NSData* ( - ^syncSwizzleBlock)(Class, NSURLRequest*, NSURLResponse**, NSError**) = + NSData* (^syncSwizzleBlock)( + Class, NSURLRequest*, NSURLResponse**, NSError**) = ^NSData*( Class slf, NSURLRequest* request, NSURLResponse** response, NSError** error) { - NSData* data = nil; - NSString* requestID = [self nextRequestID]; - [[SKFLEXNetworkRecorder defaultRecorder] - recordRequestWillBeSentWithRequestID:requestID - request:request - redirectResponse:nil]; - NSString* mechanism = [self mechanismFromClassMethod:selector - onClass:className]; - [[SKFLEXNetworkRecorder defaultRecorder] recordMechanism:mechanism - forRequestID:requestID]; - NSError* temporaryError = nil; - NSURLResponse* temporaryResponse = nil; - data = - ((id(*)(id, SEL, id, NSURLResponse**, NSError**)) - objc_msgSend)(slf, swizzledSelector, request, &temporaryResponse, &temporaryError); - [[SKFLEXNetworkRecorder defaultRecorder] - recordResponseReceivedWithRequestID:requestID - response:temporaryResponse]; - [[SKFLEXNetworkRecorder defaultRecorder] - recordDataReceivedWithRequestID:requestID - dataLength:[data length]]; - if (temporaryError) { - [[SKFLEXNetworkRecorder defaultRecorder] - recordLoadingFailedWithRequestID:requestID - error:temporaryError]; - } else { - [[SKFLEXNetworkRecorder defaultRecorder] - recordLoadingFinishedWithRequestID:requestID - responseBody:data]; - } - if (error) { - *error = temporaryError; - } - if (response) { - *response = temporaryResponse; - } - return data; - }; + NSData* data = nil; + NSString* requestID = [self nextRequestID]; + [[SKFLEXNetworkRecorder defaultRecorder] + recordRequestWillBeSentWithRequestID:requestID + request:request + redirectResponse:nil]; + NSString* mechanism = [self mechanismFromClassMethod:selector + onClass:className]; + [[SKFLEXNetworkRecorder defaultRecorder] recordMechanism:mechanism + forRequestID:requestID]; + NSError* temporaryError = nil; + NSURLResponse* temporaryResponse = nil; + data = ((id(*)(id, SEL, id, NSURLResponse**, NSError**))objc_msgSend)( + slf, + swizzledSelector, + request, + &temporaryResponse, + &temporaryError); + [[SKFLEXNetworkRecorder defaultRecorder] + recordResponseReceivedWithRequestID:requestID + response:temporaryResponse]; + [[SKFLEXNetworkRecorder defaultRecorder] + recordDataReceivedWithRequestID:requestID + dataLength:[data length]]; + if (temporaryError) { + [[SKFLEXNetworkRecorder defaultRecorder] + recordLoadingFailedWithRequestID:requestID + error:temporaryError]; + } else { + [[SKFLEXNetworkRecorder defaultRecorder] + recordLoadingFinishedWithRequestID:requestID + responseBody:data]; + } + if (error) { + *error = temporaryError; + } + if (response) { + *response = temporaryResponse; + } + return data; + }; [SKFLEXUtility replaceImplementationOfKnownSelector:selector onClass:className @@ -530,36 +533,32 @@ + (void)injectIntoNSURLSessionAsyncDataAndDownloadTaskMethods { className = [[NSURLSession sharedSession] class]; } - NSURLSessionTask* ( - ^asyncDataOrDownloadSwizzleBlock)(Class, id, NSURLSessionAsyncCompletion) = + NSURLSessionTask* (^asyncDataOrDownloadSwizzleBlock)( + Class, id, NSURLSessionAsyncCompletion) = ^NSURLSessionTask*( Class slf, id argument, NSURLSessionAsyncCompletion completion) { - NSURLSessionTask* task = nil; - // If completion block was not provided sender expect to receive - // delegated methods or does not interested in callback at all. In this - // case we should just call original method implementation with nil - // completion block. - if (completion) { - NSString* requestID = [self nextRequestID]; - NSString* mechanism = [self mechanismFromClassMethod:selector - onClass:className]; - NSURLSessionAsyncCompletion completionWrapper = - [self asyncCompletionWrapperForRequestID:requestID - mechanism:mechanism - completion:completion]; - task = ((id(*)( - id, - SEL, - id, - id))objc_msgSend)(slf, swizzledSelector, argument, completionWrapper); - [self setRequestID:requestID forConnectionOrTask:task]; - } else { - task = - ((id(*)(id, SEL, id, id)) - objc_msgSend)(slf, swizzledSelector, argument, completion); - } - return task; - }; + NSURLSessionTask* task = nil; + // If completion block was not provided sender expect to receive + // delegated methods or does not interested in callback at all. In + // this case we should just call original method implementation with + // nil completion block. + if (completion) { + NSString* requestID = [self nextRequestID]; + NSString* mechanism = [self mechanismFromClassMethod:selector + onClass:className]; + NSURLSessionAsyncCompletion completionWrapper = + [self asyncCompletionWrapperForRequestID:requestID + mechanism:mechanism + completion:completion]; + task = ((id(*)(id, SEL, id, id))objc_msgSend)( + slf, swizzledSelector, argument, completionWrapper); + [self setRequestID:requestID forConnectionOrTask:task]; + } else { + task = ((id(*)(id, SEL, id, id))objc_msgSend)( + slf, swizzledSelector, argument, completion); + } + return task; + }; [SKFLEXUtility replaceImplementationOfKnownSelector:selector @@ -599,39 +598,31 @@ + (void)injectIntoNSURLSessionAsyncUploadTaskMethods { className = [[NSURLSession sharedSession] class]; } - NSURLSessionUploadTask* ( - ^asyncUploadTaskSwizzleBlock)(Class, NSURLRequest*, id, NSURLSessionAsyncCompletion) = + NSURLSessionUploadTask* (^asyncUploadTaskSwizzleBlock)( + Class, NSURLRequest*, id, NSURLSessionAsyncCompletion) = ^NSURLSessionUploadTask*( Class slf, NSURLRequest* request, id argument, NSURLSessionAsyncCompletion completion) { - NSURLSessionUploadTask* task = nil; - if (completion) { - NSString* requestID = [self nextRequestID]; - NSString* mechanism = [self mechanismFromClassMethod:selector - onClass:className]; - NSURLSessionAsyncCompletion completionWrapper = - [self asyncCompletionWrapperForRequestID:requestID - mechanism:mechanism - completion:completion]; - task = ((id(*)( - id, - SEL, - id, - id, - id))objc_msgSend)(slf, swizzledSelector, request, argument, completionWrapper); - [self setRequestID:requestID forConnectionOrTask:task]; - } else { - task = ((id(*)( - id, - SEL, - id, - id, - id))objc_msgSend)(slf, swizzledSelector, request, argument, completion); - } - return task; - }; + NSURLSessionUploadTask* task = nil; + if (completion) { + NSString* requestID = [self nextRequestID]; + NSString* mechanism = [self mechanismFromClassMethod:selector + onClass:className]; + NSURLSessionAsyncCompletion completionWrapper = + [self asyncCompletionWrapperForRequestID:requestID + mechanism:mechanism + completion:completion]; + task = ((id(*)(id, SEL, id, id, id))objc_msgSend)( + slf, swizzledSelector, request, argument, completionWrapper); + [self setRequestID:requestID forConnectionOrTask:task]; + } else { + task = ((id(*)(id, SEL, id, id, id))objc_msgSend)( + slf, swizzledSelector, request, argument, completion); + } + return task; + }; [SKFLEXUtility replaceImplementationOfKnownSelector:selector @@ -698,8 +689,11 @@ + (void)injectWillSendRequestIntoDelegateClass:(Class)cls { struct objc_method_description methodDescription = protocol_getMethodDescription(protocol, selector, NO, YES); - typedef NSURLRequest* ( - ^NSURLConnectionWillSendRequestBlock)(id slf, NSURLConnection* connection, NSURLRequest* request, NSURLResponse* response); + typedef NSURLRequest* (^NSURLConnectionWillSendRequestBlock)( + id slf, + NSURLConnection* connection, + NSURLRequest* request, + NSURLResponse* response); NSURLConnectionWillSendRequestBlock undefinedBlock = ^NSURLRequest*( id slf, @@ -725,12 +719,8 @@ + (void)injectWillSendRequestIntoDelegateClass:(Class)cls { undefinedBlock(slf, connection, request, response); } originalImplementationBlock:^{ - returnValue = ((id(*)( - id, - SEL, - id, - id, - id))objc_msgSend)(slf, swizzledSelector, connection, request, response); + returnValue = ((id(*)(id, SEL, id, id, id))objc_msgSend)( + slf, swizzledSelector, connection, request, response); }]; return returnValue; }; diff --git a/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/SKFLEXNetworkLib/SKFLEXUtility.mm b/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/SKFLEXNetworkLib/SKFLEXUtility.mm old mode 100755 new mode 100644 index c61cb5ef486..b7d3bc8bbe3 --- a/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/SKFLEXNetworkLib/SKFLEXUtility.mm +++ b/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/SKFLEXNetworkLib/SKFLEXUtility.mm @@ -120,9 +120,9 @@ + (void)replaceImplementationOfSelector:(SEL)selector return; } - IMP implementation = imp_implementationWithBlock((id)( - [cls instancesRespondToSelector:selector] ? implementationBlock - : undefinedBlock)); + IMP implementation = imp_implementationWithBlock( + (id)([cls instancesRespondToSelector:selector] ? implementationBlock + : undefinedBlock)); Method oldMethod = class_getInstanceMethod(cls, selector); if (oldMethod) { diff --git a/xplat/FlipperTestLib/FlipperConnectionManagerMock.h b/xplat/FlipperTestLib/FlipperConnectionManagerMock.h index 5dfee373748..3e4703d15ae 100644 --- a/xplat/FlipperTestLib/FlipperConnectionManagerMock.h +++ b/xplat/FlipperTestLib/FlipperConnectionManagerMock.h @@ -45,10 +45,10 @@ class FlipperConnectionManagerMock : public FlipperConnectionManager { } void setCertificateProvider( - const std::shared_ptr provider) override{}; + const std::shared_ptr provider) override {}; void setBackupCertificateProvider( - const std::shared_ptr provider) override{}; + const std::shared_ptr provider) override {}; std::shared_ptr getCertificateProvider() override {