remove unnecessary ExceptionManager abstraction
Reviewed By: sebmarkbage Differential Revision: D8002124 fbshipit-source-id: 4e0bce9686549d0dd7b59b1323efd11ea168855b
This commit is contained in:
parent
4ef099679d
commit
42fc87eb8d
|
@ -14,9 +14,6 @@ PODS:
|
|||
- Folly (= 2016.10.31.00)
|
||||
- React/Core
|
||||
- React/cxxreact
|
||||
- React/CxxExceptions (1000.0.0):
|
||||
- React/CxxBridge
|
||||
- React/exceptions
|
||||
- React/cxxreact (1000.0.0):
|
||||
- boost-for-react-native (= 1.63.0)
|
||||
- Folly (= 2016.10.31.00)
|
||||
|
@ -25,19 +22,27 @@ PODS:
|
|||
- React/DevSupport (1000.0.0):
|
||||
- React/Core
|
||||
- React/RCTWebSocket
|
||||
- React/exceptions (1000.0.0)
|
||||
- React/fabric (1000.0.0):
|
||||
- React/fabric/attributedstring (= 1000.0.0)
|
||||
- React/fabric/core (= 1000.0.0)
|
||||
- React/fabric/debug (= 1000.0.0)
|
||||
- React/fabric/graphics (= 1000.0.0)
|
||||
- React/fabric/text (= 1000.0.0)
|
||||
- React/fabric/textlayoutmanager (= 1000.0.0)
|
||||
- React/fabric/uimanager (= 1000.0.0)
|
||||
- React/fabric/view (= 1000.0.0)
|
||||
- React/fabric/attributedstring (1000.0.0):
|
||||
- Folly (= 2016.10.31.00)
|
||||
- React/fabric/core (1000.0.0):
|
||||
- Folly (= 2016.10.31.00)
|
||||
- React/fabric/debug (1000.0.0):
|
||||
- Folly (= 2016.10.31.00)
|
||||
- React/fabric/graphics (1000.0.0):
|
||||
- Folly (= 2016.10.31.00)
|
||||
- React/fabric/text (1000.0.0):
|
||||
- Folly (= 2016.10.31.00)
|
||||
- React/fabric/textlayoutmanager (1000.0.0):
|
||||
- Folly (= 2016.10.31.00)
|
||||
- React/fabric/uimanager (1000.0.0):
|
||||
- Folly (= 2016.10.31.00)
|
||||
- React/fabric/view (1000.0.0):
|
||||
|
@ -61,7 +66,6 @@ PODS:
|
|||
- React/RCTFabric (1000.0.0):
|
||||
- Folly (= 2016.10.31.00)
|
||||
- React/Core
|
||||
- React/CxxExceptions
|
||||
- React/fabric
|
||||
- React/RCTGeolocation (1000.0.0):
|
||||
- React/Core
|
||||
|
@ -131,7 +135,7 @@ SPEC CHECKSUMS:
|
|||
DoubleConversion: e22e0762848812a87afd67ffda3998d9ef29170c
|
||||
Folly: 9a8eea4725a0b6ba3256ebf206c21e352c23abf8
|
||||
glog: 1de0bb937dccdc981596d3b5825ebfb765017ded
|
||||
React: e3382e39c51a5e5889248e97c6b9b1b3ca443a08
|
||||
React: 512b17e881b5d04d703cd292caa6f4fe12984688
|
||||
yoga: bdd268c5812f00bdb52cc2b58f129797e97935eb
|
||||
|
||||
PODFILE CHECKSUM: 1a96172007b66aa74825c234f17139dd9c3d3cd7
|
||||
|
|
|
@ -74,13 +74,6 @@ Pod::Spec.new do |s|
|
|||
ss.compiler_flags = folly_compiler_flags
|
||||
ss.private_header_files = "React/Cxx*/*.h"
|
||||
ss.source_files = "React/Cxx*/*.{h,m,mm}"
|
||||
ss.exclude_files = "React/CxxExceptions/**/*"
|
||||
end
|
||||
|
||||
s.subspec "CxxExceptions" do |ss|
|
||||
ss.dependency "React/CxxBridge"
|
||||
ss.dependency "React/exceptions"
|
||||
ss.source_files = "React/CxxExceptions/*.{h,m,mm}"
|
||||
end
|
||||
|
||||
s.subspec "DevSupport" do |ss|
|
||||
|
@ -93,7 +86,6 @@ Pod::Spec.new do |s|
|
|||
s.subspec "RCTFabric" do |ss|
|
||||
ss.dependency "Folly", folly_version
|
||||
ss.dependency "React/Core"
|
||||
ss.dependency "React/CxxExceptions"
|
||||
ss.dependency "React/fabric"
|
||||
ss.compiler_flags = folly_compiler_flags
|
||||
ss.source_files = "React/Fabric/**/*.{c,h,m,mm,S,cpp}"
|
||||
|
@ -142,12 +134,6 @@ Pod::Spec.new do |s|
|
|||
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Folly\"" }
|
||||
end
|
||||
|
||||
s.subspec "exceptions" do |ss|
|
||||
ss.source_files = "ReactCommon/exceptions/*.{cpp,h}"
|
||||
ss.header_dir = "cxxreact"
|
||||
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"" }
|
||||
end
|
||||
|
||||
s.subspec "fabric" do |ss|
|
||||
ss.subspec "attributedstring" do |sss|
|
||||
sss.dependency "Folly", folly_version
|
||||
|
|
|
@ -120,13 +120,6 @@ RCT_EXTERN void RCTPerformBlockWithLogFunction(void (^block)(void), RCTLogFuncti
|
|||
*/
|
||||
RCT_EXTERN void RCTPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix);
|
||||
|
||||
/**
|
||||
* This method computes the current call stack, useful for error reporting.
|
||||
*/
|
||||
RCT_EXTERN NSArray<NSDictionary *> *RCTGetCallStack(const char *fileName, int lineNumber);
|
||||
|
||||
#define RCT_CALLSTACK RCTGetCallStack(__FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
* Private logging function - ignore this.
|
||||
*/
|
||||
|
|
|
@ -197,41 +197,6 @@ static NSRegularExpression *nativeStackFrameRegex()
|
|||
return _regex;
|
||||
}
|
||||
|
||||
NSArray<NSDictionary *>* RCTGetCallStack(const char *fileName, int lineNumber)
|
||||
{
|
||||
NSArray<NSString *> *stackSymbols = [NSThread callStackSymbols];
|
||||
NSMutableArray<NSDictionary *> *stack =
|
||||
[NSMutableArray arrayWithCapacity:(stackSymbols.count - 1)];
|
||||
[stackSymbols enumerateObjectsUsingBlock:^(NSString *frameSymbols, NSUInteger idx, __unused BOOL *stop) {
|
||||
if (idx == 0) {
|
||||
// don't include the current frame
|
||||
return;
|
||||
}
|
||||
|
||||
NSRange range = NSMakeRange(0, frameSymbols.length);
|
||||
NSTextCheckingResult *match = [nativeStackFrameRegex() firstMatchInString:frameSymbols options:0 range:range];
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *methodName = [frameSymbols substringWithRange:[match rangeAtIndex:1]];
|
||||
char *demangledName = abi::__cxa_demangle([methodName UTF8String], NULL, NULL, NULL);
|
||||
if (demangledName) {
|
||||
methodName = @(demangledName);
|
||||
free(demangledName);
|
||||
}
|
||||
|
||||
if (idx == 1 && fileName) {
|
||||
NSString *file = [@(fileName) componentsSeparatedByString:@"/"].lastObject;
|
||||
[stack addObject:@{@"methodName": methodName, @"file": file, @"lineNumber": @(lineNumber)}];
|
||||
} else {
|
||||
[stack addObject:@{@"methodName": methodName}];
|
||||
}
|
||||
}];
|
||||
|
||||
return [stack copy];
|
||||
}
|
||||
|
||||
void _RCTLogNativeInternal(RCTLogLevel level, const char *fileName, int lineNumber, NSString *format, ...)
|
||||
{
|
||||
RCTLogFunction logFunction = RCTGetLocalLogFunction();
|
||||
|
@ -252,7 +217,35 @@ void _RCTLogNativeInternal(RCTLogLevel level, const char *fileName, int lineNumb
|
|||
|
||||
// Log to red box in debug mode.
|
||||
if (RCTSharedApplication() && level >= RCTLOG_REDBOX_LEVEL) {
|
||||
NSArray<NSDictionary *> *stack = RCT_CALLSTACK;
|
||||
NSArray<NSString *> *stackSymbols = [NSThread callStackSymbols];
|
||||
NSMutableArray<NSDictionary *> *stack =
|
||||
[NSMutableArray arrayWithCapacity:(stackSymbols.count - 1)];
|
||||
[stackSymbols enumerateObjectsUsingBlock:^(NSString *frameSymbols, NSUInteger idx, __unused BOOL *stop) {
|
||||
if (idx == 0) {
|
||||
// don't include the current frame
|
||||
return;
|
||||
}
|
||||
|
||||
NSRange range = NSMakeRange(0, frameSymbols.length);
|
||||
NSTextCheckingResult *match = [nativeStackFrameRegex() firstMatchInString:frameSymbols options:0 range:range];
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *methodName = [frameSymbols substringWithRange:[match rangeAtIndex:1]];
|
||||
char *demangledName = abi::__cxa_demangle([methodName UTF8String], NULL, NULL, NULL);
|
||||
if (demangledName) {
|
||||
methodName = @(demangledName);
|
||||
free(demangledName);
|
||||
}
|
||||
|
||||
if (idx == 1 && fileName) {
|
||||
NSString *file = [@(fileName) componentsSeparatedByString:@"/"].lastObject;
|
||||
[stack addObject:@{@"methodName": methodName, @"file": file, @"lineNumber": @(lineNumber)}];
|
||||
} else {
|
||||
[stack addObject:@{@"methodName": methodName}];
|
||||
}
|
||||
}];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// red box is thread safe, but by deferring to main queue we avoid a startup
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cxxreact/ExceptionManager.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
/**
|
||||
* Connector class (from C++ to ObjC++) to allow FabricUIManager to invoke native UI operations/updates.
|
||||
* UIKit-related impl doesn't live here, but this class gets passed to the FabricUIManager C++ impl directly.
|
||||
*/
|
||||
class RCTCxxExceptionManager : public ExceptionManager {
|
||||
public:
|
||||
|
||||
virtual void handleSoftException(const std::exception& e) const override;
|
||||
virtual void handleFatalException(const std::exception& e) const override;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
|
@ -1,31 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTCxxExceptionManager.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTBridge+Private.h>
|
||||
#import <React/RCTExceptionsManager.h>
|
||||
#import <React/RCTLog.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
void RCTCxxExceptionManager::handleSoftException(const std::exception& e) const {
|
||||
RCTExceptionsManager *manager = [[RCTBridge currentBridge] moduleForClass:[RCTExceptionsManager class]];
|
||||
[manager reportSoftException:[NSString stringWithUTF8String:e.what()] stack:RCT_CALLSTACK exceptionId:@0];
|
||||
}
|
||||
|
||||
void RCTCxxExceptionManager::handleFatalException(const std::exception& e) const {
|
||||
RCTExceptionsManager *manager = [[RCTBridge currentBridge] moduleForClass:[RCTExceptionsManager class]];
|
||||
[manager reportFatalException:[NSString stringWithUTF8String:e.what()] stack:RCT_CALLSTACK exceptionId:@0];
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
|
@ -17,7 +17,6 @@ namespace facebook {
|
|||
namespace react {
|
||||
|
||||
class FabricUIManager;
|
||||
class ExceptionManager;
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
@ -30,7 +29,6 @@ using namespace facebook::react;
|
|||
@interface RCTFabricUIManagerWrapper : NSObject <RCTInvalidating>
|
||||
|
||||
- (std::shared_ptr<FabricUIManager>)manager;
|
||||
- (std::shared_ptr<ExceptionManager>)exceptionManager;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#import "RCTFabricUIManagerWrapper.h"
|
||||
|
||||
#include <React/RCTCxxExceptionManager.h>
|
||||
#include <fabric/uimanager/ComponentDescriptorRegistry.h>
|
||||
#include <fabric/uimanager/FabricUIManager.h>
|
||||
#include <fabric/view/ViewComponentDescriptor.h>
|
||||
|
@ -20,7 +19,6 @@
|
|||
@implementation RCTFabricUIManagerWrapper
|
||||
{
|
||||
std::shared_ptr<FabricUIManager> _manager;
|
||||
std::shared_ptr<ExceptionManager> _exceptionManager;
|
||||
std::shared_ptr<IFabricPlatformUIOperationManager> _platformUIOperationManager;
|
||||
}
|
||||
|
||||
|
@ -28,7 +26,6 @@
|
|||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_exceptionManager = std::make_shared<RCTCxxExceptionManager>();
|
||||
_platformUIOperationManager = std::make_shared<RCTFabricPlatformUIOperationManagerConnector>();
|
||||
|
||||
auto componentDescriptorRegistry = std::make_shared<ComponentDescriptorRegistry>();
|
||||
|
@ -45,11 +42,6 @@
|
|||
return _manager;
|
||||
}
|
||||
|
||||
- (std::shared_ptr<ExceptionManager>)exceptionManager
|
||||
{
|
||||
return _exceptionManager;
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#import <memory>
|
||||
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTCxxExceptionManager.h>
|
||||
#import <fabric/uimanager/FabricUIManager.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
@ -56,10 +55,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@interface RCTSurfacePresenter (Deprecated)
|
||||
|
||||
/**
|
||||
* We need to expose `exceptionManager` and `uiManager` for registration
|
||||
* We need to expose `uiManager` for registration
|
||||
* purposes. Eventually, we will move this down to C++ side.
|
||||
*/
|
||||
- (std::shared_ptr<facebook::react::ExceptionManager>)exceptionManager_DO_NOT_USE;
|
||||
- (std::shared_ptr<facebook::react::FabricUIManager>)uiManager_DO_NOT_USE;
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#import "RCTSurfacePresenter.h"
|
||||
|
||||
#import <React/RCTAssert.h>
|
||||
#import <React/RCTCxxExceptionManager.h>
|
||||
#import <React/RCTScheduler.h>
|
||||
#import <React/RCTMountingManager.h>
|
||||
#import <React/RCTFabricSurface.h>
|
||||
|
@ -30,7 +29,6 @@ using namespace facebook::react;
|
|||
@end
|
||||
|
||||
@implementation RCTSurfacePresenter {
|
||||
std::shared_ptr<ExceptionManager> _exceptionManager;
|
||||
RCTScheduler *_scheduler;
|
||||
RCTMountingManager *_mountingManager;
|
||||
RCTBridge *_bridge;
|
||||
|
@ -44,8 +42,6 @@ using namespace facebook::react;
|
|||
_bridge = bridge;
|
||||
_batchedBridge = [_bridge batchedBridge] ?: _bridge;
|
||||
|
||||
_exceptionManager = std::make_shared<RCTCxxExceptionManager>();
|
||||
|
||||
_scheduler = [[RCTScheduler alloc] init];
|
||||
_scheduler.delegate = self;
|
||||
|
||||
|
@ -57,11 +53,6 @@ using namespace facebook::react;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (std::shared_ptr<ExceptionManager>)exceptionManager
|
||||
{
|
||||
return _exceptionManager;
|
||||
}
|
||||
|
||||
- (void)schedulerDidComputeMutationInstructions:(facebook::react::TreeMutationInstructionList)instructions rootTag:(ReactTag)rootTag
|
||||
{
|
||||
[_mountingManager mutateComponentViewTreeWithMutationInstructions:instructions
|
||||
|
@ -167,11 +158,6 @@ using namespace facebook::react;
|
|||
return _scheduler.uiManager_DO_NOT_USE;
|
||||
}
|
||||
|
||||
- (std::shared_ptr<facebook::react::ExceptionManager>)exceptionManager_DO_NOT_USE
|
||||
{
|
||||
return _exceptionManager;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTBridge (RCTSurfacePresenter)
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
load("//configurations/buck/apple:flag_defs.bzl", "get_debug_preprocessor_flags")
|
||||
load("//ReactNative:DEFS.bzl", "IS_OSS_BUILD", "react_native_xplat_target", "rn_xplat_cxx_library", "get_apple_inspector_flags")
|
||||
|
||||
APPLE_COMPILER_FLAGS = []
|
||||
|
||||
if not IS_OSS_BUILD:
|
||||
load("@xplat//configurations/buck/apple:flag_defs.bzl", "get_static_library_ios_flags", "flags")
|
||||
APPLE_COMPILER_FLAGS = flags.get_flag_value(get_static_library_ios_flags(), 'compiler_flags')
|
||||
|
||||
rn_xplat_cxx_library(
|
||||
name = "exceptions",
|
||||
srcs = glob(["*.cpp"]),
|
||||
header_namespace = "",
|
||||
exported_headers = subdir_glob(
|
||||
[
|
||||
("", "*.h"),
|
||||
],
|
||||
prefix = "cxxreact",
|
||||
),
|
||||
compiler_flags = [
|
||||
"-fexceptions",
|
||||
"-frtti",
|
||||
"-std=c++14",
|
||||
"-Wall",
|
||||
],
|
||||
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
|
||||
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
|
||||
force_static = True,
|
||||
preprocessor_flags = [
|
||||
"-DLOG_TAG=\"ReactNative\"",
|
||||
"-DWITH_FBSYSTRACE=1",
|
||||
],
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
deps = [
|
||||
"xplat//fbsystrace:fbsystrace",
|
||||
"xplat//third-party/glog:glog",
|
||||
],
|
||||
)
|
|
@ -1,28 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <exception>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
/**
|
||||
* An abstract class for C++-based exception handling that differentiates
|
||||
* soft exceptions from fatal exceptions.
|
||||
*/
|
||||
class ExceptionManager {
|
||||
public:
|
||||
virtual ~ExceptionManager() = default;
|
||||
|
||||
virtual void handleSoftException(const std::exception &e) const = 0;
|
||||
virtual void handleFatalException(const std::exception &e) const = 0;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
Loading…
Reference in New Issue