You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/01/02 11:34:24 UTC

[GitHub] doumafang closed pull request #1987: [iOS] Allow redundant arguments provided for callNative.

doumafang closed pull request #1987: [iOS] Allow redundant arguments provided for callNative.
URL: https://github.com/apache/incubator-weex/pull/1987
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeMethod.m b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeMethod.m
index a349849f42..f50ad2bc8c 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeMethod.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeMethod.m
@@ -102,11 +102,10 @@ - (NSInvocation *)invocationWithTarget:(id)target selector:(SEL)selector
         return nil;
     }
     
+    NSUInteger redundantArgumentCount = 0;
     NSArray *arguments = _arguments;
     if (signature.numberOfArguments - 2 < arguments.count) {
-        NSString *errorMessage = [NSString stringWithFormat:@"%@, the parameters in calling method [%@] and registered method [%@] are not consistent!", target, _methodName, NSStringFromSelector(selector)];
-        WX_MONITOR_FAIL(WXMTJSBridge, WX_ERR_INVOKE_NATIVE, errorMessage);
-        return nil;
+        redundantArgumentCount = arguments.count - (signature.numberOfArguments - 2); // JS provides more arguments than required.
     }
     
     NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
@@ -116,8 +115,8 @@ - (NSInvocation *)invocationWithTarget:(id)target selector:(SEL)selector
     void **freeList = NULL;
     
     NSMutableArray *blockArray = [NSMutableArray array];
-    WX_ALLOC_FLIST(freeList, arguments.count);
-    for (int i = 0; i < arguments.count; i ++ ) {
+    WX_ALLOC_FLIST(freeList, arguments.count - redundantArgumentCount);
+    for (int i = 0; i < arguments.count - redundantArgumentCount; i ++ ) {
         id obj = arguments[i];
         const char *parameterType = [signature getArgumentTypeAtIndex:i + 2];
         obj = [self parseArgument:obj parameterType:parameterType order:i];
@@ -138,7 +137,7 @@ - (NSInvocation *)invocationWithTarget:(id)target selector:(SEL)selector
         }
     }
     [invocation retainArguments];
-    WX_FREE_FLIST(freeList, arguments.count);
+    WX_FREE_FLIST(freeList, arguments.count - redundantArgumentCount);
     
     return invocation;
 }
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
index 3829c8faf0..c9be37a794 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
@@ -52,7 +52,7 @@ do {\
 
 #define WX_FREE_FLIST(_ppFree, _count) \
 do {\
-    for(int i = 0; i < _count; i++){\
+    for(int i = 0; i < (_count); i++){\
         if(*(_ppFree + i ) != 0) {\
             free(*(_ppFree + i));\
         }\


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services