Fixes for VS2019 and C++17 compilation
Showing 11 of 12 files from the diff.
unittests/compiled_tests.cpp
changed.
Other files ignored by Codecov
appveyor.yml
has changed.
@@ -713,15 +713,8 @@
Loading
713 | 713 | ||
714 | 714 | CHECK(Object_Copy_Count_Test::copycount() == 0); |
|
715 | 715 | CHECK(Object_Copy_Count_Test::constructcount() == 1); |
|
716 | - | ||
717 | - | ||
718 | - | #ifdef CHAISCRIPT_MSVC |
|
719 | - | CHECK(Object_Copy_Count_Test::destructcount() == 3); |
|
720 | - | CHECK(Object_Copy_Count_Test::movecount() == 2); |
|
721 | - | #else |
|
722 | 716 | CHECK(Object_Copy_Count_Test::destructcount() == 2); |
|
723 | 717 | CHECK(Object_Copy_Count_Test::movecount() == 1); |
|
724 | - | #endif |
|
725 | 718 | } |
|
726 | 719 | ||
727 | 720 |
@@ -34,7 +34,8 @@
Loading
34 | 34 | // we now that the Param pack will have only one element, so we are safe expanding it here |
|
35 | 35 | return Proxy_Function(chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Attribute_Access<Ret, std::decay_t<Param>...>>(std::forward<Func>(func))); |
|
36 | 36 | } else if constexpr (Is_Member) { |
|
37 | - | auto call = [func = std::forward<Func>(func)](auto && obj, auto && ... param) noexcept(Is_Noexcept) -> decltype(auto) { |
|
37 | + | // TODO some kind of bug is preventing forwarding of this noexcept for the lambda |
|
38 | + | auto call = [func = std::forward<Func>(func)](auto && obj, auto && ... param) /* noexcept(Is_Noexcept) */ -> decltype(auto) { |
|
38 | 39 | return (( get_first_param(Function_Params<Param...>{}, obj).*func )(std::forward<decltype(param)>(param)...)); |
|
39 | 40 | }; |
|
40 | 41 | return Proxy_Function( |
@@ -87,7 +88,7 @@
Loading
87 | 88 | template<typename T> |
|
88 | 89 | Proxy_Function fun(T &&t) |
|
89 | 90 | { |
|
90 | - | return dispatch::detail::make_callable(std::forward<T>(t), dispatch::detail::Function_Signature{t}); |
|
91 | + | return dispatch::detail::make_callable(std::forward<T>(t), dispatch::detail::function_signature(t)); |
|
91 | 92 | } |
|
92 | 93 | ||
93 | 94 |
@@ -271,7 +271,7 @@
Loading
271 | 271 | ||
272 | 272 | ||
273 | 273 | template<typename ... T> |
|
274 | - | [[nodiscard]] auto make_vector(T && ... t) |
|
274 | + | [[nodiscard]] auto make_vector(T &&... t) -> std::vector<std::common_type_t<std::decay_t<T>...>> |
|
275 | 275 | { |
|
276 | 276 | using container_type = |
|
277 | 277 | std::vector<std::common_type_t<std::decay_t<T>...>>; |
@@ -185,7 +185,9 @@
Loading
185 | 185 | return const_var(c_lhs * c_rhs); |
|
186 | 186 | case Operators::Opers::difference: |
|
187 | 187 | return const_var(c_lhs - c_rhs); |
|
188 | - | } |
|
188 | + | default: |
|
189 | + | break; |
|
190 | + | } |
|
189 | 191 | ||
190 | 192 | ||
191 | 193 | if constexpr (!std::is_floating_point<LHS>::value && !std::is_floating_point<RHS>::value) { |
@@ -203,7 +205,9 @@
Loading
203 | 205 | return const_var(c_lhs | c_rhs); |
|
204 | 206 | case Operators::Opers::bitwise_xor: |
|
205 | 207 | return const_var(c_lhs ^ c_rhs); |
|
206 | - | } |
|
208 | + | default: |
|
209 | + | break; |
|
210 | + | } |
|
207 | 211 | } |
|
208 | 212 | ||
209 | 213 | if (t_lhs) { |
@@ -224,7 +228,9 @@
Loading
224 | 228 | case Operators::Opers::assign_difference: |
|
225 | 229 | *t_lhs -= c_rhs; |
|
226 | 230 | return t_bv; |
|
227 | - | } |
|
231 | + | default: |
|
232 | + | break; |
|
233 | + | } |
|
228 | 234 | ||
229 | 235 | if constexpr (!std::is_floating_point<LHS>::value && !std::is_floating_point<RHS>::value) { |
|
230 | 236 | switch (t_oper) { |
@@ -247,7 +253,9 @@
Loading
247 | 253 | case Operators::Opers::assign_bitwise_xor: |
|
248 | 254 | *t_lhs ^= c_rhs; |
|
249 | 255 | return t_bv; |
|
250 | - | } |
|
256 | + | default: |
|
257 | + | break; |
|
258 | + | } |
|
251 | 259 | } |
|
252 | 260 | } |
|
253 | 261 |
@@ -299,7 +307,9 @@
Loading
299 | 307 | case Operators::Opers::pre_decrement: |
|
300 | 308 | --(*lhs); |
|
301 | 309 | return t_lhs; |
|
302 | - | } |
|
310 | + | default: |
|
311 | + | break; |
|
312 | + | } |
|
303 | 313 | } |
|
304 | 314 | ||
305 | 315 | switch (t_oper) { |
@@ -307,13 +317,17 @@
Loading
307 | 317 | return const_var(-c_lhs); |
|
308 | 318 | case Operators::Opers::unary_plus: |
|
309 | 319 | return const_var(+c_lhs); |
|
310 | - | } |
|
320 | + | default: |
|
321 | + | break; |
|
322 | + | } |
|
311 | 323 | ||
312 | 324 | if constexpr (!std::is_floating_point_v<std::decay_t<decltype(c_lhs)>>) { |
|
313 | 325 | switch (t_oper) { |
|
314 | 326 | case Operators::Opers::bitwise_complement: |
|
315 | 327 | return const_var(~c_lhs); |
|
316 | - | } |
|
328 | + | default: |
|
329 | + | break; |
|
330 | + | } |
|
317 | 331 | } |
|
318 | 332 | ||
319 | 333 | throw chaiscript::detail::exception::bad_any_cast(); |
@@ -39,7 +39,7 @@
Loading
39 | 39 | { |
|
40 | 40 | } |
|
41 | 41 | ||
42 | - | Ret call(const Function_Params ¶ms, const Type_Conversions_State &t_state) |
|
42 | + | Ret call(const chaiscript::Function_Params ¶ms, const Type_Conversions_State &t_state) |
|
43 | 43 | { |
|
44 | 44 | if constexpr (std::is_arithmetic_v<Ret>) { |
|
45 | 45 | return Boxed_Number(dispatch::dispatch(m_funcs, params, t_state)).get_as<Ret>(); |
@@ -57,11 +57,11 @@
Loading
57 | 57 | ||
58 | 58 | if (m_conversions) { |
|
59 | 59 | Type_Conversions_State state(*m_conversions, m_conversions->conversion_saves()); |
|
60 | - | return call(Function_Params{params}, state); |
|
60 | + | return call(chaiscript::Function_Params{params}, state); |
|
61 | 61 | } else { |
|
62 | 62 | Type_Conversions conv; |
|
63 | 63 | Type_Conversions_State state(conv, conv.conversion_saves()); |
|
64 | - | return call(Function_Params{params}, state); |
|
64 | + | return call(chaiscript::Function_Params{params}, state); |
|
65 | 65 | } |
|
66 | 66 | ||
67 | 67 | } |
@@ -78,7 +78,7 @@
Loading
78 | 78 | */ |
|
79 | 79 | template<typename Ret, typename ... Params> |
|
80 | 80 | bool compare_types_cast(Ret (*)(Params...), |
|
81 | - | const Function_Params ¶ms, const Type_Conversions_State &t_conversions) noexcept |
|
81 | + | const chaiscript::Function_Params ¶ms, const Type_Conversions_State &t_conversions) noexcept |
|
82 | 82 | { |
|
83 | 83 | try { |
|
84 | 84 | std::vector<Boxed_Value>::size_type i = 0; |
@@ -93,7 +93,7 @@
Loading
93 | 93 | template<typename Callable, typename Ret, typename ... Params, size_t ... I> |
|
94 | 94 | Ret call_func(Ret (*)(Params...), |
|
95 | 95 | std::index_sequence<I...>, const Callable &f, |
|
96 | - | [[maybe_unused]] const Function_Params ¶ms, |
|
96 | + | [[maybe_unused]] const chaiscript::Function_Params ¶ms, |
|
97 | 97 | [[maybe_unused]] const Type_Conversions_State &t_conversions) |
|
98 | 98 | { |
|
99 | 99 | return f(boxed_cast<Params>(params[I], &t_conversions)...); |
@@ -106,7 +106,7 @@
Loading
106 | 106 | /// the bad_boxed_cast is passed up to the caller. |
|
107 | 107 | template<typename Callable, typename Ret, typename ... Params> |
|
108 | 108 | Boxed_Value call_func(Ret (*sig)(Params...), const Callable &f, |
|
109 | - | const Function_Params ¶ms, const Type_Conversions_State &t_conversions) |
|
109 | + | const chaiscript::Function_Params ¶ms, const Type_Conversions_State &t_conversions) |
|
110 | 110 | { |
|
111 | 111 | if constexpr (std::is_same_v<Ret, void>) { |
|
112 | 112 | call_func(sig, std::index_sequence_for<Params...>{}, f, params, t_conversions); |
@@ -4,121 +4,142 @@
Loading
4 | 4 | #include <type_traits> |
|
5 | 5 | ||
6 | 6 | namespace chaiscript::dispatch::detail { |
|
7 | - | template<typename ... Param> |
|
8 | - | struct Function_Params |
|
9 | - | { |
|
10 | - | }; |
|
11 | 7 | ||
12 | - | template<typename Ret, typename Params, bool IsNoExcept = false, bool IsMember = false, bool IsMemberObject = false, bool IsObject = false> |
|
13 | - | struct Function_Signature { |
|
14 | - | using Param_Types = Params; |
|
15 | - | using Return_Type = Ret; |
|
16 | - | constexpr static const bool is_object = IsObject; |
|
17 | - | constexpr static const bool is_member_object = IsMemberObject; |
|
18 | - | constexpr static const bool is_noexcept = IsNoExcept; |
|
19 | - | template<typename T> |
|
20 | - | constexpr Function_Signature(T &&) noexcept {} |
|
21 | - | constexpr Function_Signature() noexcept = default; |
|
22 | - | }; |
|
8 | + | template<typename... Param> |
|
9 | + | struct Function_Params |
|
10 | + | { |
|
11 | + | }; |
|
23 | 12 | ||
24 | - | // Free functions |
|
13 | + | template<typename Ret, typename Params, bool IsNoExcept = false, bool IsMember = false, bool IsMemberObject = false, bool IsObject = false> |
|
14 | + | struct Function_Signature |
|
15 | + | { |
|
16 | + | using Param_Types = Params; |
|
17 | + | using Return_Type = Ret; |
|
18 | + | constexpr static const bool is_object = IsObject; |
|
19 | + | constexpr static const bool is_member_object = IsMemberObject; |
|
20 | + | constexpr static const bool is_noexcept = IsNoExcept; |
|
21 | + | template<typename T> |
|
22 | + | constexpr Function_Signature(T &&) noexcept {} |
|
23 | + | constexpr Function_Signature() noexcept = default; |
|
24 | + | }; |
|
25 | 25 | ||
26 | - | template<typename Ret, typename ... Param> |
|
27 | - | Function_Signature(Ret (*f)(Param...)) -> Function_Signature<Ret, Function_Params<Param...>>; |
|
26 | + | // Free functions |
|
28 | 27 | ||
29 | - | template<typename Ret, typename ... Param> |
|
30 | - | Function_Signature(Ret (*f)(Param...) noexcept) -> Function_Signature<Ret, Function_Params<Param...>, true>; |
|
28 | + | template<typename Ret, typename... Param> |
|
29 | + | Function_Signature(Ret (*f)(Param...))->Function_Signature<Ret, Function_Params<Param...>>; |
|
31 | 30 | ||
32 | - | // no reference specifier |
|
31 | + | template<typename Ret, typename... Param> |
|
32 | + | Function_Signature(Ret (*f)(Param...) noexcept)->Function_Signature<Ret, Function_Params<Param...>, true>; |
|
33 | 33 | ||
34 | - | template<typename Ret, typename Class, typename ... Param> |
|
35 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile) -> Function_Signature<Ret, Function_Params<volatile Class &, Param...>, false, true>; |
|
34 | + | // no reference specifier |
|
36 | 35 | ||
37 | - | template<typename Ret, typename Class, typename ... Param> |
|
38 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile noexcept) -> Function_Signature<Ret, Function_Params<volatile Class &, Param...>, true, true>; |
|
36 | + | template<typename Ret, typename Class, typename... Param> |
|
37 | + | Function_Signature(Ret (Class::*f)(Param...) volatile)->Function_Signature<Ret, Function_Params<volatile Class &, Param...>, false, true>; |
|
39 | 38 | ||
40 | - | template<typename Ret, typename Class, typename ... Param> |
|
41 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile const) -> Function_Signature<Ret, Function_Params<volatile const Class &, Param...>, false, true>; |
|
39 | + | template<typename Ret, typename Class, typename... Param> |
|
40 | + | Function_Signature(Ret (Class::*f)(Param...) volatile noexcept)->Function_Signature<Ret, Function_Params<volatile Class &, Param...>, true, true>; |
|
42 | 41 | ||
43 | - | template<typename Ret, typename Class, typename ... Param> |
|
44 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile const noexcept) -> Function_Signature<Ret, Function_Params<volatile const Class &, Param...>, true, true>; |
|
42 | + | template<typename Ret, typename Class, typename... Param> |
|
43 | + | Function_Signature(Ret (Class::*f)(Param...) volatile const)->Function_Signature<Ret, Function_Params<volatile const Class &, Param...>, false, true>; |
|
45 | 44 | ||
46 | - | template<typename Ret, typename Class, typename ... Param> |
|
47 | - | Function_Signature(Ret (Class::*f)(Param ...) ) -> Function_Signature<Ret, Function_Params<Class &, Param...>, false, true>; |
|
45 | + | template<typename Ret, typename Class, typename... Param> |
|
46 | + | Function_Signature(Ret (Class::*f)(Param...) volatile const noexcept)->Function_Signature<Ret, Function_Params<volatile const Class &, Param...>, true, true>; |
|
48 | 47 | ||
49 | - | template<typename Ret, typename Class, typename ... Param> |
|
50 | - | Function_Signature(Ret (Class::*f)(Param ...) noexcept) -> Function_Signature<Ret, Function_Params<Class &, Param...>, true, true>; |
|
48 | + | template<typename Ret, typename Class, typename... Param> |
|
49 | + | Function_Signature(Ret (Class::*f)(Param...))->Function_Signature<Ret, Function_Params<Class &, Param...>, false, true>; |
|
51 | 50 | ||
52 | - | template<typename Ret, typename Class, typename ... Param> |
|
53 | - | Function_Signature(Ret (Class::*f)(Param ...) const) -> Function_Signature<Ret, Function_Params<const Class &, Param...>, false, true>; |
|
51 | + | template<typename Ret, typename Class, typename... Param> |
|
52 | + | Function_Signature(Ret (Class::*f)(Param...) noexcept)->Function_Signature<Ret, Function_Params<Class &, Param...>, true, true>; |
|
54 | 53 | ||
55 | - | template<typename Ret, typename Class, typename ... Param> |
|
56 | - | Function_Signature(Ret (Class::*f)(Param ...) const noexcept) -> Function_Signature<Ret, Function_Params<const Class &, Param...>, true, true>; |
|
54 | + | template<typename Ret, typename Class, typename... Param> |
|
55 | + | Function_Signature(Ret (Class::*f)(Param...) const)->Function_Signature<Ret, Function_Params<const Class &, Param...>, false, true>; |
|
57 | 56 | ||
58 | - | // & reference specifier |
|
57 | + | template<typename Ret, typename Class, typename... Param> |
|
58 | + | Function_Signature(Ret (Class::*f)(Param...) const noexcept)->Function_Signature<Ret, Function_Params<const Class &, Param...>, true, true>; |
|
59 | 59 | ||
60 | - | template<typename Ret, typename Class, typename ... Param> |
|
61 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile &) -> Function_Signature<Ret, Function_Params<volatile Class &, Param...>, false, true>; |
|
60 | + | // & reference specifier |
|
62 | 61 | ||
63 | - | template<typename Ret, typename Class, typename ... Param> |
|
64 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile & noexcept) -> Function_Signature<Ret, Function_Params<volatile Class &, Param...>, true, true>; |
|
62 | + | template<typename Ret, typename Class, typename... Param> |
|
63 | + | Function_Signature(Ret (Class::*f)(Param...) volatile &)->Function_Signature<Ret, Function_Params<volatile Class &, Param...>, false, true>; |
|
65 | 64 | ||
66 | - | template<typename Ret, typename Class, typename ... Param> |
|
67 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile const &) -> Function_Signature<Ret, Function_Params<volatile const Class &, Param...>, false, true>; |
|
65 | + | template<typename Ret, typename Class, typename... Param> |
|
66 | + | Function_Signature(Ret (Class::*f)(Param...) volatile &noexcept)->Function_Signature<Ret, Function_Params<volatile Class &, Param...>, true, true>; |
|
68 | 67 | ||
69 | - | template<typename Ret, typename Class, typename ... Param> |
|
70 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile const & noexcept) -> Function_Signature<Ret, Function_Params<volatile const Class &, Param...>, true, true>; |
|
68 | + | template<typename Ret, typename Class, typename... Param> |
|
69 | + | Function_Signature(Ret (Class::*f)(Param...) volatile const &)->Function_Signature<Ret, Function_Params<volatile const Class &, Param...>, false, true>; |
|
71 | 70 | ||
72 | - | template<typename Ret, typename Class, typename ... Param> |
|
73 | - | Function_Signature(Ret (Class::*f)(Param ...) & ) -> Function_Signature<Ret, Function_Params<Class &, Param...>, false, true>; |
|
71 | + | template<typename Ret, typename Class, typename... Param> |
|
72 | + | Function_Signature(Ret (Class::*f)(Param...) volatile const &noexcept)->Function_Signature<Ret, Function_Params<volatile const Class &, Param...>, true, true>; |
|
74 | 73 | ||
75 | - | template<typename Ret, typename Class, typename ... Param> |
|
76 | - | Function_Signature(Ret (Class::*f)(Param ...) & noexcept) -> Function_Signature<Ret, Function_Params<Class &, Param...>, true, true>; |
|
74 | + | template<typename Ret, typename Class, typename... Param> |
|
75 | + | Function_Signature(Ret (Class::*f)(Param...) &)->Function_Signature<Ret, Function_Params<Class &, Param...>, false, true>; |
|
77 | 76 | ||
78 | - | template<typename Ret, typename Class, typename ... Param> |
|
79 | - | Function_Signature(Ret (Class::*f)(Param ...) const &) -> Function_Signature<Ret, Function_Params<const Class &, Param...>, false, true>; |
|
77 | + | template<typename Ret, typename Class, typename... Param> |
|
78 | + | Function_Signature(Ret (Class::*f)(Param...) & noexcept)->Function_Signature<Ret, Function_Params<Class &, Param...>, true, true>; |
|
80 | 79 | ||
81 | - | template<typename Ret, typename Class, typename ... Param> |
|
82 | - | Function_Signature(Ret (Class::*f)(Param ...) const & noexcept) -> Function_Signature<Ret, Function_Params<const Class &, Param...>, true, true>; |
|
80 | + | template<typename Ret, typename Class, typename... Param> |
|
81 | + | Function_Signature(Ret (Class::*f)(Param...) const &)->Function_Signature<Ret, Function_Params<const Class &, Param...>, false, true>; |
|
83 | 82 | ||
84 | - | // && reference specifier |
|
83 | + | template<typename Ret, typename Class, typename... Param> |
|
84 | + | Function_Signature(Ret (Class::*f)(Param...) const &noexcept)->Function_Signature<Ret, Function_Params<const Class &, Param...>, true, true>; |
|
85 | 85 | ||
86 | - | template<typename Ret, typename Class, typename ... Param> |
|
87 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile &&) -> Function_Signature<Ret, Function_Params<volatile Class &&, Param...>, false, true>; |
|
86 | + | // && reference specifier |
|
88 | 87 | ||
89 | - | template<typename Ret, typename Class, typename ... Param> |
|
90 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile && noexcept) -> Function_Signature<Ret, Function_Params<volatile Class &&, Param...>, true, true>; |
|
88 | + | template<typename Ret, typename Class, typename... Param> |
|
89 | + | Function_Signature(Ret (Class::*f)(Param...) volatile &&)->Function_Signature<Ret, Function_Params<volatile Class &&, Param...>, false, true>; |
|
91 | 90 | ||
92 | - | template<typename Ret, typename Class, typename ... Param> |
|
93 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile const &&) -> Function_Signature<Ret, Function_Params<volatile const Class &&, Param...>, false, true>; |
|
91 | + | template<typename Ret, typename Class, typename... Param> |
|
92 | + | Function_Signature(Ret (Class::*f)(Param...) volatile &&noexcept)->Function_Signature<Ret, Function_Params<volatile Class &&, Param...>, true, true>; |
|
94 | 93 | ||
95 | - | template<typename Ret, typename Class, typename ... Param> |
|
96 | - | Function_Signature(Ret (Class::*f)(Param ...) volatile const && noexcept) -> Function_Signature<Ret, Function_Params<volatile const Class &&, Param...>, true, true>; |
|
94 | + | template<typename Ret, typename Class, typename... Param> |
|
95 | + | Function_Signature(Ret (Class::*f)(Param...) volatile const &&)->Function_Signature<Ret, Function_Params<volatile const Class &&, Param...>, false, true>; |
|
97 | 96 | ||
98 | - | template<typename Ret, typename Class, typename ... Param> |
|
99 | - | Function_Signature(Ret (Class::*f)(Param ...) &&) -> Function_Signature<Ret, Function_Params<Class &&, Param...>, false, true>; |
|
97 | + | template<typename Ret, typename Class, typename... Param> |
|
98 | + | Function_Signature(Ret (Class::*f)(Param...) volatile const &&noexcept)->Function_Signature<Ret, Function_Params<volatile const Class &&, Param...>, true, true>; |
|
100 | 99 | ||
101 | - | template<typename Ret, typename Class, typename ... Param> |
|
102 | - | Function_Signature(Ret (Class::*f)(Param ...) && noexcept) -> Function_Signature<Ret, Function_Params<Class &&, Param...>, true, true>; |
|
100 | + | template<typename Ret, typename Class, typename... Param> |
|
101 | + | Function_Signature(Ret (Class::*f)(Param...) &&)->Function_Signature<Ret, Function_Params<Class &&, Param...>, false, true>; |
|
103 | 102 | ||
104 | - | template<typename Ret, typename Class, typename ... Param> |
|
105 | - | Function_Signature(Ret (Class::*f)(Param ...) const &&) -> Function_Signature<Ret, Function_Params<const Class &&, Param...>, false, true>; |
|
103 | + | template<typename Ret, typename Class, typename... Param> |
|
104 | + | Function_Signature(Ret (Class::*f)(Param...) && noexcept)->Function_Signature<Ret, Function_Params<Class &&, Param...>, true, true>; |
|
106 | 105 | ||
107 | - | template<typename Ret, typename Class, typename ... Param> |
|
108 | - | Function_Signature(Ret (Class::*f)(Param ...) const && noexcept) -> Function_Signature<Ret, Function_Params<const Class &&, Param...>, true, true>; |
|
106 | + | template<typename Ret, typename Class, typename... Param> |
|
107 | + | Function_Signature(Ret (Class::*f)(Param...) const &&)->Function_Signature<Ret, Function_Params<const Class &&, Param...>, false, true>; |
|
109 | 108 | ||
110 | - | template<typename Ret, typename Class> |
|
111 | - | Function_Signature(Ret (Class::*f)) -> Function_Signature<Ret, Function_Params<Class &>, true, true, true>; |
|
109 | + | template<typename Ret, typename Class, typename... Param> |
|
110 | + | Function_Signature(Ret (Class::*f)(Param...) const &&noexcept)->Function_Signature<Ret, Function_Params<const Class &&, Param...>, true, true>; |
|
112 | 111 | ||
113 | - | template<typename Func> |
|
114 | - | Function_Signature(Func &&) -> Function_Signature< |
|
115 | - | typename decltype(Function_Signature{&std::decay_t<Func>::operator()})::Return_Type, |
|
116 | - | typename decltype(Function_Signature{&std::decay_t<Func>::operator()})::Param_Types, |
|
117 | - | decltype(Function_Signature{&std::decay_t<Func>::operator()})::is_noexcept, |
|
118 | - | false, |
|
119 | - | false, |
|
120 | - | true |
|
121 | - | >; |
|
112 | + | template<typename Ret, typename Class> |
|
113 | + | Function_Signature(Ret(Class::*f))->Function_Signature<Ret, Function_Params<Class &>, true, true, true>; |
|
114 | + | ||
115 | + | // primary template handles types that have no nested ::type member: |
|
116 | + | template<class, class = std::void_t<>> |
|
117 | + | struct has_call_operator : std::false_type |
|
118 | + | { |
|
119 | + | }; |
|
120 | + | ||
121 | + | // specialization recognizes types that do have a nested ::type member: |
|
122 | + | template<class T> |
|
123 | + | struct has_call_operator<T, std::void_t<decltype(&T::operator())>> : std::true_type |
|
124 | + | { |
|
125 | + | }; |
|
126 | + | ||
127 | + | template<typename Func> |
|
128 | + | auto function_signature(const Func &f) |
|
129 | + | { |
|
130 | + | if constexpr (has_call_operator<Func>::value) { |
|
131 | + | return Function_Signature< |
|
132 | + | typename decltype(Function_Signature{ &std::decay_t<Func>::operator() })::Return_Type, |
|
133 | + | typename decltype(Function_Signature{ &std::decay_t<Func>::operator() })::Param_Types, |
|
134 | + | decltype(Function_Signature{ &std::decay_t<Func>::operator() })::is_noexcept, |
|
135 | + | false, |
|
136 | + | false, |
|
137 | + | true>{}; |
|
138 | + | } else { |
|
139 | + | return Function_Signature{ f }; |
|
140 | + | } |
|
122 | 141 | } |
|
123 | 142 | ||
143 | + | }// namespace chaiscript::dispatch::detail |
|
144 | + | ||
124 | 145 | #endif |
@@ -30,13 +30,13 @@
Loading
30 | 30 | } |
|
31 | 31 | ||
32 | 32 | explicit Function_Params(const std::vector<Boxed_Value> &vec) |
|
33 | - | : m_begin(&vec.front()), m_end(&vec.front() + vec.size()) |
|
33 | + | : m_begin(vec.empty() ? nullptr : &vec.front()), m_end(vec.empty() ? nullptr : &vec.front() + vec.size()) |
|
34 | 34 | { |
|
35 | 35 | } |
|
36 | 36 | ||
37 | 37 | template<size_t Size> |
|
38 | 38 | constexpr explicit Function_Params(const std::array<Boxed_Value, Size> &a) |
|
39 | - | : m_begin(std::begin(a)), m_end(std::end(a)) |
|
39 | + | : m_begin(&a.front()), m_end(&a.front() + Size) |
|
40 | 40 | { |
|
41 | 41 | } |
|
42 | 42 |
@@ -74,6 +74,13 @@
Loading
74 | 74 | ||
75 | 75 | }; |
|
76 | 76 | ||
77 | + | // Constructor specialization for array of size 0 |
|
78 | + | template<> |
|
79 | + | constexpr Function_Params::Function_Params(const std::array<Boxed_Value, size_t{0}> & /* a */) |
|
80 | + | : m_begin(nullptr), m_end(nullptr) |
|
81 | + | { |
|
82 | + | } |
|
83 | + | ||
77 | 84 | } |
|
78 | 85 | ||
79 | 86 |
@@ -77,7 +77,7 @@
Loading
77 | 77 | std::vector<Boxed_Value> convert(Function_Params t_params, const Type_Conversions_State &t_conversions) const |
|
78 | 78 | { |
|
79 | 79 | auto vals = t_params.to_vector(); |
|
80 | - | constexpr auto dynamic_object_type_info = user_type<Dynamic_Object>(); |
|
80 | + | const auto dynamic_object_type_info = user_type<Dynamic_Object>(); |
|
81 | 81 | for (size_t i = 0; i < vals.size(); ++i) |
|
82 | 82 | { |
|
83 | 83 | const auto &name = m_types[i].first; |
@@ -117,7 +117,7 @@
Loading
117 | 117 | // second result: needs conversions |
|
118 | 118 | std::pair<bool, bool> match(const Function_Params &vals, const Type_Conversions_State &t_conversions) const noexcept |
|
119 | 119 | { |
|
120 | - | constexpr auto dynamic_object_type_info = user_type<Dynamic_Object>(); |
|
120 | + | const auto dynamic_object_type_info = user_type<Dynamic_Object>(); |
|
121 | 121 | bool needs_conversion = false; |
|
122 | 122 | ||
123 | 123 | if (!m_has_types) { return std::make_pair(true, needs_conversion); } |
@@ -252,9 +252,9 @@
Loading
252 | 252 | ||
253 | 253 | static bool compare_type_to_param(const Type_Info &ti, const Boxed_Value &bv, const Type_Conversions_State &t_conversions) noexcept |
|
254 | 254 | { |
|
255 | - | constexpr auto boxed_value_ti = user_type<Boxed_Value>(); |
|
256 | - | constexpr auto boxed_number_ti = user_type<Boxed_Number>(); |
|
257 | - | constexpr auto function_ti = user_type<std::shared_ptr<const Proxy_Function_Base>>(); |
|
255 | + | const auto boxed_value_ti = user_type<Boxed_Value>(); |
|
256 | + | const auto boxed_number_ti = user_type<Boxed_Number>(); |
|
257 | + | const auto function_ti = user_type<std::shared_ptr<const Proxy_Function_Base>>(); |
|
258 | 258 | ||
259 | 259 | if (ti.is_undef() |
|
260 | 260 | || ti.bare_equal(boxed_value_ti) |
@@ -757,7 +757,7 @@
Loading
757 | 757 | { |
|
758 | 758 | return false; |
|
759 | 759 | } |
|
760 | - | constexpr auto class_type_info = user_type<Class>(); |
|
760 | + | const auto class_type_info = user_type<Class>(); |
|
761 | 761 | return vals[0].get_type_info().bare_equal(class_type_info); |
|
762 | 762 | } |
|
763 | 763 |
@@ -844,7 +844,7 @@
Loading
844 | 844 | namespace detail |
|
845 | 845 | { |
|
846 | 846 | template<typename FuncType> |
|
847 | - | bool types_match_except_for_arithmetic(const FuncType &t_func, const Function_Params &plist, |
|
847 | + | bool types_match_except_for_arithmetic(const FuncType &t_func, const chaiscript::Function_Params &plist, |
|
848 | 848 | const Type_Conversions_State &t_conversions) noexcept |
|
849 | 849 | { |
|
850 | 850 | const std::vector<Type_Info> &types = t_func->get_param_types(); |
@@ -863,7 +863,7 @@
Loading
863 | 863 | } |
|
864 | 864 | ||
865 | 865 | template<typename InItr, typename Funcs> |
|
866 | - | Boxed_Value dispatch_with_conversions(InItr begin, const InItr &end, const Function_Params &plist, |
|
866 | + | Boxed_Value dispatch_with_conversions(InItr begin, const InItr &end, const chaiscript::Function_Params &plist, |
|
867 | 867 | const Type_Conversions_State &t_conversions, const Funcs &t_funcs) |
|
868 | 868 | { |
|
869 | 869 | InItr matching_func(end); |
@@ -919,7 +919,7 @@
Loading
919 | 919 | ); |
|
920 | 920 | ||
921 | 921 | try { |
|
922 | - | return (*(matching_func->second))(Function_Params{newplist}, t_conversions); |
|
922 | + | return (*(matching_func->second))(chaiscript::Function_Params{newplist}, t_conversions); |
|
923 | 923 | } catch (const exception::bad_boxed_cast &) { |
|
924 | 924 | //parameter failed to cast |
|
925 | 925 | } catch (const exception::arity_error &) { |
@@ -1303,8 +1303,8 @@
Loading
1303 | 1303 | const auto lhssize = lhsparamtypes.size(); |
|
1304 | 1304 | const auto rhssize = rhsparamtypes.size(); |
|
1305 | 1305 | ||
1306 | - | constexpr const auto boxed_type = user_type<Boxed_Value>(); |
|
1307 | - | constexpr const auto boxed_pod_type = user_type<Boxed_Number>(); |
|
1306 | + | const auto boxed_type = user_type<Boxed_Value>(); |
|
1307 | + | const auto boxed_pod_type = user_type<Boxed_Number>(); |
|
1308 | 1308 | ||
1309 | 1309 | for (size_t i = 1; i < lhssize && i < rhssize; ++i) |
|
1310 | 1310 | { |
Files | Coverage |
---|---|
include/chaiscript | 90.93% |
src | 72.79% |
static_libs | 100.00% |
unittests | 45.97% |
Project Totals (60 files) | 69.78% |
1168.3
TRAVIS_OS_NAME=linux
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.