You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/02/28 02:29:56 UTC

[16/50] incubator-weex git commit: * [ios] call js Exception block when it fires

* [ios] call js Exception block when it fires


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/b7180000
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/b7180000
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/b7180000

Branch: refs/heads/0.11-dev
Commit: b71800003cc9429a70ad49272216c4cc0a2a7f0b
Parents: 8884844
Author: acton393 <zh...@gmail.com>
Authored: Wed Feb 22 15:12:46 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Feb 22 15:12:46 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK.xcodeproj/project.pbxproj       | 4 ----
 ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m | 9 +++------
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h   | 7 +++++++
 ios/sdk/WeexSDK/Sources/WeexSDK.h               | 1 -
 4 files changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b7180000/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
index 6330741..d042dbe 100644
--- a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
+++ b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
@@ -259,7 +259,6 @@
 		DCC77C141D770AE300CE7288 /* WXSliderNeighborComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = DCC77C121D770AE300CE7288 /* WXSliderNeighborComponent.h */; };
 		DCF087611DCAE161005CD6EB /* WXInvocationConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = DCF0875F1DCAE161005CD6EB /* WXInvocationConfig.h */; };
 		DCF087621DCAE161005CD6EB /* WXInvocationConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = DCF087601DCAE161005CD6EB /* WXInvocationConfig.m */; };
-		DCF343641E49CA1D00A2FB34 /* WXJSExceptionProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = DCF343631E49CA1D00A2FB34 /* WXJSExceptionProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		DCF343671E49CAEE00A2FB34 /* WXJSExceptionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DCF343651E49CAEE00A2FB34 /* WXJSExceptionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		DCF343681E49CAEE00A2FB34 /* WXJSExceptionInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = DCF343661E49CAEE00A2FB34 /* WXJSExceptionInfo.m */; };
 /* End PBXBuildFile section */
@@ -547,7 +546,6 @@
 		DCC77C121D770AE300CE7288 /* WXSliderNeighborComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXSliderNeighborComponent.h; sourceTree = "<group>"; };
 		DCF0875F1DCAE161005CD6EB /* WXInvocationConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXInvocationConfig.h; sourceTree = "<group>"; };
 		DCF087601DCAE161005CD6EB /* WXInvocationConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXInvocationConfig.m; sourceTree = "<group>"; };
-		DCF343631E49CA1D00A2FB34 /* WXJSExceptionProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXJSExceptionProtocol.h; sourceTree = "<group>"; };
 		DCF343651E49CAEE00A2FB34 /* WXJSExceptionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXJSExceptionInfo.h; sourceTree = "<group>"; };
 		DCF343661E49CAEE00A2FB34 /* WXJSExceptionInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXJSExceptionInfo.m; sourceTree = "<group>"; };
 /* End PBXFileReference section */
@@ -921,7 +919,6 @@
 				74A4BA841CAD453400195969 /* WXNetworkProtocol.h */,
 				59A582D31CF481110081FD3E /* WXAppMonitorProtocol.h */,
 				74EF31A91DE58AE600667A07 /* WXURLRewriteProtocol.h */,
-				DCF343631E49CA1D00A2FB34 /* WXJSExceptionProtocol.h */,
 			);
 			path = Protocol;
 			sourceTree = "<group>";
@@ -1136,7 +1133,6 @@
 				740451EA1E14BB26004157CB /* WXServiceFactory.h in Headers */,
 				744BEA591D0520F300452B5D /* WXComponent+Layout.h in Headers */,
 				74A4BA5B1CABBBD000195969 /* WXDebugTool.h in Headers */,
-				DCF343641E49CA1D00A2FB34 /* WXJSExceptionProtocol.h in Headers */,
 				2A837AB41CD9DE9200AEDF03 /* WXLoadingIndicator.h in Headers */,
 				747A787C1D1BAAC900DED9D0 /* WXComponent+ViewManagement.h in Headers */,
 				DC0F99311D48E5320087C6AF /* WeexSDK.h in Headers */,

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b7180000/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
index 9d63b1e..bf596e5 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
@@ -21,7 +21,6 @@
 #import <JavaScriptCore/JavaScriptCore.h>
 #import "WXPolyfillSet.h"
 #import "JSValue+Weex.h"
-#import "WXJSExceptionProtocol.h"
 
 #import <dlfcn.h>
 
@@ -98,12 +97,10 @@
             context.exception = exception;
             NSString *message = [NSString stringWithFormat:@"[%@:%@:%@] %@\n%@", exception[@"sourceURL"], exception[@"line"], exception[@"column"], exception, [exception[@"stack"] toObject]];
             
-            
-            id<WXJSExceptionProtocol> handler = [WXSDKEngine handlerForProtocol:@protocol(WXJSExceptionProtocol)];
-            if ([handler respondsToSelector:@selector(onJSException:)]) {
-                WXSDKInstance *instance = [WXSDKEngine topInstance];
+            WXSDKInstance *instance = [WXSDKEngine topInstance];
+            if (instance.onJSException) {
                 WXJSExceptionInfo * jsException = [[WXJSExceptionInfo alloc] initWithInstanceId:instance.instanceId bundleUrl:[instance.scriptURL absoluteString] errorCode:@"" functionName:@"" exception:[NSString stringWithFormat:@"%@\n%@",[exception toString], exception[@"stack"]] userInfo:nil];
-                [handler onJSException:jsException];
+                instance.onJSException(jsException);
             }
             WX_MONITOR_FAIL(WXMTJSBridge, WX_ERR_JS_EXECUTE, message);
         };

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b7180000/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
index 3e4b71b..2fd0b74 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
@@ -8,6 +8,7 @@
 
 #import <UIKit/UIKit.h>
 #import "WXComponent.h"
+#import "WXJSExceptionInfo.h"
 @class WXResourceRequest;
 
 extern NSString *const bundleUrlOptionKey;
@@ -89,6 +90,12 @@ typedef NS_ENUM(NSInteger, WXErrorCode) {//error.code
 @property (nonatomic, copy) void (^onCreate)(UIView *);
 
 /**
+ * The callback triggered when JSCore throws js exception during runtime
+ *  @return A block that takes a WXJSEXception argument.
+ */
+@property (nonatomic, copy) void (^onJSException)(WXJSExceptionInfo *);
+
+/**
  *  The callback triggered when the root container's frame has changed.
  *
  *  @return A block that takes a UIView argument, which is the root view

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b7180000/ios/sdk/WeexSDK/Sources/WeexSDK.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/WeexSDK.h b/ios/sdk/WeexSDK/Sources/WeexSDK.h
index fb88177..b51e99c 100644
--- a/ios/sdk/WeexSDK/Sources/WeexSDK.h
+++ b/ios/sdk/WeexSDK/Sources/WeexSDK.h
@@ -29,7 +29,6 @@
 #import "WXLog.h"
 #import "WXListComponent.h"
 #import "WXLayoutDefine.h"
-#import "WXJSExceptionProtocol.h"
 #import "WXJSExceptionInfo.h"
 #import "WXImgLoaderProtocol.h"
 #import "WXEventModuleProtocol.h"