2
2
3
3
#include < nui/frontend/val.hpp>
4
4
5
+ #include < traits/functions.hpp>
5
6
#include < nui/frontend/api/console.hpp>
6
7
#include < nui/frontend/utility/functions.hpp>
7
- #include < nui/utility/meta/function_traits.hpp>
8
8
#include < nui/frontend/utility/val_conversion.hpp>
9
9
#include < nui/shared/on_destroy.hpp>
10
10
@@ -39,7 +39,7 @@ namespace Nui
39
39
template <typename FunctionT>
40
40
constexpr static auto wrapFunction (FunctionT&& func)
41
41
{
42
- return [func = std::move (func)](Nui::val const & args) mutable {
42
+ return [func = std::forward<FunctionT> (func)](Nui::val const & args) mutable {
43
43
func (args);
44
44
};
45
45
}
@@ -51,7 +51,7 @@ namespace Nui
51
51
template <typename FunctionT>
52
52
constexpr static auto wrapFunction (FunctionT&& func)
53
53
{
54
- return [func = std::move (func)](Nui::val const & arg) mutable {
54
+ return [func = std::forward<FunctionT> (func)](Nui::val const & arg) mutable {
55
55
func (extractMember<ArgType>(arg));
56
56
};
57
57
}
@@ -63,7 +63,7 @@ namespace Nui
63
63
template <typename FunctionT>
64
64
constexpr static auto wrapFunction (FunctionT&& func)
65
65
{
66
- return [func = std::move (func)](Nui::val const & args) mutable {
66
+ return [func = std::forward<FunctionT> (func)](Nui::val const & args) mutable {
67
67
func (extractMember<ArgsTypes>(args[Is])...);
68
68
};
69
69
}
@@ -81,8 +81,8 @@ namespace Nui
81
81
template <typename FunctionT>
82
82
struct FunctionWrapper
83
83
: public FunctionWrapperImpl2<
84
- FunctionReturnType_t <std::decay_t <FunctionT>>,
85
- FunctionArgumentTypes_t <std::decay_t <FunctionT>>>
84
+ typename Traits::FunctionTraits <std::decay_t <FunctionT>>::ReturnType ,
85
+ typename Traits::FunctionTraits <std::decay_t <FunctionT>>::ArgsTuple >
86
86
{};
87
87
}
88
88
@@ -103,8 +103,7 @@ namespace Nui
103
103
}
104
104
if (backChannel_.empty ())
105
105
return callable_ (convertToVal (args)...);
106
- else
107
- return callable_ (convertToVal (backChannel_), convertToVal (args)...);
106
+ return callable_ (convertToVal (backChannel_), convertToVal (args)...);
108
107
}
109
108
auto operator ()(Nui::val val) const
110
109
{
@@ -116,8 +115,7 @@ namespace Nui
116
115
}
117
116
if (backChannel_.empty ())
118
117
return callable_ (val);
119
- else
120
- return callable_ (convertToVal (backChannel_), val);
118
+ return callable_ (convertToVal (backChannel_), val);
121
119
}
122
120
123
121
bool isValid () const
@@ -130,7 +128,7 @@ namespace Nui
130
128
return isValid ();
131
129
}
132
130
133
- RemoteCallable (std::string name)
131
+ explicit RemoteCallable (std::string name)
134
132
: name_{std::move (name)}
135
133
, backChannel_{}
136
134
, callable_{Nui::val::undefined ()}
@@ -236,9 +234,9 @@ namespace Nui
236
234
Nui::val::global (" nui_rpc" )[" frontend" ].set (
237
235
tempIdString,
238
236
Nui::bind (
239
- [func = Detail::FunctionWrapper<FunctionT>::wrapFunction (std::forward<FunctionT>(func)),
237
+ [funcInner = Detail::FunctionWrapper<FunctionT>::wrapFunction (std::forward<FunctionT>(func)),
240
238
tempIdString](Nui::val param) mutable {
241
- func (param);
239
+ funcInner (param);
242
240
Nui::val::global (" nui_rpc" )[" frontend" ].delete_ (tempIdString);
243
241
},
244
242
std::placeholders::_1));
@@ -263,9 +261,9 @@ namespace Nui
263
261
Nui::val::global (" nui_rpc" )[" frontend" ].set (
264
262
name.c_str (),
265
263
Nui::bind (
266
- [func = Detail::FunctionWrapper<FunctionT>::wrapFunction (std::forward<FunctionT>(func))](
264
+ [funcInner = Detail::FunctionWrapper<FunctionT>::wrapFunction (std::forward<FunctionT>(func))](
267
265
Nui::val param) mutable {
268
- func (param);
266
+ funcInner (param);
269
267
},
270
268
std::placeholders::_1));
271
269
}
@@ -291,19 +289,19 @@ namespace Nui
291
289
AutoUnregister ()
292
290
: OnDestroy{[]() {}}
293
291
{}
294
- AutoUnregister (std::string name)
292
+ explicit AutoUnregister (std::string name)
295
293
: OnDestroy{[name = std::move (name)]() {
296
294
unregisterFunction (name);
297
295
}}
298
296
{}
299
297
~AutoUnregister () = default ;
300
298
301
299
AutoUnregister (AutoUnregister const &) = delete ;
302
- AutoUnregister (AutoUnregister&& other)
300
+ AutoUnregister (AutoUnregister&& other) noexcept
303
301
: OnDestroy{std::move (other)}
304
302
{}
305
303
AutoUnregister& operator =(AutoUnregister const &) = delete ;
306
- AutoUnregister& operator =(AutoUnregister&& other)
304
+ AutoUnregister& operator =(AutoUnregister&& other) noexcept
307
305
{
308
306
OnDestroy::operator =(std::move (other));
309
307
return *this ;
0 commit comments