Skip to content

Commit

Permalink
remove unnecessary ExceptionManager abstraction
Browse files Browse the repository at this point in the history
Reviewed By: sebmarkbage

Differential Revision: D8002124

fbshipit-source-id: 4e0bce9686549d0dd7b59b1323efd11ea168855b
  • Loading branch information
fkgozali authored and facebook-github-bot committed May 15, 2018
1 parent 4ef0996 commit 42fc87e
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 216 deletions.
16 changes: 10 additions & 6 deletions RNTester/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -131,7 +135,7 @@ SPEC CHECKSUMS:
DoubleConversion: e22e0762848812a87afd67ffda3998d9ef29170c
Folly: 9a8eea4725a0b6ba3256ebf206c21e352c23abf8
glog: 1de0bb937dccdc981596d3b5825ebfb765017ded
React: e3382e39c51a5e5889248e97c6b9b1b3ca443a08
React: 512b17e881b5d04d703cd292caa6f4fe12984688
yoga: bdd268c5812f00bdb52cc2b58f129797e97935eb

PODFILE CHECKSUM: 1a96172007b66aa74825c234f17139dd9c3d3cd7
Expand Down
14 changes: 0 additions & 14 deletions React.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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}"
Expand Down Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions React/Base/RCTLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
65 changes: 29 additions & 36 deletions React/Base/RCTLog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -197,41 +197,6 @@ void RCTPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix)
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();
Expand All @@ -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
Expand Down
27 changes: 0 additions & 27 deletions React/CxxExceptions/RCTCxxExceptionManager.h

This file was deleted.

31 changes: 0 additions & 31 deletions React/CxxExceptions/RCTCxxExceptionManager.mm

This file was deleted.

2 changes: 0 additions & 2 deletions React/Fabric/RCTFabricUIManagerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace facebook {
namespace react {

class FabricUIManager;
class ExceptionManager;

} // namespace react
} // namespace facebook
Expand All @@ -30,7 +29,6 @@ using namespace facebook::react;
@interface RCTFabricUIManagerWrapper : NSObject <RCTInvalidating>

- (std::shared_ptr<FabricUIManager>)manager;
- (std::shared_ptr<ExceptionManager>)exceptionManager;

@end

Expand Down
8 changes: 0 additions & 8 deletions React/Fabric/RCTFabricUIManagerWrapper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -20,15 +19,13 @@
@implementation RCTFabricUIManagerWrapper
{
std::shared_ptr<FabricUIManager> _manager;
std::shared_ptr<ExceptionManager> _exceptionManager;
std::shared_ptr<IFabricPlatformUIOperationManager> _platformUIOperationManager;
}

- (instancetype)init
{
self = [super init];
if (self) {
_exceptionManager = std::make_shared<RCTCxxExceptionManager>();
_platformUIOperationManager = std::make_shared<RCTFabricPlatformUIOperationManagerConnector>();

auto componentDescriptorRegistry = std::make_shared<ComponentDescriptorRegistry>();
Expand All @@ -45,11 +42,6 @@ - (instancetype)init
return _manager;
}

- (std::shared_ptr<ExceptionManager>)exceptionManager
{
return _exceptionManager;
}

- (void)invalidate
{
}
Expand Down
4 changes: 1 addition & 3 deletions React/Fabric/RCTSurfacePresenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import <memory>

#import <React/RCTBridge.h>
#import <React/RCTCxxExceptionManager.h>
#import <fabric/uimanager/FabricUIManager.h>

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -30,7 +29,6 @@ @interface RCTSurfacePresenter () <RCTSchedulerDelegate, RCTMountingManagerDeleg
@end

@implementation RCTSurfacePresenter {
std::shared_ptr<ExceptionManager> _exceptionManager;
RCTScheduler *_scheduler;
RCTMountingManager *_mountingManager;
RCTBridge *_bridge;
Expand All @@ -44,8 +42,6 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
_bridge = bridge;
_batchedBridge = [_bridge batchedBridge] ?: _bridge;

_exceptionManager = std::make_shared<RCTCxxExceptionManager>();

_scheduler = [[RCTScheduler alloc] init];
_scheduler.delegate = self;

Expand All @@ -57,11 +53,6 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
return self;
}

- (std::shared_ptr<ExceptionManager>)exceptionManager
{
return _exceptionManager;
}

- (void)schedulerDidComputeMutationInstructions:(facebook::react::TreeMutationInstructionList)instructions rootTag:(ReactTag)rootTag
{
[_mountingManager mutateComponentViewTreeWithMutationInstructions:instructions
Expand Down Expand Up @@ -167,11 +158,6 @@ @implementation RCTSurfacePresenter (Deprecated)
return _scheduler.uiManager_DO_NOT_USE;
}

- (std::shared_ptr<facebook::react::ExceptionManager>)exceptionManager_DO_NOT_USE
{
return _exceptionManager;
}

@end

@implementation RCTBridge (RCTSurfacePresenter)
Expand Down
Loading

0 comments on commit 42fc87e

Please sign in to comment.