Remove unused -[RCTBridgeMethod profileArgs]

Reviewed By: mhorowitz

Differential Revision: D3801106

fbshipit-source-id: 214a18b548f8142c0f3d6b2f7db7a24894d1f01d
This commit is contained in:
Pieter De Baets 2016-09-05 07:32:19 -07:00 committed by Facebook Github Bot 2
parent 3c1b69c1a9
commit 753b37e479
2 changed files with 27 additions and 37 deletions

View File

@ -19,7 +19,6 @@ typedef NS_ENUM(NSUInteger, RCTFunctionType) {
@protocol RCTBridgeMethod <NSObject> @protocol RCTBridgeMethod <NSObject>
@property (nonatomic, copy, readonly) NSString *JSMethodName; @property (nonatomic, copy, readonly) NSString *JSMethodName;
@property (nonatomic, copy, readonly) NSDictionary *profileArgs;
@property (nonatomic, readonly) RCTFunctionType functionType; @property (nonatomic, readonly) RCTFunctionType functionType;
- (void)invokeWithBridge:(RCTBridge *)bridge - (void)invokeWithBridge:(RCTBridge *)bridge

View File

@ -27,7 +27,7 @@ typedef BOOL (^RCTArgumentBlock)(RCTBridge *, NSUInteger, id);
nullability:(RCTNullability)nullability nullability:(RCTNullability)nullability
unused:(BOOL)unused unused:(BOOL)unused
{ {
if ((self = [super init])) { if (self = [super init]) {
_type = [type copy]; _type = [type copy];
_nullability = nullability; _nullability = nullability;
_unused = unused; _unused = unused;
@ -44,11 +44,9 @@ typedef BOOL (^RCTArgumentBlock)(RCTBridge *, NSUInteger, id);
NSArray<RCTArgumentBlock> *_argumentBlocks; NSArray<RCTArgumentBlock> *_argumentBlocks;
NSString *_methodSignature; NSString *_methodSignature;
SEL _selector; SEL _selector;
NSDictionary *_profileArgs;
} }
@synthesize JSMethodName = _JSMethodName; @synthesize JSMethodName = _JSMethodName;
@synthesize functionType = _functionType;
static void RCTLogArgumentError(RCTModuleMethod *method, NSUInteger index, static void RCTLogArgumentError(RCTModuleMethod *method, NSUInteger index,
id valueOrType, const char *issue) id valueOrType, const char *issue)
@ -157,27 +155,10 @@ SEL RCTParseMethodSignature(NSString *methodSignature, NSArray<RCTMethodArgument
JSMethodName:(NSString *)JSMethodName JSMethodName:(NSString *)JSMethodName
moduleClass:(Class)moduleClass moduleClass:(Class)moduleClass
{ {
if ((self = [super init])) { if (self = [super init]) {
_moduleClass = moduleClass; _moduleClass = moduleClass;
_methodSignature = [methodSignature copy]; _methodSignature = [methodSignature copy];
_JSMethodName = JSMethodName.length > 0 ? JSMethodName : ({ _JSMethodName = [JSMethodName copy];
NSString *methodName = methodSignature;
NSRange colonRange = [methodName rangeOfString:@":"];
if (colonRange.location != NSNotFound) {
methodName = [methodName substringToIndex:colonRange.location];
}
methodName = [methodName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
RCTAssert(methodName.length, @"%@ is not a valid JS function name, please"
" supply an alternative using RCT_REMAP_METHOD()", methodSignature);
methodName;
});
if ([_methodSignature rangeOfString:@"RCTPromise"].length) {
_functionType = RCTFunctionTypePromise;
} else {
_functionType = RCTFunctionTypeNormal;
}
} }
return self; return self;
@ -218,7 +199,6 @@ SEL RCTParseMethodSignature(NSString *methodSignature, NSArray<RCTMethodArgument
__weak RCTModuleMethod *weakSelf = self; __weak RCTModuleMethod *weakSelf = self;
void (^addBlockArgument)(void) = ^{ void (^addBlockArgument)(void) = ^{
RCT_ARG_BLOCK( RCT_ARG_BLOCK(
if (RCT_DEBUG && json && ![json isKindOfClass:[NSNumber class]]) { if (RCT_DEBUG && json && ![json isKindOfClass:[NSNumber class]]) {
RCTLogArgumentError(weakSelf, index, json, "should be a function"); RCTLogArgumentError(weakSelf, index, json, "should be a function");
return NO; return NO;
@ -424,17 +404,29 @@ SEL RCTParseMethodSignature(NSString *methodSignature, NSArray<RCTMethodArgument
return _selector; return _selector;
} }
- (NSDictionary *)profileArgs - (NSString *)JSMethodName
{ {
if (!_profileArgs) { NSString *methodName = _JSMethodName;
// This sets _selector if (methodName.length == 0) {
[self processMethodSignature]; methodName = _methodSignature;
_profileArgs = @{ NSRange colonRange = [methodName rangeOfString:@":"];
@"module": NSStringFromClass(_moduleClass), if (colonRange.location != NSNotFound) {
@"selector": NSStringFromSelector(_selector), methodName = [methodName substringToIndex:colonRange.location];
}; }
methodName = [methodName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
RCTAssert(methodName.length, @"%@ is not a valid JS function name, please"
" supply an alternative using RCT_REMAP_METHOD()", _methodSignature);
}
return methodName;
}
- (RCTFunctionType)functionType
{
if ([_methodSignature rangeOfString:@"RCTPromise"].length) {
return RCTFunctionTypePromise;
} else {
return RCTFunctionTypeNormal;
} }
return _profileArgs;
} }
- (void)invokeWithBridge:(RCTBridge *)bridge - (void)invokeWithBridge:(RCTBridge *)bridge
@ -446,7 +438,6 @@ SEL RCTParseMethodSignature(NSString *methodSignature, NSArray<RCTMethodArgument
} }
if (RCT_DEBUG) { if (RCT_DEBUG) {
// Sanity check // Sanity check
RCTAssert([module class] == _moduleClass, @"Attempted to invoke method \ RCTAssert([module class] == _moduleClass, @"Attempted to invoke method \
%@ on a module of class %@", [self methodName], [module class]); %@ on a module of class %@", [self methodName], [module class]);
@ -457,7 +448,7 @@ SEL RCTParseMethodSignature(NSString *methodSignature, NSArray<RCTMethodArgument
NSInteger expectedCount = _argumentBlocks.count; NSInteger expectedCount = _argumentBlocks.count;
// Subtract the implicit Promise resolver and rejecter functions for implementations of async functions // Subtract the implicit Promise resolver and rejecter functions for implementations of async functions
if (_functionType == RCTFunctionTypePromise) { if (self.functionType == RCTFunctionTypePromise) {
actualCount -= 2; actualCount -= 2;
expectedCount -= 2; expectedCount -= 2;
} }
@ -519,8 +510,8 @@ SEL RCTParseMethodSignature(NSString *methodSignature, NSArray<RCTMethodArgument
- (NSString *)description - (NSString *)description
{ {
return [NSString stringWithFormat:@"<%@: %p; exports %@ as %@();>", return [NSString stringWithFormat:@"<%@: %p; exports %@ as %@()>",
[self class], self, [self methodName], _JSMethodName]; [self class], self, [self methodName], self.JSMethodName];
} }
@end @end