format OC code

This commit is contained in:
pengfei.zhou
2019-10-12 14:48:19 +08:00
parent 820f1e9f8c
commit f9b599e7cf
43 changed files with 493 additions and 472 deletions

View File

@@ -10,18 +10,23 @@
NS_ASSUME_NONNULL_BEGIN
@interface DoricAsyncResult <R>: NSObject
@interface DoricAsyncResult <R> : NSObject
typedef void(^DoricResultCallback)(R);
typedef void(^DoricExceptionCallback)(NSException *);
typedef void(^DoricFinishCallback)(void);
@property(nonatomic,strong) DoricResultCallback resultCallback;
@property(nonatomic,strong) DoricExceptionCallback exceptionCallback;
@property(nonatomic,strong) DoricFinishCallback finishCallback;
@property(nonatomic, strong) DoricResultCallback resultCallback;
@property(nonatomic, strong) DoricExceptionCallback exceptionCallback;
@property(nonatomic, strong) DoricFinishCallback finishCallback;
- (void)setupResult:(R)result;
- (void)setupError:(NSException*)exception;
- (void)setupError:(NSException *)exception;
- (BOOL)hasResult;
- (R)getResult;
@end

View File

@@ -7,43 +7,43 @@
#import <Foundation/Foundation.h>
extern NSString * const DORIC_BUNDLE_SANDBOX;
extern NSString * const DORIC_BUNDLE_LIB;
extern NSString * const DORIC_MODULE_LIB;
extern NSString *const DORIC_BUNDLE_SANDBOX;
extern NSString *const DORIC_BUNDLE_LIB;
extern NSString *const DORIC_MODULE_LIB;
extern NSString * const INJECT_LOG;
extern NSString * const INJECT_REQUIRE;
extern NSString * const INJECT_TIMER_SET;
extern NSString * const INJECT_TIMER_CLEAR;
extern NSString * const INJECT_BRIDGE;
extern NSString *const INJECT_LOG;
extern NSString *const INJECT_REQUIRE;
extern NSString *const INJECT_TIMER_SET;
extern NSString *const INJECT_TIMER_CLEAR;
extern NSString *const INJECT_BRIDGE;
extern NSString * const TEMPLATE_CONTEXT_CREATE;
extern NSString *const TEMPLATE_CONTEXT_CREATE;
extern NSString * const TEMPLATE_MODULE;
extern NSString *const TEMPLATE_MODULE;
extern NSString * const TEMPLATE_CONTEXT_DESTROY;
extern NSString *const TEMPLATE_CONTEXT_DESTROY;
extern NSString * const GLOBAL_DORIC;
extern NSString *const GLOBAL_DORIC;
extern NSString * const DORIC_CONTEXT_RELEASE;
extern NSString *const DORIC_CONTEXT_RELEASE;
extern NSString * const DORIC_CONTEXT_INVOKE;
extern NSString *const DORIC_CONTEXT_INVOKE;
extern NSString * const DORIC_TIMER_CALLBACK;
extern NSString *const DORIC_TIMER_CALLBACK;
extern NSString * const DORIC_BRIDGE_RESOLVE;
extern NSString *const DORIC_BRIDGE_RESOLVE;
extern NSString * const DORIC_BRIDGE_REJECT;
extern NSString *const DORIC_BRIDGE_REJECT;
extern NSString * const DORIC_ENTITY_RESPONSE;
extern NSString *const DORIC_ENTITY_RESPONSE;
extern NSString * const DORIC_ENTITY_INIT;
extern NSString *const DORIC_ENTITY_INIT;
extern NSString * const DORIC_ENTITY_CREATE;
extern NSString *const DORIC_ENTITY_CREATE;
extern NSString * const DORIC_ENTITY_DESTROY;
extern NSString *const DORIC_ENTITY_DESTROY;
extern NSString * const DORIC_ENTITY_SHOW;
extern NSString *const DORIC_ENTITY_SHOW;
extern NSString * const DORIC_ENTITY_HIDDEN;
extern NSString *const DORIC_ENTITY_HIDDEN;

View File

