Make RCTPerfMonitor TurboModule-compatible

Summary:
See title.

Changelog:
[iOS][Added] - Make RCTPerfMonitor TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18145947

fbshipit-source-id: df2f0d60a4924f094cc4ec311b6bf570fb9fb7e1
This commit is contained in:
Ramanpreet Nara 2019-11-01 11:54:44 -07:00 коммит произвёл Facebook Github Bot
Родитель 7233ae4f11
Коммит 809d01095e
6 изменённых файлов: 38 добавлений и 21 удалений

Просмотреть файл

@ -84,6 +84,9 @@ rn_apple_library(
) + react_module_plugin_providers(
name = "AppState",
native_class_func = "RCTAppStateCls",
) + react_module_plugin_providers(
name = "PerfMonitor",
native_class_func = "RCTPerfMonitorCls",
),
plugins_header = "FBCoreModulesPlugins.h",
preprocessor_flags = OBJC_ARC_PREPROCESSOR_FLAGS + get_debug_preprocessor_flags() + rn_extra_build_flags() + [

Просмотреть файл

@ -44,6 +44,7 @@ Class RCTTimingCls(void) __attribute__((used));
Class RCTStatusBarManagerCls(void) __attribute__((used));
Class RCTKeyboardObserverCls(void) __attribute__((used));
Class RCTAppStateCls(void) __attribute__((used));
Class RCTPerfMonitorCls(void) __attribute__((used));
#ifdef __cplusplus
}

Просмотреть файл

@ -33,6 +33,7 @@ Class RCTCoreModulesClassProvider(const char *name) {
{"StatusBarManager", RCTStatusBarManagerCls},
{"KeyboardObserver", RCTKeyboardObserverCls},
{"AppState", RCTAppStateCls},
{"PerfMonitor", RCTPerfMonitorCls},
};
auto p = sCoreModuleClassMap.find(name);

Просмотреть файл

Просмотреть файл

@ -7,7 +7,7 @@
#import "RCTFPSGraph.h"
#import "RCTAssert.h"
#import <React/RCTAssert.h>
#if RCT_DEV

Просмотреть файл

@ -5,7 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
#import "RCTDefines.h"
#import <React/RCTDefines.h>
#import "CoreModulesPlugins.h"
#if RCT_DEV
@ -13,19 +15,21 @@
#import <mach/mach.h>
#import "RCTBridge.h"
#import "RCTDevSettings.h"
#import "RCTFPSGraph.h"
#import "RCTInvalidating.h"
#import "RCTJavaScriptExecutor.h"
#import "RCTPerformanceLogger.h"
#import "RCTRootView.h"
#import "RCTUIManager.h"
#import "RCTBridge+Private.h"
#import "RCTUtils.h"
#import <React/RCTDevSettings.h>
#if __has_include("RCTDevMenu.h")
#import "RCTDevMenu.h"
#import <React/RCTBridge.h>
#import <React/RCTFPSGraph.h>
#import <React/RCTInvalidating.h>
#import <React/RCTJavaScriptExecutor.h>
#import <React/RCTPerformanceLogger.h>
#import <React/RCTRootView.h>
#import <React/RCTUIManager.h>
#import <React/RCTBridge+Private.h>
#import <React/RCTUtils.h>
#import <ReactCommon/RCTTurboModule.h>
#if __has_include(<React/RCTDevMenu.h>)
#import <React/RCTDevMenu.h>
#endif
static NSString *const RCTPerfMonitorCellIdentifier = @"RCTPerfMonitorCellIdentifier";
@ -46,7 +50,7 @@ static BOOL RCTJSCSetOption(const char *option)
*
* JSC::Options::setOptions - JavaScriptCore/runtime/Options.h
*/
setOption = dlsym(RTLD_DEFAULT, "_ZN3JSC7Options9setOptionEPKc");
setOption = reinterpret_cast<RCTJSCSetOptionType>(dlsym(RTLD_DEFAULT, "_ZN3JSC7Options9setOptionEPKc"));
if (RCT_DEBUG && setOption == NULL) {
RCTLogWarn(@"The symbol used to enable JSC runtime options is not available in this iOS version");
@ -72,9 +76,9 @@ static vm_size_t RCTGetResidentMemorySize(void)
return memoryUsageInByte;
}
@interface RCTPerfMonitor : NSObject <RCTBridgeModule, RCTInvalidating, UITableViewDataSource, UITableViewDelegate>
@interface RCTPerfMonitor : NSObject <RCTBridgeModule, RCTTurboModule, RCTInvalidating, UITableViewDataSource, UITableViewDelegate>
#if __has_include("RCTDevMenu.h")
#if __has_include(<React/RCTDevMenu.h>)
@property (nonatomic, strong, readonly) RCTDevMenuItem *devMenuItem;
#endif
@property (nonatomic, strong, readonly) UIPanGestureRecognizer *gestureRecognizer;
@ -91,7 +95,7 @@ static vm_size_t RCTGetResidentMemorySize(void)
@end
@implementation RCTPerfMonitor {
#if __has_include("RCTDevMenu.h")
#if __has_include(<React/RCTDevMenu.h>)
RCTDevMenuItem *_devMenuItem;
#endif
UIPanGestureRecognizer *_gestureRecognizer;
@ -140,7 +144,7 @@ RCT_EXPORT_MODULE()
{
_bridge = bridge;
#if __has_include("RCTDevMenu.h")
#if __has_include(<React/RCTDevMenu.h>)
[_bridge.devMenu addItem:self.devMenuItem];
#endif
}
@ -150,7 +154,7 @@ RCT_EXPORT_MODULE()
[self hide];
}
#if __has_include("RCTDevMenu.h")
#if __has_include(<React/RCTDevMenu.h>)
- (RCTDevMenuItem *)devMenuItem
{
if (!_devMenuItem) {
@ -576,3 +580,11 @@ heightForRowAtIndexPath:(__unused NSIndexPath *)indexPath
@end
#endif
Class RCTPerfMonitorCls(void) {
#if RCT_DEV
return RCTPerfMonitor.class;
#else
return nil;
#endif
}