| 293 | struct unqualified_pusher { |
| 294 | template <typename... Args> |
| 295 | static int push(lua_State* L, Args&&... args) { |
| 296 | using Tu = meta::unqualified_t<T>; |
| 297 | if constexpr (is_lua_reference_v<Tu>) { |
| 298 | using int_arr = int[]; |
| 299 | int_arr p { (std::forward<Args>(args).push(L))... }; |
| 300 | return p[0]; |
| 301 | } |
| 302 | else if constexpr (std::is_same_v<Tu, bool>) { |
| 303 | #if SOL_IS_ON(SOL_SAFE_STACK_CHECK) |
| 304 | luaL_checkstack(L, 1, detail::not_enough_stack_space_generic); |
| 305 | #endif // make sure stack doesn't overflow |
| 306 | lua_pushboolean(L, std::forward<Args>(args)...); |
| 307 | return 1; |
| 308 | } |
| 309 | else if constexpr (std::is_integral_v<Tu> || std::is_same_v<Tu, lua_Integer>) { |
| 310 | const Tu& value(std::forward<Args>(args)...); |
| 311 | #if SOL_IS_ON(SOL_SAFE_STACK_CHECK) |
| 312 | luaL_checkstack(L, 1, detail::not_enough_stack_space_integral); |
| 313 | #endif // make sure stack doesn't overflow |
| 314 | #if SOL_LUA_VERSION_I_ >= 503 |
| 315 | if (stack_detail::integer_value_fits<Tu>(value)) { |
| 316 | lua_pushinteger(L, static_cast<lua_Integer>(value)); |
| 317 | return 1; |
| 318 | } |
| 319 | #endif // Lua 5.3 and above |
| 320 | #if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS) |
| 321 | if (static_cast<T>(llround(static_cast<lua_Number>(value))) != value) { |
| 322 | #if SOL_IS_OFF(SOL_EXCEPTIONS) |
| 323 | // Is this really worth it? |
| 324 | SOL_ASSERT_MSG(false, "integer value will be misrepresented in lua"); |
| 325 | lua_pushinteger(L, static_cast<lua_Integer>(value)); |
| 326 | return 1; |
| 327 | #else |
| 328 | throw error(detail::direct_error, "integer value will be misrepresented in lua"); |
| 329 | #endif // No Exceptions |
| 330 | } |
| 331 | #endif // Safe Numerics and Number Precision Check |
| 332 | lua_pushnumber(L, static_cast<lua_Number>(value)); |
| 333 | return 1; |
| 334 | } |
| 335 | else if constexpr (std::is_floating_point_v<Tu> || std::is_same_v<Tu, lua_Number>) { |
| 336 | #if SOL_IS_ON(SOL_SAFE_STACK_CHECK) |
| 337 | luaL_checkstack(L, 1, detail::not_enough_stack_space_floating); |
| 338 | #endif // make sure stack doesn't overflow |
| 339 | lua_pushnumber(L, std::forward<Args>(args)...); |
| 340 | return 1; |
| 341 | } |
| 342 | else if constexpr (std::is_same_v<Tu, luaL_Stream*>) { |
| 343 | luaL_Stream* source { std::forward<Args>(args)... }; |
| 344 | luaL_Stream* stream = static_cast<luaL_Stream*>(detail::alloc_newuserdata(L, sizeof(luaL_Stream))); |
| 345 | stream->f = source->f; |
| 346 | #if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION) |
| 347 | stream->closef = source->closef; |
| 348 | #endif // LuaJIT and Lua 5.1 and below do not have |
| 349 | return 1; |
| 350 | } |
| 351 | else if constexpr (std::is_same_v<Tu, luaL_Stream>) { |
| 352 | luaL_Stream& source(std::forward<Args>(args)...); |
nothing calls this directly
no test coverage detected