|
@ -110,7 +110,7 @@ class FrontMsgProcesser { |
|
|
// ref https://blog.csdn.net/Veritaz/article/details/113820764
|
|
|
// ref https://blog.csdn.net/Veritaz/article/details/113820764
|
|
|
//
|
|
|
//
|
|
|
template <typename R, typename... Args> |
|
|
template <typename R, typename... Args> |
|
|
void regProcesser(const string& className, const string fnName, vector<string> params, MsgProcesserFn_t fn) { |
|
|
|
|
|
|
|
|
void regProcesser(function<R(Args...)> __fn, const string& className, const string fnName, vector<string> params, MsgProcesserFn_t fn) { |
|
|
vector<string> paramsTypeInfo; |
|
|
vector<string> paramsTypeInfo; |
|
|
string ret = getTypeName<R>(className, fnName); |
|
|
string ret = getTypeName<R>(className, fnName); |
|
|
(paramsTypeInfo.push_back(getTypeName<Args>(className, fnName)), ...); |
|
|
(paramsTypeInfo.push_back(getTypeName<Args>(className, fnName)), ...); |
|
@ -153,17 +153,17 @@ static inline T jsonGet(json j) { |
|
|
#define REGFNV_EACH_EXPTR1(_1, _2, _3, _4, _5, index, varName) params[#varName]
|
|
|
#define REGFNV_EACH_EXPTR1(_1, _2, _3, _4, _5, index, varName) params[#varName]
|
|
|
#define REGFNV_EACH_EXPTR2(_1, _2, _3, _4, _5, index, varName) #varName
|
|
|
#define REGFNV_EACH_EXPTR2(_1, _2, _3, _4, _5, index, varName) #varName
|
|
|
|
|
|
|
|
|
#define REG_FN(fn, type, ...) \
|
|
|
|
|
|
FrontMsgProcesser::ins().regProcesser<type>(thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr<MsgProcessContext> cxt) { \ |
|
|
|
|
|
|
|
|
#define REG_FN(fn, type, ...) { function<type> __fun; \
|
|
|
|
|
|
FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr<MsgProcessContext> cxt) { \ |
|
|
json& params = cxt->params; \ |
|
|
json& params = cxt->params; \ |
|
|
cxt->content = fn(MARCO_LIST(REGFNV_EACH_EXPTR1, _1, _2, _3, _4, _5, __VA_ARGS__)); \ |
|
|
cxt->content = fn(MARCO_LIST(REGFNV_EACH_EXPTR1, _1, _2, _3, _4, _5, __VA_ARGS__)); \ |
|
|
}); |
|
|
|
|
|
|
|
|
});} |
|
|
|
|
|
|
|
|
#define REG_FN_VOID(fn, type) FrontMsgProcesser::ins().regProcesser<type>(thisClass.className, #fn, {}, [this](shared_ptr<MsgProcessContext> cxt) { cxt->content = fn(); });
|
|
|
|
|
|
|
|
|
#define REG_FN_VOID(fn, type) { function<type> __fun; FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {}, [this](shared_ptr<MsgProcessContext> cxt) { cxt->content = fn(); });}
|
|
|
|
|
|
|
|
|
#define REG_EXTFN(fn, type, ...) \
|
|
|
|
|
|
FrontMsgProcesser::ins().regProcesser<type>(thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr<MsgProcessContext> cxt) { \ |
|
|
|
|
|
|
|
|
#define REG_EXTFN(fn, type, ...) { function<type> __fun; \
|
|
|
|
|
|
FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr<MsgProcessContext> cxt) { \ |
|
|
json& params = cxt->params; \ |
|
|
json& params = cxt->params; \ |
|
|
fn(cxt, MARCO_LIST(REGFNV_EACH_EXPTR1, _1, _2, _3, _4, _5, __VA_ARGS__)); \ |
|
|
fn(cxt, MARCO_LIST(REGFNV_EACH_EXPTR1, _1, _2, _3, _4, _5, __VA_ARGS__)); \ |
|
|
}); |
|
|
|
|
|
#define REG_EXTFN_VOID(fn, type) FrontMsgProcesser::ins().regProcesser<type>(thisClass.className, #fn, {}, [this](shared_ptr<MsgProcessContext> cxt) { fn(cxt); });
|
|
|
|
|
|
|
|
|
}); } |
|
|
|
|
|
#define REG_EXTFN_VOID(fn, type) { function<type> __fun; FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {}, [this](shared_ptr<MsgProcessContext> cxt) { fn(cxt); }); }
|