You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by xi...@apache.org on 2019/01/02 11:34:28 UTC
[incubator-weex] branch master updated: [iOS] Allow redundant
arguments provided for callNative. (#1987)
This is an automated email from the ASF dual-hosted git repository.
xifang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new ab262a1 [iOS] Allow redundant arguments provided for callNative. (#1987)
ab262a1 is described below
commit ab262a193abee1265c516b50c7ffd886b70bc0ee
Author: wqyfavor <wq...@gmail.com>
AuthorDate: Wed Jan 2 19:34:22 2019 +0800
[iOS] Allow redundant arguments provided for callNative. (#1987)
---
ios/sdk/WeexSDK/Sources/Bridge/WXBridgeMethod.m | 11 +++++------
ios/sdk/WeexSDK/Sources/Utility/WXUtility.h | 2 +-
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeMethod.m b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeMethod.m
index a349849..f50ad2b 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeMethod.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeMethod.m
@@ -102,11 +102,10 @@
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 @@
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 @@
}
}
[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 3829c8f..c9be37a 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));\
}\