@@ -423,7 +423,7 @@ - (void)_exportsClassMethods:(LSCExportTypeDescriptor *)typeDescriptor
423423 hasExists = NO ;
424424 [methodList enumerateObjectsUsingBlock: ^(LSCExportMethodDescriptor * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
425425
426- if ([obj.methodSignature isEqualToString: signStr])
426+ if ([obj.paramsSignature isEqualToString: signStr])
427427 {
428428 hasExists = YES ;
429429 *stop = YES ;
@@ -433,12 +433,8 @@ - (void)_exportsClassMethods:(LSCExportTypeDescriptor *)typeDescriptor
433433
434434 if (!hasExists)
435435 {
436- LSCExportMethodDescriptor *methodDesc = [[LSCExportMethodDescriptor alloc ] init ];
437- methodDesc.methodSignature = signStr;
438-
439436 NSMethodSignature *sign = [targetTypeDescriptor.nativeType methodSignatureForSelector: selector];
440- methodDesc.invocation = [NSInvocation invocationWithMethodSignature: sign];
441- [methodDesc.invocation setSelector: selector];
437+ LSCExportMethodDescriptor *methodDesc = [[LSCExportMethodDescriptor alloc ] initWithSelector: selector methodSignature: sign paramsSignature: signStr];
442438
443439 [methodList addObject: methodDesc];
444440 }
@@ -673,7 +669,7 @@ - (void)_exportsInstanceMethods:(LSCExportTypeDescriptor *)typeDescriptor
673669 hasExists = NO ;
674670 [methodList enumerateObjectsUsingBlock: ^(LSCExportMethodDescriptor * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
675671
676- if ([obj.methodSignature isEqualToString: signStr])
672+ if ([obj.paramsSignature isEqualToString: signStr])
677673 {
678674 hasExists = YES ;
679675 *stop = YES ;
@@ -683,13 +679,9 @@ - (void)_exportsInstanceMethods:(LSCExportTypeDescriptor *)typeDescriptor
683679
684680 if (!hasExists)
685681 {
686- LSCExportMethodDescriptor *methodDesc = [[LSCExportMethodDescriptor alloc ] init ];
687- methodDesc.methodSignature = signStr;
688-
689682 NSMethodSignature *sign = [typeDescriptor.nativeType instanceMethodSignatureForSelector: selector];
690- methodDesc.invocation = [NSInvocation invocationWithMethodSignature: sign];
691- [methodDesc.invocation setSelector: selector];
692-
683+ LSCExportMethodDescriptor *methodDesc = [[LSCExportMethodDescriptor alloc ] initWithSelector: selector methodSignature: sign paramsSignature: signStr];
684+
693685 [methodList addObject: methodDesc];
694686 }
695687 }
@@ -949,7 +941,7 @@ - (NSInvocation *)_invocationWithMethodName:(NSString *)methodName
949941 methodDesc = [typeDesc instanceMethodWithName: methodName arguments: arguments];
950942 }
951943
952- return methodDesc. invocation ;
944+ return [ methodDesc createInvocation ] ;
953945}
954946
955947
@@ -1175,23 +1167,23 @@ static int instanceMethodRouteHandler(lua_State *state)
11751167 index = [LSCEngineAdapter upvalueIndex: 2 ];
11761168 ptr = [LSCEngineAdapter toPointer: state index: index];
11771169 LSCExportTypeDescriptor *typeDescriptor = (__bridge LSCExportTypeDescriptor *)ptr;
1178-
1170+
11791171 index = [LSCEngineAdapter upvalueIndex: 3 ];
11801172 const char *methodNameCStr = [LSCEngineAdapter toString: state index: index];
11811173 NSString *methodName = [NSString stringWithUTF8String: methodNameCStr];
1182-
1174+
11831175 if ([LSCEngineAdapter type: state index: 1 ] != LUA_TUSERDATA)
11841176 {
11851177 NSString *errMsg = [NSString stringWithFormat: @" call %@ method error : missing self parameter, please call by instance:methodName(param)" , methodName];
11861178 [LSCEngineAdapter error: state message: errMsg.UTF8String];
11871179 return retCount;
11881180 }
1189-
1181+
11901182 // 创建调用会话
11911183 LSCSession *callSession = [exporter.context makeSessionWithState: state];
11921184 NSArray *arguments = [callSession parseArguments ];
11931185 id instance = [arguments[0 ] toObject ];
1194-
1186+
11951187 NSInvocation *invocation = [exporter _invocationWithMethodName: methodName
11961188 arguments: arguments
11971189 typeDesc: typeDescriptor
@@ -1203,7 +1195,7 @@ static int instanceMethodRouteHandler(lua_State *state)
12031195 LSCValue *retValue = [typeDescriptor _invokeMethodWithInstance: instance
12041196 invocation: invocation
12051197 arguments: arguments];
1206-
1198+
12071199 if (retValue)
12081200 {
12091201 retCount = [callSession setReturnValue: retValue];
@@ -1214,7 +1206,7 @@ static int instanceMethodRouteHandler(lua_State *state)
12141206 NSString *errMsg = [NSString stringWithFormat: @" call `%@ ` method fail : argument type mismatch" , methodName];
12151207 [LSCEngineAdapter error: state message: errMsg.UTF8String];
12161208 }
1217-
1209+
12181210 [exporter.context destroySession: callSession];
12191211
12201212 return retCount;
0 commit comments