diff --git a/appsrc/baseservice/front_msg_processer/front_msg_processer.hpp b/appsrc/baseservice/front_msg_processer/front_msg_processer.hpp index 55ff2bf..23af09c 100644 --- a/appsrc/baseservice/front_msg_processer/front_msg_processer.hpp +++ b/appsrc/baseservice/front_msg_processer/front_msg_processer.hpp @@ -110,7 +110,7 @@ class FrontMsgProcesser { // ref https://blog.csdn.net/Veritaz/article/details/113820764 // template - void regProcesser(const string& className, const string fnName, vector params, MsgProcesserFn_t fn) { + void regProcesser(function __fn, const string& className, const string fnName, vector params, MsgProcesserFn_t fn) { vector paramsTypeInfo; string ret = getTypeName(className, fnName); (paramsTypeInfo.push_back(getTypeName(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_EXPTR2(_1, _2, _3, _4, _5, index, varName) #varName -#define REG_FN(fn, type, ...) \ - FrontMsgProcesser::ins().regProcesser(thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr cxt) { \ +#define REG_FN(fn, type, ...) { function __fun; \ + FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr cxt) { \ json& params = cxt->params; \ cxt->content = fn(MARCO_LIST(REGFNV_EACH_EXPTR1, _1, _2, _3, _4, _5, __VA_ARGS__)); \ - }); + });} -#define REG_FN_VOID(fn, type) FrontMsgProcesser::ins().regProcesser(thisClass.className, #fn, {}, [this](shared_ptr cxt) { cxt->content = fn(); }); +#define REG_FN_VOID(fn, type) { function __fun; FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {}, [this](shared_ptr cxt) { cxt->content = fn(); });} -#define REG_EXTFN(fn, type, ...) \ - FrontMsgProcesser::ins().regProcesser(thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr cxt) { \ +#define REG_EXTFN(fn, type, ...) { function __fun; \ + FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {MARCO_LIST(REGFNV_EACH_EXPTR2, _1, _2, _3, _4, _5, __VA_ARGS__)}, [this](shared_ptr cxt) { \ json& params = cxt->params; \ fn(cxt, MARCO_LIST(REGFNV_EACH_EXPTR1, _1, _2, _3, _4, _5, __VA_ARGS__)); \ - }); -#define REG_EXTFN_VOID(fn, type) FrontMsgProcesser::ins().regProcesser(thisClass.className, #fn, {}, [this](shared_ptr cxt) { fn(cxt); }); + }); } +#define REG_EXTFN_VOID(fn, type) { function __fun; FrontMsgProcesser::ins().regProcesser(__fun,thisClass.className, #fn, {}, [this](shared_ptr cxt) { fn(cxt); }); } diff --git a/appsrc/service/app_core.cpp b/appsrc/service/app_core.cpp index e48fc3f..ebac235 100644 --- a/appsrc/service/app_core.cpp +++ b/appsrc/service/app_core.cpp @@ -133,7 +133,9 @@ void AppCore::initialize() { } }); - REG_EXTFN_VOID(getState, void(void)); + // REG_EXTFN_VOID(getState, void(void)); + + REG_EXTFN(promptConfirm, void(string), promptId); REG_EXTFN_VOID(promptGetAll, void(void)); REG_EXTFN_VOID(promptGetNext, void(void));