valid msg
This commit is contained in:
parent
1e106bd10f
commit
5a05f1019f
|
@ -55,7 +55,6 @@ extern "C" {
|
||||||
|
|
||||||
extern char* tMsgInfo[];
|
extern char* tMsgInfo[];
|
||||||
extern int32_t tMsgDict[];
|
extern int32_t tMsgDict[];
|
||||||
// extern int32_t tMsgRangeDict[];
|
|
||||||
|
|
||||||
typedef uint16_t tmsg_t;
|
typedef uint16_t tmsg_t;
|
||||||
|
|
||||||
|
|
|
@ -35,17 +35,13 @@
|
||||||
|
|
||||||
#elif defined(TD_MSG_RANGE_CODE_)
|
#elif defined(TD_MSG_RANGE_CODE_)
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t start;
|
|
||||||
int32_t end;
|
|
||||||
} TMsgRange;
|
|
||||||
#undef TD_NEW_MSG_SEG
|
#undef TD_NEW_MSG_SEG
|
||||||
#undef TD_DEF_MSG_TYPE
|
#undef TD_DEF_MSG_TYPE
|
||||||
#undef TD_CLOSE_MSG_TYPE
|
#undef TD_CLOSE_MSG_TYPE
|
||||||
#define TD_NEW_MSG_SEG(TYPE) {(TYPE##_SEG_CODE) << 8,
|
#define TD_NEW_MSG_SEG(TYPE)
|
||||||
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP)
|
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP)
|
||||||
#define TD_CLOSE_MSG_TYPE(TYPE) TYPE},
|
#define TD_CLOSE_MSG_TYPE(TYPE) TYPE,
|
||||||
TMsgRange tMsgRangeDict[] = {
|
int32_t tMsgRangeDict[] = {
|
||||||
|
|
||||||
#elif defined(TD_MSG_NUMBER_)
|
#elif defined(TD_MSG_NUMBER_)
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,10 @@
|
||||||
|
|
||||||
inline bool tmsgIsValid(tmsg_t type) {
|
inline bool tmsgIsValid(tmsg_t type) {
|
||||||
static int8_t sz = sizeof(tMsgRangeDict) / sizeof(tMsgRangeDict[0]);
|
static int8_t sz = sizeof(tMsgRangeDict) / sizeof(tMsgRangeDict[0]);
|
||||||
for (int i = 0; i < sz; i++) {
|
|
||||||
if (type > tMsgRangeDict[i].start && type < tMsgRangeDict[i].end) {
|
int segIdx = TMSG_SEG_CODE(type);
|
||||||
return true;
|
if (segIdx < sz) {
|
||||||
}
|
return type < tMsgRangeDict[segIdx];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue