File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -20,18 +20,25 @@ using namespace RpcUtils::detail;
2020#ifdef HANDLE_RPC_ERRORS
2121#include < stdexcept>
2222#endif
23+ #ifdef ARDUINO_ARCH_ZEPHYR
24+ #include < functional>
25+ #endif
2326
2427class IFunctionWrapper {
2528public:
2629 virtual ~IFunctionWrapper () {}
2730 virtual bool operator ()(MsgPack::Unpacker& unpacker, MsgPack::Packer& packer) = 0;
2831};
2932
33+ #ifdef ARDUINO_ARCH_ZEPHYR
34+ class RpcFunctionWrapper : public IFunctionWrapper {
35+ #else
3036template <typename F>
3137class RpcFunctionWrapper ;
3238
3339template <typename R, typename ... Args>
3440class RpcFunctionWrapper <std::function<R(Args...)>>: public IFunctionWrapper {
41+ #endif
3542public:
3643 RpcFunctionWrapper (std::function<R(Args...)> func) : _func(func) {}
3744
@@ -110,9 +117,16 @@ class RpcFunctionWrapper<std::function<R(Args...)>>: public IFunctionWrapper {
110117 }
111118};
112119
120+ #ifdef ARDUINO_ARCH_ZEPHYR
121+ template <typename F>
122+ auto wrap (F&& f) {
123+ return new RpcFunctionWrapper (std::function (std::forward<F>(f)));
124+ };
125+ #else
113126template <typename F, typename Signature = typename arx::function_traits<typename std::decay<F>::type>::function_type>
114127auto wrap (F&& f) -> RpcFunctionWrapper<Signature>* {
115128 return new RpcFunctionWrapper<Signature>(std::forward<F>(f));
116129};
130+ #endif
117131
118132#endif
You can’t perform that action at this time.
0 commit comments