Run CLANGFORMAT on FlipperKit folder
Summary: This diff runs CLANGFORMAT lint on FlipperKit. I have added CLANGFORMAT as the lint engined for objc files in xplat/sonar. Right now the iOS folder is not formatted according to CLANGFORMAT. Ran `arc lint -a --paths-cmd "find ./iOS/FlipperKit -type f" --verbose` Reviewed By: passy Differential Revision: D19942170 fbshipit-source-id: af677323af4edb761f61f8f7e289cab743aa31f2
This commit is contained in:
committed by
Facebook Github Bot
parent
127eec5fa1
commit
ca513cf370
@@ -8,14 +8,14 @@
|
||||
#if FB_SONARKIT_ENABLED
|
||||
|
||||
#import "FlipperClient.h"
|
||||
#import "FlipperCppWrapperPlugin.h"
|
||||
#import <Flipper/FlipperClient.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#include <folly/io/async/EventBase.h>
|
||||
#include <folly/io/async/ScopedEventBaseThread.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#include "SKStateUpdateCPPWrapper.h"
|
||||
#import "FlipperClient+Testing.h"
|
||||
#import "FlipperCppWrapperPlugin.h"
|
||||
#import "SKEnvironmentVariables.h"
|
||||
#include "SKStateUpdateCPPWrapper.h"
|
||||
|
||||
#if !TARGET_OS_SIMULATOR
|
||||
#import <FKPortForwarding/FKPortForwardingServer.h>
|
||||
@@ -24,23 +24,22 @@
|
||||
using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
||||
|
||||
@implementation FlipperClient {
|
||||
facebook::flipper::FlipperClient *_cppClient;
|
||||
facebook::flipper::FlipperClient* _cppClient;
|
||||
folly::ScopedEventBaseThread sonarThread;
|
||||
folly::ScopedEventBaseThread connectionThread;
|
||||
#if !TARGET_OS_SIMULATOR
|
||||
FKPortForwardingServer *_secureServer;
|
||||
FKPortForwardingServer *_insecureServer;
|
||||
FKPortForwardingServer* _secureServer;
|
||||
FKPortForwardingServer* _insecureServer;
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (instancetype)sharedClient
|
||||
{
|
||||
static FlipperClient *sharedClient = nil;
|
||||
+ (instancetype)sharedClient {
|
||||
static FlipperClient* sharedClient = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
try {
|
||||
sharedClient = [[self alloc] init];
|
||||
} catch (const std::exception &e) {
|
||||
} catch (const std::exception& e) {
|
||||
// fail.
|
||||
sharedClient = nil;
|
||||
}
|
||||
@@ -48,46 +47,51 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
||||
return sharedClient;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
UIDevice *device = [UIDevice currentDevice];
|
||||
NSString *deviceName = [device name];
|
||||
NSBundle *bundle = [NSBundle mainBundle];
|
||||
NSString *appName = [bundle objectForInfoDictionaryKey:(NSString *)kCFBundleNameKey];
|
||||
NSString *appId = [bundle bundleIdentifier];
|
||||
NSString *privateAppDirectory = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)[0];
|
||||
UIDevice* device = [UIDevice currentDevice];
|
||||
NSString* deviceName = [device name];
|
||||
NSBundle* bundle = [NSBundle mainBundle];
|
||||
NSString* appName =
|
||||
[bundle objectForInfoDictionaryKey:(NSString*)kCFBundleNameKey];
|
||||
NSString* appId = [bundle bundleIdentifier];
|
||||
NSString* privateAppDirectory = NSSearchPathForDirectoriesInDomains(
|
||||
NSApplicationSupportDirectory, NSUserDomainMask, YES)[0];
|
||||
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
NSFileManager* manager = [NSFileManager defaultManager];
|
||||
|
||||
if ([manager fileExistsAtPath:privateAppDirectory isDirectory:NULL] == NO &&
|
||||
![manager createDirectoryAtPath:privateAppDirectory withIntermediateDirectories:YES attributes:nil error:nil]) {
|
||||
![manager createDirectoryAtPath:privateAppDirectory
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:nil]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
#if TARGET_OS_SIMULATOR
|
||||
deviceName = [NSString stringWithFormat:@"%@ %@", [[UIDevice currentDevice] model], @"Simulator"];
|
||||
deviceName = [NSString stringWithFormat:@"%@ %@",
|
||||
[[UIDevice currentDevice] model],
|
||||
@"Simulator"];
|
||||
#endif
|
||||
|
||||
static const std::string UNKNOWN = std::string("unknown");
|
||||
try {
|
||||
facebook::flipper::FlipperClient::init({
|
||||
{
|
||||
"localhost",
|
||||
"iOS",
|
||||
[deviceName UTF8String],
|
||||
UNKNOWN,
|
||||
[appName UTF8String] ?: UNKNOWN,
|
||||
[appId UTF8String] ?: UNKNOWN,
|
||||
[privateAppDirectory UTF8String],
|
||||
},
|
||||
sonarThread.getEventBase(),
|
||||
connectionThread.getEventBase(),
|
||||
[SKEnvironmentVariables getInsecurePort],
|
||||
[SKEnvironmentVariables getSecurePort]
|
||||
});
|
||||
facebook::flipper::FlipperClient::init(
|
||||
{{
|
||||
"localhost",
|
||||
"iOS",
|
||||
[deviceName UTF8String],
|
||||
UNKNOWN,
|
||||
[appName UTF8String] ?: UNKNOWN,
|
||||
[appId UTF8String] ?: UNKNOWN,
|
||||
[privateAppDirectory UTF8String],
|
||||
},
|
||||
sonarThread.getEventBase(),
|
||||
connectionThread.getEventBase(),
|
||||
[SKEnvironmentVariables getInsecurePort],
|
||||
[SKEnvironmentVariables getSecurePort]});
|
||||
_cppClient = facebook::flipper::FlipperClient::instance();
|
||||
} catch (const std::system_error &e) {
|
||||
} catch (const std::system_error& e) {
|
||||
// Probably ran out of disk space.
|
||||
return nil;
|
||||
}
|
||||
@@ -95,32 +99,27 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refreshPlugins
|
||||
{
|
||||
- (void)refreshPlugins {
|
||||
_cppClient->refreshPlugins();
|
||||
}
|
||||
|
||||
- (void)addPlugin:(NSObject<FlipperPlugin> *)plugin
|
||||
{
|
||||
- (void)addPlugin:(NSObject<FlipperPlugin>*)plugin {
|
||||
_cppClient->addPlugin(std::make_shared<WrapperPlugin>(plugin));
|
||||
}
|
||||
|
||||
- (void)removePlugin:(NSObject<FlipperPlugin> *)plugin
|
||||
{
|
||||
- (void)removePlugin:(NSObject<FlipperPlugin>*)plugin {
|
||||
_cppClient->removePlugin(std::make_shared<WrapperPlugin>(plugin));
|
||||
}
|
||||
|
||||
- (NSObject<FlipperPlugin> *)pluginWithIdentifier:(NSString *)identifier
|
||||
{
|
||||
- (NSObject<FlipperPlugin>*)pluginWithIdentifier:(NSString*)identifier {
|
||||
auto cppPlugin = _cppClient->getPlugin([identifier UTF8String]);
|
||||
if (auto wrapper = dynamic_cast<WrapperPlugin *>(cppPlugin.get())) {
|
||||
if (auto wrapper = dynamic_cast<WrapperPlugin*>(cppPlugin.get())) {
|
||||
return wrapper->getObjCPlugin();
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
- (void)start {
|
||||
#if !TARGET_OS_SIMULATOR
|
||||
_secureServer = [FKPortForwardingServer new];
|
||||
[_secureServer forwardConnectionsFromPort:8088];
|
||||
@@ -132,9 +131,7 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
||||
_cppClient->start();
|
||||
}
|
||||
|
||||
|
||||
- (void)stop
|
||||
{
|
||||
- (void)stop {
|
||||
_cppClient->stop();
|
||||
#if !TARGET_OS_SIMULATOR
|
||||
[_secureServer close];
|
||||
@@ -144,16 +141,18 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSString *)getState {
|
||||
- (NSString*)getState {
|
||||
return @(_cppClient->getState().c_str());
|
||||
}
|
||||
|
||||
- (NSArray *)getStateElements {
|
||||
NSMutableArray<NSDictionary<NSString *, NSString *>*> *const array = [NSMutableArray array];
|
||||
- (NSArray*)getStateElements {
|
||||
NSMutableArray<NSDictionary<NSString*, NSString*>*>* const array =
|
||||
[NSMutableArray array];
|
||||
|
||||
for (facebook::flipper::StateElement element: _cppClient->getStateElements()) {
|
||||
for (facebook::flipper::StateElement element :
|
||||
_cppClient->getStateElements()) {
|
||||
facebook::flipper::State state = element.state_;
|
||||
NSString *stateString;
|
||||
NSString* stateString;
|
||||
switch (state) {
|
||||
case facebook::flipper::in_progress:
|
||||
stateString = @"⏳ ";
|
||||
@@ -172,9 +171,9 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
||||
break;
|
||||
}
|
||||
[array addObject:@{
|
||||
@"name": [NSString stringWithUTF8String:element.name_.c_str()],
|
||||
@"state": stateString
|
||||
}];
|
||||
@"name" : [NSString stringWithUTF8String:element.name_.c_str()],
|
||||
@"state" : stateString
|
||||
}];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
@@ -188,11 +187,11 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
||||
|
||||
@implementation FlipperClient (Testing)
|
||||
|
||||
- (instancetype)initWithCppClient:(facebook::flipper::FlipperClient *)cppClient {
|
||||
if (self = [super init]) {
|
||||
_cppClient = cppClient;
|
||||
}
|
||||
return self;
|
||||
- (instancetype)initWithCppClient:(facebook::flipper::FlipperClient*)cppClient {
|
||||
if (self = [super init]) {
|
||||
_cppClient = cppClient;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user