Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Apply clang-format 18
Browse files Browse the repository at this point in the history
Summary: Previously this code conformed from clang-format 12.

Reviewed By: igorsugak

Differential Revision: D56065247

fbshipit-source-id: f5a985dd8f8b84f2f9e1818b3719b43c5a1b05b3
  • Loading branch information
zertosh authored and facebook-github-bot committed Apr 14, 2024
1 parent 2a80446 commit fa4ceea
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,5 @@ id convertFollyDynamicToId(const folly::dynamic& dyn) {

return nil;
}
}
}
} // namespace cxxutils
} // namespace facebook
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -698,8 +689,11 @@ + (void)injectWillSendRequestIntoDelegateClass:(Class)cls {
struct objc_method_description methodDescription =
protocol_getMethodDescription(protocol, selector, NO, YES);

typedef NSURLRequest* (
^NSURLConnectionWillSendRequestBlock)(id<NSURLConnectionDelegate> slf, NSURLConnection* connection, NSURLRequest* request, NSURLResponse* response);
typedef NSURLRequest* (^NSURLConnectionWillSendRequestBlock)(
id<NSURLConnectionDelegate> slf,
NSURLConnection* connection,
NSURLRequest* request,
NSURLResponse* response);

NSURLConnectionWillSendRequestBlock undefinedBlock = ^NSURLRequest*(
id<NSURLConnectionDelegate> slf,
Expand All @@ -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;
};
Expand Down
6 changes: 3 additions & 3 deletions iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/SKFLEXNetworkLib/SKFLEXUtility.mm
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions xplat/FlipperTestLib/FlipperConnectionManagerMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class FlipperConnectionManagerMock : public FlipperConnectionManager {
}

void setCertificateProvider(
const std::shared_ptr<FlipperCertificateProvider> provider) override{};
const std::shared_ptr<FlipperCertificateProvider> provider) override {};

void setBackupCertificateProvider(
const std::shared_ptr<FlipperCertificateProvider> provider) override{};
const std::shared_ptr<FlipperCertificateProvider> provider) override {};

std::shared_ptr<FlipperCertificateProvider> getCertificateProvider()
override {
Expand Down

0 comments on commit fa4ceea

Please sign in to comment.