strong context
This commit is contained in:
parent
4653c5872c
commit
bc8e815b05
@ -33,7 +33,7 @@
|
|||||||
@implementation DoricBridgeExtension
|
@implementation DoricBridgeExtension
|
||||||
|
|
||||||
- (id)callNativeWithContextId:(NSString *)contextId module:(NSString *)module method:(NSString *)method callbackId:(NSString *)callbackId argument:(id)argument {
|
- (id)callNativeWithContextId:(NSString *)contextId module:(NSString *)module method:(NSString *)method callbackId:(NSString *)callbackId argument:(id)argument {
|
||||||
DoricContext *context = [[DoricContextManager instance] getContext:contextId];
|
__strong DoricContext *context = [[DoricContextManager instance] getContext:contextId];
|
||||||
DoricRegistry *registry = context.driver.registry;
|
DoricRegistry *registry = context.driver.registry;
|
||||||
Class pluginClass = [registry acquireNativePlugin:module];
|
Class pluginClass = [registry acquireNativePlugin:module];
|
||||||
DoricNativePlugin *nativePlugin = context.pluginInstanceMap[module];
|
DoricNativePlugin *nativePlugin = context.pluginInstanceMap[module];
|
||||||
@ -53,6 +53,8 @@ - (id)createParamWithMethodName:(NSString *)method context:(DoricContext *)conte
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (id)findClass:(Class)clz target:(id)target context:(DoricContext *)context method:(NSString *)name callbackId:(NSString *)callbackId argument:(id)argument {
|
- (id)findClass:(Class)clz target:(id)target context:(DoricContext *)context method:(NSString *)name callbackId:(NSString *)callbackId argument:(id)argument {
|
||||||
|
__strong DoricContext *strongContext = context;
|
||||||
|
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
id ret = nil;
|
id ret = nil;
|
||||||
Method *methods = class_copyMethodList(clz, &count);
|
Method *methods = class_copyMethodList(clz, &count);
|
||||||
@ -78,7 +80,7 @@ - (id)findClass:(Class)clz target:(id)target context:(DoricContext *)context met
|
|||||||
if (idx - 2 > [array count]) {
|
if (idx - 2 > [array count]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
id args = [self createParamWithMethodName:array[idx - 2] context:context callbackId:callbackId argument:argument];
|
id args = [self createParamWithMethodName:array[idx - 2] context:strongContext callbackId:callbackId argument:argument];
|
||||||
if (args) {
|
if (args) {
|
||||||
[tempArray addObject:args];
|
[tempArray addObject:args];
|
||||||
}
|
}
|
||||||
@ -87,7 +89,7 @@ - (id)findClass:(Class)clz target:(id)target context:(DoricContext *)context met
|
|||||||
[invocation invoke];
|
[invocation invoke];
|
||||||
} @catch (NSException *exception) {
|
} @catch (NSException *exception) {
|
||||||
DoricLog(@"CallNative Error:%@", exception.reason);
|
DoricLog(@"CallNative Error:%@", exception.reason);
|
||||||
[context.driver.registry onException:exception inContext:context];
|
[strongContext.driver.registry onException:exception inContext:strongContext];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -103,7 +105,7 @@ - (id)findClass:(Class)clz target:(id)target context:(DoricContext *)context met
|
|||||||
ret = [JSValue valueWithObject:[returnValue copy] inContext:[JSContext currentContext]];
|
ret = [JSValue valueWithObject:[returnValue copy] inContext:[JSContext currentContext]];
|
||||||
} else {
|
} else {
|
||||||
DoricLog(@"CallNative Error:%@", @"Must return object type");
|
DoricLog(@"CallNative Error:%@", @"Must return object type");
|
||||||
[context.driver.registry onLog:DoricLogTypeError
|
[strongContext.driver.registry onLog:DoricLogTypeError
|
||||||
message:[NSString stringWithFormat:@"CallNative Error:%@", @"Must return object type"]];
|
message:[NSString stringWithFormat:@"CallNative Error:%@", @"Must return object type"]];
|
||||||
ret = nil;
|
ret = nil;
|
||||||
}
|
}
|
||||||
@ -118,7 +120,7 @@ - (id)findClass:(Class)clz target:(id)target context:(DoricContext *)context met
|
|||||||
if (!isFound) {
|
if (!isFound) {
|
||||||
Class superclass = class_getSuperclass(clz);
|
Class superclass = class_getSuperclass(clz);
|
||||||
if (superclass && superclass != [NSObject class]) {
|
if (superclass && superclass != [NSObject class]) {
|
||||||
return [self findClass:superclass target:target context:context method:name callbackId:callbackId argument:argument];
|
return [self findClass:superclass target:target context:strongContext method:name callbackId:callbackId argument:argument];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user