@@ -7,60 +7,60 @@
#import "DoricConstant.h"
NSString * const DORIC_BUNDLE_SANDBOX = @"doric-sandbox";
NSString * const DORIC_BUNDLE_LIB = @"doric-lib";
NSString * const DORIC_MODULE_LIB = @"doric";
NSString *const DORIC_BUNDLE_SANDBOX = @"doric-sandbox";
NSString *const DORIC_BUNDLE_LIB = @"doric-lib";
NSString *const DORIC_MODULE_LIB = @"doric";
NSString * const INJECT_LOG = @"nativeLog";
NSString * const INJECT_REQUIRE = @"nativeRequire";
NSString * const INJECT_TIMER_SET = @"nativeSetTimer";
NSString * const INJECT_TIMER_CLEAR = @"nativeClearTimer";
NSString * const INJECT_BRIDGE = @"nativeBridge";
NSString *const INJECT_LOG = @"nativeLog";
NSString *const INJECT_REQUIRE = @"nativeRequire";
NSString *const INJECT_TIMER_SET = @"nativeSetTimer";
NSString *const INJECT_TIMER_CLEAR = @"nativeClearTimer";
NSString *const INJECT_BRIDGE = @"nativeBridge";
NSString * const TEMPLATE_CONTEXT_CREATE = @"Reflect.apply("
"function(doric,context,Entry,require,exports){" "\n"
"%@" "\n"
"},doric.jsObtainContext(\"%@\"),["
"undefined,"
"doric.jsObtainContext(\"%@\"),"
"doric.jsObtainEntry(\"%@\"),"
"doric.__require__"
",{}"
"])";
NSString *const TEMPLATE_CONTEXT_CREATE = @"Reflect.apply("
"function(doric,context,Entry,require,exports){" "\n"
"%@" "\n"
"},doric.jsObtainContext(\"%@\"),["
"undefined,"
"doric.jsObtainContext(\"%@\"),"
"doric.jsObtainEntry(\"%@\"),"
"doric.__require__"
",{}"
"])";
NSString * const TEMPLATE_MODULE = @"Reflect.apply(doric.jsRegisterModule,this,["
"\"%@\","
"Reflect.apply(function(__module){"
"(function(module,exports,require){" "\n"
"%@" "\n"
"})(__module,__module.exports,doric.__require__);"
"\nreturn __module.exports;"
"},this,[{exports:{}}])"
"])";
NSString *const TEMPLATE_MODULE = @"Reflect.apply(doric.jsRegisterModule,this,["
"\"%@\","
"Reflect.apply(function(__module){"
"(function(module,exports,require){" "\n"
"%@" "\n"
"})(__module,__module.exports,doric.__require__);"
"\nreturn __module.exports;"
"},this,[{exports:{}}])"
"])";
NSString * const TEMPLATE_CONTEXT_DESTROY = @"doric.jsReleaseContext(\"%@\")";
NSString *const TEMPLATE_CONTEXT_DESTROY = @"doric.jsReleaseContext(\"%@\")";
NSString * const GLOBAL_DORIC = @"doric";
NSString *const GLOBAL_DORIC = @"doric";
NSString * const DORIC_CONTEXT_RELEASE = @"jsReleaseContext";
NSString *const DORIC_CONTEXT_RELEASE = @"jsReleaseContext";
NSString * const DORIC_CONTEXT_INVOKE = @"jsCallEntityMethod";
NSString *const DORIC_CONTEXT_INVOKE = @"jsCallEntityMethod";
NSString * const DORIC_TIMER_CALLBACK = @"jsCallbackTimer";
NSString *const DORIC_TIMER_CALLBACK = @"jsCallbackTimer";
NSString * const DORIC_BRIDGE_RESOLVE = @"jsCallResolve";
NSString *const DORIC_BRIDGE_RESOLVE = @"jsCallResolve";
NSString * const DORIC_BRIDGE_REJECT = @"jsCallReject";
NSString *const DORIC_BRIDGE_REJECT = @"jsCallReject";
NSString * const DORIC_ENTITY_RESPONSE = @"__response__";
NSString *const DORIC_ENTITY_RESPONSE = @"__response__";
NSString * const DORIC_ENTITY_INIT = @"__init__";
NSString *const DORIC_ENTITY_INIT = @"__init__";
NSString * const DORIC_ENTITY_CREATE = @"__onCreate__";
NSString *const DORIC_ENTITY_CREATE = @"__onCreate__";
NSString * const DORIC_ENTITY_DESTROY = @"__onDestroy__";
NSString *const DORIC_ENTITY_DESTROY = @"__onDestroy__";
NSString * const DORIC_ENTITY_SHOW = @"__onShow__";
NSString *const DORIC_ENTITY_SHOW = @"__onShow__";
NSString * const DORIC_ENTITY_HIDDEN = @"__onHidden__";
NSString *const DORIC_ENTITY_HIDDEN = @"__onHidden__";

View File

@@ -7,8 +7,8 @@
#import <Foundation/Foundation.h>
void DoricLog(NSString * _Nonnull format, ...);
void DoricLog(NSString *_Nonnull format, ...);
UIColor* _Nonnull DoricColor(NSNumber * _Nonnull number);
UIColor *_Nonnull DoricColor(NSNumber *_Nonnull number);
NSBundle *DoricBundle();

View File

@@ -8,20 +8,20 @@
#import "DoricUtil.h"
#import "DoricContext.h"
void DoricLog(NSString * _Nonnull format, ...) {
void DoricLog(NSString *_Nonnull format, ...) {
va_list args;
va_start(args, format);
NSLogv([NSString stringWithFormat:@"Doric:%@",format],args);
NSLogv([NSString stringWithFormat:@"Doric:%@", format], args);
va_end(args);
}
UIColor *DoricColor(NSNumber *number) {
CGFloat r, g, b, a;
long colorValue = [number longValue];
a = ((colorValue >> 24) & 0xff)/255.0f;
r = ((colorValue >> 16) & 0xff)/255.0f;
g = ((colorValue >> 8) & 0xff)/255.0f;
b = ((colorValue >> 0) & 0xff)/255.0f;
a = ((colorValue >> 24) & 0xff) / 255.0f;
r = ((colorValue >> 16) & 0xff) / 255.0f;
g = ((colorValue >> 8) & 0xff) / 255.0f;
b = ((colorValue >> 0) & 0xff) / 255.0f;
return [UIColor colorWithRed:r green:g blue:b alpha:a];
}