| 17700 | |
| 17701 | template <bool is_yielding, typename Fx, typename... Args> |
| 17702 | void select(lua_State* L, Fx&& fx, Args&&... args) { |
| 17703 | using uFx = meta::unqualified_t<Fx>; |
| 17704 | if constexpr (is_lua_reference_v<uFx>) { |
| 17705 | // TODO: hoist into lambda in this case for yielding??? |
| 17706 | stack::push(L, std::forward<Fx>(fx), std::forward<Args>(args)...); |
| 17707 | } |
| 17708 | else if constexpr (is_lua_c_function_v<uFx>) { |
| 17709 | int upvalues = 0; |
| 17710 | upvalues += stack::push(L, nullptr); |
| 17711 | upvalues += stack::push(L, std::forward<Fx>(fx)); |
| 17712 | #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE |
| 17713 | if constexpr (std::is_nothrow_invocable_r_v<int, uFx, lua_State*>) { |
| 17714 | detail::lua_CFunction_noexcept cf = &lua_c_noexcept_wrapper<is_yielding>; |
| 17715 | lua_pushcclosure(L, reinterpret_cast<lua_CFunction>(cf), 2); |
| 17716 | } |
| 17717 | else { |
| 17718 | lua_CFunction cf = &lua_c_wrapper<is_yielding>; |
| 17719 | lua_pushcclosure(L, cf, 2); |
| 17720 | } |
| 17721 | #else |
| 17722 | lua_CFunction cf = &function_detail::lua_c_wrapper<is_yielding>; |
| 17723 | lua_pushcclosure(L, cf, 2); |
| 17724 | #endif |
| 17725 | } |
| 17726 | else if constexpr (std::is_function_v<std::remove_pointer_t<uFx>>) { |
| 17727 | std::decay_t<Fx> target(std::forward<Fx>(fx), std::forward<Args>(args)...); |
| 17728 | lua_CFunction freefunc = &function_detail::upvalue_free_function<Fx, is_yielding>::call; |
| 17729 | |
| 17730 | int upvalues = 0; |
| 17731 | upvalues += stack::push(L, nullptr); |
| 17732 | upvalues += stack::stack_detail::push_as_upvalues(L, target); |
| 17733 | stack::push(L, c_closure(freefunc, upvalues)); |
| 17734 | } |
| 17735 | else if constexpr (std::is_member_function_pointer_v<uFx>) { |
| 17736 | select_member_function<is_yielding>(L, std::forward<Fx>(fx), std::forward<Args>(args)...); |
| 17737 | } |
| 17738 | else if constexpr (meta::is_member_object_v<uFx>) { |
| 17739 | select_member_variable<is_yielding>(L, std::forward<Fx>(fx), std::forward<Args>(args)...); |
| 17740 | } |
| 17741 | else { |
| 17742 | select_convertible<is_yielding>(types<>(), L, std::forward<Fx>(fx), std::forward<Args>(args)...); |
| 17743 | } |
| 17744 | } |
| 17745 | } // namespace function_detail |
| 17746 | |
| 17747 | namespace stack { |
nothing calls this directly
no test coverage detected