iOS:Support debugging

This commit is contained in:
pengfeizhou
2021-02-22 19:03:34 +08:00
committed by osborn
parent 5ca650c9cb
commit 9db60d94ba
26 changed files with 461 additions and 422 deletions

View File

@@ -46,6 +46,8 @@ NS_ASSUME_NONNULL_BEGIN
- (JSValue *)invokeDoricMethod:(NSString *)method argumentsArray:(NSArray *)args;
- (void)ensureRunOnJSThread:(dispatch_block_t)block;
- (void)initJSEngine;
@end
NS_ASSUME_NONNULL_END

View File

@@ -96,6 +96,7 @@ - (instancetype)init {
[self initJSExecutor];
[self initDoricEnvironment];
}];
[self.registry registerMonitor:[DoricDefaultMonitor new]];
}
return self;
}
@@ -126,7 +127,6 @@ - (void)threadRun {
}
- (void)initJSEngine {
[self.registry registerMonitor:[DoricDefaultMonitor new]];
self.jsExecutor = [DoricJSCoreExecutor new];
}

View File

@@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface NSString (JsonString)
+ (NSString *)dc_convertToJsonWithDic:(NSDictionary *)dic;
+ (NSString *)dc_convertToJsonWithDic:(id)obj;
@end
NS_ASSUME_NONNULL_END

View File

@@ -9,11 +9,11 @@
#import "DoricUtil.h"
@implementation NSString (JsonString)
+ (NSString *)dc_convertToJsonWithDic:(NSDictionary *)dic {
+ (NSString *)dc_convertToJsonWithDic:(id)obj {
NSError *err;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&err];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:obj options:NSJSONWritingPrettyPrinted error:&err];
NSString *jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
if (err) {
DoricLog(NSStringFromSelector(_cmd), @"Convert dictionary to json string failed.");
return nil;

View File

@@ -1,24 +0,0 @@
//
// DoricJSRemoteArgType.h
// Doric
//
// Created by Insomnia on 2019/11/7.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, DoricJSRemoteArgType) {
DoricJSRemoteArgTypeNil = 0,
DoricJSRemoteArgTypeNumber,
DoricJSRemoteArgTypeBool,
DoricJSRemoteArgTypeString,
DoricJSRemoteArgTypeObject,
DoricJSRemoteArgTypeArray,
};
DoricJSRemoteArgType DoricargTypeWithArg(id arg);
NS_ASSUME_NONNULL_END

View File

@@ -1,21 +0,0 @@
//
// DoricJSRemoteArgType.m
// Doric
//
// Created by Insomnia on 2019/11/7.
//
#import "DoricJSRemoteArgType.h"
DoricJSRemoteArgType DoricargTypeWithArg(id arg) {
DoricJSRemoteArgType type = DoricJSRemoteArgTypeNil;
if ([arg isKindOfClass:[NSNumber class]]) {
type = DoricJSRemoteArgTypeNumber;
}else if ([arg isKindOfClass:[NSString class]]) {
type = DoricJSRemoteArgTypeString;
}else if ([arg isKindOfClass:[NSDictionary class]]) {
type = DoricJSRemoteArgTypeObject;
}else if ([arg isKindOfClass:[NSMutableArray class]]) {
type = DoricJSRemoteArgTypeArray;
}
return type;
}