| 17600 | |
| 17601 | template <bool is_yielding, typename Fx, typename... Args> |
| 17602 | void select_member_variable(lua_State* L, Fx&& fx, Args&&... args) { |
| 17603 | using uFx = meta::unqualified_t<Fx>; |
| 17604 | if constexpr (sizeof...(Args) < 1) { |
| 17605 | using C = typename meta::bind_traits<uFx>::object_type; |
| 17606 | lua_CFunction freefunc = &function_detail::upvalue_this_member_variable<C, Fx, is_yielding>::call; |
| 17607 | |
| 17608 | int upvalues = 0; |
| 17609 | upvalues += stack::push(L, nullptr); |
| 17610 | upvalues += stack::stack_detail::push_as_upvalues(L, fx); |
| 17611 | stack::push(L, c_closure(freefunc, upvalues)); |
| 17612 | } |
| 17613 | else if constexpr (sizeof...(Args) < 2) { |
| 17614 | using Tu = typename meta::meta_detail::unqualified_non_alias<Args...>::type; |
| 17615 | constexpr bool is_reference = meta::is_specialization_of_v<Tu, std::reference_wrapper> || std::is_pointer_v<Tu>; |
| 17616 | if constexpr (meta::is_specialization_of_v<Tu, function_detail::class_indicator>) { |
| 17617 | lua_CFunction freefunc = &function_detail::upvalue_this_member_variable<typename Tu::type, Fx, is_yielding>::call; |
| 17618 | |
| 17619 | int upvalues = 0; |
| 17620 | upvalues += stack::push(L, nullptr); |
| 17621 | upvalues += stack::stack_detail::push_as_upvalues(L, fx); |
| 17622 | stack::push(L, c_closure(freefunc, upvalues)); |
| 17623 | } |
| 17624 | else if constexpr (is_reference) { |
| 17625 | typedef std::decay_t<Fx> dFx; |
| 17626 | dFx memfxptr(std::forward<Fx>(fx)); |
| 17627 | auto userptr = detail::ptr(std::forward<Args>(args)...); |
| 17628 | lua_CFunction freefunc |
| 17629 | = &function_detail::upvalue_member_variable<std::decay_t<decltype(*userptr)>, meta::unqualified_t<Fx>, is_yielding>::call; |
| 17630 | |
| 17631 | int upvalues = 0; |
| 17632 | upvalues += stack::push(L, nullptr); |
| 17633 | upvalues += stack::stack_detail::push_as_upvalues(L, memfxptr); |
| 17634 | upvalues += stack::push(L, static_cast<void const*>(userptr)); |
| 17635 | stack::push(L, c_closure(freefunc, upvalues)); |
| 17636 | } |
| 17637 | else { |
| 17638 | using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>; |
| 17639 | using F = function_detail::member_variable<Tu, clean_fx, is_yielding>; |
| 17640 | select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...); |
| 17641 | } |
| 17642 | } |
| 17643 | else { |
| 17644 | using C = typename meta::bind_traits<uFx>::object_type; |
| 17645 | using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>; |
| 17646 | using F = function_detail::member_variable<C, clean_fx, is_yielding>; |
| 17647 | select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...); |
| 17648 | } |
| 17649 | } |
| 17650 | |
| 17651 | template <bool is_yielding, typename Fx, typename T, typename... Args> |
| 17652 | void select_member_function_with(lua_State* L, Fx&& fx, T&& obj, Args&&... args) { |
nothing calls this directly
no test coverage detected