mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-26 13:25:51 +08:00
Backout D2570057
Reviewed By: kmagiera Differential Revision: D2590341 fb-gh-sync-id: 8a6073de3ef2a6e87b785a2bb252468a37c081cf
This commit is contained in:
committed by
facebook-github-bot-9
parent
7d4f5a5c47
commit
4ac898fceb
@@ -308,9 +308,12 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void);
|
||||
|
||||
- (NSString *)moduleConfig
|
||||
{
|
||||
NSMutableArray *config = [NSMutableArray new];
|
||||
NSMutableDictionary *config = [NSMutableDictionary new];
|
||||
for (RCTModuleData *moduleData in _moduleDataByID) {
|
||||
[config addObject:moduleData.config];
|
||||
NSDictionary *moduleConfig = moduleData.config;
|
||||
if (moduleConfig) {
|
||||
config[moduleData.name] = moduleConfig;
|
||||
}
|
||||
if ([moduleData.instance conformsToProtocol:@protocol(RCTFrameUpdateObserver)]) {
|
||||
[_frameUpdateObservers addObject:moduleData];
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
@property (nonatomic, strong, readonly) Class moduleClass;
|
||||
@property (nonatomic, copy, readonly) NSString *name;
|
||||
@property (nonatomic, copy, readonly) NSArray *methods;
|
||||
@property (nonatomic, copy, readonly) NSArray *config;
|
||||
@property (nonatomic, copy, readonly) NSDictionary *config;
|
||||
|
||||
@property (nonatomic, strong) dispatch_queue_t queue;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTModuleMethod.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@implementation RCTModuleData
|
||||
{
|
||||
@@ -80,36 +79,37 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
|
||||
return _methods;
|
||||
}
|
||||
|
||||
- (NSArray *)config
|
||||
- (NSDictionary *)config
|
||||
{
|
||||
if (_constants.count == 0 && self.methods.count == 0) {
|
||||
return (id)kCFNull; // Nothing to export
|
||||
return nil; // Nothing to export
|
||||
}
|
||||
|
||||
NSMutableArray *methods = self.methods.count ? [NSMutableArray new] : nil;
|
||||
NSMutableArray *asyncMethods = nil;
|
||||
for (id<RCTBridgeMethod> method in self.methods) {
|
||||
[methods addObject:method.JSMethodName];
|
||||
NSMutableDictionary *config = [NSMutableDictionary new];
|
||||
config[@"moduleID"] = _moduleID;
|
||||
|
||||
if (_constants) {
|
||||
config[@"constants"] = _constants;
|
||||
}
|
||||
|
||||
NSMutableDictionary *methodconfig = [NSMutableDictionary new];
|
||||
[self.methods enumerateObjectsUsingBlock:^(id<RCTBridgeMethod> method, NSUInteger idx, __unused BOOL *stop) {
|
||||
if (method.functionType == RCTFunctionTypePromise) {
|
||||
if (!asyncMethods) {
|
||||
asyncMethods = [NSMutableArray new];
|
||||
}
|
||||
[asyncMethods addObject:@(methods.count)];
|
||||
methodconfig[method.JSMethodName] = @{
|
||||
@"methodID": @(idx),
|
||||
@"type": @"remoteAsync",
|
||||
};
|
||||
} else {
|
||||
methodconfig[method.JSMethodName] = @{
|
||||
@"methodID": @(idx),
|
||||
};
|
||||
}
|
||||
}];
|
||||
if (methodconfig.count) {
|
||||
config[@"methods"] = [methodconfig copy];
|
||||
}
|
||||
|
||||
NSMutableArray *config = [NSMutableArray new];
|
||||
[config addObject:_name];
|
||||
if (_constants.count) {
|
||||
[config addObject:_constants];
|
||||
}
|
||||
if (methods) {
|
||||
[config addObject:methods];
|
||||
if (asyncMethods) {
|
||||
[config addObject:asyncMethods];
|
||||
}
|
||||
}
|
||||
return config;
|
||||
return [config copy];
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)queue
|
||||
|
||||
@@ -31,6 +31,7 @@ typedef NS_ENUM(NSUInteger, RCTNullability) {
|
||||
|
||||
@property (nonatomic, readonly) Class moduleClass;
|
||||
@property (nonatomic, readonly) SEL selector;
|
||||
@property (nonatomic, readonly) RCTFunctionType functionType;
|
||||
|
||||
- (instancetype)initWithObjCMethodName:(NSString *)objCMethodName
|
||||
JSMethodName:(NSString *)JSMethodName
|
||||
|
||||
@@ -54,7 +54,6 @@ typedef BOOL (^RCTArgumentBlock)(RCTBridge *, NSUInteger, id);
|
||||
}
|
||||
|
||||
@synthesize JSMethodName = _JSMethodName;
|
||||
@synthesize functionType = _functionType;
|
||||
|
||||
static void RCTLogArgumentError(RCTModuleMethod *method, NSUInteger index,
|
||||
id valueOrType, const char *issue)
|
||||
|
||||
Reference in New Issue
Block a user