You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2017/03/02 10:23:33 UTC

[1/2] incubator-weex git commit: * [ios]add jsexception protocol

Repository: incubator-weex
Updated Branches:
  refs/heads/0.11-dev de8c25d9a -> 4a80026f8


* [ios]add jsexception protocol


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

Branch: refs/heads/0.11-dev
Commit: c7cb5ad757d1f27808c15946656034d68baa34db
Parents: de8c25d
Author: acton393 <zh...@gmail.com>
Authored: Thu Mar 2 18:15:27 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Mar 2 18:15:27 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK.xcodeproj/project.pbxproj       |  4 ++++
 ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m |  8 +++++---
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h   |  6 ------
 .../Sources/Protocol/WXJSExceptionProtocol.h    | 21 ++++++++++++++++++++
 ios/sdk/WeexSDK/Sources/WeexSDK.h               |  1 +
 5 files changed, 31 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c7cb5ad7/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
index add0ddd..3b97234 100644
--- a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
+++ b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
@@ -263,6 +263,7 @@
 		DCAB35FF1D658EB700C0EA70 /* WXRuleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DCAB35FD1D658EB700C0EA70 /* WXRuleManager.m */; };
 		DCC77C131D770AE300CE7288 /* WXSliderNeighborComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = DCC77C111D770AE300CE7288 /* WXSliderNeighborComponent.m */; };
 		DCC77C141D770AE300CE7288 /* WXSliderNeighborComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = DCC77C121D770AE300CE7288 /* WXSliderNeighborComponent.h */; };
+		DCDFED011E68238F00C228D7 /* WXJSExceptionProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = DCDFED001E68238F00C228D7 /* WXJSExceptionProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		DCF087611DCAE161005CD6EB /* WXInvocationConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = DCF0875F1DCAE161005CD6EB /* WXInvocationConfig.h */; };
 		DCF087621DCAE161005CD6EB /* WXInvocationConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = DCF087601DCAE161005CD6EB /* WXInvocationConfig.m */; };
 		DCF343671E49CAEE00A2FB34 /* WXJSExceptionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DCF343651E49CAEE00A2FB34 /* WXJSExceptionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -556,6 +557,7 @@
 		DCAB35FD1D658EB700C0EA70 /* WXRuleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXRuleManager.m; sourceTree = "<group>"; };
 		DCC77C111D770AE300CE7288 /* WXSliderNeighborComponent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXSliderNeighborComponent.m; sourceTree = "<group>"; };
 		DCC77C121D770AE300CE7288 /* WXSliderNeighborComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXSliderNeighborComponent.h; sourceTree = "<group>"; };
+		DCDFED001E68238F00C228D7 /* WXJSExceptionProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXJSExceptionProtocol.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>"; };
 		DCF343651E49CAEE00A2FB34 /* WXJSExceptionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXJSExceptionInfo.h; sourceTree = "<group>"; };
@@ -926,6 +928,7 @@
 			isa = PBXGroup;
 			children = (
 				59A596171CB630E50012CD52 /* WXNavigationProtocol.h */,
+				DCDFED001E68238F00C228D7 /* WXJSExceptionProtocol.h */,
 				2AE5B7551CABA04E0082FDDB /* WXEventModuleProtocol.h */,
 				2A4445BE1CA8FD56009E7C6D /* WXTextComponentProtocol.h */,
 				775BEE701C1BD977008D1629 /* WXModuleProtocol.h */,
@@ -1231,6 +1234,7 @@
 				74B8BEFE1DC47B72004A6027 /* WXRootView.h in Headers */,
 				77E65A111C155EA8008B8775 /* WXImageComponent.h in Headers */,
 				2A60CE9C1C91733E00857B9F /* WXSwitchComponent.h in Headers */,
+				DCDFED011E68238F00C228D7 /* WXJSExceptionProtocol.h in Headers */,
 				2A4445BF1CA8FD56009E7C6D /* WXTextComponentProtocol.h in Headers */,
 				746319021C60AFC100EFEBD4 /* WXThreadSafeCounter.h in Headers */,
 				77D1613C1C02DEA60010B15B /* WXJSCoreBridge.h in Headers */,

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c7cb5ad7/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 bf596e5..f9b4cac 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
@@ -21,6 +21,7 @@
 #import <JavaScriptCore/JavaScriptCore.h>
 #import "WXPolyfillSet.h"
 #import "JSValue+Weex.h"
