| 16395 | struct lua_call_wrapper { |
| 16396 | template <typename Fx, typename... Args> |
| 16397 | static int call(lua_State* L, Fx&& fx, Args&&... args) { |
| 16398 | if constexpr (std::is_member_function_pointer_v<F>) { |
| 16399 | using wrap = wrapper<F>; |
| 16400 | using object_type = typename wrap::object_type; |
| 16401 | if constexpr (sizeof...(Args) < 1) { |
| 16402 | using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>; |
| 16403 | static_assert(std::is_base_of_v<object_type, Ta>, "It seems like you might have accidentally bound a class type with a member function method that does not correspond to the class. For example, there could be a small type in your new_usertype<T>(...) binding, where you specify one class \"T\" but then bind member methods from a complete unrelated class. Check things over!"); |
| 16404 | #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE |
| 16405 | auto maybeo = stack::check_get<Ta*>(L, 1); |
| 16406 | if (!maybeo || maybeo.value() == nullptr) { |
| 16407 | return luaL_error(L, |
| 16408 | "sol: received nil for 'self' argument (use ':' for accessing member functions, make sure member variables are " |
| 16409 | "preceeded by the " |
| 16410 | "actual object with '.' syntax)"); |
| 16411 | } |
| 16412 | object_type* o = static_cast<object_type*>(maybeo.value()); |
| 16413 | return call(L, std::forward<Fx>(fx), *o); |
| 16414 | #else |
| 16415 | object_type& o = static_cast<object_type&>(*stack::unqualified_get<non_null<Ta*>>(L, 1)); |
| 16416 | return call(L, std::forward<Fx>(fx), o); |
| 16417 | #endif // Safety |
| 16418 | } |
| 16419 | else { |
| 16420 | using returns_list = typename wrap::returns_list; |
| 16421 | using args_list = typename wrap::args_list; |
| 16422 | using caller = typename wrap::caller; |
| 16423 | return stack::call_into_lua<checked, clean_stack>( |
| 16424 | returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), std::forward<Fx>(fx), std::forward<Args>(args)...); |
| 16425 | } |
| 16426 | } |
| 16427 | else if constexpr (std::is_member_object_pointer_v<F>) { |
| 16428 | using wrap = wrapper<F>; |
| 16429 | using object_type = typename wrap::object_type; |
| 16430 | if constexpr (is_index) { |
| 16431 | if constexpr (sizeof...(Args) < 1) { |
| 16432 | using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>; |
| 16433 | static_assert(std::is_base_of_v<object_type, Ta>, "It seems like you might have accidentally bound a class type with a member function method that does not correspond to the class. For example, there could be a small type in your new_usertype<T>(...) binding, where you specify one class \"T\" but then bind member methods from a complete unrelated class. Check things over!"); |
| 16434 | #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE |
| 16435 | auto maybeo = stack::check_get<Ta*>(L, 1); |
| 16436 | if (!maybeo || maybeo.value() == nullptr) { |
| 16437 | if (is_variable) { |
| 16438 | return luaL_error(L, "sol: 'self' argument is lua_nil (bad '.' access?)"); |
| 16439 | } |
| 16440 | return luaL_error(L, "sol: 'self' argument is lua_nil (pass 'self' as first argument)"); |
| 16441 | } |
| 16442 | object_type* o = static_cast<object_type*>(maybeo.value()); |
| 16443 | return call(L, std::forward<Fx>(fx), *o); |
| 16444 | #else |
| 16445 | object_type& o = static_cast<object_type&>(*stack::get<non_null<Ta*>>(L, 1)); |
| 16446 | return call(L, std::forward<Fx>(fx), o); |
| 16447 | #endif // Safety |
| 16448 | } |
| 16449 | else { |
| 16450 | using returns_list = typename wrap::returns_list; |
| 16451 | using caller = typename wrap::caller; |
| 16452 | return stack::call_into_lua<checked, clean_stack>(returns_list(), |
| 16453 | types<>(), |
| 16454 | L, |
nothing calls this directly
no test coverage detected