BBASDDefine.h
3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// BBASDDefine.h
// BBASchemeDispatcher
//
// Created by Wang,Peng(MAD) on 2018/10/12.
// Copyright © 2018年 Baidu. All rights reserved.
//
#ifndef BBASDDefine_h
#define BBASDDefine_h
#import <BBAFoundation/BBAFoundation.h>
@class BBASchemeDispatcher;
typedef void(^DispatcherHandler) (BBASchemeDispatcher *dispatcher, BOOL shouldUpgrade);
typedef void(^SDUBCHandler) (NSString* event, NSDictionary* dict);
typedef void(^SDGuardResult)(BOOL result);
typedef void(^SDGuardHandler)(BBASchemeDispatcher *dispatcher, SDGuardResult result);
typedef void(^SDParseFinishHandler)(BBASchemeDispatcher *dispatcher);
// 通用结果状态码, 预留:0 - 100
typedef NS_ENUM(NSUInteger, BDPSDCallbackResult) {
BDPSDCallbackResultSuccess = 0, // success
BDPSDCallbackResultUnknownError = 1,
BDPSDCallbackResultInvalidParameters = 2,
BDPSDCallbackResultUserCancelled = 3,
BDPSDCallbackResultPathForbidden = 4, // 超出访问权限,拒绝访问
BDPSDCallbackResultMax = 100
};
// 宏定义
#define kBBASchemeDispatcherNextDelayTime 0.35f // 调起序列下级调起默认延迟时间
// 通用参数 - key
#define kBBASchemeDispatcherModuleKey @"module"
#define kBBASchemeDispatcherActionKey @"action"
#define kBBASchemeDispatcherCallbackKey @"callback"
#define kBBASchemeDispatcherUpgradeKey @"upgrade"
#define kBBASchemeDispatcherParamsKey @"params"
#define kBBASchemeDispatcherParamKey @"param"
#define kBBASchemeDispatcherOptionsKey @"options"
#define kBBASchemeDispatcherMinFuncKey @"func"
#define kBBASchemeDispatcherSuccessCallbackKey @"successcallback"
#define kBBASchemeDispatcherFailCallbackKey @"failcallback"
typedef NSString* BDPSDCallbackKey;
FOUNDATION_EXTERN BDPSDCallbackKey const BDPSDCallbackKeyResult;
FOUNDATION_EXTERN BDPSDCallbackKey const BDPSDCallbackKeyErrorCode;
#define kBBASchemeDispatcherNextKey @"next"
#define kBBASchemeDispatcherDelayTimeKey @"delaytime"
#define kBBASchemeDispatcherOauthTypeKey @"oauthType"
#define kBBASchemeDispatcherBackupKey @"backup"
#define kBBASchemeDispatcherPrevKey @"prev"
#define kBBASchemeDispatcherSeniorKey @"senior"
/**
@abstract 注册Plugin (注册插件以className去掉前缀后缀的string为Key 【建议写在 Pyraimd moduleRegister方法中注册】)
@param Implementation Class 需要注册的端能力类
**/
#define registerPlugin(Implementation) \
do { \
[BBASchemeDispatcher registerPluginWithClassName:NSStringFromClass([Implementation class])];\
[Pyramid registerDispatcher:[Implementation class] forModuleInstance:self]; \
} while(0)
/**
@abstract 注册Plugin (以传入的module为Key,如果module为空,以className去掉前缀后缀的string为Key)
@param Implementation Class 需要注册的端能力类
@param moduleString NSString 端能力的module
**/
#define registerPluginWithModule(Implementation, moduleString) \
do { \
[BBASchemeDispatcher registerPluginWithClassName:NSStringFromClass([Implementation class]) module:moduleString];\
[Pyramid registerDispatcher:[Implementation class] forModuleInstance:self]; \
} while(0)
/**
@abstract 注册Plugin 在plugin类中注册(以传入的modulez为Key 不建议使用此方法,启动速度统计不能明确区分耗时)
@param Implementation Class 需要注册的端能力类
@param moduleString NSString 端能力的module
**/
#define registerPluginInSelf(Implementation, moduleString)\
__attribute__((constructor))\
static void registerPluginInSelf(void) {\
[BBASchemeDispatcher registerPluginWithClassName:NSStringFromClass([Implementation class]) module:moduleString];\
}
#endif /* BBASDHeader_h */