+#import "WXJSExceptionProtocol.h"
 
 #import <dlfcn.h>
 
@@ -96,11 +97,12 @@
         _jsContext.exceptionHandler = ^(JSContext *context, JSValue *exception){
             context.exception = exception;
             NSString *message = [NSString stringWithFormat:@"[%@:%@:%@] %@\n%@", exception[@"sourceURL"], exception[@"line"], exception[@"column"], exception, [exception[@"stack"] toObject]];
+            id<WXJSExceptionProtocol> jsExceptionHandler = [WXHandlerFactory handlerForProtocol:@protocol(WXJSExceptionProtocol)];
             
             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];
-                instance.onJSException(jsException);
+            if ([jsExceptionHandler respondsToSelector:@selector(onJSException:)]) {
+                WXJSExceptionInfo * jsExceptionInfo = [[WXJSExceptionInfo alloc] initWithInstanceId:instance.instanceId bundleUrl:[instance.scriptURL absoluteString] errorCode:@"" functionName:@"" exception:[NSString stringWithFormat:@"%@\n%@",[exception toString], exception[@"stack"]] userInfo:nil];
+                [jsExceptionHandler onJSException:jsExceptionInfo];
             }
             WX_MONITOR_FAIL(WXMTJSBridge, WX_ERR_JS_EXECUTE, message);
         };

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c7cb5ad7/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 2fd0b74..962838e 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
@@ -90,12 +90,6 @@ 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/c7cb5ad7/ios/sdk/WeexSDK/Sources/Protocol/WXJSExceptionProtocol.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Protocol/WXJSExceptionProtocol.h b/ios/sdk/WeexSDK/Sources/Protocol/WXJSExceptionProtocol.h
new file mode 100644
index 0000000..36fa523
--- /dev/null
+++ b/ios/sdk/WeexSDK/Sources/Protocol/WXJSExceptionProtocol.h
@@ -0,0 +1,21 @@
+/**
+ * Created by Weex.
+ * Copyright (c) 2016, Alibaba, Inc. All rights reserved.
+ *
+ * This source code is licensed under the Apache Licence 2.0.
+ * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree.
+ */
+
+#import "WXJSExceptionInfo.h"
+
+@protocol WXJSExceptionProtocol <NSObject>
+
+/**
+ * report js exception
+ *
+ * @param exception WXJSExceptionInfo
+ */
+
+- (void)onJSException:(WXJSExceptionInfo*) exception;
+
+@end

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


[2/2] incubator-weex git commit: * [ios] remove unused

Posted by cx...@apache.org.
* [ios] remove unused


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

Branch: refs/heads/0.11-dev
Commit: 4a80026f8d33a04da66acb3f7f4e27890285a32e
Parents: c7cb5ad
Author: acton393 <zh...@gmail.com>
Authored: Thu Mar 2 18:15:57 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Mar 2 18:15:57 2017 +0800

----------------------------------------------------------------------
 ios/playground/WeexDemo/WXDemoViewController.m | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4a80026f/ios/playground/WeexDemo/WXDemoViewController.m
----------------------------------------------------------------------
diff --git a/ios/playground/WeexDemo/WXDemoViewController.m b/ios/playground/WeexDemo/WXDemoViewController.m
index 038a478..d354078 100644
--- a/ios/playground/WeexDemo/WXDemoViewController.m
+++ b/ios/playground/WeexDemo/WXDemoViewController.m
@@ -132,10 +132,6 @@
         #endif
     };
     
-    _instance.onJSException = ^(WXJSExceptionInfo* jsException){
-        // handle js exception
-    };
-    
     _instance.renderFinish = ^(UIView *view) {
          WXLogDebug(@"%@", @"Render Finish...");
         [weakSelf updateInstanceState:WeexInstanceAppear];