mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
Added lightweight generic annotations
Summary: public Added lightweight genarics annotations to make the code more readable and help the compiler catch bugs. Fixed some type bugs and improved bridge validation in a few places. Reviewed By: javache Differential Revision: D2600189 fb-gh-sync-id: f81e22f2cdc107bf8d0b15deec6d5b83aacc5b56
This commit is contained in:
committed by
facebook-github-bot-7
parent
31565781f2
commit
c5b990f65f
@@ -17,10 +17,11 @@
|
||||
@implementation RCTModuleData
|
||||
{
|
||||
NSDictionary *_constants;
|
||||
NSArray *_methods;
|
||||
NSString *_queueName;
|
||||
}
|
||||
|
||||
@synthesize methods = _methods;
|
||||
|
||||
- (instancetype)initWithExecutor:(id<RCTJavaScriptExecutor>)javaScriptExecutor
|
||||
moduleID:(NSNumber *)moduleID
|
||||
instance:(id<RCTBridgeModule>)instance
|
||||
@@ -46,10 +47,10 @@
|
||||
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)init);
|
||||
|
||||
- (NSArray *)methods
|
||||
- (NSArray<id<RCTBridgeMethod>> *)methods
|
||||
{
|
||||
if (!_methods) {
|
||||
NSMutableArray *moduleMethods = [NSMutableArray new];
|
||||
NSMutableArray<id<RCTBridgeMethod>> *moduleMethods = [NSMutableArray new];
|
||||
|
||||
if ([_instance respondsToSelector:@selector(methodsToExport)]) {
|
||||
[moduleMethods addObjectsFromArray:[_instance methodsToExport]];
|
||||
@@ -63,11 +64,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
|
||||
SEL selector = method_getName(method);
|
||||
if ([NSStringFromSelector(selector) hasPrefix:@"__rct_export__"]) {
|
||||
IMP imp = method_getImplementation(method);
|
||||
NSArray *entries = ((NSArray *(*)(id, SEL))imp)(_moduleClass, selector);
|
||||
NSArray<NSString *> *entries =
|
||||
((NSArray<NSString *> *(*)(id, SEL))imp)(_moduleClass, selector);
|
||||
id<RCTBridgeMethod> moduleMethod =
|
||||
[[RCTModuleMethod alloc] initWithObjCMethodName:entries[1]
|
||||
JSMethodName:entries[0]
|
||||
moduleClass:_moduleClass];
|
||||
[[RCTModuleMethod alloc] initWithObjCMethodName:entries[1]
|
||||
JSMethodName:entries[0]
|
||||
moduleClass:_moduleClass];
|
||||
|
||||
[moduleMethods addObject:moduleMethod];
|
||||
}
|
||||
@@ -86,8 +88,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
|
||||
return (id)kCFNull; // Nothing to export
|
||||
}
|
||||
|
||||
NSMutableArray *methods = self.methods.count ? [NSMutableArray new] : nil;
|
||||
NSMutableArray *asyncMethods = nil;
|
||||
NSMutableArray<NSString *> *methods = self.methods.count ? [NSMutableArray new] : nil;
|
||||
NSMutableArray<NSNumber *> *asyncMethods = nil;
|
||||
for (id<RCTBridgeMethod> method in self.methods) {
|
||||
if (method.functionType == RCTFunctionTypePromise) {
|
||||
if (!asyncMethods) {
|
||||
|
||||
Reference in New Issue
Block a user