27 #ifndef SOL_SINGLE_INCLUDE_HPP 28 #define SOL_SINGLE_INCLUDE_HPP 41 #define SOL_VERSION_MAJOR 3 42 #define SOL_VERSION_MINOR 5 43 #define SOL_VERSION_PATCH 0 44 #define SOL_VERSION_STRING "3.5.0" 45 #define SOL_VERSION ((SOL_VERSION_MAJOR * 100000) + (SOL_VERSION_MINOR * 100) + (SOL_VERSION_PATCH)) 47 #define SOL_IS_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) != 0) 48 #define SOL_IS_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3) == 0) 49 #define SOL_IS_DEFAULT_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) > 3) 50 #define SOL_IS_DEFAULT_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3 OP_SYMBOL 3) < 0) 54 #define SOL_DEFAULT_ON + 55 #define SOL_DEFAULT_OFF - 58 #define SOL_COMPILER_CLANG_I_ SOL_OFF 59 #define SOL_COMPILER_GCC_I_ SOL_OFF 60 #define SOL_COMPILER_EDG_I_ SOL_OFF 61 #define SOL_COMPILER_VCXX_I_ SOL_ON 62 #elif defined(__clang__) 63 #define SOL_COMPILER_CLANG_I_ SOL_ON 64 #define SOL_COMPILER_GCC_I_ SOL_OFF 65 #define SOL_COMPILER_EDG_I_ SOL_OFF 66 #define SOL_COMPILER_VCXX_I_ SOL_OFF 67 #elif defined(__GNUC__) 68 #define SOL_COMPILER_CLANG_I_ SOL_OFF 69 #define SOL_COMPILER_GCC_I_ SOL_ON 70 #define SOL_COMPILER_EDG_I_ SOL_OFF 71 #define SOL_COMPILER_VCXX_I_ SOL_OFF 73 #define SOL_COMPILER_CLANG_I_ SOL_OFF 74 #define SOL_COMPILER_GCC_I_ SOL_OFF 75 #define SOL_COMPILER_EDG_I_ SOL_OFF 76 #define SOL_COMPILER_VCXX_I_ SOL_OFF 79 #if defined(__MINGW32__) 80 #define SOL_COMPILER_FRONTEND_MINGW_I_ SOL_ON 82 #define SOL_COMPILER_FRONTEND_MINGW_I_ SOL_OFF 85 #if SIZE_MAX <= 0xFFFFULL 86 #define SOL_PLATFORM_X16_I_ SOL_ON 87 #define SOL_PLATFORM_X86_I_ SOL_OFF 88 #define SOL_PLATFORM_X64_I_ SOL_OFF 89 #elif SIZE_MAX <= 0xFFFFFFFFULL 90 #define SOL_PLATFORM_X16_I_ SOL_OFF 91 #define SOL_PLATFORM_X86_I_ SOL_ON 92 #define SOL_PLATFORM_X64_I_ SOL_OFF 94 #define SOL_PLATFORM_X16_I_ SOL_OFF 95 #define SOL_PLATFORM_X86_I_ SOL_OFF 96 #define SOL_PLATFORM_X64_I_ SOL_ON 99 #define SOL_PLATFORM_ARM32_I_ SOL_OFF 100 #define SOL_PLATFORM_ARM64_I_ SOL_OFF 103 #define SOL_PLATFORM_WINDOWS_I_ SOL_ON 105 #define SOL_PLATFORM_WINDOWS_I_ SOL_OFF 107 #if defined(__APPLE__) 108 #define SOL_PLATFORM_APPLE_I_ SOL_ON 110 #define SOL_PLATFORM_APPLE_I_ SOL_OFF 112 #if defined(__unix__) 113 #define SOL_PLATFORM_UNIXLIKE_I_ SOL_ON 115 #define SOL_PLATFORM_UNIXLIKE_I_ SOL_OFF 117 #if defined(__linux__) 118 #define SOL_PLATFORM_LINUXLIKE_I_ SOL_ON 120 #define SOL_PLATFORM_LINUXLIKE_I_ SOL_OFF 123 #define SOL_PLATFORM_APPLE_IPHONE_I_ SOL_OFF 124 #define SOL_PLATFORM_BSDLIKE_I_ SOL_OFF 126 #if defined(SOL_IN_DEBUG_DETECTED) 127 #if SOL_IN_DEBUG_DETECTED != 0 128 #define SOL_DEBUG_BUILD_I_ SOL_ON 130 #define SOL_DEBUG_BUILD_I_ SOL_OFF 132 #elif !defined(NDEBUG) 133 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) && defined(_DEBUG) 134 #define SOL_DEBUG_BUILD_I_ SOL_ON 135 #elif (SOL_IS_ON(SOL_COMPILER_CLANG_I_) || SOL_IS_ON(SOL_COMPILER_GCC_I_)) && !defined(__OPTIMIZE__) 136 #define SOL_DEBUG_BUILD_I_ SOL_ON 138 #define SOL_DEBUG_BUILD_I_ SOL_OFF 141 #define SOL_DEBUG_BUILD_I_ SOL_DEFAULT_OFF 142 #endif // We are in a debug mode of some sort 144 #if defined(SOL_NO_EXCEPTIONS) 145 #if (SOL_NO_EXCEPTIONS != 0) 146 #define SOL_EXCEPTIONS_I_ SOL_OFF 148 #define SOL_EXCEPTIONS_I_ SOL_ON 150 #elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) 151 #if !defined(_CPPUNWIND) 152 #define SOL_EXCEPTIONS_I_ SOL_OFF 154 #define SOL_EXCEPTIONS_I_ SOL_ON 156 #elif SOL_IS_ON(SOL_COMPILER_CLANG_I_) || SOL_IS_ON(SOL_COMPILER_GCC_I_) 157 #if !defined(__EXCEPTIONS) 158 #define SOL_EXCEPTIONS_I_ SOL_OFF 160 #define SOL_EXCEPTIONS_I_ SOL_ON 163 #define SOL_EXCEPTIONS_I_ SOL_DEFAULT_ON 166 #if defined(SOL_NO_RTTI) 167 #if (SOL_NO_RTTI != 0) 168 #define SOL_RTTI_I_ SOL_OFF 170 #define SOL_RTTI_I_ SOL_ON 172 #elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) 173 #if !defined(_CPPRTTI) 174 #define SOL_RTTI_I_ SOL_OFF 176 #define SOL_RTTI_I_ SOL_ON 178 #elif SOL_IS_ON(SOL_COMPILER_CLANG_I_) || SOL_IS_ON(SOL_COMPILER_GCC_I_) 179 #if !defined(__GXX_RTTI) 180 #define SOL_RTTI_I_ SOL_OFF 182 #define SOL_RTTI_I_ SOL_ON 185 #define SOL_RTTI_I_ SOL_DEFAULT_ON 188 #if defined(SOL_NO_THREAD_LOCAL) && (SOL_NO_THREAD_LOCAL != 0) 189 #define SOL_USE_THREAD_LOCAL_I_ SOL_OFF 191 #define SOL_USE_THREAD_LOCAL_I_ SOL_DEFAULT_ON 192 #endif // thread_local keyword is bjorked on some platforms 194 #if defined(SOL_ALL_SAFETIES_ON) && (SOL_ALL_SAFETIES_ON != 0) 195 #define SOL_ALL_SAFETIES_ON_I_ SOL_ON 197 #define SOL_ALL_SAFETIES_ON_I_ SOL_DEFAULT_OFF 200 #if defined(SOL_SAFE_GETTER) && (SOL_SAFE_GETTER != 0) 201 #define SOL_SAFE_GETTER_I_ SOL_ON 203 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 204 #define SOL_SAFE_GETTER_I_ SOL_ON 205 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 206 #define SOL_SAFE_GETTER_I_ SOL_DEFAULT_ON 208 #define SOL_SAFE_GETTER_I_ SOL_DEFAULT_OFF 212 #if defined(SOL_SAFE_USERTYPE) && (SOL_SAFE_USERTYPE != 0) 213 #define SOL_SAFE_USERTYPE_I_ SOL_ON 215 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 216 #define SOL_SAFE_USERTYPE_I_ SOL_ON 217 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 218 #define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_ON 220 #define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_OFF 224 #if defined(SOL_SAFE_REFERENCES) && (SOL_SAFE_REFERENCES != 0) 225 #define SOL_SAFE_REFERENCES_I_ SOL_ON 227 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 228 #define SOL_SAFE_REFERENCES_I_ SOL_ON 229 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 230 #define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_ON 232 #define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_OFF 236 #if (defined(SOL_SAFE_FUNCTIONS) && (SOL_SAFE_FUNCTIONS != 0)) \ 237 || (defined(SOL_SAFE_FUNCTION_OBJECTS) && (SOL_SAFE_FUNCTION_OBJECTS != 0)) 238 #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_ON 240 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 241 #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_ON 242 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 243 #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_ON 245 #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_OFF 249 #if defined(SOL_SAFE_FUNCTION_CALLS) && (SOL_SAFE_FUNCTION_CALLS != 0) 250 #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_ON 252 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 253 #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_ON 254 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 255 #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_ON 257 #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_OFF 261 #if defined(SOL_SAFE_PROXIES) && (SOL_SAFE_PROXIES != 0) 262 #define SOL_SAFE_PROXIES_I_ SOL_ON 264 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 265 #define SOL_SAFE_PROXIES_I_ SOL_ON 266 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 267 #define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_ON 269 #define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_OFF 273 #if defined(SOL_SAFE_NUMERICS) && (SOL_SAFE_NUMERICS != 0) 274 #define SOL_SAFE_NUMERICS_I_ SOL_ON 276 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 277 #define SOL_SAFE_NUMERICS_I_ SOL_ON 278 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 279 #define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_ON 281 #define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_OFF 285 #if defined(SOL_SAFE_STACK_CHECK) && (SOL_SAFE_STACK_CHECK != 0) 286 #define SOL_SAFE_STACK_CHECK_I_ SOL_ON 288 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 289 #define SOL_SAFE_STACK_CHECK_I_ SOL_ON 290 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 291 #define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_ON 293 #define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_OFF 297 #if (defined(SOL_NO_CHECK_NUMBER_PRECISION) && (SOL_NO_CHECK_NUMBER_PRECISION != 0)) \ 298 || (defined(SOL_NO_CHECKING_NUMBER_PRECISION) && (SOL_NO_CHECKING_NUMBER_PRECISION != 0)) 299 #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_OFF 301 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 302 #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON 303 #elif SOL_IS_ON(SOL_SAFE_NUMERICS_I_) 304 #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON 305 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 306 #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_ON 308 #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_OFF 312 #if defined(SOL_STRINGS_ARE_NUMBERS) 313 #if (SOL_STRINGS_ARE_NUMBERS != 0) 314 #define SOL_STRINGS_ARE_NUMBERS_I_ SOL_ON 316 #define SOL_STRINGS_ARE_NUMBERS_I_ SOL_OFF 319 #define SOL_STRINGS_ARE_NUMBERS_I_ SOL_DEFAULT_OFF 322 #if defined(SOL_ENABLE_INTEROP) && (SOL_ENABLE_INTEROP != 0) \ 323 || defined(SOL_USE_INTEROP) && (SOL_USE_INTEROP != 0) 324 #define SOL_USE_INTEROP_I_ SOL_ON 326 #define SOL_USE_INTEROP_I_ SOL_DEFAULT_OFF 329 #if defined(SOL_NO_NIL) 330 #if (SOL_NO_NIL != 0) 331 #define SOL_NIL_I_ SOL_OFF 333 #define SOL_NIL_I_ SOL_ON 335 #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil) 336 #define SOL_NIL_I_ SOL_DEFAULT_OFF 338 #define SOL_NIL_I_ SOL_DEFAULT_ON 341 #if defined(SOL_USERTYPE_TYPE_BINDING_INFO) 342 #if (SOL_USERTYPE_TYPE_BINDING_INFO != 0) 343 #define SOL_USERTYPE_TYPE_BINDING_INFO_I_ SOL_ON 345 #define SOL_USERTYPE_TYPE_BINDING_INFO_I_ SOL_OFF 348 #define SOL_USERTYPE_TYPE_BINDING_INFO_I_ SOL_DEFAULT_ON 349 #endif // We should generate a my_type.__type table with lots of class information for usertypes 351 #if defined(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT) 352 #if (SOL_AUTOMAGICAL_TYPES_BY_DEFAULT != 0) 353 #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_ON 355 #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_OFF 357 #elif defined(SOL_DEFAULT_AUTOMAGICAL_USERTYPES) 358 #if (SOL_DEFAULT_AUTOMAGICAL_USERTYPES != 0) 359 #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_ON 361 #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_OFF 364 #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_DEFAULT_ON 365 #endif // make is_automagical on/off by default 367 #if defined(SOL_STD_VARIANT) 368 #if (SOL_STD_VARIANT != 0) 369 #define SOL_STD_VARIANT_I_ SOL_ON 371 #define SOL_STD_VARIANT_I_ SOL_OFF 374 #if SOL_IS_ON(SOL_COMPILER_CLANG_I_) && SOL_IS_ON(SOL_PLATFORM_APPLE_I_) 375 #if defined(__has_include) 376 #if __has_include(<variant>) 377 #define SOL_STD_VARIANT_I_ SOL_ON 379 #define SOL_STD_VARIANT_I_ SOL_OFF 382 #define SOL_STD_VARIANT_I_ SOL_OFF 385 #define SOL_STD_VARIANT_I_ SOL_DEFAULT_ON 387 #endif // make is_automagical on/off by default 389 #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) 390 #if (SOL_NOEXCEPT_FUNCTION_TYPE != 0) 391 #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_ON 393 #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_OFF 396 #if defined(__cpp_noexcept_function_type) 397 #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_ON 398 #elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) && (defined(_MSVC_LANG) && (_MSVC_LANG < 201403L)) 404 #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_OFF 406 #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_DEFAULT_ON 408 #endif // noexcept is part of a function's type 410 #if defined(SOL_STACK_STRING_OPTIMIZATION_SIZE) && SOL_STACK_STRING_OPTIMIZATION_SIZE > 0 411 #define SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_ SOL_STACK_STRING_OPTIMIZATION_SIZE 413 #define SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_ 1024 416 #if defined(SOL_ID_SIZE) && SOL_ID_SIZE > 0 417 #define SOL_ID_SIZE_I_ SOL_ID_SIZE 419 #define SOL_ID_SIZE_I_ 512 422 #if defined(LUA_IDSIZE) && LUA_IDSIZE > 0 423 #define SOL_FILE_ID_SIZE_I_ LUA_IDSIZE 424 #elif defined(SOL_ID_SIZE) && SOL_ID_SIZE > 0 425 #define SOL_FILE_ID_SIZE_I_ SOL_FILE_ID_SIZE 427 #define SOL_FILE_ID_SIZE_I_ 2048 430 #if defined(SOL_PRINT_ERRORS) 431 #if (SOL_PRINT_ERRORS != 0) 432 #define SOL_PRINT_ERRORS_I_ SOL_ON 434 #define SOL_PRINT_ERRORS_I_ SOL_OFF 437 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 438 #define SOL_PRINT_ERRORS_I_ SOL_ON 439 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 440 #define SOL_PRINT_ERRORS_I_ SOL_DEFAULT_ON 442 #define SOL_PRINT_ERRORS_I_ SOL_OFF 446 #if defined(SOL_DEFAULT_PASS_ON_ERROR) && (SOL_DEFAULT_PASS_ON_ERROR != 0) 447 #define SOL_DEFAULT_PASS_ON_ERROR_I_ SOL_ON 449 #if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_) 450 #define SOL_DEFAULT_PASS_ON_ERROR_I_ SOL_ON 451 #elif SOL_IS_ON(SOL_DEBUG_BUILD_I_) 452 #define SOL_DEFAULT_PASS_ON_ERROR_I_ SOL_DEFAULT_ON 454 #define SOL_DEFAULT_PASS_ON_ERROR_I_ SOL_OFF 458 #if defined(SOL_USING_CXX_LUA) 459 #if (SOL_USING_CXX_LUA != 0) 460 #define SOL_USE_CXX_LUA_I_ SOL_ON 462 #define SOL_USE_CXX_LUA_I_ SOL_OFF 464 #elif defined(SOL_USE_CXX_LUA) 465 #if (SOL_USE_CXX_LUA != 0) 466 #define SOL_USE_CXX_LUA_I_ SOL_ON 468 #define SOL_USE_CXX_LUA_I_ SOL_OFF 471 #define SOL_USE_CXX_LUA_I_ SOL_OFF 474 #if defined(SOL_USING_CXX_LUAJIT) 475 #if (SOL_USING_CXX_LUA != 0) 476 #define SOL_USE_CXX_LUAJIT_I_ SOL_ON 478 #define SOL_USE_CXX_LUAJIT_I_ SOL_OFF 480 #elif defined(SOL_USE_CXX_LUAJIT) 481 #if (SOL_USE_CXX_LUA != 0) 482 #define SOL_USE_CXX_LUAJIT_I_ SOL_ON 484 #define SOL_USE_CXX_LUAJIT_I_ SOL_OFF 487 #define SOL_USE_CXX_LUAJIT_I_ SOL_OFF 490 #if defined(SOL_NO_LUA_HPP) 491 #if (SOL_NO_LUA_HPP != 0) 492 #define SOL_USE_LUA_HPP_I_ SOL_OFF 494 #define SOL_USE_LUA_HPP_I_ SOL_ON 496 #elif defined(SOL_USING_CXX_LUA) 497 #define SOL_USE_LUA_HPP_I_ SOL_OFF 498 #elif defined(__has_include) 499 #if __has_include(<lua.hpp>) 500 #define SOL_USE_LUA_HPP_I_ SOL_ON 502 #define SOL_USE_LUA_HPP_I_ SOL_OFF 505 #define SOL_USE_LUA_HPP_I_ SOL_DEFAULT_ON 508 #if defined(SOL_CONTAINERS_START) 509 #define SOL_CONTAINER_START_INDEX_I_ SOL_CONTAINERS_START 510 #elif defined(SOL_CONTAINERS_START_INDEX) 511 #define SOL_CONTAINER_START_INDEX_I_ SOL_CONTAINERS_START_INDEX 512 #elif defined(SOL_CONTAINER_START_INDEX) 513 #define SOL_CONTAINER_START_INDEX_I_ SOL_CONTAINER_START_INDEX 515 #define SOL_CONTAINER_START_INDEX_I_ 1 518 #if defined (SOL_NO_MEMORY_ALIGNMENT) 519 #if (SOL_NO_MEMORY_ALIGNMENT != 0) 520 #define SOL_ALIGN_MEMORY_I_ SOL_OFF 522 #define SOL_ALIGN_MEMORY_I_ SOL_ON 525 #define SOL_ALIGN_MEMORY_I_ SOL_DEFAULT_ON 528 #if defined(SOL_USE_BOOST) 529 #if (SOL_USE_BOOST != 0) 530 #define SOL_USE_BOOST_I_ SOL_ON 532 #define SOL_USE_BOOST_I_ SOL_OFF 535 #define SOL_USE_BOOST_I_ SOL_OFF 538 #if defined(SOL_USE_UNSAFE_BASE_LOOKUP) 539 #if (SOL_USE_UNSAFE_BASE_LOOKUP != 0) 540 #define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_ON 542 #define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_OFF 545 #define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_OFF 548 #if defined(SOL_INSIDE_UNREAL) 549 #if (SOL_INSIDE_UNREAL != 0) 550 #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_ON 552 #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_OFF 555 #if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER) 556 #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_ON 558 #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_DEFAULT_OFF 562 #if defined(SOL_NO_COMPAT) 563 #if (SOL_NO_COMPAT != 0) 564 #define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_OFF 566 #define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_ON 569 #define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_DEFAULT_ON 572 #if defined(SOL_GET_FUNCTION_POINTER_UNSAFE) 573 #if (SOL_GET_FUNCTION_POINTER_UNSAFE != 0) 574 #define SOL_GET_FUNCTION_POINTER_UNSAFE_I_ SOL_ON 576 #define SOL_GET_FUNCTION_POINTER_UNSAFE_I_ SOL_OFF 579 #define SOL_GET_FUNCTION_POINTER_UNSAFE_I_ SOL_DEFAULT_OFF 582 #if SOL_IS_ON(SOL_COMPILER_FRONTEND_MINGW_I_) && defined(__GNUC__) && (__GNUC__ < 6) 584 #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_ON 586 #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_OFF 591 #if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE_I_) 593 #pragma push_macro("check") 596 #endif // Unreal Engine 4 Bullshit 598 #if SOL_IS_ON(SOL_COMPILER_GCC_I_) 599 #pragma GCC diagnostic push 600 #pragma GCC diagnostic ignored "-Wshadow" 601 #pragma GCC diagnostic ignored "-Wconversion" 603 #pragma GCC diagnostic ignored "-Wnoexcept-type" 605 #elif SOL_IS_ON(SOL_COMPILER_CLANG_I_) 606 #elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) 607 #pragma warning(push) 608 #pragma warning(disable : 4505) // unreferenced local function has been removed GEE THANKS 609 #endif // clang++ vs. g++ vs. VC++ 613 #ifndef SOL_FORWARD_HPP 614 #define SOL_FORWARD_HPP 617 #include <type_traits> 618 #include <string_view> 620 #if SOL_IS_ON(SOL_USE_CXX_LUA_I_) || SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_) 626 #endif // C++ Mangling for Lua vs. Not 632 class stateless_reference;
634 class basic_reference;
635 using reference = basic_reference<false>;
637 class stateless_stack_reference;
638 class stack_reference;
640 template <
typename A>
641 class basic_bytecode;
645 struct proxy_base_tag;
648 template <
typename,
typename>
651 template <
bool,
typename>
652 class basic_table_core;
654 using table_core = basic_table_core<b, reference>;
659 template <
typename base_type>
660 using basic_table = basic_table_core<false, base_type>;
661 using table = table_core<false>;
669 struct basic_lua_table;
670 using lua_table = basic_lua_table<reference>;
673 template <
typename T,
typename base_type>
674 class basic_usertype;
675 template <
typename T>
676 using usertype = basic_usertype<T, reference>;
677 template <
typename T>
680 template <
typename base_type>
681 class basic_metatable;
682 using metatable = basic_metatable<reference>;
685 template <
typename base_t>
686 struct basic_environment;
691 template <
typename T,
bool>
692 class basic_function;
693 template <
typename T,
bool,
typename H>
694 class basic_protected_function;
696 using safe_function = basic_protected_function<reference, false, reference>;
698 using main_safe_function = basic_protected_function<main_reference, false, reference>;
707 #if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS_I_) 720 struct unsafe_function_result;
721 struct protected_function_result;
723 #if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS_I_) 729 template <
typename base_t>
730 class basic_object_base;
731 template <
typename base_t>
733 template <
typename base_t>
734 class basic_userdata;
735 template <
typename base_t>
736 class basic_lightuserdata;
737 template <
typename base_t>
738 class basic_coroutine;
739 template <
typename base_t>
742 using object = basic_object<reference>;
743 using userdata = basic_userdata<reference>;
745 using thread = basic_thread<reference>;
746 using coroutine = basic_coroutine<reference>;
757 struct stack_proxy_base;
759 struct variadic_args;
760 struct variadic_results;
763 struct this_main_state;
764 struct this_environment;
769 template <
typename T>
771 template <
typename T>
772 struct as_container_t;
773 template <
typename T>
775 template <
typename T>
777 template <
typename T>
779 template <
typename T>
781 template <
typename T>
783 template <
typename F,
typename... Policies>
784 struct policy_wrapper;
786 template <
typename T>
787 struct usertype_traits;
788 template <
typename T>
789 struct unique_usertype_traits;
791 template <
typename... Args>
793 typedef std::make_index_sequence<
sizeof...(Args)>
indices;
794 static constexpr std::size_t
size() {
795 return sizeof...(Args);
799 template <
typename T>
800 struct derive : std::false_type {
804 template <
typename T>
805 struct base : std::false_type {
809 template <
typename T>
814 template <
typename T>
821 #if SOL_IS_OFF(SOL_USE_BOOST_I_) 833 #define SOL_BASE_CLASSES(T, ...) \ 836 struct base<T> : std::true_type { \ 837 typedef ::sol::types<__VA_ARGS__> type; \ 840 void a_sol3_detail_function_decl_please_no_collide() 841 #define SOL_DERIVED_CLASSES(T, ...) \ 844 struct derive<T> : std::true_type { \ 845 typedef ::sol::types<__VA_ARGS__> type; \ 848 void a_sol3_detail_function_decl_please_no_collide() 850 #endif // SOL_FORWARD_HPP 855 #ifndef SOL_FORWARD_DETAIL_HPP 856 #define SOL_FORWARD_DETAIL_HPP 864 #include <type_traits> 876 template <
typename T>
879 template <
typename T>
882 template <
typename T>
885 namespace meta_detail {
886 template <
typename T>
889 template <
template <
class...>
class Test,
class,
class... Args>
892 template <
template <
class...>
class Test,
class... Args>
896 template <
template <
class...>
class Trait,
class... Args>
899 template <
template <
class...>
class Trait,
class... Args>
902 template <std::
size_t I>
907 template <
typename T,
typename U>
913 template <
typename T,
typename U>
917 template <
bool B,
typename T,
typename U>
920 namespace meta_detail {
921 template <
typename T,
template <
typename...>
class Templ>
923 template <
typename... T,
template <
typename...>
class Templ>
927 template <
typename T,
template <
typename...>
class Templ>
930 template <
typename T,
template <
typename...>
class Templ>
933 template <
typename T>
938 template <
typename T>
941 template <
typename T>
958 template <
typename T>
961 template <
typename T>
965 template <
typename... Args>
968 template <
typename... Args>
972 template <
typename... Args>
975 template <
typename Arg>
978 template <
typename Arg>
981 template <
typename... Args>
987 template <
typename Arg,
typename... Args>
993 template <std::
size_t N,
typename Tuple>
994 using tuple_element = std::tuple_element<N, std::remove_reference_t<Tuple>>;
996 template <std::
size_t N,
typename Tuple>
999 template <std::
size_t N,
typename Tuple>
1002 template <std::
size_t N,
typename Tuple>
1012 namespace sol {
namespace meta {
1013 namespace meta_detail {
1019 static auto test(
int) -> decltype(&G::operator(),
void());
1021 static auto test(...) ->
nat;
1023 using type = std::is_void<decltype(test<F>(0))>;
1030 namespace meta_detail {
1032 template <std::
size_t I,
typename T>
1035 template <std::
size_t I>
1040 template <std::
size_t I,
typename T>
1043 template <
bool it_is_noexcept,
bool has_c_variadic,
typename T,
typename R,
typename... Args>
1049 inline static constexpr
const bool is_noexcept = it_is_noexcept;
1051 inline static constexpr
bool has_c_var_arg = has_c_variadic;
1052 inline static constexpr std::size_t arity =
sizeof...(Args);
1059 typedef R(function_type)(Args...);
1061 typedef meta::conditional_t<std::is_void<T>::value, R(Args...), R(first_type, Args...)>
free_function_type;
1064 template <std::
size_t i>
1072 template <
typename R,
typename... Args>
1074 typedef R (*function_pointer_type)(Args...);
1077 template <
typename R,
typename... Args>
1079 typedef R (*function_pointer_type)(Args...);
1082 template <
typename R,
typename... Args>
1084 typedef R (*function_pointer_type)(Args..., ...);
1087 template <
typename R,
typename... Args>
1089 typedef R (*function_pointer_type)(Args..., ...);
1094 template <
typename T,
typename R,
typename... Args>
1096 typedef R (T::*function_pointer_type)(Args...);
1099 template <
typename T,
typename R,
typename... Args>
1101 typedef R (T::*function_pointer_type)(Args..., ...);
1105 template <
typename T,
typename R,
typename... Args>
1107 typedef R (T::*function_pointer_type)(Args...)
const;
1110 template <
typename T,
typename R,
typename... Args>
1112 typedef R (T::*function_pointer_type)(Args..., ...)
const;
1115 template <
typename T,
typename R,
typename... Args>
1117 typedef R (T::*function_pointer_type)(Args...)
const volatile;
1120 template <
typename T,
typename R,
typename... Args>
1122 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile;
1126 template <
typename T,
typename R,
typename... Args>
1128 typedef R (T::*function_pointer_type)(Args...) &;
1131 template <
typename T,
typename R,
typename... Args>
1133 typedef R (T::*function_pointer_type)(Args..., ...) &;
1136 template <
typename T,
typename R,
typename... Args>
1138 typedef R (T::*function_pointer_type)(Args...)
const&;
1141 template <
typename T,
typename R,
typename... Args>
1143 typedef R (T::*function_pointer_type)(Args..., ...)
const&;
1146 template <
typename T,
typename R,
typename... Args>
1148 typedef R (T::*function_pointer_type)(Args...)
const volatile&;
1151 template <
typename T,
typename R,
typename... Args>
1153 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile&;
1156 template <
typename T,
typename R,
typename... Args>
1158 typedef R (T::*function_pointer_type)(Args...) &&;
1161 template <
typename T,
typename R,
typename... Args>
1163 typedef R (T::*function_pointer_type)(Args..., ...) &&;
1166 template <
typename T,
typename R,
typename... Args>
1168 typedef R (T::*function_pointer_type)(Args...)
const&&;
1171 template <
typename T,
typename R,
typename... Args>
1173 typedef R (T::*function_pointer_type)(Args..., ...)
const&&;
1176 template <
typename T,
typename R,
typename... Args>
1178 typedef R (T::*function_pointer_type)(Args...)
const volatile&&;
1181 template <
typename T,
typename R,
typename... Args>
1183 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile&&;
1186 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) 1188 template <
typename R,
typename... Args>
1190 typedef R (*function_pointer_type)(Args...) noexcept;
1193 template <
typename R,
typename... Args>
1195 typedef R (*function_pointer_type)(Args...) noexcept;
1198 template <
typename R,
typename... Args>
1200 typedef R (*function_pointer_type)(Args..., ...) noexcept;
1203 template <
typename R,
typename... Args>
1205 typedef R (*function_pointer_type)(Args..., ...) noexcept;
1208 template <
typename T,
typename R,
typename... Args>
1210 typedef R (T::*function_pointer_type)(Args...) noexcept;
1213 template <
typename T,
typename R,
typename... Args>
1215 typedef R (T::*function_pointer_type)(Args..., ...) noexcept;
1219 template <
typename T,
typename R,
typename... Args>
1221 typedef R (T::*function_pointer_type)(Args...)
const noexcept;
1224 template <
typename T,
typename R,
typename... Args>
1226 typedef R (T::*function_pointer_type)(Args..., ...)
const noexcept;
1229 template <
typename T,
typename R,
typename... Args>
1231 typedef R (T::*function_pointer_type)(Args...)
const volatile noexcept;
1234 template <
typename T,
typename R,
typename... Args>
1236 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile noexcept;
1239 template <
typename T,
typename R,
typename... Args>
1241 typedef R (T::*function_pointer_type)(Args...) & noexcept;
1244 template <
typename T,
typename R,
typename... Args>
1246 typedef R (T::*function_pointer_type)(Args..., ...) & noexcept;
1249 template <
typename T,
typename R,
typename... Args>
1251 typedef R (T::*function_pointer_type)(Args...)
const& noexcept;
1254 template <
typename T,
typename R,
typename... Args>
1256 typedef R (T::*function_pointer_type)(Args..., ...)
const& noexcept;
1259 template <
typename T,
typename R,
typename... Args>
1261 typedef R (T::*function_pointer_type)(Args...)
const volatile& noexcept;
1264 template <
typename T,
typename R,
typename... Args>
1266 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile& noexcept;
1269 template <
typename T,
typename R,
typename... Args>
1271 typedef R (T::*function_pointer_type)(Args...) && noexcept;
1274 template <
typename T,
typename R,
typename... Args>
1276 typedef R (T::*function_pointer_type)(Args..., ...) && noexcept;
1279 template <
typename T,
typename R,
typename... Args>
1281 typedef R (T::*function_pointer_type)(Args...)
const&& noexcept;
1284 template <
typename T,
typename R,
typename... Args>
1286 typedef R (T::*function_pointer_type)(Args..., ...)
const&& noexcept;
1289 template <
typename T,
typename R,
typename... Args>
1291 typedef R (T::*function_pointer_type)(Args...)
const volatile&& noexcept;
1294 template <
typename T,
typename R,
typename... Args>
1296 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile&& noexcept;
1299 #endif // noexcept is part of a function's type 1301 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) && SOL_IS_ON(SOL_PLATFORM_X86_I_) 1302 template <
typename R,
typename... Args>
1304 typedef R(__stdcall* function_pointer_type)(Args...);
1307 template <
typename R,
typename... Args>
1309 typedef R(__stdcall* function_pointer_type)(Args...);
1312 template <
typename T,
typename R,
typename... Args>
1314 typedef R (__stdcall T::*function_pointer_type)(Args...);
1318 template <
typename T,
typename R,
typename... Args>
1319 struct fx_traits<R (__stdcall T::*)(Args...) const, false> :
basic_traits<false, false, T, R, Args...> {
1320 typedef R (__stdcall T::*function_pointer_type)(Args...)
const;
1323 template <
typename T,
typename R,
typename... Args>
1324 struct fx_traits<R (__stdcall T::*)(Args...) const volatile, false> :
basic_traits<false, false, T, R, Args...> {
1325 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile;
1329 template <
typename T,
typename R,
typename... Args>
1331 typedef R (__stdcall T::*function_pointer_type)(Args...) &;
1334 template <
typename T,
typename R,
typename... Args>
1335 struct fx_traits<R (__stdcall T::*)(Args...) const&, false> :
basic_traits<false, false, T, R, Args...> {
1336 typedef R (__stdcall T::*function_pointer_type)(Args...)
const&;
1339 template <
typename T,
typename R,
typename... Args>
1340 struct fx_traits<R (__stdcall T::*)(Args...) const volatile&, false> :
basic_traits<false, false, T, R, Args...> {
1341 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile&;
1344 template <
typename T,
typename R,
typename... Args>
1345 struct fx_traits<R (__stdcall T::*)(Args...)&&, false> :
basic_traits<false, false, T, R, Args...> {
1346 typedef R (__stdcall T::*function_pointer_type)(Args...) &&;
1349 template <
typename T,
typename R,
typename... Args>
1350 struct fx_traits<R (__stdcall T::*)(Args...) const&&, false> :
basic_traits<false, false, T, R, Args...> {
1351 typedef R (__stdcall T::*function_pointer_type)(Args...)
const&&;
1354 template <
typename T,
typename R,
typename... Args>
1355 struct fx_traits<R (__stdcall T::*)(Args...) const volatile&&, false> :
basic_traits<false, false, T, R, Args...> {
1356 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile&&;
1359 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) 1361 template <
typename R,
typename... Args>
1362 struct fx_traits<R __stdcall(Args...) noexcept, false> :
basic_traits<true, false, void, R, Args...> {
1363 typedef R(__stdcall* function_pointer_type)(Args...) noexcept;
1366 template <
typename R,
typename... Args>
1368 typedef R(__stdcall* function_pointer_type)(Args...) noexcept;
1382 template <
typename T,
typename R,
typename... Args>
1383 struct fx_traits<R (__stdcall T::*)(Args...) noexcept, false> :
basic_traits<true, false, T, R, Args...> {
1384 typedef R (__stdcall T::*function_pointer_type)(Args...) noexcept;
1394 template <
typename T,
typename R,
typename... Args>
1395 struct fx_traits<R (__stdcall T::*)(Args...) const noexcept, false> :
basic_traits<true, false, T, R, Args...> {
1396 typedef R (__stdcall T::*function_pointer_type)(Args...)
const noexcept;
1405 template <
typename T,
typename R,
typename... Args>
1406 struct fx_traits<R (__stdcall T::*)(Args...) const volatile noexcept, false> :
basic_traits<true, false, T, R, Args...> {
1407 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile noexcept;
1416 template <
typename T,
typename R,
typename... Args>
1417 struct fx_traits<R (__stdcall T::*)(Args...) & noexcept, false> :
basic_traits<true, false, T, R, Args...> {
1418 typedef R (__stdcall T::*function_pointer_type)(Args...) & noexcept;
1427 template <
typename T,
typename R,
typename... Args>
1428 struct fx_traits<R (__stdcall T::*)(Args...) const& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
1429 typedef R (__stdcall T::*function_pointer_type)(Args...)
const& noexcept;
1438 template <
typename T,
typename R,
typename... Args>
1439 struct fx_traits<R (__stdcall T::*)(Args...) const volatile& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
1440 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile& noexcept;
1449 template <
typename T,
typename R,
typename... Args>
1450 struct fx_traits<R (__stdcall T::*)(Args...) && noexcept, false> :
basic_traits<true, false, T, R, Args...> {
1451 typedef R (__stdcall T::*function_pointer_type)(Args...) && noexcept;
1460 template <
typename T,
typename R,
typename... Args>
1461 struct fx_traits<R (__stdcall T::*)(Args...) const&& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
1462 typedef R (__stdcall T::*function_pointer_type)(Args...)
const&& noexcept;
1471 template <
typename T,
typename R,
typename... Args>
1472 struct fx_traits<R (__stdcall T::*)(Args...) const volatile&& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
1473 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile&& noexcept;
1481 #endif // noexcept is part of a function's type 1482 #endif // __stdcall x86 VC++ bug 1484 template <
typename Signature>
1486 :
public fx_traits<typename fx_traits<decltype(&Signature::operator())>::function_type, false> {};
1490 :
public fx_traits<std::decay_t<Signature>> {};
1492 template <
typename R,
typename T>
1498 inline static constexpr
bool is_noexcept =
false;
1499 inline static constexpr
bool is_member_function =
false;
1500 inline static constexpr std::size_t arity = 1;
1501 inline static constexpr std::size_t free_arity = 2;
1506 typedef return_type(function_type)(T&, return_type);
1507 typedef return_type (*function_pointer_type)(T&, Arg);
1508 typedef return_type (*free_function_pointer_type)(T&, Arg);
1509 template <std::
size_t i>
1515 template <
typename Signature>
1518 template <
typename Signature>
1521 template <
typename Signature>
1524 template <
typename Signature>
1533 #include <type_traits> 1538 namespace meta_detail {
1539 template <
typename T>
1542 template <
typename T>
1546 template <
typename T>
1547 using is_pointer_like = std::integral_constant<bool, !std::is_array_v<T> && (std::is_pointer_v<T> || is_detected_v<meta_detail::is_explicitly_dereferenceable_test, T>)>;
1549 template <
typename T>
1555 template <
typename T>
1556 auto unwrap(T&& item) -> decltype(std::forward<T>(item)) {
1557 return std::forward<T>(item);
1560 template <
typename T>
1565 template <
typename T>
1568 if constexpr (meta::is_pointer_like_v<Tu>) {
1569 return *std::forward<T>(item);
1572 return std::forward<T>(item);
1576 template <
typename T>
1579 if constexpr (meta::is_pointer_like_v<Tu> && !std::is_pointer_v<Tu> && !std::is_copy_constructible_v<Tu>) {
1580 return *std::forward<T>(item);
1583 return std::forward<T>(item);
1587 template <
typename T>
1589 return std::addressof(val);
1592 template <
typename T>
1593 inline T*
ptr(std::reference_wrapper<T> val) {
1594 return std::addressof(val.get());
1597 template <
typename T>
1610 #include <string_view> 1611 #include <functional> 1614 template <
typename C,
typename T = std::
char_traits<C>>
1626 #include <type_traits> 1629 #include <functional> 1633 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 1635 #endif // variant is weird on XCode, thanks XCode 1637 namespace sol {
namespace meta {
1638 template <
typename T>
1643 template <
typename T>
1648 template <
typename T>
1651 template <
typename T>
1654 template <
typename T>
1657 template <
typename T>
1660 template <
typename R,
typename T>
1665 template <
typename R,
typename T>
1670 template <
typename T>
1673 template <
typename T,
typename...>
1676 template <
typename T,
typename U,
typename... Args>
1677 struct all_same<T, U, Args...> : std::integral_constant<bool, std::is_same<T, U>::value && all_same<T, Args...>::value> {};
1679 template <
typename T,
typename...>
1682 template <
typename T,
typename U,
typename... Args>
1683 struct any_same<T, U, Args...> : std::integral_constant<bool, std::is_same<T, U>::value || any_same<T, Args...>::value> {};
1685 template <
typename T,
typename... Args>
1689 using boolean = std::integral_constant<bool, B>;
1694 template <
typename T>
1697 template <
typename T>
1700 template <
typename... Args>
1703 template <
typename T,
typename... Args>
1706 template <
typename... Args>
1709 template <
typename T,
typename... Args>
1712 template <
typename T,
typename... Args>
1715 template <
typename T,
typename... Args>
1722 template <
bool value,
typename T =
void>
1725 template <
typename... Args>
1728 template <
typename... Args>
1731 template <
typename... Args>
1734 template <
typename... Args>
1737 template <
typename V,
typename... Vs>
1740 template <
typename V,
typename Vs1,
typename... Vs>
1741 struct find_in_pack_v<V, Vs1, Vs...> :
any<boolean<(V::value == Vs1::value)>, find_in_pack_v<V, Vs...>> {};
1743 namespace meta_detail {
1744 template <std::size_t I,
typename T,
typename... Args>
1747 template <std::size_t I,
typename T,
typename T1,
typename... Args>
1749 :
conditional_t<std::is_same<T, T1>::value, std::integral_constant<std::ptrdiff_t, I>, index_in_pack<I + 1, T, Args...>> {};
1752 template <
typename T,
typename... Args>
1755 template <
typename T,
typename List>
1758 template <
typename T,
typename... Args>
1761 template <std::size_t I,
typename... Args>
1764 template <std::size_t I,
typename... Args>
1767 template <std::size_t I,
typename Arg,
typename... Args>
1768 struct at_in_pack<I, Arg, Args...> : std::conditional<I == 0, Arg, at_in_pack_t<I - 1, Args...>> {};
1770 template <
typename Arg,
typename... Args>
1775 namespace meta_detail {
1776 template <
typename,
typename TI>
1779 template <
typename,
typename TI>
1782 template <
typename,
typename>
1785 template <
template <
typename...>
class When, std::size_t Limit, std::size_t I,
template <
typename...>
class Pred,
typename... Ts>
1787 template <
template <
typename...>
class When, std::size_t Limit, std::size_t I,
template <
typename...>
class Pred,
typename T,
typename... Ts>
1790 || Limit<2, std::integral_constant<std::size_t, I + static_cast<std::size_t>(Limit != 0 && Pred<T>::value)>,
1791 count_when_for_pack<When, Limit - static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value),
1792 I + static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value&& Pred<T>::value), Pred, Ts...>> {};
1795 template <template <typename...> class Pred, typename... Ts>
1796 struct count_for_pack : meta_detail::count_when_for_pack<meta_detail::on_always, sizeof...(Ts), 0, Pred, Ts...> {};
1798 template <template <typename...> class Pred, typename... Ts>
1799 inline constexpr std::size_t count_for_pack_v = count_for_pack<Pred, Ts...>::value;
1801 template <template <typename...> class Pred, typename List>
1804 template <template <typename...> class Pred, typename... Args>
1805 struct count_for<Pred, types<Args...>> : count_for_pack<Pred, Args...> {};
1807 template <std::size_t Limit, template <typename...> class Pred, typename... Ts>
1808 struct count_for_to_pack : meta_detail::count_when_for_pack<meta_detail::on_always, Limit, 0, Pred, Ts...> {};
1810 template <std::size_t Limit, template <typename...> class Pred, typename... Ts>
1811 inline constexpr std::size_t count_for_to_pack_v = count_for_to_pack<Limit, Pred, Ts...>::value;
1813 template <template <typename...> class When, std::size_t Limit, template <typename...> class Pred, typename... Ts>
1814 struct count_when_for_to_pack : meta_detail::count_when_for_pack<When, Limit, 0, Pred, Ts...> {};
1816 template <template <typename...> class When, std::size_t Limit, template <typename...> class Pred, typename... Ts>
1817 inline constexpr std::size_t count_when_for_to_pack_v = count_when_for_to_pack<When, Limit, Pred, Ts...>::value;
1819 template <template <typename...> class Pred, typename... Ts>
1820 using count_even_for_pack = count_when_for_to_pack<meta_detail::on_even, sizeof...(Ts), Pred, Ts...>;
1822 template <template <typename...> class Pred, typename... Ts>
1823 inline constexpr std::size_t count_even_for_pack_v = count_even_for_pack<Pred, Ts...>::value;
1825 template <template <typename...> class Pred, typename... Ts>
1826 using count_odd_for_pack = count_when_for_to_pack<meta_detail::on_odd, sizeof...(Ts), Pred, Ts...>;
1828 template <template <typename...> class Pred, typename... Ts>
1829 inline constexpr std::size_t count_odd_for_pack_v = count_odd_for_pack<Pred, Ts...>::value;
1831 template <typename... Args>
1832 struct return_type {
1833 typedef std::tuple<Args...> type;
1836 template <typename T>
1837 struct return_type<T> {
1842 struct return_type<> {
1846 template <typename... Args>
1847 using return_type_t = typename return_type<Args...>::type;
1849 namespace meta_detail {
1851 struct always_true : std::true_type {};
1852 struct is_invokable_tester {
1853 template <typename Fun, typename... Args>
1854 static always_true<decltype(std::declval<Fun>()(std::declval<Args>()...))> test(int);
1855 template <typename...>
1856 static std::false_type test(...);
1860 template <typename T>
1861 struct is_invokable;
1862 template <typename Fun, typename... Args>
1863 struct is_invokable<Fun(Args...)> : decltype(meta_detail::is_invokable_tester::test<Fun, Args...>(0)) {};
1865 namespace meta_detail {
1867 template <typename T, typename = void>
1868 struct is_callable : std::is_function<std::remove_pointer_t<T>> {};
1870 template <typename T>
1871 struct is_callable<T,
1872 std::enable_if_t<std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value
1873 && std::is_same<decltype(void(&T::operator())), void>::value>> {};
1875 template <typename T>
1876 struct is_callable<T,
1877 std::enable_if_t<!std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value
1878 && std::is_destructible<unqualified_t<T>>::value>> {
1880 void operator()() {};
1882 struct Derived : T, F {};
1883 template <typename U, U>
1886 template <typename V>
1887 static sfinae_no_t test(Check<void (F::*)(), &V::operator()>*);
1890 static sfinae_yes_t test(...);
1892 static constexpr bool value = std::is_same_v<decltype(test<Derived>(0)), sfinae_yes_t>;
1895 template <typename T>
1896 struct is_callable<T,
1897 std::enable_if_t<!std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value
1898 && !std::is_destructible<unqualified_t<T>>::value>> {
1900 void operator()() {};
1902 struct Derived : T, F {
1903 ~Derived() = delete;
1905 template <typename U, U>
1908 template <typename V>
1909 static sfinae_no_t test(Check<void (F::*)(), &V::operator()>*);
1912 static sfinae_yes_t test(...);
1914 static constexpr bool value = std::is_same_v<decltype(test<Derived>(0)), sfinae_yes_t>;
1917 struct has_begin_end_impl {
1918 template <typename T, typename U = unqualified_t<T>, typename B = decltype(std::declval<U&>().begin()),
1919 typename E = decltype(std::declval<U&>().end())>
1920 static std::true_type test(int);
1922 template <typename...>
1923 static std::false_type test(...);
1926 struct has_key_type_impl {
1927 template <typename T, typename U = unqualified_t<T>, typename V = typename U::key_type>
1928 static std::true_type test(int);
1930 template <typename...>
1931 static std::false_type test(...);
1934 struct has_key_comp_impl {
1935 template <typename T, typename V = decltype(std::declval<unqualified_t<T>>().key_comp())>
1936 static std::true_type test(int);
1938 template <typename...>
1939 static std::false_type test(...);
1942 struct has_load_factor_impl {
1943 template <typename T, typename V = decltype(std::declval<unqualified_t<T>>().load_factor())>
1944 static std::true_type test(int);
1946 template <typename...>
1947 static std::false_type test(...);
1950 struct has_mapped_type_impl {
1951 template <typename T, typename V = typename unqualified_t<T>::mapped_type>
1952 static std::true_type test(int);
1954 template <typename...>
1955 static std::false_type test(...);
1958 struct has_value_type_impl {
1959 template <typename T, typename V = typename unqualified_t<T>::value_type>
1960 static std::true_type test(int);
1962 template <typename...>
1963 static std::false_type test(...);
1966 struct has_iterator_impl {
1967 template <typename T, typename V = typename unqualified_t<T>::iterator>
1968 static std::true_type test(int);
1970 template <typename...>
1971 static std::false_type test(...);
1974 struct has_key_value_pair_impl {
1975 template <typename T, typename U = unqualified_t<T>, typename V = typename U::value_type, typename F = decltype(std::declval<V&>().first),
1976 typename S = decltype(std::declval<V&>().second)>
1977 static std::true_type test(int);
1979 template <typename...>
1980 static std::false_type test(...);
1983 template <typename T>
1984 struct has_push_back_test {
1986 template <typename C>
1987 static sfinae_yes_t test(decltype(std::declval<C>().push_back(std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
1988 template <typename C>
1989 static sfinae_no_t test(...);
1992 static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
1995 template <typename T>
1996 struct has_insert_test {
1998 template <typename C>
1999 static sfinae_yes_t test(decltype(std::declval<C>().insert(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>(),
2000 std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
2001 template <typename C>
2002 static sfinae_no_t test(...);
2005 static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
2008 template <typename T>
2009 struct has_insert_after_test {
2011 template <typename C>
2012 static sfinae_yes_t test(decltype(std::declval<C>().insert_after(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>(),
2013 std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
2014 template <typename C>
2015 static sfinae_no_t test(...);
2018 static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
2021 template <typename T>
2022 struct has_size_test {
2024 template <typename C>
2025 static sfinae_yes_t test(decltype(std::declval<C>().size())*);
2026 template <typename C>
2027 static sfinae_no_t test(...);
2030 static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
2033 template <typename T>
2034 struct has_max_size_test {
2036 template <typename C>
2037 static sfinae_yes_t test(decltype(std::declval<C>().max_size())*);
2038 template <typename C>
2039 static sfinae_no_t test(...);
2042 static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
2045 template <typename T>
2046 struct has_to_string_test {
2048 template <typename C>
2049 static sfinae_yes_t test(decltype(std::declval<C>().to_string())*);
2050 template <typename C>
2051 static sfinae_no_t test(...);
2054 static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
2057 template <typename T, typename U, typename = void>
2058 class supports_op_less_test : public std::false_type {};
2059 template <typename T, typename U>
2060 class supports_op_less_test<T, U, void_t<decltype(std::declval<T&>() < std::declval<U&>())>>
2061 : public std::integral_constant<bool,
2062 !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
2064 template <typename T, typename U, typename = void>
2065 class supports_op_equal_test : public std::false_type {};
2066 template <typename T, typename U>
2067 class supports_op_equal_test<T, U, void_t<decltype(std::declval<T&>() == std::declval<U&>())>>
2068 : public std::integral_constant<bool,
2069 !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
2071 template <typename T, typename U, typename = void>
2072 class supports_op_less_equal_test : public std::false_type {};
2073 template <typename T, typename U>
2074 class supports_op_less_equal_test<T, U, void_t<decltype(std::declval<T&>() <= std::declval<U&>())>>
2075 : public std::integral_constant<bool,
2076 !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
2078 template <typename T, typename U, typename = void>
2079 class supports_op_left_shift_test : public std::false_type {};
2080 template <typename T, typename U>
2081 class supports_op_left_shift_test<T, U, void_t<decltype(std::declval<T&>() << std::declval<U&>())>> : public std::true_type {};
2083 template <typename T, typename = void>
2084 class supports_adl_to_string_test : public std::false_type {};
2085 template <typename T>
2086 class supports_adl_to_string_test<T, void_t<decltype(to_string(std::declval<const T&>()))>> : public std::true_type {};
2088 template <typename T, bool b>
2089 struct is_matched_lookup_impl : std::false_type {};
2090 template <typename T>
2091 struct is_matched_lookup_impl<T, true> : std::is_same<typename T::key_type, typename T::value_type> {};
2093 template <typename T>
2094 using non_void_t = meta::conditional_t<std::is_void_v<T>, ::sol::detail::unchecked_t, T>;
2097 template <typename T, typename U = T>
2098 class supports_op_less : public meta_detail::supports_op_less_test<T, U> {};
2100 template <typename T, typename U = T>
2101 class supports_op_equal : public meta_detail::supports_op_equal_test<T, U> {};
2103 template <typename T, typename U = T>
2104 class supports_op_less_equal : public meta_detail::supports_op_less_equal_test<T, U> {};
2106 template <typename T, typename U = T>
2107 class supports_op_left_shift : public meta_detail::supports_op_left_shift_test<T, U> {};
2109 template <typename T>
2110 class supports_adl_to_string : public meta_detail::supports_adl_to_string_test<T> {};
2112 template <typename T>
2113 class supports_to_string_member : public meta::boolean<meta_detail::has_to_string_test<meta_detail::non_void_t<T>>::value> {};
2115 template <typename T>
2116 using is_callable = boolean<meta_detail::is_callable<T>::value>;
2118 template <typename T>
2119 constexpr inline bool is_callable_v = is_callable<T>::value;
2121 template <typename T>
2122 struct has_begin_end : decltype(meta_detail::has_begin_end_impl::test<T>(0)) {};
2124 template <typename T>
2125 constexpr inline bool has_begin_end_v = has_begin_end<T>::value;
2127 template <typename T>
2128 struct has_key_value_pair : decltype(meta_detail::has_key_value_pair_impl::test<T>(0)) {};
2130 template <typename T>
2131 struct has_key_type : decltype(meta_detail::has_key_type_impl::test<T>(0)) {};
2133 template <typename T>
2134 struct has_key_comp : decltype(meta_detail::has_key_comp_impl::test<T>(0)) {};
2136 template <typename T>
2137 struct has_load_factor : decltype(meta_detail::has_load_factor_impl::test<T>(0)) {};
2139 template <typename T>
2140 struct has_mapped_type : decltype(meta_detail::has_mapped_type_impl::test<T>(0)) {};
2142 template <typename T>
2143 struct has_iterator : decltype(meta_detail::has_iterator_impl::test<T>(0)) {};
2145 template <typename T>
2146 struct has_value_type : decltype(meta_detail::has_value_type_impl::test<T>(0)) {};
2148 template <typename T>
2149 using has_push_back = meta::boolean<meta_detail::has_push_back_test<T>::value>;
2151 template <typename T>
2152 using has_max_size = meta::boolean<meta_detail::has_max_size_test<T>::value>;
2154 template <typename T>
2155 using has_insert = meta::boolean<meta_detail::has_insert_test<T>::value>;
2157 template <typename T>
2158 using has_insert_after = meta::boolean<meta_detail::has_insert_after_test<T>::value>;
2160 template <typename T>
2161 using has_size = meta::boolean<meta_detail::has_size_test<T>::value>;
2163 template <typename T>
2164 using is_associative = meta::all<has_key_type<T>, has_key_value_pair<T>, has_mapped_type<T>>;
2166 template <typename T>
2167 using is_lookup = meta::all<has_key_type<T>, has_value_type<T>>;
2169 template <typename T>
2170 using is_ordered = meta::all<has_key_comp<T>, meta::neg<has_load_factor<T>>>;
2172 template <typename T>
2173 using is_matched_lookup = meta_detail::is_matched_lookup_impl<T, is_lookup<T>::value>;
2175 template <typename T>
2176 using is_initializer_list = meta::is_specialization_of<T, std::initializer_list>;
2178 template <typename T>
2179 constexpr inline bool is_initializer_list_v = is_initializer_list<T>::value;
2181 template <typename T, typename CharT = char>
2182 using is_string_literal_array_of = boolean<std::is_array_v<T> && std::is_same_v<std::remove_all_extents_t<T>, CharT>>;
2184 template <typename T, typename CharT = char>
2185 constexpr inline bool is_string_literal_array_of_v = is_string_literal_array_of<T, CharT>::value;
2187 template <typename T>
2188 using is_string_literal_array = boolean<std::is_array_v<T> && any_same_v<std::remove_all_extents_t<T>, char, char16_t, char32_t, wchar_t>>;
2190 template <typename T>
2191 constexpr inline bool is_string_literal_array_v = is_string_literal_array<T>::value;
2193 template <typename T, typename CharT>
2194 struct is_string_of : std::false_type {};
2196 template <typename CharT, typename CharTargetT, typename TraitsT, typename AllocT>
2197 struct is_string_of<std::basic_string<CharT, TraitsT, AllocT>, CharTargetT> : std::is_same<CharT, CharTargetT> {};
2199 template <typename T, typename CharT>
2200 constexpr inline bool is_string_of_v = is_string_of<T, CharT>::value;
2202 template <typename T, typename CharT>
2203 struct is_string_view_of : std::false_type {};
2205 template <typename CharT, typename CharTargetT, typename TraitsT>
2206 struct is_string_view_of<std::basic_string_view<CharT, TraitsT>, CharTargetT> : std::is_same<CharT, CharTargetT> {};
2208 template <typename T, typename CharT>
2209 constexpr inline bool is_string_view_of_v = is_string_view_of<T, CharT>::value;
2211 template <typename T>
2212 using is_string_like
2213 = meta::boolean<is_specialization_of_v<T, std::basic_string> || is_specialization_of_v<T, std::basic_string_view> || is_string_literal_array_v<T>>;
2215 template <typename T>
2216 constexpr inline bool is_string_like_v = is_string_like<T>::value;
2218 template <typename T, typename CharT = char>
2219 using is_string_constructible = meta::boolean<
2220 is_string_literal_array_of_v<T,
2221 CharT> || std::is_same_v<T, const CharT*> || std::is_same_v<T, CharT> || is_string_of_v<T, CharT> || std::is_same_v<T, std::initializer_list<CharT>> || is_string_view_of_v<T, CharT>>;
2223 template <typename T, typename CharT = char>
2224 constexpr inline bool is_string_constructible_v = is_string_constructible<T, CharT>::value;
2226 template <typename T>
2227 using is_string_like_or_constructible = meta::boolean<is_string_like_v<T> || is_string_constructible_v<T>>;
2229 template <typename T>
2230 struct is_pair : std::false_type {};
2232 template <typename T1, typename T2>
2233 struct is_pair<std::pair<T1, T2>> : std::true_type {};
2235 template <typename T, typename Char>
2236 using is_c_str_of = any<std::is_same<T, const Char*>, std::is_same<T, Char const* const>, std::is_same<T, Char*>, is_string_of<T, Char>,
2237 is_string_literal_array_of<T, Char>>;
2239 template <typename T, typename Char>
2240 constexpr inline bool is_c_str_of_v = is_c_str_of<T, Char>::value;
2242 template <typename T>
2243 using is_c_str = is_c_str_of<T, char>;
2245 template <typename T>
2246 constexpr inline bool is_c_str_v = is_c_str<T>::value;
2248 template <typename T>
2249 struct is_move_only : all<neg<std::is_reference<T>>, neg<std::is_copy_constructible<unqualified_t<T>>>, std::is_move_constructible<unqualified_t<T>>> {};
2251 template <typename T>
2252 using is_not_move_only = neg<is_move_only<T>>;
2254 namespace meta_detail {
2255 template <typename T>
2256 decltype(auto) force_tuple(T&& x) {
2257 if constexpr (meta::is_specialization_of_v<meta::unqualified_t<T>, std::tuple>) {
2258 return std::forward<T>(x);
2261 return std::tuple<T>(std::forward<T>(x));
2266 template <typename... X>
2267 decltype(auto) tuplefy(X&&... x) {
2268 return std::tuple_cat(meta_detail::force_tuple(std::forward<X>(x))...);
2271 template <typename T, typename = void>
2272 struct iterator_tag {
2273 using type = std::input_iterator_tag;
2276 template <typename T>
2277 struct iterator_tag<T, conditional_t<false, typename std::iterator_traits<T>::iterator_category, void>> {
2278 using type = typename std::iterator_traits<T>::iterator_category;
2287 const bool default_safe_function_calls =
2288 #if SOL_IS_ON(SOL_SAFE_FUNCTION_CALLS_I_)
2295 namespace meta { namespace meta_detail {
2298 namespace stack { namespace stack_detail {
2299 using undefined_method_func = void (*)(stack_reference);
2301 template <typename T>
2302 void set_undefined_methods_on(stack_reference);
2304 struct undefined_metatable;
2317 #if SOL_IS_ON(SOL_USE_CXX_LUA_I_)
2320 #include <lauxlib.h>
2321 #elif SOL_IS_ON(SOL_USE_LUA_HPP_I_)
2326 #include <lauxlib.h>
2331 #if defined(SOL_LUAJIT)
2332 #if (SOL_LUAJIT != 0)
2333 #define SOL_USE_LUAJIT_I_ SOL_ON
2335 #define SOL_USE_LUAJIT_I_ SOL_OFF
2337 #elif defined(LUAJIT_VERSION)
2338 #define SOL_USE_LUAJIT_I_ SOL_OFF
2340 #define SOL_USE_LUAJIT_I_ SOL_DEFAULT_OFF
2343 #if SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_)
2345 #elif SOL_IS_ON(SOL_USE_LUAJIT_I_)
2351 #if defined(SOL_LUAJIT_VERSION)
2352 #define SOL_LUAJIT_VERSION_I_ SOL_LUAJIT_VERSION
2353 #elif SOL_IS_ON(SOL_USE_LUAJIT_I_)
2354 #define SOL_LUAJIT_VERSION_I_ LUAJIT_VERSION_NUM
2356 #define SOL_LUAJIT_VERSION_I_ 0
2359 #if defined(MOONJIT_VERSION)
2360 #define SOL_USE_MOONJIT_I_ SOL_ON
2362 #define SOL_USE_MOONJIT_I_ SOL_OFF
2365 #if !defined(SOL_LUA_VERSION)
2366 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 502
2367 #define SOL_LUA_VERSION LUA_VERSION_NUM
2368 #elif defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
2369 #define SOL_LUA_VERSION LUA_VERSION_NUM
2370 #elif !defined(LUA_VERSION_NUM) || !(LUA_VERSION_NUM)
2372 #define SOL_LUA_VERSION 500
2375 #define SOL_LUA_VERSION 504
2379 #if defined(SOL_LUA_VERSION)
2380 #define SOL_LUA_VESION_I_ SOL_LUA_VERSION
2382 #define SOL_LUA_VESION_I_ 504
2385 #if defined(SOL_EXCEPTIONS_ALWAYS_UNSAFE)
2386 #if (SOL_EXCEPTIONS_ALWAYS_UNSAFE != 0)
2387 #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
2389 #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_ON
2391 #elif defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
2392 #if (SOL_EXCEPTIONS_SAFE_PROPAGATION != 0)
2393 #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_ON
2395 #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
2397 #elif SOL_LUAJIT_VERSION_I_ >= 20100
2399 #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON
2400 #elif SOL_LUAJIT_VERSION_I_ >= 20000
2402 #if SOL_IS_ON(SOL_PLATFORM_X64_I_)
2403 #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON
2405 #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
2411 #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_OFF
2414 #if defined(SOL_LUAJIT_USE_EXCEPTION_TRAMPOLINE)
2415 #if (SOL_LUAJIT_USE_EXCEPTION_TRAMPOLINE != 0)
2416 #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_ON
2418 #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_OFF
2421 #if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS_I_) && SOL_IS_ON(SOL_USE_LUAJIT_I_)
2422 #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_ON
2424 #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_DEFAULT_OFF
2428 #if defined(SOL_LUAL_STREAM_HAS_CLOSE_FUNCTION)
2429 #if (SOL_LUAL_STREAM_HAS_CLOSE_FUNCTION != 0)
2430 #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_ON
2432 #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_OFF
2435 #if SOL_IS_OFF(SOL_USE_LUAJIT_I_) && (SOL_LUA_VERSION > 501)
2436 #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_ON
2438 #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_DEFAULT_OFF
2444 #if SOL_IS_ON(SOL_USE_COMPATIBILITY_LAYER_I_)
2446 #if SOL_IS_ON(SOL_USE_CXX_LUA_I_) || SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_)
2447 #ifndef COMPAT53_LUA_CPP
2448 #define COMPAT53_LUA_CPP 1
2451 #ifndef COMPAT53_INCLUDE_SOURCE
2452 #define COMPAT53_INCLUDE_SOURCE 1
2457 #ifndef KEPLER_PROJECT_COMPAT53_H_
2458 #define KEPLER_PROJECT_COMPAT53_H_
2463 #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
2467 #include <lauxlib.h>
2469 #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
2473 #ifndef COMPAT53_PREFIX
2478 # define COMPAT53_PREFIX kp_compat53
2481 #ifndef COMPAT53_API
2482 # if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE
2483 # if defined(__GNUC__) || defined(__clang__)
2484 # define COMPAT53_API __attribute__((__unused__)) static inline
2486 # define COMPAT53_API static inline
2490 # define COMPAT53_API extern
2494 #define COMPAT53_CONCAT_HELPER(a, b) a##b
2495 #define COMPAT53_CONCAT(a, b) COMPAT53_CONCAT_HELPER(a, b)
2498 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
2512 # define LUA_OPADD 0
2515 # define LUA_OPSUB 1
2518 # define LUA_OPMUL 2
2521 # define LUA_OPDIV 3
2524 # define LUA_OPMOD 4
2527 # define LUA_OPPOW 5
2530 # define LUA_OPUNM 6
2546 #if !defined(LUA_ERRGCMM)
2552 # define LUA_ERRGCMM (LUA_ERRERR + 2)
2555 #if !defined(MOONJIT_VERSION)
2556 typedef size_t lua_Unsigned;
2559 typedef struct luaL_Buffer_53 {
2566 #define luaL_Buffer luaL_Buffer_53
2572 typedef struct luaL_Stream {
2576 #define lua_absindex COMPAT53_CONCAT(COMPAT53_PREFIX, _absindex)
2577 COMPAT53_API int lua_absindex(lua_State *L, int i);
2579 #define lua_arith COMPAT53_CONCAT(COMPAT53_PREFIX, _arith)
2580 COMPAT53_API void lua_arith(lua_State *L, int op);
2582 #define lua_compare COMPAT53_CONCAT(COMPAT53_PREFIX, _compare)
2583 COMPAT53_API int lua_compare(lua_State *L, int idx1, int idx2, int op);
2585 #define lua_copy COMPAT53_CONCAT(COMPAT53_PREFIX, _copy)
2586 COMPAT53_API void lua_copy(lua_State *L, int from, int to);
2588 #define lua_getuservalue(L, i) \
2589 (lua_getfenv((L), (i)), lua_type((L), -1))
2590 #define lua_setuservalue(L, i) \
2591 (luaL_checktype((L), -1, LUA_TTABLE), lua_setfenv((L), (i)))
2593 #define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len)
2594 COMPAT53_API void lua_len(lua_State *L, int i);
2596 #define lua_pushstring(L, s) \
2597 (lua_pushstring((L), (s)), lua_tostring((L), -1))
2599 #define lua_pushlstring(L, s, len) \
2600 ((((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))), lua_tostring((L), -1))
2602 #ifndef luaL_newlibtable
2603 # define luaL_newlibtable(L, l) \
2604 (lua_createtable((L), 0, sizeof((l))/sizeof(*(l))-1))
2607 # define luaL_newlib(L, l) \
2608 (luaL_newlibtable((L), (l)), luaL_register((L), NULL, (l)))
2611 #ifndef lua_pushglobaltable
2612 # define lua_pushglobaltable(L) \
2613 lua_pushvalue((L), LUA_GLOBALSINDEX)
2615 #define lua_rawgetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawgetp)
2616 COMPAT53_API int lua_rawgetp(lua_State *L, int i, const void *p);
2618 #define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp)
2619 COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p);
2621 #define lua_rawlen(L, i) lua_objlen((L), (i))
2623 #define lua_tointeger(L, i) lua_tointegerx((L), (i), NULL)
2625 #define lua_tonumberx COMPAT53_CONCAT(COMPAT53_PREFIX, _tonumberx)
2626 COMPAT53_API lua_Number lua_tonumberx(lua_State *L, int i, int *isnum);
2628 #define luaL_checkversion COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkversion)
2629 COMPAT53_API void luaL_checkversion(lua_State *L);
2631 #define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53)
2632 COMPAT53_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char* source, const char* mode);
2634 #define luaL_loadfilex COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadfilex)
2635 COMPAT53_API int luaL_loadfilex(lua_State *L, const char *filename, const char *mode);
2637 #define luaL_loadbufferx COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadbufferx)
2638 COMPAT53_API int luaL_loadbufferx(lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);
2640 #define luaL_checkstack COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkstack_53)
2641 COMPAT53_API void luaL_checkstack(lua_State *L, int sp, const char *msg);
2643 #define luaL_getsubtable COMPAT53_CONCAT(COMPAT53_PREFIX, L_getsubtable)
2644 COMPAT53_API int luaL_getsubtable(lua_State* L, int i, const char *name);
2646 #define luaL_len COMPAT53_CONCAT(COMPAT53_PREFIX, L_len)
2647 COMPAT53_API lua_Integer luaL_len(lua_State *L, int i);
2649 #define luaL_setfuncs COMPAT53_CONCAT(COMPAT53_PREFIX, L_setfuncs)
2650 COMPAT53_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup);
2652 #define luaL_setmetatable COMPAT53_CONCAT(COMPAT53_PREFIX, L_setmetatable)
2653 COMPAT53_API void luaL_setmetatable(lua_State *L, const char *tname);
2655 #define luaL_testudata COMPAT53_CONCAT(COMPAT53_PREFIX, L_testudata)
2656 COMPAT53_API void *luaL_testudata(lua_State *L, int i, const char *tname);
2658 #define luaL_traceback COMPAT53_CONCAT(COMPAT53_PREFIX, L_traceback)
2659 COMPAT53_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level);
2661 #define luaL_fileresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_fileresult)
2662 COMPAT53_API int luaL_fileresult(lua_State *L, int stat, const char *fname);
2664 #define luaL_execresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_execresult)
2665 COMPAT53_API int luaL_execresult(lua_State *L, int stat);
2667 #define lua_callk(L, na, nr, ctx, cont) \
2668 ((void)(ctx), (void)(cont), lua_call((L), (na), (nr)))
2669 #define lua_pcallk(L, na, nr, err, ctx, cont) \
2670 ((void)(ctx), (void)(cont), lua_pcall((L), (na), (nr), (err)))
2672 #define lua_resume(L, from, nargs) \
2673 ((void)(from), lua_resume((L), (nargs)))
2675 #define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53)
2676 COMPAT53_API void luaL_buffinit(lua_State *L, luaL_Buffer_53 *B);
2678 #define luaL_prepbuffsize COMPAT53_CONCAT(COMPAT53_PREFIX, _prepbufsize_53)
2679 COMPAT53_API char *luaL_prepbuffsize(luaL_Buffer_53 *B, size_t s);
2681 #define luaL_addlstring COMPAT53_CONCAT(COMPAT53_PREFIX, _addlstring_53)
2682 COMPAT53_API void luaL_addlstring(luaL_Buffer_53 *B, const char *s, size_t l);
2684 #define luaL_addvalue COMPAT53_CONCAT(COMPAT53_PREFIX, _addvalue_53)
2685 COMPAT53_API void luaL_addvalue(luaL_Buffer_53 *B);
2687 #define luaL_pushresult COMPAT53_CONCAT(COMPAT53_PREFIX, _pushresult_53)
2688 COMPAT53_API void luaL_pushresult(luaL_Buffer_53 *B);
2690 #undef luaL_buffinitsize
2691 #define luaL_buffinitsize(L, B, s) \
2692 (luaL_buffinit((L), (B)), luaL_prepbuffsize((B), (s)))
2694 #undef luaL_prepbuffer
2695 #define luaL_prepbuffer(B) \
2696 luaL_prepbuffsize((B), LUAL_BUFFERSIZE)
2699 #define luaL_addchar(B, c) \
2700 ((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize((B), 1)), \
2701 ((B)->ptr[(B)->nelems++] = (c)))
2704 #define luaL_addsize(B, s) \ 2705 ((B)->nelems += (s)) 2707 #undef luaL_addstring 2708 #define luaL_addstring(B, s) \ 2709 luaL_addlstring((B), (s), strlen((s))) 2711 #undef luaL_pushresultsize 2712 #define luaL_pushresultsize(B, s) \ 2713 (luaL_addsize((B), (s)), luaL_pushresult((B))) 2715 #if defined(LUA_COMPAT_APIINTCASTS) 2716 #define lua_pushunsigned(L, n) \ 2717 lua_pushinteger((L), (lua_Integer)(n)) 2718 #define lua_tounsignedx(L, i, is) \ 2719 ((lua_Unsigned)lua_tointegerx((L), (i), (is))) 2720 #define lua_tounsigned(L, i) \ 2721 lua_tounsignedx((L), (i), NULL) 2722 #define luaL_checkunsigned(L, a) \ 2723 ((lua_Unsigned)luaL_checkinteger((L), (a))) 2724 #define luaL_optunsigned(L, a, d) \ 2725 ((lua_Unsigned)luaL_optinteger((L), (a), (lua_Integer)(d))) 2731 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502 2735 typedef int(*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);
2737 #define lua_dump(L, w, d, s) \ 2738 ((void)(s), lua_dump((L), (w), (d))) 2740 #define lua_getfield(L, i, k) \ 2741 (lua_getfield((L), (i), (k)), lua_type((L), -1)) 2743 #define lua_gettable(L, i) \ 2744 (lua_gettable((L), (i)), lua_type((L), -1)) 2746 #define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti) 2749 #define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger) 2752 #define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx_53) 2755 #define lua_numbertointeger(n, p) \ 2756 ((*(p) = (lua_Integer)(n)), 1) 2758 #define lua_rawget(L, i) \ 2759 (lua_rawget((L), (i)), lua_type((L), -1)) 2761 #define lua_rawgeti(L, i, n) \ 2762 (lua_rawgeti((L), (i), (n)), lua_type((L), -1)) 2764 #define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate) 2767 #define lua_seti COMPAT53_CONCAT(COMPAT53_PREFIX, _seti) 2770 #define lua_stringtonumber COMPAT53_CONCAT(COMPAT53_PREFIX, _stringtonumber) 2773 #define luaL_tolstring COMPAT53_CONCAT(COMPAT53_PREFIX, L_tolstring) 2776 #define luaL_getmetafield(L, o, e) \ 2777 (luaL_getmetafield((L), (o), (e)) ? lua_type((L), -1) : LUA_TNIL) 2779 #define luaL_newmetatable(L, tn) \ 2780 (luaL_newmetatable((L), (tn)) ? (lua_pushstring((L), (tn)), lua_setfield((L), -2, "__name"), 1) : 0) 2782 #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53) 2784 lua_CFunction openf, int glb);
2789 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 502 2798 #define lua_getglobal(L, n) \ 2799 (lua_getglobal((L), (n)), lua_type((L), -1)) 2801 #define lua_getuservalue(L, i) \ 2802 (lua_getuservalue((L), (i)), lua_type((L), -1)) 2804 #define lua_pushlstring(L, s, len) \ 2805 (((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))) 2807 #define lua_rawgetp(L, i, p) \ 2808 (lua_rawgetp((L), (i), (p)), lua_type((L), -1)) 2810 #define LUA_KFUNCTION(_name) \ 2811 static int (_name)(lua_State *L, int status, lua_KContext ctx); \ 2812 static int (_name ## _52)(lua_State *L) { \ 2814 int status = lua_getctx(L, &ctx); \ 2815 return (_name)(L, status, ctx); \ 2817 static int (_name)(lua_State *L, int status, lua_KContext ctx) 2819 #define lua_pcallk(L, na, nr, err, ctx, cont) \ 2820 lua_pcallk((L), (na), (nr), (err), (ctx), cont ## _52) 2822 #define lua_callk(L, na, nr, ctx, cont) \ 2823 lua_callk((L), (na), (nr), (ctx), cont ## _52) 2825 #define lua_yieldk(L, nr, ctx, cont) \ 2826 lua_yieldk((L), (nr), (ctx), cont ## _52) 2830 # define lua_call(L, na, nr) \ 2831 (lua_callk)((L), (na), (nr), 0, NULL) 2836 # define lua_pcall(L, na, nr, err) \ 2837 (lua_pcallk)((L), (na), (nr), (err), 0, NULL) 2842 # define lua_yield(L, nr) \ 2843 (lua_yieldk)((L), (nr), 0, NULL) 2849 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 504 2851 # error "unsupported Lua version (i.e. not Lua 5.1, 5.2, 5.3, or 5.4)" 2857 #ifndef LUA_KFUNCTION 2858 #define LUA_KFUNCTION(_name) \ 2859 static int (_name)(lua_State *L, int status, lua_KContext ctx) 2862 #if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE == 1 2873 #ifndef KEPLER_PROJECT_COMPAT53_C_ 2874 #define KEPLER_PROJECT_COMPAT53_C_ 2877 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501 2879 #ifndef COMPAT53_FOPEN_NO_LOCK 2880 #if defined(_MSC_VER) 2881 #define COMPAT53_FOPEN_NO_LOCK 1 2883 #define COMPAT53_FOPEN_NO_LOCK 0 2887 #if defined(_MSC_VER) && COMPAT53_FOPEN_NO_LOCK 2891 #ifndef COMPAT53_HAVE_STRERROR_R 2892 #if defined(__GLIBC__) || defined(_POSIX_VERSION) || defined(__APPLE__) || (!defined(__MINGW32__) && defined(__GNUC__) && (__GNUC__ < 6)) 2893 #define COMPAT53_HAVE_STRERROR_R 1 2895 #define COMPAT53_HAVE_STRERROR_R 0 2899 #ifndef COMPAT53_HAVE_STRERROR_S 2900 #if defined(_MSC_VER) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || (defined(__STDC_LIB_EXT1__) && __STDC_LIB_EXT1__) 2901 #define COMPAT53_HAVE_STRERROR_S 1 2903 #define COMPAT53_HAVE_STRERROR_S 0 2907 #ifndef COMPAT53_LUA_FILE_BUFFER_SIZE 2908 #define COMPAT53_LUA_FILE_BUFFER_SIZE 4096 2911 static char* compat53_strerror(int en, char* buff, size_t sz) {
2912 #if COMPAT53_HAVE_STRERROR_R 2921 if (buff[0] ==
'\0') {
2925 return strerror(en);
2929 #elif COMPAT53_HAVE_STRERROR_S 2941 return strerror(en);
2951 static void compat53_call_lua(
lua_State* L,
char const code[],
size_t len,
int nargs,
int nret) {
2964 static const char compat53_arith_code[]
2965 =
"local op,a,b=...\n" 2966 "if op==0 then return a+b\n" 2967 "elseif op==1 then return a-b\n" 2968 "elseif op==2 then return a*b\n" 2969 "elseif op==3 then return a/b\n" 2970 "elseif op==4 then return a%b\n" 2971 "elseif op==5 then return a^b\n" 2972 "elseif op==6 then return -a\n" 2977 luaL_error(L,
"invalid 'op' argument for lua_arith");
2979 if (op == LUA_OPUNM)
2983 compat53_call_lua(L, compat53_arith_code,
sizeof(compat53_arith_code) - 1, 3, 1);
2986 static const char compat53_compare_code[]
2994 return lua_equal(L, idx1, idx2);
2996 return lua_lessthan(L, idx1, idx2);
3003 compat53_call_lua(L, compat53_compare_code,
sizeof(compat53_compare_code) - 1, 2, 1);
3008 luaL_error(L,
"invalid 'op' argument for lua_compare");
3055 if (isnum != NULL) {
3099 luaL_error(L,
"object length is not an integer");
3105 for (; l->
name != NULL; l++) {
3108 for (i = 0; i < nup; i++)
3138 static int compat53_countlevels(
lua_State* L) {
3148 int m = (li + le) / 2;
3157 static int compat53_findfield(
lua_State* L,
int objidx,
int level) {
3167 else if (compat53_findfield(L, objidx, level - 1)) {
3184 if (compat53_findfield(L, top + 1, 2)) {
3198 else if (*ar->
what ==
'm')
3200 else if (*ar->
what ==
'C') {
3201 if (compat53_pushglobalfuncname(L, ar)) {
3212 #define COMPAT53_LEVELS1 12 3213 #define COMPAT53_LEVELS2 10 3218 int numlevels = compat53_countlevels(L1);
3219 int mark = (numlevels > COMPAT53_LEVELS1 + COMPAT53_LEVELS2) ? COMPAT53_LEVELS1 : 0;
3224 if (level == mark) {
3226 level = numlevels - COMPAT53_LEVELS2;
3234 compat53_pushfuncname(L, &ar);
3242 const char* serr = NULL;
3244 char buf[512] = { 0 };
3251 serr = compat53_strerror(en, buf,
sizeof(buf));
3261 static int compat53_checkmode(
lua_State* L,
const char*
mode,
const char* modename,
int err) {
3262 if (mode && strchr(mode, modename[0]) == NULL) {
3263 lua_pushfstring(L,
"attempt to load a %s chunk (mode is '%s')", modename, mode);
3272 int has_peeked_data;
3273 const char* peeked_data;
3274 size_t peeked_data_size;
3275 } compat53_reader_data;
3277 static const char* compat53_reader(
lua_State* L,
void* ud,
size_t*
size) {
3278 compat53_reader_data*
data = (compat53_reader_data*)ud;
3279 if (data->has_peeked_data) {
3280 data->has_peeked_data = 0;
3281 *size = data->peeked_data_size;
3282 return data->peeked_data;
3285 return data->reader(L, data->ud, size);
3290 compat53_reader_data compat53_data = { reader,
data, 1, 0, 0 };
3291 compat53_data.peeked_data = reader(L, data, &(compat53_data.peeked_data_size));
3292 if (compat53_data.peeked_data && compat53_data.peeked_data_size && compat53_data.peeked_data[0] ==
LUA_SIGNATURE[0])
3293 status = compat53_checkmode(L, mode,
"binary",
LUA_ERRSYNTAX);
3295 status = compat53_checkmode(L, mode,
"text",
LUA_ERRSYNTAX);
3300 return lua_load(L, compat53_reader, &compat53_data, source);
3301 #define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53) 3307 char buff[COMPAT53_LUA_FILE_BUFFER_SIZE];
3310 static const char* compat53_getF(
lua_State* L,
void* ud,
size_t* size) {
3311 compat53_LoadF* lf = (compat53_LoadF*)ud;
3323 *size = fread(lf->buff, 1,
sizeof(lf->buff), lf->f);
3328 static int compat53_errfile(
lua_State* L,
const char* what,
int fnameindex) {
3329 char buf[512] = { 0 };
3330 const char* serr = compat53_strerror(errno, buf,
sizeof(buf));
3331 const char* filename =
lua_tostring(L, fnameindex) + 1;
3337 static int compat53_skipBOM(compat53_LoadF* lf) {
3338 const char* p =
"\xEF\xBB\xBF";
3343 if (c == EOF || c != *(
const unsigned char*)p++)
3345 lf->buff[lf->n++] = (char)c;
3346 }
while (*p !=
'\0');
3358 static int compat53_skipcomment(compat53_LoadF* lf,
int* cp) {
3359 int c = *cp = compat53_skipBOM(lf);
3363 }
while (c != EOF && c !=
'\n');
3373 int status, readstatus;
3376 if (filename == NULL) {
3382 #if defined(_MSC_VER) 3393 #if COMPAT53_FOPEN_NO_LOCK 3394 lf.f = _fsopen(filename,
"r", _SH_DENYNO);
3396 return compat53_errfile(L,
"open", fnameindex);
3398 if (fopen_s(&lf.f, filename,
"r") != 0)
3399 return compat53_errfile(L,
"open", fnameindex);
3402 lf.f = fopen(filename,
"r");
3404 return compat53_errfile(L,
"open", fnameindex);
3407 if (compat53_skipcomment(&lf, &c))
3408 lf.buff[lf.n++] =
'\n';
3410 #if defined(_MSC_VER) 3411 if (freopen_s(&lf.f, filename,
"rb", lf.f) != 0)
3412 return compat53_errfile(L,
"reopen", fnameindex);
3414 lf.f = freopen(filename,
"rb", lf.f);
3416 return compat53_errfile(L,
"reopen", fnameindex);
3418 compat53_skipcomment(&lf, &c);
3421 lf.buff[lf.n++] = (char)c;
3423 readstatus = ferror(lf.f);
3428 return compat53_errfile(L,
"read", fnameindex);
3437 status = compat53_checkmode(L, mode,
"binary",
LUA_ERRSYNTAX);
3440 status = compat53_checkmode(L, mode,
"text",
LUA_ERRSYNTAX);
3447 #if !defined(l_inspectstat) \ 3448 && (defined(unix) || defined(__unix) || defined(__unix__) || defined(__TOS_AIX__) || defined(_SYSTYPE_BSD) || (defined(__APPLE__) && defined(__MACH__))) 3453 #if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L 3454 #include <sys/wait.h> 3455 #define l_inspectstat(stat, what) \ 3456 if (WIFEXITED(stat)) { \ 3457 stat = WEXITSTATUS(stat); \ 3459 else if (WIFSIGNALED(stat)) { \ 3460 stat = WTERMSIG(stat); \ 3467 #if !defined(l_inspectstat) 3468 #define l_inspectstat(stat, what) ((void)0) 3472 const char* what =
"exit";
3477 if (*what ==
'e' && stat == 0)
3493 B->ptr = B->b.buffer;
3500 if (B->capacity - B->nelems < s) {
3501 char* newptr = NULL;
3502 size_t newcap = B->capacity * 2;
3503 if (newcap - B->nelems < s)
3504 newcap = B->nelems + s;
3505 if (newcap < B->capacity)
3508 memcpy(newptr, B->ptr, B->nelems);
3509 if (B->ptr != B->b.buffer)
3512 B->capacity = newcap;
3514 return B->ptr + B->nelems;
3526 luaL_error(B->L2,
"cannot convert value to string");
3527 if (B->ptr != B->b.buffer)
3530 lua_remove(B->L2, B->ptr != B->b.buffer ? -2 : -1);
3535 if (B->ptr != B->b.buffer)
3542 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502 3576 static void compat53_reverse(
lua_State* L,
int a,
int b) {
3577 for (; a < b; ++a, --b) {
3591 if (n > 0 && n < n_elems) {
3594 compat53_reverse(L, idx, idx + n - 1);
3595 compat53_reverse(L, idx + n, idx + n_elems - 1);
3596 compat53_reverse(L, idx, idx + n_elems - 1);
3608 #if !defined(lua_str2number) 3609 #define lua_str2number(s, p) strtod((s), (p)) 3616 while (*endptr !=
'\0' && isspace((
unsigned char)*endptr))
3618 if (*endptr ==
'\0') {
3620 return endptr - s + 1;
3629 char const* name = NULL;
3655 luaL_error(L,
"'__tostring' must return a string");
3716 #ifndef NOT_KEPLER_PROJECT_COMPAT54_H_ 3717 #define NOT_KEPLER_PROJECT_COMPAT54_H_ 3719 #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) 3725 #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) 3729 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 504 3731 #if !defined(LUA_ERRGCMM) 3735 # define LUA_ERRGCMM (LUA_ERRERR + 2) 3738 #endif // Lua 5.4 only 3740 #endif // NOT_KEPLER_PROJECT_COMPAT54_H_// end of sol/compatibility/compat-5.4.h 3752 template <
typename Allocator = std::allocator<std::byte>>
3753 class basic_bytecode :
private std::vector<std::byte, Allocator> {
3755 using base_t = std::vector<std::byte, Allocator>;
3758 using typename base_t::allocator_type;
3759 using typename base_t::const_iterator;
3760 using typename base_t::const_pointer;
3761 using typename base_t::const_reference;
3762 using typename base_t::const_reverse_iterator;
3763 using typename base_t::difference_type;
3764 using typename base_t::iterator;
3765 using typename base_t::pointer;
3767 using typename base_t::reverse_iterator;
3768 using typename base_t::size_type;
3769 using typename base_t::value_type;
3771 using base_t::base_t;
3772 using base_t::operator=;
3775 using base_t::empty;
3776 using base_t::max_size;
3780 using base_t::operator[];
3782 using base_t::front;
3784 using base_t::begin;
3785 using base_t::cbegin;
3789 using base_t::crbegin;
3790 using base_t::crend;
3791 using base_t::rbegin;
3794 using base_t::get_allocator;
3798 using base_t::emplace;
3799 using base_t::emplace_back;
3800 using base_t::erase;
3801 using base_t::insert;
3802 using base_t::pop_back;
3803 using base_t::push_back;
3805 using base_t::resize;
3806 using base_t::shrink_to_fit;
3813 template <
typename Container>
3815 using storage_t = Container;
3816 const std::byte* p_code =
static_cast<const std::byte*
>(
memory);
3817 storage_t& bc = *
static_cast<storage_t*
>(
userdata);
3818 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 3819 bc.insert(bc.cend(), p_code, p_code + memory_size);
3822 bc.insert(bc.cend(), p_code, p_code + memory_size);
3847 #include <stdexcept> 3867 error_result(
const char* fmt,
const char* msg) : results(0), format_string(fmt) {
3868 args_strings[0] = msg;
3880 class error :
public std::runtime_error {
3900 virtual const char*
what() const noexcept
override {
3901 return what_reason.c_str();
3922 template <
typename T>
3924 template <
typename T>
3936 #if SOL_IS_ON(SOL_USE_BOOST_I_) 3937 #include <boost/optional.hpp> 3941 #define SOL_TL_OPTIONAL_VERSION_MAJOR 0 3942 #define SOL_TL_OPTIONAL_VERSION_MINOR 5 3944 #include <exception> 3945 #include <functional> 3947 #include <type_traits> 3952 #if (defined(_MSC_VER) && _MSC_VER == 1900) 3953 #define SOL_TL_OPTIONAL_MSVC2015 3956 #if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 9 && !defined(__clang__)) 3957 #define SOL_TL_OPTIONAL_GCC49 3960 #if (defined(__GNUC__) && __GNUC__ == 5 && __GNUC_MINOR__ <= 4 && !defined(__clang__)) 3961 #define SOL_TL_OPTIONAL_GCC54 3964 #if (defined(__GNUC__) && __GNUC__ == 5 && __GNUC_MINOR__ <= 5 && !defined(__clang__)) 3965 #define SOL_TL_OPTIONAL_GCC55 3968 #if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 9 && !defined(__clang__)) 3969 #define SOL_TL_OPTIONAL_NO_CONSTRR 3971 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) std::has_trivial_copy_constructor<T>::value 3972 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) std::has_trivial_copy_assign<T>::value 3974 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value 3976 #elif (defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__)) 3977 #ifndef SOL_TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX 3978 #define SOL_TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX 3981 struct is_trivially_copy_constructible : std::is_trivially_copy_constructible<T> {};
3982 #ifdef _GLIBCXX_VECTOR 3983 template <
class T,
class A>
3984 struct is_trivially_copy_constructible<std::vector<T, A>> : std::is_trivially_copy_constructible<T> {};
3989 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) sol::detail::is_trivially_copy_constructible<T>::value 3990 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) std::is_trivially_copy_assignable<T>::value 3991 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value 3993 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) std::is_trivially_copy_constructible<T>::value 3994 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) std::is_trivially_copy_assignable<T>::value 3995 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value 3998 #if __cplusplus > 201103L 3999 #define SOL_TL_OPTIONAL_CXX14 4002 #if (__cplusplus == 201103L || defined(SOL_TL_OPTIONAL_MSVC2015) || defined(SOL_TL_OPTIONAL_GCC49)) 4003 #define SOL_TL_OPTIONAL_11_CONSTEXPR 4005 #define SOL_TL_OPTIONAL_11_CONSTEXPR constexpr 4010 #ifndef SOL_TL_MONOSTATE_INPLACE_MUTEX 4011 #define SOL_TL_MONOSTATE_INPLACE_MUTEX 4021 #ifndef SOL_TL_TRAITS_MUTEX 4022 #define SOL_TL_TRAITS_MUTEX 4030 template <
bool E,
class T =
void>
4032 template <
bool B,
class T,
class F>
4040 template <
class B,
class... Bs>
4043 #if defined(_LIBCPP_VERSION) && __cplusplus == 201103L 4044 #define SOL_TL_OPTIONAL_LIBCXX_MEM_FN_WORKAROUND 4047 #ifdef SOL_TL_OPTIONAL_LIBCXX_MEM_FN_WORKAROUND 4049 struct is_pointer_to_non_const_member_func : std::false_type {};
4050 template <
class T,
class Ret,
class... Args>
4051 struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...)> : std::true_type {};
4052 template <
class T,
class Ret,
class... Args>
4053 struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...)&> : std::true_type {};
4054 template <
class T,
class Ret,
class... Args>
4055 struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...) &&> : std::true_type {};
4056 template <
class T,
class Ret,
class... Args>
4057 struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...) volatile> : std::true_type {};
4058 template <
class T,
class Ret,
class... Args>
4059 struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...) volatile&> : std::true_type {};
4060 template <
class T,
class Ret,
class... Args>
4061 struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...) volatile&&> : std::true_type {};
4064 struct is_const_or_const_ref : std::false_type {};
4066 struct is_const_or_const_ref<T const&> : std::true_type {};
4068 struct is_const_or_const_ref<T const> : std::true_type {};
4073 template <
typename Fn,
typename... Args,
4074 #ifdef SOL_TL_OPTIONAL_LIBCXX_MEM_FN_WORKAROUND 4078 constexpr
auto invoke(Fn&& f, Args&&... args) noexcept(noexcept(std::mem_fn(f)(std::forward<Args>(args)...)))
4079 -> decltype(std::mem_fn(f)(std::forward<Args>(args)...)) {
4080 return std::mem_fn(f)(std::forward<Args>(args)...);
4084 constexpr
auto invoke(Fn&& f, Args&&... args) noexcept(noexcept(
std::forward<Fn>(f)(
std::forward<Args>(args)...)))
4085 -> decltype(
std::forward<Fn>(f)(
std::forward<Args>(args)...)) {
4086 return std::forward<Fn>(f)(std::forward<Args>(args)...);
4090 template <
class F,
class,
class... Us>
4093 template <
class F,
class... Us>
4098 template <
class F,
class... Us>
4101 template <
class F,
class... Us>
4110 template <
class... Ts>
4125 template <
class F,
class U,
class = invoke_result_t<F, U>>
4129 template <
class F,
class =
void,
class... U>
4131 template <
class F,
class... U>
4133 template <
class F,
class... U>
4136 template <
class T,
class... U>
4139 template <
class T,
class... U>
4142 template <
class T,
class U>
4146 template <
class T,
class U,
class Other>
4148 && !std::is_constructible<T, optional<U>&&>::value && !std::is_constructible<T, const optional<U>&>::value
4149 && !std::is_constructible<T, const optional<U>&&>::value && !std::is_convertible<optional<U>&, T>::value
4150 && !std::is_convertible<optional<U>&&, T>::value && !std::is_convertible<const optional<U>&, T>::value
4151 && !std::is_convertible<const optional<U>&&, T>::value>;
4153 template <
class T,
class U>
4158 template <
class T,
class U,
class Other>
4160 && !std::is_constructible<T, optional<U>&>::value && !std::is_constructible<T, optional<U>&&>::value
4161 && !std::is_constructible<T, const optional<U>&>::value && !std::is_constructible<T, const optional<U>&&>::value
4162 && !std::is_convertible<optional<U>&, T>::value && !std::is_convertible<optional<U>&&, T>::value
4163 && !std::is_convertible<const optional<U>&, T>::value && !std::is_convertible<const optional<U>&&, T>::value
4164 && !std::is_assignable<T&, optional<U>&>::value && !std::is_assignable<T&, optional<U>&&>::value
4165 && !std::is_assignable<T&, const optional<U>&>::value && !std::is_assignable<T&, const optional<U>&&>::value>;
4169 template <
class T,
class U = T>
4172 template <
class T,
class U = T>
4176 namespace swap_adl_tests {
4183 template <
class T, std::
size_t N>
4184 tag swap(T (&a)[N], T (&b)[N]);
4188 template <
class,
class>
4189 std::false_type
can_swap(...) noexcept(
false);
4190 template <
class T,
class U,
class = decltype(swap(std::declval<T&>(), std::declval<U&>()))>
4191 std::true_type
can_swap(
int) noexcept(noexcept(
swap(std::declval<T&>(), std::declval<U&>())));
4193 template <
class,
class>
4195 template <
class T,
class U>
4196 std::is_same<decltype(swap(std::declval<T&>(), std::declval<U&>())),
tag>
uses_std(
int);
4200 : std::integral_constant<bool, std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value> {};
4202 template <
class T, std::
size_t N>
4205 template <
class T,
class U>
4209 template <
class T,
class U = T>
4211 decltype(detail::swap_adl_tests::can_swap<T, U>(0))::value
4212 && (!decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value
4213 || (std::is_move_assignable<T>::value && std::is_move_constructible<T>::value))> {};
4215 template <
class T, std::
size_t N>
4217 decltype(detail::swap_adl_tests::can_swap<T[N], T[N]>(0))::value
4218 && (!decltype(detail::swap_adl_tests::uses_std<T[N], T[N]>(0))::value || is_swappable<T, T>::value)> {};
4220 template <
class T,
class U = T>
4222 : std::integral_constant<bool,
4223 is_swappable<T, U>::value
4224 && ((decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value&& detail::swap_adl_tests::is_std_swap_noexcept<T>::value)
4225 || (!decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value&& detail::swap_adl_tests::is_adl_swap_noexcept<T, U>::value))> {};
4236 template <
class... U>
4243 m_has_value =
false;
4262 template <
class... U>
4274 bool m_has_value =
false;
4285 this->m_has_value =
false;
4288 template <
class... Args>
4290 new (std::addressof(this->m_value)) T(std::forward<Args>(args)...);
4291 this->m_has_value =
true;
4294 template <
class Opt>
4296 if (this->has_value()) {
4297 if (rhs.has_value()) {
4298 this->m_value = std::forward<Opt>(rhs).
get();
4302 this->m_has_value =
false;
4306 else if (rhs.has_value()) {
4307 construct(std::forward<Opt>(rhs).
get());
4312 return this->m_has_value;
4316 return this->m_value;
4319 return this->m_value;
4324 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 4325 constexpr
const T&&
get()
const&& {
4333 template <
class T,
bool = SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>
4343 using base_t::base_t;
4351 this->m_has_value =
false;
4360 #ifndef SOL_TL_OPTIONAL_GCC49 4366 template <
class T,
bool = false>
4381 this->m_has_value =
false;
4411 #ifndef SOL_TL_OPTIONAL_GCC49 4418 template <
class T,
bool = false>
4434 std::is_nothrow_move_constructible<T>::value&&
std::is_nothrow_move_assignable<T>::value) {
4536 const char*
what() const noexcept {
4537 return "Optional has no value";
4557 #if defined(SOL_TL_OPTIONAL_CXX14) && !defined(SOL_TL_OPTIONAL_GCC49) && !defined(SOL_TL_OPTIONAL_GCC54) && !defined(SOL_TL_OPTIONAL_GCC55) 4589 constexpr
auto and_then(F&& f) const& {
4596 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 4600 constexpr
auto and_then(F&& f) const&& {
4646 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 4659 #if defined(SOL_TL_OPTIONAL_CXX14) && !defined(SOL_TL_OPTIONAL_GCC49) && !defined(SOL_TL_OPTIONAL_GCC54) && !defined(SOL_TL_OPTIONAL_GCC55) 4684 constexpr
auto map(F&& f)
const& {
4691 constexpr
auto map(F&& f)
const&& {
4719 constexpr decltype(
optional_map_impl(std::declval<const optional&>(), std::declval<F&&>())) map(F&& f) const& {
4723 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 4727 constexpr decltype(
optional_map_impl(std::declval<const optional&&>(), std::declval<F&&>())) map(F&& f) const&& {
4742 template <
class F, detail::enable_if_ret_
void<F>* =
nullptr>
4747 std::forward<F>(f)();
4752 template <
class F, detail::disable_if_ret_
void<F>* =
nullptr>
4754 return has_value() ? *
this : std::forward<F>(f)();
4759 template <
class F, detail::enable_if_ret_
void<F>* =
nullptr>
4764 std::forward<F>(f)();
4769 template <
class F, detail::disable_if_ret_
void<F>* =
nullptr>
4771 return has_value() ?
std::move(*
this) : std::forward<F>(f)();
4776 template <
class F, detail::enable_if_ret_
void<F>* =
nullptr>
4781 std::forward<F>(f)();
4786 template <
class F, detail::disable_if_ret_
void<F>* =
nullptr>
4788 return has_value() ? *
this : std::forward<F>(f)();
4791 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 4792 template <
class F, detail::enable_if_ret_
void<F>* =
nullptr>
4798 std::forward<F>(f)();
4803 template <
class F, detail::disable_if_ret_
void<F>* =
nullptr>
4805 return has_value() ?
std::move(*
this) : std::forward<F>(f)();
4816 template <
class F,
class U>
4818 return has_value() ?
detail::invoke(std::forward<F>(f), **
this) : std::forward<U>(u);
4822 template <
class F,
class U>
4828 template <
class F,
class U>
4830 return has_value() ?
detail::invoke(std::forward<F>(f), **
this) : std::forward<U>(u);
4833 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 4834 template <
class F,
class U>
4850 template <
class F,
class U>
4852 return has_value() ?
detail::invoke(std::forward<F>(f), **
this) : std::forward<U>(u)();
4858 template <
class F,
class U>
4866 template <
class F,
class U>
4868 return has_value() ?
detail::invoke(std::forward<F>(f), **
this) : std::forward<U>(u)();
4871 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 4872 template <
class F,
class U>
4891 return has_value() ? *
this : rhs;
4896 return has_value() ? *
this : rhs;
4901 return has_value() ?
std::move(*
this) : rhs;
4904 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 4907 return has_value() ?
std::move(*
this) : rhs;
4913 return has_value() ? *
this :
std::move(rhs);
4918 return has_value() ? *
this :
std::move(rhs);
4926 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 4955 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 4968 constexpr
optional() noexcept = default;
4989 template <
class... Args>
4996 template <
class U,
class... Args>
4998 std::initializer_list<U> il, Args&&... args) {
4999 this->
construct(il, std::forward<Args>(args)...);
5002 #if 0 // SOL_MODIFICATION 5011 constexpr
explicit optional(U&& u) :
base(
in_place, std::forward<U>(u)) {
5022 #endif // sol3 modification 5026 template <
class U, detail::enable_from_other<T, U, const U&>* =
nullptr, detail::enable_if_t<std::is_convertible<const U&, T>::value>* =
nullptr>
5034 template <
class U, detail::enable_from_other<T, U, const U&>* =
nullptr, detail::enable_if_t<!std::is_convertible<const U&, T>::value>* =
nullptr>
5043 template <
class U, detail::enable_from_other<T, U, U&&>* =
nullptr, detail::enable_if_t<std::is_convertible<U&&, T>::value>* =
nullptr>
5051 template <
class U, detail::enable_from_other<T, U, U&&>* =
nullptr, detail::enable_if_t<!std::is_convertible<U&&, T>::value>* =
nullptr>
5057 ~optional() =
default;
5065 this->m_has_value =
false;
5075 optional& operator=(
const optional& rhs) =
default;
5081 optional& operator=(optional&& rhs) =
default;
5086 template <
class U = T, detail::enable_assign_forward<T, U>* =
nullptr>
5089 this->m_value = std::forward<U>(u);
5103 template <
class U, detail::enable_assign_from_other<T, U, const U&>* =
nullptr>
5107 this->m_value = *rhs;
5127 template <
class U, detail::enable_assign_from_other<T, U, U>* =
nullptr>
5148 template <
class... Args>
5153 this->
construct(std::forward<Args>(args)...);
5159 template <
class U,
class... Args>
5162 this->
construct(il, std::forward<Args>(args)...);
5180 this->m_value.T::~T();
5194 return std::addressof(this->m_value);
5200 return std::addressof(this->m_value);
5208 return this->m_value;
5214 return this->m_value;
5222 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 5223 constexpr
const T&&
operator*()
const&& {
5232 return this->m_has_value;
5236 constexpr
explicit operator bool() const noexcept {
5237 return this->m_has_value;
5246 return this->m_value;
5247 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 5251 #endif // No exceptions allowed 5257 return this->m_value;
5258 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 5262 #endif // No exceptions allowed 5268 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 5272 #endif // No exceptions allowed 5275 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 5280 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 5284 #endif // No exceptions allowed 5293 return has_value() ? **
this :
static_cast<T
>(std::forward<U>(u));
5300 return has_value() ? **
this :
static_cast<T
>(std::forward<U>(u));
5307 this->m_has_value =
false;
5318 template <
class T,
class U>
5323 template <
class T,
class U>
5328 template <
class T,
class U>
5329 inline constexpr
bool operator<(const optional<T>& lhs,
const optional<U>& rhs) {
5330 return rhs.
has_value() && (!lhs.has_value() || *lhs < *rhs);
5333 template <
class T,
class U>
5338 template <
class T,
class U>
5339 inline constexpr
bool operator<=(const optional<T>& lhs,
const optional<U>& rhs) {
5340 return !lhs.
has_value() || (rhs.has_value() && *lhs <= *rhs);
5343 template <
class T,
class U>
5358 return !rhs.has_value();
5368 return rhs.has_value();
5372 inline constexpr
bool operator<(const optional<T>&,
nullopt_t) noexcept {
5377 inline constexpr
bool operator<(nullopt_t, const optional<T>& rhs) noexcept {
5378 return rhs.has_value();
5382 inline constexpr
bool operator<=(const optional<T>& lhs,
nullopt_t) noexcept {
5383 return !lhs.has_value();
5387 inline constexpr
bool operator<=(nullopt_t, const optional<T>&) noexcept {
5408 return !rhs.has_value();
5416 template <
class T,
class U>
5418 return lhs.
has_value() ? *lhs == rhs :
false;
5421 template <
class T,
class U>
5423 return rhs.
has_value() ? lhs == *rhs :
false;
5426 template <
class T,
class U>
5428 return lhs.
has_value() ? *lhs != rhs :
true;
5431 template <
class T,
class U>
5433 return rhs.
has_value() ? lhs != *rhs :
true;
5436 template <
class T,
class U>
5437 inline constexpr
bool operator<(const optional<T>& lhs,
const U& rhs) {
5438 return lhs.
has_value() ? *lhs < rhs :
true;
5441 template <
class T,
class U>
5442 inline constexpr
bool operator<(const U& lhs, const optional<T>& rhs) {
5443 return rhs.has_value() ? lhs < *rhs :
false;
5446 template <
class T,
class U>
5447 inline constexpr
bool operator<=(const optional<T>& lhs,
const U& rhs) {
5448 return lhs.has_value() ? *lhs <= rhs :
true;
5451 template <
class T,
class U>
5452 inline constexpr
bool operator<=(const U& lhs, const optional<T>& rhs) {
5453 return rhs.has_value() ? lhs <= *rhs :
false;
5456 template <
class T,
class U>
5458 return lhs.
has_value() ? *lhs > rhs :
false;
5461 template <
class T,
class U>
5463 return rhs.
has_value() ? lhs > *rhs :
true;
5466 template <
class T,
class U>
5468 return lhs.
has_value() ? *lhs >= rhs :
false;
5471 template <
class T,
class U>
5473 return rhs.
has_value() ? lhs >= *rhs :
true;
5479 return lhs.swap(rhs);
5491 template <
class T,
class... Args>
5495 template <
class T,
class U,
class... Args>
5500 #if __cplusplus >= 201703L 5507 #ifdef SOL_TL_OPTIONAL_CXX14 5508 template <
class Opt,
class F,
class Ret = decltype(detail::invoke(std::declval<F>(), *std::declval<Opt>())),
5509 detail::enable_if_t<!std::is_
void<Ret>::value>* =
nullptr>
5514 template <
class Opt,
class F,
class Ret = decltype(detail::invoke(std::declval<F>(), *std::declval<Opt>())),
5515 detail::enable_if_t<std::is_
void<Ret>::value>* =
nullptr>
5517 if (opt.has_value()) {
5525 template <
class Opt,
class F,
class Ret = decltype(detail::invoke(std::declval<F>(), *std::declval<Opt>())),
5526 detail::enable_if_t<!std::is_
void<Ret>::value>* =
nullptr>
5532 template <
class Opt,
class F,
class Ret = decltype(detail::invoke(std::declval<F>(), *std::declval<Opt>())),
5533 detail::enable_if_t<std::is_
void<Ret>::value>* =
nullptr>
5536 if (opt.has_value()) {
5571 #if defined(SOL_TL_OPTIONAL_CXX14) && !defined(SOL_TL_OPTIONAL_GCC49) && !defined(SOL_TL_OPTIONAL_GCC54) && !defined(SOL_TL_OPTIONAL_GCC55) 5603 constexpr
auto and_then(F&& f)
const& {
5610 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 5614 constexpr
auto and_then(F&& f)
const&& {
5660 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 5673 #if defined(SOL_TL_OPTIONAL_CXX14) && !defined(SOL_TL_OPTIONAL_GCC49) && !defined(SOL_TL_OPTIONAL_GCC54) && !defined(SOL_TL_OPTIONAL_GCC55) 5698 constexpr
auto map(F&& f)
const& {
5705 constexpr
auto map(F&& f)
const&& {
5737 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 5755 template <
class F, detail::enable_if_ret_
void<F>* =
nullptr>
5760 std::forward<F>(f)();
5765 template <
class F, detail::disable_if_ret_
void<F>* =
nullptr>
5767 return has_value() ? *
this : std::forward<F>(f)();
5772 template <
class F, detail::enable_if_ret_
void<F>* =
nullptr>
5777 std::forward<F>(f)();
5782 template <
class F, detail::disable_if_ret_
void<F>* =
nullptr>
5784 return has_value() ?
std::move(*
this) : std::forward<F>(f)();
5789 template <
class F, detail::enable_if_ret_
void<F>* =
nullptr>
5794 std::forward<F>(f)();
5799 template <
class F, detail::disable_if_ret_
void<F>* =
nullptr>
5801 return has_value() ? *
this : std::forward<F>(f)();
5804 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 5805 template <
class F, detail::enable_if_ret_
void<F>* =
nullptr>
5811 std::forward<F>(f)();
5816 template <
class F, detail::disable_if_ret_
void<F>* =
nullptr>
5818 return has_value() ?
std::move(*
this) : std::forward<F>(f)();
5829 template <
class F,
class U>
5831 return has_value() ?
detail::invoke(std::forward<F>(f), **
this) : std::forward<U>(u);
5835 template <
class F,
class U>
5841 template <
class F,
class U>
5843 return has_value() ?
detail::invoke(std::forward<F>(f), **
this) : std::forward<U>(u);
5846 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 5847 template <
class F,
class U>
5863 template <
class F,
class U>
5865 return has_value() ?
detail::invoke(std::forward<F>(f), **
this) : std::forward<U>(u)();
5871 template <
class F,
class U>
5879 template <
class F,
class U>
5881 return has_value() ?
detail::invoke(std::forward<F>(f), **
this) : std::forward<U>(u)();
5884 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 5885 template <
class F,
class U>
5904 return has_value() ? *
this : rhs;
5909 return has_value() ? *
this : rhs;
5914 return has_value() ?
std::move(*
this) : rhs;
5917 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 5920 return has_value() ?
std::move(*
this) : rhs;
5926 return has_value() ? *
this :
std::move(rhs);
5931 return has_value() ? *
this :
std::move(rhs);
5939 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 5968 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR 6002 template <
class U = T, detail::enable_if_t<!detail::is_optional<detail::decay_t<U>>::value>* =
nullptr>
6033 template <
class U = T, detail::enable_if_t<!detail::is_optional<detail::decay_t<U>>::value>* =
nullptr>
6036 m_value = std::addressof(u);
6046 m_value = std::addressof(rhs.
value());
6054 template <
class... Args>
6059 this->
construct(std::forward<Args>(args)...);
6103 return m_value !=
nullptr;
6107 constexpr
explicit operator bool() const noexcept {
6108 return m_value !=
nullptr;
6118 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 6122 #endif // No exceptions allowed 6129 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 6133 #endif // No exceptions allowed 6141 return has_value() ?
const_cast<T&
>(**this) :
static_cast<T&
>(std::forward<U>(u));
6163 return ::std::hash<::sol::detail::remove_const_t<T>>()(*o);
6170 #endif // Boost vs. Better optional 6176 #if SOL_IS_ON(SOL_USE_BOOST_I_) 6177 template <
typename T>
6178 using optional = boost::optional<T>;
6181 #endif // Boost vs. Better optional 6184 template <
typename T>
6187 template <
typename T>
6192 template <
typename T>
6197 #if SOL_IS_ON(SOL_USE_BOOST_I_) 6198 template <
typename T>
6202 #endif // Boost nullopt 6204 template <
typename T>
6218 template <
typename T,
typename... Args>
6221 std::allocator<Tu> alloc{};
6222 std::allocator_traits<std::allocator<Tu>>
::construct(alloc, std::forward<T>(obj), std::forward<Args>(args)...);
6225 template <
typename T,
typename... Args>
6227 construct(std::forward<T>(obj), std::forward<Args>(args)...);
6232 template <
typename T>
6234 std::allocator<meta::unqualified_t<T>> alloc{};
6238 template <
typename T>
6240 destroy(std::forward<T>(obj));
6245 template <
typename T>
6257 template <
typename T,
typename Dx,
typename... Args>
6259 return std::unique_ptr<T, Dx>(
new T(std::forward<Args>(args)...));
6262 template <
typename Tag,
typename T>
6270 : value_(
std::forward<Arg>(
arg),
std::forward<Args>(args)...) {
6287 template <
typename... Args>
6290 template <
typename... Args>
6301 template <
typename... Functions>
6306 : functions(
std::forward<Arg>(
arg),
std::forward<Args>(args)...) {
6310 template <
typename... Functions>
6315 template <
typename... Functions>
6320 : functions(
std::forward<Arg>(
arg),
std::forward<Args>(args)...) {
6324 template <
typename... Functions>
6329 template <
typename Function>
6342 template <
typename Fx>
6360 template <
int Target,
int... In>
6363 template <
int... In>
6372 template <
typename... Args>
6373 stack_dependencies(
int stack_target, Args&&... args) : target(stack_target), stack_indices(), len(sizeof...(Args)) {
6375 (
void)
detail::swallow{ int(), (stack_indices[i++] =
static_cast<int>(std::forward<Args>(args)), int())... };
6379 return stack_indices[i];
6383 return stack_indices[i];
6391 template <
typename F,
typename... Policies>
6402 policy_wrapper(
const policy_wrapper&) =
default;
6403 policy_wrapper& operator=(
const policy_wrapper&) =
default;
6404 policy_wrapper(policy_wrapper&&) =
default;
6405 policy_wrapper& operator=(policy_wrapper&&) =
default;
6408 template <
typename F,
typename... Args>
6414 template <
typename T>
6417 template <
typename T>
6426 #include <type_traits> 6431 template <
typename T, std::
size_t tag = 0,
typename =
void>
6438 ebco& operator=(
const ebco&) =
default;
6450 template <
typename Arg,
typename... Args,
6451 typename = std::enable_if_t<!std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>,
6452 ebco> && !std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>, T>>>
6468 template <
typename T, std::
size_t tag>
6469 struct ebco<T, tag,
std::
enable_if_t<!std::is_reference_v<T> && std::is_class_v<T> && !std::is_final_v<T>>> : T {
6475 template <
typename Arg,
typename... Args,
6476 typename = std::enable_if_t<!std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>,
6477 ebco> && !std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>, T>>>
6481 ebco& operator=(
const ebco&) =
default;
6484 static_cast<T&
>(*this) = v;
6493 return static_cast<T&
>(*this);
6497 return static_cast<T const&
>(*this);
6501 return std::move(static_cast<T&>(*
this));
6505 template <
typename T, std::
size_t tag>
6514 ebco& operator=(
const ebco&) =
default;
6526 template <
typename T, std::
size_t tag>
6535 ebco& operator=(
const ebco&) =
default;
6560 #include <initializer_list> 6562 #include <string_view> 6564 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 6566 #endif // variant shenanigans (thanks, Mac OSX) 6570 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) 6574 #endif // noexcept function type for lua_CFunction 6576 template <
typename T>
6579 template <
typename T>
6590 return std::addressof(item);
6606 #if SOL_IS_ON(SOL_NIL_I_) 6624 template <
typename T>
6633 template <
typename Arg,
6638 template <
typename Arg0,
typename Arg1,
typename... Args>
6639 yielding_t(Arg0&& arg0, Arg1&& arg1, Args&&... args) : func(
std::forward<Arg0>(arg0),
std::forward<Arg1>(arg1),
std::forward<Args>(args)...) {
6643 template <
typename F>
6650 template <
typename T>
6653 template <
typename... Args>
6661 operator int()
const {
6671 operator int()
const {
6681 operator int()
const {
6691 operator int()
const {
6707 operator void*()
const {
6716 operator void*()
const {
6721 template <
typename L>
6729 light(
void* x) : value(static_cast<L*>(x)) {
6731 operator L*()
const {
6734 operator L&()
const {
6739 template <
typename T>
6745 template <
typename U>
6751 operator std::add_pointer_t<std::remove_reference_t<U>>() {
6752 return std::addressof(value);
6754 operator std::add_lvalue_reference_t<U>() {
6757 operator std::add_const_t<std::add_lvalue_reference_t<U>> &()
const {
6762 template <
typename T>
6765 return user<U>(std::forward<T>(u));
6768 template <
typename T>
6776 template <
typename T>
6782 template <
typename... Upvalues>
6800 template <
typename... Args>
6802 return closure<Args...>(f, std::forward<Args>(args)...);
6805 template <
typename Sig,
typename... Ps>
6813 template <
typename Sig = function_sig<>,
typename... Args>
6818 template <
typename Sig = function_sig<>,
typename... Args>
6823 template <
typename T>
6834 template <
typename Arg,
6839 template <
typename Arg0,
typename Arg1,
typename... Args>
6840 as_table_t(Arg0&& arg0, Arg1&& arg1, Args&&... args) : value_(
std::forward<Arg0>(arg0),
std::forward<Arg1>(arg1),
std::forward<Args>(args)...) {
6855 operator std::add_lvalue_reference_t<T>() {
6860 template <
typename T>
6873 template <
typename Arg,
6878 template <
typename Arg0,
typename Arg1,
typename... Args>
6879 nested(Arg0&& arg0, Arg1&& arg1, Args&&... args) : value_(
std::forward<Arg0>(arg0),
std::forward<Arg1>(arg1),
std::forward<Args>(args)...) {
6894 operator std::add_lvalue_reference_t<T>() {
6902 template <
typename T>
6907 template <
typename T>
6912 template <
typename T>
6914 return nested<T>(std::forward<T>(container));
6917 template <
typename T>
6922 template <
typename T>
6935 template <
typename Arg,
6940 template <
typename Arg0,
typename Arg1,
typename... Args>
6941 as_container_t(Arg0&& arg0, Arg1&& arg1, Args&&... args) : value_(
std::forward<Arg0>(arg0),
std::forward<Arg1>(arg1),
std::forward<Args>(args)...) {
6957 template <
typename T>
6975 template <
typename T>
6980 template <
typename T>
6991 template <
typename Arg,
6996 template <
typename Arg0,
typename Arg1,
typename... Args>
6997 push_invoke_t(Arg0&& arg0, Arg1&& arg1, Args&&... args) : value_(
std::forward<Arg0>(arg0),
std::forward<Arg1>(arg1),
std::forward<Args>(args)...) {
7013 template <
typename T>
7025 template <
typename Fx>
7038 enum insert_mode {
none = 0x0, update_if_empty = 0x01, override_value = 0x02, create_if_nil = 0x04 };
7040 template <
typename T,
typename...>
7042 std::is_same_v<T, override_value_t> || std::is_same_v<T, update_if_empty_t> || std::is_same_v<T, create_if_nil_t>>;
7044 template <
typename T,
typename...>
7087 int sequence_hint = 0;
7096 new_table(
int sequence_hint,
int map_hint = 0) : sequence_hint(sequence_hint), map_hint(map_hint) {
7176 enum class type : int {
7179 #if SOL_IS_ON(SOL_NIL_I_) 7181 #endif // Objective C/C++ Keyword that's found in OSX SDK and OBJC -- check for all forms to protect 7194 static const std::array<std::string, 10> names { {
"ok",
7202 "CRITICAL_EXCEPTION_FAILURE",
7203 "CRITICAL_INDETERMINATE_STATE_FAILURE" } };
7222 if (static_cast<std::ptrdiff_t>(c) == -1) {
7245 static const std::array<std::string, 7> names {
7246 {
"ok",
"memory",
"gc",
"syntax",
"file",
"CRITICAL_EXCEPTION_FAILURE",
"CRITICAL_INDETERMINATE_STATE_FAILURE" }
7260 if (static_cast<int>(c) == -1) {
7268 static const std::array<std::string, 3> names { {
7273 return names[
static_cast<std::size_t
>(
c)];
7321 static const std::array<std::string, 37> names = { {
"new",
7359 "__sol.static_index",
7360 "__sol.static_new_index" } };
7369 return static_cast<type
>(
lua_type(L, index));
7376 template <
typename T>
7378 : std::integral_constant<bool, std::is_base_of_v<reference, T> || std::is_base_of_v<main_reference, T> || std::is_base_of_v<stack_reference, T>> { };
7380 template <
typename T>
7383 template <
typename T>
7386 template <
typename T>
7389 template <
typename T>
7392 template <
typename T>
7403 template <
typename T>
7406 template <
typename T>
7408 : std::integral_constant<bool,
7409 !std::is_same_v<state_view,
7410 T> && !std::is_same_v<state, T> && !meta::is_initializer_list_v<T> && !meta::is_string_like_v<T> && !meta::is_string_literal_array_v<T> && !is_transparent_argument_v<T> && !is_lua_reference_v<T> && (meta::has_begin_end_v<T> || std::is_array_v<T>)> {
7413 template <
typename T>
7416 template <
typename T>
7417 struct is_to_stringable :
meta::any<meta::supports_to_string_member<meta::unqualified_t<T>>, meta::supports_adl_to_string<meta::unqualified_t<T>>,
7418 meta::supports_op_left_shift<std::ostream, meta::unqualified_t<T>>> { };
7421 template <
typename T,
typename =
void>
7422 struct lua_type_of : std::integral_constant<type, type::userdata> { };
7424 template <
typename C,
typename T,
typename A>
7425 struct lua_type_of<
std::basic_string<C, T, A>> : std::integral_constant<type, type::string> { };
7427 template <
typename C,
typename T>
7430 template <std::
size_t N>
7431 struct lua_type_of<char[N]> : std::integral_constant<type, type::string> { };
7433 template <std::
size_t N>
7434 struct lua_type_of<wchar_t[N]> : std::integral_constant<type, type::string> { };
7436 template <std::
size_t N>
7437 struct lua_type_of<char16_t[N]> : std::integral_constant<type, type::string> { };
7439 template <std::
size_t N>
7440 struct lua_type_of<char32_t[N]> : std::integral_constant<type, type::string> { };
7443 struct lua_type_of<char> : std::integral_constant<type, type::string> { };
7446 struct lua_type_of<wchar_t> : std::integral_constant<type, type::string> { };
7449 struct lua_type_of<char16_t> : std::integral_constant<type, type::string> { };
7452 struct lua_type_of<char32_t> : std::integral_constant<type, type::string> { };
7455 struct lua_type_of<const char*> : std::integral_constant<type, type::string> { };
7458 struct lua_type_of<const char16_t*> : std::integral_constant<type, type::string> { };
7461 struct lua_type_of<const char32_t*> : std::integral_constant<type, type::string> { };
7479 struct lua_type_of<std::nullptr_t> : std::integral_constant<type, type::lua_nil> { };
7484 template <
bool b,
typename Base>
7487 template <
typename Base>
7490 template <
typename Base>
7493 template <
typename T,
typename Base>
7499 template <
typename B>
7508 template <
typename T>
7511 template <
typename T>
7512 struct lua_type_of<std::initializer_list<T>> : std::integral_constant<type, type::table> { };
7520 template <
typename Base>
7523 template <
typename... Args>
7524 struct lua_type_of<std::tuple<Args...>> : std::integral_constant<type, type::poly> { };
7526 template <
typename A,
typename B>
7527 struct lua_type_of<std::pair<A, B>> : std::integral_constant<type, type::poly> { };
7541 template <
typename T>
7544 template <
typename T>
7547 template <
typename Base>
7550 template <
typename Base>
7557 struct lua_type_of<std::remove_pointer_t<lua_CFunction>> : std::integral_constant<type, type::function> { };
7559 template <
typename Base,
bool aligned>
7562 template <
typename Base,
bool aligned,
typename Handler>
7565 template <
typename Base>
7568 template <
typename Base>
7571 template <
typename Signature>
7574 template <
typename T>
7577 template <
typename T>
7581 struct lua_type_of<variadic_args> : std::integral_constant<type, type::poly> { };
7590 struct lua_type_of<this_state> : std::integral_constant<type, type::poly> { };
7593 struct lua_type_of<this_main_state> : std::integral_constant<type, type::poly> { };
7596 struct lua_type_of<this_environment> : std::integral_constant<type, type::poly> { };
7599 struct lua_type_of<type> : std::integral_constant<type, type::poly> { };
7601 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) 7602 template <
typename T>
7605 template <
typename T>
7606 struct lua_type_of<T*> : std::integral_constant<type, type::userdata> { };
7609 template <
typename T>
7610 struct lua_type_of<T, std::
enable_if_t<std::is_arithmetic_v<T> || std::is_same_v<T, lua_Number> || std::is_same_v<T, lua_Integer>>>
7611 : std::integral_constant<type, type::number> { };
7613 template <
typename T>
7616 template <
typename T>
7622 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 7623 template <
typename... Tn>
7624 struct lua_type_of<std::variant<Tn...>> : std::integral_constant<type, type::poly> { };
7625 #endif // std::variant deployment sucks on Clang 7627 template <
typename T>
7630 template <
typename C, C v,
template <
typename...>
class V,
typename... Args>
7633 template <
typename C, C v,
template <
typename...>
class V,
typename T,
typename... Args>
7636 template <
typename C, C v,
template <
typename...>
class V,
typename List>
7639 template <
typename C, C v,
template <
typename...>
class V,
typename... Args>
7643 template <
typename T>
7648 template <
typename T>
7651 template <
typename T>
7656 template <
typename A,
typename B>
7657 struct lua_size<
std::pair<A, B>> : std::integral_constant<int, lua_size<A>::value + lua_size<B>::value> { };
7659 template <
typename... Args>
7660 struct lua_size<std::tuple<Args...>> : std::integral_constant<int, detail::accumulate<int, 0, lua_size, Args...>::value> { };
7662 template <
typename T>
7666 template <
typename...>
7670 template <
typename T,
typename =
void>
7672 template <
typename T>
7675 template <
typename T>
7678 template <
typename T>
7682 template <
typename T>
7684 : std::integral_constant<bool,
7687 T> || ((type::userdata == lua_type_of_v<T>)&&detail::has_internal_marker_v<lua_type_of<T>> && !detail::has_internal_marker_v<lua_size<T>>)
7688 || is_lua_reference_or_proxy_v<T> || meta::is_specialization_of_v<T, std::tuple> || meta::is_specialization_of_v<T, std::pair>> { };
7690 template <
typename T>
7693 template <
typename T>
7696 template <
typename T>
7711 template <
typename T>
7714 template <
typename T>
7720 template <
typename T>
7722 template <
typename T>
7724 template <
typename T>
7726 template <
typename T>
7728 template <
typename T>
7730 template <
typename T>
7732 template <
typename T>
7742 template <
typename T>
7745 template <
typename T>
7756 template <
typename Signature>
7763 static const std::size_t true_arity = base_t::arity;
7766 static const std::size_t true_free_arity = base_t::free_arity;
7768 - meta::count_for<is_transparent_argument, typename base_t::args_list>::value;
7771 template <
typename T>
7773 template <
bool x,
typename T>
7775 template <
typename T>
7778 template <
typename T>
7781 template <
typename T>
7783 template <
bool x,
typename T>
7785 template <
typename T>
7788 template <
typename T>
7791 template <
typename T>
7793 template <
typename T,
bool aligned>
7795 template <
typename T,
bool aligned,
typename Handler>
7798 template <
typename T>
7801 template <
typename T>
7804 template <
typename T>
7807 template <
typename T>
7810 template <
typename T>
7811 using is_environment = std::integral_constant<bool, is_userdata_v<T> || is_table_v<T> || meta::is_specialization_of_v<T, basic_environment>>;
7813 template <
typename T>
7816 template <
typename T>
7817 using is_table_like = std::integral_constant<bool, is_table_v<T> || is_environment_v<T> || is_userdata_v<T>>;
7819 template <
typename T>
7822 template <
typename T>
7824 : std::integral_constant<bool,
7825 (SOL_IS_ON(SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_))
7826 || (std::is_array_v<
7827 meta::unqualified_t<T>> || (!std::is_same_v<meta::unqualified_t<T>, state> && !std::is_same_v<meta::unqualified_t<T>, state_view>))> {
7830 template <
typename T>
7836 template <
typename T>
7839 template <
typename... Args>
7842 template <
typename... Args>
7848 template <
typename T>
7851 template <
typename T>
7854 template <
typename... Args>
7857 template <
typename T>
7860 template <
typename F,
typename... Policies>
7863 template <
typename T>
7866 template <
typename... Args>
7869 template <
typename... Args>
7872 template <
typename T>
7875 template <
typename Fx>
7878 template <
typename... Args>
7881 template <
typename... Args>
7885 template <
typename T>
7888 template <
typename T>
7894 bool pairs_operator =
true;
7895 bool to_string_operator =
true;
7896 bool call_operator =
true;
7897 bool less_than_operator =
true;
7898 bool less_than_or_equal_to_operator =
true;
7899 bool length_operator =
true;
7900 bool equal_to_operator =
true;
7907 #include <exception> 7910 #if SOL_IS_ON(SOL_PRINT_ERRORS_I_) 7922 static const char name[11] =
"sol.\xE2\x98\xA2\xE2\x98\xA2";
7928 #if SOL_IS_ON(SOL_PRINT_ERRORS_I_) 7929 std::cerr <<
"[sol3] An exception occurred: ";
7930 std::cerr.write(what.data(), what.size());
7931 std::cerr << std::endl;
7939 type t =
static_cast<type
>(
lua_type(L, -1));
7946 if (vfunc ==
nullptr) {
7953 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 7954 template <lua_CFunction f>
7959 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) 7960 template <lua_CFunction_noexcept f>
7965 template <lua_CFunction f>
7971 template <
typename Fx,
typename... Args>
7973 return f(L, std::forward<Args>(args)...);
7982 #if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS_I_) 7989 catch (
const char* cs) {
7995 catch (
const std::exception& e) {
7998 #if SOL_IS_OFF(SOL_USE_LUAJIT_I_) 8005 #endif // LuaJIT cannot have the catchall, but we must catch std::exceps for it 8007 #endif // Safe exceptions 8010 template <lua_CFunction f>
8015 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) 8016 template <lua_CFunction_noexcept f>
8021 template <lua_CFunction f>
8027 template <
typename Fx,
typename... Args>
8030 return f(L, std::forward<Args>(args)...);
8033 #if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS_I_) 8034 return f(L, std::forward<Args>(args)...);
8037 return f(L, std::forward<Args>(args)...);
8039 catch (
const char* cs) {
8045 catch (
const std::exception& e) {
8048 #if SOL_IS_OFF(SOL_USE_LUAJIT_I_) 8064 #endif // Exceptions vs. No Exceptions 8066 template <
typename F, F fx>
8069 return static_trampoline_noexcept<fx>(L);
8072 return static_trampoline<fx>(L);
8079 "void* storage is too small to transport the exception handler: please file a bug on the sol2 issue tracker to get this looked at!");
8100 #if SOL_IS_ON(SOL_MINGW_CCTYPE_IS_POISONED_I_) 8104 #endif // MinGW is on some stuff 8108 inline constexpr std::array<string_view, 9>
removals { {
"{anonymous}",
8109 "(anonymous namespace)",
8115 "`anonymous-namespace'",
8116 "`anonymous namespace'" } };
8118 #if SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_) 8121 using namespace std;
8122 std::size_t start = name.find_first_of(
'[');
8123 start = name.find_first_of(
'=', start);
8124 std::size_t end = name.find_last_of(
']');
8125 if (end == std::string::npos)
8127 if (start == std::string::npos)
8129 if (start < name.size() - 1)
8131 name = name.substr(start, end - start);
8132 start = name.rfind(
"seperator_mark");
8133 if (start != std::string::npos) {
8134 name.erase(start - 2, name.length());
8136 while (!name.empty() && isblank(name.front()))
8137 name.erase(name.begin());
8138 while (!name.empty() && isblank(name.back()))
8141 for (std::size_t r = 0; r <
removals.size(); ++r) {
8142 auto found = name.find(
removals[r]);
8143 while (found != std::string::npos) {
8152 template <
typename T,
class seperator_mark =
int>
8154 return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__);
8156 #elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) 8158 std::size_t start = name.find(
"get_type_name");
8159 if (start == std::string::npos)
8163 if (start < name.size() - 1)
8165 std::size_t end = name.find_last_of(
'>');
8166 if (end == std::string::npos)
8168 name = name.substr(start, end - start);
8169 if (name.find(
"struct", 0) == 0)
8170 name.replace(0, 6,
"", 0);
8171 if (name.find(
"class", 0) == 0)
8172 name.replace(0, 5,
"", 0);
8173 while (!name.empty() && isblank(name.front()))
8174 name.erase(name.begin());
8175 while (!name.empty() && isblank(name.back()))
8178 for (std::size_t r = 0; r <
removals.size(); ++r) {
8179 auto found = name.find(
removals[r]);
8180 while (found != std::string::npos) {
8189 template <
typename T>
8191 return ctti_get_type_name_from_sig(__FUNCSIG__);
8194 #error Compiler not supported for demangling 8197 template <
typename T>
8205 static const std::array<std::string, 10> ops = {
8206 {
"operator<",
"operator<<",
"operator<<=",
"operator<=",
"operator>",
"operator>>",
"operator>>=",
"operator>=",
"operator->",
"operator->*" }
8209 std::ptrdiff_t idx = 0;
8210 for (idx = static_cast<std::ptrdiff_t>(realname.empty() ? 0 : realname.size() - 1); idx > 0; --idx) {
8211 if (level == 0 && realname[idx] ==
':') {
8214 bool isleft = realname[idx] ==
'<';
8215 bool isright = realname[idx] ==
'>';
8216 if (!isleft && !isright)
8218 bool earlybreak =
false;
8219 for (
const auto& op : ops) {
8220 std::size_t nisop = realname.rfind(op, idx);
8221 if (nisop == std::string::npos)
8223 std::size_t nisopidx = idx - op.size() + 1;
8224 if (nisop == nisopidx) {
8225 idx =
static_cast<std::ptrdiff_t
>(nisopidx);
8233 level += isleft ? -1 : 1;
8236 realname.erase(0, realname.length() <
static_cast<std::size_t
>(idx) ? realname.length() : idx + 1);
8241 template <
typename T>
8247 template <
typename T>
8253 template <
typename T>
8264 template <
typename T>
8267 static const std::string& n = detail::short_demangle<T>();
8271 static const std::string& q_n = detail::demangle<T>();
8283 static const std::string u_g_m =
std::string(
"sol.").append(detail::demangle<T>()).append(
".user\xE2\x99\xBB");
8287 static const std::string g_t =
std::string(
"sol.").append(detail::demangle<T>()).append(
".\xE2\x99\xBB");
8302 template <
typename T>
8306 template <
typename X>
8311 template <
typename U>
8316 template <
typename U>
8317 static auto get(U&& value) {
8322 template <
typename T>
8329 template <
typename X>
8335 return p ==
nullptr;
8338 static type*
get(
const actual_type& p) {
8343 template <
typename T,
typename D>
8351 return p ==
nullptr;
8359 template <
typename T>
8362 template <
typename T>
8366 template <
typename T,
typename Rebind =
void>
8370 template <
typename T>
8373 template <
typename T>
8377 template <
typename T,
typename =
void>
8380 template <
typename T>
8382 : std::integral_constant<bool, !std::is_void_v<typename T::template rebind_base<void>>> {};
8385 template <
typename T>
8388 template <
typename T>
8396 template <
typename... Args>
8398 template <
typename... Args>
8404 template <
typename... Args>
8410 static const auto& key =
"class_check";
8415 static const auto& key =
"class_cast";
8420 static const auto& key = u8
"\xF0\x9F\x8C\xB2.index";
8425 static const auto& key = u8
"\xF0\x9F\x8C\xB2.new_index";
8429 template <
typename T>
8437 template <
typename Base,
typename... Args>
8446 template <
typename ...Bases>
8455 template <
typename Base,
typename... Args>
8462 T* data =
static_cast<T*
>(voiddata);
8466 template <
typename... Bases>
8468 T* data =
static_cast<T*
>(voiddata);
8472 template <
typename U>
8477 template <
typename U,
typename Base,
typename... Args>
8480 using base_ptr =
typename uu_traits::template rebind_base<Base>;
8482 if (base_ti == ti) {
8483 if (target_data !=
nullptr) {
8484 U* source =
static_cast<U*
>(source_data);
8485 base_ptr* target =
static_cast<base_ptr*
>(target_data);
8491 return type_unique_cast_bases<U>(
types<Args...>(), source_data, target_data, ti);
8494 template <
typename U>
8497 if constexpr (is_base_rebindable_v<uu_traits>) {
8498 typedef typename uu_traits::template rebind_base<void> rebind_t;
8501 if (rebind_ti != this_rebind_ti) {
8506 if (ti == this_ti) {
8510 return type_unique_cast_bases<U>(cond_bases_t(), source_data, target_data, ti);
8515 if (ti == this_ti) {
8519 return type_unique_cast_bases<U>(
types<>(), source_data, target_data, ti);
8523 template <
typename U,
typename... Bases>
8525 using uc_bases_t =
types<Bases...>;
8527 if constexpr (is_base_rebindable_v<uu_traits>) {
8528 using rebind_t =
typename uu_traits::template rebind_base<void>;
8531 if (rebind_ti != this_rebind_ti) {
8536 if (ti == this_ti) {
8540 return type_unique_cast_bases<U>(cond_bases_t(), source_data, target_data, ti);
8545 if (ti == this_ti) {
8549 return type_unique_cast_bases<U>(
types<>(), source_data, target_data, ti);
8571 constexpr
const char*
not_a_number_integral =
"not a numeric type that fits exactly an integer (number maybe has significant decimals)";
8573 =
"not a numeric type or a numeric string that fits exactly an integer (e.g. number maybe has significant decimals)";
8587 aux_message +=
", ";
8599 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 8601 #endif // make sure stack doesn't overflow 8609 std::string tn(name, static_cast<std::string::size_type>(sz));
8620 const char* err = message.size() == 0
8621 ? (aux_message.size() == 0 ?
"stack index %d, expected %s, received %s" :
"stack index %d, expected %s, received %s: %s")
8622 :
"stack index %d, expected %s, received %s: %s %s";
8626 lua_pushfstring(L, err, index, type_name, actual_name.c_str(), message.data(), aux_message.data());
8659 template <
typename F =
void>
8662 push_type_panic_string(L, index, expected, actual, message,
"(bad argument to variable or function call)");
8667 template <
typename R,
typename... Args>
8672 aux_message += detail::demangle<R>();
8676 aux_message +=
")')";
8693 type_error(L, static_cast<int>(expected), static_cast<int>(actual));
8697 if (expected !=
type::poly && expected != actual) {
8703 type actual =
type_of(L, index);
8718 if (rightL ==
nullptr || leftL ==
nullptr || leftL == rightL) {
8723 return leftregistry == rightregistry;
8759 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 8760 luaL_checkstack(L, 1,
"not enough Lua stack space to push a single reference value");
8761 #endif // make sure stack doesn't overflow 8781 return static_cast<type
>(
result);
8785 type t = get_type(L);
8820 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 8821 luaL_checkstack(L, 1,
"not enough Lua stack space to push a single reference value");
8822 #endif // make sure stack doesn't overflow 8835 return push(lua_state());
8880 return !lhs.
valid();
8884 return !rhs.
valid();
8914 std::hash<const void*> h;
8922 #include <functional> 8927 static const char name[9] =
"sol.\xF0\x9F\x93\x8C";
8940 if (rawindex == -
count || top == rawindex) {
8953 int last = index +
count;
8954 for (
int i = index; i < last; ++i) {
8970 template <
bool top_level>
8991 template <
bool,
typename T,
typename =
void>
9009 template <
typename T,
typename C>
9024 template <
typename T>
9032 return r.stack_index();
9039 template <
bool top_level = false,
typename T>
9044 template <
typename T>
9051 template <
bool top_level = false>
9058 #if SOL_LUA_VESION_I_ < 502 9060 return backup_if_unsupported;
9066 return backup_if_unsupported;
9069 return backup_if_unsupported;
9074 #endif // Lua 5.2+ has the main thread unqualified_getter 9086 (
void)backup_if_unsupported;
9096 template <
bool o_main_only>
9131 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 9132 luaL_checkstack(L, 1,
"not enough Lua stack space to push this reference value");
9133 #endif // make sure stack doesn't overflow 9154 if (r.ref ==
LUA_NOREF || L ==
nullptr) {
9166 if (r.ref ==
LUA_NOREF || L ==
nullptr) {
9175 if (L ==
nullptr || r.lua_state() ==
nullptr || r.get_type() ==
type::none) {
9192 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 9193 luaL_checkstack(L, 1,
"not enough Lua stack space to push this reference value");
9194 #endif // make sure stack doesn't overflow 9221 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 9222 luaL_checkstack(L, 1,
"not enough Lua stack space to push this reference value");
9223 #endif // make sure stack doesn't overflow 9251 return static_cast<type
>(
result);
9263 template <
bool main_only = false>
9266 template <
bool o_main_only>
9270 template <
bool r_main_only>
9276 luastate = detail::pick_main_thread < main_only && !r_main_only > (r.
lua_state(), r.
lua_state());
9286 r.
push(lua_state());
9290 luastate = detail::pick_main_thread < main_only && !r_main_only > (r.
lua_state(), r.
lua_state());
9294 template <
bool r_main_only>
9300 luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
9305 luastate = r.luastate;
9310 r.push(lua_state());
9315 luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
9318 r.luastate =
nullptr;
9337 return copy(lua_state());
9352 template <
bool r_main_only>
9358 if (r.ref ==
LUA_NOREF || lua_state() ==
nullptr) {
9363 r.push(lua_state());
9370 template <
bool r_main_only>
9376 if (r.ref ==
LUA_NOREF || lua_state() ==
nullptr) {
9381 r.push(lua_state());
9387 r.luastate =
nullptr;
9391 if (lua_state() ==
nullptr || r.lua_state() ==
nullptr || r.get_type() ==
type::none) {
9399 if (lua_state() != r.lua_state() && !
detail::xmovable(lua_state(), r.lua_state())) {
9402 r.push(lua_state());
9407 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 9408 luaL_checkstack(L, 1,
"not enough Lua stack space to push this reference value");
9409 #endif // make sure stack doesn't overflow 9421 if (lua_state() ==
nullptr || ref ==
LUA_NOREF)
9430 o.luastate =
nullptr;
9434 :
basic_reference(detail::pick_main_thread<main_only>(o.lua_state(), o.lua_state()), o) {
9439 o.luastate =
nullptr;
9472 template <
typename Super>
9475 template <
typename Super>
9479 return push(lua_state());
9483 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 9484 luaL_checkstack(L, 1,
"not enough Lua stack space to push this reference value");
9485 #endif // make sure stack doesn't overflow 9486 if (lua_state() ==
nullptr) {
9491 if (L != lua_state()) {
9517 explicit operator bool() const noexcept {
9530 template <
bool lb,
bool rb>
9537 template <
bool lb,
bool rb>
9566 return !lhs.
valid();
9571 return !rhs.
valid();
9595 template <
bool lb,
bool rb>
9617 std::hash<const void*> h;
9630 template <
typename T>
9634 template <
typename T>
9637 template <
typename T>
9638 struct is_tieable : std::integral_constant<bool, (::sol::tie_size<T>::value > 0)> {};
9640 template <
typename... Tn>
9641 struct tie_t :
public std::tuple<std::add_lvalue_reference_t<Tn>...> {
9643 typedef std::tuple<std::add_lvalue_reference_t<Tn>...>
base_t;
9645 template <
typename T>
9646 void set(std::false_type, T&& target) {
9647 std::get<0>(*this) = std::forward<T>(target);
9650 template <
typename T>
9651 void set(std::true_type, T&& target) {
9655 typedef std::make_index_sequence<indices_size::value>
indices;
9659 template <std::size_t... I,
typename T>
9660 void set_extra(std::true_type, std::index_sequence<I...>, T&& target) {
9666 template <std::size_t... I,
typename T>
9667 void set_extra(std::false_type, std::index_sequence<I...>, T&& target) {
9670 (get<I>(
static_cast<base_t&
>(*this)) = get<I>(target), 0)..., 0};
9674 using base_t::base_t;
9676 template <
typename T>
9679 set(tieable(), std::forward<T>(
value));
9684 template <
typename... Tn>
9687 namespace adl_barrier_detail {
9688 template <
typename... Tn>
9694 using namespace adl_barrier_detail;
9702 #include <functional> 9707 #if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS) 9713 #endif // No Exceptions 9728 if (top == bottom) {
9731 on_mismatch(top, bottom);
9744 #include <forward_list> 9746 #include <algorithm> 9754 template <
typename T>
9756 template <
typename T>
9758 template <
typename T>
9760 template <
typename T>
9768 inline void*
align(std::size_t alignment, std::size_t size,
void*&
ptr, std::size_t&
space, std::size_t& required_space) {
9776 required_space += size + padding;
9777 if (space < required_space) {
9780 ptr =
static_cast<void*
>(
static_cast<char*
>(
ptr) + padding);
9785 inline void*
align(std::size_t alignment, std::size_t size,
void*&
ptr, std::size_t&
space) {
9786 std::size_t required_space = 0;
9787 return align(alignment, size, ptr, space, required_space);
9790 inline void align_one(std::size_t a, std::size_t s,
void*& target_alignment) {
9792 target_alignment =
align(a, s, target_alignment, space);
9793 target_alignment =
static_cast<void*
>(
static_cast<char*
>(target_alignment) + s);
9796 template <
typename... Args>
9799 char alignment_shim[(
std::max)({
sizeof(Args)... }) + (
std::max)({
alignof(Args)... })] {};
9800 char* start = alignment ==
nullptr ?
static_cast<char*
>(alignment) : alignment_shim;
9802 return static_cast<char*
>(alignment) - start;
9806 using use_align = std::integral_constant<
bool,
9807 #if SOL_IS_OFF(SOL_ALIGN_MEMORY_I_) 9820 template <
bool pre_aligned = false,
bool pre_shifted = false>
9822 using use_align = std::integral_constant<
bool,
9823 #if SOL_IS_OFF(SOL_ALIGN_MEMORY_I_) 9833 ptr =
static_cast<void*
>(
static_cast<char*
>(
ptr) +
sizeof(
void*));
9836 return static_cast<void*
>(
static_cast<void**
>(
ptr) + 1);
9842 template <
bool pre_aligned = false,
bool pre_shifted = false>
9844 using use_align = std::integral_constant<
bool,
9845 #if SOL_IS_OFF(SOL_ALIGN_MEMORY_I_) 9864 template <
typename T,
bool pre_aligned = false,
bool pre_shifted = false>
9866 typedef std::integral_constant<
bool,
9867 #if SOL_IS_OFF(SOL_ALIGN_MEMORY_I_) 9870 (std::alignment_of_v<T> > 1)
9878 ptr =
static_cast<void*
>(
static_cast<char*
>(
ptr) +
sizeof(
unique_tag));
9884 return align(std::alignment_of_v<T>,
sizeof(T), ptr, space);
9887 template <
typename T>
9889 typedef std::integral_constant<
bool,
9890 #if SOL_IS_OFF(SOL_ALIGN_MEMORY_I_) 9893 (std::alignment_of_v<T> > 1)
9901 return align(std::alignment_of_v<T>,
sizeof(T), ptr, space);
9904 template <
typename T>
9906 typedef std::integral_constant<
bool,
9907 #if SOL_IS_OFF(SOL_ALIGN_MEMORY_I_) 9915 T** pointerpointer =
static_cast<T**
>(
lua_newuserdata(L,
sizeof(T*)));
9916 return pointerpointer;
9918 static const std::size_t initial_size = aligned_space_for<T*>(
nullptr);
9919 static const std::size_t misaligned_size = aligned_space_for<T*>(
reinterpret_cast<void*
>(0x1));
9921 std::size_t allocated_size = initial_size;
9924 if (adjusted ==
nullptr) {
9928 allocated_size = misaligned_size;
9931 if (adjusted ==
nullptr) {
9936 luaL_error(L,
"cannot properly align memory for '%s'", detail::demangle<T*>().
data());
9939 return static_cast<T**
>(adjusted);
9942 inline bool attempt_alloc(
lua_State* L, std::size_t ptr_align, std::size_t ptr_size, std::size_t value_align, std::size_t value_size,
9943 std::size_t allocated_size,
void*& pointer_adjusted,
void*& data_adjusted) {
9945 pointer_adjusted =
align(ptr_align, ptr_size, adjusted, allocated_size);
9946 if (pointer_adjusted ==
nullptr) {
9951 allocated_size -= ptr_size;
9952 adjusted =
static_cast<void*
>(
static_cast<char*
>(pointer_adjusted) + ptr_size);
9953 data_adjusted =
align(value_align, value_size, adjusted, allocated_size);
9954 if (data_adjusted ==
nullptr) {
9962 std::size_t allocated_size,
void*& pointer_adjusted,
void*& dx_adjusted,
void*& id_adjusted,
void*& data_adjusted) {
9964 pointer_adjusted =
align(ptr_align, ptr_size, adjusted, allocated_size);
9965 if (pointer_adjusted ==
nullptr) {
9969 allocated_size -= ptr_size;
9971 adjusted =
static_cast<void*
>(
static_cast<char*
>(pointer_adjusted) + ptr_size);
9972 dx_adjusted =
align(std::alignment_of_v<unique_destructor>,
sizeof(
unique_destructor), adjusted, allocated_size);
9973 if (dx_adjusted ==
nullptr) {
9979 adjusted =
static_cast<void*
>(
static_cast<char*
>(dx_adjusted) +
sizeof(
unique_destructor));
9981 id_adjusted =
align(std::alignment_of_v<unique_tag>,
sizeof(
unique_tag), adjusted, allocated_size);
9982 if (id_adjusted ==
nullptr) {
9988 adjusted =
static_cast<void*
>(
static_cast<char*
>(id_adjusted) +
sizeof(
unique_tag));
9989 data_adjusted =
align(real_align, real_size, adjusted, allocated_size);
9990 if (data_adjusted ==
nullptr) {
9997 template <
typename T>
9999 typedef std::integral_constant<
bool,
10000 #if SOL_IS_OFF(SOL_ALIGN_MEMORY_I_) 10008 T** pointerpointer =
static_cast<T**
>(
lua_newuserdata(L,
sizeof(T*) +
sizeof(T)));
10009 T*& pointerreference = *pointerpointer;
10010 T* allocationtarget =
reinterpret_cast<T*
>(pointerpointer + 1);
10011 pointerreference = allocationtarget;
10012 return allocationtarget;
10030 static const std::size_t initial_size = aligned_space_for<T*, T>(
nullptr);
10031 static const std::size_t misaligned_size = aligned_space_for<T*, T>(
reinterpret_cast<void*
>(0x1));
10033 void* pointer_adjusted;
10034 void* data_adjusted;
10036 =
attempt_alloc(L, std::alignment_of_v<T*>,
sizeof(T*), std::alignment_of_v<T>,
sizeof(T), initial_size, pointer_adjusted, data_adjusted);
10040 pointer_adjusted =
nullptr;
10041 data_adjusted =
nullptr;
10043 L, std::alignment_of_v<T*>,
sizeof(T*), std::alignment_of_v<T>,
sizeof(T), misaligned_size, pointer_adjusted, data_adjusted);
10045 if (pointer_adjusted ==
nullptr) {
10046 luaL_error(L,
"aligned allocation of userdata block (pointer section) for '%s' failed", detail::demangle<T>().c_str());
10049 luaL_error(L,
"aligned allocation of userdata block (data section) for '%s' failed", detail::demangle<T>().c_str());
10055 T** pointerpointer =
reinterpret_cast<T**
>(pointer_adjusted);
10056 T*& pointerreference = *pointerpointer;
10057 T* allocationtarget =
reinterpret_cast<T*
>(data_adjusted);
10058 pointerreference = allocationtarget;
10059 return allocationtarget;
10062 template <
typename T,
typename Real>
10064 typedef std::integral_constant<
bool,
10065 #if SOL_IS_OFF(SOL_ALIGN_MEMORY_I_) 10076 id =
static_cast<unique_tag*
>(
static_cast<void*
>(dx + 1));
10077 Real* mem =
static_cast<Real*
>(
static_cast<void*
>(
id + 1));
10081 static const std::size_t initial_size = aligned_space_for<T*, unique_destructor, unique_tag, Real>(
nullptr);
10082 static const std::size_t misaligned_size = aligned_space_for<T*, unique_destructor, unique_tag, Real>(
reinterpret_cast<void*
>(0x1));
10084 void* pointer_adjusted;
10087 void* data_adjusted;
10089 std::alignment_of_v<T*>,
10091 std::alignment_of_v<Real>,
10101 pointer_adjusted =
nullptr;
10102 dx_adjusted =
nullptr;
10103 id_adjusted =
nullptr;
10104 data_adjusted =
nullptr;
10106 std::alignment_of_v<T*>,
10108 std::alignment_of_v<Real>,
10116 if (pointer_adjusted ==
nullptr) {
10117 luaL_error(L,
"aligned allocation of userdata block (pointer section) for '%s' failed", detail::demangle<T>().c_str());
10119 else if (dx_adjusted ==
nullptr) {
10120 luaL_error(L,
"aligned allocation of userdata block (deleter section) for '%s' failed", detail::demangle<T>().c_str());
10123 luaL_error(L,
"aligned allocation of userdata block (data section) for '%s' failed", detail::demangle<T>().c_str());
10129 pref =
static_cast<T**
>(pointer_adjusted);
10132 Real* mem =
static_cast<Real*
>(data_adjusted);
10136 template <
typename T>
10138 typedef std::integral_constant<
bool,
10139 #if SOL_IS_OFF(SOL_ALIGN_MEMORY_I_) 10142 (std::alignment_of_v<T> > 1)
10151 static const std::size_t initial_size = aligned_space_for<T>(
nullptr);
10152 static const std::size_t misaligned_size = aligned_space_for<T>(
reinterpret_cast<void*
>(0x1));
10154 std::size_t allocated_size = initial_size;
10156 void* adjusted =
align(std::alignment_of_v<T>,
sizeof(T), unadjusted, allocated_size);
10157 if (adjusted ==
nullptr) {
10160 allocated_size = misaligned_size;
10162 adjusted =
align(std::alignment_of_v<T>,
sizeof(T), unadjusted, allocated_size);
10163 if (adjusted ==
nullptr) {
10165 luaL_error(L,
"cannot properly align memory for '%s'", detail::demangle<T>().
data());
10168 return static_cast<T*
>(adjusted);
10171 template <
typename T>
10175 T** pdata =
static_cast<T**
>(
memory);
10177 std::allocator<T> alloc {};
10178 std::allocator_traits<std::allocator<T>>::destroy(alloc, data);
10182 template <
typename T>
10187 memory = align_usertype_unique_tag<true>(
memory);
10192 template <
typename T>
10195 memory = align_user<T>(
memory);
10196 T* data =
static_cast<T*
>(
memory);
10197 std::allocator<T> alloc;
10198 std::allocator_traits<std::allocator<T>>::destroy(alloc, data);
10202 template <
typename T,
typename Real>
10204 memory = align_usertype_unique<Real, true>(
memory);
10205 Real* target =
static_cast<Real*
>(
memory);
10206 std::allocator<Real> alloc;
10207 std::allocator_traits<std::allocator<Real>>::destroy(alloc, target);
10210 template <
typename T>
10213 "cannot call the destructor for '%s': it is either hidden (protected/private) or removed with '= " 10214 "delete' and thusly this type is being destroyed without properly destructing, invoking undefined " 10215 "behavior: please bind a usertype and specify a custom destructor to define the behavior properly",
10216 detail::demangle<T>().
data());
10219 template <
typename T>
10223 template <
typename T,
typename Al>
10224 void reserve(std::vector<T, Al>& vec, std::size_t hint) {
10228 template <
typename T,
typename Tr,
typename Al>
10229 void reserve(std::basic_string<T, Tr, Al>& str, std::size_t hint) {
10243 : times_through(times), properties(props), enrollments(enroll) {
10247 bool p = properties[
static_cast<int>(mf)];
10248 if (times_through > 0) {
10286 template <
typename T,
bool global = false,
bool raw = false,
typename =
void>
10288 template <
typename T,
typename P,
bool global = false,
bool raw = false,
typename =
void>
10291 template <
typename T,
bool global = false,
bool raw = false,
typename =
void>
10294 template <
typename T,
typename =
void>
10296 template <
typename T,
typename =
void>
10299 template <
typename T,
typename =
void>
10301 template <
typename T,
typename =
void>
10304 template <
typename T,
typename =
void>
10307 template <
typename T,
typename =
void>
10310 template <
typename T, type t,
typename =
void>
10312 template <
typename T, type t,
typename =
void>
10315 template <
typename T,
typename =
void>
10317 template <
typename T,
typename =
void>
10324 probe(
bool s,
int l) : success(s), levels(l) {
10344 namespace stack_detail {
10345 template <
typename Function>
10347 template <
typename Function,
typename Handler>
10353 namespace meta {
namespace meta_detail {
10355 template <
typename T>
10358 template <
typename T>
10360 = decltype(sol_lua_interop_get(
types<T>(), static_cast<lua_State*>(
nullptr), -1, static_cast<void*>(
nullptr), std::declval<stack::record&>()));
10362 template <
typename T>
10365 template <
typename T>
10369 template <
typename T>
10371 = decltype(sol_lua_check_get(
types<T>(), static_cast<lua_State*>(
nullptr), -1,
no_panic, std::declval<stack::record&>()));
10373 template <
typename... Args>
10376 template <
typename T,
typename... Args>
10379 template <
typename T>
10382 template <
typename T>
10385 template <
typename T>
10388 template <
typename T>
10391 template <
typename T>
10394 template <
typename... Args>
10397 template <
typename T,
typename... Args>
10402 namespace stack_detail {
10412 template <
typename T>
10416 template <
typename T>
10420 template <
typename T>
10424 template <
typename T>
10428 template <
typename T>
10431 template <
typename C>
10433 return static_cast<int>(c.size());
10436 template <
typename V,
typename Al>
10439 return static_cast<int>(32);
10442 template <
typename T>
10445 if constexpr (meta::meta_detail::is_adl_sol_lua_get_v<Tu>) {
10446 return sol_lua_get(
types<Tu>(), L, index, tracking);
10451 return g.
get(L, index, tracking);
10455 template <
typename T>
10457 if constexpr (meta::meta_detail::is_adl_sol_lua_get_v<T>) {
10458 return sol_lua_get(
types<T>(), L, index, tracking);
10463 return g.
get(L, index, tracking);
10467 template <
typename T>
10470 if constexpr (meta::meta_detail::is_adl_sol_lua_interop_get_v<Tu>) {
10471 return sol_lua_interop_get(
types<Tu>(), L, index, unadjusted_pointer, tracking);
10476 (
void)unadjusted_pointer;
10479 return std::pair<bool, Ti*> {
false,
nullptr };
10483 template <
typename T>
10485 if constexpr (meta::meta_detail::is_adl_sol_lua_interop_get_v<T>) {
10486 return sol_lua_interop_get(
types<T>(), L, index, unadjusted_pointer, tracking);
10489 return unqualified_interop_get<T>(L,
index, unadjusted_pointer, tracking);
10493 template <
typename T,
typename Handler>
10496 if constexpr (meta::meta_detail::is_adl_sol_lua_interop_check_v<Tu>) {
10497 return sol_lua_interop_check(
types<Tu>(), L, index, index_type, std::forward<Handler>(
handler), tracking);
10509 template <
typename T,
typename Handler>
10511 if constexpr (meta::meta_detail::is_adl_sol_lua_interop_check_v<T>) {
10512 return sol_lua_interop_check(
types<T>(), L, index, index_type, std::forward<Handler>(
handler), tracking);
10515 return unqualified_interop_check<T>(L,
index, index_type, std::forward<Handler>(
handler), tracking);
10550 return ismainthread == 1;
10558 if (stacksize < 1) {
10571 while (
lua_next(L, table_index) != 0) {
10584 auto pp = push_pop<false>(r);
10585 int stack_index = pp.index_of(r);
10593 template <
typename T,
typename... Args>
10596 if constexpr (meta::meta_detail::is_adl_sol_lua_push_exact_v<T, T, Args...>) {
10597 return sol_lua_push(
types<T>(), L, std::forward<T>(t), std::forward<Args>(args)...);
10599 else if constexpr (meta::meta_detail::is_adl_sol_lua_push_exact_v<Tu, T, Args...>) {
10600 return sol_lua_push(
types<Tu>(), L, std::forward<T>(t), std::forward<Args>(args)...);
10602 else if constexpr (meta::meta_detail::is_adl_sol_lua_push_v<T, Args...>) {
10603 return sol_lua_push(L, std::forward<T>(t), std::forward<Args>(args)...);
10608 return p.
push(L, std::forward<T>(t), std::forward<Args>(args)...);
10616 if constexpr (meta::meta_detail::is_adl_sol_lua_push_exact_v<T, Arg, Args...>) {
10617 return sol_lua_push(
types<T>(), L, std::forward<Arg>(
arg), std::forward<Args>(args)...);
10619 else if constexpr (meta::meta_detail::is_adl_sol_lua_push_exact_v<Tu, Arg, Args...>) {
10620 return sol_lua_push(
types<Tu>(), L, std::forward<Arg>(
arg), std::forward<Args>(args)...);
10622 else if constexpr (meta::meta_detail::is_adl_sol_lua_push_v<Arg, Args...>) {
10623 return sol_lua_push(L, std::forward<Arg>(
arg), std::forward<Args>(args)...);
10628 return p.
push(L, std::forward<Arg>(
arg), std::forward<Args>(args)...);
10632 template <
typename T,
typename... Args>
10638 return stack::push<Tr>(L, std::forward<T>(t), std::forward<Args>(args)...);
10641 template <
typename T,
typename Arg,
typename... Args>
10647 return stack::push<Tr>(L, std::forward<Arg>(
arg), std::forward<Args>(args)...);
10650 namespace stack_detail {
10652 template <
typename T,
typename Arg,
typename... Args>
10659 return stack::push<Tr>(L, std::forward<Arg>(
arg), std::forward<Args>(args)...);
10664 template <
typename T,
typename... Args>
10666 return stack_detail::push_reference<T>(L, std::forward<T>(t), std::forward<Args>(args)...);
10669 template <
typename T,
typename Arg,
typename... Args>
10671 return stack_detail::push_reference<T>(L, std::forward<Arg>(
arg), std::forward<Args>(args)...);
10679 template <
typename T,
typename... Args>
10681 int pushcount =
push(L, std::forward<T>(t));
10691 template <
typename T,
typename... Args>
10698 template <
typename T,
typename Handler>
10701 if constexpr (meta::meta_detail::is_adl_sol_lua_check_v<Tu>) {
10702 return sol_lua_check(
types<Tu>(), L, index, std::forward<Handler>(
handler), tracking);
10708 return c.
check(L, index, std::forward<Handler>(
handler), tracking);
10712 template <
typename T,
typename Handler>
10715 return unqualified_check<T>(L,
index, std::forward<Handler>(
handler), tracking);
10718 template <
typename T>
10724 template <
typename T,
typename Handler>
10726 if constexpr (meta::meta_detail::is_adl_sol_lua_check_v<T>) {
10727 return sol_lua_check(
types<T>(), L, index, std::forward<Handler>(
handler), tracking);
10734 return c.
check(L, index, std::forward<Handler>(
handler), tracking);
10738 template <
typename T,
typename Handler>
10741 return check<T>(L,
index, std::forward<Handler>(
handler), tracking);
10744 template <
typename T>
10750 template <
typename T,
typename Handler>
10754 return check<detail_t>(L,
index, std::forward<Handler>(
handler), tracking);
10757 template <
typename T,
typename Handler>
10761 return check<detail_t>(L,
index, std::forward<Handler>(
handler), tracking);
10764 template <
typename T,
typename Handler>
10767 return check_usertype<T>(L,
index, std::forward<Handler>(
handler), tracking);
10770 template <
typename T>
10776 template <
typename T,
typename Handler>
10779 if constexpr (meta::meta_detail::is_adl_sol_lua_check_get_v<T>) {
10780 return sol_lua_check_get(
types<T>(), L, index, std::forward<Handler>(handler), tracking);
10782 else if constexpr (meta::meta_detail::is_adl_sol_lua_check_get_v<Tu>) {
10783 return sol_lua_check_get(
types<Tu>(), L, index, std::forward<Handler>(handler), tracking);
10788 return cg.
get(L, index, std::forward<Handler>(handler), tracking);
10792 template <
typename T,
typename Handler>
10795 return unqualified_check_get<T>(L,
index,
handler, tracking);
10798 template <
typename T>
10804 template <
typename T,
typename Handler>
10806 if constexpr (meta::meta_detail::is_adl_sol_lua_check_get_v<T>) {
10807 return sol_lua_check_get(
types<T>(), L, index, std::forward<Handler>(handler), tracking);
10812 return cg.
get(L, index, std::forward<Handler>(handler), tracking);
10816 template <
typename T,
typename Handler>
10822 template <
typename T>
10828 namespace stack_detail {
10830 template <
typename Handler>
10835 template <
typename T,
typename... Args,
typename Handler>
10837 if (!stack::check<T>(L, firstargument + tracking.
used,
handler, tracking))
10839 return check_types<Args...>(L, firstargument, std::forward<Handler>(
handler), tracking);
10842 template <
typename... Args,
typename Handler>
10849 template <
typename... Args,
typename Handler>
10854 template <
typename... Args,
typename Handler>
10860 template <
typename... Args>
10865 template <
typename T>
10867 #if SOL_IS_ON(SOL_SAFE_GETTER_I_) 10868 static constexpr
bool is_op = meta::is_optional_v<T>;
10869 if constexpr (is_op) {
10870 return stack_detail::unchecked_unqualified_get<T>(L,
index, tracking);
10874 return stack_detail::unchecked_unqualified_get<T>(L,
index, tracking);
10880 return stack_detail::unchecked_unqualified_get<T>(L,
index, tracking);
10884 template <
typename T>
10887 return unqualified_get<T>(L,
index, tracking);
10890 template <
typename T>
10892 #if SOL_IS_ON(SOL_SAFE_GETTER_I_) 10893 static constexpr
bool is_op = meta::is_optional_v<T>;
10894 if constexpr (is_op) {
10895 return stack_detail::unchecked_get<T>(L,
index, tracking);
10899 return stack_detail::unchecked_get<T>(L,
index, tracking);
10905 return stack_detail::unchecked_get<T>(L,
index, tracking);
10909 template <
typename T>
10912 return get<T>(L,
index, tracking);
10915 template <
typename T>
10918 return get<UT>(L,
index, tracking);
10921 template <
typename T>
10924 return get_usertype<T>(L,
index, tracking);
10927 template <
typename T>
10932 template <
bool global = false,
bool raw = false,
typename Key>
10937 template <
bool global = false,
bool raw = false,
typename Key>
10942 template <
bool global = false,
typename Key>
10944 get_field<global, true>(L, std::forward<Key>(key));
10947 template <
bool global = false,
typename Key>
10949 get_field<global, true>(L, std::forward<Key>(key), tableindex);
10952 template <
bool global = false,
bool raw = false,
typename C = detail::non_lua_nil_t,
typename Key>
10957 template <
bool global = false,
bool raw = false,
typename C = detail::non_lua_nil_t,
typename Key>
10962 template <
bool global = false,
typename C = detail::non_lua_nil_t,
typename Key>
10964 return probe_get_field<global, true, C>(L, std::forward<Key>(key));
10967 template <
bool global = false,
typename C = detail::non_lua_nil_t,
typename Key>
10969 return probe_get_field<global, true, C>(L, std::forward<Key>(key), tableindex);
10972 template <
bool global = false,
bool raw = false,
typename Key,
typename Value>
10977 template <
bool global = false,
bool raw = false,
typename Key,
typename Value>
10982 template <
bool global = false,
typename Key,
typename Value>
10984 set_field<global, true>(L, std::forward<Key>(key), std::forward<Value>(
value));
10987 template <
bool global = false,
typename Key,
typename Value>
10989 set_field<global, true>(L, std::forward<Key>(key), std::forward<Value>(
value), tableindex);
10992 template <
typename T,
typename F>
10997 void* uu_memory = detail::align_usertype_unique<T>(raw);
10998 T& uu = *
static_cast<T*
>(uu_memory);
11000 *
static_cast<void**
>(ptr_memory) = static_cast<void*>(
u_traits::get(uu));
11003 template <
typename F>
11006 using T =
typename bt::template arg_at<0>;
11008 modify_unique_usertype_as<Tu>(obj, std::forward<F>(f));
11015 template <
typename T>
11017 if constexpr (is_unique_usertype_v<T>) {
11018 return &unique_destruct<T>;
11020 else if constexpr (!std::is_pointer_v<T>) {
11021 return &usertype_alloc_destruct<T>;
11024 return &cannot_destruct<T>;
11028 template <
typename T>
11030 return &cannot_destruct<T>;
11033 template <
typename T>
11035 return make_destructor<T>(std::is_destructible<T>());
11039 template <
typename A,
typename B>
11045 template <
typename T>
11050 template <
typename T>
11052 decltype(
auto) ts = stack::get<T>(L, 1).
to_string();
11053 return stack::push(L, std::forward<decltype(ts)>(ts));
11056 template <
typename T>
11059 "cannot perform to_string on '%s': no 'to_string' overload in namespace, 'to_string' member " 11060 "function, or operator<<(ostream&, ...) present",
11061 detail::demangle<T>().
data());
11064 template <
typename T>
11066 using namespace std;
11067 decltype(
auto) ts =
to_string(stack::get<T>(L, 1));
11068 return stack::push(L, std::forward<decltype(ts)>(ts));
11071 template <
typename T>
11076 template <
typename T>
11078 std::ostringstream oss;
11079 oss << stack::unqualified_get<T>(L, 1);
11083 template <
typename T>
11088 template <
typename T>
11093 template <
typename T>
11095 decltype(
auto)
self = stack::unqualified_get<T>(L, 1);
11099 template <
typename T,
typename Op>
11101 if constexpr (std::is_void_v<T>) {
11105 auto maybel = stack::unqualified_check_get<T>(L, 1);
11109 auto mayber = stack::unqualified_check_get<T>(L, 2);
11113 decltype(
auto) l = *maybel;
11114 decltype(
auto) r = *mayber;
11115 if constexpr (std::is_same_v<no_comp, Op>) {
11116 std::equal_to<> op;
11120 if constexpr (std::is_same_v<std::equal_to<>, Op>
11121 || std::is_same_v<std::less_equal<>, Op>
11122 || std::is_same_v<std::less_equal<>, Op>) {
11133 template <
typename T,
typename IFx,
typename Fx>
11136 template <
typename T,
bool,
bool>
11139 template <
typename T>
11141 :
meta::neg<std::is_reference<decltype(sol_lua_get(types<T>(), nullptr, -1, std::declval<stack::record&>()))>> { };
11143 template <
typename T>
11145 :
meta::neg<std::is_reference<decltype(sol_lua_get(types<meta::unqualified_t<T>>(), nullptr, -1, std::declval<stack::record&>()))>> { };
11147 template <
typename T>
11152 template <
typename T>
11154 :
detail::get_is_primitive<T, meta::meta_detail::is_adl_sol_lua_get_v<T>, meta::meta_detail::is_adl_sol_lua_get_v<meta::unqualified_t<T>>> { };
11165 #include <functional> 11168 #include <optional> 11169 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 11171 #endif // variant shenanigans 11173 namespace sol {
namespace stack {
11174 namespace stack_detail {
11177 const type expectedmetatabletype =
static_cast<type
>(
lua_type(L, -1));
11180 lua_pop(L, 1 + static_cast<int>(poptable));
11188 template <
typename T,
bool poptable = true>
11193 template <type expected,
int (*check_func)(lua_State*,
int)>
11195 template <
typename Handler>
11198 bool success = check_func(L, index) == 1;
11208 template <
typename T,
typename>
11210 template <
typename Handler>
11216 template <
typename T,
typename>
11218 template <
typename Handler>
11220 return stack_detail::unqualified_interop_check<T>(L,
index, index_type, std::forward<Handler>(
handler), tracking);
11224 template <
typename T, type expected,
typename>
11226 template <
typename Handler>
11228 if constexpr (std::is_same_v<T, bool>) {
11237 else if constexpr (meta::any_same_v<T, char /* , char8_t*/, char16_t, char32_t>) {
11238 return stack::check<std::basic_string<T>>(L,
index, std::forward<Handler>(
handler), tracking);
11240 else if constexpr (std::is_integral_v<T> || std::is_same_v<T, lua_Integer>) {
11242 #if SOL_LUA_VESION_I_ >= 503 11244 #if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_) 11248 const bool success = isnum != 0;
11253 #elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_) 11258 const bool success =
false;
11275 #if SOL_IS_OFF(SOL_STRINGS_ARE_NUMBERS_I_) 11283 #endif // Do not allow strings to be numbers 11285 #if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_) 11288 const bool success = isnum != 0 &&
static_cast<lua_Number>(llround(v)) == v;
11290 const bool success =
true;
11291 #endif // Safe numerics and number precision checking 11294 #if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_) 11296 #elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_) 11305 else if constexpr (std::is_floating_point_v<T> || std::is_same_v<T, lua_Number>) {
11307 #if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_) 11322 #endif // Strings are Numbers 11324 else if constexpr (meta::any_same_v<T, type, this_state, this_main_state, this_environment, variadic_args>) {
11331 else if constexpr (is_unique_usertype_v<T>) {
11333 const type indextype =
type_of(L, index);
11347 bool success = &detail::usertype_unique_alloc_destroy<proper_T, T> == pdx;
11349 memory = detail::align_usertype_unique_tag<true>(
memory);
11353 const char*& name_tag = *
static_cast<const char**
>(
memory);
11357 handler(L, index,
type::userdata, indextype,
"value is a userdata but is not the correct unique usertype");
11366 else if constexpr (meta::any_same_v<T, lua_nil_t, std::nullopt_t, nullopt_t>) {
11380 else if constexpr (std::is_same_v<T, env_key_t>) {
11389 else if constexpr (std::is_same_v<T, detail::non_lua_nil_t>) {
11390 return !stack::unqualified_check<lua_nil_t>(L,
index, std::forward<Handler>(
handler), tracking);
11392 else if constexpr (meta::is_specialization_of_v<T, basic_lua_table>) {
11401 else if constexpr (meta::is_specialization_of_v<T, basic_bytecode>) {
11410 else if constexpr (meta::is_specialization_of_v<T, basic_environment>) {
11427 else if constexpr (std::is_same_v<T, metatable_key_t>) {
11439 handler(L, index, expected, t,
"value does not have a valid metatable");
11444 else if constexpr (std::is_same_v<T, luaL_Stream*> || std::is_same_v<T, luaL_Stream>) {
11447 handler(L, index, expected, t,
"value is not a valid luaL_Stream (has no metatable/is not a valid value)");
11458 "value is not a valid luaL_Stream (there is no metatable for luaL_Stream -- did you forget to " 11459 "my_lua_state.open_libraries(sol::lib::state) or equivalent?)");
11464 if (is_stream_table == 0) {
11466 handler(L, index, expected, t,
"value is not a valid luaL_Stream (incorrect metatable)");
11471 else if constexpr (meta::is_optional_v<T>) {
11472 using ValueType =
typename T::value_type;
11483 return stack::unqualified_check<ValueType>(L,
index,
no_panic, tracking);
11485 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) 11486 else if constexpr (std::is_function_v<T> || (std::is_pointer_v<T> && std::is_function_v<std::remove_pointer_t<T>>)) {
11487 return stack_detail::check_function_pointer<std::remove_pointer_t<T>>(L,
index, std::forward<Handler>(
handler), tracking);
11491 if constexpr (meta::any_same_v<T, userdata_value> || meta::is_specialization_of_v<T, basic_userdata>) {
11501 else if constexpr (meta::is_specialization_of_v<T, user>) {
11504 return c.
check(L, index, std::forward<Handler>(
handler), tracking);
11507 if constexpr (std::is_pointer_v<T>) {
11508 return check_usertype<T>(L,
index, std::forward<Handler>(
handler), tracking);
11510 else if constexpr (meta::is_specialization_of_v<T, std::reference_wrapper>) {
11511 using T_internal =
typename T::type;
11512 return stack::check<T_internal>(L,
index, std::forward<Handler>(
handler), tracking);
11515 return check_usertype<T>(L,
index, std::forward<Handler>(
handler), tracking);
11519 else if constexpr (expected ==
type::poly) {
11563 handler(L, index,
type::function, t,
"value is not a function and does not have overriden metatable");
11574 handler(L, index,
type::function, t,
"value's metatable does not have __call overridden in metatable, cannot call this type");
11589 handler(L, index,
type::table, t,
"value is not a table or a userdata that can behave like one");
11596 const type indextype =
type_of(L, index);
11597 bool success = expected == indextype;
11600 handler(L, index, expected, indextype,
"");
11607 template <
typename T>
11610 template <
typename T>
11612 template <
typename Handler>
11614 const type indextype =
type_of(L, index);
11618 template <
typename U,
typename Handler>
11622 lightuserdata_value> || std::is_same_v<T, userdata_value> || std::is_same_v<T, userdata> || std::is_same_v<T, lightuserdata>) {
11631 #if SOL_IS_ON(SOL_USE_INTEROP_I_) 11632 if (stack_detail::interop_check<U>(L, index, indextype,
handler, tracking)) {
11635 #endif // interop extensibility 11645 if (stack_detail::check_metatable<U>(L, metatableindex))
11647 if (stack_detail::check_metatable<U*>(L, metatableindex))
11656 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 11658 #endif // make sure stack doesn't overflow 11670 handler(L, index,
type::userdata, indextype,
"value at this index does not properly reflect the desired type");
11678 template <
typename T>
11680 template <
typename Handler>
11686 return check_usertype<std::remove_pointer_t<T>>(L,
index, std::forward<Handler>(
handler), tracking);
11689 template <
typename Handler>
11691 const type indextype =
type_of(L, index);
11692 return check(L, index, indextype, std::forward<Handler>(
handler), tracking);
11696 template <
typename... Args>
11698 template <
typename Handler>
11704 template <
typename A,
typename B>
11706 template <
typename Handler>
11708 return stack::multi_check<A, B>(L,
index, std::forward<Handler>(
handler), tracking);
11712 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 11714 template <
typename... Tn>
11716 typedef std::variant<Tn...>
V;
11720 template <
typename Handler>
11732 template <std::
size_t I,
typename Handler>
11734 typedef std::variant_alternative_t<I - 1,
V> T;
11735 record temp_tracking = tracking;
11736 if (stack::check<T>(L, index,
no_panic, temp_tracking)) {
11737 tracking = temp_tracking;
11740 return is_one(std::integral_constant<std::size_t, I - 1>(), L, index, std::forward<Handler>(
handler), tracking);
11743 template <
typename Handler>
11745 return is_one(std::integral_constant<std::size_t, V_size::value>(), L, index, std::forward<Handler>(
handler), tracking);
11749 #endif // variant shenanigans 11760 template <
typename X, type expected,
typename>
11762 template <
typename Handler>
11764 if constexpr (!std::is_reference_v<X> && is_unique_usertype_v<X>) {
11767 if constexpr (is_base_rebindable_non_void_v<u_traits>) {
11768 using rebind_t =
typename u_traits::template rebind_base<void>;
11771 const type indextype =
type_of(L, index);
11780 if (&detail::usertype_unique_alloc_destroy<T, X> == pdx) {
11784 memory = detail::align_usertype_unique_tag<true, false>(
memory);
11788 if (ic(
nullptr,
nullptr, ti, rebind_ti) != 0) {
11792 handler(L, index,
type::userdata, indextype,
"value is a userdata but is not the correct unique usertype");
11796 return stack::unqualified_check<X>(L,
index, std::forward<Handler>(
handler), tracking);
11799 else if constexpr (!std::is_reference_v<X> && is_container_v<X>) {
11801 return stack::unqualified_check<X>(L,
index, std::forward<Handler>(
handler), tracking);
11804 return stack::unqualified_check<nested<X>>(L,
index, std::forward<Handler>(
handler), tracking);
11807 else if constexpr (!std::is_reference_v<X> && meta::is_specialization_of_v<X, nested>) {
11809 return stack::check<NestedX>(L,
index, ::std::forward<Handler>(
handler), tracking);
11812 return stack::unqualified_check<X>(L,
index, std::forward<Handler>(
handler), tracking);
11832 template <
typename... Functions>
11837 : functions(
std::forward<Arg>(
arg),
std::forward<Args>(args)...) {
11845 template <
typename... Args>
11861 namespace unicode {
11875 "invalid code points",
11876 "invalid code unit",
11877 "invalid leading surrogate",
11878 "invalid trailing surrogate",
11879 "sequence too short",
11880 "overlong sequence" 11882 return storage[
static_cast<std::size_t
>(ec)];
11885 template <
typename It>
11892 template <
typename C>
11901 static constexpr char32_t last_code_point = 0x10FFFF;
11903 static constexpr char32_t first_lead_surrogate = 0xD800;
11904 static constexpr char32_t last_lead_surrogate = 0xDBFF;
11906 static constexpr char32_t first_trail_surrogate = 0xDC00;
11907 static constexpr char32_t last_trail_surrogate = 0xDFFF;
11909 static constexpr char32_t first_surrogate = first_lead_surrogate;
11910 static constexpr char32_t last_surrogate = last_trail_surrogate;
11913 return u >= first_lead_surrogate && u <= last_lead_surrogate;
11916 return u >= first_trail_surrogate && u <= last_trail_surrogate;
11919 return u >= first_surrogate && u <= last_surrogate;
11923 static constexpr
auto last_1byte_value = 0x7Fu;
11924 static constexpr
auto last_2byte_value = 0x7FFu;
11925 static constexpr
auto last_3byte_value = 0xFFFFu;
11927 static constexpr
auto start_2byte_mask = 0x80u;
11928 static constexpr
auto start_3byte_mask = 0xE0u;
11929 static constexpr
auto start_4byte_mask = 0xF0u;
11931 static constexpr
auto continuation_mask = 0xC0u;
11932 static constexpr
auto continuation_signature = 0x80u;
11935 return b == 0xC0 || b == 0xC1 || b > 0xF4;
11939 return (b & unicode_detail::continuation_mask) == unicode_detail::continuation_signature;
11943 return u <= unicode_detail::last_1byte_value || (u <= unicode_detail::last_2byte_value && bytes > 2)
11944 || (u <= unicode_detail::last_3byte_value && bytes > 3);
11948 return (b & start_2byte_mask) == 0 ? 1
11949 : (b & start_3byte_mask) != start_3byte_mask ? 2
11950 : (b & start_4byte_mask) != start_4byte_mask ? 3
11954 static constexpr char32_t
decode(
unsigned char b0,
unsigned char b1) {
11955 return ((b0 & 0x1F) << 6) | (b1 & 0x3F);
11957 static constexpr char32_t
decode(
unsigned char b0,
unsigned char b1,
unsigned char b2) {
11958 return ((b0 & 0x0F) << 12) | ((b1 & 0x3F) << 6) | (b2 & 0x3F);
11960 static constexpr char32_t
decode(
unsigned char b0,
unsigned char b1,
unsigned char b2,
unsigned char b3) {
11961 return ((b0 & 0x07) << 18) | ((b1 & 0x3F) << 12) | ((b2 & 0x3F) << 6) | (b3 & 0x3F);
11965 static constexpr char32_t last_bmp_value = 0xFFFF;
11966 static constexpr char32_t normalizing_value = 0x10000;
11967 static constexpr
int lead_surrogate_bitmask = 0xFFC00;
11968 static constexpr
int trail_surrogate_bitmask = 0x3FF;
11969 static constexpr
int lead_shifted_bits = 10;
11970 static constexpr char32_t replacement = 0xFFFD;
11973 auto hi = lead - first_lead_surrogate;
11974 auto lo = trail - first_trail_surrogate;
11975 return normalizing_value + ((hi << lead_shifted_bits) | lo);
11982 if (codepoint <= unicode_detail::last_1byte_value) {
11986 else if (codepoint <= unicode_detail::last_2byte_value) {
11989 static_cast<char>(0xC0 | ((codepoint & 0x7C0) >> 6)),
11990 static_cast<char>(0x80 | (codepoint & 0x3F)),
11993 else if (codepoint <= unicode_detail::last_3byte_value) {
11996 static_cast<char>(0xE0 | ((codepoint & 0xF000) >> 12)),
11997 static_cast<char>(0x80 | ((codepoint & 0xFC0) >> 6)),
11998 static_cast<char>(0x80 | (codepoint & 0x3F)),
12004 static_cast<char>(0xF0 | ((codepoint & 0x1C0000) >> 18)),
12005 static_cast<char>(0x80 | ((codepoint & 0x3F000) >> 12)),
12006 static_cast<char>(0x80 | ((codepoint & 0xFC0) >> 6)),
12007 static_cast<char>(0x80 | (codepoint & 0x3F)),
12016 if (codepoint <= unicode_detail::last_bmp_value) {
12022 auto normal = codepoint - unicode_detail::normalizing_value;
12023 auto lead = unicode_detail::first_lead_surrogate + ((normal & unicode_detail::lead_surrogate_bitmask) >> unicode_detail::lead_shifted_bits);
12024 auto trail = unicode_detail::first_trail_surrogate + (normal & unicode_detail::trail_surrogate_bitmask);
12026 static_cast<char16_t
>(lead),
12027 static_cast<char16_t>(trail)
12043 template <
typename It>
12048 dr.
error = error_code::sequence_too_short;
12052 unsigned char b0 = *it;
12053 std::size_t
length = unicode_detail::sequence_length(b0);
12056 dr.
codepoint =
static_cast<char32_t
>(b0);
12063 if (unicode_detail::is_invalid(b0) || unicode_detail::is_continuation(b0)) {
12064 dr.
error = error_code::invalid_code_unit;
12070 std::array<unsigned char, 4> b;
12072 for (std::size_t i = 1; i <
length; ++i) {
12074 if (!unicode_detail::is_continuation(b[i])) {
12075 dr.
error = error_code::invalid_code_unit;
12095 if (unicode_detail::is_overlong(decoded, length)) {
12096 dr.
error = error_code::overlong_sequence;
12099 if (unicode_detail::is_surrogate(decoded) || decoded > unicode_detail::last_code_point) {
12100 dr.
error = error_code::invalid_code_point;
12111 template <
typename It>
12116 dr.
error = error_code::sequence_too_short;
12120 char16_t lead =
static_cast<char16_t
>(*it);
12122 if (!unicode_detail::is_surrogate(lead)) {
12124 dr.
codepoint =
static_cast<char32_t
>(lead);
12129 if (!unicode_detail::is_lead_surrogate(lead)) {
12130 dr.
error = error_code::invalid_leading_surrogate;
12137 if (!unicode_detail::is_trail_surrogate(trail)) {
12138 dr.
error = error_code::invalid_trailing_surrogate;
12143 dr.
codepoint = unicode_detail::combine_surrogates(lead, trail);
12149 template <
typename It>
12154 dr.
error = error_code::sequence_too_short;
12157 dr.
codepoint =
static_cast<char32_t
>(*it);
12167 #include <functional> 12171 #include <string_view> 12172 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 12174 #endif // Apple clang screwed up 12176 namespace sol {
namespace stack {
12178 namespace stack_detail {
12179 template <
typename Ch>
12191 template <
typename Ch,
typename ErCh>
12204 template <
typename Ch,
typename F>
12205 inline void convert(
const char* strb,
const char* stre, F&& f) {
12207 for (
const char* strtarget = strb; strtarget < stre;) {
12215 strtarget = dr.next;
12217 if constexpr (std::is_same_v<Ch, char32_t>) {
12228 template <
typename BaseCh,
typename S>
12230 using Ch =
typename S::value_type;
12236 const char* strb = utf8p;
12237 const char* stre = utf8p +
len;
12239 convert<BaseCh>(strb, stre, count_units);
12240 S r(count_units.
needed_size, static_cast<Ch>(0));
12242 Ch* target = &r[0];
12244 convert<BaseCh>(strb, stre, copy_units);
12249 template <
typename T,
typename>
12252 if constexpr (std::is_same_v<T, bool>) {
12256 else if constexpr (std::is_enum_v<T>) {
12260 else if constexpr (std::is_integral_v<T> || std::is_same_v<T, lua_Integer>) {
12262 #if SOL_LUA_VESION_I_ >= 503 12267 return static_cast<T
>(llround(
lua_tonumber(L, index)));
12269 else if constexpr (std::is_floating_point_v<T> || std::is_same_v<T, lua_Number>) {
12273 else if constexpr (is_lua_reference_v<T>) {
12275 return T(L, index);
12277 else if constexpr (is_unique_usertype_v<T>) {
12282 memory = detail::align_usertype_unique<Real>(
memory);
12283 Real* mem =
static_cast<Real*
>(
memory);
12286 else if constexpr (meta::is_optional_v<T>) {
12287 using ValueType =
typename T::value_type;
12290 else if constexpr (std::is_same_v<T, luaL_Stream*>) {
12294 else if constexpr (std::is_same_v<T, luaL_Stream>) {
12298 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) 12299 else if constexpr (std::is_function_v<T> || (std::is_pointer_v<T> && std::is_function_v<std::remove_pointer_t<T>>)) {
12300 return stack_detail::get_function_pointer<std::remove_pointer_t<T>>(L,
index, tracking);
12304 return stack_detail::unchecked_unqualified_get<detail::as_value_tag<T>>(L,
index, tracking);
12309 template <
typename X,
typename>
12313 static constexpr
bool is_userdata_of_some_kind
12314 = !std::is_reference_v<
12315 X> && is_container_v<Tu> && std::is_default_constructible_v<Tu> && !is_lua_primitive_v<Tu> && !is_transparent_argument_v<Tu>;
12316 if constexpr (is_userdata_of_some_kind) {
12318 return static_cast<Tu
>(stack_detail::unchecked_unqualified_get<Tu>(L,
index, tracking));
12321 return stack_detail::unchecked_unqualified_get<sol::nested<Tu>>(L,
index, tracking);
12327 using Real =
typename u_traits::actual_type;
12332 if (&detail::usertype_unique_alloc_destroy<T, X> == pdx) {
12333 memory = detail::align_usertype_unique_tag<true, false>(
memory);
12334 memory = detail::align_usertype_unique<Real, true, false>(
memory);
12335 Real* mem =
static_cast<Real*
>(
memory);
12336 return static_cast<Real
>(*mem);
12341 return static_cast<Real
>(
std::move(r));
12344 memory = detail::align_usertype_unique_tag<true, false>(
memory);
12346 memory = detail::align_usertype_unique<Real, true, false>(
memory);
12348 int cast_operation;
12349 if constexpr (is_base_rebindable_v<u_traits>) {
12350 using rebind_t =
typename u_traits::template rebind_base<void>;
12352 cast_operation = ic(memory, &r, ti, rebind_ti);
12356 cast_operation = ic(memory, &r, ti, rebind_ti);
12358 switch (cast_operation) {
12362 Real* mem =
static_cast<Real*
>(
memory);
12363 return static_cast<Real
>(*mem);
12368 return static_cast<Real
>(
std::move(r));
12374 return static_cast<Real
>(r);
12378 return stack_detail::unchecked_unqualified_get<Tu>(L,
index, tracking);
12383 template <
typename T>
12387 template <
typename V>
12392 template <
typename V>
12397 template <
typename V>
12403 template <
typename V>
12413 return idx >= cont.max_size();
12421 typedef typename Tu::value_type V;
12422 return get(
types<V>(), L, relindex, tracking);
12425 template <
typename V>
12465 std::size_t idx = 0;
12466 #if SOL_LUA_VESION_I_ >= 503 12475 bool isnil =
false;
12477 #if defined(LUA_NILINTABLE) && LUA_NILINTABLE && SOL_LUA_VESION_I_ >= 600 12478 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 12480 #endif // make sure stack doesn't overflow 12482 if (lua_keyin(L, index) == 0) {
12491 type vt =
static_cast<type
>(
lua_geti(L, index, i + vi));
12498 #if defined(LUA_NILINTABLE) && LUA_NILINTABLE && SOL_LUA_VESION_I_ >= 600 12508 #if defined(LUA_NILINTABLE) && LUA_NILINTABLE && SOL_LUA_VESION_I_ >= 600 12522 if (idx >= cont.max_size()) {
12526 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 12528 #endif // make sure stack doesn't overflow 12529 bool isnil =
false;
12555 typedef typename Tu::value_type P;
12556 typedef typename P::first_type K;
12557 typedef typename P::second_type V;
12561 template <
typename K,
typename V>
12565 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 12567 #endif // make sure stack doesn't overflow 12573 decltype(
auto) key = stack::check_get<K>(L, -2);
12578 associative.emplace(std::forward<decltype(*key)>(*key), stack::get<V>(L, -1));
12581 return associative;
12585 template <
typename T,
typename Al>
12587 typedef std::forward_list<T, Al>
C;
12594 typedef typename T::value_type P;
12595 typedef typename P::first_type K;
12596 typedef typename P::second_type V;
12601 typedef typename C::value_type V;
12602 return get(
types<V>(), L, relindex, tracking);
12605 template <
typename V>
12608 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 12610 #endif // make sure stack doesn't overflow 12614 auto at = cont.cbefore_begin();
12615 std::size_t idx = 0;
12616 #if SOL_LUA_VESION_I_ >= 503 12619 if (idx >= cont.max_size()) {
12622 bool isnil =
false;
12624 type t =
static_cast<type
>(
lua_geti(L, index, i + vi));
12642 if (idx >= cont.max_size()) {
12645 bool isnil =
false;
12669 template <
typename K,
typename V>
12673 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 12675 #endif // make sure stack doesn't overflow 12678 auto at = associative.cbefore_begin();
12682 decltype(
auto) key = stack::check_get<K>(L, -2);
12687 at = associative.emplace_after(at, std::forward<decltype(*key)>(*key), stack::get<V>(L, -1));
12690 return associative;
12694 template <
typename T>
12698 if constexpr (is_container_v<Tu>) {
12700 typedef typename T::value_type P;
12701 typedef typename P::first_type K;
12702 typedef typename P::second_type V;
12709 typedef typename T::value_type V;
12720 return g.
get(L, index, tracking);
12725 template <
typename T>
12728 return stack::unqualified_get<T>(L,
index, tracking);
12732 template <
typename T>
12735 return stack::unqualified_get<T*>(L,
index, tracking);
12755 template <
typename T>
12764 template <
typename T>
12769 memory = detail::align_user<T>(
memory);
12770 return *
static_cast<std::remove_reference_t<T>*
>(
memory);
12774 template <
typename T>
12779 memory = detail::align_user<T*>(
memory);
12780 return static_cast<T*
>(
memory);
12788 return static_cast<type
>(
lua_type(L, index));
12817 return len > 0 ? str[0] :
'\0';
12821 template <
typename Traits>
12831 template <
typename Traits,
typename Al>
12833 using S = std::basic_string<wchar_t, Traits, Al>;
12836 return stack_detail::get_into<Ch, S>(L,
index, tracking);
12840 template <
typename Traits,
typename Al>
12843 return stack_detail::get_into<char16_t, std::basic_string<char16_t, Traits, Al>>(L,
index, tracking);
12847 template <
typename Traits,
typename Al>
12850 return stack_detail::get_into<char32_t, std::basic_string<char32_t, Traits, Al>>(L,
index, tracking);
12858 const char* strb = utf8.data();
12859 const char* stre = utf8.data() + utf8.size();
12869 return er.code_units[0];
12877 const char* strb = utf8.data();
12878 const char* stre = utf8.data() + utf8.size();
12888 return er.code_units[0];
12898 auto c = g.
get(L, index, tracking);
12899 return static_cast<wchar_t>(
c);
12909 for (std::size_t i = 0; i < mfnames.size(); ++i)
12910 if (mfnames[i] == name)
12978 if (err ==
nullptr) {
13001 template <
typename T>
13005 #if SOL_IS_ON(SOL_USE_INTEROP_I_) 13006 auto ugr = stack_detail::interop_get<T>(L,
index,
memory, tracking);
13010 #endif // interop extensibility 13013 void** pudata =
static_cast<void**
>(rawdata);
13014 void* udata = *pudata;
13015 return get_no_lua_nil_from(L, udata, index, tracking);
13032 T* obj =
static_cast<T*
>(udata);
13037 return *get_no_lua_nil(L, index, tracking);
13041 template <
typename T>
13052 return g.get_no_lua_nil(L, index, tracking);
13056 template <
typename T>
13062 return g.get_no_lua_nil(L, index, tracking);
13066 template <
typename T>
13072 return g.
get(L, index, tracking);
13076 template <
typename T>
13082 return g.
get(L, index, tracking);
13086 template <
typename T>
13089 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) 13090 if constexpr (std::is_function_v<T>) {
13091 return stack_detail::get_function_pointer<T>(L,
index, tracking);
13097 return g.
get(L, index, tracking);
13103 return g.
get(L, index, tracking);
13108 template <
typename... Tn>
13110 typedef std::tuple<decltype(stack::get<Tn>(
nullptr, 0))...>
R;
13112 template <
typename... Args>
13115 return R { std::forward<Args>(args)... };
13118 template <std::size_t I, std::size_t... Ix,
typename... Args>
13122 return apply(std::index_sequence<Ix...>(), L, index, tracking, std::forward<Args>(args)..., stack::get<T>(L, index + tracking.
used, tracking));
13126 return apply(std::make_index_sequence<
sizeof...(Tn)>(), L, index, tracking);
13130 template <
typename A,
typename B>
13133 return std::pair<decltype(stack::get<A>(L,
index)), decltype(stack::get<B>(L, index))> { stack::get<A>(L,
index, tracking),
13134 stack::get<B>(L, index + tracking.used, tracking) };
13138 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 13140 template <
typename... Tn>
13142 using V = std::variant<Tn...>;
13148 if constexpr (std::variant_size_v<V> == 0) {
13158 template <std::
size_t I>
13160 typedef std::variant_alternative_t<I, V> T;
13161 record temp_tracking = tracking;
13162 if (stack::check<T>(L, index,
no_panic, temp_tracking)) {
13163 tracking = temp_tracking;
13164 return V(std::in_place_index<I>, stack::get<T>(L, index));
13166 return get_one(std::integral_constant<std::size_t, I + 1>(), L, index, tracking);
13170 return get_one(std::integral_constant<std::size_t, 0>(), L, index, tracking);
13201 #include <optional> 13202 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 13204 #endif // variant shenanigans (thanks, Mac OSX) 13206 namespace sol {
namespace stack {
13207 template <
typename T,
typename>
13209 typedef decltype(stack_detail::unchecked_unqualified_get<T>(
nullptr, -1, std::declval<record&>())) R;
13211 template <typename Optional, typename Handler>
13213 if constexpr (!meta::meta_detail::is_adl_sol_lua_check_v<T> && !meta::meta_detail::is_adl_sol_lua_get_v<T>) {
13214 if constexpr (is_lua_reference_v<T>) {
13220 tracking.use(static_cast<int>(success));
13222 return detail::associated_nullopt_v<Optional>;
13224 return stack_detail::unchecked_get<T>(L,
index, tracking);
13226 else if constexpr ((std::is_integral_v<T> || std::is_same_v<T, lua_Integer>)&&!std::is_same_v<T, bool>) {
13227 #if SOL_LUA_VESION_I_ >= 503 13236 #if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_) 13237 const auto integer_value = llround(value);
13238 if (static_cast<lua_Number>(integer_value) == value) {
13240 return static_cast<T
>(integer_value);
13244 return static_cast<T
>(value);
13247 const type t =
type_of(L, index);
13248 tracking.use(static_cast<int>(t !=
type::none));
13250 return detail::associated_nullopt_v<Optional>;
13252 else if constexpr (std::is_floating_point_v<T> || std::is_same_v<T, lua_Number>) {
13257 tracking.use(static_cast<int>(t !=
type::none));
13259 return detail::associated_nullopt_v<Optional>;
13262 return static_cast<T
>(value);
13264 else if constexpr (std::is_enum_v<T> && !meta::any_same_v<T, meta_function, type>) {
13269 tracking.use(static_cast<int>(t !=
type::none));
13271 return detail::associated_nullopt_v<Optional>;
13274 return static_cast<T
>(value);
13277 if (!unqualified_check<T>(L, index, std::forward<Handler>(handler))) {
13278 tracking.use(static_cast<int>(!
lua_isnone(L, index)));
13279 return detail::associated_nullopt_v<Optional>;
13281 return stack_detail::unchecked_unqualified_get<T>(L,
index, tracking);
13285 if (!unqualified_check<T>(L, index, std::forward<Handler>(handler))) {
13286 tracking.use(static_cast<int>(!
lua_isnone(L, index)));
13287 return detail::associated_nullopt_v<Optional>;
13289 return stack_detail::unchecked_unqualified_get<T>(L,
index, tracking);
13293 template <
typename Handler>
13295 return get_using<optional<R>>(L,
index, std::forward<Handler>(
handler), tracking);
13299 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 13300 template <
typename... Tn,
typename C>
13302 typedef std::variant<Tn...>
V;
13306 template <
typename Handler>
13311 template <
typename Handler>
13317 L, index,
type::poly,
type_of(L, index),
"this variant code should never be reached: if it has, you have done something so terribly wrong");
13321 template <
typename Handler>
13323 return get_empty(V_is_empty(), L, index, std::forward<Handler>(
handler), tracking);
13326 template <std::
size_t I,
typename Handler>
13328 typedef std::variant_alternative_t<I - 1,
V> T;
13329 if (stack::check<T>(L, index,
no_panic, tracking)) {
13330 return V(std::in_place_index<I - 1>, stack::get<T>(L, index));
13332 return get_one(std::integral_constant<std::size_t, I - 1>(), L, index, std::forward<Handler>(
handler), tracking);
13335 template <
typename Handler>
13337 return get_one(std::integral_constant<std::size_t, V_size::value>(), L, index, std::forward<Handler>(handler), tracking);
13340 #endif // standard variant 13347 namespace sol {
namespace stack {
13348 template <
typename T,
typename C>
13350 typedef decltype(stack_detail::unchecked_get<T>(
nullptr, -1, std::declval<record&>())) R;
13352 template <typename Handler>
13354 if constexpr (is_lua_reference_v<T>) {
13360 tracking.use(static_cast<int>(success));
13364 return stack_detail::unchecked_get<T>(L,
index, tracking);
13367 if (!check<T>(L, index, std::forward<Handler>(handler))) {
13368 tracking.use(static_cast<int>(!
lua_isnone(L, index)));
13371 return stack_detail::unchecked_get<T>(L,
index, tracking);
13376 template <
typename T>
13380 if constexpr (is_lua_reference_v<ValueType>) {
13386 tracking.use(static_cast<int>(success));
13389 return stack_detail::unchecked_get<ValueType>(L,
index, tracking);
13392 if (!check<ValueType>(L, index, &
no_panic)) {
13393 tracking.use(static_cast<int>(!
lua_isnone(L, index)));
13396 return stack_detail::unchecked_get<ValueType>(L,
index, tracking);
13410 #include <type_traits> 13414 #include <string_view> 13415 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 13417 #endif // Can use variant 13419 namespace sol {
namespace stack {
13420 namespace stack_detail {
13421 template <
typename T>
13423 if constexpr (
sizeof(T) <
sizeof(
lua_Integer) || (std::is_signed_v<T> &&
sizeof(T) ==
sizeof(
lua_Integer))) {
13432 return (u_min <= t_min || value >= static_cast<T>(u_min)) && (u_max >= t_max || value <= static_cast<T>(u_max));
13436 template <
typename T>
13438 if constexpr (
meta::any_same_v<std::underlying_type_t<T>,
char , char16_t, char32_t>) {
13439 if constexpr (std::is_signed_v<T>) {
13440 return stack::push(L, static_cast<std::int_least32_t>(value));
13443 return stack::push(L, static_cast<std::uint_least32_t>(value));
13447 return stack::push(L,
static_cast<std::underlying_type_t<T>
>(value));
13451 template <
typename T>
13458 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13460 #endif // make sure stack doesn't overflow 13461 #if SOL_LUA_VESION_I_ < 502 13463 lua_getfenv(L, index);
13474 template <
typename T>
13480 template <
typename T>
13482 template <
typename F,
typename... Args>
13484 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13486 #endif // make sure stack doesn't overflow 13492 T* obj = detail::usertype_allocate<T>(L);
13494 std::allocator<T> alloc {};
13495 std::allocator_traits<std::allocator<T>>
::construct(alloc, obj, std::forward<Args>(args)...);
13499 template <
typename K,
typename... Args>
13502 return push_fx(L, fx, std::forward<Args>(args)...);
13505 template <
typename Arg,
typename... Args>
13509 return push_fx(L, std::forward<Args>(args)...);
13521 template <
typename T>
13525 template <
typename F>
13527 if (obj ==
nullptr)
13529 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13531 #endif // make sure stack doesn't overflow 13532 T** pref = detail::usertype_allocate_pointer<T>(L);
13538 template <
typename K>
13541 return push_fx(L, fx, obj);
13544 template <
typename Arg,
typename... Args>
13548 return push_fx(L, std::forward<Args>(args)...);
13558 template <
typename T>
13564 namespace stack_detail {
13565 template <
typename T>
13571 template <
typename Arg,
typename... Args>
13574 if (u_traits::is_null(
arg)) {
13577 return push_deep(L, std::forward<Arg>(
arg), std::forward<Args>(args)...);
13580 return push_deep(L, std::forward<Arg>(
arg), std::forward<Args>(args)...);
13584 template <
typename... Args>
13586 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13588 #endif // make sure stack doesn't overflow 13589 P** pref =
nullptr;
13592 Real* mem = detail::usertype_unique_allocate<P, Real>(L, pref, fx, id);
13602 *fx = detail::usertype_unique_alloc_destroy<P, Real>;
13611 template <
typename T>
13613 template <
typename... Args>
13617 return p.
push(L, std::forward<Args>(args)...);
13621 template <
typename T,
typename>
13623 template <
typename... Args>
13626 if constexpr (is_lua_reference_v<Tu>) {
13627 using int_arr =
int[];
13628 int_arr p { (std::forward<Args>(args).
push(L))... };
13631 else if constexpr (std::is_same_v<Tu, bool>) {
13632 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13634 #endif // make sure stack doesn't overflow 13638 else if constexpr (std::is_integral_v<Tu> || std::is_same_v<Tu, lua_Integer>) {
13639 const Tu&
value(std::forward<Args>(args)...);
13640 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13642 #endif // make sure stack doesn't overflow 13643 #if SOL_LUA_VESION_I_ >= 503 13644 if (stack_detail::integer_value_fits<Tu>(value)) {
13648 #endif // Lua 5.3 and above 13649 #if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_) 13650 if (static_cast<T>(llround(static_cast<lua_Number>(value))) != value) {
13651 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 13653 assert(
false &&
"integer value will be misrepresented in lua");
13658 #endif // No Exceptions 13660 #endif // Safe Numerics and Number Precision Check 13664 else if constexpr (std::is_floating_point_v<Tu> || std::is_same_v<Tu, lua_Number>) {
13665 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13667 #endif // make sure stack doesn't overflow 13671 else if constexpr (std::is_same_v<Tu, luaL_Stream*>) {
13672 luaL_Stream* source { std::forward<Args>(args)... };
13674 stream->
f = source->f;
13675 #if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_) 13676 stream->closef = source->closef;
13677 #endif // LuaJIT and Lua 5.1 and below do not have 13680 else if constexpr (std::is_same_v<Tu, luaL_Stream>) {
13681 luaL_Stream& source(std::forward<Args>(args)...);
13683 stream->
f = source.
f;
13684 #if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_) 13686 #endif // LuaJIT and Lua 5.1 and below do not have 13689 else if constexpr (std::is_enum_v<Tu>) {
13692 else if constexpr (std::is_pointer_v<Tu>) {
13693 return stack::push<detail::as_pointer_tag<std::remove_pointer_t<T>>>(L, std::forward<Args>(args)...);
13695 else if constexpr (is_unique_usertype_v<Tu>) {
13696 return stack::push<detail::as_unique_tag<T>>(L, std::forward<Args>(args)...);
13699 return stack::push<detail::as_value_tag<T>>(L, std::forward<Args>(args)...);
13704 template <
typename T>
13711 template <
typename T>
13716 return push(
has_kvp(), std::false_type(), L, tablecont);
13720 return push(
has_kvp(), std::true_type(), L, tablecont);
13724 return push(
has_kvp(), std::true_type(), L, tablecont);
13728 return push(
has_kvp(), std::false_type(), L, tablecont);
13731 template <
bool is_nested>
13732 static int push(std::true_type, std::integral_constant<bool, is_nested>,
lua_State* L,
const T& tablecont) {
13736 for (
const auto& pair : cont) {
13741 set_field(L, pair.first, pair.second, tableindex);
13747 template <
bool is_nested>
13748 static int push(std::false_type, std::integral_constant<bool, is_nested>,
lua_State* L,
const T& tablecont) {
13752 std::size_t index = 1;
13753 for (
const auto& i : cont) {
13754 #if SOL_LUA_VESION_I_ >= 503 13756 for (
int pi = 0; pi < p; ++pi) {
13757 lua_seti(L, tableindex, static_cast<lua_Integer>(index++));
13760 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13762 #endif // make sure stack doesn't overflow 13770 int firstindex = tableindex + 1 + 1;
13771 for (
int pi = 0; pi < p; ++pi) {
13773 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13775 #endif // make sure stack doesn't overflow 13783 #endif // Lua Version 5.3 and others 13791 template <
typename T>
13794 using inner_t = std::remove_pointer_t<meta::unwrap_unqualified_t<T>>;
13795 if constexpr (is_container_v<inner_t>) {
13796 return stack::push<detail::as_table_tag<T>>(L, v);
13804 template <
typename T>
13808 using inner_t = std::remove_pointer_t<Tu>;
13809 if constexpr (is_container_v<inner_t>) {
13810 return stack::push<detail::as_table_tag<T>>(L, tablecont,
nested_tag);
13813 return stack::push<Tu>(L, tablecont);
13818 template <
typename T>
13824 return p.
push(L, il);
13831 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13833 #endif // make sure stack doesn't overflow 13849 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13851 #endif // make sure stack doesn't overflow 13860 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13862 #endif // make sure stack doesn't overflow 13871 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13873 #endif // make sure stack doesn't overflow 13879 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) 13883 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13885 #endif // make sure stack doesn't overflow 13894 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13896 #endif // make sure stack doesn't overflow 13901 #endif // noexcept function type 13906 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13908 #endif // make sure stack doesn't overflow 13914 template <
typename Arg,
typename... Args>
13916 template <std::size_t... I,
typename T>
13918 using f_tuple = decltype(std::forward<T>(
c).upvalues);
13919 int pushcount =
multi_push(L, std::get<I>(std::forward<f_tuple>(std::forward<T>(
c).upvalues))...);
13923 template <
typename T>
13925 return push(std::make_index_sequence<1 +
sizeof...(Args)>(), L, std::forward<T>(
c));
13932 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13934 #endif // make sure stack doesn't overflow 13943 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13945 #endif // make sure stack doesn't overflow 13954 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13956 #endif // make sure stack doesn't overflow 13962 template <
typename T>
13965 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13967 #endif // make sure stack doesn't overflow 13973 template <
typename T>
13975 template <
bool with_meta =
true,
typename Key,
typename... Args>
13977 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13979 #endif // make sure stack doesn't overflow 13981 T* data = detail::user_allocate<T>(L);
13984 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 13986 #endif // make sure stack doesn't overflow 13994 std::allocator<T> alloc {};
13995 std::allocator_traits<std::allocator<T>>
::construct(alloc, data, std::forward<Args>(args)...);
13999 template <
typename Arg,
typename... Args>
14002 const auto name = &
arg[0];
14003 return push_with<true>(L, name, std::forward<Args>(args)...);
14008 return push_with<false>(L, name, std::forward<Args>(args)...);
14012 return push_with(L, name, std::forward<Arg>(
arg), std::forward<Args>(args)...);
14018 return push_with(L, name, u.
value);
14023 return push_with(L, name,
std::move(u.value));
14028 return push_with<false>(L, name, u.
value);
14033 return push_with<false>(L, name,
std::move(u.value));
14040 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14042 #endif // make sure stack doesn't overflow 14043 void** ud = detail::usertype_allocate_pointer<void>(L);
14052 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14054 #endif // make sure stack doesn't overflow 14060 if (str ==
nullptr)
14062 return push_sized(L, str, std::char_traits<char>::length(str));
14066 return push_sized(L, strb, stre - strb);
14070 return push_sized(L, str, len);
14085 return p.
push(L, str);
14091 return p.
push(L, strb, stre);
14097 return p.
push(L, str, len);
14101 template <
size_t N>
14104 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14106 #endif // make sure stack doesn't overflow 14112 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14114 #endif // make sure stack doesn't overflow 14123 const char str[2] = {
c,
'\0' };
14124 return stack::push(L, static_cast<const char*>(str), 1);
14128 template <
typename Ch,
typename Traits,
typename Al>
14131 if constexpr (!std::is_same_v<Ch, char>) {
14135 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14137 #endif // make sure stack doesn't overflow 14143 static int push(
lua_State* L,
const std::basic_string<Ch, Traits, Al>& str, std::size_t sz) {
14144 if constexpr (!std::is_same_v<Ch, char>) {
14148 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14150 #endif // make sure stack doesn't overflow 14157 template <
typename Ch,
typename Traits>
14171 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14173 #endif // make sure stack doesn't overflow 14183 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14185 #endif // make sure stack doesn't overflow 14194 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14196 #endif // make sure stack doesn't overflow 14205 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14207 #endif // make sure stack doesn't overflow 14216 return push(L, wstr, std::char_traits<wchar_t>::length(wstr));
14220 return push(L, wstr, wstr + sz);
14224 if constexpr (
sizeof(
wchar_t) == 2) {
14225 const char16_t* sb =
reinterpret_cast<const char16_t*
>(strb);
14226 const char16_t* se =
reinterpret_cast<const char16_t*
>(stre);
14230 const char32_t* sb =
reinterpret_cast<const char32_t*
>(strb);
14231 const char32_t* se =
reinterpret_cast<const char32_t*
>(stre);
14242 return p.
push(L, str);
14248 return p.
push(L, strb, stre);
14254 return p.
push(L, str, len);
14261 char* target = start;
14263 for (
const char16_t* strtarget = strb; strtarget < stre;) {
14272 const char* utf8data = er.code_units.data();
14273 std::memcpy(target, utf8data, er.code_units_size);
14274 target += er.code_units_size;
14275 strtarget = dr.next;
14282 return push(L, u16str, std::char_traits<char16_t>::length(u16str));
14286 return push(L, u16str, u16str + sz);
14293 std::size_t max_possible_code_units = (stre - strb) * 4;
14295 return convert_into(L, sbo, max_possible_code_units, strb, stre);
14298 std::size_t needed_size = 0;
14299 for (
const char16_t* strtarget = strb; strtarget < stre;) {
14302 needed_size += er.code_units_size;
14303 strtarget = dr.next;
14306 return convert_into(L, sbo, needed_size, strb, stre);
14309 u8str.resize(needed_size);
14310 char* target =
const_cast<char*
>(u8str.data());
14311 return convert_into(L, target, needed_size, strb, stre);
14320 return p.
push(L, str);
14326 return p.
push(L, strb, stre);
14332 return p.
push(L, str, len);
14339 char* target = start;
14341 for (
const char32_t* strtarget = strb; strtarget < stre;) {
14350 const char* data = er.code_units.data();
14351 std::memcpy(target, data, er.code_units_size);
14352 target += er.code_units_size;
14353 strtarget = dr.next;
14359 return push(L, u32str, u32str + std::char_traits<char32_t>::length(u32str));
14363 return push(L, u32str, u32str + sz);
14370 std::size_t max_possible_code_units = (stre - strb) * 4;
14372 return convert_into(L, sbo, max_possible_code_units, strb, stre);
14375 std::size_t needed_size = 0;
14376 for (
const char32_t* strtarget = strb; strtarget < stre;) {
14379 needed_size += er.code_units_size;
14380 strtarget = dr.next;
14383 return convert_into(L, sbo, needed_size, strb, stre);
14386 u8str.resize(needed_size);
14387 char* target =
const_cast<char*
>(u8str.data());
14388 return convert_into(L, target, needed_size, strb, stre);
14397 return p.
push(L, str);
14403 return p.
push(L, strb, stre);
14409 return p.
push(L, str, len);
14413 template <
size_t N>
14416 return push(L, str, std::char_traits<wchar_t>::length(str));
14420 const wchar_t* str_ptr =
static_cast<const wchar_t*
>(str);
14421 return stack::push<const wchar_t*>(L, str_ptr, str_ptr + sz);
14425 template <
size_t N>
14428 return push(L, str, std::char_traits<char16_t>::length(str));
14432 const char16_t* str_ptr =
static_cast<const char16_t*
>(str);
14433 return stack::push<const char16_t*>(L, str_ptr, str_ptr + sz);
14437 template <
size_t N>
14440 return push(L, str, std::char_traits<char32_t>::length(str));
14444 const char32_t* str_ptr =
static_cast<const char32_t*
>(str);
14445 return stack::push<const char32_t*>(L, str_ptr, str_ptr + sz);
14452 const wchar_t str[2] = {
c,
'\0' };
14453 return stack::push(L, static_cast<const wchar_t*>(str), 1);
14460 const char16_t str[2] = {
c,
'\0' };
14461 return stack::push(L, static_cast<const char16_t*>(str), 1);
14468 const char32_t str[2] = {
c,
'\0' };
14469 return stack::push(L, static_cast<const char32_t*>(str), 1);
14473 template <
typename... Args>
14475 template <std::size_t... I,
typename T>
14477 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 14479 #endif // make sure stack doesn't overflow 14485 template <
typename T>
14487 return push(std::index_sequence_for<Args...>(), L, std::forward<T>(t));
14491 template <
typename A,
typename B>
14493 template <
typename T>
14495 int pushcount =
stack::push(L, std::get<0>(std::forward<T>(t)));
14496 pushcount +=
stack::push(L, std::get<1>(std::forward<T>(t)));
14501 template <
typename T>
14505 template <
typename Optional>
14511 return stack::push(L, static_cast<QualifiedValueType>(op.value()));
14551 template <
typename Allocator>
14553 template <
typename T>
14555 const auto first = bc.data();
14556 const auto bcsize = bc.size();
14560 L, reinterpret_cast<const char*>(first),
static_cast<std::size_t
>(bcsize * (
sizeof(*first) /
sizeof(
const char))), bytecode_name);
14564 template <
typename T>
14566 return push(L, std::forward<bc>(bc),
"bytecode");
14570 #if SOL_IS_ON(SOL_STD_VARIANT_I_) 14571 namespace stack_detail {
14579 template <
typename T>
14581 return stack::push<T>(L, std::forward<T>(
value));
14587 template <
typename... Tn>
14597 #endif // Variant because Clang is terrible 14610 template <
typename T,
typename>
14615 "You cannot pop something that lives solely on the stack: it will not remain on the stack when popped and thusly will go out of " 14633 namespace sol {
namespace stack {
14634 template <
typename T,
bool global,
bool raw,
typename>
14637 #if SOL_LUA_VESION_I_ >= 503 14638 || (std::is_integral_v<T> && !std::is_same_v<T, bool>)
14640 || (raw && std::is_void_v<std::remove_pointer_t<T>>),
14641 std::integral_constant<int, -1>, std::integral_constant<int, -2> > ::value;
14643 template <
typename Key>
14644 void get(
lua_State* L, Key&& key,
int tableindex = default_table_index) {
14645 if constexpr (std::is_same_v<T, update_if_empty_t> || std::is_same_v<T, override_value_t> || std::is_same_v<T, create_if_nil_t>) {
14650 else if constexpr (std::is_same_v<T, env_key_t>) {
14652 #if SOL_LUA_VESION_I_ < 502 14654 lua_getfenv(L, tableindex);
14662 else if constexpr (std::is_same_v<T, metatable_key_t>) {
14667 else if constexpr (raw) {
14668 if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
14669 lua_rawgeti(L, tableindex, static_cast<lua_Integer>(key));
14671 #if SOL_LUA_VESION_I_ >= 502 14672 else if constexpr (std::is_void_v<std::remove_pointer_t<T>>) {
14675 #endif // Lua 5.2.x+ 14677 push(L, std::forward<Key>(key));
14682 if constexpr (meta::is_c_str_v<T>) {
14683 if constexpr (global) {
14691 #if SOL_LUA_VESION_I_ >= 503 14692 else if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
14693 lua_geti(L, tableindex, static_cast<lua_Integer>(key));
14695 #endif // Lua 5.3.x+ 14697 push(L, std::forward<Key>(key));
14704 template <
typename... Args,
bool b,
bool raw,
typename C>
14706 template <std::size_t... I,
typename Keys>
14708 get_field<b, raw>(L, std::get<0>(std::forward<Keys>(keys)), tableindex);
14709 void(
detail::swallow { (get_field<false, raw>(L, std::get<I>(std::forward<Keys>(keys))), 0)... });
14711 lua_pop(L, static_cast<int>(
sizeof...(I)));
14715 template <
typename Keys>
14717 apply(std::make_index_sequence<
sizeof...(Args)>(), L, std::forward<Keys>(keys),
lua_absindex(L, -1));
14720 template <
typename Keys>
14722 apply(std::make_index_sequence<
sizeof...(Args)>(), L, std::forward<Keys>(keys), tableindex);
14726 template <
typename A,
typename B,
bool b,
bool raw,
typename C>
14728 template <
typename Keys>
14730 get_field<b, raw>(L, std::get<0>(std::forward<Keys>(keys)), tableindex);
14731 get_field<false, raw>(L, std::get<1>(std::forward<Keys>(keys)));
14733 lua_pop(L, static_cast<int>(2));
14737 template <
typename Keys>
14739 get_field<b, raw>(L, std::get<0>(std::forward<Keys>(keys)));
14740 get_field<false, raw>(L, std::get<1>(std::forward<Keys>(keys)));
14742 lua_pop(L, static_cast<int>(2));
14747 template <
typename T,
bool global,
bool raw,
typename>
14749 static constexpr
int default_table_index
14751 || (std::is_integral_v<T> && !std::is_same_v<T, bool>) || (raw && std::is_void_v<std::remove_pointer_t<T>>),
14752 std::integral_constant<int, -2>, std::integral_constant<int, -3> > ::value;
14754 template <
typename Key,
typename Value>
14756 if constexpr (std::is_same_v<T, update_if_empty_t> || std::is_same_v<T, override_value_t>) {
14762 else if constexpr (std::is_same_v<T, metatable_key_t>) {
14764 push(L, std::forward<Value>(value));
14767 else if constexpr (raw) {
14768 if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
14769 push(L, std::forward<Value>(value));
14770 lua_rawseti(L, tableindex, static_cast<lua_Integer>(key));
14772 #if SOL_LUA_VESION_I_ >= 502 14773 else if constexpr (std::is_void_v<std::remove_pointer_t<T>>) {
14774 push(L, std::forward<Value>(value));
14775 lua_rawsetp(L, tableindex, std::forward<Key>(key));
14777 #endif // Lua 5.2.x 14779 push(L, std::forward<Key>(key));
14780 push(L, std::forward<Value>(value));
14785 if constexpr (meta::is_c_str_v<T> || meta::is_string_of_v<T, char>) {
14786 if constexpr (global) {
14787 push(L, std::forward<Value>(value));
14792 push(L, std::forward<Value>(value));
14796 #if SOL_LUA_VESION_I_ >= 503 14797 else if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
14798 push(L, std::forward<Value>(value));
14799 lua_seti(L, tableindex, static_cast<lua_Integer>(key));
14801 #endif // Lua 5.3.x 14803 push(L, std::forward<Key>(key));
14804 push(L, std::forward<Value>(value));
14811 template <
typename... Args,
bool b,
bool raw,
typename C>
14813 template <
bool g, std::
size_t I,
typename Keys,
typename Value>
14815 I < 1 ? set_field<g, raw>(L, std::get<I>(std::forward<Keys>(keys)), std::forward<Value>(
value), tableindex)
14816 : set_field<g, raw>(L, std::get<I>(std::forward<Keys>(keys)), std::forward<Value>(
value));
14819 template <
bool g, std::size_t I0, std::size_t I1, std::size_t... I,
typename Keys,
typename Value>
14821 I0 < 1 ? get_field<g, raw>(L, std::get<I0>(std::forward<Keys>(keys)), tableindex)
14822 : get_field<g, raw>(L, std::get<I0>(std::forward<Keys>(keys)), -1);
14823 apply<false>(std::index_sequence<I1, I...>(), L, std::forward<Keys>(keys), std::forward<Value>(
value), -1);
14826 template <
bool g, std::size_t I0, std::size_t... I,
typename Keys,
typename Value>
14828 apply<g>(std::index_sequence<I0, I...>(), L, std::forward<Keys>(keys), std::forward<Value>(
value), tableindex);
14829 lua_pop(L, static_cast<int>(
sizeof...(I)));
14832 template <
typename Keys,
typename Value>
14834 top_apply<b>(std::make_index_sequence<
sizeof...(Args)>(), L, std::forward<Keys>(keys), std::forward<Value>(value), tableindex);
14838 template <
typename A,
typename B,
bool b,
bool raw,
typename C>
14840 template <
typename Keys,
typename Value>
14842 get_field<b, raw>(L, std::get<0>(std::forward<Keys>(keys)), tableindex);
14843 set_field<false, raw>(L, std::get<1>(std::forward<Keys>(keys)), std::forward<Value>(value),
lua_gettop(L));
14855 template <
typename T,
typename P,
bool b,
bool raw,
typename>
14857 template <
typename Key>
14861 return probe(
false, 0);
14864 get_field<b, raw>(L, std::forward<Key>(key), tableindex);
14865 return probe(check<P>(L), 1);
14869 template <
typename A,
typename B,
typename P,
bool b,
bool raw,
typename C>
14871 template <
typename Keys>
14874 return probe(
false, 0);
14876 get_field<b, raw>(L, std::get<0>(keys), tableindex);
14878 return probe(
false, 1);
14880 get_field<false, raw>(L, std::get<1>(keys), tableindex);
14881 return probe(check<P>(L), 2);
14885 template <
typename... Args,
typename P,
bool b,
bool raw,
typename C>
14887 template <std::
size_t I,
typename Keys>
14889 get_field<(I<1) && b, raw>(L, std::get<I>(keys), tableindex);
14890 return probe(check<P>(L), sofar);
14893 template <std::size_t I, std::size_t I1, std::size_t... In,
typename Keys>
14895 get_field < I<1 && b, raw>(L, std::get<I>(keys), tableindex);
14897 return probe(
false, sofar);
14899 return apply(std::index_sequence<I1, In...>(), sofar + 1, L, std::forward<Keys>(keys), -1);
14902 template <
typename Keys>
14904 if constexpr (!b) {
14906 return probe(
false, 0);
14908 return apply(std::index_sequence_for<Args...>(), 1, L, std::forward<Keys>(keys), tableindex);
14911 return apply(std::index_sequence_for<Args...>(), 1, L, std::forward<Keys>(keys), tableindex);
14933 template <std::
size_t N>
14935 if (chunkname.empty()) {
14936 auto it = code.cbegin();
14937 auto e = code.cend();
14939 static const std::size_t n = N - 4;
14940 for (i = 0; i < n && it != e; ++i, ++it) {
14941 basechunkname[i] = *it;
14944 for (std::size_t
c = 0;
c < 3; ++i, ++
c) {
14945 basechunkname[i] =
'.';
14948 basechunkname[i] =
'\0';
14949 return &basechunkname[0];
14952 return chunkname.c_str();
14973 namespace stack_detail {
14974 template <
typename T>
14976 typedef std::decay_t<T>
TValue;
14977 static const std::size_t itemsize =
sizeof(
TValue);
14978 static const std::size_t voidsize =
sizeof(
void*);
14979 static const std::size_t voidsizem1 = voidsize - 1;
14980 static const std::size_t data_t_count = (
sizeof(
TValue) + voidsizem1) / voidsize;
14981 typedef std::array<void*, data_t_count> data_t;
14983 data_t data { {} };
14984 std::memcpy(&data[0], std::addressof(item), itemsize);
14986 for (
const auto& v : data) {
14993 template <
typename T>
14995 static const std::size_t data_t_count = (
sizeof(T) + (
sizeof(
void*) - 1)) /
sizeof(
void*);
14996 typedef std::array<void*, data_t_count> data_t;
14997 data_t voiddata { {} };
14998 for (std::size_t i = 0,
d = 0;
d <
sizeof(T); ++i,
d +=
sizeof(
void*)) {
15001 return std::pair<T, int>(*
reinterpret_cast<T*
>(
static_cast<void*
>(voiddata.data())),
index);
15004 template <
typename T>
15006 static const std::size_t data_t_count = (
sizeof(T) + (
sizeof(
void*) - 1)) /
sizeof(
void*);
15007 typedef std::array<void*, data_t_count> data_t;
15010 data_t voiddata { {} };
15011 for (std::size_t
d = 0;
d <
sizeof(T);
d +=
sizeof(
void*)) {
15014 const char* upvalue_name =
lua_getupvalue(L, function_index, index + 2);
15015 if (upvalue_name ==
nullptr) {
15023 return std::pair<T, int>(*
reinterpret_cast<T*
>(
static_cast<void*
>(voiddata.data())),
index);
15026 template <
typename Fx,
typename... Args>
15028 return std::forward<Fx>(fx)(std::forward<Args>(args)...);
15031 template <
typename Fx,
typename Arg,
typename... Args, std::size_t I, std::size_t... Is,
typename... FxArgs>
15033 types<Arg, Args...>,
std::index_sequence<I, Is...>,
lua_State* L,
int start,
record& tracking, Fx&& fx, FxArgs&&... fxargs) {
15035 std::index_sequence<Is...>(),
15039 std::forward<Fx>(fx),
15040 std::forward<FxArgs>(fxargs)...,
15041 stack_detail::unchecked_get<Arg>(L, start + tracking.used, tracking));
15047 "One of the arguments being bound is a move-only type, and it is not being taken by reference: this will break your code. Please take " 15048 "a reference and std::move it manually if this was your intention.");
15049 if constexpr (checkargs) {
15054 if constexpr (std::is_void_v<R>) {
15055 eval(ta, tai, L, start, tracking, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
15058 return eval(ta, tai, L, start, tracking, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
15063 template <
typename T>
15065 push(L, std::forward<T>(
arg));
15071 using args_indices = std::make_index_sequence<
sizeof...(Args)>;
15072 if constexpr (std::is_void_v<R>) {
15073 stack_detail::call<check_args>(tr, ta, args_indices(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
15076 return stack_detail::call<check_args>(tr, ta, args_indices(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
15082 if constexpr (std::is_void_v<R>) {
15083 call<check_args>(tr, ta, L, 1, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
15086 return call<check_args>(tr, ta, L, 1, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
15093 if constexpr (std::is_void_v<R>) {
15094 call<check_args>(tr,
15098 std::forward<Fx>(fx),
15099 std::forward<FxArgs>(args)...);
15102 return call<check_args>(tr,
15106 std::forward<Fx>(fx),
15107 std::forward<FxArgs>(args)...);
15112 typename Fx,
typename... FxArgs>
15114 if constexpr (std::is_void_v<Ret0>) {
15115 call<check_args>(tr, ta, L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
15116 if constexpr (clean_stack) {
15124 = call<check_args>(
types<
meta::return_type_t<Ret0, Ret...>>(), ta, L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
15126 using is_stack =
meta::any<is_stack_based<R>, std::is_same<R, absolute_index>, std::is_same<R, ref_index>, std::is_same<R, raw_index>>;
15137 using args_list =
typename traits_type::args_list;
15138 using returns_list =
typename traits_type::returns_list;
15139 return call_into_lua<check_args, clean_stack>(returns_list(), args_list(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
15147 auto pn =
pop_n(L, 1);
15180 #if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_) 15181 if (L ==
nullptr) {
15184 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 15186 #endif // make sure stack doesn't overflow 15188 auto pn =
pop_n(L, 1);
15189 luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_ON);
15197 #if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_) 15198 if (L ==
nullptr) {
15201 luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_OFF);
15217 template <
typename R = reference,
bool should_pop = !is_stack_based_v<R>,
typename T>
15220 R r = stack::get<R>(L, -backpedal);
15227 template <
typename T,
typename R = reference,
bool should_pop = !is_stack_based_v<R>,
typename... Args>
15229 int backpedal = stack::push<T>(L, std::forward<Args>(args)...);
15230 R r = stack::get<R>(L, -backpedal);
15237 template <
typename R = reference,
bool should_pop = !is_stack_based_v<R>,
typename T>
15240 R r = stack::get<R>(L, -backpedal);
15247 template <
typename T,
typename R = reference,
bool should_pop = !is_stack_based_v<R>,
typename... Args>
15249 int backpedal = stack::push_userdata<T>(L, std::forward<Args>(args)...);
15250 R r = stack::get<R>(L, -backpedal);
15265 template <
typename ref_t>
15270 template <
typename T>
15271 decltype(
auto) as_stack(
std::true_type)
const {
15272 return stack::get<T>(base_t::lua_state(), base_t::stack_index());
15275 template <
typename T>
15276 decltype(
auto) as_stack(
std::false_type)
const {
15278 return stack::pop<T>(base_t::lua_state());
15281 template <
typename T>
15283 return stack::check<T>(base_t::lua_state(), base_t::stack_index(),
no_panic);
15286 template <
typename T>
15288 int r = base_t::registry_index();
15294 return stack::check<T>(base_t::lua_state(), -1,
no_panic);
15308 template <
typename T>
15309 decltype(
auto) as()
const {
15313 template <
typename T>
15324 template <
typename base_type>
15329 template <
bool invert_and_pop = false>
15331 : base_t(L, index) {
15332 if (invert_and_pop) {
15346 template <
typename T,
15352 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
15357 basic_object() noexcept =
default;
15358 template <
typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_
object>>, meta::neg<std::is_same<base_type, stack_reference>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
15360 : base_t(
std::forward<T>(r)) {
15362 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
15364 : base_t(L,
std::forward<T>(r)) {
15369 basic_object(
const basic_object&) =
default;
15370 basic_object(basic_object&&) =
default;
15372 : basic_object(r.lua_state(), r.stack_index()) {
15375 : basic_object(r.lua_state(), r.stack_index()) {
15377 template <
typename Super>
15379 : basic_object(r.operator basic_object()) {
15381 template <
typename Super>
15383 : basic_object(r.operator basic_object()) {
15389 : base_t(L, index) {
15392 : base_t(L, index) {
15395 : base_t(L, index) {
15398 : base_t(L, index) {
15400 template <
typename T,
typename... Args>
15402 : basic_object(
std::integral_constant<
bool, !
is_stack_based<base_t>::value>(), L, -stack::
push<T>(L,
std::forward<Args>(args)...)) {
15404 template <
typename T,
typename... Args>
15408 basic_object& operator=(
const basic_object&) =
default;
15409 basic_object& operator=(basic_object&&) =
default;
15411 base_t::operator=(b);
15418 template <
typename Super>
15420 this->operator=(r.operator basic_object());
15423 template <
typename Super>
15425 this->operator=(r.operator basic_object());
15430 template <
typename T>
15432 return make_reference<object, true>(L, std::forward<T>(
value));
15435 template <
typename T,
typename... Args>
15437 return make_reference<T, object, true>(L, std::forward<Args>(args)...);
15440 template <
typename T>
15442 return make_reference_userdata<object, true>(L, std::forward<T>(
value));
15445 template <
typename T,
typename... Args>
15447 return make_reference_userdata<T, object, true>(L, std::forward<Args>(args)...);
15467 template <
typename T>
15472 template <
typename Super>
15475 const Super& super = *
static_cast<const Super*
>(
static_cast<const void*
>(
this));
15476 return super.template get<std::string>();
15479 template <
typename T, meta::enable<meta::neg<meta::is_
string_constructible<T>>, is_proxy_primitive<meta::unqualified_t<T>>> = meta::enabler>
15480 operator T()
const {
15481 const Super& super = *
static_cast<const Super*
>(
static_cast<const void*
>(
this));
15482 return super.template get<T>();
15485 template <
typename T, meta::enable<meta::neg<meta::is_
string_constructible<T>>, meta::neg<is_proxy_primitive<meta::unqualified_t<T>>>> = meta::enabler>
15486 operator T&()
const {
15487 const Super& super = *
static_cast<const Super*
>(
static_cast<const void*
>(
this));
15488 return super.template get<T&>();
15492 const Super& super = *
static_cast<const Super*
>(
static_cast<const void*
>(
this));
15493 return super.lua_state();
15503 #include <iterator> 15506 template <
typename proxy_t,
bool is_const>
15519 : L(
nullptr), index((
std::numeric_limits<int>::
max)()), stacktop((
std::numeric_limits<int>::
max)()), sp() {
15522 : L(r.L), index(r.index), stacktop(r.stacktop), sp(r.sp) {
15525 : L(luastate), index(idx), stacktop(topidx), sp(luastate, idx) {
15529 return proxy_t(L, index);
15533 return proxy_t(L, index);
15537 sp = proxy_t(L, index);
15542 const_cast<proxy_t&
>(sp) = proxy_t(L, index);
15553 this->operator++();
15564 this->operator--();
15569 index +=
static_cast<int>(idx);
15574 index -=
static_cast<int>(idx);
15579 return index - r.
index;
15589 return proxy_t(L, index + static_cast<int>(idx));
15597 return index == stacktop;
15599 return index == r.
index;
15607 return index < r.
index;
15611 return index > r.
index;
15615 return index <= r.
index;
15619 return index >= r.
index;
15623 template <
typename proxy_t,
bool is_const>
15646 : L(L), index(index) {
15649 template <
typename T>
15651 return stack::get<T>(L, stack_index());
15654 template <
typename T>
15656 return stack::check<T>(L, stack_index());
15659 template <
typename T>
15660 decltype(
auto) as()
const {
15665 return type_of(lua_state(), stack_index());
15713 template <
typename... Ret,
typename... Args>
15714 decltype(
auto)
call(Args&&... args);
15716 template <
typename... Args>
15717 decltype(
auto) operator()(Args&&... args) {
15718 return call<>(std::forward<Args>(args)...);
15766 : L(Ls), index(idx), returncount(retnum), popcount(popped), err(pferr) {
15777 : L(o.L), index(o.index), returncount(o.returncount), popcount(o.popcount), err(o.err) {
15786 returncount = o.returncount;
15787 popcount = o.popcount;
15809 template <
typename T>
15810 decltype(
auto)
get(
int index_offset = 0)
const {
15812 int target = index + index_offset;
15813 if constexpr (meta::is_optional_v<UT>) {
15814 using ValueType =
typename UT::value_type;
15815 if constexpr (std::is_same_v<ValueType, error>) {
15825 return stack::get<UT>(L, target);
15829 if constexpr (std::is_same_v<T, error>) {
15830 #if SOL_IS_ON(SOL_SAFE_PROXIES_I_) 15835 #endif // Check Argument Safety 15839 #if SOL_IS_ON(SOL_SAFE_PROXIES_I_) 15844 #endif // Check Argument Safety 15845 return stack::get<T>(L, target);
15851 return type_of(L, index + static_cast<int>(index_offset));
15855 return stack_proxy(L, index + static_cast<int>(index_offset));
15859 return iterator(L, index, stack_index() + return_count());
15862 return iterator(L, stack_index() + return_count(), stack_index() + return_count());
15865 return const_iterator(L, index, stack_index() + return_count());
15868 return const_iterator(L, stack_index() + return_count(), stack_index() + return_count());
15878 return std::reverse_iterator<iterator>(begin());
15881 return std::reverse_iterator<iterator>(end());
15884 return std::reverse_iterator<const_iterator>(begin());
15887 return std::reverse_iterator<const_iterator>(end());
15890 return std::reverse_iterator<const_iterator>(cbegin());
15893 return std::reverse_iterator<const_iterator>(cend());
15903 return returncount;
15924 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 15926 #endif // make sure stack doesn't overflow 15928 for (
int i = 0; i < pfr.
pop_count(); ++i) {
15982 returncount = o.returncount;
15995 template <
typename T>
15996 decltype(
auto)
get(difference_type index_offset = 0)
const {
15997 return stack::get<T>(L, index +
static_cast<int>(index_offset));
16000 type
get_type(difference_type index_offset = 0) const noexcept {
16001 return type_of(L, index + static_cast<int>(index_offset));
16005 return stack_proxy(L, index + static_cast<int>(index_offset));
16009 return iterator(L, index, stack_index() + return_count());
16012 return iterator(L, stack_index() + return_count(), stack_index() + return_count());
16015 return const_iterator(L, index, stack_index() + return_count());
16018 return const_iterator(L, stack_index() + return_count(), stack_index() + return_count());
16028 return std::reverse_iterator<iterator>(begin());
16031 return std::reverse_iterator<iterator>(end());
16034 return std::reverse_iterator<const_iterator>(begin());
16037 return std::reverse_iterator<const_iterator>(end());
16040 return std::reverse_iterator<const_iterator>(cbegin());
16043 return std::reverse_iterator<const_iterator>(cend());
16061 return returncount;
16100 template <std::size_t I,
typename... Args,
typename T>
16102 return stack_proxy(fr.lua_state(),
static_cast<int>(fr.stack_index() + I));
16117 template <std::
size_t I>
16119 return stack_proxy(fr.lua_state(),
static_cast<int>(fr.stack_index() + I));
16122 template <std::size_t I,
typename... Args>
16127 template <std::
size_t I>
16129 return stack_proxy(fr.lua_state(),
static_cast<int>(fr.stack_index() + I));
16132 template <std::size_t I,
typename... Args>
16149 template <
typename T>
16153 template <
typename F,
typename =
void>
16160 template <
typename... Args>
16161 static decltype(
auto)
call(F& f, Args&&... args) {
16162 return f(std::forward<Args>(args)...);
16166 template <
typename... Args>
16167 decltype(
auto) operator()(F& fx, Args&&... args)
const {
16168 return call(fx, std::forward<Args>(args)...);
16173 template <
typename F>
16180 template <F fx,
typename... Args>
16182 return fx(std::forward<Args>(args)...);
16185 template <
typename... Args>
16186 static decltype(
auto)
call(F& fx, Args&&... args) {
16187 return fx(std::forward<Args>(args)...);
16191 template <
typename... Args>
16192 decltype(
auto) operator()(F& fx, Args&&... args)
const {
16193 return call(fx, std::forward<Args>(args)...);
16199 template <
typename... Args>
16200 decltype(
auto) operator()(Args&&... args)
const {
16201 return invoke<fx>(std::forward<Args>(args)...);
16206 template <
typename F>
16220 template <F fx,
typename Arg,
typename... Args>
16221 static decltype(
auto)
invoke(object_type& mem, Arg&&
arg, Args&&...) {
16222 return mem.*fx = std::forward<Arg>(
arg);
16225 template <
typename Fx>
16230 template <
typename Fx,
typename Arg,
typename... Args>
16231 static void call(Fx&& fx, object_type& mem, Arg&&
arg, Args&&...) {
16233 if constexpr (std::is_array_v<actual_type>) {
16236 auto first = cbegin(
arg);
16237 auto last = cend(
arg);
16238 for (std::size_t i = 0; first != last; ++i, ++first) {
16239 (mem.*fx)[i] = *first;
16243 (mem.*fx) = std::forward<Arg>(
arg);
16248 template <
typename Fx,
typename... Args>
16249 decltype(
auto) operator()(Fx&& fx, object_type& mem, Args&&... args)
const {
16250 return call(std::forward<Fx>(fx), mem, std::forward<Args>(args)...);
16256 template <
typename... Args>
16257 decltype(
auto) operator()(Args&&... args)
const {
16258 return invoke<fx>(std::forward<Args>(args)...);
16263 template <
typename F,
typename R,
typename O,
typename... FArgs>
16271 template <F fx,
typename... Args>
16273 return (mem.*fx)(std::forward<Args>(args)...);
16276 template <
typename Fx,
typename... Args>
16277 static R
call(Fx&& fx, O& mem, Args&&... args) {
16278 return (mem.*fx)(std::forward<Args>(args)...);
16282 template <
typename Fx,
typename... Args>
16283 decltype(
auto) operator()(Fx&& fx, O& mem, Args&&... args)
const {
16284 return call(std::forward<Fx>(fx), mem, std::forward<Args>(args)...);
16290 template <
typename... Args>
16291 decltype(
auto) operator()(O& mem, Args&&... args)
const {
16292 return invoke<fx>(mem, std::forward<Args>(args)...);
16297 template <
typename R,
typename O,
typename... Args>
16300 template <
typename R,
typename O,
typename... Args>
16303 template <
typename R,
typename O,
typename... Args>
16306 template <
typename R,
typename O,
typename... Args>
16309 template <
typename R,
typename O,
typename... Args>
16312 template <
typename R,
typename O,
typename... Args>
16315 template <
typename R,
typename O,
typename... Args>
16318 template <
typename R,
typename O,
typename... Args>
16321 template <
typename R,
typename O,
typename... Args>
16324 template <
typename R,
typename O,
typename... Args>
16327 template <
typename R,
typename O,
typename... Args>
16330 template <
typename R,
typename O,
typename... Args>
16333 template <
typename R,
typename O,
typename... Args>
16336 template <
typename R,
typename O,
typename... Args>
16339 template <
typename R,
typename O,
typename... Args>
16342 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) 16345 template <
typename R,
typename O,
typename... Args>
16348 template <
typename R,
typename O,
typename... Args>
16351 template <
typename R,
typename O,
typename... Args>
16354 template <
typename R,
typename O,
typename... Args>
16357 template <
typename R,
typename O,
typename... Args>
16360 template <
typename R,
typename O,
typename... Args>
16363 template <
typename R,
typename O,
typename... Args>
16366 template <
typename R,
typename O,
typename... Args>
16369 template <
typename R,
typename O,
typename... Args>
16370 struct wrapper<R (O::*)(Args..., ...) const volatile& noexcept>
16373 template <
typename R,
typename O,
typename... Args>
16376 template <
typename R,
typename O,
typename... Args>
16379 template <
typename R,
typename O,
typename... Args>
16382 template <
typename R,
typename O,
typename... Args>
16385 template <
typename R,
typename O,
typename... Args>
16388 template <
typename R,
typename O,
typename... Args>
16389 struct wrapper<R (O::*)(Args..., ...) const volatile&& noexcept>
16392 #endif // noexcept is part of a function's type 16401 namespace function_detail {
16402 template <
typename Fx,
int start = 1,
bool is_yielding = false>
16424 #include <type_traits> 16432 template <
typename R,
typename W>
16439 template <
typename Rx,
typename Wx>
16461 template <
typename F,
typename G>
16465 if constexpr (left_traits::free_arity < right_traits::free_arity) {
16473 template <
typename F>
16476 if constexpr (left_traits::free_arity < 2) {
16484 template <
typename F>
16489 template <
typename F>
16494 template <
typename T>
16500 using base_t::base_t;
16505 operator const T&()
const {
16511 template <
typename R,
typename T>
16516 template <
typename T>
16522 using base_t::base_t;
16525 template <
typename V>
16527 typedef std::decay_t<V> T;
16532 template <
typename T>
16535 template <
typename T>
16538 template <
typename T>
16552 template <
typename T>
16558 : value(
std::forward<Arg>(
arg),
std::forward<Args>(args)...) {
16567 template <
typename T>
16577 namespace u_detail {
16581 namespace policy_detail {
16582 template <
int I,
int... In>
16584 if constexpr (
sizeof...(In) == 0) {
16595 auto per_dep = [&L, &deps](
int i) {
16596 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 16598 #endif // make sure stack doesn't overflow 16608 template <
int... In>
16621 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 16623 #endif // make sure stack doesn't overflow 16624 for (std::size_t i = 0; i < sdeps.
size(); ++i) {
16631 template <
typename P, meta::disable<std::is_base_of<detail::policy_base_tag, meta::unqualified_t<P>>> = meta::enabler>
16633 pushed = std::forward<P>(p)(L, pushed);
16637 namespace function_detail {
16639 return luaL_error(L,
"sol: cannot call this constructor (tagged as non-constructible)");
16643 namespace call_detail {
16645 template <
typename R,
typename W>
16650 template <
typename R,
typename W>
16655 template <
typename T,
typename List>
16658 template <
typename T,
typename... Args>
16664 template <
typename T,
bool checked,
bool clean_stack>
16671 template <
typename Fx, std::size_t I,
typename... R,
typename... Args>
16674 return stack::call_into_lua<checked, clean_stack>(r, a, L, start, func, obj_);
16678 namespace overload_detail {
16679 template <std::size_t... M,
typename Match,
typename... Args>
16681 return luaL_error(L,
"sol: no matching function call takes this number of arguments and the specified types");
16684 template <
typename Fx,
typename... Fxs, std::size_t I, std::size_t... In, std::size_t... M,
typename Match,
typename... Args>
16686 int fxarity,
int start, Args&&... args) {
16689 typedef typename traits::free_args_list args_list;
16694 std::index_sequence<In...>(),
16695 std::index_sequence<M...>(),
16696 std::forward<Match>(matchfx),
16700 std::forward<Args>(args)...);
16704 if (traits::free_arity != fxarity) {
16706 std::index_sequence<In...>(),
16707 std::index_sequence<traits::free_arity, M...>(),
16708 std::forward<Match>(matchfx),
16712 std::forward<Args>(args)...);
16718 std::index_sequence<In...>(),
16719 std::index_sequence<M...>(),
16720 std::forward<Match>(matchfx),
16724 std::forward<Args>(args)...);
16730 template <std::size_t... M,
typename Match,
typename... Args>
16732 types<>, std::index_sequence<>, std::index_sequence<M...>, Match&& matchfx,
lua_State* L,
int fxarity,
int start, Args&&... args) {
16734 std::index_sequence<>(),
16735 std::index_sequence<M...>(),
16736 std::forward<Match>(matchfx),
16740 std::forward<Args>(args)...);
16743 template <
typename Fx, std::size_t I, std::size_t... M,
typename Match,
typename... Args>
16745 types<Fx>, std::index_sequence<I>, std::index_sequence<M...>, Match&& matchfx,
lua_State* L,
int fxarity,
int start, Args&&... args) {
16748 typedef typename traits::free_args_list args_list;
16753 std::index_sequence<>(),
16754 std::index_sequence<M...>(),
16755 std::forward<Match>(matchfx),
16759 std::forward<Args>(args)...);
16762 if (traits::free_arity != fxarity) {
16764 std::index_sequence<>(),
16765 std::index_sequence<traits::free_arity, M...>(),
16766 std::forward<Match>(matchfx),
16770 std::forward<Args>(args)...);
16776 template <
typename Fx,
typename Fx1,
typename... Fxs, std::size_t I, std::size_t I1, std::size_t... In, std::size_t... M,
typename Match,
16779 lua_State* L,
int fxarity,
int start, Args&&... args) {
16782 typedef typename traits::free_args_list args_list;
16787 std::index_sequence<I1, In...>(),
16788 std::index_sequence<M...>(),
16789 std::forward<Match>(matchfx),
16793 std::forward<Args>(args)...);
16797 if (traits::free_arity != fxarity) {
16799 std::index_sequence<I1, In...>(),
16800 std::index_sequence<traits::free_arity, M...>(),
16801 std::forward<Match>(matchfx),
16805 std::forward<Args>(args)...);
16811 std::index_sequence<I1, In...>(),
16812 std::index_sequence<M...>(),
16813 std::forward<Match>(matchfx),
16817 std::forward<Args>(args)...);
16824 template <
typename... Functions,
typename Match,
typename... Args>
16827 std::make_index_sequence<
sizeof...(Functions)>(),
16828 std::index_sequence<>(),
16829 std::forward<Match>(matchfx),
16833 std::forward<Args>(args)...);
16836 template <
typename... Functions,
typename Match,
typename... Args>
16839 return overload_match_arity<Functions...>(std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
16842 template <
typename T,
typename... TypeLists,
typename Match,
typename... Args>
16846 std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
16849 template <
typename T,
bool checked,
bool clean_stack,
typename... TypeLists>
16854 argcount -=
static_cast<int>(
syntax);
16856 T* obj = detail::usertype_allocate<T>(L);
16865 userdataref.push();
16869 template <
typename T,
bool checked,
bool clean_stack,
typename... TypeLists>
16874 template <
typename F,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename =
void>
16876 template <
typename Fx,
typename... Args>
16879 static constexpr
bool is_ref = is_lua_reference_v<uFx>;
16880 if constexpr (is_ref) {
16881 if constexpr (is_index) {
16882 return stack::push(L, std::forward<Fx>(f), std::forward<Args>(args)...);
16885 std::forward<Fx>(f) = stack::unqualified_get<F>(L, boost + (is_variable ? 3 : 1));
16891 using traits_type =
typename wrap::traits_type;
16892 using fp_t =
typename traits_type::function_pointer_type;
16893 constexpr
bool is_function_pointer_convertible
16894 = std::is_class_v<uFx> && std::is_convertible_v<std::decay_t<Fx>, fp_t>;
16895 if constexpr (is_function_pointer_convertible) {
16898 L, fx, std::forward<Args>(args)...);
16901 using returns_list =
typename wrap::returns_list;
16902 using args_list =
typename wrap::free_args_list;
16903 using caller =
typename wrap::caller;
16904 return stack::call_into_lua<checked, clean_stack>(
16905 returns_list(), args_list(), L, boost + 1, caller(), std::forward<Fx>(f), std::forward<Args>(args)...);
16911 template <
typename T,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
16913 template <
typename F>
16915 if constexpr (is_index) {
16917 if constexpr (clean_stack && !is_stack) {
16925 return luaL_error(L,
"sol: cannot write to a readonly (const) variable");
16937 return luaL_error(L,
"sol: cannot write to this variable: copy assignment/constructor not available");
16944 template <
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
16951 template <
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
16958 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) 16959 template <
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
16965 #endif // noexcept function types 16967 template <
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
16970 return luaL_error(L, is_index ?
"sol: cannot read from a writeonly property" :
"sol: cannot write to a readonly property");
16974 template <
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
16981 template <
typename... Args,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
16989 template <
typename T,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
16993 return alcw.
call(L, f.get());
16998 bool clean_stack =
true,
typename =
void>
17000 template <
typename Fx,
typename... Args>
17002 if constexpr (std::is_member_function_pointer_v<F>) {
17004 using object_type =
typename wrap::object_type;
17005 if constexpr (
sizeof...(Args) < 1) {
17007 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!");
17008 #if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) 17009 auto maybeo = stack::check_get<Ta*>(L, 1);
17010 if (!maybeo || maybeo.value() ==
nullptr) {
17012 "sol: received nil for 'self' argument (use ':' for accessing member functions, make sure member variables are " 17013 "preceeded by the " 17014 "actual object with '.' syntax)");
17016 object_type* o =
static_cast<object_type*
>(maybeo.value());
17017 return call(L, std::forward<Fx>(fx), *o);
17019 object_type& o =
static_cast<object_type&
>(*stack::unqualified_get<non_null<Ta*>>(L, 1));
17020 return call(L, std::forward<Fx>(fx), o);
17024 using returns_list =
typename wrap::returns_list;
17025 using args_list =
typename wrap::args_list;
17026 using caller =
typename wrap::caller;
17027 return stack::call_into_lua<checked, clean_stack>(
17028 returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), std::forward<Fx>(fx), std::forward<Args>(args)...);
17031 else if constexpr (std::is_member_object_pointer_v<F>) {
17033 using object_type =
typename wrap::object_type;
17034 if constexpr (is_index) {
17035 if constexpr (
sizeof...(Args) < 1) {
17037 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!");
17038 #if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) 17039 auto maybeo = stack::check_get<Ta*>(L, 1);
17040 if (!maybeo || maybeo.value() ==
nullptr) {
17042 return luaL_error(L,
"sol: 'self' argument is lua_nil (bad '.' access?)");
17044 return luaL_error(L,
"sol: 'self' argument is lua_nil (pass 'self' as first argument)");
17046 object_type* o =
static_cast<object_type*
>(maybeo.value());
17047 return call(L, std::forward<Fx>(fx), *o);
17049 object_type& o =
static_cast<object_type&
>(*stack::get<non_null<Ta*>>(L, 1));
17050 return call(L, std::forward<Fx>(fx), o);
17054 using returns_list =
typename wrap::returns_list;
17055 using caller =
typename wrap::caller;
17056 return stack::call_into_lua<checked, clean_stack>(returns_list(),
17059 boost + (is_variable ? 3 : 2),
17061 std::forward<Fx>(fx),
17062 std::forward<Args>(args)...);
17067 using return_type =
typename traits_type::return_type;
17068 constexpr
bool ret_is_const = std::is_const_v<std::remove_reference_t<return_type>>;
17069 if constexpr (ret_is_const) {
17072 return luaL_error(L,
"sol: cannot write to a readonly (const) variable");
17076 constexpr
bool is_assignable = std::is_copy_assignable_v<u_return_type> || std::is_array_v<u_return_type>;
17077 if constexpr (!is_assignable) {
17080 return luaL_error(L,
"sol: cannot write to this variable: copy assignment/constructor not available");
17083 using args_list =
typename wrap::args_list;
17084 using caller =
typename wrap::caller;
17085 if constexpr (
sizeof...(Args) > 0) {
17086 return stack::call_into_lua<checked, clean_stack>(
types<void>(),
17089 boost + (is_variable ? 3 : 2),
17091 std::forward<Fx>(fx),
17092 std::forward<Args>(args)...);
17096 #if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) 17097 auto maybeo = stack::check_get<Ta*>(L, 1);
17098 if (!maybeo || maybeo.value() ==
nullptr) {
17100 return luaL_error(L,
"sol: received nil for 'self' argument (bad '.' access?)");
17102 return luaL_error(L,
"sol: received nil for 'self' argument (pass 'self' as first argument)");
17104 object_type* po =
static_cast<object_type*
>(maybeo.value());
17105 object_type& o = *po;
17107 object_type& o =
static_cast<object_type&
>(*stack::get<non_null<Ta*>>(L, 1));
17110 return stack::call_into_lua<checked, clean_stack>(
17111 types<void>(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), std::forward<Fx>(fx), o);
17119 return alcw.
call(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
17124 template <
typename T,
typename F,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17131 if constexpr (!is_index) {
17133 return luaL_error(L,
"sol: cannot write to a sol::readonly variable");
17142 if constexpr (!is_index) {
17148 return lcw.
call(L, rw.value(), o);
17153 if constexpr (!is_index) {
17155 return luaL_error(L,
"sol: cannot write to a sol::readonly variable");
17164 if constexpr (!is_index) {
17166 return call(L, rw);
17175 template <
typename T,
typename... Args,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17183 argcount -=
static_cast<int>(
syntax);
17185 T* obj = detail::usertype_allocate<T>(L);
17194 userdataref.push();
17199 template <
typename T,
typename... Cxs,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17204 template <
typename Fx, std::size_t I,
typename... R,
typename... Args>
17207 T* obj = detail::usertype_allocate<T>(L);
17217 userdataref.push();
17224 int syntaxval =
static_cast<int>(
syntax);
17226 return construct_match<T, meta::pop_front_type_t<meta::function_args_t<Cxs>>...>(onmatch(), L, argcount, 1 + syntaxval, f);
17230 template <
typename T,
typename Fx,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17233 template <
typename F>
17235 if constexpr (std::is_void_v<Fx>) {
17236 return detail::usertype_alloc_destruct<T>(L);
17241 return lcw.
call(L, std::forward<F>(f).fx);
17246 template <
typename T,
typename... Fs,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17251 template <
typename Fx, std::size_t I,
typename... R,
typename... Args>
17263 template <
typename T,
typename... Fs,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17268 template <
typename Fx, std::size_t I,
typename... R,
typename... Args>
17280 template <
typename T,
typename R,
typename W,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17288 template <
typename F,
typename... Args>
17294 std::is_member_pointer<U>>::value;
17295 if constexpr (is_specialized) {
17296 if constexpr (is_index) {
17297 decltype(
auto) p = f.read();
17299 return lcw.
call(L, p, std::forward<Args>(args)...);
17302 decltype(
auto) p = f.write();
17304 return lcw.
call(L, p, std::forward<Args>(args)...);
17310 if constexpr (non_class_object_type) {
17315 if constexpr (is_index) {
17316 decltype(
auto)
pf = f.read();
17317 return stack::call_into_lua<checked, clean_stack>(
17318 returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(),
pf);
17321 decltype(
auto)
pf = f.write();
17322 return stack::call_into_lua<checked, clean_stack>(
17323 returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(),
pf);
17329 using Oa = std::remove_pointer_t<object_type>;
17330 #if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) 17331 auto maybeo = stack::check_get<Ta*>(L, 1);
17332 if (!maybeo || maybeo.value() ==
nullptr) {
17334 return luaL_error(L,
"sol: 'self' argument is lua_nil (bad '.' access?)");
17336 return luaL_error(L,
"sol: 'self' argument is lua_nil (pass 'self' as first argument)");
17338 Oa* o =
static_cast<Oa*
>(maybeo.value());
17340 Oa* o =
static_cast<Oa*
>(stack::get<non_null<Ta*>>(L, 1));
17344 if constexpr (is_index) {
17345 decltype(
auto)
pf = f.read();
17346 return stack::call_into_lua<checked, clean_stack>(
17350 decltype(
auto)
pf = f.write();
17351 return stack::call_into_lua<checked, clean_stack>(
17359 template <
typename T,
typename V,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17363 template <
typename... Args>
17369 template <
typename T,
typename F,
typename... Policies,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17373 template <std::size_t... In>
17386 template <
typename T,
typename Y,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17388 template <
typename F>
17394 template <
typename T,
typename Sig,
typename P,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
17408 typename Fx,
typename... Args>
17411 if constexpr (meta::is_specialization_of_v<uFx, yielding_t>) {
17414 return lcw.
call(L, std::forward<Fx>(fx).func, std::forward<Args>(args)...);
17418 return lcw.
call(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
17423 bool clean_stack =
true>
17425 auto& fx = stack::unqualified_get<user<F>>(L,
upvalue_index(start));
17427 int nr = call_wrapped<T, is_index, is_variable, 0, checked, clean_stack>(L, fx);
17428 if constexpr (meta::is_specialization_of_v<uFx, yielding_t>) {
17436 template <
typename T,
typename =
void>
17439 template <
typename T>
17442 template <
typename T>
17448 template <
typename R,
typename W>
17451 template <
typename T>
17454 template <
typename T>
17457 template <
typename F,
typename... Policies>
17461 template <
typename T>
17464 template <
typename T>
17467 template <
typename T>
17475 namespace function_detail {
17476 template <
typename F, F fx>
17479 typedef typename traits_type::args_list args_list;
17484 template <
typename R,
typename V, V,
typename T>
17486 return luaL_error(L,
"cannot write to this type: copy assignment/constructor not available");
17489 template <
typename R,
typename V, V variable,
typename T>
17491 (mem.*variable) = stack::get<R>(L, 2);
17495 template <
typename R,
typename V, V,
typename T>
17497 return luaL_error(L,
"cannot write to a const variable");
17500 template <
typename R,
typename V, V variable,
typename T>
17502 return call_set_assignable<R, V, variable>(std::is_assignable<std::add_lvalue_reference_t<R>, R>(), L, std::forward<T>(mem));
17505 template <
typename V, V variable>
17508 typedef typename traits_type::object_type T;
17509 typedef typename traits_type::return_type R;
17510 auto& mem = stack::get<T>(L, 1);
17513 decltype(
auto) r = (mem.*variable);
17520 return luaL_error(L,
"incorrect number of arguments to member variable function call");
17524 template <
typename F, F fx>
17526 return call_wrapper_variable<F, fx>(std::is_member_object_pointer<F>(), L);
17529 template <
typename F, F fx>
17531 return call_detail::call_wrapped<void, false, false>(L, fx);
17534 template <
typename F, F fx>
17536 return call_wrapper_function<F, fx>(std::is_member_function_pointer<meta::unqualified_t<F>>(), L);
17539 template <
typename... Fxs>
17541 template <
typename Fx, std::size_t I,
typename R,
typename... Args>
17548 template <
typename F, F fx>
17553 template <
typename F, F fx>
17558 return detail::typed_static_trampoline<decltype(&function_detail::call_wrapper_entry<F, fx>), (&function_detail::call_wrapper_entry<F, fx>)>(L);
17559 #endif // fuck you clang :c 17564 template <
typename F, F fx>
17567 typedef std::integral_constant<
bool,
17569 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) 17574 return function_detail::c_call_raw<F, fx>(is_raw(), L);
17577 template <
typename F, F f>
17582 return c_call<type, f>(L);
17586 template <
typename... Fxs>
17588 if constexpr (
sizeof...(Fxs) < 2) {
17603 namespace sol {
namespace function_detail {
17604 template <
typename Function,
bool is_yielding>
17610 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) 17613 noexcept(traits_type::is_noexcept)
17616 auto udata = stack::stack_detail::get_as_upvalues<function_type*>(L);
17618 return call_detail::call_wrapped<void, true, false>(L, fx);
17622 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
17636 template <
typename T,
typename Function,
bool is_yielding>
17642 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) 17645 noexcept(traits_type::is_noexcept)
17653 function_type& memfx = stack::get<user<function_type>>(L,
upvalue_index(2));
17654 auto& item = *
static_cast<T*
>(stack::get<void*>(L,
upvalue_index(3)));
17659 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) 17662 noexcept(traits_type::is_noexcept)
17665 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
17679 template <
typename T,
typename Function,
bool is_yielding>
17685 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) 17688 noexcept(traits_type::is_noexcept)
17696 auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
17697 auto objdata = stack::stack_detail::get_as_upvalues<T*>(L, memberdata.second);
17698 auto& mem = *objdata.first;
17699 function_type&
var = memberdata.first;
17706 return luaL_error(L,
"sol: incorrect number of arguments to member variable function");
17711 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) 17714 noexcept(traits_type::is_noexcept)
17717 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
17731 template <
typename T,
typename Function,
bool is_yielding>
17737 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) 17740 noexcept(traits_type::is_noexcept)
17748 auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
17749 auto objdata = stack::stack_detail::get_as_upvalues<T*>(L, memberdata.second);
17750 auto& mem = *objdata.first;
17751 function_type&
var = memberdata.first;
17756 return luaL_error(L,
"sol: incorrect number of arguments to member variable function");
17761 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) 17764 noexcept(traits_type::is_noexcept)
17767 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
17781 template <
typename T,
typename Function,
bool is_yielding>
17787 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) 17790 noexcept(traits_type::is_noexcept)
17795 function_type& memfx = stack::get<user<function_type>>(L,
upvalue_index(2));
17796 return call_detail::call_wrapped<T, false, false>(L, memfx);
17800 #if SOL_IS_ON(SOL_COMPILER_VCXX_I_) 17803 noexcept(traits_type::is_noexcept)
17806 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
17820 template <
typename T,
typename Function,
bool is_yielding>
17827 auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
17828 function_type&
var = memberdata.first;
17831 return call_detail::call_wrapped<T, true, false>(L,
var);
17833 return call_detail::call_wrapped<T, false, false>(L,
var);
17835 return luaL_error(L,
"sol: incorrect number of arguments to member variable function");
17840 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
17854 template <
typename T,
typename Function,
bool is_yielding>
17862 auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
17863 function_type&
var = memberdata.first;
17866 return call_detail::call_wrapped<T, true, false>(L,
var);
17868 return luaL_error(L,
"sol: incorrect number of arguments to member variable function");
17873 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
17893 namespace function_detail {
17894 template <
typename Func,
bool is_yielding,
bool no_trampoline>
17899 template <
typename... Args>
17901 : fx(
std::
move(f),
std::forward<Args>(args)...) {
17905 int nr = call_detail::call_wrapped<void, true, false>(L, fx);
17915 if (!no_trampoline) {
17925 template <
typename T,
typename Function,
bool is_yielding>
17933 template <
typename... Args>
17935 : invocation(
std::
move(f)), member(
std::forward<Args>(args)...) {
17954 template <
typename T,
typename Function,
bool is_yielding>
17961 typedef std::add_lvalue_reference_t<meta::unwrapped_t<std::remove_reference_t<decltype(detail::deref(member))>>>
M;
17963 template <
typename... Args>
17965 : var(
std::
move(v)), member(
std::forward<Args>(args)...) {
17980 nr =
luaL_error(L,
"sol: incorrect number of arguments to member variable function");
18005 namespace function_detail {
18006 template <
int start_skew,
typename... Functions>
18009 typedef std::make_index_sequence<
sizeof...(Functions)>
indices;
18013 : overloads(
std::
move(set)) {
18017 : overloads(fxs...) {
18020 template <
typename Fx, std::size_t I,
typename... R,
typename... Args>
18022 auto& func = std::get<I>(ol);
18023 int nr = call_detail::call_wrapped<void, true, false, start_skew>(L, func);
18028 auto mfx = [](
auto&&... args) {
return call(std::forward<decltype(args)>(args)...); };
18045 template <
typename R,
typename... Args,
typename F,
typename = std::invoke_result_t<meta::unqualified_t<F>, Args...>>
18047 using Sig = R(Args...);
18049 return static_cast<Sig Fu::*
>(&Fu::operator());
18052 template <
typename F,
typename U = meta::unqualified_t<F>>
18058 template <
typename F>
18064 template <
typename F,
typename U = meta::unqualified_t<F>>
18074 template <
typename Sig,
typename C>
18075 inline constexpr Sig C::*
resolve_v(std::false_type, Sig C::*mem_func_ptr) {
18076 return mem_func_ptr;
18079 template <
typename Sig,
typename C>
18080 inline constexpr Sig C::*
resolve_v(std::true_type, Sig C::*mem_variable_ptr) {
18081 return mem_variable_ptr;
18085 template <
typename... Args,
typename R>
18086 inline constexpr
auto resolve(R fun_ptr(Args...)) -> R (*)(Args...) {
18090 template <
typename Sig>
18095 template <
typename... Args,
typename R,
typename C>
18096 inline constexpr
auto resolve(R (C::*mem_ptr)(Args...)) -> R (C::*)(Args...) {
18100 template <
typename Sig,
typename C>
18115 template <
typename R,
typename... Args,
typename F,
typename = std::invoke_result_t<meta::unqualified_t<F>, Args...>>
18117 using Sig = R(Args...);
18119 return static_cast<Sig Fu::*
>(&Fu::operator());
18122 template <
typename F,
typename U = meta::unqualified_t<F>>
18123 inline auto resolve_f(std::true_type, F&& f)
18128 template <
typename F>
18129 inline void resolve_f(std::false_type, F&&) {
18134 template <
typename F,
typename U = meta::unqualified_t<F>>
18144 template <
typename Sig,
typename C>
18145 inline Sig C::*
resolve_v(std::false_type, Sig C::*mem_func_ptr) {
18146 return mem_func_ptr;
18149 template <
typename Sig,
typename C>
18150 inline Sig C::*
resolve_v(std::true_type, Sig C::*mem_variable_ptr) {
18151 return mem_variable_ptr;
18155 template <
typename... Args,
typename R>
18156 inline auto resolve(R fun_ptr(Args...)) -> R (*)(Args...) {
18160 template <
typename Sig>
18161 inline Sig*
resolve(Sig* fun_ptr) {
18165 template <
typename... Args,
typename R,
typename C>
18166 inline auto resolve(R (C::*mem_ptr)(Args...)) -> R (C::*)(Args...) {
18170 template <
typename Sig,
typename C>
18171 inline Sig C::*
resolve(Sig C::*mem_ptr) {
18175 template <
typename... Sig,
typename F>
18187 namespace function_detail {
18188 template <
typename T>
18195 template <
bool yielding>
18207 template <
bool yielding>
18221 template <
bool is_yielding,
typename Fx,
typename... Args>
18224 template <
bool is_yielding,
bool no_trampoline,
typename Fx,
typename... Args>
18226 lua_CFunction freefunc = no_trampoline ? detail::static_trampoline<function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>>
18227 : function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>;
18231 upvalues += stack::push<user<Fx>>(L, std::forward<Args>(args)...);
18235 template <
bool is_yielding,
typename R,
typename... A,
typename Fx,
typename... Args>
18237 using dFx = std::decay_t<meta::unwrap_unqualified_t<Fx>>;
18238 using fx_ptr_t = R (*)(A...);
18239 constexpr
bool is_convertible = std::is_convertible_v<dFx, fx_ptr_t>;
18240 if constexpr (is_convertible) {
18242 select<is_yielding>(L,
std::move(fxptr), std::forward<Args>(args)...);
18246 select_set_fx<is_yielding, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18250 template <
bool is_yielding,
typename Fx,
typename... Args>
18253 select_convertible<is_yielding>(
types<Sig>(), L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18256 template <
bool is_yielding,
typename Fx,
typename... Args>
18259 if constexpr (
sizeof...(Args) < 1) {
18268 else if constexpr (
sizeof...(Args) < 2) {
18270 constexpr
bool is_reference = meta::is_specialization_of_v<Tu, std::reference_wrapper> || std::is_pointer_v<Tu>;
18271 if constexpr (meta::is_specialization_of_v<Tu, function_detail::class_indicator>) {
18279 else if constexpr (is_reference) {
18280 typedef std::decay_t<Fx> dFx;
18281 dFx memfxptr(std::forward<Fx>(fx));
18282 auto userptr =
detail::ptr(std::forward<Args>(args)...);
18289 upvalues +=
stack::push(L, static_cast<void const*>(userptr));
18293 using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>;
18295 select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18300 using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>;
18302 select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18306 template <
bool is_yielding,
typename Fx,
typename T,
typename... Args>
18308 using dFx = std::decay_t<Fx>;
18310 if constexpr (meta::is_specialization_of_v<Tu, function_detail::class_indicator>) {
18317 upvalues += stack::push<user<dFx>>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18321 constexpr
bool is_reference = meta::is_specialization_of_v<Tu, std::reference_wrapper> || std::is_pointer_v<Tu>;
18322 if constexpr (is_reference) {
18323 auto userptr =
detail::ptr(std::forward<T>(obj));
18328 upvalues += stack::push<user<dFx>>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18334 select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<T>(obj), std::forward<Args>(args)...);
18339 template <
bool is_yielding,
typename Fx,
typename... Args>
18341 using dFx = std::decay_t<Fx>;
18342 if constexpr (
sizeof...(Args) < 1) {
18348 upvalues += stack::push<user<dFx>>(L, std::forward<Fx>(fx));
18352 select_member_function_with<is_yielding>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18356 template <
bool is_yielding,
typename Fx,
typename... Args>
18359 if constexpr (is_lua_reference_v<uFx>) {
18361 stack::push(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18363 else if constexpr (is_lua_c_function_v<uFx>) {
18366 upvalues +=
stack::push(L, std::forward<Fx>(fx));
18367 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_) 18368 if constexpr (std::is_nothrow_invocable_r_v<int, uFx, lua_State*>) {
18377 lua_CFunction cf = &function_detail::lua_c_wrapper<is_yielding>;
18381 else if constexpr (std::is_function_v<std::remove_pointer_t<uFx>>) {
18382 std::decay_t<Fx> target(std::forward<Fx>(fx), std::forward<Args>(args)...);
18390 else if constexpr (std::is_member_function_pointer_v<uFx>) {
18391 select_member_function<is_yielding>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18393 else if constexpr (meta::is_member_object_v<uFx>) {
18394 select_member_variable<is_yielding>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18397 select_convertible<is_yielding>(
types<>(), L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18403 template <
typename... Sigs>
18405 template <
bool is_yielding,
typename Arg0,
typename... Args>
18408 if constexpr (is_yielding) {
18409 return stack::push<meta::unqualified_t<Arg0>>(L,
detail::yield_tag, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
18412 return stack::push(L, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
18416 function_detail::select<is_yielding>(L, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
18421 template <
typename Arg0,
typename... Args>
18424 push<true>(L, std::forward<Args>(args)...);
18427 push<true>(L, std::forward<Arg0>(arg0).func, std::forward<Args>(args)...);
18430 push<false>(L, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
18436 template <
typename T>
18438 template <
typename... Args>
18444 function_detail::select<true>(L, f.
func, std::forward<Args>(args)...);
18449 template <
typename... Args>
18455 function_detail::select<true>(L,
std::move(f.func), std::forward<Args>(args)...);
18461 template <
typename T,
typename... Args>
18463 template <std::size_t... I,
typename FP>
18465 return stack::push<T>(L, std::get<I>(std::forward<FP>(fp).arguments)...);
18469 return push_func(std::make_index_sequence<
sizeof...(Args)>(), L, fp);
18473 return push_func(std::make_index_sequence<
sizeof...(Args)>(), L,
std::move(fp));
18477 template <
typename Signature>
18481 function_detail::select<true>(L, fx);
18489 function_detail::select<true>(L,
std::move(fx));
18497 function_detail::select<false>(L, fx);
18505 function_detail::select<false>(L,
std::move(fx));
18512 template <
typename Signature>
18514 template <
typename... Args>
18516 function_detail::select<false>(L, std::forward<Args>(args)...);
18521 template <
typename Signature>
18523 std::
enable_if_t<meta::all<std::is_function<std::remove_pointer_t<Signature>>, meta::neg<std::is_same<Signature, lua_CFunction>>,
18524 meta::neg<std::is_same<Signature, std::remove_pointer_t<lua_CFunction>>>
18525 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
18527 meta::neg<std::is_same<Signature, detail::lua_CFunction_noexcept>>,
18528 meta::neg<std::is_same<Signature, std::remove_pointer_t<detail::lua_CFunction_noexcept>>>
18531 template <
typename F>
18533 function_detail::select<false>(L, std::forward<F>(f));
18538 template <
typename... Functions>
18542 function_detail::select_set_fx<false, false, F>(L,
std::move(
set.functions));
18548 function_detail::select_set_fx<false, false, F>(L,
set.functions);
18553 template <
typename T>
18556 lua_CFunction cf = call_detail::call_user<void, false, false, protect_t<T>, 2>;
18559 upvalues += stack::push<user<protect_t<T>>>(L,
std::move(pw.value));
18564 lua_CFunction cf = call_detail::call_user<void, false, false, protect_t<T>, 2>;
18567 upvalues += stack::push<user<protect_t<T>>>(L, pw.
value);
18572 template <
typename F,
typename G>
18575 if constexpr (std::is_void_v<F>) {
18578 else if constexpr (std::is_void_v<G>) {
18587 if constexpr (std::is_void_v<F>) {
18590 else if constexpr (std::is_void_v<G>) {
18599 template <
typename T>
18609 template <
typename... Functions>
18613 function_detail::select_set_fx<false, false, F>(L, fw.
functions);
18619 function_detail::select_set_fx<false, false, F>(L,
std::move(fw.functions));
18625 function_detail::select_set_fx<false, false, F>(L, fw.
functions);
18631 function_detail::select_set_fx<false, false, F>(L,
std::move(fw.functions));
18648 template <
typename T>
18660 template <
typename T,
typename... Lists>
18673 template <
typename L0,
typename... Lists>
18678 return stack::push<detail::tagged<T, cl_t>>(L, cl);
18682 template <
typename T,
typename... Fxs>
18689 return push(L,
c.value());
18709 template <
typename F,
typename... Fxs>
18724 template <
typename T>
18732 template <
typename T,
typename Fx>
18735 lua_CFunction cf = call_detail::call_user<T, false, false, destructor_wrapper<Fx>, 2>;
18738 upvalues += stack::push<user<destructor_wrapper<Fx>>>(L,
std::move(
c));
18743 lua_CFunction cf = call_detail::call_user<T, false, false, destructor_wrapper<Fx>, 2>;
18746 upvalues += stack::push<user<destructor_wrapper<Fx>>>(L,
c);
18751 template <
typename Fx>
18754 lua_CFunction cf = call_detail::call_user<void, false, false, destructor_wrapper<Fx>, 2>;
18757 upvalues += stack::push<user<destructor_wrapper<Fx>>>(L,
std::move(
c));
18762 lua_CFunction cf = call_detail::call_user<void, false, false, destructor_wrapper<Fx>, 2>;
18765 upvalues += stack::push<user<destructor_wrapper<Fx>>>(L,
c);
18770 template <
typename F,
typename... Policies>
18775 lua_CFunction cf = call_detail::call_user<void, false, false, P, 2>;
18778 upvalues += stack::push<user<P>>(L, p);
18783 lua_CFunction cf = call_detail::call_user<void, false, false, P, 2>;
18786 upvalues += stack::push<user<P>>(L,
std::move(p));
18791 template <
typename T,
typename F,
typename... Policies>
18797 lua_CFunction cf = call_detail::call_user<T, false, false, P, 2>;
18800 upvalues += stack::push<user<P>>(L, p.
value());
18805 lua_CFunction cf = call_detail::call_user<T, false, false, P, 2>;
18808 upvalues += stack::push<user<P>>(L,
std::move(p.value()));
18813 template <
typename T>
18816 if constexpr (std::is_invocable_v<std::add_rvalue_reference_t<T>,
lua_State*>) {
18825 if constexpr (std::is_invocable_v<const T, lua_State*>) {
18834 namespace stack_detail {
18835 template <
typename Function,
typename Handler>
18837 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) 18844 success = upvalue_name !=
nullptr;
18849 L, index,
type::function,
type_of(L, index),
"type must be a Lua C Function gotten from a function pointer serialized by sol2");
18857 template <
typename Function>
18859 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE_I_) 18861 auto udata = stack::stack_detail::get_as_upvalues_using_function<Function*>(L,
index);
18862 Function* fx = udata.first;
18867 "You are attempting to retrieve a function pointer type. " 18868 "This is inherently unsafe in sol2. In order to do this, you must turn on the " 18869 "SOL_GET_FUNCTION_POINTER_UNSAFE configuration macro, as detailed in the documentation. " 18870 "Please be careful!" 18872 "You are attempting to retrieve a function pointer type. " 18873 "You explicitly turned off the ability to do this by defining " 18874 "SOL_GET_FUNCTION_POINTER_UNSAFE or similar to be off. " 18875 "Please reconsider this!" 18890 #include <exception> 18909 (
void)writer_function;
18912 return result_code;
18917 (
void)writer_function;
18920 return luaL_error(L,
"a non-zero error code (%d) was returned by the lua_Writer for the dump function", result_code);
18924 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 18928 (
void)writer_function;
18932 #endif // no exceptions stuff 18942 template <
typename ref_t,
bool aligned = false>
18947 void luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount)
const {
18948 lua_call(lua_state(), static_cast<int>(argcount), static_cast<int>(resultcount));
18951 template <std::size_t... I,
typename... Ret>
18954 return stack::pop<std::tuple<Ret...>>(lua_state());
18957 template <std::
size_t I,
typename Ret, meta::enable<meta::neg<std::is_
void<Ret>>> = meta::enabler>
18960 return stack::pop<Ret>(lua_state());
18963 template <std::
size_t I>
18970 int firstreturn = (
std::max)(1, stacksize - static_cast<int>(n));
18972 int poststacksize =
lua_gettop(lua_state());
18973 int returncount = poststacksize - (firstreturn - 1);
18978 using base_t::lua_state;
18981 template <
typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_function>>, meta::neg<std::is_same<base_t, stack_reference>>, meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
18983 : base_t(
std::forward<T>(r)) {
18984 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 18988 stack::check<basic_function>(lua_state(), -1,
handler);
19005 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
19007 : base_t(L,
std::forward<T>(r)) {
19008 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 19011 stack::check<basic_function>(lua_state(), -1,
handler);
19015 : base_t(L, index) {
19016 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 19022 : base_t(L, index) {
19023 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 19026 stack::check<basic_function>(lua_state(), -1,
handler);
19030 template <
typename Fx>
19034 int r =
lua_dump(this->lua_state(), writer, userdata, strip ? 1 : 0);
19036 return on_error(this->lua_state(), r, writer, userdata, strip);
19045 template <
typename Container = bytecode>
19048 (
void)dump(static_cast<lua_Writer>(&basic_insert_dump_writer<Container>),
static_cast<void*
>(&bc),
false, &
dump_panic_on_error);
19052 template <
typename Container = bytecode,
typename Fx>
19055 (
void)dump(static_cast<lua_Writer>(&basic_insert_dump_writer<Container>),
static_cast<void*
>(&bc),
false, std::forward<Fx>(on_error));
19059 template <
typename... Args>
19061 return call<>(std::forward<Args>(args)...);
19064 template <
typename... Ret,
typename... Args>
19065 decltype(
auto) operator()(
types<Ret...>, Args&&... args)
const {
19066 return call<Ret...>(std::forward<Args>(args)...);
19069 template <
typename... Ret,
typename... Args>
19070 decltype(
auto)
call(Args&&... args)
const {
19075 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), static_cast<std::ptrdiff_t>(pushcount));
19091 static const char name[9] =
"sol.\xF0\x9F\x94\xA9";
19095 template <
bool b,
typename target_t = reference>
19102 : target(target), stackindex(0) {
19104 stackindex =
lua_gettop(target.lua_state()) + 1;
19110 : target(target), stackindex(0) {
19112 stackindex = target.stack_index();
19126 if (stackindex != 0) {
19133 template <
typename base_t,
typename T>
19138 template <
typename Reference,
bool is_main_ref = false>
19141 return Reference(L,
lua_nil);
19145 return Reference(L, -1);
19148 template <
typename T>
19150 if (L ==
nullptr) {
19153 if (!ref.valid()) {
19154 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_) 19156 #endif // make sure stack doesn't overflow 19171 #include <algorithm> 19176 template <
bool b,
typename handler_t>
19190 template <
typename ref_t,
bool aligned = false,
typename handler_t = reference>
19202 template <
typename T>
19213 template <std::size_t... I,
bool b,
typename... Ret>
19215 luacall(n,
sizeof...(Ret), h);
19216 return stack::pop<std::tuple<Ret...>>(lua_state());
19219 template <std::
size_t I,
bool b,
typename Ret>
19222 return stack::pop<Ret>(lua_state());
19225 template <std::
size_t I,
bool b>
19233 int poststacksize = stacksize;
19234 int firstreturn = 1;
19235 int returncount = 0;
19237 #if !defined(SOL_NO_EXCEPTIONS) || !SOL_NO_EXCEPTIONS 19238 #if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !SOL_NO_EXCEPTIONS_SAFE_PROPAGATION) || (defined(SOL_LUAJIT) && SOL_LUAJIT) 19240 #endif // Safe Exception Propagation 19241 #endif // No Exceptions 19245 returncount = poststacksize - (firstreturn - 1);
19246 #ifndef SOL_NO_EXCEPTIONS 19247 #if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !SOL_NO_EXCEPTIONS_SAFE_PROPAGATION) || (defined(SOL_LUAJIT) && SOL_LUAJIT) 19250 catch (
const char*
error) {
19260 catch (
const std::exception& error) {
19265 #if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !SOL_NO_EXCEPTIONS_SAFE_PROPAGATION) 19277 #endif // Safe Exception Propagation 19278 #endif // Exceptions vs. No Exceptions 19283 using base_t::lua_state;
19288 template <
typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_protected_function>>, meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<T>>>, meta::neg<std::is_same<base_t, stack_reference>>, meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
19291 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 19295 stack::check<basic_protected_function>(lua_state(), -1,
handler);
19310 : base_t(b), error_handler(
std::
move(eh)) {
19328 template <
typename Super>
19332 template <
typename Super>
19336 template <
typename Proxy,
typename Handler, meta::enable<std::is_base_of<proxy_base_tag, meta::unqualified_t<Proxy>>, meta::neg<is_lua_index<meta::unqualified_t<Handler>>>> = meta::enabler>
19341 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
19345 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
19347 : base_t(L,
std::forward<T>(r)), error_handler(
std::
move(eh)) {
19348 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 19351 stack::check<basic_protected_function>(lua_state(), -1,
handler);
19356 : base_t(n), error_handler(n) {
19363 : base_t(L, index), error_handler(
std::
move(eh)) {
19364 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 19366 stack::check<basic_protected_function>(L,
index,
handler);
19373 : base_t(L, index), error_handler(
std::
move(eh)) {
19374 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 19376 stack::check<basic_protected_function>(L,
index,
handler);
19383 : base_t(L, index), error_handler(
std::
move(eh)) {
19384 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 19386 stack::check<basic_protected_function>(L,
index,
handler);
19393 : base_t(L, index), error_handler(
std::
move(eh)) {
19394 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 19397 stack::check<basic_protected_function>(lua_state(), -1,
handler);
19401 template <
typename Fx>
19405 int r =
lua_dump(this->lua_state(), writer, userdata, strip ? 1 : 0);
19407 return on_error(this->lua_state(), r, writer, userdata, strip);
19416 template <
typename Container = bytecode>
19419 (
void)dump(static_cast<lua_Writer>(&basic_insert_dump_writer<Container>),
static_cast<void*
>(&bc),
false, &
dump_throw_on_error);
19423 template <
typename Container = bytecode,
typename Fx>
19426 (
void)dump(static_cast<lua_Writer>(&basic_insert_dump_writer<Container>),
static_cast<void*
>(&bc),
false, std::forward<Fx>(on_error));
19430 template <
typename... Args>
19432 return call<>(std::forward<Args>(args)...);
19435 template <
typename... Ret,
typename... Args>
19436 decltype(
auto) operator()(
types<Ret...>, Args&&... args)
const {
19437 return call<Ret...>(std::forward<Args>(args)...);
19440 template <
typename... Ret,
typename... Args>
19441 decltype(
auto)
call(Args&&... args)
const {
19442 if constexpr (!aligned) {
19444 if (error_handler.valid()) {
19448 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), pushcount, h);
19454 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), pushcount, h);
19459 if (error_handler.valid()) {
19473 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), pushcount, h);
19478 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), pushcount, h);
19487 #include <functional> 19490 template <
typename... Ret,
typename... Args>
19493 return sf.template
call<Ret...>(std::forward<Args>(args)...);
19497 : L(o.lua_state()), index(o.stack_index()), returncount(o.return_count()), popcount(o.return_count()), err(o.status()) {
19506 index = o.stack_index();
19507 returncount = o.return_count();
19508 popcount = o.return_count();
19518 : L(o.lua_state()), index(o.stack_index()), returncount(o.return_count()) {
19526 index = o.stack_index();
19527 returncount = o.return_count();
19536 template <
typename... R>
19543 template <
typename... Args>
19545 return lua_func_.
call<R...>(std::forward<Args>(args)...);
19556 template <
typename... Args>
19558 lua_func_.
call<
void>(std::forward<Args>(args)...);
19564 template <
typename Signature>
19570 template <
typename... R>
19582 return get_std_func(return_types(), L, index);
19586 template <
typename Allocator>
19606 #ifndef SOL_DEPRECATED 19608 #define SOL_DEPRECATED __declspec(deprecated) 19610 #define SOL_DEPRECATED __attribute__((deprecated)) 19612 #define SOL_DEPRECATED [[deprecated]] 19613 #endif // compilers 19614 #endif // SOL_DEPRECATED 19618 template <
typename T>
19633 template <
typename T>
19636 namespace container_detail {
19638 template <
typename T>
19641 template <
typename C>
19643 template <
typename C>
19650 template <
typename T>
19653 template <
typename C>
19655 template <
typename C>
19662 template <
typename T>
19665 template <
typename C>
19667 decltype(std::declval<C>().erase_after(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>()))*);
19668 template <
typename C>
19675 template <
typename T,
typename =
void>
19678 template <
typename C>
19679 static meta::sfinae_yes_t test(decltype(std::declval<C>().
find(std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
19680 template <
typename C>
19687 template <
typename T>
19690 template <
typename C>
19691 static meta::sfinae_yes_t test(decltype(std::declval<C>().
find(std::declval<std::add_rvalue_reference_t<typename C::key_type>>()))*);
19692 template <
typename C>
19699 template <
typename T>
19702 template <
typename C>
19703 static meta::sfinae_yes_t test(decltype(std::declval<C>().erase(std::declval<typename C::iterator>()))*);
19704 template <
typename C>
19711 template <
typename T>
19714 template <
typename C>
19715 static meta::sfinae_yes_t test(decltype(std::declval<C>().erase(std::declval<typename C::key_type>()))*);
19716 template <
typename C>
19723 template <
typename T>
19726 template <
typename C>
19728 template <
typename C>
19735 template <
typename T>
19738 template <
typename C>
19740 template <
typename C>
19747 template <
typename T>
19750 template <
typename C>
19752 template <
typename C>
19759 template <
typename T>
19762 template <
typename C>
19764 template <
typename C>
19771 template <
typename T>
19774 template <
typename C>
19776 template <
typename C>
19783 template <
typename T>
19786 template <
typename C>
19788 template <
typename C>
19795 template <
typename T>
19798 template <
typename C>
19800 template <
typename C>
19807 template <
typename T>
19810 template <
typename C>
19812 template <
typename C>
19819 template <
typename T>
19822 template <
typename C>
19824 template <
typename C>
19831 template <
typename T>
19834 template <
typename C>
19836 template <
typename C>
19843 template <
typename T>
19846 template <
typename C>
19848 template <
typename C>
19855 template <
typename T>
19858 template <
typename C>
19860 template <
typename C>
19867 template <
typename T>
19870 template <
typename C>
19872 template <
typename C>
19879 template <
typename T>
19882 template <
typename C>
19884 template <
typename C>
19891 template <
typename T>
19894 template <
typename T>
19897 template <
typename T>
19900 template <
typename T>
19903 template <
typename T>
19906 template <
typename T>
19909 template <
typename T>
19912 template <
typename T>
19915 template <
typename T>
19918 template <
typename T>
19921 template <
typename T>
19924 template <
typename T>
19927 template <
typename T>
19930 template <
typename T>
19933 template <
typename T>
19936 template <
typename T>
19939 template <
typename T>
19942 template <
typename T>
19945 template <
typename T>
19948 template <
typename T>
19951 template <
typename T>
19954 template <
typename T>
19957 template <
typename T>
19960 template <
typename T>
19963 template <
typename T>
19968 template <
typename T>
19973 template <
typename T>
19976 template <
typename T>
19978 return std::forward<T>(t);
19981 template <
typename T>
19986 template <
typename T>
19988 return std::forward<T>(t);
19991 template <
typename T>
19996 template <
typename X,
typename =
void>
19999 typedef std::remove_pointer_t<meta::unwrap_unqualified_t<X>>
T;
20006 return luaL_error(L,
"sol: cannot call 'at(index)' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20010 return luaL_error(L,
"sol: cannot call 'get(key)' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20014 return luaL_error(L,
"sol: cannot call 'container[key]' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20018 return luaL_error(L,
"sol: cannot call 'set(key, value)' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20023 L,
"sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20027 return luaL_error(L,
"sol: cannot call 'add' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20031 return luaL_error(L,
"sol: cannot call 'insert' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20035 return luaL_error(L,
"sol: cannot call 'find' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20039 return luaL_error(L,
"sol: cannot call 'index_of' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20043 return luaL_error(L,
"sol: cannot call 'end' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20047 return luaL_error(L,
"sol: cannot call 'clear' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20051 return luaL_error(L,
"sol: cannot call 'empty' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20055 return luaL_error(L,
"sol: cannot call 'erase' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20059 return luaL_error(L,
"sol: cannot call 'next' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20063 return luaL_error(L,
"sol: cannot call '__pairs/pairs' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20067 return luaL_error(L,
"sol: cannot call '__ipairs' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20071 luaL_error(L,
"sol: cannot call 'being' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20076 luaL_error(L,
"sol: cannot call 'end' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
20081 template <
typename X>
20083 std::
enable_if_t<meta::all<is_forced_container<meta::unqualified_t<X>>, meta::has_value_type<meta::unqualified_t<container_decay_t<X>>>,
20084 meta::has_iterator<meta::unqualified_t<container_decay_t<X>>>>::value>> {
20086 using T = std::remove_pointer_t<meta::unwrap_unqualified_t<container_decay_t<X>>>;
20099 typedef typename KV::first_type
K;
20100 typedef typename KV::second_type
V;
20102 typedef decltype(*std::declval<iterator&>()) iterator_return;
20127 #if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) 20128 auto p = stack::unqualified_check_get<T*>(L, 1);
20131 "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)",
20132 detail::demangle<T>().c_str());
20134 if (p.value() ==
nullptr) {
20136 L,
"sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
20140 return stack::unqualified_get<T>(L, 1);
20141 #endif // Safe getting with error 20145 pos += deferred_uc::index_adjustment(L,
self);
20149 auto it = deferred_uc::begin(L,
self);
20150 auto e = deferred_uc::end(L,
self);
20165 std::ptrdiff_t len =
static_cast<std::ptrdiff_t
>(size_start(L,
self));
20166 pos += deferred_uc::index_adjustment(L,
self);
20167 if (pos < 0 || pos >= len) {
20170 auto it =
std::next(deferred_uc::begin(L,
self), pos);
20178 template <
typename Iter>
20180 decltype(
auto) v = *it;
20184 template <
typename Iter>
20190 key += deferred_uc::index_adjustment(L,
self);
20194 auto it = deferred_uc::begin(L,
self);
20195 auto e = deferred_uc::end(L,
self);
20210 std::ptrdiff_t len =
static_cast<std::ptrdiff_t
>(size_start(L,
self));
20211 key += deferred_uc::index_adjustment(L,
self);
20212 if (key < 0 || key >= len) {
20215 auto it =
std::next(deferred_uc::begin(L,
self), key);
20225 auto e = deferred_uc::end(L,
self);
20226 auto it = std::find_if(deferred_uc::begin(L,
self), e, std::ref(fx));
20234 return detail::error_result(
"cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'",
20235 detail::demangle<T>().
data(),
20236 detail::demangle<K>().
data());
20244 decltype(
auto) v = *it;
20245 v.second = value.
as<V>();
20250 decltype(
auto) v = *it;
20261 "cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().
data());
20265 decltype(
auto) key = okey.
as<K>();
20266 key += deferred_uc::index_adjustment(L,
self);
20267 auto e = deferred_uc::end(L,
self);
20268 auto it = deferred_uc::begin(L,
self);
20270 for (; key > 0 && it != e; --key, ++it) {
20277 return detail::error_result(
"out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
20283 decltype(
auto) key = okey.
as<K>();
20284 key += deferred_uc::index_adjustment(L,
self);
20286 return detail::error_result(
"sol: out of bounds (too small) for set on '%s'", detail::demangle<T>().c_str());
20288 std::ptrdiff_t len =
static_cast<std::ptrdiff_t
>(size_start(L,
self));
20292 else if (key >= len) {
20293 return detail::error_result(
"sol: out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
20295 auto it =
std::next(deferred_uc::begin(L,
self), key);
20300 decltype(
auto) key = okey.
as<K>();
20303 "cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().
data());
20306 auto e = deferred_uc::end(L,
self);
20307 auto it = std::find_if(deferred_uc::begin(L,
self), e, std::ref(fx));
20315 return detail::error_result(
"cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key",
20316 detail::demangle<T>().
data(),
20317 detail::demangle<K>().
data());
20320 template <
typename Iter>
20331 "cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
20335 template <
typename Iter>
20338 self.insert(it, key);
20346 "cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle<T>().c_str());
20351 decltype(
auto) key = okey.
as<K>();
20352 auto it =
self.find(key);
20353 if (it == deferred_uc::end(L,
self)) {
20371 template <
bool idx_of = false>
20376 return detail::error_result(
"cannot perform an 'index_of': '%s's is not an ordered container", detail::demangle<T>().
data());
20379 decltype(
auto) key = stack::unqualified_get<K>(L, 2);
20380 auto it =
self.find(key);
20381 if (it == deferred_uc::end(L,
self)) {
20384 if constexpr (idx_of) {
20385 auto dist = std::distance(deferred_uc::begin(L,
self), it);
20386 dist -= deferred_uc::index_adjustment(L,
self);
20395 template <
bool idx_of = false>
20400 return detail::error_result(
"cannot perform an 'index_of': '%s's is not an ordered container", detail::demangle<T>().
data());
20403 decltype(
auto)
value = stack::unqualified_get<V>(L, 2);
20404 auto it =
self.find(
value);
20405 if (it == deferred_uc::end(L,
self)) {
20408 if constexpr (idx_of) {
20409 auto dist = std::distance(deferred_uc::begin(L,
self), it);
20410 dist -= deferred_uc::index_adjustment(L,
self);
20419 template <
bool idx_of = false>
20424 template <
typename Iter>
20429 template <
typename Iter>
20431 idx -= deferred_uc::index_adjustment(L,
self);
20435 template <
bool = false>
20437 return detail::error_result(
"cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable",
20438 detail::demangle<T>().c_str());
20441 template <
bool idx_of = false>
20443 decltype(
auto)
value = stack::unqualified_get<V>(L, 2);
20444 auto it = deferred_uc::begin(L,
self);
20445 auto e = deferred_uc::end(L,
self);
20446 std::size_t idx = 0;
20447 for (;; ++it, ++idx) {
20458 template <
bool idx_of = false>
20463 template <
typename Iter>
20465 return add_insert_after(std::false_type(), L,
self, value);
20469 return detail::error_result(
"cannot call 'add' on type '%s': no suitable insert/push_back C++ functions", detail::demangle<T>().
data());
20472 template <
typename Iter>
20474 self.insert_after(pos, value.
as<V>());
20479 auto backit =
self.before_begin();
20481 auto e = deferred_uc::end(L,
self);
20482 for (
auto it = deferred_uc::begin(L,
self); it != e; ++backit, ++it) {
20485 return add_insert_after(std::true_type(), L,
self, value, backit);
20488 template <
typename Iter>
20490 self.insert(pos, value.
as<V>());
20495 auto pos = deferred_uc::end(L,
self);
20496 return add_insert(std::true_type(), L,
self, value, pos);
20499 template <
typename Iter>
20508 template <
typename Iter>
20510 self.push_back(value.
as<V>());
20515 self.push_back(value.
as<V>());
20519 template <
typename Iter>
20528 template <
typename Iter>
20531 self.insert(pos,
value_type(key.
as<K>(), stack::unqualified_get<V>(L, 3)));
20540 "cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
20545 auto pos = deferred_uc::end(L,
self);
20546 return add_associative(std::true_type(), L,
self,
std::move(key), pos);
20549 template <
typename Iter>
20558 template <
typename Iter>
20567 template <
typename Iter>
20569 return add_copyable(std::false_type(), L,
self,
std::move(value));
20573 return detail::error_result(
"cannot call 'add' on '%s': value_type is non-copyable", detail::demangle<T>().
data());
20578 return add_copyable(std::true_type(), L,
self,
std::move(value));
20582 auto it = deferred_uc::begin(L,
self);
20583 auto key = where.
as<K>();
20584 key += deferred_uc::index_adjustment(L,
self);
20585 std::advance(it, key);
20586 self.insert(it, value.
as<V>());
20591 auto key = where.
as<K>();
20592 auto backit =
self.before_begin();
20594 key += deferred_uc::index_adjustment(L,
self);
20595 auto e = deferred_uc::end(L,
self);
20596 for (
auto it = deferred_uc::begin(L,
self); key > 0; ++backit, ++it, --key) {
20598 return detail::error_result(
"sol: out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
20602 self.insert_after(backit, value.
as<V>());
20608 "cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle<T>().
data());
20624 return detail::error_result(
"cannot call 'insert' on '%s': value_type is non-copyable", detail::demangle<T>().
data());
20628 auto it = deferred_uc::begin(L,
self);
20629 key += deferred_uc::index_adjustment(L,
self);
20630 std::advance(it, key);
20637 auto fx = [&](
const value_type& r) ->
bool {
return key == r; };
20638 auto e = deferred_uc::end(L,
self);
20639 auto it = std::find_if(deferred_uc::begin(L,
self), e, std::ref(fx));
20654 return erase_integral(std::is_integral<K>(), L,
self, key);
20658 auto backit =
self.before_begin();
20660 key += deferred_uc::index_adjustment(L,
self);
20661 auto e = deferred_uc::end(L,
self);
20662 for (
auto it = deferred_uc::begin(L,
self); key > 0; ++backit, ++it, --key) {
20664 return detail::error_result(
"sol: out of bounds for erase on '%s'", detail::demangle<T>().c_str());
20668 self.erase_after(backit);
20693 return std::distance(deferred_uc::begin(L,
self), deferred_uc::end(L,
self));
20697 return self.size();
20705 luaL_error(L,
"sol: cannot call clear on '%s'", detail::demangle<T>().c_str());
20709 return self.empty();
20713 return deferred_uc::begin(L,
self) == deferred_uc::end(L,
self);
20717 auto it =
self.find(key);
20718 if (it == deferred_uc::end(L,
self)) {
20722 return get_associative(std::true_type(), L, it);
20755 iter& i = stack::unqualified_get<user<iter>>(L, 1);
20756 auto& source = i.source;
20758 if (it == deferred_uc::end(L, source)) {
20762 if constexpr (ip) {
20770 std::advance(it, 1);
20776 iter& i = stack::unqualified_get<user<iter>>(L, 1);
20777 auto& source = i.source;
20779 next_K k = stack::unqualified_get<next_K>(L, 2);
20780 if (it == deferred_uc::end(L, source)) {
20784 if constexpr (std::is_integral_v<next_K>) {
20791 std::advance(it, 1);
20798 return next_associative<ip>(is_assoc(), L);
20803 auto& src = get_src(L);
20805 stack::push<user<iter>>(L, src, deferred_uc::begin(L, src));
20812 auto& src = get_src(L);
20814 stack::push<user<iter>>(L, src, deferred_uc::begin(L, src));
20821 auto&
self = get_src(L);
20824 std::ptrdiff_t pos = stack::unqualified_get<std::ptrdiff_t>(L, 2);
20825 er = at_start(L,
self, pos);
20831 auto&
self = get_src(L);
20834 decltype(
auto) key = stack::unqualified_get<K>(L);
20835 er = get_start(L,
self, key);
20850 auto key = stack::get<K>(L, 2);
20851 auto self_size = deferred_uc::size(L);
20852 if (key == static_cast<K>(self_size)) {
20863 auto&
self = get_src(L);
20873 auto&
self = get_src(L);
20879 auto&
self = get_src(L);
20885 auto&
self = get_src(L);
20891 auto&
self = get_src(L);
20897 if constexpr (meta::has_begin_end_v<T>) {
20898 return self.begin();
20902 return begin(
self);
20907 if constexpr (meta::has_begin_end_v<T>) {
20917 auto&
self = get_src(L);
20918 std::size_t r = size_start(L,
self);
20923 auto&
self = get_src(L);
20924 clear_start(L,
self);
20929 auto&
self = get_src(L);
20932 decltype(
auto) key = stack::unqualified_get<K>(L, 2);
20933 er = erase_start(L,
self, key);
20939 auto&
self = get_src(L);
20949 return pairs_associative<false>(is_assoc(), L);
20954 return pairs_associative<true>(is_assoc(), L);
20962 template <
typename X>
20965 typedef std::remove_pointer_t<meta::unwrap_unqualified_t<X>>
T;
20982 auto p = stack::unqualified_check_get<T*>(L, 1);
20983 #if SOL_IS_ON(SOL_SAFE_USERTYPE_I_) 20986 "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)",
20987 detail::demangle<T>().c_str());
20989 if (p.value() ==
nullptr) {
20991 L,
"sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
20993 #endif // Safe getting with error 20998 T&
self = get_src(L);
20999 decltype(
auto)
value = stack::unqualified_get<value_type>(L, 2);
21001 for (std::size_t idx = 0; idx < N; ++idx) {
21002 using v_t = std::add_const_t<decltype(self[idx])>;
21005 idx -= deferred_uc::index_adjustment(L,
self);
21013 return luaL_error(L,
"sol: cannot call 'find' on '%s': no supported comparison operator for the value type", detail::demangle<T>().c_str());
21017 iter& i = stack::unqualified_get<user<iter>>(L, 1);
21018 auto& source = i.source;
21020 std::size_t k = stack::unqualified_get<std::size_t>(L, 2);
21021 if (it == deferred_uc::end(L, source)) {
21027 std::advance(it, 1);
21033 return luaL_error(L,
"sol: cannot call 'clear' on type '%s': cannot remove all items from a fixed array", detail::demangle<T>().c_str());
21037 return luaL_error(L,
"sol: cannot call 'erase' on type '%s': cannot remove an item from fixed arrays", detail::demangle<T>().c_str());
21041 return luaL_error(L,
"sol: cannot call 'add' on type '%s': cannot add to fixed arrays", detail::demangle<T>().c_str());
21045 return luaL_error(L,
"sol: cannot call 'insert' on type '%s': cannot insert new entries into fixed arrays", detail::demangle<T>().c_str());
21053 T&
self = get_src(L);
21054 std::ptrdiff_t idx = stack::unqualified_get<std::ptrdiff_t>(L, 2);
21055 idx += deferred_uc::index_adjustment(L,
self);
21067 T&
self = get_src(L);
21068 std::ptrdiff_t idx = stack::unqualified_get<std::ptrdiff_t>(L, 2);
21069 idx += deferred_uc::index_adjustment(L,
self);
21071 return luaL_error(L,
"sol: index out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
21074 return luaL_error(L,
"sol: index out of bounds (too small) for set on '%s'", detail::demangle<T>().c_str());
21076 self[idx] = stack::unqualified_get<value_type>(L, 3);
21101 auto& src = get_src(L);
21103 stack::push<user<iter>>(L, src, deferred_uc::begin(L, src));
21121 return std::addressof(
self[0]);
21129 template <
typename X>
21133 template <
typename T>
21140 #include <unordered_map> 21144 namespace container_detail {
21145 template <
typename X>
21147 using T = std::remove_pointer_t<meta::unqualified_t<X>>;
21152 return uc::index_get(L);
21156 return default_uc::index_get(L);
21160 static const std::unordered_map<string_view, lua_CFunction> calls {
21161 {
"at", &real_at_call },
21162 {
"get", &real_get_call },
21163 {
"set", &real_set_call },
21164 {
"size", &real_length_call },
21165 {
"add", &real_add_call },
21166 {
"empty", &real_empty_call },
21167 {
"insert", &real_insert_call },
21168 {
"clear", &real_clear_call },
21169 {
"find", &real_find_call },
21170 {
"index_of", &real_index_of_call },
21171 {
"erase", &real_erase_call },
21172 {
"pairs", &pairs_call },
21173 {
"next", &next_call },
21175 auto maybenameview = stack::unqualified_check_get<string_view>(L, 2);
21176 if (maybenameview) {
21178 auto it = calls.find(name);
21179 if (it != calls.cend()) {
21191 return default_uc::at(L);
21215 return default_uc::set(L);
21223 return uc::index_set(L);
21227 return default_uc::index_set(L);
21271 return uc::size(L);
21275 return default_uc::size(L);
21287 return default_uc::add(L);
21295 return uc::insert(L);
21299 return default_uc::insert(L);
21319 return uc::empty(L);
21323 return default_uc::empty(L);
21331 return uc::erase(L);
21335 return default_uc::erase(L);
21356 return uc::index_of(L);
21359 return default_uc::index_of(L);
21364 return detail::typed_static_trampoline<decltype(&real_add_call), (&real_add_call)>(L);
21368 return detail::typed_static_trampoline<decltype(&real_erase_call), (&real_erase_call)>(L);
21372 return detail::typed_static_trampoline<decltype(&real_insert_call), (&real_insert_call)>(L);
21376 return detail::typed_static_trampoline<decltype(&real_clear_call), (&real_clear_call)>(L);
21380 return detail::typed_static_trampoline<decltype(&real_empty_call), (&real_empty_call)>(L);
21384 return detail::typed_static_trampoline<decltype(&real_find_call), (&real_find_call)>(L);
21388 return detail::typed_static_trampoline<decltype(&real_index_of_call), (&real_index_of_call)>(L);
21392 return detail::typed_static_trampoline<decltype(&real_length_call), (&real_length_call)>(L);
21396 return detail::typed_static_trampoline<decltype(&real_pairs_call), (&real_pairs_call)>(L);
21400 return detail::typed_static_trampoline<decltype(&real_ipairs_call), (&real_ipairs_call)>(L);
21404 return detail::typed_static_trampoline<decltype(&real_next_call), (&real_next_call)>(L);
21408 return detail::typed_static_trampoline<decltype(&real_at_call), (&real_at_call)>(L);
21412 return detail::typed_static_trampoline<decltype(&real_get_call), (&real_get_call)>(L);
21416 return detail::typed_static_trampoline<decltype(&real_set_call), (&real_set_call)>(L);
21420 return detail::typed_static_trampoline<decltype(&real_index_call), (&real_index_call)>(L);
21424 return detail::typed_static_trampoline<decltype(&real_new_index_call), (&real_new_index_call)>(L);
21430 namespace stack_detail {
21431 template <
typename T,
bool is_shim = false>
21439 using meta_usertype_container
21441 static const char* metakey
21443 static const std::array<luaL_Reg, 20> reg = { {
21445 {
"__pairs", &meta_usertype_container::pairs_call },
21446 {
"__ipairs", &meta_usertype_container::ipairs_call },
21447 {
"__len", &meta_usertype_container::length_call },
21448 {
"__index", &meta_usertype_container::index_call },
21449 {
"__newindex", &meta_usertype_container::new_index_call },
21450 {
"pairs", &meta_usertype_container::pairs_call },
21451 {
"next", &meta_usertype_container::next_call },
21452 {
"at", &meta_usertype_container::at_call },
21453 {
"get", &meta_usertype_container::get_call },
21454 {
"set", &meta_usertype_container::set_call },
21455 {
"size", &meta_usertype_container::length_call },
21456 {
"empty", &meta_usertype_container::empty_call },
21457 {
"clear", &meta_usertype_container::clear_call },
21458 {
"insert", &meta_usertype_container::insert_call },
21459 {
"add", &meta_usertype_container::add_call },
21460 {
"find", &meta_usertype_container::find_call },
21461 {
"index_of", &meta_usertype_container::index_of_call },
21462 {
"erase", &meta_usertype_container::erase_call },
21464 {
nullptr,
nullptr }
21476 template <
typename T>
21496 return push_lvalue(std::is_lvalue_reference<T>(), L, cont);
21500 return push_lvalue(std::is_lvalue_reference<T>(), L, as_cont.
value());
21504 return push_rvalue(
meta::all<std::is_rvalue_reference<T>,
meta::neg<std::is_lvalue_reference<T>>>(), L, std::forward<T>(as_cont.value()));
21508 template <
typename T>
21510 using C = std::add_pointer_t<meta::unqualified_t<std::remove_pointer_t<T>>>;
21518 template <
typename T>
21522 template <
typename... Args>
21529 template <
typename T>
21531 using C = std::add_pointer_t<meta::unqualified_t<std::remove_pointer_t<T>>>;
21545 #include <type_traits> 21548 namespace u_detail {
21591 template <
typename Arg>
21624 template <
typename T,
typename IFx,
typename Fx>
21631 lua_CFunction f = &comparsion_operator_wrap<T, std::less<>>;
21637 lua_CFunction f = &comparsion_operator_wrap<T, std::less_equal<>>;
21643 lua_CFunction f = &comparsion_operator_wrap<T, std::equal_to<>>;
21656 auto f = &default_size<T>;
21662 auto f = &detail::static_trampoline<&default_to_string<T>>;
21668 auto f = &c_call<decltype(&T::operator()), &T::operator()>;
21676 namespace stack {
namespace stack_detail {
21677 template <
typename X>
21679 using T = std::remove_pointer_t<X>;
21689 if constexpr (!std::is_pointer_v<X>) {
21714 #include <unordered_map> 21716 namespace sol {
namespace u_detail {
21718 struct usertype_storage_base;
21719 template <
typename T>
21724 template <
typename T>
21726 template <
typename T>
21744 virtual void*
data() = 0;
21749 template <
typename K,
typename Fq,
typename T =
void>
21753 #ifdef __cpp_char8_t 21754 || meta::is_c_str_of_v<uF, char8_t>
21756 || meta::is_c_str_of_v<uF, char16_t> || meta::is_c_str_of_v<uF, char32_t> || meta::is_c_str_of_v<uF, wchar_t>,
21757 std::add_pointer_t<std::add_const_t<std::remove_all_extents_t<Fq>>>, std::decay_t<Fq>>;
21760 template <
typename... Args>
21765 return static_cast<void*
>(std::addressof(data_));
21768 template <
bool is_index = true,
bool is_variable = false>
21771 auto& f = *
static_cast<F*
>(target);
21772 return call_detail::call_wrapped<T, is_index, is_variable, boost>(L, f);
21775 template <
bool is_index = true,
bool is_variable = false>
21778 return call_with_<is_index, is_variable>(L, f);
21781 template <
bool is_index = true,
bool is_variable = false>
21783 int r = detail::typed_static_trampoline<decltype(&call_<is_index, is_variable>), (&call_<is_index, is_variable>)>(L);
21784 if constexpr (meta::is_specialization_of_v<uF, yielding_t>) {
21792 template <
bool is_index = true,
bool is_variable = false>
21794 if constexpr (!is_variable) {
21796 auto& f = *
static_cast<std::decay_t<F>*
>(target);
21805 auto cfunc = &call<is_index, is_variable>;
21811 auto& f = *
static_cast<F*
>(target);
21812 return call_detail::call_wrapped<T, is_index, is_variable, boost>(L, f);
21816 template <
bool is_index = true,
bool is_variable = false>
21819 return index_call_with_<is_index, is_variable>(L, f);
21822 template <
bool is_index = true,
bool is_variable = false>
21824 int r = detail::typed_static_trampoline<decltype(&index_call_<is_index, is_variable>), (&index_call_<is_index, is_variable>)>(L);
21825 if constexpr (meta::is_specialization_of_v<uF, yielding_t>) {
21837 stack::get_field<false, true>(L, stack_reference(L,
raw_index(2)), metatarget);
21851 return luaL_error(L,
"sol: cannot set (new_index) into this object: no defined new_index operation on usertype");
21859 bool is_destruction =
false;
21860 bool is_index =
false;
21861 bool is_new_index =
false;
21862 bool is_static_index =
false;
21863 bool is_static_new_index =
false;
21864 bool poison_indexing =
false;
21865 bool is_unqualified_lua_CFunction =
false;
21866 bool is_unqualified_lua_reference =
false;
21869 lua_CFunction call_func =
nullptr;
21872 void* p_derived_usb =
nullptr;
21873 lua_CFunction idx_call =
nullptr, new_idx_call =
nullptr, meta_idx_call =
nullptr, meta_new_idx_call =
nullptr;
21881 if (smt == submetatable_type::named) {
21888 int fast_index_table_push = fast_index_table.
push();
21889 stack_reference t(L, -fast_index_table_push);
21890 if (poison_indexing) {
21891 (usb.*change_indexing)(L, smt, p_derived_usb, t, idx_call, new_idx_call, meta_idx_call, meta_new_idx_call);
21903 if (is_index || is_new_index || is_static_index || is_static_new_index) {
21909 if (is_unqualified_lua_CFunction) {
21910 stack::set_field<false, true>(L, key, call_func, t.
stack_index());
21912 else if (is_unqualified_lua_reference) {
21913 reference& binding_ref = *p_binding_ref;
21914 stack::set_field<false, true>(L, key, binding_ref, t.
stack_index());
21928 if (smt == submetatable_type::named) {
21931 int fast_index_table_push = fast_index_table.
push();
21932 stack_reference t(L, -fast_index_table_push);
21933 stack::set_field<false, true>(L, key, value, t.
stack_index());
21947 int fast_index_table_push = fast_index_table.
push();
21948 stack_reference t(L, -fast_index_table_push);
21952 (p_usb->*change_indexing)(L, smt, p_derived_usb, t, idx_call, new_idx_call, meta_idx_call, meta_new_idx_call);
21964 return binding_data == ptr->data();
21973 std::unordered_map<reference, reference, reference_hash, reference_equals>
auxiliary_keys;
21993 , value_index_table()
21994 , reference_index_table()
21995 , unique_index_table()
21996 , const_reference_index_table()
22001 , static_base_index()
22002 , is_using_index(false)
22003 , is_using_new_index(false)
22012 static_base_index.
new_index = new_index_target_set;
22015 template <
typename Fx>
22017 for (
int i = 0; i < 6; ++i) {
22018 submetatable_type smt =
static_cast<submetatable_type
>(i);
22019 reference* p_fast_index_table =
nullptr;
22021 case submetatable_type::const_value:
22022 p_fast_index_table = &this->const_value_index_table;
22025 p_fast_index_table = &this->reference_index_table;
22028 p_fast_index_table = &this->unique_index_table;
22030 case submetatable_type::const_reference:
22031 p_fast_index_table = &this->const_reference_index_table;
22033 case submetatable_type::named:
22034 p_fast_index_table = &this->named_index_table;
22038 p_fast_index_table = &this->value_index_table;
22041 fx(L, smt, *p_fast_index_table);
22046 string_keys_storage.emplace_back(
new char[sv.size()]);
22047 std::unique_ptr<char[]>& sv_storage = string_keys_storage.back();
22048 std::memcpy(sv_storage.get(), sv.data(), sv.size());
22049 string_view stored_sv(sv_storage.get(), sv.size());
22053 template <
typename T,
typename... Bases>
22056 "The size of this data pointer is too small to fit the inheritance checking function: Please file " 22059 "The size of this data pointer is too small to fit the inheritance checking function: Please file " 22062 if constexpr (
sizeof...(Bases) < 1) {
22077 for_each_fx.
p_usb =
this;
22079 for_each_fx.
change_indexing = &usertype_storage_base::change_indexing;
22081 this->for_each_table(L, for_each_fx);
22085 if (value_index_table.
valid()) {
22088 if (reference_index_table.
valid()) {
22091 if (unique_index_table.
valid()) {
22094 if (const_reference_index_table.
valid()) {
22097 if (const_value_index_table.
valid()) {
22100 if (named_index_table.
valid()) {
22103 if (type_table.
valid()) {
22106 if (gc_names_table.
valid()) {
22109 if (named_metatable.
valid()) {
22112 int named_metatable_index = pp.index_of(named_metatable);
22120 reference_index_table =
lua_nil;
22121 unique_index_table =
lua_nil;
22122 const_reference_index_table =
lua_nil;
22123 const_value_index_table =
lua_nil;
22130 string_keys.clear();
22131 auxiliary_keys.clear();
22134 template <
bool is_new_index,
typename Base>
22142 #if SOL_IS_ON(SOL_USE_UNSAFE_BASE_LOOKUP_I_) 22144 base_result = self_index_call<is_new_index, true>(
bases(), L, base_storage);
22147 if (static_cast<bool>(maybe_base_storage)) {
22148 base_result = self_index_call<is_new_index, true>(
bases(), L, *maybe_base_storage);
22151 #endif // Fast versus slow, safe base lookup 22154 template <
bool is_new_index =
false,
bool base_walking =
false,
bool from_named_metatable =
false,
typename... Bases>
22156 type k_type = stack::get<type>(L, 2);
22161 auto it =
self.string_keys.find(k);
22162 if (it !=
self.string_keys.cend()) {
22163 target = &it->second;
22166 if (target !=
nullptr) {
22168 if constexpr (is_new_index) {
22179 stack_reference k = stack::get<stack_reference>(L, 2);
22180 auto it =
self.auxiliary_keys.find(k);
22181 if (it !=
self.auxiliary_keys.cend()) {
22182 target = &it->second;
22185 if (target !=
nullptr) {
22186 if constexpr (is_new_index) {
22200 bool keep_going =
true;
22204 (
void)
detail::swallow { 1, (base_walk_index<is_new_index, Bases>(L,
self, keep_going, base_result), 1)... };
22205 if constexpr (
sizeof...(Bases) > 0) {
22207 return base_result;
22210 if constexpr (base_walking) {
22215 else if constexpr (from_named_metatable) {
22216 if constexpr (is_new_index) {
22217 return self.static_base_index.new_index(L,
self.static_base_index.
new_binding_data);
22220 return self.static_base_index.index(L,
self.static_base_index.
binding_data);
22224 if constexpr (is_new_index) {
22228 return self.base_index.index(L,
self.base_index.
binding_data);
22234 lua_CFunction
new_index, lua_CFunction meta_index, lua_CFunction meta_new_index) {
22236 void* base_this =
static_cast<void*
>(&this_base);
22238 this->is_using_index |=
true;
22239 this->is_using_new_index |=
true;
22240 if (submetatable == submetatable_type::named) {
22242 stack_reference stack_metametatable(L, -named_metatable.
push());
22243 stack::set_field<false, true>(L,
22246 stack_metametatable.stack_index());
22247 stack::set_field<false, true>(L,
22250 stack_metametatable.stack_index());
22251 stack_metametatable.pop();
22254 stack::set_field<false, true>(
22256 stack::set_field<false, true>(
22261 template <
typename T =
void,
typename Key,
typename Value>
22271 template <
typename T>
22274 using usertype_storage_base::usertype_storage_base;
22276 template <
bool is_new_index,
bool from_named_metatable>
22280 return self_index_call<is_new_index, false, from_named_metatable>(
bases(), L,
self);
22283 template <
bool is_new_index,
bool from_named_metatable,
typename... Bases>
22287 return self_index_call<is_new_index, false, from_named_metatable>(
bases(), L,
self);
22290 template <
bool is_new_index>
22292 return detail::static_trampoline<&index_call_<is_new_index, false>>(L);
22295 template <
bool is_new_index,
typename... Bases>
22300 template <
bool is_new_index>
22302 return detail::static_trampoline<&index_call_<is_new_index, true>>(L);
22305 template <
bool is_new_index,
typename... Bases>
22310 template <
typename Key,
typename Value>
22314 template <
typename T>
22316 return detail::user_alloc_destruct<usertype_storage<T>>(L);
22319 template <
typename T,
typename Key,
typename Value>
22325 if constexpr (std::is_same_v<KeyU, call_construction>) {
22327 std::unique_ptr<Binding> p_binding = std::make_unique<Binding>(std::forward<Value>(
value));
22328 Binding& b = *p_binding;
22331 this->named_index_table.push();
22335 lua_CFunction target_func = &b.template call<false, false>;
22338 this->named_index_table.pop();
22340 else if constexpr (std::is_same_v<KeyU, base_classes_tag>) {
22342 this->update_bases<T>(L, std::forward<Value>(
value));
22346 auto storage_it = this->
storage.end();
22347 auto string_it = this->string_keys.find(s);
22348 if (string_it != this->string_keys.cend()) {
22349 const auto& binding_data = string_it->second.binding_data;
22351 this->string_keys.erase(string_it);
22354 std::unique_ptr<Binding> p_binding = std::make_unique<Binding>(std::forward<Value>(
value));
22355 Binding& b = *p_binding;
22356 if (storage_it != this->
storage.cend()) {
22368 bool poison_indexing = (!is_using_index || !is_using_new_index) && (
is_var_bind::value || is_index || is_new_index);
22372 ics.
index = is_index || is_static_index ? &Binding::template call_with_<true, is_var_bind::value>
22373 : &Binding::template index_call_with_<true, is_var_bind::value>;
22374 ics.
new_index = is_new_index || is_static_new_index ? &Binding::template call_with_<false, is_var_bind::value>
22375 : &Binding::template index_call_with_<false, is_var_bind::value>;
22384 for_each_fx.
p_key = &s;
22385 for_each_fx.
p_ics = &ics;
22386 if constexpr (is_lua_c_function_v<ValueU>) {
22390 else if constexpr (is_lua_reference_or_proxy_v<ValueU>) {
22395 for_each_fx.
call_func = &b.template call<false, is_var_bind::value>;
22397 for_each_fx.
p_usb =
this;
22403 for_each_fx.
change_indexing = &usertype_storage_base::change_indexing;
22407 this->base_index.index = ics.
index;
22410 if (is_new_index) {
22411 this->base_index.new_index = ics.
new_index;
22414 if (is_static_index) {
22415 this->static_base_index.index = ics.
index;
22416 this->static_base_index.binding_data = ics.
binding_data;
22418 if (is_static_new_index) {
22419 this->static_base_index.new_index = ics.
new_index;
22420 this->static_base_index.new_binding_data = ics.
binding_data;
22422 this->for_each_table(L, for_each_fx);
22428 if constexpr (is_lua_reference_v<KeyU> && is_lua_reference_v<ValueU>) {
22431 std::string string_key = stack::pop<std::string>(L);
22432 this->set<T>(L, string_key, std::forward<Value>(
value));
22437 this->for_each_table(L, ref_additions_fx);
22438 this->auxiliary_keys.insert_or_assign(std::forward<Key>(key), std::forward<Value>(value));
22446 this->for_each_table(L, ref_additions_fx);
22452 template <
typename T>
22453 template <
typename Key,
typename Value>
22458 template <
typename T>
22464 int usertype_storage_push_count = stack::push<user<usertype_storage<T>>>(L,
no_metatable, L);
22465 stack_reference usertype_storage_ref(L, -usertype_storage_push_count);
22471 stack_reference usertype_storage_metatable(L, -usertype_storage_metatabe_count);
22476 usertype_storage_metatable.
pop();
22480 stack::set_field<true>(L, gcmetakey, usertype_storage_ref);
22481 usertype_storage_ref.pop();
22485 stack::get_field<true>(L, gcmetakey);
22495 usertype_storage_base& target_umt = stack::stack_detail::unchecked_unqualified_get<user<usertype_storage_base>>(L, -1, tracking);
22500 stack::get_field<true>(L, gcmetakey);
22503 return maybe_storage;
22507 stack::get_field<true>(L, gcmetakey);
22509 usertype_storage_base& target_umt = stack::stack_detail::unchecked_unqualified_get<user<usertype_storage_base>>(L, -1, tracking);
22514 template <
typename T>
22517 stack::get_field<true>(L, gcmetakey);
22526 template <
typename T>
22529 stack::get_field<true>(L, gcmetakey);
22534 template <
typename T>
22545 const char* gcmetakey = &u_traits::gc_table()[0];
22546 stack::get_field<true>(L, gcmetakey);
22552 target_umt.
clear();
22568 #endif // Registry Cleanout 22570 stack::set_field<true>(L, gcmetakey,
lua_nil);
22573 template <
typename T>
22616 delete_usertype_storage<T>(L);
22624 void* light_storage =
static_cast<void*
>(&
storage);
22625 void* light_base_storage =
static_cast<void*
>(&base_storage);
22628 storage.gc_names_table.push();
22629 stack_reference gnt(L, -1);
22639 stack_reference stacked_type_table(L, -storage.type_table.push());
22640 stack::set_field(L,
"name", detail::demangle<T>(), stacked_type_table.stack_index());
22641 stack::set_field(L,
"is", &detail::is_check<T>, stacked_type_table.stack_index());
22642 stacked_type_table.pop();
22648 int for_each_backing_metatable_calls = 0;
22649 auto for_each_backing_metatable = [&](
lua_State* L, submetatable_type smt,
reference& fast_index_table) {
22651 const char* metakey =
nullptr;
22653 case submetatable_type::const_value:
22662 case submetatable_type::const_reference:
22665 case submetatable_type::named:
22666 metakey = &u_traits::user_metatable()[0];
22675 if (smt == submetatable_type::named) {
22678 storage.named_metatable =
reference(L, -1);
22685 stack_reference t(L, -1);
22688 if constexpr (std::is_destructible_v<T>) {
22692 case submetatable_type::const_reference:
22694 case submetatable_type::named:
22700 case submetatable_type::const_value:
22711 case submetatable_type::const_reference:
22713 case submetatable_type::named:
22719 case submetatable_type::const_value:
22727 "The size of this data pointer is too small to fit the inheritance checking function: file a bug " 22730 "The size of this data pointer is too small to fit the inheritance checking function: file a bug " 22737 stack::set_field<false, true>(L, mf, reg, t.stack_index());
22738 storage.properties[
static_cast<int>(mf)] =
true;
22740 detail::insert_default_registrations<T>(insert_fx, prop_fx);
22745 if (smt == submetatable_type::named) {
22752 absolute_index named_metatable_index(L, -storage.named_metatable.push());
22753 stack::set_field<false, true>(L,
metatable_key, t, named_metatable_index);
22754 storage.named_metatable.pop();
22756 stack_reference stack_metametatable(L, -storage.named_index_table.push());
22757 stack::set_field<false, true>(L,
22760 stack_metametatable.stack_index());
22761 stack::set_field<false, true>(L,
22764 stack_metametatable.stack_index());
22765 stack_metametatable.pop();
22771 stack::set_field<false, true>(L,
22775 storage.is_using_new_index =
true;
22778 ++for_each_backing_metatable_calls;
22783 storage.for_each_table(L, for_each_backing_metatable);
22786 if constexpr (std::is_default_constructible_v<T>) {
22787 if (enrollments.default_constructor) {
22793 storage.named_metatable.push();
22803 template <
typename Table,
typename Key>
22808 template <
typename T, std::size_t... I>
22809 decltype(
auto) tuple_get(
std::index_sequence<I...>) const & {
22810 return tbl.template traverse_get<T>(std::get<I>(key)...);
22813 template <
typename T, std::size_t... I>
22814 decltype(
auto) tuple_get(
std::index_sequence<I...>) && {
22815 return tbl.template traverse_get<T>(std::get<I>(
std::move(key))...);
22818 template <std::size_t... I,
typename T>
22820 if constexpr (
sizeof...(I) > 1) {
22821 tbl.traverse_set(std::get<I>(key)..., std::forward<T>(
value));
22824 tbl.set(std::get<I>(key)..., std::forward<T>(
value));
22828 template <std::size_t... I,
typename T>
22830 if constexpr (
sizeof...(I) > 1) {
22831 tbl.traverse_set(std::get<I>(
std::move(key))..., std::forward<T>(
value));
22834 tbl.set(std::get<I>(
std::move(key))..., std::forward<T>(
value));
22842 template <
typename T>
22844 : tbl(table), key(
std::forward<T>(k)) {
22847 template <
typename T>
22849 using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
22850 tuple_set(idx_seq(), std::forward<T>(item));
22854 template <
typename T>
22856 using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
22857 std::move(*this).tuple_set(idx_seq(), std::forward<T>(item));
22861 template <
typename T>
22863 return set(std::forward<T>(other));
22866 template <
typename T>
22868 return std::move(*this).set(std::forward<T>(other));
22871 template <
typename T>
22876 template <
typename T>
22881 template <
typename T>
22883 using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
22884 return tuple_get<T>(idx_seq());
22887 template <
typename T>
22889 using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
22890 return std::move(*this).template tuple_get<T>(idx_seq());
22893 template <
typename K>
22894 decltype(
auto) operator[](K&& k) const& {
22899 template <
typename K>
22900 decltype(
auto) operator[](K&& k) & {
22905 template <
typename K>
22906 decltype(
auto) operator[](K&& k) && {
22911 template <
typename... Ret,
typename... Args>
22913 #if !defined(__clang__) && defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 191200000 22915 return get<function>().call<Ret...>(std::forward<Args>(args)...);
22917 return get<function>().
template call<Ret...>(std::forward<Args>(args)...);
22921 template <
typename... Args>
22922 decltype(
auto) operator()(Args&&... args) {
22923 return call<>(std::forward<Args>(args)...);
22928 auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>,
global_table>::value>(lua_state(), key,
lua_gettop(lua_state()));
22929 lua_pop(lua_state(), p.levels);
22934 return push(this->lua_state());
22938 return get<reference>().
push(L);
22944 auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>,
global_table>::value>(lua_state(), key,
lua_gettop(lua_state()));
22946 t =
type_of(lua_state(), -1);
22948 lua_pop(lua_state(), p.levels);
22953 return tbl.lua_state();
22968 template <
typename Table,
typename Key>
22973 template <
typename T, std::size_t... I>
22974 decltype(
auto) tuple_get(
std::index_sequence<I...>) const& {
22975 return tbl.template traverse_get<T>(std::get<I>(key)...);
22978 template <
typename T, std::size_t... I>
22979 decltype(
auto) tuple_get(
std::index_sequence<I...>) && {
22980 return tbl.template traverse_get<T>(std::get<I>(
std::move(key))...);
22983 template <std::size_t... I,
typename T>
22985 tbl.traverse_set(std::get<I>(key)..., std::forward<T>(
value));
22988 template <std::size_t... I,
typename T>
22990 tbl.traverse_set(std::get<I>(
std::move(key))..., std::forward<T>(
value));
22994 auto p = stack::probe_get_field<std::is_same_v<meta::unqualified_t<Table>,
global_table>>(lua_state(), key, tbl.stack_index());
22995 lua_pop(lua_state(), p.levels);
23001 auto p = stack::probe_get_field<std::is_same_v<meta::unqualified_t<Table>,
global_table>>(lua_state(), key,
lua_gettop(lua_state()));
23002 lua_pop(lua_state(), p.levels);
23010 template <
typename T>
23014 template <
typename T>
23020 template <
typename T>
23026 template <
typename... Args>
23028 tbl.set_function(key, std::forward<Args>(args)...);
23032 template <
typename... Args>
23034 tbl.set_function(
std::move(key), std::forward<Args>(args)...);
23038 template <
typename T>
23041 if constexpr (!is_lua_reference_or_proxy_v<Tu> && meta::is_callable_v<Tu>) {
23042 return set_function(std::forward<T>(other));
23045 return set(std::forward<T>(other));
23049 template <
typename T>
23052 if constexpr (!is_lua_reference_or_proxy_v<Tu> && meta::is_callable_v<Tu>) {
23053 return std::move(*this).set_function(std::forward<T>(other));
23056 return std::move(*this).set(std::forward<T>(other));
23060 template <
typename T>
23065 template <
typename T>
23070 template <
typename T>
23072 using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
23073 return tuple_get<T>(idx_seq());
23076 template <
typename T>
23078 using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
23079 return std::move(*this).template tuple_get<T>(idx_seq());
23082 template <
typename T>
23083 decltype(
auto) get_or(T&& otherwise)
const {
23084 typedef decltype(get<T>()) U;
23087 return static_cast<U
>(option.
value());
23089 return static_cast<U
>(std::forward<T>(otherwise));
23092 template <
typename T,
typename D>
23093 decltype(
auto) get_or(D&& otherwise)
const {
23096 return static_cast<T
>(option.
value());
23098 return static_cast<T
>(std::forward<D>(otherwise));
23101 template <
typename T>
23102 decltype(
auto) get_or_create() {
23106 template <
typename T,
typename Otherwise>
23107 decltype(
auto) get_or_create(Otherwise&& other) {
23108 if (!this->valid()) {
23109 this->
set(std::forward<Otherwise>(other));
23114 template <
typename K>
23115 decltype(
auto) operator[](K&& k) const& {
23120 template <
typename K>
23121 decltype(
auto) operator[](K&& k) & {
23126 template <
typename K>
23127 decltype(
auto) operator[](K&& k) && {
23132 template <
typename... Ret,
typename... Args>
23138 return func.
call<Ret...>(std::forward<Args>(args)...);
23141 template <
typename... Args>
23142 decltype(
auto) operator()(Args&&... args) {
23143 return call<>(std::forward<Args>(args)...);
23148 auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>,
global_table>::value>(lua_state(), key,
lua_gettop(lua_state()));
23149 lua_pop(lua_state(), p.levels);
23154 return push(this->lua_state());
23159 auto pp = stack::push_pop<true>(tbl);
23160 int tableindex = pp.index_of(tbl);
23162 stack::get_field<true>(lua_state(), key, tableindex);
23167 auto pp = stack::push_pop<false>(tbl);
23168 int tableindex = pp.index_of(tbl);
23170 stack::get_field<false>(lua_state(), key, tableindex);
23180 auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>,
global_table>::value>(lua_state(), key,
lua_gettop(lua_state()));
23182 t =
type_of(lua_state(), -1);
23184 lua_pop(lua_state(), p.levels);
23189 return tbl.lua_state();
23193 if (!this->valid()) {
23200 template <
typename Table,
typename Key,
typename T>
23202 using G = decltype(stack::get<T>(
nullptr, 0));
23203 return right.template get<optional<G>>() ==
left;
23206 template <
typename Table,
typename Key,
typename T>
23208 using G = decltype(stack::get<T>(
nullptr, 0));
23209 return right.template get<optional<G>>() ==
left;
23212 template <
typename Table,
typename Key,
typename T>
23214 using G = decltype(stack::get<T>(
nullptr, 0));
23215 return right.template get<optional<G>>() !=
left;
23218 template <
typename Table,
typename Key,
typename T>
23220 using G = decltype(stack::get<T>(
nullptr, 0));
23221 return right.template get<optional<G>>() !=
left;
23224 template <
typename Table,
typename Key>
23226 return !right.
valid();
23229 template <
typename Table,
typename Key>
23231 return !right.
valid();
23234 template <
typename Table,
typename Key>
23236 return right.
valid();
23239 template <
typename Table,
typename Key>
23241 return right.
valid();
23245 template <
typename Super>
23253 template <
typename Super>
23261 template <
typename Table,
typename Key>
23274 #include <iterator> 23278 template <
typename reference_type>
23295 std::ptrdiff_t idx = 0;
23305 this->operator++();
23316 if (
lua_next(ref.lua_state(), tableidx) == 0) {
23322 kvp.first =
object(ref.lua_state(), -2);
23323 kvp.second =
object(ref.lua_state(), -1);
23331 auto saved = *
this;
23332 this->operator++();
23345 return idx == right.
idx;
23349 return idx != right.
idx;
23353 if (keyidx != -1) {
23356 if (ref.lua_state() !=
nullptr && ref.valid()) {
23368 template <std::
size_t n>
23374 lua_pop(L, static_cast<int>(n));
23384 lua_pop(L, static_cast<int>(n));
23389 return luaL_error(L,
"sol: cannot modify the elements of an enumeration table");
23394 template <
bool top_level,
typename ref_t>
23401 template <
typename,
typename>
23403 template <
typename>
23406 template <
bool raw,
typename... Ret,
typename... Keys>
23407 decltype(
auto) tuple_get(
int table_index, Keys&&... keys)
const {
23408 if constexpr (
sizeof...(Ret) < 2) {
23409 return traverse_get_single_maybe_tuple<raw, Ret...>(table_index, std::forward<Keys>(keys)...);
23412 using multi_ret = decltype(
stack::pop<std::tuple<Ret...>>(
nullptr));
23413 return multi_ret(traverse_get_single_maybe_tuple<raw, Ret>(table_index, std::forward<Keys>(keys))...);
23417 template <
bool raw,
typename Ret,
size_t... I,
typename Key>
23418 decltype(
auto) traverse_get_single_tuple(
int table_index,
std::index_sequence<I...>, Key&& key)
const {
23419 return traverse_get_single<raw, Ret>(table_index, std::get<I>(std::forward<Key>(key))...);
23422 template <
bool raw,
typename Ret,
typename Key>
23423 decltype(
auto) traverse_get_single_maybe_tuple(
int table_index, Key&& key)
const {
23425 return traverse_get_single_tuple<raw, Ret>(
23426 table_index, std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<Key>>>(), std::forward<Key>(key));
23429 return traverse_get_single<raw, Ret>(table_index, std::forward<Key>(key));
23433 template <
bool raw,
typename Ret,
typename... Keys>
23434 decltype(
auto) traverse_get_single(
int table_index, Keys&&... keys)
const {
23435 constexpr
static bool global = top_level && (meta::count_for_to_pack_v<1, meta::is_c_str, meta::unqualified_t<Keys>...> > 0);
23439 return traverse_get_deep_optional<global, raw, detail::insert_mode::none, Ret>(popcount, table_index, std::forward<Keys>(keys)...);
23443 return traverse_get_deep<global, raw, detail::insert_mode::none, Ret>(table_index, std::forward<Keys>(keys)...);
23447 template <
bool raw,
typename Pairs, std::size_t... I>
23449 constexpr
static bool global = top_level
23450 && (meta::count_even_for_pack_v<meta::is_c_str, meta::unqualified_t<decltype(std::get<I * 2>(std::forward<Pairs>(
pairs)))>...> > 0);
23451 auto pp = stack::push_pop<global>(*this);
23452 int table_index = pp.index_of(*
this);
23457 L, std::get<I * 2>(std::forward<Pairs>(
pairs)), std::get<I * 2 + 1>(std::forward<Pairs>(
pairs)), table_index),
23462 decltype(
auto) traverse_get_deep(
int table_index, Key&& key, Keys&&... keys)
const {
23466 table_index, std::forward<Keys>(keys)...);
23470 stack::get_field<global, raw>(L, std::forward<Key>(key), table_index);
23471 if constexpr (
sizeof...(Keys) > 0) {
23479 return traverse_get_deep<false, raw, mode, T>(
lua_gettop(L), std::forward<Keys>(keys)...);
23489 return stack::get<T>(L);
23495 decltype(
auto) traverse_get_deep_optional(
int& popcount,
int table_index, Key&& key, Keys&&... keys)
const {
23499 return traverse_get_deep_optional<global, raw, new_mode, T>(popcount, table_index, std::forward<Keys>(keys)...);
23504 return traverse_get_deep_optional<global, raw, new_mode, T>(popcount, table_index, std::forward<Keys>(keys)...);
23509 return traverse_get_deep_optional<global, raw, new_mode, T>(popcount, table_index, std::forward<Keys>(keys)...);
23512 if constexpr (
sizeof...(Keys) > 0) {
23514 auto p = stack::probe_get_field<global, raw>(L, std::forward<Key>(key), table_index);
23515 popcount += p.levels;
23521 stack::set_field<global, raw>(L, std::forward<Key>(key),
stack_reference(L, -1), table_index);
23527 return traverse_get_deep_optional<false, raw, mode, T>(popcount,
lua_gettop(L), std::forward<Keys>(keys)...);
23530 using R = decltype(stack::get<T>(
nullptr));
23533 auto p = stack::probe_get_field<global, raw, value_type>(L, key, table_index);
23534 popcount += p.levels;
23539 stack::set_field<global, raw>(L, std::forward<Key>(key),
stack_reference(L, -1), table_index);
23541 return stack::get<T>(L);
23546 return stack::get<T>(L);
23554 if constexpr (std::is_same_v<KeyU, update_if_empty_t>) {
23557 table_index, std::forward<Keys>(keys)...);
23559 else if constexpr (std::is_same_v<KeyU, create_if_nil_t>) {
23562 table_index, std::forward<Keys>(keys)...);
23564 else if constexpr (std::is_same_v<KeyU, override_value_t>) {
23567 table_index, std::forward<Keys>(keys)...);
23571 if constexpr (
sizeof...(Keys) == 1) {
23573 auto p = stack::probe_get_field<global, raw>(L, key, table_index);
23576 stack::set_field<global, raw>(L, std::forward<Key>(key), std::forward<Keys>(keys)..., table_index);
23580 stack::set_field<global, raw>(L, std::forward<Key>(key), std::forward<Keys>(keys)..., table_index);
23585 stack::get_field<global, raw>(L, key, table_index);
23593 stack::set_field<global, raw>(L, std::forward<Key>(key),
stack_reference(L, -1), table_index);
23601 stack::set_field<global, raw>(L, std::forward<Key>(key),
stack_reference(L, -1), table_index);
23606 stack::get_field<global, raw>(L, std::forward<Key>(key), table_index);
23608 traverse_set_deep<false, raw, mode>(
lua_gettop(L), std::forward<Keys>(keys)...);
23623 template <
typename T,
23625 meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> =
meta::enabler>
23628 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
23636 using base_t::lua_state;
23638 basic_table_core() noexcept = default;
23639 basic_table_core(const basic_table_core&) = default;
23640 basic_table_core(basic_table_core&&) = default;
23641 basic_table_core& operator=(const basic_table_core&) = default;
23642 basic_table_core& operator=(basic_table_core&&) = default;
23643 basic_table_core(const
stack_reference& r) : basic_table_core(r.lua_state(), r.stack_index()) {
23647 template <
typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
23649 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 23651 int table_index = pp.index_of(*
this);
23653 stack::check<basic_table_core>(lua_state(), table_index,
handler);
23662 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 23668 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 23670 int table_index = pp.index_of(*
this);
23672 stack::check<basic_table_core>(lua_state(), table_index,
handler);
23675 template <
typename T,
23676 meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_table_core>>, meta::neg<std::is_same<ref_t, stack_reference>>,
23677 meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> =
meta::enabler>
23679 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 23682 int table_index = pp.index_of(*
this);
23684 stack::check<basic_table_core>(lua_state(), table_index,
handler);
23711 auto pp = stack::push_pop<false>(*this);
23712 int table_index = pp.index_of(*
this);
23716 template <
typename... Ret,
typename... Keys>
23717 decltype(
auto)
get(Keys&&... keys)
const {
23718 static_assert(
sizeof...(Keys) ==
sizeof...(Ret),
"number of keys and number of return types do not match");
23720 auto pp = stack::push_pop<global>(*this);
23721 int table_index = pp.index_of(*
this);
23722 return tuple_get<
false, Ret...>(table_index, std::forward<Keys>(keys)...);
23725 template <
typename T,
typename Key>
23726 decltype(
auto) get_or(Key&& key, T&& otherwise)
const {
23727 typedef decltype(get<T>(
"")) U;
23728 optional<U> option = get<optional<U>>(std::forward<Key>(key));
23730 return static_cast<U
>(option.
value());
23732 return static_cast<U
>(std::forward<T>(otherwise));
23735 template <
typename T,
typename Key,
typename D>
23736 decltype(
auto) get_or(Key&& key, D&& otherwise)
const {
23737 optional<T> option = get<optional<T>>(std::forward<Key>(key));
23739 return static_cast<T
>(option.
value());
23741 return static_cast<T
>(std::forward<D>(otherwise));
23744 template <
typename T,
typename... Keys>
23745 decltype(
auto) traverse_get(Keys&&... keys)
const {
23746 static_assert(
sizeof...(Keys) > 0,
"must pass at least 1 key to get");
23747 constexpr
static bool global = top_level && (meta::count_for_to_pack_v<1, meta::is_c_str, meta::unqualified_t<Keys>...> > 0);
23748 auto pp = stack::push_pop<global>(*this);
23749 int table_index = pp.index_of(*
this);
23750 return traverse_get_single<false, T>(table_index, std::forward<Keys>(keys)...);
23753 template <
typename... Keys>
23755 static_assert(
sizeof...(Keys) > 1,
"must pass at least 1 key and 1 value to set");
23756 constexpr
static bool global
23757 = top_level && (meta::count_when_for_to_pack_v<detail::is_not_insert_mode, 1, meta::is_c_str, meta::unqualified_t<Keys>...> > 0);
23758 auto pp = stack::push_pop<global>(*this);
23759 int table_index = pp.index_of(*
this);
23762 traverse_set_deep<top_level, false, detail::insert_mode::none>(table_index, std::forward<Keys>(keys)...);
23766 template <
typename... Args>
23767 basic_table_core&
set(Args&&... args) {
23768 if constexpr (
sizeof...(Args) == 2) {
23769 traverse_set(std::forward<Args>(args)...);
23772 tuple_set<false>(std::make_index_sequence<
sizeof...(Args) / 2>(), std::forward_as_tuple(std::forward<Args>(args)...));
23777 template <
typename... Ret,
typename... Keys>
23778 decltype(
auto) raw_get(Keys&&... keys)
const {
23779 static_assert(
sizeof...(Keys) ==
sizeof...(Ret),
"number of keys and number of return types do not match");
23780 constexpr
static bool global = top_level && (meta::count_for_to_pack_v<1, meta::is_c_str, meta::unqualified_t<Keys>...> > 0);
23781 auto pp = stack::push_pop<global>(*this);
23782 int table_index = pp.index_of(*
this);
23783 return tuple_get<
true, Ret...>(table_index, std::forward<Keys>(keys)...);
23786 template <
typename T,
typename Key>
23787 decltype(
auto) raw_get_or(Key&& key, T&& otherwise)
const {
23788 typedef decltype(raw_get<T>(
"")) U;
23789 optional<U> option = raw_get<optional<U>>(std::forward<Key>(key));
23791 return static_cast<U
>(option.
value());
23793 return static_cast<U
>(std::forward<T>(otherwise));
23796 template <
typename T,
typename Key,
typename D>
23797 decltype(
auto) raw_get_or(Key&& key, D&& otherwise)
const {
23798 optional<T> option = raw_get<optional<T>>(std::forward<Key>(key));
23800 return static_cast<T
>(option.
value());
23802 return static_cast<T
>(std::forward<D>(otherwise));
23805 template <
typename T,
typename... Keys>
23806 decltype(
auto) traverse_raw_get(Keys&&... keys)
const {
23807 constexpr
static bool global = top_level && (meta::count_for_to_pack_v<1, meta::is_c_str, meta::unqualified_t<Keys>...> > 0);
23808 auto pp = stack::push_pop<global>(*this);
23809 int table_index = pp.index_of(*
this);
23810 return traverse_get_single<true, T>(table_index, std::forward<Keys>(keys)...);
23813 template <
typename... Keys>
23815 constexpr
static bool global = top_level && (meta::count_for_to_pack_v<1, meta::is_c_str, meta::unqualified_t<Keys>...> > 0);
23816 auto pp = stack::push_pop<global>(*this);
23819 traverse_set_deep<top_level, true, false>(std::forward<Keys>(keys)...);
23823 template <
typename... Args>
23825 tuple_set<true>(std::make_index_sequence<
sizeof...(Args) / 2>(), std::forward_as_tuple(std::forward<Args>(args)...));
23829 template <
typename Class,
typename Key>
23832 template <
typename Class,
typename Key>
23835 template <
typename Class,
typename Key,
typename Arg,
typename... Args,
23839 template <
bool read_only =
true,
typename... Args>
23841 table target = create_with(std::forward<Args>(args)...);
23853 template <
typename T,
bool read_only = true>
23855 table target =
create(static_cast<int>(items.size()), static_cast<int>(0));
23856 for (
const auto& kvp : items) {
23857 target.
set(kvp.first, kvp.second);
23859 if constexpr (read_only) {
23870 template <
typename Key =
object,
typename Value =
object,
typename Fx>
23873 if constexpr (std::is_invocable_v<Fx, Key, Value>) {
23875 int table_index = pp.index_of(*
this);
23877 while (
lua_next(L, table_index)) {
23886 int table_index = pp.index_of(*
this);
23888 while (
lua_next(L, table_index)) {
23892 std::pair<Key&, Value&> keyvalue(key, value);
23900 int table_index = pp.index_of(*
this);
23903 return stack::pop<size_t>(L);
23907 return cbegin() == cend();
23910 template <
typename T>
23915 template <
typename T>
23920 template <
typename T>
23925 template <
typename Sig,
typename Key,
typename... Args>
23927 set_fx(
types<Sig>(), std::forward<Key>(key), std::forward<Args>(args)...);
23931 template <
typename Key,
typename... Args>
23933 set_fx(
types<>(), std::forward<Key>(key), std::forward<Args>(args)...);
23937 template <
typename... Args>
23938 basic_table_core&
add(Args&&... args) {
23940 int table_index = pp.index_of(*
this);
23947 template <
typename R,
typename... Args,
typename Fx,
typename Key,
typename =
std::invoke_result_t<Fx, Args...>>
23949 set_resolved_function<R(Args...)>(std::forward<Key>(key), std::forward<Fx>(fx));
23952 template <
typename Fx,
typename Key, meta::enable<meta::is_specialization_of<meta::unqualified_t<Fx>, overload_set>> = meta::enabler>
23954 set(std::forward<Key>(key), std::forward<Fx>(fx));
23957 template <
typename Fx,
typename Key,
typename... Args,
23960 set(std::forward<Key>(key),
as_function_reference(std::forward<Fx>(fx), std::forward<Args>(args)...));
23963 template <
typename... Sig,
typename... Args,
typename Key>
23976 template <
typename Key,
typename Value,
typename... Args>
23980 result.
set(std::forward<Key>(key), std::forward<Value>(
value), std::forward<Args>(args)...);
23985 template <
typename... Args>
23987 static_assert(
sizeof...(Args) % 2 == 0,
"You must have an even number of arguments for a key, value ... list.");
23989 return create(L, narr, static_cast<int>((
sizeof...(Args) / 2) - narr), std::forward<Args>(args)...);
23993 return create(base_t::lua_state(), narr, nrec);
23996 template <
typename Key,
typename Value,
typename... Args>
23998 return create(base_t::lua_state(), narr, nrec, std::forward<Key>(key), std::forward<Value>(
value), std::forward<Args>(args)...);
24001 template <
typename Name>
24003 table x =
create(base_t::lua_state(), narr, nrec);
24004 this->
set(std::forward<Name>(
name), x);
24008 template <
typename Name,
typename Key,
typename Value,
typename... Args>
24010 table x =
create(base_t::lua_state(), narr, nrec, std::forward<Key>(key), std::forward<Value>(
value), std::forward<Args>(args)...);
24011 this->
set(std::forward<Name>(
name), x);
24015 template <
typename... Args>
24017 return create_with(base_t::lua_state(), std::forward<Args>(args)...);
24020 template <
typename Name,
typename... Args>
24023 return create(std::forward<Name>(name), narr, (
sizeof...(Args) / 2) - narr, std::forward<Args>(args)...);
24032 template <
typename base_type>
24045 template <
typename T,
24046 meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>,
basic_metatable>>, meta::neg<std::is_same<base_type, stack_reference>>,
24047 meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> =
meta::enabler>
24050 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
24055 using base_t::lua_state;
24057 basic_metatable() noexcept =
default;
24058 basic_metatable(
const basic_metatable&) =
default;
24059 basic_metatable(basic_metatable&&) =
default;
24060 basic_metatable& operator=(
const basic_metatable&) =
default;
24061 basic_metatable& operator=(basic_metatable&&) =
default;
24066 template <
typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
24068 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24071 stack::check<basic_metatable>(lua_state(), -1,
handler);
24075 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24081 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24084 stack::check<basic_metatable>(lua_state(), -1,
handler);
24087 template <
typename T,
24088 meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_metatable>>, meta::neg<std::is_same<base_type, stack_reference>>,
24089 meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> =
meta::enabler>
24091 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24095 stack::check<basic_metatable>(base_t::lua_state(), -1,
handler);
24102 template <
typename Key,
typename Value>
24123 ustorage_base& base_storage = *
static_cast<ustorage_base*
>(stack::get<void*>(L, -1));
24124 std::array<string_view, 6> registry_traits;
24125 for (std::size_t i = 0; i < registry_traits.size(); ++i) {
24127 stack::get_field<false, true>(L, smt, gc_names_table.
stack_index());
24128 registry_traits[i] = stack::get<string_view>(L, -1);
24138 for (std::size_t i = 0; i < registry_traits.size(); ++i) {
24140 const string_view& gcmetakey = registry_traits[i];
24144 stack::set_field<true>(L, gcmetakey.data(),
lua_nil);
24154 base_storage.clear();
24172 template <
typename T,
typename base_type>
24178 template <
typename>
24181 template <
bool,
typename>
24184 template <std::size_t... I,
typename... Args>
24185 void tuple_set(std::index_sequence<I...>, std::tuple<Args...>&& args) {
24188 (this->
set(std::get<I * 2>(
std::move(args)), std::get<I * 2 + 1>(
std::move(args))), 0)... };
24192 using base_t::base_t;
24196 using base_t::lua_state;
24198 using base_t::set_function;
24199 using base_t::traverse_set;
24200 using base_t::traverse_get;
24201 using base_t::unregister;
24203 template <
typename Key,
typename Value>
24208 uts.
set(this->lua_state(), std::forward<Key>(key), std::forward<Value>(
value));
24213 if constexpr (detail::is_non_factory_constructor_v<ValueU> || detail::is_policy_v<ValueU>) {
24218 table_base_t::set(std::forward<Key>(key), std::forward<Value>(
value));
24223 template <
typename Key>
24228 template <
typename Key>
24244 template <
typename ref_t>
24253 using base_t::lua_state;
24264 template <
typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
24266 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24269 stack::check<basic_lua_table>(lua_state(), -1,
handler);
24278 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24284 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24287 stack::check<basic_lua_table>(lua_state(), -1,
handler);
24290 template <
typename T,
24292 meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> =
meta::enabler>
24294 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24298 stack::check<basic_lua_table>(lua_state(), -1,
handler);
24313 template <
bool is_global,
typename base_type>
24314 template <
typename Class,
typename Key>
24317 return this->new_usertype<Class>(std::forward<Key>(key),
std::move(enrollments));
24320 template <
bool is_global,
typename base_type>
24321 template <
typename Class,
typename Key>
24323 int mt_index = u_detail::register_usertype<Class>(this->lua_state(),
std::move(enrollments));
24325 lua_pop(this->lua_state(), 1);
24326 set(std::forward<Key>(key), mt);
24330 template <
bool is_global,
typename base_type>
24331 template <
typename Class,
typename Key,
typename Arg,
typename... Args,
typename>
24337 static_assert(
sizeof...(Args) % 2 == static_cast<std::size_t>(!detail::any_is_constructor_v<Arg>),
24338 "you must pass an even number of arguments to new_usertype after first passing a constructor");
24339 if constexpr (detail::any_is_constructor_v<Arg>) {
24341 ut.
tuple_set(std::make_index_sequence<(
sizeof...(Args)) / 2>(), std::forward_as_tuple(std::forward<Args>(args)...));
24344 ut.
tuple_set(std::make_index_sequence<(
sizeof...(Args) + 1) / 2>(), std::forward_as_tuple(std::forward<Arg>(
arg), std::forward<Args>(args)...));
24349 template <
typename base_type>
24350 template <
typename Key,
typename Value>
24359 uts.
set(L, std::forward<Key>(key), std::forward<Value>(
value));
24362 base_t::set(std::forward<Key>(key), std::forward<Value>(
value));
24373 return table(L, -1);
24389 template <
typename base_type>
24395 using base_t::lua_state;
24419 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24421 stack::check<env_key_t>(this->lua_state(), -1,
handler);
24423 lua_pop(this->lua_state(), 2);
24428 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24430 stack::check<env_key_t>(this->lua_state(), -1,
handler);
24432 lua_pop(this->lua_state(), 2);
24435 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24441 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24444 stack::check<basic_environment>(L, -1,
handler);
24447 template <
typename T,
24448 meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>,
basic_environment>>, meta::neg<std::is_same<base_type, stack_reference>>,
24449 meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> =
meta::enabler>
24451 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24455 stack::check<basic_environment>(lua_state(), -1,
handler);
24462 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
24464 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 24468 stack::check<basic_environment>(lua_state(), -1,
handler);
24473 template <
typename T>
24477 #if SOL_LUA_VESION_I_ < 502 24480 lua_setfenv(L, -2);
24485 if (name ==
nullptr) {
24492 template <
typename T,
typename E>
24497 template <
typename E = reference,
typename T>
24517 return static_cast<bool>(env);
24529 return env.
value();
24533 return env.
value();
24567 if (!env.valid()) {
24595 : L(Ls), index(stackindex), returncount(retnum), popcount(popnum), err(lerr) {
24618 returncount = o.returncount;
24619 popcount = o.popcount;
24640 template <
typename T>
24643 if constexpr (meta::is_optional_v<UT>) {
24644 using ValueType =
typename UT::value_type;
24645 if constexpr (std::is_same_v<ValueType, error>) {
24655 return stack::get<UT>(L,
index);
24659 if constexpr (std::is_same_v<T, error>) {
24660 #if SOL_IS_ON(SOL_SAFE_PROXIES_I_) 24664 #endif // Check proxy type's safety 24668 #if SOL_IS_ON(SOL_SAFE_PROXIES_I_) 24672 #endif // Check proxy type's safety 24673 return stack::get<T>(L,
index);
24678 template <
typename... Ret,
typename... Args>
24680 #if !defined(__clang__) && defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 191200000 24682 return get<protected_function>().call<Ret...>(std::forward<Args>(args)...);
24684 return get<protected_function>().
template call<Ret...>(std::forward<Args>(args)...);
24688 template <
typename... Args>
24689 decltype(
auto) operator()(Args&&... args) {
24690 return call<>(std::forward<Args>(args)...);
24720 using base_t::base_t;
24724 template <
typename T>
24728 template <
typename T>
24732 #if SOL_IS_ON(SOL_USE_THREAD_LOCAL_I_) 24733 static thread_local
lua_State* L =
nullptr;
24744 thread_local_lua_state() = L;
24747 template <
typename T, meta::disable<is_reference_or_lua_value_init_list<meta::unqualified_t<T>>> = meta::enabler>
24751 template <
typename T, meta::disable<is_lua_value_single_constructible<meta::unqualified_t<T>>> = meta::enabler>
24802 template <
typename T>
24803 decltype(
auto) as()
const {
24805 return stack::pop<T>(ref_value.
lua_state());
24808 template <
typename T>
24837 return lua_value(L, stack::get<reference>(L, index, tracking));
24845 #if SOL_IS_ON(SOL_PRINT_ERRORS_I_) 24846 #include <iostream> 24851 #if SOL_LUA_VESION_I_ < 502 24852 if (L ==
nullptr) {
24865 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 24869 size_t messagesize;
24874 #if SOL_IS_ON(SOL_PRINT_ERRORS_I_) 24875 std::cerr <<
"[sol3] An error occurred and panic has been invoked: ";
24877 std::cerr << std::endl;
24882 throw error(
std::string(
"An unexpected error occurred and panic has been invoked"));
24883 #endif // Printing Errors 24887 std::string msg =
"An unknown error has triggered the default error handler";
24891 msg.assign(topmsg.data(), topmsg.size());
24895 if (maybetraceback) {
24897 msg.assign(traceback.data(), traceback.size());
24899 #if SOL_IS_ON(SOL_PRINT_ERRORS_I_) 24934 #if SOL_IS_ON(SOL_EXCEPTIONS_I_) 24935 std::exception_ptr eptr = std::current_exception();
24939 std::rethrow_exception(eptr);
24941 catch (
const std::exception& ex) {
24942 err +=
"std::exception -- ";
24943 err.append(ex.what());
24946 err +=
"thrown message -- ";
24947 err.append(message);
24949 catch (
const char* message) {
24950 err +=
"thrown message -- ";
24951 err.append(message);
24954 err.append(
"thrown but unknown type, cannot serialize into error message");
24957 #endif // serialize exception information if possible 24961 err.append(serr.data(), serr.size());
24963 #if SOL_IS_ON(SOL_PRINT_ERRORS_I_) 24964 std::cerr <<
"[sol3] An error occurred and has been passed to an error handler: ";
24966 std::cerr << std::endl;
24975 int towards = top - target;
24976 if (towards != 0) {
24979 #if SOL_IS_OFF(SOL_EXCEPTIONS_I_) 24984 #endif // If exceptions are allowed 24988 #if SOL_IS_ON(SOL_DEFAULT_PASS_ON_ERROR_I_) 24998 sol::error err = stack::get<sol::error>(L, -p);
25020 bool is53mod = loaded && !(loaded->is<
bool>() && !loaded->as<
bool>());
25023 #if SOL_LUA_VESION_I_ <= 501 25025 bool is51mod = loaded51 && !(loaded51->is<
bool>() && !loaded51->as<
bool>());
25032 template <
typename T>
25034 #if SOL_LUA_VESION_I_ <= 501 25035 auto pkg = global[
"package"];
25036 if (!pkg.valid()) {
25037 pkg = create_table_with(
"loaded", create_table_with(key, sr));
25040 auto ld = pkg[
"loaded"];
25042 ld = create_table_with(key, sr);
25049 auto loaded = reg[
"_LOADED"];
25050 if (!loaded.valid()) {
25051 loaded = create_table_with(key, sr);
25058 template <
typename Fx>
25061 if (loaded && loaded->valid())
25067 ensure_package(key, sr);
25068 return stack::pop<object>(L);
25085 template <
typename... Args>
25088 if constexpr (
sizeof...(args) == 0) {
25097 #if SOL_LUA_VESION_I_ <= 501 && defined(SOL_LUAJIT) 25099 #endif // luajit opens coroutine base stuff 25108 #if !defined(SOL_LUAJIT) 25110 #if SOL_LUA_VESION_I_ > 501 25113 #endif // Lua 5.2+ only 25115 #endif // Not LuaJIT - comes builtin 25132 #elif (SOL_LUA_VESION_I_ == 502) || defined(LUA_COMPAT_BITLIB) || defined(LUA_COMPAT_5_2) 25136 #endif // Lua 5.2 only (deprecated in 5.3 (503)) (Can be turned on with Compat flags) 25151 #if SOL_LUA_VESION_I_ > 502 && !defined(SOL_LUAJIT) 25154 #endif // Lua 5.3+ only 25160 #endif // LuaJIT only 25166 #endif // LuaJIT Only 25177 luaL_requiref(L, key.c_str(), open_function, create_global ? 1 : 0);
25178 return stack::pop<object>(L);
25183 auto action = [
this, &code, &chunkname, &
mode]() {
stack::script(L, code, chunkname, mode); };
25184 return require_core(key, action, create_global);
25189 return require_core(key, action, create_global);
25194 if (!maybe_package) {
25199 table&
package = *maybe_package;
25203 auto loaders_proxy =
package 25204 #if SOL_LUA_VESION_I_ < 502
25210 if (!loaders_proxy.valid()) {
25219 template <
typename Fx>
25222 if (!maybe_package) {
25227 table&
package = *maybe_package;
25231 auto loaders_proxy =
package 25232 #if SOL_LUA_VESION_I_ < 502
25238 bool make_new_table = clear_all_package_loaders || !loaders_proxy.valid();
25239 if (make_new_table) {
25245 if (!maybe_loaders) {
25251 table loaders = loaders_proxy;
25252 loaders.
add(std::forward<Fx>(fx));
25255 template <
typename E>
25281 template <
typename E>
25307 template <
typename E>
25327 template <
typename Fx,
25333 if (!pfr.
valid()) {
25344 template <
typename Fx,
25345 meta::disable_any<meta::is_string_constructible<meta::unqualified_t<Fx>>,
25346 meta::is_specialization_of<meta::unqualified_t<Fx>, basic_environment>> =
meta::enabler>
25350 if (!pfr.
valid()) {
25356 template <
typename Fx,
typename E>
25360 if (!pfr.
valid()) {
25366 template <
typename E>
25377 template <
typename Fx,
25378 meta::disable_any<meta::is_string_constructible<meta::unqualified_t<Fx>>,
25379 meta::is_specialization_of<meta::unqualified_t<Fx>, basic_environment>> =
meta::enabler>
25382 if (!pfr.
valid()) {
25388 template <
typename Fx,
typename E>
25392 if (!pfr.
valid()) {
25398 template <
typename E>
25407 template <
typename E>
25421 int returns = postindex -
index;
25430 int returns = postindex -
index;
25434 template <
typename E>
25448 int returns = postindex -
index;
25457 int returns = postindex -
index;
25461 template <
typename E>
25472 int returns = postindex -
index;
25480 int returns = postindex -
index;
25484 template <
typename Fx,
25485 meta::disable_any<meta::is_string_constructible<meta::unqualified_t<Fx>>,
25486 meta::is_specialization_of<meta::unqualified_t<Fx>, basic_environment>> =
meta::enabler>
25489 return safe_script(code, std::forward<Fx>(on_error), chunkname, mode);
25492 template <
typename Fx,
25493 meta::disable_any<meta::is_string_constructible<meta::unqualified_t<Fx>>,
25494 meta::is_specialization_of<meta::unqualified_t<Fx>, basic_environment>> =
meta::enabler>
25496 return safe_script_file(filename, std::forward<Fx>(on_error), mode);
25499 template <
typename Fx,
typename E>
25502 return safe_script(code, env, std::forward<Fx>(on_error), chunkname, mode);
25505 template <
typename Fx,
typename E>
25507 return safe_script_file(filename, env, std::forward<Fx>(on_error), mode);
25519 #if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS_I_) 25522 return safe_script(reader, data, chunkname, mode);
25527 return safe_script(code, chunkname, mode);
25531 return safe_script_file(filename, mode);
25535 return unsafe_script(code, chunkname, mode);
25539 return unsafe_script_file(filename, mode);
25550 return load(
string_view(buff, size), chunkname, mode);
25555 return load(
string_view(reinterpret_cast<const char*>(buff), size), chunkname, mode);
25571 return global.
begin();
25575 return global.
end();
25583 return global.
cend();
25609 int s = stack_top();
25615 #if SOL_LUA_VESION_I_ >= 504 25624 #if SOL_LUA_VESION_I_ >= 502 25644 #if SOL_LUA_VESION_I_ >= 504 25669 #if SOL_LUA_VESION_I_ >= 504 25670 int old_mode =
lua_gc(lua_state(),
LUA_GCINC, pause, step_multiplier, step_byte_size);
25680 (
void)step_byte_size;
25687 #if SOL_LUA_VESION_I_ >= 504 25690 int old_mode =
lua_gc(lua_state(),
LUA_GCGEN, minor_multiplier, major_multiplier);
25702 return lua_state();
25713 template <
typename... Args,
typename... Keys>
25714 decltype(
auto)
get(Keys&&... keys)
const {
25715 return global.
get<Args...>(std::forward<Keys>(keys)...);
25718 template <
typename T,
typename Key>
25719 decltype(
auto) get_or(Key&& key, T&& otherwise)
const {
25720 return global.
get_or(std::forward<Key>(key), std::forward<T>(otherwise));
25723 template <
typename T,
typename Key,
typename D>
25724 decltype(
auto) get_or(Key&& key, D&& otherwise)
const {
25725 return global.
get_or<T>(std::forward<Key>(key), std::forward<D>(otherwise));
25728 template <
typename... Args>
25730 global.
set(std::forward<Args>(args)...);
25734 template <
typename T,
typename... Keys>
25735 decltype(
auto) traverse_get(Keys&&... keys)
const {
25736 return global.
traverse_get<T>(std::forward<Keys>(keys)...);
25739 template <
typename... Args>
25745 template <
typename Class,
typename... Args>
25747 return global.
new_usertype<Class>(name, std::forward<Args>(args)...);
25750 template <
bool read_only =
true,
typename... Args>
25752 global.
new_enum<read_only>(name, std::forward<Args>(args)...);
25756 template <
typename T,
bool read_only = true>
25762 template <
typename Fx>
25764 global.
for_each(std::forward<Fx>(fx));
25767 template <
typename T>
25769 return global[std::forward<T>(key)];
25772 template <
typename T>
25774 return global[std::forward<T>(key)];
25777 template <
typename Sig,
typename... Args,
typename Key>
25779 global.
set_function<Sig>(std::forward<Key>(key), std::forward<Args>(args)...);
25783 template <
typename... Args,
typename Key>
25785 global.
set_function(std::forward<Key>(key), std::forward<Args>(args)...);
25789 template <
typename Name>
25791 return global.
create(std::forward<Name>(name), narr, nrec);
25794 template <
typename Name,
typename Key,
typename Value,
typename... Args>
25796 return global.
create(std::forward<Name>(name), narr, nrec, std::forward<Key>(key), std::forward<Value>(
value), std::forward<Args>(args)...);
25799 template <
typename Name,
typename... Args>
25802 global.
set(std::forward<Name>(name), x);
25807 return create_table(lua_state(), narr, nrec);
25810 template <
typename Key,
typename Value,
typename... Args>
25812 return create_table(lua_state(), narr, nrec, std::forward<Key>(key), std::forward<Value>(
value), std::forward<Args>(args)...);
25815 template <
typename... Args>
25817 return create_table_with(lua_state(), std::forward<Args>(args)...);
25824 template <
typename Key,
typename Value,
typename... Args>
25826 return global_table::create(L, narr, nrec, std::forward<Key>(key), std::forward<Value>(
value), std::forward<Args>(args)...);
25829 template <
typename... Args>
25852 return lua_state();
25855 return lua_state();
25879 template <
typename Handler>
25892 template <
typename ref_t>
25898 using base_t::lua_state;
25904 basic_thread(T&& r)
25905 : base_t(
std::forward<T>(r)) {
25906 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 25909 stack::check<basic_thread>(lua_state(), -1,
handler);
25918 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
25920 : base_t(L,
std::forward<T>(r)) {
25921 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 25924 stack::check<basic_thread>(lua_state(), -1,
handler);
25928 : base_t(L, index) {
25929 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 25935 : base_t(L, index) {
25936 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 25939 stack::check<basic_thread>(lua_state(), -1,
handler);
25949 : base_t(L, -stack::
push(L, actualthread)) {
25950 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 25952 stack::check<basic_thread>(lua_state(), -1,
handler);
25989 return create(lua_state());
26029 state_view::operator=(
std::move(that));
26030 unique_base::operator=(
std::move(that));
26046 template <
typename ref_t>
26058 void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) {
26059 #if SOL_LUA_VESION_I_ >= 504 26061 stats =
static_cast<call_status>(
lua_resume(lua_state(),
nullptr, static_cast<int>(argcount), &nresults));
26067 template <std::size_t... I,
typename... Ret>
26069 luacall(n,
sizeof...(Ret));
26070 return stack::pop<std::tuple<Ret...>>(lua_state());
26073 template <std::
size_t I,
typename Ret>
26076 return stack::pop<Ret>(lua_state());
26079 template <std::
size_t I>
26085 int firstreturn = 1;
26087 int poststacksize =
lua_gettop(this->lua_state());
26088 int returncount = poststacksize - (firstreturn - 1);
26090 if (error_handler.
valid()) {
26091 string_view err = stack::get<string_view>(this->lua_state(), poststacksize);
26092 error_handler.
push();
26102 using base_t::lua_state;
26105 template <
typename T,
26108 meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> =
meta::enabler>
26111 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26115 stack::check<basic_coroutine>(lua_state(), -1,
handler);
26119 basic_coroutine(
const basic_coroutine&) =
default;
26120 basic_coroutine& operator=(
const basic_coroutine&) =
default;
26121 basic_coroutine(basic_coroutine&&) =
default;
26122 basic_coroutine& operator=(basic_coroutine&&) =
default;
26144 template <
typename Super>
26148 template <
typename Super>
26152 template <
typename Proxy,
typename Handler,
26157 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
26161 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
26163 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26166 stack::check<basic_coroutine>(lua_state(), -1,
handler);
26177 #ifdef SOL_SAFE_REFERENCES 26186 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26195 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26204 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26207 stack::check<basic_coroutine>(lua_state(), -1,
handler);
26224 explicit operator bool() const noexcept {
26228 template <
typename... Args>
26230 return call<>(std::forward<Args>(args)...);
26233 template <
typename... Ret,
typename... Args>
26234 decltype(
auto) operator()(
types<Ret...>, Args&&... args) {
26235 return call<Ret...>(std::forward<Args>(args)...);
26238 template <
typename... Ret,
typename... Args>
26256 template <
typename base_type>
26262 using base_t::lua_state;
26266 basic_userdata(T&& r) noexcept
26267 : base_t(
std::forward<T>(r)) {
26268 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26285 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
26287 : base_t(L,
std::forward<T>(r)) {
26288 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26291 stack::check<basic_userdata>(L, -1,
handler);
26296 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26303 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26306 stack::check<basic_userdata>(L, -1,
handler);
26311 template <
typename base_type>
26316 using base_t::lua_state;
26320 basic_lightuserdata(T&& r) noexcept
26321 : base_t(
std::forward<T>(r)) {
26322 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26339 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
26342 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26345 stack::check<basic_lightuserdata>(lua_state(), -1,
handler);
26349 : base_t(L, index) {
26350 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26356 : base_t(L, index) {
26357 #if SOL_IS_ON(SOL_SAFE_REFERENCES_I_) 26360 stack::check<basic_lightuserdata>(lua_state(),
index,
handler);
26372 template <
typename T>
26377 template <
typename Source>
26383 template <
typename T>
26387 for (
const auto& i : e.
src) {
26401 #include <iterator> 26426 : L(luastate), index(
lua_absindex(luastate, stackindex)), stacktop(lastindex) {
26431 : L(o.L), index(o.index), stacktop(o.stacktop) {
26442 stacktop = o.stacktop;
26453 return iterator(L, index, stacktop + 1);
26456 return iterator(L, stacktop + 1, stacktop + 1);
26459 return const_iterator(L, index, stacktop + 1);
26462 return const_iterator(L, stacktop + 1, stacktop + 1);
26472 return std::reverse_iterator<iterator>(begin());
26475 return std::reverse_iterator<iterator>(end());
26478 return std::reverse_iterator<const_iterator>(begin());
26481 return std::reverse_iterator<const_iterator>(end());
26484 return std::reverse_iterator<const_iterator>(cbegin());
26487 return std::reverse_iterator<const_iterator>(cend());
26496 for (
int i = index; i <= stacktop; ++i) {
26506 template <
typename T>
26507 decltype(
auto)
get(difference_type index_offset = 0)
const {
26508 return stack::get<T>(L, index +
static_cast<int>(index_offset));
26511 type
get_type(difference_type index_offset = 0) const noexcept {
26512 return type_of(L, index + static_cast<int>(index_offset));
26516 return stack_proxy(L, index + static_cast<int>(index_offset));
26526 return stacktop - (index - 1);
26529 return static_cast<std::size_t
>(leftover_count());
26548 return ref.
push(L);
26561 template <
typename T>
26566 template <
typename Source>
26572 template <
typename T>
26577 for (
const auto& i : src) {
26592 template <
typename Al =
typename std::allocator<
object>>
26595 using base_t = std::vector<object, Al>;
26603 this->insert(this->cend(), fr.
begin(), fr.
end());
26608 this->insert(this->cend(), fr.
begin(), fr.
end());
26611 template <
typename Arg0,
typename... Args,
26617 basic_variadic_results(
const basic_variadic_results&) =
default;
26618 basic_variadic_results(basic_variadic_results&&) =
default;
26629 template <
typename Al>
26636 template <
typename Al>
26640 for (
const auto& i : e) {
26651 return stack::push(L, static_cast<const base_t&>(r));
26660 #if SOL_IS_ON(SOL_COMPILER_GCC_I_) 26661 #pragma GCC diagnostic pop 26662 #elif SOL_IS_ON(SOL_COMPILER_VCXX_I_) 26663 #pragma warning(pop) 26666 #if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE_I_) 26668 #pragma pop_macro("check") 26669 #endif // Unreal Engine 4 Bullshit 26674 #endif // SOL_SINGLE_INCLUDE_HPP static int get_call(lua_State *L)
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(optional &&rhs)&
disjunction
std::size_t code_units_size
#define luaL_addsize(B, s)
static detail::error_result set_comparative(std::false_type, lua_State *, T &, stack_object, stack_object)
static int push(lua_State *L, detail::tagged< T, no_construction >)
basic_function(T &&r) noexcept
LUA_API int lua_isstring(lua_State *L, int idx)
basic_userdata(lua_State *L, int index=-1)
stack_iterator & operator-=(difference_type idx)
LUA_API const char * lua_getupvalue(lua_State *L, int funcindex, int n)
auto unqualified_get(lua_State *L, int index, record &tracking) -> decltype(stack_detail::unchecked_unqualified_get< T >(L, index, tracking))
std::integral_constant< bool, meta::count_for< is_variadic_arguments, typename base_t::args_list >::value!=0 > runtime_variadics_t
static detail::error_result set_it(std::false_type, lua_State *L, T &self, stack_object key, stack_object value)
static int push(lua_State *L, const T &tablecont)
const_reference operator*() const
table create(Name &&name, int narr=0, int nrec=0)
static int push(lua_State *L, detail::yield_tag_t, const std::function< Signature > &fx)
void set_on(const T &target) const
void select_member_variable(lua_State *L, Fx &&fx, Args &&...args)
void operator()(meta_function mf, lua_CFunction f)
constexpr const char * not_a_number
protected_function_result safe_script(const string_view &code, const basic_environment< E > &env, Fx &&on_error, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
object require(const std::string &key, lua_CFunction open_function, bool create_global=true)
lua_State * copy_assign(lua_State *L, lua_State *rL, const stateless_reference &r)
error(detail::direct_error_tag, const std::string &str)
static int real_insert_traits(std::true_type, lua_State *L)
static int ipairs(lua_State *L)
#define lua_isnoneornil(L, n)
LUA_API void lua_xmove(lua_State *from, lua_State *to, int n)
T & unwrap(std::reference_wrapper< T > arg)
detail::inheritance_cast_function base_class_cast_func
meta::boolean< has_find_test< T >::value > has_find
std::bitset< 64 > properties
static int real_empty_traits(std::false_type, lua_State *L)
basic_coroutine(proxy_base< Super > &&p)
constexpr const char * not_enough_stack_space_generic
bool valid() const noexcept
constexpr std::in_place_t in_place
const reference & value() const &
std::unordered_map< string_view, index_call_storage > string_keys
typename std::remove_const< T >::type remove_const_t
static int real_set_traits(std::false_type, lua_State *L)
state & operator=(state &&that)
lua_State * lua_state() const noexcept
static int push(std::index_sequence< I... >, lua_State *L, T &&c)
stack_iterator(lua_State *luastate, int idx, int topidx)
static int push(lua_State *L, const variadic_args &ref)
static table create_with(lua_State *L, Args &&...args)
static int next_iter(lua_State *L)
static int push(std::false_type, lua_State *L, const T &tablecont)
implicit_wrapper(T &item)
basic_function(lua_State *L, ref_index index)
int operator()(lua_State *L, int index, type expected, type actual, string_view message) const noexcept(false)
nested< T > as_nested_ref(T &&container)
static int push(lua_State *L, overload_set< Functions... > &&set)
bool check_usertype(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
static int index_call_with_bases(lua_State *L)
static int panic(lua_State *L)
type get_type(difference_type index_offset=0) const noexcept
int default_at_panic(lua_State *L)
constexpr Sig C::* resolve_v(std::true_type, Sig C::*mem_variable_ptr)
lua_State * lua_state() const noexcept
constexpr optional< typename std::decay< U >::type > conjunction(U &&u) const
const auto call_constructor
LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data, int strip)
bool operator!=(const stack_iterator &r) const
void swap(optional &rhs) noexcept
LUALIB_API int luaL_ref(lua_State *L, int t)
static int real_next_traits(std::false_type, lua_State *L)
#define lua_pushcfunction(L, f)
static detail::error_result find_has(std::false_type, lua_State *L, T &self)
static int push(lua_State *L, const wchar_t *strb, const wchar_t *stre)
constexpr const T * operator->() const
static int real_ipairs_call(lua_State *L)
basic_reference(basic_reference &&o) noexcept
LUA_API int lua_isinteger(lua_State *L, int idx)
bool runnable() const noexcept
static int real_size_traits(std::false_type, lua_State *L)
basic_table_core(detail::no_safety_tag, lua_State *L, int index)
void move_assign(basic_reference< r_main_only > &&r)
static R apply(std::index_sequence< I, Ix... >, lua_State *L, int index, record &tracking, Args &&...args)
static int next(lua_State *L)
static decltype(auto) pop(lua_State *L)
static int push(lua_State *L, const char16_t *str, std::size_t len)
static detail::error_result set_associative(std::true_type, iterator &it, stack_object value)
void tuple_set(std::index_sequence< I... >, T &&value)&&
static int ipairs(lua_State *L)
basic_object(std::integral_constant< bool, invert_and_pop >, lua_State *L, int index=-1) noexcept
LUA_API int lua_rawget(lua_State *L, int idx)
ebco(Arg &&arg, Args &&...args)
enum MQTTPropertyCodes value
std::string short_demangle_from_type_name(std::string realname)
meta::conditional_t< meta::is_c_str_of_v< uF, char >||meta::is_c_str_of_v< uF, char16_t >||meta::is_c_str_of_v< uF, char32_t >||meta::is_c_str_of_v< uF, wchar_t >, std::add_pointer_t< std::add_const_t< std::remove_all_extents_t< Fq >>>, std::decay_t< Fq >> F
basic_lua_table(lua_State *L, ref_index index)
constexpr const Char * data() const
int overload_match_arity(Match &&matchfx, lua_State *L, int fxarity, int start, Args &&...args)
static void clear_has(std::false_type, lua_State *L, T &)
void accumulate_and_mark(const std::string &n, std::string &aux_message, int &marker)
std::array< C, 4 > code_units
base_list< Args... > bases
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f) const &
int dump(lua_Writer writer, void *userdata, bool strip, Fx &&on_error) const
meta::unqualified_t< T > C
static int push(lua_State *L, const char *strb, const char *stre)
static const std::string & gc_table()
optional< usertype_storage< T > & > maybe_get_usertype_storage(lua_State *L)
basic_thread(lua_State *L, int index=-1)
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
const_reverse_iterator crend() const
static int add(lua_State *L)
stack_reference argument_type
basic_reference(lua_State *oL, const basic_reference<!main_only > &o) noexcept
void tuple_set(std::index_sequence< I... >, std::tuple< Args... > &&args)
std::is_copy_assignable< V > is_copyable
basic_reference< true > main_reference
const_iterator cend() const
static int push(lua_State *L, constructor_wrapper< Fxs... > &&c)
static auto call(object_type &mem) -> detail::array_return_type< decltype(mem.*fx)>
void hard_reset() noexcept
properties_enrollment_allowed(int ×, std::bitset< 64 > &props, automagic_enrollments &enroll)
stack_reference(lua_State *L, absolute_index i) noexcept
lua_State * lua_state() const
std::variant_size< V > V_size
int & operator[](std::size_t i)
static int push(lua_State *L, char32_t c)
optional_copy_base(const optional_copy_base &rhs)
constexpr auto associated_nullopt_v
protected_function_result safe_script(lua_Reader reader, void *data, Fx &&on_error, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
index_call_function * index
type get_type(lua_State *L) const noexcept
state(lua_CFunction panic, lua_Alloc alfunc, void *alpointer=nullptr)
basic_protected_function(proxy_base< Super > &&p)
basic_object(lua_State *L, in_place_type_t< T >, Args &&...args) noexcept
void for_each_table(lua_State *L, Fx &&fx)
detail::enable_if_t< std::is_constructible< T, U && >::value &&!std::is_same< detail::decay_t< U >, in_place_t >::value &&!std::is_same< optional< T >, detail::decay_t< U >>::value > enable_forward_value
int push() const noexcept
traits_type::args_list args_list
const std::array< std::string, 37 > & meta_function_names()
std::integral_constant< bool, std::is_same_v< T, override_value_t >||std::is_same_v< T, update_if_empty_t >||std::is_same_v< T, create_if_nil_t >> is_insert_mode
lightuserdata_value(void *data)
static int real_add_call(lua_State *L)
static detail::error_result erase_key_has(std::false_type, lua_State *L, T &self, K &key)
static int push(lua_State *L, T &&obj)
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
int dump(lua_Writer writer, void *userdata, bool strip=false) const
optional< object > is_loaded_package(const std::string &key)
static detail::error_result add_copyable(std::false_type, lua_State *, T &, stack_object)
int member_default_to_string(std::false_type, lua_State *L)
basic_thread(lua_State *L, T &&r)
int multi_push_reference(lua_State *L, T &&t, Args &&...args)
typename invoke_result< F, Us... >::type invoke_result_t
basic_object(detail::no_safety_tag, lua_State *L, T &&r) noexcept
const void * pointer() const noexcept
optional_move_base(optional_move_base &&rhs) noexcept(std::is_nothrow_move_constructible< T >::value)
member_function(function_type f, Args &&...args)
static void set_default_handler(const T &ref)
meta::iterator_tag< iterator >::type iterator_category
protected_function_result operator()(Args &&...args) const
ebco & operator=(const T &v)
static int call(lua_State *L, F &)
basic_protected_function(lua_State *L, absolute_index index)
void luajit_exception_off(lua_State *L)
basic_protected_function(lua_State *L, raw_index index)
static detail::error_result set_start(lua_State *L, T &self, stack_object key, stack_object value)
static int call(lua_State *L) noexcept(traits_type::is_noexcept)
#define SOL_FILE_ID_SIZE_I_
static detail::error_result find_associative_lookup(std::true_type, lua_State *L, T &, Iter &it, std::size_t)
stack_iterator< proxy_t, is_const > operator+(typename stack_iterator< proxy_t, is_const >::difference_type n, const stack_iterator< proxy_t, is_const > &r)
this_main_state(lua_State *Ls)
meta::boolean< has_traits_insert_test< T >::value > has_traits_insert
load_status status() const noexcept
basic_reference(lua_State *L, lua_nil_t) noexcept
constexpr auto optional_map_impl(Opt &&opt, F &&f) -> optional< Ret >
const_reverse_iterator rend() const
static int push(lua_State *L, std::function< Signature > &&fx)
static int push(lua_State *L, const std::function< Signature > &fx)
constexpr std::in_place_type_t< T > in_place_type
LUA_API void lua_pushnil(lua_State *L)
basic_lightuserdata< reference > lightuserdata
static int push(lua_State *L, const char *str)
LUA_API int lua_isnumber(lua_State *L, int idx)
static int real_get_traits(std::false_type, lua_State *L)
constexpr const char * not_enough_stack_space_environment
static int index_of_call(lua_State *L)
thread_status status() const
protected_handler(const target_t &target)
stateless_stack_reference(lua_State *, raw_index i) noexcept
static int push(lua_State *L, const wchar_t *wstr, std::size_t sz)
static int push(lua_State *L, lua_nil_t)
difference_type operator-(const stack_iterator &r) const
lua_CFunction new_idx_call
as_container_t(Arg0 &&arg0, Arg1 &&arg1, Args &&...args)
basic_lua_table< reference > lua_table
SOL_TL_OPTIONAL_11_CONSTEXPR T & operator*()
const bool default_safe_function_calls
push_popper_n(lua_State *, int)
meta::boolean< has_traits_index_of_test< T >::value > has_traits_index_of
bool valid() const noexcept
bool attempt_alloc_unique(lua_State *L, std::size_t ptr_align, std::size_t ptr_size, std::size_t real_align, std::size_t real_size, std::size_t allocated_size, void *&pointer_adjusted, void *&dx_adjusted, void *&id_adjusted, void *&data_adjusted)
void invoke(types< void >, std::index_sequence< I >, std::ptrdiff_t n)
constexpr bool operator!=(const optional< T > &lhs, const optional< U > &rhs)
relop
LUA_KCONTEXT lua_KContext
static int push(lua_State *L, Tagged &&p)
constexpr bool is_table_v
bool operator()(const basic_reference< lb > &lhs, const lua_nil_t &rhs) const
static int push(lua_State *L, Arg &&arg, Args &&...args)
LUA_API const void * lua_topointer(lua_State *L, int idx)
stack_iterator< stack_proxy, true > const_iterator
basic_coroutine(lua_State *L, int index=-1)
constexpr const char * not_enough_stack_space_integral
reverse_iterator rbegin()
basic_table_iterator(reference_type x)
const void * pointer(lua_State *L) const noexcept
void operator()(Args &&...args)
basic_object< reference > object
static constexpr char32_t decode(unsigned char b0, unsigned char b1, unsigned char b2)
std::basic_string< wchar_t, Traits, Al > S
table create(Name &&name, int narr, int nrec, Key &&key, Value &&value, Args &&...args)
optional< T > or_else(F &&f) const &&
basic_thread< stack_reference > stack_thread
overloaded_function(overload_list set)
state_view & new_enum(const string_view &name, std::initializer_list< std::pair< string_view, T >> items)
basic_object(const stack_reference &r) noexcept
int adl_default_to_string(std::false_type, lua_State *L)
LUA_API int lua_rawgeti(lua_State *L, int idx, lua_Integer n)
constexpr optional(detail::enable_if_t< std::is_constructible< T, Args... >::value, in_place_t >, Args &&...args)
basic_lua_table< stack_reference > stack_lua_table
int comparsion_operator_wrap(lua_State *L)
std::is_same< iterator_category, std::input_iterator_tag > is_input_iterator
int push(lua_State *L) const noexcept
static int call(lua_State *L, F &fx, Args &&...args)
static int real_index_set_traits(std::true_type, lua_State *L)
constexpr const char * not_enough_stack_space_meta_function_name
meta::tuple_types< typename fx_t::return_type > return_types
stack_iterator< stack_proxy, false > iterator
static int push(lua_State *L, const T &tablecont)
int lua_c_wrapper(lua_State *L)
stack_guard(lua_State *L, int top, std::function< void(int, int)> fx=detail::stack_fail)
lua_State * main_thread(lua_State *L, lua_State *backup_if_unsupported=nullptr)
types< object_type &, FArgs... > free_args_list
static int index_get(lua_State *L)
auto optional_map_impl(Opt &&opt, F &&f) -> optional< monostate >
protected_function_result do_reader(lua_Reader reader, void *data, const basic_environment< E > &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
basic_coroutine(basic_function< base_t > &&b, handler_t eh)
meta::boolean< has_traits_set_test< T >::value > has_traits_set
lua_State * lua_state() const
protected_function_result safe_script(const string_view &code, Fx &&on_error, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
meta::function_args_t< function_type > args_lists
static int next_associative(std::false_type, lua_State *L)
bool operator()(const std::unique_ptr< binding_base > &ptr) const
std_shim(unsafe_function lua_func)
decltype(auto) traverse_get(Keys &&...keys) const
void select_set_fx(lua_State *L, Args &&...args)
int destruct_usertype_storage(lua_State *L)
optional_move_assign_base & operator=(optional_move_assign_base &&rhs) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value)
basic_table_core(detail::no_safety_tag, lua_State *L, ref_index index)
void operator()(T &&obj, Args &&...args) const
const_reverse_iterator rbegin() const
static detail::error_result add_associative(std::true_type, lua_State *L, T &self, stack_object key)
constexpr bool operator>=(const optional< T > &lhs, const optional< U > &rhs)
relop
int operator()(lua_State *L)
static int push(lua_State *L, const char16_t *strb, const char16_t *stre)
stack_iterator operator+(difference_type idx) const
int dump_throw_on_error(lua_State *L, int result_code, lua_Writer writer_function, void *userdata, bool strip)
static detail::error_result insert_lookup(std::false_type, lua_State *L, T &self, stack_object where, stack_object value)
int is_indexer(call_construction)
protected_function_result script_file(const std::string &filename, const basic_environment< E > &env, Fx &&on_error, load_mode mode=load_mode::any)
static int push(lua_State *L, user< T > &&u)
basic_coroutine(lua_nil_t n)
detail::invoke_result_t< U > map_or_else(F &&f, U &&u)&
Maps the stored value with f if there is one, otherwise calls u and returns the result.
usertype_storage_base * p_usb
static int insert_call(lua_State *L)
int lua_cfunction_trampoline(lua_State *L, lua_CFunction f)
int operator()(lua_State *L, int index, type expected, type actual, string_view message) const noexcept(false)
static constexpr bool is_overlong(char32_t u, std::size_t bytes)
typename std::conditional< B, T, F >::type conditional_t
static void push_back_at_end(std::false_type, types< V > t, lua_State *L, T &cont, std::size_t idx)
detail::enable_if_t< std::is_constructible< T, Other >::value &&std::is_assignable< T &, Other >::value &&!std::is_constructible< T, optional< U > & >::value &&!std::is_constructible< T, optional< U > && >::value &&!std::is_constructible< T, const optional< U > & >::value &&!std::is_constructible< T, const optional< U > && >::value &&!std::is_convertible< optional< U > &, T >::value &&!std::is_convertible< optional< U > &&, T >::value &&!std::is_convertible< const optional< U > &, T >::value &&!std::is_convertible< const optional< U > &&, T >::value &&!std::is_assignable< T &, optional< U > & >::value &&!std::is_assignable< T &, optional< U > && >::value &&!std::is_assignable< T &, const optional< U > & >::value &&!std::is_assignable< T &, const optional< U > && >::value > enable_assign_from_other
std::initializer_list< int > swallow
meta::boolean< has_traits_size_test< T >::value > has_traits_size
auto as_args(Source &&source)
static int push(lua_State *L, T *cont)
int stack_index() const noexcept
basic_environment< main_reference > main_environment
const T & value() const &
decltype(auto) get_key(std::true_type, T &&t)
meta::boolean< has_traits_index_set_test< T >::value > has_traits_index_set
constexpr T & value_or(U &&u) const
stack_table_core< true > stack_global_table
lua_bind_traits< meta::unqualified_t< F > > traits_type
LUA_API int lua_resume(lua_State *L, lua_State *from, int nargs, int *nresults)
static int push(lua_State *L, factory_wrapper< Functions... > &&fw)
LUA_API int lua_setmetatable(lua_State *L, int objindex)
std::tuple< decltype(stack::get< Tn >nullptr, 0))... > R
member_variable(function_type v, Args &&...args)
meta::conditional_t< is_const, const proxy_t, proxy_t > reference
const char * format_string
static detail::error_result get_associative(std::false_type, lua_State *L, Iter &it)
static table create(lua_State *L, int narr=0, int nrec=0)
static bool type_unique_cast_bases(types<>, void *, void *, const string_view &)
LUAMOD_API int luaopen_debug(lua_State *L)
meta::boolean< has_erase_key_test< T >::value > has_erase_key
static const char * get(lua_State *L, int index, record &tracking)
static detail::error_result erase_integral(std::true_type, lua_State *L, T &self, K &key)
int stack_index() const noexcept
LUA_API int lua_toboolean(lua_State *L, int idx)
auto as_returns(Source &&source)
static int ipairs_call(lua_State *L)
static int push_keyed(lua_State *L, K &&k, T *obj)
LUA_API void lua_rawsetp(lua_State *L, int idx, const void *p)
bool check_types(types< Args... >, lua_State *L, int index, Handler &&handler, record &tracking)
static detail::error_result add_insert_after(std::false_type, lua_State *, T &, stack_object)
static int push(lua_State *, const this_state &)
static int push(lua_State *L, const detail::tagged< T, const constructor_wrapper< Fxs... >> &c)
constexpr auto bytecode_dump_writer
LUAMOD_API int luaopen_os(lua_State *L)
stateless_stack_reference(raw_index i) noexcept
void select(lua_State *L, Fx &&fx, Args &&...args)
U map_or(F &&f, U &&u) const &
map_or
SOL_TL_OPTIONAL_11_CONSTEXPR T & get()&
int operator()(lua_State *L)
basic_thread(lua_State *L, ref_index index)
void tuple_set(std::index_sequence< I... >, T &&value)&&
decltype(auto) unqualified_interop_get(lua_State *L, int index, void *unadjusted_pointer, record &tracking)
decoded_result< It > utf32_to_code_point(It it, It last)
LUA_API void lua_rawset(lua_State *L, int idx)
detail::inheritance_check_function base_class_check_func
void deref() const noexcept
static detail::error_result get_associative_find(std::true_type, lua_State *L, T &self, K &key)
std::remove_pointer_t< std::decay_t< Function > > function_type
static int push(lua_State *L, raw_index ri)
SOL_TL_OPTIONAL_11_CONSTEXPR T && value()&&
int push(lua_State *L, const as_returns_t< T > &e)
void * align_user(void *ptr)
bool is_stack(std::true_type) const
void *(* pf)(int, unsigned char, char *, size_t)
static int push(lua_State *L, wchar_t c)
basic_reference(lua_State *L, detail::global_tag) noexcept
error(detail::direct_error_tag, std::string &&str)
LUA_API void * lua_touserdata(lua_State *L, int idx)
basic_protected_function(lua_State *L, raw_index index, handler_t eh)
static int push(lua_State *L, T &&t)
basic_reference(basic_reference<!main_only > &&o) noexcept
static const std::string & name()
int(* lua_Writer)(lua_State *L, const void *p, size_t sz, void *ud)
meta::unqualified_t< T > Tu
static constexpr char32_t decode(unsigned char b0, unsigned char b1, unsigned char b2, unsigned char b3)
constexpr override_value_t override_value
basic_coroutine(lua_State *L, int index, handler_t eh)
optional< usertype_storage_base & > maybe_get_usertype_storage_base(lua_State *L, const char *gcmetakey)
stack_proxy reference_type
LUA_API void lua_seti(lua_State *L, int idx, lua_Integer n)
int default_to_string(lua_State *L)
static int push(lua_State *L, no_construction c, function_detail::call_indicator)
int typed_static_trampoline(lua_State *L)
void reset() noexcept
Destroys the stored value if one exists, making the optional empty.
static int call(lua_State *L, lua_CFunction_ref f)
LUALIB_API int luaL_callmeta(lua_State *L, int obj, const char *event)
stack_unsafe_function stack_function
basic_table_iterator & operator++()
static int real_ipairs_traits(std::true_type, lua_State *L)
static int real_index_call(lua_State *L)
void tuple_set(std::index_sequence< I... >, T &&value)&
variadic_args(lua_State *luastate, int stackindex=-1)
stack_iterator operator++(int)
static iterator begin(lua_State *L, T &)
void pop(lua_State *L, int n=1) const noexcept
protected_function_result safe_function_result
meta::bind_traits< Signature > base_t
constexpr bool operator>(const optional< T > &lhs, const optional< U > &rhs)
relop
static detail::error_result add_insert(std::false_type, lua_State *L, T &self, stack_object value)
static int real_size_traits(std::true_type, lua_State *L)
T * usertype_allocate(lua_State *L)
functor_function(function_type f, Args &&...args)
void copy_assign(const basic_reference< r_main_only > &r)
static int push(lua_State *L, const char32_t(&str)[N])
detail::enable_if_t<!std::is_same< optional< T >, detail::decay_t< U >>::value &&!detail::conjunction< std::is_scalar< T >, std::is_same< T, detail::decay_t< U >>>::value &&std::is_constructible< T, U >::value &&std::is_assignable< T &, U >::value > enable_assign_forward
constexpr auto resolve_i(types< R(Args...)>, F &&) -> R(meta::unqualified_t< F >::*)(Args...)
typename lua_value::arr array_value
std::input_iterator_tag iterator_category
Container dump(Fx &&on_error) const
static decltype(auto) get(lua_State *L, int index, record &tracking)
basic_reference & operator=(const basic_reference &r) noexcept
constexpr const T & operator*() const &
int push_as_upvalues(lua_State *L, T &item)
reference named_metatable
basic_reference(const stack_reference &r) noexcept
lua_State * lua_state() const
static int push(lua_State *L, const char32_t *str)
meta_function meta_method
int operator()(lua_State *L)
static int call(lua_State *L, const detail::no_prop &)
static basic_thread create(lua_State *L)
error_result(int results)
constexpr detail::invoke_result_t< F, const T && > and_then(F &&f) const &&
void clear_entries(const reference ®istry_reference)
usertype_storage< T > & create_usertype_storage(lua_State *L)
type get_type() const noexcept
auto make_string_view(base_classes_tag)
void script(lua_State *L, const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
void * align_usertype_unique_tag(void *ptr)
int push(lua_State *L, const basic_variadic_results< Al > &e)
static table create_table(lua_State *L, int narr, int nrec, Key &&key, Value &&value, Args &&...args)
#define SOL_IS_DEFAULT_OFF(OP_SYMBOL)
static int call(lua_State *L)
bool is_main_thread() const
state_view & traverse_set(Args &&...args)
state_view & new_enum(const string_view &name, Args &&...args)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
static int writer(lua_State *L, const void *b, size_t size, void *ud)
static int call(std::index_sequence< In... >, lua_State *L, P &fx)
basic_lightuserdata(lua_State *L, int index=-1)
static int push(lua_State *L, char c)
static auto size_has(std::false_type, lua_State *L, T &self)
constexpr const char * not_enough_stack_space_string
reference value_index_table
basic_reference(lua_State *L, const stack_reference &r) noexcept
std::bitset< 64 > & properties
meta::neg< meta::any< std::is_const< V >, std::is_const< std::remove_reference_t< iterator_return > >, meta::neg< is_copyable > > > is_writable
push_invoke_t(Arg0 &&arg0, Arg1 &&arg1, Args &&...args)
#define lua_remove(L, idx)
protected_function_result safe_script_file(const std::string &filename, load_mode mode=load_mode::any)
has_empty< T > has_traits_empty
int no_construction_error(lua_State *L)
T const & value() const &
LUA_API int lua_compare(lua_State *L, int index1, int index2, int op)
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount) const
static int push(lua_State *L, const std::initializer_list< T > &il)
std::unique_ptr< lua_State, detail::state_deleter > unique_base
basic_environment< stack_reference > stack_environment
static int next_associative(std::true_type, lua_State *L)
int call_wrapper_function(std::true_type, lua_State *L)
static detail::error_result set_category(std::random_access_iterator_tag, lua_State *L, T &self, stack_object okey, stack_object value)
int basic_insert_dump_writer(lua_State *, const void *memory, size_t memory_size, void *userdata)
constexpr const char * not_a_number_integral
basic_object(lua_State *L, absolute_index index) noexcept
static int push(lua_State *L, no_construction)
as_table_t< meta::unqualified_t< T > > as_table(T &&container)
static int call(lua_State *L, F &&f)
static detail::error_result add_associative(std::false_type, lua_State *L, T &self, stack_object value, Iter &pos)
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f) const &
static void clear_start(lua_State *L, T &self)
static int empty(lua_State *L)
basic_coroutine(lua_State *L, ref_index index)
basic_coroutine(T &&r) noexcept
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *pisnum)
static int push(lua_State *L, const yielding_t< T > &f, Args &&...args)
std::add_lvalue_reference_t< meta::unwrapped_t< std::remove_reference_t< decltype(detail::deref(member))> > > M
void abandon(lua_State *=nullptr)
static int push(lua_State *L, yielding_t< T > &&f, Args &&...args)
static int push(lua_State *L, T *cont)
protected_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
std::integral_constant< bool, is_userdata_v< T >||is_table_v< T >||meta::is_specialization_of_v< T, basic_environment >> is_environment
protected_function_result safe_script(lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
static int index_call_with_(lua_State *L, void *target)
int operator()(T &&value) const
static void call(Fx &&fx, object_type &mem, Arg &&arg, Args &&...)
static int call(lua_State *L, F &fx)
std::tuple< Functions... > functions
encoded_result< char16_t > code_point_to_utf16(char32_t codepoint)
void insert_default_registrations(IFx &&ifx, Fx &&fx)
#define lua_tointeger(L, i)
SOL_TL_OPTIONAL_11_CONSTEXPR T * operator->()
#define SOL_TL_OPTIONAL_11_CONSTEXPR
decltype(auto) deref(T &&item)
static iterator end(lua_State *, T &self)
static int push(lua_State *L, const function_arguments< T, Args... > &fp)
static int push_fx(lua_State *L, F &&f, Args &&...args)
bool operator()(const basic_reference< lb > &lhs, const basic_reference< rb > &rhs) const
reference operator*() const
static int call_with_(lua_State *L, void *target)
constexpr const T & operator*() const
basic_protected_function(const basic_function< base_t > &b)
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
constexpr const char * not_enough_stack_space_integral
static int push_sized(lua_State *L, const char *str, std::size_t len)
LUA_API lua_State * lua_newstate(lua_Alloc f, void *ud)
static int push_lvalue(std::true_type, lua_State *L, const C &cont)
static int real_new_index_call(lua_State *L)
static int push(lua_State *L, no_metatable_t, const user< T > &u)
Ret invoke(types< Ret >, std::index_sequence< I >, std::ptrdiff_t n)
fallback_uintptr uintptr_t
U map_or(F &&f, U &&u) const &
map_or
int push(lua_State *Ls) const
probe get(lua_State *L, Key &&key, int tableindex=-2)
int dump(lua_Writer writer, void *userdata, bool strip, Fx &&on_error) const
static int push(lua_State *L, lightuserdata_value userdata)
traits_type::object_type object_type
static detail::error_result add_associative(std::true_type, lua_State *L, T &self, stack_object key, Iter &pos)
LUAMOD_API int luaopen_package(lua_State *L)
int trampoline(lua_State *L, Fx &&f, Args &&...args)
static int call(lua_State *L)
basic_object(lua_State *L, in_place_t, T &&arg, Args &&...args) noexcept
constexpr bool is_lua_c_function_v
void script(lua_State *L, lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
basic_protected_function(const stack_reference &r)
load_result load(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
std::unique_ptr< T, Dx > make_unique_deleter(Args &&...args)
call_status luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount, detail::protected_handler< b, handler_t > &h) const
int operator()(types< Fx >, meta::index_value< I >, types< R >, types< Args... >, lua_State *L, int, int) const
const_reverse_iterator crend() const
typename voider< Ts... >::type void_t
static detail::error_result erase_key_has(std::true_type, lua_State *L, T &self, K &key)
static int real_pairs_traits(std::true_type, lua_State *L)
static detail::error_result add_insert(std::true_type, lua_State *L, T &self, stack_object value)
#define LUA_TLIGHTUSERDATA
int push() const noexcept
meta::unqualified_t< P > U
void operator()(lua_State *L, submetatable_type smt, reference &fast_index_table)
meta::conditional_t< is_matched_lookup::value, std::pair< value_type, value_type >, meta::conditional_t< is_associative::value||is_lookup::value, value_type, std::pair< std::ptrdiff_t, value_type > > > KV
static int real_set_traits(std::true_type, lua_State *L)
static int push(lua_State *L, const user< T > &u)
static int real_empty_call(lua_State *L)
static int real_ipairs_traits(std::false_type, lua_State *L)
decoded_result< It > utf16_to_code_point(It it, It last)
yielding_t(Arg0 &&arg0, Arg1 &&arg1, Args &&...args)
static int real_call(lua_State *L) noexcept(false)
int multi_push_reference(lua_State *)
~protected_function_result()
std::string associated_type_name(lua_State *L, int index, type t)
auto as_function(Args &&...args)
LUA_API int lua_error(lua_State *L)
LUALIB_API int luaL_loadbufferx(lua_State *L, const char *buff, size_t size, const char *name, const char *mode)
stack_iterator< stack_proxy, false > iterator
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(optional &&rhs)&&
disjunction
#define luaL_getmetatable(L, n)
basic_variadic_results(unsafe_function_result fr)
basic_metatable< stack_reference > stack_metatable
void * align_usertype_pointer(void *ptr)
std::string short_demangle_once()
basic_environment(env_key_t, const basic_reference< b > &extraction_target)
basic_lua_table(lua_State *L, T &&r)
typename T::value_type value_type
static detail::error_result erase_after_has(std::false_type, lua_State *, T &, const K &)
bool check_types(lua_State *, int, Handler &&, record &)
decltype(&inheritance< void >::type_unique_cast< void >) inheritance_unique_cast_function
optional_copy_assign_base & operator=(const optional_copy_assign_base &rhs)
T const & value() const &
basic_function< stack_reference, false > stack_unsafe_function
decltype(auto) call(Args &&...args)
error get_traceback_or_errors(lua_State *L)
static constexpr bool is_invalid(unsigned char b)
stack_iterator(const stack_iterator< proxy_t, true > &r)
int(lua_State *, int, type, type, const char *) check_handler_type
const value_type & const_reference
#define lua_tonumber(L, i)
int pop_count() const noexcept
static int push_rvalue(std::true_type, lua_State *L, C &&cont)
SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base() noexcept
static lua_State *& thread_local_lua_state()
basic_reference & operator=(basic_reference<!main_only > &&r) noexcept
std::string make_string(Arg &&arg)
basic_lightuserdata(lua_State *L, ref_index index)
void modify_unique_usertype(const stack_reference &obj, F &&f)
basic_lua_table(T &&r) noexcept
static int push(lua_State *L, T &&c)
static void push_back_at_end(std::true_type, types< V >, lua_State *L, T &cont, std::size_t)
basic_coroutine(const basic_function< base_t > &b, handler_t eh)
lua_State * lua_state() const
policy_wrapper< F, Policies... > P
int copy(lua_State *L) const noexcept
static int clear(lua_State *L)
basic_reference & operator=(const basic_reference<!main_only > &r) noexcept
char short_src[LUA_IDSIZE]
LUAMOD_API int luaopen_coroutine(lua_State *L)
auto initializers(Functions &&...functions)
basic_table_core(lua_State *L, ref_index index)
protected_function_result do_string(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
static void insert_at_end(std::true_type, types< V >, lua_State *L, T &cont, std::size_t)
LUALIB_API int luaL_newmetatable(lua_State *L, const char *tname)
state_view(this_state Ls)
static int at_call(lua_State *L)
unsafe_function_result & operator=(unsafe_function_result &&o) noexcept
bool error() const noexcept
decltype(auto) call_from_top(types< R > tr, types< Args... > ta, lua_State *L, Fx &&fx, FxArgs &&...args)
Container dump(Fx &&on_error) const
void clear_package_loaders()
const_reverse_iterator crbegin() const
bool operator!=(const basic_table_iterator &right) const
static int push(lua_State *L, const wchar_t *str)
constexpr const char * not_enough_stack_space_meta_function_name
void(*)(stack_reference) undefined_method_func
static int call(lua_State *L) noexcept(traits_type::is_noexcept)
int(* lua_CFunction_noexcept)(lua_State *L) noexcept
static int real_pairs_call(lua_State *L)
lua_State * lua_state() const noexcept
#define SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_
static int find(lua_State *L)
static int call(lua_State *L, const no_construction &)
static bool check(lua_State *L, int index, type index_type, Handler &&handler, record &tracking)
constexpr bool is_userdata_v
void convert(const char *strb, const char *stre, F &&f)
static int next_iter(lua_State *L)
static detail::error_result set_comparative(std::true_type, lua_State *L, T &self, stack_object okey, stack_object value)
lua_value(lua_State *L_, reference r)
std::remove_pointer_t< std::decay_t< Function > > function_type
optional & operator=(U &&u)
static int convert_into(lua_State *L, char *start, std::size_t, const char32_t *strb, const char32_t *stre)
basic_reference(const basic_reference<!main_only > &o) noexcept
meta::boolean< has_traits_at_test< T >::value > has_traits_at
optional(optional< U > &&rhs)
basic_environment(lua_State *L, int index=-1)
basic_coroutine(lua_State *L, ref_index index, handler_t eh)
static detail::error_result get_associative(std::true_type, lua_State *L, Iter &it)
meta::bind_traits< function_type >::args_list args_lists
char[SOL_ID_SIZE_I_] typical_chunk_name_t
int handle_errors(lua_State *L, const error_result &er)
stateless_reference(lua_State *L, int index=-1) noexcept
stateless_reference(lua_State *L, ref_index index) noexcept
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
lua_bind_traits< F > traits_type
S get_into(lua_State *L, int index, record &tracking)
bool valid() const noexcept
bool operator()(const lua_nil_t &lhs, const basic_reference< rb > &rhs) const
std::true_type can_swap(int) noexcept(noexcept(swap(std::declval< T & >(), std::declval< U & >())))
static int find(std::true_type, lua_State *L)
decltype(auto) get_value(std::true_type, T &&t)
lua_CFunction meta_new_idx_call
static int call(lua_State *L)
std::ptrdiff_t difference_type
pointer operator->() const
static int push(lua_State *L, cl_t cl)
std::size_t hash(const BasicJsonType &j)
hash a JSON value
push_function(lua_State *L)
std::reverse_iterator< iterator > reverse_iterator
variadic_args(lua_State *luastate, int stackindex, int lastindex)
void script_file(lua_State *L, const std::string &filename, load_mode mode=load_mode::any)
stateless_reference(stack_reference &&r) noexcept
basic_userdata(stack_reference &&r)
static detail::error_result erase_start(lua_State *L, T &self, K &key)
static bool check(types< U >, lua_State *L, int index, type indextype, Handler &&handler, record &tracking)
stateless_reference(const stack_reference &r) noexcept
static detail::error_result add_associative(std::false_type, lua_State *L, T &self, stack_object value)
SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base(in_place_t, U &&...u)
static int push(lua_State *L, c_closure cc)
meta::boolean< has_traits_pairs_test< T >::value > has_traits_pairs
protected_function_result safe_script_file(const std::string &filename, Fx &&on_error, load_mode mode=load_mode::any)
int new_index_target_fail(lua_State *L, void *)
bool operator()(A &&, B &&) const
static detail::error_result find_has_associative_lookup(std::false_type, lua_State *L, T &self)
std::reverse_iterator< const_iterator > const_reverse_iterator
void set(lua_State *L, Key &&key, Value &&value, int tableindex=default_table_index)
const_reverse_iterator rend() const
unsafe_function lua_func_
static T & get(lua_State *L, int index, record &tracking)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
detail::proxy_key_t< Key > key_type
usertype_storage< T > & get_usertype_storage(lua_State *L)
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
lua_State * pick_main_thread(lua_State *L, lua_State *backup_if_unsupported=nullptr)
decltype(auto) base_class_new_index_propogation_key()
virtual const char * what() const noexceptoverride
meta::conditional_t< is_matched_lookup::value, std::ptrdiff_t, K > next_K
bool property_always_true(meta_function)
static int push(std::true_type, lua_State *L, const T &tablecont)
int operator()(lua_State *L)
static int call(lua_State *L)
typename std::conditional< B, T, F >::type conditional_t
int call_exception_handler(lua_State *L, optional< const std::exception & > maybe_ex, string_view what)
basic_coroutine(stack_reference &&r, handler_t eh)
const char * what() const noexcept
LUA_API lua_Number lua_tonumberx(lua_State *L, int idx, int *pisnum)
constexpr type lua_type_of_v
LUAMOD_API int luaopen_io(lua_State *L)
decltype(auto) get(Keys &&...keys) const
tie_t & operator=(T &&value)
void clear(stack_reference &r)
int registry_index() const noexcept
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) const &&
stack_proxy get(const unsafe_function_result &fr)
std::add_pointer_t< meta::unqualified_t< std::remove_pointer_t< T >>> C
table_proxy & operator=(T &&other)&
constexpr const char * not_enough_stack_space_generic
static int index_call(lua_State *L)
meta::neg< is_insert_mode< T >> is_not_insert_mode
basic_object_base< base_type > base_t
int new_index_fail(lua_State *L)
static int push(lua_State *L, const char32_t(&str)[N], std::size_t sz)
std::ptrdiff_t difference_type
const_iterator cbegin() const
stack_proxy(lua_State *L, int index)
static bool empty_start(lua_State *L, T &self)
static void destroy(T &&obj)
basic_environment(lua_State *L, new_table t, const basic_reference< b > &fallback)
static R apply(std::index_sequence<>, lua_State *, int, record &, Args &&...args)
static void call(Args...)
basic_userdata< main_reference > main_userdata
LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l)
LUA_API int lua_geti(lua_State *L, int idx, lua_Integer n)
basic_protected_function(const proxy_base< Super > &p)
static int ipairs(lua_State *L)
static int push(lua_State *L, protect_t< T > &&pw)
static int find(std::false_type, lua_State *L)
static int push(lua_State *L, const factory_wrapper< Functions... > &fw, function_detail::call_indicator)
basic_coroutine(lua_State *L, T &&r)
basic_lua_table(stack_reference &&r)
basic_lua_table(lua_nil_t r) noexcept
basic_thread< reference > thread
table create_table(Name &&name, int narr, int nrec, Key &&key, Value &&value, Args &&...args)
bool valid(lua_State *L) const noexcept
static int set_call(lua_State *L)
int operator()(lua_State *L)
int call_lua(lua_State *L, int start, Fx &&fx, FxArgs &&...fxargs)
traits_type::args_list args_list
detail::invoke_result_t< U > map_or_else(F &&f, U &&u)&
Maps the stored value with f if there is one, otherwise calls u and returns the result.
this_state(lua_State *Ls)
type get_type(int index_offset=0) const noexcept
basic_environment(stack_reference &&r)
basic_userdata< stack_reference > stack_userdata
static int push(lua_State *L, char16_t c)
lua_bind_traits< U > traits_type
constexpr optional(const T &u)
decltype(auto) unqualified_get(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
stateless_reference(lua_State *L, const stack_reference &r) noexcept
static int push_rvalue(std::false_type, lua_State *L, const C &cont)
static int push(lua_State *L, Args &&...args)
auto factories(Functions &&...functions)
constexpr bool is_lua_reference_v
protected_function_result script_file(const std::string &filename, const environment &env, load_mode mode=load_mode::any)
basic_protected_function(basic_function< base_t > &&b, handler_t eh)
static int erase(lua_State *L)
basic_object(detail::no_safety_tag, lua_State *L, ref_index index)
change_indexing_mem_func change_indexing
LUA_API void lua_pushvalue(lua_State *L, int idx)
#define luaL_loadbuffer(L, s, sz, n)
int index_target_fail(lua_State *L, void *)
static int real_empty_traits(std::true_type, lua_State *L)
LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
stack_aligned_safe_function stack_aligned_protected_function
usertype_storage_base(lua_State *L)
basic_lua_table(lua_State *L, int index=-1)
const destructor_wrapper< void > default_destructor
std::make_index_sequence< sizeof...(Args)> indices
protected_function_result script_default_on_error(lua_State *L, protected_function_result pfr)
usertype< Class > new_usertype(const std::string &name, Args &&...args)
LUALIB_API int luaL_execresult(lua_State *L, int stat)
LUA_API int lua_rawgetp(lua_State *L, int idx, const void *p)
static int call(lua_State *L, P &fx)
typename wrap::object_type object_type
void set_undefined_methods_on(stack_reference)
int is_check(lua_State *L)
auto policies(F &&f, Args &&...args)
meta::unqualified_t< T > U
static int push(lua_State *L, detail::tagged< T, constructor_wrapper< Fxs... >> &&c)
#define LUA_RIDX_MAINTHREAD
decltype(auto) call(Args &&...args) const
std::variant_size< V > V_size
meta::unqualified_t< typename traits_type::template arg_at< 0 > > object_type
basic_string_view< char > string_view
basic_environment(lua_nil_t r) noexcept
int push(lua_State *L) const noexcept
unsafe_function_result operator()(Args &&...args) const
void set_fx(types<>, Key &&key, Fx &&fx, Args &&...args)
static detail::error_result get_comparative(std::true_type, lua_State *L, T &self, K &key)
basic_protected_function(lua_State *L, absolute_index index, handler_t eh)
static bool max_size_check(std::true_type, T &cont, std::size_t idx)
int operator()(types< Fx >, meta::index_value< I >, types< R... >, types< Args... >, lua_State *L, int, int, F &fx)
void get_field(lua_State *L, Key &&key)
unsafe_function_result(unsafe_function_result &&o) noexcept
static int push(lua_State *, const this_main_state &)
static table create_table(lua_State *L, int narr=0, int nrec=0)
static int push(lua_State *L, detail::tagged< T, constructor_list< Lists... >>)
void * align(std::size_t alignment, std::size_t size, void *&ptr, std::size_t &space)
static int real_next_call(lua_State *L)
static int push(lua_State *L, no_construction c, function_detail::call_indicator)
constexpr optional< typename std::decay< U >::type > conjunction(U &&u) const
traits_type::returns_list returns_list
protected_function_result() noexcept=default
static int call(lua_State *L, readonly_wrapper< F > &&rw)
constexpr void resolve_f(std::false_type, F &&)
static int call(lua_State *L, function_arguments< Sig, P > &&f)
static int push(lua_State *L, const wchar_t *wstr)
bool valid() const noexcept
basic_environment(T &&r) noexcept
int operator()(types< Fx >, meta::index_value< I >, types< R... >, types< Args... >, lua_State *L, int, int, F &fx)
static int push(lua_State *L, const overload_set< Functions... > &set)
load_result & operator=(load_result &&o) noexcept
meta::boolean< has_clear_test< T >::value > has_clear
LUA_API void lua_settop(lua_State *L, int idx)
int registry_index() const noexcept
LUA_API int lua_getmetatable(lua_State *L, int objindex)
constexpr optional< Ret > make_optional(U &&v)
int set_ref(lua_State *L, T &&arg, int tableindex=-2)
static int push(lua_State *L, const char *strb, const char *stre)
static int push(lua_State *L, const protected_function_result &pfr)
static std::size_t size_start(lua_State *L, T &self)
static std::ptrdiff_t index_adjustment(lua_State *, T &)
object require_script(const std::string &key, const string_view &code, bool create_global=true, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
basic_object(lua_nil_t r)
luaL_Reg[64] lua_reg_table
basic_object & operator=(const proxy_base< Super > &r)
reference named_index_table
static const std::string & qualified_name()
table create_with(Args &&...args)
static detail::error_result add_push_back(std::false_type, lua_State *L, T &self, stack_object value)
bool operator<=(const stack_iterator &r) const
const yield_tag_t yield_tag
basic_table_core & add(Args &&...args)
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
lua_value(lua_State *L_, std::initializer_list< std::pair< lua_value, lua_value >> il)
static int length_call(lua_State *L)
const type_panic_t type_panic
basic_reference & operator=(basic_reference &&r) noexcept
static auto size_has(std::true_type, lua_State *, T &self)
LUA_API void lua_setglobal(lua_State *L, const char *name)
LUA_API int lua_getglobal(lua_State *L, const char *name)
load_result load(lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
#define lua_upvalueindex(i)
LUAMOD_API int luaopen_table(lua_State *L)
gc_mode change_gc_mode_incremental(int pause, int step_multiplier, int step_byte_size)
void type_error(lua_State *L, int expected, int actual) noexcept(false)
constexpr bool is_transparent_argument_v
static int push(lua_State *L, const destructor_wrapper< Fx > &c)
void handle_policy(static_stack_dependencies< I, In... >, lua_State *L, int &)
stack_iterator operator--(int)
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
#define lua_pcall(L, n, r, f)
reference const_value_index_table
usertype_container< X > deferred_uc
static int push(std::false_type, std::integral_constant< bool, is_nested >, lua_State *L, const T &tablecont)
const T & value() const &
static int push(lua_State *L, as_container_t< T > &&as_cont)
typename u_traits::actual_type Real
static char32_t combine_surrogates(char16_t lead, char16_t trail)
object require_file(const std::string &key, const std::string &filename, bool create_global=true, load_mode mode=load_mode::any)
static int pairs_associative(std::true_type, lua_State *L)
static int push(lua_State *L, const as_container_t< T > &as_cont)
const no_metatable_t no_metatable
std::shared_ptr< T > actual_type
probe apply(std::index_sequence< I, I1, In... >, int sofar, lua_State *L, Keys &&keys, int tableindex)
constexpr detail::invoke_result_t< F, const T & > and_then(F &&f) const &
static int push(lua_State *L, const char(&str)[N], std::size_t sz)
basic_environment(lua_State *L, ref_index index)
decltype(auto) unchecked_unqualified_get(lua_State *L, int index, record &tracking)
static constexpr bool is_surrogate(char32_t u)
lua_State * thread_state() const
LUALIB_API void luaL_openlibs(lua_State *L)
int construct_match(Match &&matchfx, lua_State *L, int fxarity, int start, Args &&...args)
bool xmovable(lua_State *leftL, lua_State *rightL)
bool maybe_indexable(lua_State *L, int index=-1)
static int call(lua_State *L, const readonly_wrapper< F > &rw, object_type &o)
decltype(auto) writeonly_property(F &&f)
void reserve(std::basic_string< T, Tr, Al > &str, std::size_t hint)
bool check_stack(int modification=0) const
static detail::error_result add_insert_after(std::true_type, lua_State *, T &self, stack_object value, Iter &pos)
const_iterator cbegin() const
static detail::error_result erase_associative_lookup(std::true_type, lua_State *, T &self, const K &key)
std::in_place_index_t< I > in_place_index_t
auto invoke(types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
T ** usertype_allocate_pointer(lua_State *L)
basic_coroutine(const proxy_base< Super > &p)
static int push(lua_State *L, const char16_t(&str)[N], std::size_t sz)
lua_State * operator->() const noexcept
optional< T > or_else(F &&f)&&
main_unsafe_function main_function
std::pair< T, int > get_as_upvalues(lua_State *L, int index=2)
const T & value() const &
int oss_default_to_string(std::false_type, lua_State *L)
basic_protected_function(basic_function< base_t > &&b)
std::remove_pointer_t< std::decay_t< Function > > function_type
dump_error(int error_code_)
static int clear_call(lua_State *L)
basic_protected_function(lua_State *L, int index, handler_t eh)
constexpr optional disjunction(const optional &rhs) const &
disjunction
void for_each(Fx &&fx) const
int push(lua_State *target) const
basic_environment(env_key_t, const stack_reference &extraction_target)
LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar)
stateless_stack_reference(lua_nil_t) noexcept
reference operator[](difference_type idx) const
static int at(lua_State *L)
basic_table_core(lua_State *L, int index=-1)
constexpr bool is_unique_usertype_v
static bool is_null(const actual_type &p)
static void * type_cast_bases(types< Base, Args... >, T *data, const string_view &ti)
unsafe_function_result & operator=(const unsafe_function_result &)=delete
LUAMOD_API int luaopen_base(lua_State *L)
LUALIB_API void * luaL_testudata(lua_State *L, int ud, const char *tname)
std::remove_pointer_t< std::decay_t< Function > > function_type
decltype(auto) base_class_cast_key()
void set_fx(types< R(Args...)>, Key &&key, Fx &&fx)
optional & operator=(const optional< U > &rhs)
LUA_API int lua_status(lua_State *L)
const_iterator end() const
bool interop_check(lua_State *L, int index, type index_type, Handler &&handler, record &tracking)
basic_reference & operator=(const lua_nil_t &) noexcept
closure(lua_CFunction f, int upvalue_count=0)
basic_protected_function(const basic_function< base_t > &b, handler_t eh)
static int index_of(lua_State *L)
const_iterator begin() const
probe probe_get_field(lua_State *L, Key &&key, int tableindex)
std::random_access_iterator_tag iterator_category
const_iterator cend() const
int push(lua_State *L) const noexcept
int cannot_destruct(lua_State *L)
static int push(lua_State *L, const char16_t *u16str)
static auto get(U &&value)
load_result(load_result &&o) noexcept
static int erase(lua_State *L)
int push(lua_State *L, T &&t, Args &&...args)
constructor_wrapper(Arg &&arg, Args &&...args)
static table create(lua_State *L, int narr, int nrec, Key &&key, Value &&value, Args &&...args)
table_proxy(Table table, T &&k)
int overload_match(Match &&matchfx, lua_State *L, int start, Args &&...args)
void top_apply(std::index_sequence< I0, I... >, lua_State *L, Keys &&keys, Value &&value, int tableindex)
table_proxy & set_function(Args &&...args)&
static detail::error_result set_associative(std::false_type, iterator &it, stack_object value)
static int push(lua_State *L, lua_value &&lv)
decltype(auto) get_usertype(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f)&&
basic_environment< reference > environment
bool supports_gc_mode(gc_mode mode) const noexcept
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
int(* lua_CFunction)(lua_State *L)
std::u16string_view u16string_view
protected_function_result script_throw_on_error(lua_State *L, protected_function_result result)
std::tuple< Policies... > policies
static int push(lua_State *L, const unsafe_function_result &fr)
#define l_inspectstat(stat, what)
static T * get_no_lua_nil_from(lua_State *L, void *udata, int index, record &)
variadic_args & operator=(variadic_args &&o)
meta::bind_traits< Signature > fx_t
bool check_metatable(lua_State *L, int index=-2)
const_iterator end() const
unsafe_function_result() noexcept=default
static int real_erase_call(lua_State *L)
meta::conditional_t< is_index, R, W > P
bool unqualified_interop_check(lua_State *L, int index, type index_type, Handler &&handler, record &tracking)
overload_set(Arg &&arg, Args &&...args)
static detail::error_result at_category(std::random_access_iterator_tag, lua_State *L, T &self, std::ptrdiff_t pos)
static std::function< Signature > get_std_func(types< R... >, lua_State *L, int index)
table create_named_table(Name &&name, Args &&...args)
decltype(auto) interop_get(lua_State *L, int index, void *unadjusted_pointer, record &tracking)
void add_package_loader(Fx &&fx, bool clear_all_package_loaders=false)
static detail::error_result insert_has(std::false_type, lua_State *L, T &self, stack_object where, stack_object value)
static auto & get_src(lua_State *L)
static bool is_null(const actual_type &p)
protected_handler(std::false_type, const target_t &target)
int type_panic_c_str(lua_State *L, int index, type expected, type actual, const char *message=nullptr) noexcept(false)
meta::boolean< has_traits_ipairs_test< T >::value > has_traits_ipairs
stateless_reference(lua_nil_t) noexcept
static void insert_at_end(std::false_type, types< V >, lua_State *L, T &cont, std::size_t idx)
int operator()(lua_State *L, int index, type expected, type actual) const noexcept(false)
LUA_API lua_CFunction lua_atpanic(lua_State *L, lua_CFunction panicf)
#define lua_newuserdata(L, s)
int push_reference(lua_State *L, Arg &&arg, Args &&...args)
basic_table_core(stack_reference &&r)
static int push(lua_State *L, P &&p)
static int call(lua_State *L)
int register_usertype(lua_State *L, automagic_enrollments enrollments={})
static int push(lua_State *L, const std::reference_wrapper< T > &t)
static detail::error_result insert_after_has(std::true_type, lua_State *L, T &self, stack_object where, stack_object value)
void set_field(lua_State *L, Key &&key, Value &&value)
basic_object(stack_reference &&r) noexcept
optional< T > or_else(F &&f) const &
std::remove_pointer_t< meta::unwrap_unqualified_t< X > > T
std::shared_ptr< X > rebind_base
constexpr detail::invoke_result_t< F, const T & > and_then(F &&f) const &
global_table globals() const
LUA_API void lua_settable(lua_State *L, int idx)
basic_function(lua_nil_t n)
basic_protected_function(T &&r) noexcept
static int push(lua_State *L, const wchar_t(&str)[N], std::size_t sz)
void handle_policy(P &&p, lua_State *L, int &pushed)
static int index_call(lua_State *L)
ebco & operator=(const T &v)
basic_object & operator=(proxy_base< Super > &&r)
int call_set_assignable(std::true_type, lua_State *L, T &&mem)
index_call_function * new_index
bool impl_check_metatable(lua_State *L, int index, const std::string &metakey, bool poptable)
const void * pointer(lua_State *L) const noexcept
constexpr in_place_index_t< I > in_place_index
U map_or(F &&f, U &&u)&&
map_or
auto operator[](T &&key)&
unsafe_function_result script(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
typename global_table::iterator iterator
void set(lua_State *L, Key &&key, Value &&value)
auto push_invoke(Fx &&fx)
int push(lua_State *L) const noexcept
#define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T)
copy_code_units_utf(Ch *target)
static detail::error_result add_insert(std::false_type, lua_State *L, T &self, stack_object value, Iter &pos)
stack_proxy get(types< Args... >, meta::index_value< 0 >, meta::index_value< I >, const T &fr)
void ensure_package(const std::string &key, T &&sr)
static int index_call(lua_State *L)
auto invoke(types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n)
static auto & get_src(lua_State *L)
#define SOL_GET_FUNCTION_POINTER_UNSAFE_I_
meta::unqualified_t< T > Tu
bool operator()(const stack_reference &lhs, const stack_reference &rhs) const
typename T::template rebind_base< Rebind > is_base_rebindable_test
#define lua_setuservalue(L, idx)
static detail::error_result find_associative_lookup(std::false_type, lua_State *L, T &self, Iter &, std::size_t idx)
function_arguments(Arg &&arg, Args &&...args)
basic_object(lua_State *L, ref_index index) noexcept
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t)
decltype(auto) property(F &&f, G &&g)
void *(* lua_Alloc)(void *ud, void *ptr, size_t osize, size_t nsize)
encoded_result< char > code_point_to_utf8(char32_t codepoint)
stack_proxy reference_type
const_reverse_iterator rend() const
decltype(auto) get_or(Key &&key, T &&otherwise) const
T const & value() const &
void select_member_function(lua_State *L, Fx &&fx, Args &&...args)
static int push(lua_State *L)
constexpr detail::invoke_result_t< F, const T & > and_then(F &&f) const &&
static int real_next_traits(std::true_type, lua_State *L)
basic_protected_function(lua_State *L, T &&r)
static constexpr char32_t decode(unsigned char b0, unsigned char b1)
basic_coroutine< main_reference > main_coroutine
call_status status() const noexcept
basic_object(lua_State *L, lua_nil_t r) noexcept
int usertype_alloc_destruct(lua_State *L)
protected_function_result script(const string_view &code, const basic_environment< E > &env, Fx &&on_error, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
static int clear(lua_State *L)
static detail::error_result set_associative_insert(std::true_type, lua_State *, T &self, Iter &it, K &key, stack_object value)
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f)&
Calls f if the optional is empty std::invoke_result_t<F> must be void or convertible to optional<T>...
void use(int count) noexcept
std::remove_pointer_t< lua_CFunction > lua_CFunction_ref
constexpr const char * not_enough_stack_space_floating
const_iterator end() const
meta::is_detected< detail::is_base_rebindable_test, T > is_base_rebindable_non_void
static detail::error_result add_push_back(std::false_type, lua_State *L, T &self, stack_object value, Iter &pos)
FMT_CONSTEXPR bool find(Ptr first, Ptr last, T value, Ptr &out)
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
encoded_result< char32_t > code_point_to_utf32(char32_t codepoint)
optional & operator=(nullopt_t) noexcept
basic_reference(lua_State *L, basic_reference< r_main_only > &&r) noexcept
int SOL_INTERNAL_UNSPECIALIZED_MARKER_
const_reverse_iterator rbegin() const
static int push(lua_State *L, const property_wrapper< F, G > &pw)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
decltype(auto) base_class_check_key()
constexpr const int simple_usertype_storage_index
unsafe_function_result unsafe_script(lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
LUA_API void lua_pushboolean(lua_State *L, int b)
basic_variadic_results(Arg0 &&arg0, Args &&...args)
lua_State * lua_state() const
decltype(auto) deref_move_only(T &&item)
detail::enable_if_t< std::is_constructible< T, Other >::value &&!std::is_constructible< T, optional< U > & >::value &&!std::is_constructible< T, optional< U > && >::value &&!std::is_constructible< T, const optional< U > & >::value &&!std::is_constructible< T, const optional< U > && >::value &&!std::is_convertible< optional< U > &, T >::value &&!std::is_convertible< optional< U > &&, T >::value &&!std::is_convertible< const optional< U > &, T >::value &&!std::is_convertible< const optional< U > &&, T >::value > enable_from_other
LUA_API int lua_iscfunction(lua_State *L, int idx)
lua_State * lua_state() const
protected_function_result do_reader(lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
static int real_index_get_traits(std::false_type, lua_State *L)
void abandon(lua_State *=nullptr)
lua_thread_state(lua_State *Ls)
#define lua_pushglobaltable(L)
decltype(auto) base_class_index_propogation_key()
basic_string_view< wchar_t > wstring_view
constexpr const int new_index_function_index
int unique_destruct(lua_State *L)
std::wstring_view wstring_view
static int push(lua_State *L, const push_invoke_t< T > &pi)
constexpr bool is_non_factory_constructor_v
static int push(lua_State *L, Arg &&arg, Args &&...args)
optional take() const &
take
static constexpr bool is_trail_surrogate(char32_t u)
static int index_call_(lua_State *L)
static int push(lua_State *L, const char *str, std::size_t len)
typename T::iterator iterator
basic_object(lua_State *L, T &&r)
static int meta_index_call_with_bases(lua_State *L)
table_proxy< global_table &, detail::proxy_key_t< T > > operator[](T &&key)
static int push(lua_State *L, const P &p)
lua_value(std::initializer_list< std::pair< lua_value, lua_value >> il)
protected_function_result safe_script_file(const std::string &filename, const basic_environment< E > &env, load_mode mode=load_mode::any)
int operator()(lua_State *L)
std::remove_pointer_t< std::decay_t< Function >> function_type
basic_lightuserdata< main_reference > main_lightuserdata
lua_value(lua_State *L_, T &&value)
static int push(lua_State *L, const char32_t *u32str)
usertype_proxy && operator=(std::initializer_list< T > other)&&
basic_coroutine(const stack_reference &r)
int return_count() const noexcept
static detail::error_result set_associative_find(std::true_type, lua_State *L, T &self, stack_object okey, stack_object value)
unsafe_function_result script_file(const std::string &filename, load_mode mode=load_mode::any)
basic_object(proxy_base< Super > &&r) noexcept
LUA_API void lua_rawseti(lua_State *L, int idx, lua_Integer n)
protected_function_result script(const string_view &code, Fx &&on_error, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
bool operator==(const basic_table_iterator &right) const
static int push(lua_State *L, Arg &&arg, Args &&...args)
basic_protected_function(lua_State *L, T &&r, handler_t eh)
typename std::decay< T >::type decay_t
void set(lua_State *L, Key &&key, Value &&value)
lua_State * operator->() const noexcept
static decltype(auto) eval(types< Arg, Args... >, std::index_sequence< I, Is... >, lua_State *L, int start, record &tracking, Fx &&fx, FxArgs &&...fxargs)
meta::unqualified_t< T > Tu
static detail::error_result add_copyable(std::true_type, lua_State *L, T &self, stack_object value)
traits_type::returns_list returns_list
basic_object(const proxy_base< Super > &r) noexcept
stack_proxy operator[](difference_type index_offset) const
bool operator()(meta_function mf) const
static int push(lua_State *L, userdata_value data)
std::vector< object, typename std::allocator< object > > base_t
constexpr bool is_container_v
iter(T &source, iterator it)
static int meta_index_call(lua_State *L)
constexpr bool is_base_rebindable_non_void_v
int call_into_lua(types< Ret0, Ret... > tr, types< Args... > ta, lua_State *L, int start, Fx &&fx, FxArgs &&...fxargs)
static int push(lua_State *L, const basic_string_view< Ch, Traits > &sv, std::size_t n)
protected_handler(std::true_type, const target_t &target)
static int insert(lua_State *L)
stack_iterator< stack_proxy, true > const_iterator
static int call(lua_State *L) noexcept(traits_type::is_noexcept)
stateless_reference(int raw_ref_index) noexcept
static detail::error_result add_insert_after(std::false_type, lua_State *L, T &self, stack_object value, Iter &)
static int push(lua_State *, const stack_proxy &ref)
basic_protected_function< stack_reference, true, stack_reference > stack_aligned_stack_handler_function
stack_iterator< stack_proxy, true > const_iterator
basic_lightuserdata(lua_State *L, T &&r)
static detail::error_result get_start(lua_State *L, T &self, K &key)
const_iterator begin() const
static int size(lua_State *L)
LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname)
optional take() const &
take
constexpr bool any_is_constructor_v
stateless_reference(lua_State *, lua_nil_t) noexcept
static int call(lua_State *L, F &&f)
R make_reference_userdata(lua_State *L, T &&value)
std::array< int, 64 > stack_indices
bool is_indeterminate_call_failure(call_status c)
std::remove_extent_t< T > value_type
overloaded_function(Functions...fxs)
void swap(optional &rhs) noexcept(std::is_nothrow_move_constructible< T >::value &&detail::is_nothrow_swappable< T >::value)
stateless_stack_reference(absolute_index i) noexcept
typename std::remove_reference< T >::type remove_reference_t
static int real_length_call(lua_State *L)
static int type_unique_cast_with(void *source_data, void *target_data, const string_view &ti, const string_view &rebind_ti)
lua_State * move_assign(lua_State *L, lua_State *rL, stateless_reference &&r)
constexpr const char * not_enough_stack_space
int push() const noexcept
static int push(lua_State *L, const char(&str)[N])
static detail::error_result set_category(std::input_iterator_tag, lua_State *L, T &self, stack_object okey, stack_object value)
stack_reference(lua_State *L, const stack_reference &r) noexcept
static int find_call(lua_State *L)
static bool is_null(U &&)
basic_protected_function< main_reference, false, reference > main_safe_function
std::vector< std::unique_ptr< char[]> > string_keys_storage
LUA_API void lua_close(lua_State *L)
static int find(lua_State *L)
table_proxy && set_function(Args &&...args)&&
static const std::string & metatable()
basic_protected_function(stack_reference &&r, handler_t eh)
bool valid() const noexcept
probe apply(std::index_sequence< I >, int sofar, lua_State *L, Keys &&keys, int tableindex)
const void * pointer() const noexcept
bool operator()(const stack_reference &lhs, const basic_reference< rb > &rhs) const
std::reference_wrapper< T > value_
enable_if_t<!returns_void< T &&, U... >::value > disable_if_ret_void
iter(T &source, iterator it)
stateless_stack_reference(lua_State *L, int i) noexcept
static int push(lua_State *L, T &&bc, const char *bytecode_name)
static int push(lua_State *L, property_wrapper< F, G > &&pw)
traits_type::args_list args_list
static int real_index_of_call(lua_State *L)
traits_type::returns_list returns_list
void align_one(std::size_t a, std::size_t s, void *&target_alignment)
variadic_args(variadic_args &&o)
int operator()(lua_State *L)
constexpr bool any_is_destructor_v
void add_entry(string_view sv, index_call_storage ics)
traits_type::return_type return_type
basic_coroutine(basic_function< base_t > &&b)
static int push(lua_State *L, T &&bc)
constexpr const char * not_enough_stack_space_environment
std::false_type uses_std(...)
basic_object_base< base_type > base_t
std::tuple< std::add_lvalue_reference_t< Tn >... > base_t
void pop(lua_State *L, int n=1) const noexcept
int call_wrapper_variable(std::true_type, lua_State *L)
basic_coroutine< reference > coroutine
as_table_t(Arg0 &&arg0, Arg1 &&arg1, Args &&...args)
void apply(std::index_sequence< 0, I... >, lua_State *L, Keys &&keys, int tableindex)
static int push(lua_State *L, constructor_list< Lists... >)
constexpr optional() noexcept=default
meta::boolean< has_erase_after_test< T >::value > has_erase_after
constexpr optional(const optional< U > &rhs)
static auto call(Fx &&fx, object_type &mem) -> detail::array_return_type< decltype(mem.*fx)>
LUA_API int lua_gc(lua_State *L, int what,...)
table_core< false > table
bool operator==(const stack_iterator &r) const
void raw_set_field(lua_State *L, Key &&key, Value &&value, int tableindex)
static int push(lua_State *L, const void *userdata)
std::tuple< Functions... > functions
push_popper_n(lua_State *luastate, int x)
static int index_get(lua_State *L)
static detail::error_result find_comparative(std::true_type, lua_State *L, T &self)
std::array< const char *, 4 > args_strings
void * align_usertype_unique_destructor(void *ptr)
detail::enable_if_t< std::is_constructible< T, std::initializer_list< U > &, Args &&... >::value, T & > emplace(std::initializer_list< U > il, Args &&...args)
SOL_TL_OPTIONAL_11_CONSTEXPR T & operator*()&
LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx)
static R invoke(O &mem, Args &&...args)
basic_table_core & set(Args &&...args)
LUA_API void lua_arith(lua_State *L, int op)
as_table_t< T > as_table_ref(T &&container)
LUA_API int lua_pushthread(lua_State *L)
void pop(lua_State *L, int n=1) const noexcept
std::string type_name(lua_State *L, type t)
basic_object(lua_State *L, raw_index index) noexcept
const std::string & default_chunk_name()
load_result load_file(const std::string &filename, load_mode mode=load_mode::any)
basic_reference(const basic_reference &o) noexcept
int(*)(lua_State *, optional< const std::exception & >, string_view) exception_handler_function
static int call(lua_State *L) noexcept(traits_type::is_noexcept)
#define SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T)
auto operator[](T &&key) const &
absolute_index(lua_State *L, int idx)
int dump_pass_on_error(lua_State *L, int result_code, lua_Writer writer_function, void *userdata, bool strip)
static int real_add_traits(std::true_type, lua_State *L)
static int push(lua_State *L, const std::basic_string< Ch, Traits, Al > &str, std::size_t sz)
static int push_with(lua_State *L, Key &&name, Args &&...args)
void set_resolved_function(Key &&key, Args &&...args)
void set_default_exception_handler(lua_State *L, exception_handler_function exf=&detail::default_exception_handler)
int push_type_panic_string(lua_State *L, int index, type expected, type actual, string_view message, string_view aux_message) noexcept
basic_function(stack_reference &&r)
basic_protected_function< stack_reference, true, reference > stack_aligned_safe_function
int push_userdata(lua_State *L, T &&t, Args &&...args)
static detail::error_result erase_after_has(std::true_type, lua_State *L, T &self, K &key)
void change_indexing(lua_State *L, submetatable_type submetatable, void *derived_this, stack_reference &t, lua_CFunction index, lua_CFunction new_index, lua_CFunction meta_index, lua_CFunction meta_new_index)
static int push(lua_State *L, no_metatable_t, user< T > &&u)
usertype_proxy< basic_usertype &, std::decay_t< Key > > operator[](Key &&key)
static int push(lua_State *L, const char16_t(&str)[N])
static int push(lua_State *L, const new_table &nt)
basic_lightuserdata(stack_reference &&r)
SOL_TL_OPTIONAL_11_CONSTEXPR T * operator->()
void open_libraries(Args &&...args)
stack_proxy get(types< Args... > t, const protected_function_result &fr)
basic_coroutine(Proxy &&p, Handler &&eh)
std::tuple< Ps... > arguments
int overload_match_arity_single(types< Fx, Fx1, Fxs... >, std::index_sequence< I, I1, In... >, std::index_sequence< M... >, Match &&matchfx, lua_State *L, int fxarity, int start, Args &&...args)
traits_type::args_list args_list
stack_proxy operator[](difference_type index_offset) const
LUA_API lua_State * lua_tothread(lua_State *L, int idx)
#define lua_pushliteral(L, s)
LUAMOD_API int() luaopen_utf8(lua_State *L)
meta::is_detected< detail::is_base_rebindable_test, T > is_base_rebindable
static int push(lua_State *L, destructor_wrapper< Fx > &&c)
static int push(lua_State *L, const char32_t *str, std::size_t len)
static optional< V > get_one(std::integral_constant< std::size_t, 0 >, lua_State *L, int index, Handler &&handler, record &tracking)
const_reverse_iterator rbegin() const
reference const_reference_index_table
static int erase_call(lua_State *L)
std::vector< std::byte, Allocator > base_t
LUA_API size_t lua_stringtonumber(lua_State *L, const char *s)
LUA_API const char * lua_tolstring(lua_State *L, int idx, size_t *len)
basic_reference< false > reference
static optional< V > get_empty(std::true_type, lua_State *, int, Handler &&, record &)
constructor_list< L0, Lists... > cl_t
LUALIB_API lua_Integer luaL_len(lua_State *L, int idx)
void invoke(types< void >, std::index_sequence< I >, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
void deref(lua_State *L) const noexcept
meta::boolean< has_traits_erase_test< T >::value > has_traits_erase
static const std::string & user_metatable()
LUALIB_API void luaL_unref(lua_State *L, int t, int ref)
static optional< V > get_one(std::integral_constant< std::size_t, I >, lua_State *L, int index, Handler &&handler, record &tracking)
std::size_t total_memory_used(lua_State *L)
static int push(std::true_type, std::integral_constant< bool, is_nested >, lua_State *L, const T &tablecont)
std::integral_constant< bool, V_size::value==0 > V_is_empty
stateless_reference & operator=(stateless_reference &&o) noexcept
constexpr std::array< string_view, 9 > removals
detail::inheritance_unique_cast_function unique_tag
meta::conditional_t< is_const, const proxy_t *, proxy_t * > pointer
std::ptrdiff_t difference_type
static int push(lua_State *L, const destructor_wrapper< Fx > &c)
const int & operator[](std::size_t i) const
error_result(const char *fmt, const char *msg)
std::hash< std::string_view > string_view_hash
basic_environment(lua_State *L, T &&r) noexcept
static int clear(lua_State *L)
static int push_deep(lua_State *L, Args &&...args)
static detail::error_result add_insert(std::true_type, lua_State *, T &self, stack_object value, Iter &pos)
const_iterator cend() const
stack_proxy reference_type
protected_function_result script(const string_view &code, const environment &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
table_proxy && operator=(T &&other)&&
basic_protected_function(lua_nil_t n)
bool multi_check(lua_State *L, int index)
static int call(lua_State *L, readonly_wrapper< F > &&rw, object_type &o)
U map_or(F &&f, U &&u)&
Maps the stored value with f if there is one, otherwise returns u.
decltype(auto) as() const
std::size_t memory_used() const
basic_thread(const stack_reference &r)
static int push(std::index_sequence< I... >, lua_State *L, T &&t)
static int pairs_associative(std::false_type, lua_State *L)
#define lua_isboolean(L, n)
void set_exception_handler(exception_handler_function handler)
std::reverse_iterator< iterator > reverse_iterator
basic_object(lua_State *L, detail::global_tag t)
static void base_walk_index(lua_State *L, usertype_storage_base &self, bool &keep_going, int &base_result)
fx_t::args_list args_lists
int registry_index() const noexcept
decltype(auto) readonly_property(F &&f)
basic_environment< E > get_environment(const T &target)
basic_table_core(lua_State *L, T &&r)
basic_object< stack_reference > stack_object
static int push(lua_State *L, const constructor_wrapper< F, Fxs... > &c)
usertype_proxy && operator=(T &&other)&&
static int push(lua_State *L, const T &v)
std::integral_constant< bool, is_table_v< T >||is_environment_v< T >||is_userdata_v< T >> is_table_like
static detail::error_result find_has_associative_lookup(std::true_type, lua_State *L, T &self)
void update_bases(lua_State *L, bases< Bases... >)
static int next_call(lua_State *L)
int operator()(lua_State *L)
main_table_core< false > main_table
stack_dependencies(int stack_target, Args &&...args)
meta::tuple_types< R > returns_list
constexpr bool is_base_rebindable_v
std::string demangle_once()
stateless_reference(lua_State *L, detail::global_tag) noexcept
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(optional &&rhs)&
disjunction
std::add_pointer_t< meta::unqualified_t< std::remove_pointer_t< T >>> C
stack_proxy_base(lua_State *L, int index)
static int real_insert_traits(std::false_type, lua_State *L)
constexpr const char * not_enough_stack_space_string
static detail::error_result erase_integral(std::false_type, lua_State *L, T &self, const K &key)
int static_trampoline_noexcept(lua_State *L) noexcept
state_view & set_function(Key &&key, Args &&...args)
stack_iterator & operator++()
table_core< true > global_table
struct sol::detail::global_tag global_
LUALIB_API void luaL_checkstack(lua_State *L, int space, const char *msg)
LUA_API int lua_next(lua_State *L, int idx)
static int push(lua_State *L, lua_CFunction func, int n=0)
push_popper_at push_pop_at(T &&x)
main_safe_function main_protected_function
static int push(lua_State *L, const wchar_t *strb, const wchar_t *stre)
#define luaL_checkversion(L)
meta::bind_traits< function_type >::return_type return_type
basic_protected_function< stack_reference, false, reference > stack_safe_function
LUALIB_API const char * luaL_tolstring(lua_State *L, int idx, size_t *len)
static int push_keyed(lua_State *L, K &&k, Args &&...args)
bool is_main_thread(lua_State *L)
static int real_erase_traits(std::false_type, lua_State *L)
const_iterator cend() const
const_iterator cbegin() const
basic_table< base_type > base_t
basic_protected_function(Proxy &&p, Handler &&eh)
static detail::error_result insert_copyable(std::false_type, lua_State *, T &, stack_object, stack_object)
static int index_set(lua_State *L)
tagged(Arg &&arg, Args &&...args)
decoded_result< It > utf8_to_code_point(It it, It last)
basic_userdata(lua_State *L, ref_index index)
types< object_type &, return_type > free_args_list
static int push(lua_State *L, Args &&...args)
static int push(lua_State *L, lua_CFunction func, int n=0)
protected_function_result do_file(const std::string &filename, const basic_environment< E > &env, load_mode mode=load_mode::any)
protected_function_result script_file(const std::string &filename, Fx &&on_error, load_mode mode=load_mode::any)
static R call(Fx &&fx, O &mem, Args &&...args)
stack_reference(lua_State *L, int i) noexcept
void operator()(const unicode::encoded_result< ErCh > er)
LUALIB_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level)
safe_function protected_function
SOL_TL_OPTIONAL_11_CONSTEXPR T & value()
static int pairs_call(lua_State *L)
basic_protected_function(lua_State *L, ref_index index, handler_t eh)
decltype(&inheritance< void >::type_check) inheritance_check_function
stack_iterator< stack_proxy, false > iterator
load_result load_buffer(const std::byte *buff, size_t size, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
decltype(auto) unqualified_check_get(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
static int empty(lua_State *L)
std::unique_ptr< T, D > actual_type
basic_usertype< T, stack_reference > stack_usertype
optional< environment > env
meta::conditional_t< is_associative::value||is_matched_lookup::value, std::add_lvalue_reference_t< V >, meta::conditional_t< is_lookup::value, V, iterator_return > > captured_type
protected_function_result(protected_function_result &&o) noexcept
protected_function_result do_string(const string_view &code, const basic_environment< E > &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
LUA_API void lua_concat(lua_State *L, int n)
lua_bind_traits< meta::unqualified_t< F > > traits_type
basic_coroutine(lua_State *L, raw_index index)
basic_usertype< T, reference > usertype
decltype(auto) get(Keys &&...keys) const
basic_reference(lua_State *L, const basic_reference< r_main_only > &r) noexcept
usertype_proxy(Table table, T &&k)
static detail::error_result add_copyable(std::true_type, lua_State *L, T &self, stack_object value, Iter &pos)
void set_environment(const basic_environment< E > &env, const T &target)
constexpr create_if_nil_t create_if_nil
static bool max_size_check(std::false_type, T &, std::size_t)
constexpr const int base_walking_failed_index
constexpr const T * operator->() const
const char *(* lua_Reader)(lua_State *L, void *ud, size_t *sz)
static V get_one(std::integral_constant< std::size_t, std::variant_size_v< V >>, lua_State *L, int index, record &tracking)
basic_reference(lua_nil_t) noexcept
bool operator()(const lua_nil_t &lhs, const stack_reference &rhs) const
constexpr const char * not_a_number_or_number_string_integral
std::reverse_iterator< const_iterator > const_reverse_iterator
std::nullopt_t nullopt_t
A tag type to represent an empty optional.
const_reverse_iterator crend() const
static int push_func(std::index_sequence< I... >, lua_State *L, FP &&fp)
constexpr auto invoke(Fn &&f, Args &&...args) noexcept(noexcept(std::forward< Fn >(f)(std::forward< Args >(args)...))) -> decltype(std::forward< Fn >(f)(std::forward< Args >(args)...))
static int real_find_traits(std::true_type, lua_State *L)
std::integral_constant< bool, V_size::value==0 > V_is_empty
stack_iterator & operator--()
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(optional &&rhs)&&
disjunction
closure< Args... > make_closure(lua_CFunction f, Args &&...args)
detail::proxy_key_t< Key > key_type
static void check(LexState *ls, int c)
ref_clean(lua_State *luastate, int &n)
static detail::error_result get_it(std::true_type, lua_State *L, T &self, K &key)
basic_coroutine(lua_State *L, absolute_index index, handler_t eh)
detail::named_arg< Char, T > arg(const Char *name, const T &arg)
static int call(lua_State *L, lua_CFunction f)
void traverse_set_deep(int table_index, Key &&key, Keys &&...keys) const
constexpr optional() noexcept
auto invoke(types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n) const
const T & value() const &
yielding_t< std::decay_t< F > > yielding(F &&f)
U map_or(F &&f, U &&u) const &&
map_or
meta::conditional_t< is_input_iterator::value, V, decltype(detail::deref_move_only(std::declval< captured_type >)))> push_type
void coroutine_create_guard(lua_State *L)
LUALIB_API void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int glb)
void operator()(const unicode::encoded_result< Ch > er)
constexpr bool is_lua_reference_or_proxy_v
optional & operator=(nullopt_t) noexcept
meta::conditional_t< meta::is_specialization_of_v< meta::unqualified_t< T >, std::tuple >, T, std::tuple< meta::conditional_t< std::is_array_v< meta::unqualified_t< T >>, std::remove_reference_t< T > &, meta::unqualified_t< T >>>> proxy_key_t
static int codepoint(lua_State *L)
bool operator()(const stack_reference &lhs, const lua_nil_t &rhs) const
const unchecked_t unchecked
table new_enum(const string_view &name, std::initializer_list< std::pair< string_view, T >> items)
reverse_iterator rbegin()
static int push(lua_State *L, T &&t)
lua_State * lua_state() const
static void * type_cast_with(void *voiddata, const string_view &ti)
bool check_function_pointer(lua_State *L, int index, Handler &&handler, record &tracking) noexcept
SOL_TL_OPTIONAL_11_CONSTEXPR T && operator*()&&
static int push(lua_State *L, Args &&...args)
const T & move(const T &v)
static int size(lua_State *L)
SOL_TL_OPTIONAL_11_CONSTEXPR T value_or(U &&u)&&
value_or
bool valid() const noexcept
traits_type::args_list free_args_list
static int push(lua_State *L, constructor_wrapper< F, Fxs... > &&c)
object make_object(lua_State *L, T &&value)
basic_table_core(lua_State *L, const new_table &nt)
static optional< R > get(lua_State *L, int index, Handler &&handler, record &tracking)
optional< T > or_else(F &&f)&&
basic_table_core & set_function(Key &&key, Args &&...args)
static void * type_cast(void *voiddata, const string_view &ti)
SOL_TL_OPTIONAL_11_CONSTEXPR optional(detail::enable_if_t< std::is_constructible< T, std::initializer_list< U > &, Args &&... >::value, in_place_t >, std::initializer_list< U > il, Args &&...args)
static int call(lua_State *L, const readonly_wrapper< F > &rw)
const_iterator cend() const
push_popper_n< top_level > pop_n(lua_State *L, int x)
static int empty_call(lua_State *L)
static handler_t get_default_handler(lua_State *L)
const metatable_key_t metatable_key
basic_metatable< reference > metatable
state(lua_CFunction panic=default_at_panic)
constexpr bool is_environment_v
basic_table_core & traverse_raw_set(Keys &&...keys)
int operator()(lua_State *L)
static bool check(lua_State *L, int index, type indextype, Handler &&handler, record &tracking)
const T & value() const &
static detail::error_result add_insert_after(std::true_type, lua_State *L, T &self, stack_object value)
LUAMOD_API int luaopen_string(lua_State *L)
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
static int push(lua_State *L, const wchar_t *str, std::size_t len)
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(const optional &rhs)&&
disjunction
int operator()(types< Fx >, meta::index_value< I >, types< R... > r, types< Args... > a, lua_State *L, int, int start, F &f)
std::index_sequence_for< Policies... > indices
optional< T > or_else(F &&f) const &&
LUA_API int lua_absindex(lua_State *L, int idx)
int index_of(const Tu &r)
basic_function(lua_State *L, int index=-1)
LUA_API int lua_type(lua_State *L, int idx)
basic_function(const stack_reference &r)
static int index_of(lua_State *L)
static int pairs(lua_State *L)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
optional< T > or_else(F &&f) const &
basic_object(lua_State *L, int index=-1) noexcept
static int push(lua_State *, const stack_proxy_base &ref)
#define assert(a, b, c, d)
lua_CFunction make_destructor()
void select_convertible(types<>, lua_State *L, Fx &&fx, Args &&...args)
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
static detail::error_result set_it(std::true_type, lua_State *L, T &self, stack_object key, stack_object value)
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) const &
decltype(auto) pop(lua_State *L)
basic_protected_function(const stack_reference &r, handler_t eh)
static int index_set(lua_State *L)
implicit_wrapper(T *item)
std::tuple< Functions... > functions
conditional_t< std::is_void< U >::value, monostate, U > fixup_void
auto meta_registry_key(T &&key)
protect_t(Arg &&arg, Args &&...args)
static int add_call(lua_State *L)
const char(& default_handler_name())[9]
void set(Key &&key, Value &&value)
int no_panic(lua_State *, int, type, type, const char *=nullptr) noexcept
static int push(lua_State *L, std::variant< Tn... > &&v)
static int push(lua_State *L, const factory_wrapper< Functions... > &fw)
static int push(lua_State *L, var_wrapper< T > &&vw)
static int insert(lua_State *L)
void set_default_state(lua_State *L, lua_CFunction panic_function=&default_at_panic, lua_CFunction traceback_function=c_call< decltype(&default_traceback_error_handler),&default_traceback_error_handler >, exception_handler_function exf=detail::default_exception_handler)
static int call(lua_State *L, F &&f)
constexpr const int usertype_storage_base_index
static int push(lua_State *L, void *userdata)
protected_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n)
meta::boolean< has_traits_index_get_test< T >::value > has_traits_index_get
stateless_stack_reference(lua_State *, absolute_index i) noexcept
automagic_enrollments & enrollments
constexpr std::in_place_t in_place_of
#define lua_replace(L, idx)
unsafe_function_result unsafe_script(lua_Reader reader, void *data, const basic_environment< E > &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
int push(lua_State *Ls) const noexcept
constexpr bool is_lightuserdata_v
lua_bind_traits< function_type > traits_type
static detail::error_result get_category(std::input_iterator_tag, lua_State *L, T &self, K &key)
basic_object(detail::no_safety_tag, T &&r) noexcept
lua_State * lua_state() const noexcept
static int real_index_set_traits(std::false_type, lua_State *L)
basic_function< base_t > force_cast(T &p)
basic_protected_function(lua_State *L, int index=-1)
constexpr optional(nullopt_t) noexcept
ctor_empty
void operator()(lua_State *L, submetatable_type smt, reference &fast_index_table)
new_index_call_storage static_base_index
basic_table_core< false, base_type > basic_table
meta::boolean< has_traits_next_test< T >::value > has_traits_next
basic_reference(lua_State *L, ref_index index) noexcept
LUAMOD_API int luaopen_math(lua_State *L)
typename strip< T >::type strip_t
meta::return_type_t< R... > operator()(Args &&...args)
#define lua_tostring(L, i)
static int call(lua_State *L, F &f)
basic_table_core< b, reference > table_core
R make_reference(lua_State *L, T &&value)
LUA_API void lua_copy(lua_State *L, int fromidx, int toidx)
void set_extra(std::false_type, std::index_sequence< I... >, T &&target)
lua_bind_traits< function_type > traits_type
void delete_usertype_storage(lua_State *L)
static int push(lua_State *L, detail::yield_tag_t, std::function< Signature > &&fx)
int push(lua_State *L, Arg &&arg, Args &&...args)
int push(lua_State *, lua_thread_state lts)
void set_panic(lua_CFunction panic)
::std::size_t operator()(const ::sol::optional< T > &o) const
void set_extra(std::true_type, std::index_sequence< I... >, T &&target)
static int push(lua_State *L, Args &&...args)
static int push(lua_State *, stack_count st)
static int push(lua_State *L, const char32_t *strb, const char32_t *stre)
LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction fn, int n)
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T && > and_then(F &&f)&&
void stack_fail(int, int)
lua_value(lua_State *L_, arr il)
static detail::error_result add_copyable(std::false_type, lua_State *L, T &self, stack_object value, Iter &)
constexpr optional(U &&u)
unsafe_function_result unsafe_script_file(const std::string &filename, load_mode mode=load_mode::any)
char[SOL_FILE_ID_SIZE_I_] typical_file_chunk_name_t
static iterator begin(lua_State *, T &self)
meta::boolean< has_empty_test< T >::value > has_empty
protected_function_result safe_script(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
void usertype_unique_alloc_destroy(void *memory)
closure(lua_CFunction f, Upvalues...targetupvalues)
meta::unqualified_t< decltype(get_key(is_associative(), std::declval< std::add_lvalue_reference_t< value_type >>()))> key_type
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) const &&
optional & operator=(const optional< U > &rhs)
const char(& default_exception_handler_name())[11]
void swap(optional< T > &lhs, optional< T > &rhs) noexcept(noexcept(lhs.swap(rhs)))
template <class t>=""> swap(optional<T> &lhs, optional<T> &rhs);
U map_or(F &&f, U &&u)&
Maps the stored value with f if there is one, otherwise returns u.
stack_safe_function stack_protected_function
static bool is_one(std::integral_constant< std::size_t, 0 >, lua_State *L, int index, Handler &&handler, record &tracking)
stack_proxy operator[](difference_type index_offset) const
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f)&
Calls f if the optional is empty std::invoke_result_t<F> must be void or convertible to optional<T>...
int dump_panic_on_error(lua_State *L, int result_code, lua_Writer writer_function, void *userdata, bool strip)
is_stack_based< target_t > is_stack
static optional< V > get_empty(std::false_type, lua_State *L, int index, Handler &&handler, record &)
result_type operator()(const basic_reference< lb > &lhs) const
SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base(in_place_t, U &&...u)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
std::remove_pointer_t< std::decay_t< Function > > function_type
auto & pick(std::false_type, property_wrapper< R, W > &f)
std::ptrdiff_t difference_type
std::ptrdiff_t difference_type
int push_reference(lua_State *L, Arg &&arg, Args &&...args)
factory_wrapper< Fs... > F
static int push(lua_State *L, factory_wrapper< Functions... > &&fw, function_detail::call_indicator)
basic_coroutine(lua_State *L, T &&r, handler_t eh)
int static_trampoline(lua_State *L)
std::pair< object, object > value_type
static int index_set(lua_State *L)
SOL_TL_OPTIONAL_11_CONSTEXPR const T & value() const
basic_lightuserdata(const stack_reference &r)
std_shim(unsafe_function lua_func)
std::reverse_iterator< iterator > reverse_iterator
static int call(lua_State *L, detail::lua_CFunction_noexcept f)
void * align_usertype_unique(void *ptr)
const auto no_constructor
basic_variadic_results(protected_function_result fr)
std::function< void(int, int)> on_mismatch
constexpr const char * protected_function_error
basic_coroutine(const basic_function< base_t > &b)
basic_thread(lua_State *L, this_state actualthread)
static table create_table_with(lua_State *L, Args &&...args)
static bool check(lua_State *, int, type, Handler &&, record &)
policy_wrapper(Fx &&fx, Args &&...args)
#define lua_call(L, n, r)
LUA_API void lua_rotate(lua_State *L, int idx, int n)
LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char *chunkname, const char *mode)
typename u_traits::type P
void type_assert(lua_State *L, int index, type expected, type actual) noexcept(false)
static int at(lua_State *L)
property_wrapper(Rx &&r, Wx &&w)
LUALIB_API void luaL_addvalue(luaL_Buffer *B)
~unsafe_function_result()
constexpr const int index_function_index
basic_coroutine(stack_reference &&r)
stack_reference(lua_State *L, raw_index i) noexcept
constexpr bool is_stack_table_v
static_stack_dependencies<-1, 1 > self_dependency
type get_type(difference_type index_offset=0) const noexcept
basic_table_core(detail::no_safety_tag, lua_State *L, T &&r) noexcept
static detail::error_result erase_has(std::true_type, lua_State *L, T &self, K &key)
basic_userdata< reference > userdata
int default_size(lua_State *L)
clean(lua_State *luastate)
lua_State * lua_state() const noexcept
lua_State * lua_state() const noexcept
table create(int narr=0, int nrec=0)
void reset() noexcept
Destroys the stored value if one exists, making the optional empty.
static int size(lua_State *L)
static iterator begin(lua_State *, T &self)
void get(lua_State *L, Key &&key, int tableindex=default_table_index)
static constexpr bool is_lead_surrogate(char32_t u)
destructor_wrapper(Function f)
reference reference_index_table
auto as_function_reference(Args &&...args)
basic_environment(lua_State *L, new_table nt)
static int real_set_call(lua_State *L)
int c_trampoline(lua_State *L, lua_CFunction f)
int call_set_variable(std::true_type, lua_State *L, T &&mem)
bool operator>=(const stack_iterator &r) const
LUA_API lua_State * lua_newthread(lua_State *L)
lua_bind_traits< function_type > traits_type
void operator()(T *p) const
bool is_valid(std::false_type)
std::reference_wrapper< T > value_
static bool type_check(const string_view &ti)
result_type operator()(const argument_type &lhs) const
static int push(lua_State *L, const char32_t *u32str, std::size_t sz)
userdata_value(void *data)
auto unwrap(T &&item) -> decltype(std::forward< T >(item))
basic_object & operator=(base_type &&b)
static iterator end(lua_State *L, T &)
as_container_t(Arg &&arg)
static int push(lua_State *L, detail::lua_CFunction_noexcept func, int n=0)
static bool empty_has(std::true_type, lua_State *, T &self)
static int real_call(lua_State *L) noexcept(false)
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(const optional &rhs)&
const_iterator cbegin() const
basic_protected_function< reference, false, reference > safe_function
typename global_table::const_iterator const_iterator
table create_table(int narr=0, int nrec=0)
table create_table_with(Args &&...args)
nested< meta::unqualified_t< T > > as_nested(T &&container)
static int index_get(lua_State *L)
basic_table_core(T &&r) noexcept
static int empty(lua_State *L)
constexpr const char * not_enough_stack_space_floating
LUALIB_API int luaL_getsubtable(lua_State *L, int idx, const char *fname)
basic_thread(stack_reference &&r)
T * user_allocate(lua_State *L)
returns_self_with returns_self
constexpr const char * not_enough_stack_space_userdata
int construct_trampolined(lua_State *L)
constexpr const char * not_a_number_or_number_string
static detail::error_result add_push_back(std::true_type, lua_State *, T &self, stack_object value, Iter &)
constexpr bool has_value() const noexcept
static int real_get_call(lua_State *L)
static Reference get_default_handler(lua_State *L)
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
void(usertype_storage_base::*)(lua_State *, submetatable_type, void *, stack_reference &, lua_CFunction, lua_CFunction, lua_CFunction, lua_CFunction) change_indexing_mem_func
static int push(lua_State *L, const Tagged &p)
constexpr const int usertype_storage_index
static int push(lua_State *L, destructor_wrapper< void >)
static int push(lua_State *L, Arg &&arg, Args &&...args)
int operator()(types< Fx >, meta::index_value< I >, types< R... > r, types< Args... > a, lua_State *L, int, int start) const
void invoke(types< void >, std::index_sequence< I >, std::ptrdiff_t n) const
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
static void construct(T &&obj, Args &&...args)
static bool is_one(std::integral_constant< std::size_t, I >, lua_State *L, int index, Handler &&handler, record &tracking)
usertype_proxy & operator=(T &&other)&
basic_thread(lua_State *L, lua_State *actualthread)
static int call(lua_State *L, std::reference_wrapper< T > f)
static int get_size_hint(const std::forward_list< V, Al > &)
int call_wrapped(lua_State *L, Fx &&fx, Args &&...args)
void tuple_set(std::index_sequence< I... >, T &&value)&
static int push(lua_State *L, const T &tablecont, nested_tag_t)
probe probe_raw_get_field(lua_State *L, Key &&key, int tableindex)
call_status status() const noexcept
#define LUA_REGISTRYINDEX
static int push(lua_State *L, destructor_wrapper< Fx > &&c)
int operator()(lua_State *L, int index, type expected, type actual, string_view message) const noexcept(false)
const_iterator begin() const
state_view(lua_State *Ls)
static constexpr bool is_continuation(unsigned char b)
static int push(lua_State *L, push_invoke_t< T > &&pi)
static detail::error_result at_start(lua_State *L, T &self, std::ptrdiff_t pos)
gc_mode change_gc_mode_generational(int minor_multiplier, int major_multiplier)
static detail::error_result set_writable(std::false_type, lua_State *, T &, iterator &, stack_object)
constexpr const int magic_index
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
static int call(lua_State *L, Fx &&fx, Args &&...args)
static int at(lua_State *L)
basic_protected_function(lua_State *L, ref_index index)
static T * get_no_lua_nil(lua_State *L, int index, record &tracking)
static int real_at_call(lua_State *L)
basic_lightuserdata< stack_reference > stack_lightuserdata
static optional< R > get(lua_State *L, int index, Handler &&handler, record &tracking)
static int push_lvalue(std::false_type, lua_State *L, const C &cont)
static int erase(lua_State *L)
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > and_then(F &&f)&
stateless_reference(lua_State *L, stateless_reference &&r) noexcept
type get_type(lua_State *L) const noexcept
void tuple_set(std::index_sequence< I... >, Pairs &&pairs)
basic_table_core & traverse_set(Keys &&...keys)
static int index_call_with_bases_(lua_State *L)
#define SOL_CONTAINER_START_INDEX_I_
int operator()(lua_State *L)
std::in_place_t in_place_t
void apply(std::index_sequence< I0, I1, I... >, lua_State *L, Keys &&keys, Value &&value, int tableindex)
static int real_clear_traits(std::true_type, lua_State *L)
constexpr optional disjunction(optional &&rhs) const &
disjunction
load_result load_buffer(const char *buff, size_t size, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
auto setup_table(std::true_type)
void(*)(void *) unique_destructor
struct sol::detail::no_safety_tag no_safety
void set_fx(types<>, Key &&key, Fx &&fx)
static int push(lua_State *L, nullopt_t)
static int push(lua_State *L, const char *str, std::size_t len)
basic_object(detail::no_safety_tag, lua_State *L, int index)
traits_type::args_list free_args_list
lua_CFunction meta_idx_call
static int push(lua_State *L, detail::lua_CFunction_noexcept func, int n=0)
#define lua_istable(L, n)
LUALIB_API lua_State * luaL_newstate(void)
std::tuple< Functions... > overload_list
type get_type() const noexcept
LUA_API void lua_len(lua_State *L, int idx)
static int index_call_(lua_State *L)
LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename, const char *mode)
static int new_index_call(lua_State *L)
int construct(lua_State *L)
constexpr const int exact_function_index
const_reverse_iterator crbegin() const
unsafe_function lua_func_
static int call(lua_State *L, Fx &&f, Args &&...args)
void raw_get_field(lua_State *L, Key &&key, int tableindex)
has_clear< T > has_traits_clear
int stack_index() const noexcept
int operator()(lua_State *L, int index, type expected, type actual, string_view message) const noexcept(false)
static detail::error_result find_has(std::true_type, lua_State *L, T &self)
static bool type_check_with(const string_view &ti)
static int pairs(lua_State *L)
int multi_push(lua_State *L, T &&t, Args &&...args)
std::decay_t< meta::unwrap_unqualified_t< Func > > function_type
static int real_at_traits(std::true_type, lua_State *L)
LUALIB_API void luaL_setmetatable(lua_State *L, const char *tname)
int copy(lua_State *L) const noexcept
static detail::error_result get_category(std::random_access_iterator_tag, lua_State *L, T &self, K &key)
Function * get_function_pointer(lua_State *, int, record &) noexcept
decltype(&inheritance< void >::type_cast) inheritance_cast_function
typename std::enable_if< B, T >::type enable_if_t
void operator()(lua_State *L) const
void select_member_function_with(lua_State *L, Fx &&fx, T &&obj, Args &&...args)
constructor_list< Args... > F
optional & operator=(U &&u)
int call_user(lua_State *L)
int push(lua_State *L, const variadic_results &r)
constexpr bool is_lua_primitive_v
main_table_core< true > main_global_table
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
const char(& default_main_thread_name())[9]
constexpr bool is_policy_v
table create_named(Name &&name, Args &&...args)
void construct(Args &&...args) noexcept
std::remove_pointer_t< std::decay_t< Function > > function_type
usertype_proxy< const basic_usertype &, std::decay_t< Key > > operator[](Key &&key) const
static int push(lua_State *L, std::nullptr_t)
basic_function(lua_State *L, T &&r)
unsafe_function_result function_result
static void * type_cast_bases(types<>, T *, const string_view &)
optional & operator=(optional< U > &&rhs)
protected_function_result do_file(const std::string &filename, load_mode mode=load_mode::any)
LUA_API const char * lua_setupvalue(lua_State *L, int funcindex, int n)
lua_bind_traits< function_type > traits_type
#define lua_insert(L, idx)
string_view as_string_view() const
static detail::error_result find_comparative(std::false_type, lua_State *, T &)
type type_of(lua_State *L, int index)
void register_main_thread(lua_State *L)
unsafe_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n) const
static int push(lua_State *L, Arg0 &&arg0, Args &&...args)
std::forward_list< T, Al > C
basic_coroutine(lua_State *L, absolute_index index)
call_syntax get_call_syntax(lua_State *L, const string_view &key, int index)
int dump(lua_Writer writer, void *userdata, bool strip=false) const
stack_reference(lua_State *L, lua_nil_t) noexcept
int default_traceback_error_handler(lua_State *L)
static int real_erase_traits(std::true_type, lua_State *L)
static void set_default_handler(lua_State *L, const T &ref)
#define lua_str2number(s, p)
void handle_protected_exception(lua_State *L, optional< const std::exception & > maybe_ex, const char *error, detail::protected_handler< b, handler_t > &h)
LUA_API const char * lua_pushlstring(lua_State *L, const char *s, size_t len)
static int push(lua_State *L, const constructor_wrapper< Fxs... > &c)
void clear(lua_State *L, int table_index)
stateless_reference(stateless_reference &&o) noexcept
static int push_fx(lua_State *L, F &&f, T *obj)
static constexpr char32_t replacement
static detail::error_result at_category(std::input_iterator_tag, lua_State *L, T &self, std::ptrdiff_t pos)
constexpr update_if_empty_t update_if_empty
static detail::error_result get_it(std::false_type, lua_State *L, T &self, K &key)
LUALIB_API char * luaL_prepbuffsize(luaL_Buffer *B, size_t sz)
int operator()(lua_State *L)
ebco(Arg &&arg, Args &&...args)
T & emplace(Args &&...args) noexcept
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > and_then(F &&f)&&
static int real_find_call(lua_State *L)
static int call(lua_State *L, F &&f, Args &&...args)
basic_reference(stack_reference &&r) noexcept
reverse_iterator rbegin()
basic_table_core(detail::no_safety_tag, lua_nil_t n)
std::in_place_type_t< T > in_place_type_t
void set_field(lua_State *L, Key &&key, Value &&value, int tableindex)
auto operator[](T &&key)&&
static int real_index_get_traits(std::true_type, lua_State *L)
basic_table_iterator< ref_t > iterator
static int insert(lua_State *L)
meta::function_return_t< function_type > return_type
std::remove_pointer_t< meta::unwrap_unqualified_t< X > > T
static constexpr int sequence_length(unsigned char b)
static int push(lua_State *L, const lua_value &lv)
int push_environment_of(lua_State *L, int index=-1)
U map_or(F &&f, U &&u)&&
map_or
decltype(auto) unchecked_get(lua_State *L, int index, record &tracking)
lua_State * operator->() const noexcept
static iterator end(lua_State *, T &self)
typename container_decay< meta::unqualified_t< T >>::type container_decay_t
void operator()(T &&obj) const
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > and_then(F &&f)&
usertype_storage_base & get_usertype_storage_base(lua_State *L, const char *gcmetakey)
usertype< Class > new_usertype(Key &&key)
void get_field(lua_State *L, Key &&key, int tableindex)
static detail::error_result insert_lookup(std::true_type, lua_State *L, T &self, stack_object, stack_object value)
detail::invoke_result_t< U > map_or_else(F &&f, U &&u)&&
meta::boolean< has_traits_add_test< T >::value > has_traits_add
static int push(lua_State *L, const char *str)
void luajit_exception_handler(lua_State *L, int(*handler)(lua_State *, lua_CFunction)=detail::c_trampoline)
static int type_unique_cast_bases(types< Base, Args... >, void *source_data, void *target_data, const string_view &ti)
void remove(lua_State *L, int rawindex, int count)
table new_enum(const string_view &name, Args &&...args)
stack_guard(lua_State *L)
basic_protected_function(stack_reference &&r)
const_iterator cbegin() const
object make_object_userdata(lua_State *L, T &&value)
int push_reference(lua_State *L, T &&t, Args &&...args)
SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base() noexcept
int user_alloc_destruct(lua_State *L)
basic_function< stack_reference, true > stack_aligned_unsafe_function
optional(const optional< U > &rhs)
basic_table_core(detail::no_safety_tag, T &&r) noexcept
basic_table_core< b, main_reference > main_table_core
static detail::error_result get_comparative(std::false_type, lua_State *, T &, K &)
constructor_wrapper< Cxs... > F
std::remove_pointer_t< std::decay_t< Function > > function_type
static detail::error_result erase_has(std::false_type, lua_State *L, T &self, K &key)
int(lua_State *, void *) index_call_function
unsafe_function_result unsafe_script_file(const std::string &filename, const basic_environment< E > &env, load_mode mode=load_mode::any)
bool attempt_alloc(lua_State *L, std::size_t ptr_align, std::size_t ptr_size, std::size_t value_align, std::size_t value_size, std::size_t allocated_size, void *&pointer_adjusted, void *&data_adjusted)
std::tuple< Upvalues... > upvalues
basic_coroutine(const stack_reference &r, handler_t eh)
constexpr const lua_Integer toplevel_magic
basic_reference(lua_State *L, detail::global_tag, detail::global_tag) noexcept
bool check(lua_State *L, int index, Handler &&handler, record &tracking)
static detail::error_result insert_has(std::true_type, lua_State *L, T &self, stack_object key, stack_object value)
meta::boolean< has_traits_get_test< T >::value > has_traits_get
static int push(lua_State *L, absolute_index ai)
LUA_API int lua_getfield(lua_State *L, int idx, const char *k)
const auto default_constructor
int call_wrapper_entry(lua_State *L) noexcept(meta::bind_traits< F >::is_noexcept)
stack_iterator & operator+=(difference_type idx)
static int find(lua_State *L)
static int real_add_traits(std::false_type, lua_State *L)
make_index_sequence< sizeof...(Ts)> index_sequence_for
void pop(lua_State *Ls, int n=1) const noexcept
basic_coroutine< stack_reference > stack_coroutine
static detail::error_result insert_copyable(std::true_type, lua_State *L, T &self, stack_object key, stack_object value)
basic_function< main_reference, false > main_unsafe_function
static int new_index_target_set(lua_State *L, void *target)
static detail::error_result set_associative_find(std::false_type, lua_State *L, T &self, stack_object key, stack_object value)
bool multi_check(lua_State *L, int index, Handler &&handler, record &tracking)
constexpr optional disjunction(optional &&rhs) const &
disjunction
static decltype(auto) get(lua_State *L, int index, record &tracking)
LUALIB_API int luaL_getmetafield(lua_State *L, int obj, const char *event)
bool operator<(const stack_iterator &r) const
~basic_reference() noexcept
int copy() const noexcept
int lua_c_noexcept_wrapper(lua_State *L) noexcept
constexpr bool is_table_like_v
constexpr const char * not_enough_stack_space_userdata
std::unordered_map< reference, reference, reference_hash, reference_equals > auxiliary_keys
constexpr const int environment_index
int push(lua_State *L) const noexcept
constexpr Sig C::* resolve_v(std::false_type, Sig C::*mem_func_ptr)
protected_function_result safe_script(const string_view &code, const basic_environment< E > &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
std::reverse_iterator< const_iterator > const_reverse_iterator
static int push(lua_State *L, const char16_t *str)
table_proxy< const global_table &, detail::proxy_key_t< T > > operator[](T &&key) const
basic_object< main_reference > main_object
constexpr nested_tag_t nested_tag
basic_reference(lua_State *L, int index=-1) noexcept
unsafe_function_result unsafe_script(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
constexpr bool is_constructor_v
table_proxy & operator=(std::initializer_list< T > other)&
static int push_sized(lua_State *L, const char *str, std::size_t len)
basic_thread(lua_State *L, lua_thread_state actualthread)
constexpr auto resolve(R fun_ptr(Args...)) -> R(*)(Args...)
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
std::size_t aligned_space_for(void *alignment=nullptr)
void pop() const noexcept
binding_data_equals(void *b)
typename std::enable_if< E, T >::type enable_if_t
protected_function_result script_pass_on_error(lua_State *, protected_function_result result)
basic_function< reference, false > unsafe_function
static bool empty_has(std::false_type, lua_State *L, T &self)
meta::boolean< has_erase_test< T >::value > has_erase
static const char * libraries[]
this_environment(environment e)
static int push(lua_State *L, const char32_t *strb, const char32_t *stre)
static int add(lua_State *L)
static int push(lua_State *L, Arg0 &&arg0, Args &&...args)
#define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)
const std::string & short_demangle()
static int call(lua_State *, const bases< Args... > &)
bool integer_value_fits(const T &value)
int index_fail(lua_State *L)
T & emplace(Args &&...args)
static int push(lua_State *L, const basic_string_view< Ch, Traits > &sv)
static int call(lua_State *L, const function_arguments< Sig, P > &f)
basic_object_base(T &&arg, Args &&...args)
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) const &
Used to represent an optional with no data; essentially a bool.
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(const optional &rhs)&
new_index_call_storage base_index
protected_function_result safe_script_file(const std::string &filename, const basic_environment< E > &env, Fx &&on_error, load_mode mode=load_mode::any)
table create(int narr, int nrec, Key &&key, Value &&value, Args &&...args)
static int real_find_traits(std::false_type, lua_State *L)
SOL_TL_OPTIONAL_11_CONSTEXPR T & value()&
SOL_TL_OPTIONAL_11_CONSTEXPR const T & value() const &
bool operator>(const stack_iterator &r) const
bool less_than_or_equal_to_operator
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
enable_if_t< returns_void< T &&, U... >::value > enable_if_ret_void
constexpr T value_or(U &&u) const &
static int real_clear_traits(std::false_type, lua_State *L)
Real * usertype_unique_allocate(lua_State *L, T **&pref, unique_destructor *&dx, unique_tag *&id)
LUA_API int lua_rawequal(lua_State *L, int index1, int index2)
int default_exception_handler(lua_State *L, optional< const std::exception & >, string_view what)
static int add(lua_State *L)
bool is_stack(std::false_type) const
decltype(auto) overload(Args &&...args)
static int push(lua_State *L, const char16_t *u16str, std::size_t sz)
static int push(lua_State *L, const table_proxy< Table, Key > &p)
int SOL_INTERNAL_UNSPECIALIZED_MARKER_
protected_function_result operator()(Args &&...args)
constexpr bool operator==(const optional< T > &lhs, const optional< U > &rhs)
Compares two optional objects.
std::pair< object, object > kvp
const_reverse_iterator crbegin() const
lua_bind_traits< function_type > traits_type
static int call_(lua_State *L)
static detail::error_result set_writable(std::true_type, lua_State *, T &, iterator &it, stack_object value)
basic_table_core< b, stack_reference > stack_table_core
call_status status() const noexcept
const nullopt_t nullopt((nullopt_t::init()))
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
static int push(lua_State *L, ref_index ri)
int push_environment_of(const T &target)
meta::unqualified_t< T > Tu
stateless_reference(lua_State *L, const stateless_reference &r) noexcept
lua_State * lua_state() const noexcept
detail::invoke_result_t< U > map_or_else(F &&f, U &&u)&&
unsafe_function_result unsafe_script(const string_view &code, const basic_environment< E > &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
static int real_insert_call(lua_State *L)
static int real_clear_call(lua_State *L)
static int real_pairs_traits(std::false_type, lua_State *L)
void pop() const noexcept
constexpr bool has_internal_marker_v
constexpr auto invoke(Fn &&f, Args &&...args) noexcept(noexcept(std::mem_fn(f)(std::forward< Args >(args)...))) -> decltype(std::mem_fn(f)(std::forward< Args >(args)...))
indexed_insert(lua_reg_table &cont, int &idx)
static detail::error_result set_associative_insert(std::false_type, lua_State *, T &self, Iter &it, K &key, stack_object)
basic_table_iterator operator++(int)
meta::boolean< has_traits_find_test< T >::value > has_traits_find
Ret invoke(types< Ret >, std::index_sequence< I >, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
static int pairs(lua_State *L)
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f)&&
static constexpr std::size_t size()
static int push(lua_State *L, const char16_t *strb, const char16_t *stre)
basic_table_core(lua_State *L, detail::global_tag t) noexcept
static int next(lua_State *L)
void modify_unique_usertype_as(const stack_reference &obj, F &&f)
basic_table_core(lua_nil_t r) noexcept
protected_function_result & operator=(protected_function_result &&o) noexcept
int push_userdata(lua_State *L, Arg &&arg, Args &&...args)
static detail::error_result add_push_back(std::true_type, lua_State *, T &self, stack_object value)
static void clear_has(std::true_type, lua_State *, T &self)
void apply(std::index_sequence< I >, lua_State *L, Keys &&keys, Value &&value, int tableindex)
static int call(types< Fx >, meta::index_value< I >, types< R... >, types< Args... >, lua_State *L, int, int, overload_list &ol)
stack_aligned_unsafe_function stack_aligned_function
table create_table(Name &&name, int narr=0, int nrec=0)
push_popper< top_level, T > push_pop(T &&x)
typename std::remove_reference< T >::type remove_reference_t
static int push(lua_State *L, const var_wrapper< T > &vw)
static int push(lua_State *L, const std::basic_string< Ch, Traits, Al > &str)
static int next(lua_State *L)
static int type_unique_cast(void *source_data, void *target_data, const string_view &ti, const string_view &rebind_ti)
std::vector< std::unique_ptr< binding_base > > storage
int push(lua_State *L, const as_args_t< T > &e)
static int push(lua_State *L, const protect_t< T > &pw)
int leftover_count() const
int c_call_raw(std::false_type, lua_State *L)
object require_core(const std::string &key, Fx &&action, bool create_global=true)
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(const optional &rhs)&&
disjunction
const char * make_chunk_name(const string_view &code, const std::string &chunkname, char(&basechunkname)[N])
static int push(lua_State *L, const wchar_t(&str)[N])
static int push(lua_State *L, function_arguments< T, Args... > &&fp)
static detail::error_result insert_after_has(std::false_type, lua_State *, T &, stack_object, stack_object)
bool operator()(const basic_reference< lb > &lhs, const stack_reference &rhs) const
bool valid(lua_State *) const noexcept
state_view & set_function(Key &&key, Args &&...args)
static const std::string & user_gc_metatable()
int type_panic_string(lua_State *L, int index, type expected, type actual, string_view message="") noexcept(false)
optional< usertype_storage_base & > maybe_get_usertype_storage_base(lua_State *L, int index)
static int push(lua_State *L, light< T > l)
U map_or(F &&f, U &&u) const &&
map_or
constexpr optional disjunction(const optional &rhs) const &
disjunction
LUA_API int lua_checkstack(lua_State *L, int n)
static V get_one(std::integral_constant< std::size_t, I >, lua_State *L, int index, record &tracking)
constexpr const int lookup_failed_index
meta::conditional_t< std::is_array< T >::value, std::add_lvalue_reference_t< T >, T > array_return_type
table_proxy && operator=(std::initializer_list< T > other)&&
const std::string & demangle()
basic_lua_table(lua_State *L, const new_table &nt)
tie_t< std::remove_reference_t< Tn >... > tie(Tn &&...argn)
constexpr bool is_stack_based_v
basic_object & operator=(const base_type &b)
int stack_index() const noexcept
LUA_API int lua_gettable(lua_State *L, int idx)
factory_wrapper(Arg &&arg, Args &&...args)
basic_coroutine(lua_State *L, raw_index index, handler_t eh)
static std::ptrdiff_t index_adjustment(lua_State *, T &)
static int real_at_traits(std::false_type, lua_State *L)
constexpr bool has_value() const noexcept
protected_function_result & operator=(const protected_function_result &)=delete
type get_type() const noexcept
Ret invoke(types< Ret >, std::index_sequence< I >, std::ptrdiff_t n) const
int fail_on_newindex(lua_State *L)
static int self_index_call(types< Bases... >, lua_State *L, usertype_storage_base &self)
usertype_proxy & operator=(std::initializer_list< T > other)&
meta::unqualified_t< Fq > uF
std::make_index_sequence< sizeof...(Functions)> indices
bool step_gc(int step_size_kilobytes)
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
std::u32string_view u32string_view
static int index_of(lua_State *L)
static detail::error_result erase_associative_lookup(std::false_type, lua_State *L, T &self, K &key)
basic_userdata(lua_State *L, T &&r)
error(const std::string &str)
LUA_API int lua_gettop(lua_State *L)
stack_table_core< false > stack_table
std::remove_pointer_t< std::decay_t< Function > > function_type
push_popper_at(lua_State *luastate, int index=-1, int count=1)
std::pair< T, int > get_as_upvalues_using_function(lua_State *L, int function_index=-1)
basic_table_core & set_function(Key &&key, Args &&...args)
constexpr auto resolve_i(types< Args... >, F &&f) -> decltype(resolve_i(types< R(Args...)>(), std::forward< F >(f)))
int msvc_is_ass_with_if_constexpr_push_enum(std::false_type, lua_State *, const T &)
decltype(auto) check_get(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
lua_bind_traits< std::remove_pointer_t< meta::unqualified_t< F > > > traits_type
static bool type_check_bases(types< Base, Args... >, const string_view &ti)
static detail::error_result get_associative_find(std::false_type, lua_State *L, T &self, K &key)
static int call(lua_State *L, F &fx)
static int convert_into(lua_State *L, char *start, std::size_t, const char16_t *strb, const char16_t *stre)
int push() const noexcept
table create_table(int narr, int nrec, Key &&key, Value &&value, Args &&...args)
basic_object(detail::no_safety_tag, lua_nil_t n)
nested(Arg0 &&arg0, Arg1 &&arg1, Args &&...args)
virtual void * data() override
std::string_view string_view
basic_table_core & raw_set(Args &&...args)
static void set_lua_state(lua_State *L)
reference unique_index_table
auto as_container(T &&value)
new_table(int sequence_hint, int map_hint=0)
basic_userdata(const stack_reference &r)
static int push(lua_State *L, const std::variant< Tn... > &v)
static int real_get_traits(std::true_type, lua_State *L)
LUA_API const char * lua_typename(lua_State *L, int t)
static bool type_check_bases(types<>, const string_view &)
bool unqualified_check(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)