Setup lint for iOS

Summary: uncrustify was not recommended to add in xplat thus I have added clangformat for xplat/sonar/iOS

Reviewed By: zertosh

Differential Revision: D19879977

fbshipit-source-id: 76f6dadf5d55a61a5342802cfde2821cbff38525
This commit is contained in:
Pritesh Nandgaonkar
2020-02-14 21:15:23 -08:00
committed by Facebook Github Bot
parent 44f5e35675
commit 35ed3ce1a4
2 changed files with 30 additions and 26 deletions

View File

@@ -11,13 +11,12 @@
#import "FlipperCppBridgingResponder.h" #import "FlipperCppBridgingResponder.h"
@implementation FlipperCppBridgingConnection @implementation FlipperCppBridgingConnection {
{
std::shared_ptr<facebook::flipper::FlipperConnection> conn_; std::shared_ptr<facebook::flipper::FlipperConnection> conn_;
} }
- (instancetype)initWithCppConnection:(std::shared_ptr<facebook::flipper::FlipperConnection>)conn - (instancetype)initWithCppConnection:
{ (std::shared_ptr<facebook::flipper::FlipperConnection>)conn {
if (self = [super init]) { if (self = [super init]) {
conn_ = conn; conn_ = conn;
} }
@@ -26,27 +25,31 @@
#pragma mark - SonarConnection #pragma mark - SonarConnection
- (void)send:(NSString *)method withParams:(NSDictionary *)params - (void)send:(NSString*)method withParams:(NSDictionary*)params {
{ conn_->send(
conn_->send([method UTF8String], facebook::cxxutils::convertIdToFollyDynamic(params, true)); [method UTF8String],
facebook::cxxutils::convertIdToFollyDynamic(params, true));
} }
- (void)receive:(NSString *)method withBlock:(SonarReceiver)receiver - (void)receive:(NSString*)method withBlock:(SonarReceiver)receiver {
{ const auto lambda =
const auto lambda = [receiver](const folly::dynamic &message, [receiver](
const folly::dynamic& message,
std::shared_ptr<facebook::flipper::FlipperResponder> responder) { std::shared_ptr<facebook::flipper::FlipperResponder> responder) {
@autoreleasepool { @autoreleasepool {
FlipperCppBridgingResponder *const objCResponder = FlipperCppBridgingResponder* const objCResponder =
[[FlipperCppBridgingResponder alloc] initWithCppResponder:responder]; [[FlipperCppBridgingResponder alloc]
receiver(facebook::cxxutils::convertFollyDynamicToId(message), objCResponder); initWithCppResponder:responder];
receiver(
facebook::cxxutils::convertFollyDynamicToId(message),
objCResponder);
} }
}; };
conn_->receive([method UTF8String], lambda); conn_->receive([method UTF8String], lambda);
} }
- (void)errorWithMessage:(NSString *)message stackTrace:(NSString *)stacktrace { - (void)errorWithMessage:(NSString*)message stackTrace:(NSString*)stacktrace {
conn_->error([message UTF8String], [stacktrace UTF8String]); conn_->error([message UTF8String], [stacktrace UTF8String]);
} }
@end @end

View File

@@ -13,24 +13,25 @@
typedef void (^SonarReceiver)(NSDictionary*, id<FlipperResponder>); typedef void (^SonarReceiver)(NSDictionary*, id<FlipperResponder>);
/** /**
Represents a connection between the Desktop and mobile plugins with corresponding identifiers. Represents a connection between the Desktop and mobile plugins with
corresponding identifiers.
*/ */
@protocol FlipperConnection @protocol FlipperConnection
/** /**
Invoke a method on the Sonar desktop plugin with with a matching identifier. Invoke a method on the Sonar desktop plugin with with a matching identifier.
*/ */
- (void)send:(NSString *)method withParams:(NSDictionary *)params; - (void)send:(NSString*)method withParams:(NSDictionary*)params;
/** /**
Register a receiver to be notified of incoming calls of the given method from the Sonar desktop Register a receiver to be notified of incoming calls of the given method from
plugin with a matching identifier. the Sonar desktop plugin with a matching identifier.
*/ */
- (void)receive:(NSString *)method withBlock:(SonarReceiver)receiver; - (void)receive:(NSString*)method withBlock:(SonarReceiver)receiver;
/** /**
Report an error to the Flipper desktop app Report an error to the Flipper desktop app
*/ */
- (void)errorWithMessage:(NSString *)message stackTrace:(NSString *)stacktrace; - (void)errorWithMessage:(NSString*)message stackTrace:(NSString*)stacktrace;
@end @end