| 18318 | |
| 18319 | template <bool is_yielding, typename Fx, typename... Args> |
| 18320 | void select_member_variable(lua_State* L, Fx&& fx, Args&&... args) { |
| 18321 | using uFx = meta::unqualified_t<Fx>; |
| 18322 | if constexpr (sizeof...(Args) < 1) { |
| 18323 | using C = typename meta::bind_traits<uFx>::object_type; |
| 18324 | lua_CFunction freefunc = &function_detail::upvalue_this_member_variable<C, Fx, is_yielding>::call; |
| 18325 | |
| 18326 | int upvalues = 0; |
| 18327 | upvalues += stack::push(L, nullptr); |
| 18328 | upvalues += stack::stack_detail::push_as_upvalues(L, fx); |
| 18329 | stack::push(L, c_closure(freefunc, upvalues)); |
| 18330 | } |
| 18331 | else if constexpr (sizeof...(Args) < 2) { |
| 18332 | using Tu = typename meta::meta_detail::unqualified_non_alias<Args...>::type; |
| 18333 | constexpr bool is_reference = meta::is_specialization_of_v<Tu, std::reference_wrapper> || std::is_pointer_v<Tu>; |
| 18334 | if constexpr (meta::is_specialization_of_v<Tu, function_detail::class_indicator>) { |
| 18335 | lua_CFunction freefunc = &function_detail::upvalue_this_member_variable<typename Tu::type, Fx, is_yielding>::call; |
| 18336 | |
| 18337 | int upvalues = 0; |
| 18338 | upvalues += stack::push(L, nullptr); |
| 18339 | upvalues += stack::stack_detail::push_as_upvalues(L, fx); |
| 18340 | stack::push(L, c_closure(freefunc, upvalues)); |
| 18341 | } |
| 18342 | else if constexpr (is_reference) { |
| 18343 | typedef std::decay_t<Fx> dFx; |
| 18344 | dFx memfxptr(std::forward<Fx>(fx)); |
| 18345 | auto userptr = detail::ptr(std::forward<Args>(args)...); |
| 18346 | lua_CFunction freefunc |
| 18347 | = &function_detail::upvalue_member_variable<std::decay_t<decltype(*userptr)>, meta::unqualified_t<Fx>, is_yielding>::call; |
| 18348 | |
| 18349 | int upvalues = 0; |
| 18350 | upvalues += stack::push(L, nullptr); |
| 18351 | upvalues += stack::stack_detail::push_as_upvalues(L, memfxptr); |
| 18352 | upvalues += stack::push(L, static_cast<void const*>(userptr)); |
| 18353 | stack::push(L, c_closure(freefunc, upvalues)); |
| 18354 | } |
| 18355 | else { |
| 18356 | using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>; |
| 18357 | using F = function_detail::member_variable<Tu, clean_fx, is_yielding>; |
| 18358 | select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...); |
| 18359 | } |
| 18360 | } |
| 18361 | else { |
| 18362 | using C = typename meta::bind_traits<uFx>::object_type; |
| 18363 | using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>; |
| 18364 | using F = function_detail::member_variable<C, clean_fx, is_yielding>; |
| 18365 | select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...); |
| 18366 | } |
| 18367 | } |
| 18368 | |
| 18369 | template <bool is_yielding, typename Fx, typename T, typename... Args> |
| 18370 | void select_member_function_with(lua_State* L, Fx&& fx, T&& obj, Args&&... args) { |
nothing calls this directly
no test coverage detected