27 #ifndef SOL_SINGLE_INCLUDE_HPP 28 #define SOL_SINGLE_INCLUDE_HPP 35 #if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER) 36 #define SOL_INSIDE_UNREAL 1 37 #endif // Unreal Engine 4 bullshit 39 #if defined(SOL_INSIDE_UNREAL) && SOL_INSIDE_UNREAL 41 #define SOL_INSIDE_UNREAL_REMOVED_CHECK 1 44 #endif // Unreal Engine 4 Bullshit 47 #pragma GCC diagnostic push 48 #pragma GCC diagnostic ignored "-Wshadow" 49 #pragma GCC diagnostic ignored "-Wconversion" 51 #pragma GCC diagnostic ignored "-Wnoexcept-type" 53 #elif defined(__clang__) 54 #elif defined _MSC_VER 55 #pragma warning( push ) 56 #pragma warning( disable : 4324 ) // structure was padded due to alignment specifier 57 #pragma warning( disable : 4503 ) // decorated name horse shit 58 #pragma warning( disable : 4702 ) // unreachable code 59 #pragma warning( disable: 4127 ) // 'conditional expression is constant' yeah that's the point your old compilers don't have `if constexpr` you jerk 60 #pragma warning( disable: 4505 ) // some other nonsense warning 61 #endif // clang++ vs. g++ vs. VC++ 67 #if (defined(__cplusplus) && __cplusplus == 201703L) || (defined(_MSC_VER) && _MSC_VER > 1900 && ((defined(_HAS_CXX17) && _HAS_CXX17 == 1) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402L)))) 68 #ifndef SOL_CXX17_FEATURES 69 #define SOL_CXX17_FEATURES 1 70 #endif // C++17 features macro 71 #endif // C++17 features check 73 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 74 #if defined(__cpp_noexcept_function_type) || ((defined(_MSC_VER) && _MSC_VER > 1911) && (defined(_MSVC_LANG) && ((_MSVC_LANG >= 201403L)))) 75 #ifndef SOL_NOEXCEPT_FUNCTION_TYPE 76 #define SOL_NOEXCEPT_FUNCTION_TYPE 1 77 #endif // noexcept is part of a function's type 78 #endif // compiler-specific checks 79 #if defined(__clang__) && defined(__APPLE__) 80 #if defined(__has_include) 81 #if __has_include(<variant>) 82 #define SOL_STD_VARIANT 1 83 #endif // has include nonsense 84 #endif // __has_include 86 #define SOL_STD_VARIANT 1 87 #endif // Clang screws up variant 93 #if defined(_DEBUG) && !defined(NDEBUG) 95 #ifndef SOL_IN_DEBUG_DETECTED 96 #define SOL_IN_DEBUG_DETECTED 1 99 #endif // VC++ Debug macros 102 #ifndef SOL_NO_EXCEPTIONS 103 #define SOL_NO_EXCEPTIONS 1 105 #endif // Automatic Exceptions 109 #define SOL_NO_RTTI 1 111 #endif // Automatic RTTI 112 #elif defined(__GNUC__) || defined(__clang__) 114 #if !defined(NDEBUG) && !defined(__OPTIMIZE__) 116 #ifndef SOL_IN_DEBUG_DETECTED 117 #define SOL_IN_DEBUG_DETECTED 1 120 #endif // Not Debug && g++ optimizer flag 123 #ifndef SOL_NO_EXCEPTIONS 124 #define SOL_NO_EXCEPTIONS 1 126 #endif // No Exceptions 130 #define SOL_NO_RTTI 1 134 #endif // vc++ || clang++/g++ 136 #if defined(SOL_CHECK_ARGUMENTS) && SOL_CHECK_ARGUMENTS 140 #if !defined(SOL_SAFE_GETTER) 141 #define SOL_SAFE_GETTER 1 148 #if !defined(SOL_SAFE_USERTYPE) 149 #define SOL_SAFE_USERTYPE 1 155 #if !defined(SOL_SAFE_REFERENCES) 156 #define SOL_SAFE_REFERENCES 1 161 #if !defined(SOL_SAFE_FUNCTION) 162 #define SOL_SAFE_FUNCTION 1 170 #if !defined(SOL_SAFE_FUNCTION_CALLS) 171 #define SOL_SAFE_FUNCTION_CALLS 1 177 #if !defined(SOL_SAFE_PROXIES) 178 #define SOL_SAFE_PROXIES 1 184 #if !defined(SOL_SAFE_NUMERICS) 185 #define SOL_SAFE_NUMERICS 1 192 #if !defined(SOL_NO_CHECK_NUMBER_PRECISION) 194 #define SOL_NO_CHECK_NUMBER_PRECISION 0 197 #endif // Turn on Safety for all if top-level macro is defined 199 #if defined(SOL_IN_DEBUG_DETECTED) && SOL_IN_DEBUG_DETECTED 201 #if !defined(SOL_SAFE_REFERENCES) 203 #define SOL_SAFE_REFERENCES 1 210 #if !defined(SOL_SAFE_USERTYPE) 211 #define SOL_SAFE_USERTYPE 1 214 #if !defined(SOL_SAFE_FUNCTION_CALLS) 216 #define SOL_SAFE_FUNCTION_CALLS 1 221 #if !defined(SOL_PRINT_ERRORS) 222 #define SOL_PRINT_ERRORS 1 225 #endif // DEBUG: Turn on all debug safety features for VC++ / g++ / clang++ and similar 227 #if !defined(SOL_PRINT_ERRORS) 228 #define SOL_PRINT_ERRORS 0 231 #if !defined(SOL_DEFAULT_PASS_ON_ERROR) 232 #define SOL_DEFAULT_PASS_ON_ERROR 0 235 #if !defined(SOL_ENABLE_INTEROP) 236 #define SOL_ENABLE_INTEROP 0 239 #if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil) 240 #if !defined(SOL_NO_NIL) 243 #endif // avoiding nil defines / keywords 245 #if defined(SOL_USE_BOOST) && SOL_USE_BOOST 246 #ifndef SOL_UNORDERED_MAP_COMPATIBLE_HASH 247 #define SOL_UNORDERED_MAP_COMPATIBLE_HASH 1 248 #endif // SOL_UNORDERED_MAP_COMPATIBLE_HASH 251 #ifndef SOL_STACK_STRING_OPTIMIZATION_SIZE 252 #define SOL_STACK_STRING_OPTIMIZATION_SIZE 1024 253 #endif // Optimized conversion routines using a KB or so off the stack 272 template <
typename Super>
274 template <
typename Table,
typename Key>
277 template <
typename T>
279 template <
typename T>
281 template <
bool,
typename T>
289 template <
typename T>
297 template <
typename base_t>
302 template <
typename T,
bool>
304 template <
typename T,
bool,
typename H>
318 #if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION 333 #if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION 339 template <
typename base_t>
341 template <
typename base_t>
343 template <
typename base_t>
345 template <
typename base_t>
347 template <
typename base_t>
374 template <
typename T>
376 template <
typename T>
378 template <
typename T>
380 template <
typename T>
382 template <
typename T>
384 template <
typename T>
386 template <
typename T>
388 template <
typename F,
typename... Filters>
391 template <
typename T>
393 template <
typename T>
414 class error :
public std::runtime_error {
427 :
std::runtime_error(
""), w(str) {
430 :
std::runtime_error(
""), w(
std::move(str)) {
438 virtual const char*
what() const noexcept
override {
465 template <
typename... Args>
467 typedef std::make_index_sequence<
sizeof...(Args)>
indices;
468 static constexpr std::size_t
size() {
469 return sizeof...(Args);
474 template <
typename... Args>
477 template <
typename... Args>
481 template <
typename T>
484 template <
typename T>
487 template <
typename... Args>
490 template <
typename Arg>
493 template <
typename Arg>
496 template <
typename... Args>
502 template <
typename Arg,
typename... Args>
508 template <std::
size_t N,
typename Tuple>
509 using tuple_element = std::tuple_element<N, std::remove_reference_t<Tuple>>;
511 template <std::
size_t N,
typename Tuple>
514 template <std::
size_t N,
typename Tuple>
517 template <std::
size_t N,
typename Tuple>
529 namespace meta_detail {
535 static auto test(
int) -> decltype(&G::operator(),
void());
537 static auto test(...) ->
nat;
539 using type = std::is_void<decltype(test<F>(0))>;
546 namespace meta_detail {
548 template <std::
size_t I,
typename T>
551 template <std::
size_t I>
554 template <std::
size_t I,
typename T>
557 template <
bool it_is_noexcept,
bool has_c_variadic,
typename T,
typename R,
typename... Args>
560 typedef std::conditional_t<std::is_void<T>::value, int, T>&
first_type;
563 static const bool is_noexcept = it_is_noexcept;
564 static const bool is_member_function = std::is_void<T>::value;
565 static const bool has_c_var_arg = has_c_variadic;
566 static const std::size_t arity =
sizeof...(Args);
567 static const std::size_t free_arity =
sizeof...(Args) + static_cast<std::size_t>(!std::is_void<T>::value);
573 typedef R(function_type)(Args...);
575 typedef std::conditional_t<std::is_void<T>::value, R(Args...), R(first_type, Args...)>
free_function_type;
578 template <std::
size_t i>
582 template <typename Signature, bool b = has_deducible_signature<Signature>::value>
586 template <
typename R,
typename... Args>
588 typedef R (*function_pointer_type)(Args...);
591 template <
typename R,
typename... Args>
593 typedef R (*function_pointer_type)(Args...);
596 template <
typename R,
typename... Args>
598 typedef R (*function_pointer_type)(Args..., ...);
601 template <
typename R,
typename... Args>
603 typedef R (*function_pointer_type)(Args..., ...);
608 template <
typename T,
typename R,
typename... Args>
610 typedef R (T::*function_pointer_type)(Args...);
613 template <
typename T,
typename R,
typename... Args>
615 typedef R (T::*function_pointer_type)(Args..., ...);
619 template <
typename T,
typename R,
typename... Args>
621 typedef R (T::*function_pointer_type)(Args...)
const;
624 template <
typename T,
typename R,
typename... Args>
626 typedef R (T::*function_pointer_type)(Args..., ...)
const;
629 template <
typename T,
typename R,
typename... Args>
631 typedef R (T::*function_pointer_type)(Args...)
const volatile;
634 template <
typename T,
typename R,
typename... Args>
636 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile;
640 template <
typename T,
typename R,
typename... Args>
642 typedef R (T::*function_pointer_type)(Args...) &;
645 template <
typename T,
typename R,
typename... Args>
647 typedef R (T::*function_pointer_type)(Args..., ...) &;
650 template <
typename T,
typename R,
typename... Args>
652 typedef R (T::*function_pointer_type)(Args...)
const&;
655 template <
typename T,
typename R,
typename... Args>
657 typedef R (T::*function_pointer_type)(Args..., ...)
const&;
660 template <
typename T,
typename R,
typename... Args>
662 typedef R (T::*function_pointer_type)(Args...)
const volatile&;
665 template <
typename T,
typename R,
typename... Args>
667 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile&;
670 template <
typename T,
typename R,
typename... Args>
672 typedef R (T::*function_pointer_type)(Args...) &&;
675 template <
typename T,
typename R,
typename... Args>
677 typedef R (T::*function_pointer_type)(Args..., ...) &&;
680 template <
typename T,
typename R,
typename... Args>
682 typedef R (T::*function_pointer_type)(Args...)
const&&;
685 template <
typename T,
typename R,
typename... Args>
687 typedef R (T::*function_pointer_type)(Args..., ...)
const&&;
690 template <
typename T,
typename R,
typename... Args>
692 typedef R (T::*function_pointer_type)(Args...)
const volatile&&;
695 template <
typename T,
typename R,
typename... Args>
697 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile&&;
700 #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE 702 template <
typename R,
typename... Args>
704 typedef R (*function_pointer_type)(Args...) noexcept;
707 template <
typename R,
typename... Args>
709 typedef R (*function_pointer_type)(Args...) noexcept;
712 template <
typename R,
typename... Args>
714 typedef R (*function_pointer_type)(Args..., ...) noexcept;
717 template <
typename R,
typename... Args>
719 typedef R (*function_pointer_type)(Args..., ...) noexcept;
722 template <
typename T,
typename R,
typename... Args>
724 typedef R (T::*function_pointer_type)(Args...) noexcept;
727 template <
typename T,
typename R,
typename... Args>
729 typedef R (T::*function_pointer_type)(Args..., ...) noexcept;
733 template <
typename T,
typename R,
typename... Args>
734 struct fx_traits<R (T::*)(Args...) const noexcept, false> :
basic_traits<true, false, T, R, Args...> {
735 typedef R (T::*function_pointer_type)(Args...)
const noexcept;
738 template <
typename T,
typename R,
typename... Args>
739 struct fx_traits<R (T::*)(Args..., ...) const noexcept, false> :
basic_traits<true, true, T, R, Args...> {
740 typedef R (T::*function_pointer_type)(Args..., ...)
const noexcept;
743 template <
typename T,
typename R,
typename... Args>
744 struct fx_traits<R (T::*)(Args...) const volatile noexcept, false> :
basic_traits<true, false, T, R, Args...> {
745 typedef R (T::*function_pointer_type)(Args...)
const volatile noexcept;
748 template <
typename T,
typename R,
typename... Args>
749 struct fx_traits<R (T::*)(Args..., ...) const volatile noexcept, false> :
basic_traits<true, true, T, R, Args...> {
750 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile noexcept;
753 template <
typename T,
typename R,
typename... Args>
755 typedef R (T::*function_pointer_type)(Args...) & noexcept;
758 template <
typename T,
typename R,
typename... Args>
759 struct fx_traits<R (T::*)(Args..., ...) & noexcept, false> :
basic_traits<true, true, T, R, Args...> {
760 typedef R (T::*function_pointer_type)(Args..., ...) & noexcept;
763 template <
typename T,
typename R,
typename... Args>
764 struct fx_traits<R (T::*)(Args...) const& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
765 typedef R (T::*function_pointer_type)(Args...)
const& noexcept;
768 template <
typename T,
typename R,
typename... Args>
769 struct fx_traits<R (T::*)(Args..., ...) const& noexcept, false> :
basic_traits<true, true, T, R, Args...> {
770 typedef R (T::*function_pointer_type)(Args..., ...)
const& noexcept;
773 template <
typename T,
typename R,
typename... Args>
774 struct fx_traits<R (T::*)(Args...) const volatile& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
775 typedef R (T::*function_pointer_type)(Args...)
const volatile& noexcept;
778 template <
typename T,
typename R,
typename... Args>
779 struct fx_traits<R (T::*)(Args..., ...) const volatile& noexcept, false> :
basic_traits<true, true, T, R, Args...> {
780 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile& noexcept;
783 template <
typename T,
typename R,
typename... Args>
785 typedef R (T::*function_pointer_type)(Args...) && noexcept;
788 template <
typename T,
typename R,
typename... Args>
789 struct fx_traits<R (T::*)(Args..., ...) && noexcept, false> :
basic_traits<true, true, T, R, Args...> {
790 typedef R (T::*function_pointer_type)(Args..., ...) && noexcept;
793 template <
typename T,
typename R,
typename... Args>
794 struct fx_traits<R (T::*)(Args...) const&& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
795 typedef R (T::*function_pointer_type)(Args...)
const&& noexcept;
798 template <
typename T,
typename R,
typename... Args>
799 struct fx_traits<R (T::*)(Args..., ...) const&& noexcept, false> :
basic_traits<true, true, T, R, Args...> {
800 typedef R (T::*function_pointer_type)(Args..., ...)
const&& noexcept;
803 template <
typename T,
typename R,
typename... Args>
804 struct fx_traits<R (T::*)(Args...) const volatile&& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
805 typedef R (T::*function_pointer_type)(Args...)
const volatile&& noexcept;
808 template <
typename T,
typename R,
typename... Args>
809 struct fx_traits<R (T::*)(Args..., ...) const volatile&& noexcept, false> :
basic_traits<true, true, T, R, Args...> {
810 typedef R (T::*function_pointer_type)(Args..., ...)
const volatile&& noexcept;
813 #endif // noexcept is part of a function's type 815 #if defined(_MSC_VER) && defined(_M_IX86) 816 template <
typename R,
typename... Args>
818 typedef R(__stdcall* function_pointer_type)(Args...);
821 template <
typename R,
typename... Args>
823 typedef R(__stdcall* function_pointer_type)(Args...);
826 template <
typename T,
typename R,
typename... Args>
828 typedef R (__stdcall T::*function_pointer_type)(Args...);
832 template <
typename T,
typename R,
typename... Args>
833 struct fx_traits<R (__stdcall T::*)(Args...) const, false> :
basic_traits<false, false, T, R, Args...> {
834 typedef R (__stdcall T::*function_pointer_type)(Args...)
const;
837 template <
typename T,
typename R,
typename... Args>
838 struct fx_traits<R (__stdcall T::*)(Args...) const volatile, false> :
basic_traits<false, false, T, R, Args...> {
839 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile;
843 template <
typename T,
typename R,
typename... Args>
845 typedef R (__stdcall T::*function_pointer_type)(Args...) &;
848 template <
typename T,
typename R,
typename... Args>
849 struct fx_traits<R (__stdcall T::*)(Args...) const&, false> :
basic_traits<false, false, T, R, Args...> {
850 typedef R (__stdcall T::*function_pointer_type)(Args...)
const&;
853 template <
typename T,
typename R,
typename... Args>
854 struct fx_traits<R (__stdcall T::*)(Args...) const volatile&, false> :
basic_traits<false, false, T, R, Args...> {
855 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile&;
858 template <
typename T,
typename R,
typename... Args>
860 typedef R (__stdcall T::*function_pointer_type)(Args...) &&;
863 template <
typename T,
typename R,
typename... Args>
864 struct fx_traits<R (__stdcall T::*)(Args...) const&&, false> :
basic_traits<false, false, T, R, Args...> {
865 typedef R (__stdcall T::*function_pointer_type)(Args...)
const&&;
868 template <
typename T,
typename R,
typename... Args>
869 struct fx_traits<R (__stdcall T::*)(Args...) const volatile&&, false> :
basic_traits<false, false, T, R, Args...> {
870 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile&&;
873 #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE 875 template <
typename R,
typename... Args>
876 struct fx_traits<R __stdcall(Args...) noexcept, false> :
basic_traits<true, false, void, R, Args...> {
877 typedef R(__stdcall* function_pointer_type)(Args...) noexcept;
880 template <
typename R,
typename... Args>
881 struct fx_traits<R (__stdcall *)(Args...) noexcept,
false> :
basic_traits<
true,
false, void, R, Args...> {
882 typedef R(__stdcall* function_pointer_type)(Args...) noexcept;
896 template <
typename T,
typename R,
typename... Args>
897 struct fx_traits<R (__stdcall T::*)(Args...) noexcept, false> :
basic_traits<true, false, T, R, Args...> {
898 typedef R (__stdcall T::*function_pointer_type)(Args...) noexcept;
908 template <
typename T,
typename R,
typename... Args>
909 struct fx_traits<R (__stdcall T::*)(Args...) const noexcept, false> :
basic_traits<true, false, T, R, Args...> {
910 typedef R (__stdcall T::*function_pointer_type)(Args...)
const noexcept;
919 template <
typename T,
typename R,
typename... Args>
920 struct fx_traits<R (__stdcall T::*)(Args...) const volatile noexcept, false> :
basic_traits<true, false, T, R, Args...> {
921 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile noexcept;
930 template <
typename T,
typename R,
typename... Args>
931 struct fx_traits<R (__stdcall T::*)(Args...) & noexcept, false> :
basic_traits<true, false, T, R, Args...> {
932 typedef R (__stdcall T::*function_pointer_type)(Args...) & noexcept;
941 template <
typename T,
typename R,
typename... Args>
942 struct fx_traits<R (__stdcall T::*)(Args...) const& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
943 typedef R (__stdcall T::*function_pointer_type)(Args...)
const& noexcept;
952 template <
typename T,
typename R,
typename... Args>
953 struct fx_traits<R (__stdcall T::*)(Args...) const volatile& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
954 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile& noexcept;
963 template <
typename T,
typename R,
typename... Args>
964 struct fx_traits<R (__stdcall T::*)(Args...) && noexcept, false> :
basic_traits<true, false, T, R, Args...> {
965 typedef R (__stdcall T::*function_pointer_type)(Args...) && noexcept;
974 template <
typename T,
typename R,
typename... Args>
975 struct fx_traits<R (__stdcall T::*)(Args...) const&& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
976 typedef R (__stdcall T::*function_pointer_type)(Args...)
const&& noexcept;
985 template <
typename T,
typename R,
typename... Args>
986 struct fx_traits<R (__stdcall T::*)(Args...) const volatile&& noexcept, false> :
basic_traits<true, false, T, R, Args...> {
987 typedef R (__stdcall T::*function_pointer_type)(Args...)
const volatile&& noexcept;
995 #endif // noexcept is part of a function's type 996 #endif // __stdcall x86 VC++ bug 998 template <
typename Signature>
999 struct fx_traits<Signature, true> :
fx_traits<typename fx_traits<decltype(&Signature::operator())>::function_type, false> {};
1001 template <typename Signature, bool b = std::is_member_object_pointer<Signature>::value>
1005 template <
typename R,
typename T>
1007 typedef std::conditional_t<std::is_array<R>::value, std::add_lvalue_reference_t<T>, R>
return_type;
1011 static const bool is_noexcept =
false;
1012 static const bool is_member_function =
false;
1013 static const std::size_t arity = 1;
1014 static const std::size_t free_arity = 2;
1019 typedef return_type(function_type)(T&, return_type);
1020 typedef return_type(*function_pointer_type)(T&, Arg);
1021 typedef return_type(*free_function_pointer_type)(T&, Arg);
1022 template <std::
size_t i>
1028 template <
typename Signature>
1031 template <
typename Signature>
1034 template <
typename Signature>
1037 template <
typename Signature>
1046 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 1047 #include <string_view> 1048 #endif // C++17 features 1049 #include <functional> 1050 #if defined(SOL_USE_BOOST) && SOL_USE_BOOST 1051 #include <boost/functional/hash.hpp> 1055 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 1056 template <
typename C,
typename T = std::
char_traits<C>>
1064 template <
typename Char,
typename Traits = std::
char_traits<Char>>
1065 struct basic_string_view {
1070 : basic_string_view(r.data(), r.size()) {
1073 : basic_string_view(ptr, Traits::
length(ptr)) {
1079 static int compare(
const Char* lhs_p, std::size_t lhs_sz,
const Char* rhs_p, std::size_t rhs_sz) {
1080 int result = Traits::compare(lhs_p, rhs_p, lhs_sz < rhs_sz ? lhs_sz : rhs_sz);
1083 if (lhs_sz < rhs_sz)
1085 if (lhs_sz > rhs_sz)
1118 operator std::basic_string<Char, Traits>()
const {
1119 return std::basic_string<Char, Traits>(data(), size());
1123 return compare(p, s, r.
data(), r.
size()) == 0;
1130 bool operator==(
const std::basic_string<Char, Traits>& r)
const {
1131 return compare(r.data(), r.size(), p, s) == 0;
1135 return !(*
this == r);
1139 return !(*
this == r);
1142 bool operator!=(
const std::basic_string<Char, Traits>& r)
const {
1143 return !(*
this == r);
1147 template <
typename Ch,
typename Tr = std::
char_traits<Ch>>
1152 template <
typename Al>
1153 result_type
operator()(
const std::basic_string<Ch, Tr, Al>& r)
const {
1154 return (*
this)(argument_type(r.c_str(), r.size()));
1158 #if defined(SOL_USE_BOOST) && SOL_USE_BOOST 1159 return boost::hash_range(r.
begin(), r.
end());
1168 std::size_t hash = 0;
1169 const unsigned char* cptr =
reinterpret_cast<const unsigned char*
>(r.
data());
1170 for (std::size_t sz = r.
size(); sz != 0; --sz) {
1171 hash ^=
static_cast<size_t>(*cptr++);
1172 hash *=
static_cast<size_t>(1099511628211ULL);
1181 template <
typename Ch,
typename Tr>
1191 #endif // C++17 Support 1196 #include <type_traits> 1204 template <std::
size_t I>
1211 template <
typename T>
1214 template <
typename T>
1217 template <
typename... Args>
1220 template <
typename... Args>
1223 template <
typename T>
1224 struct is_builtin_type : std::integral_constant<bool, std::is_arithmetic<T>::value || std::is_pointer<T>::value || std::is_array<T>::value> {};
1226 template <
typename T>
1231 template <
typename T>
1236 template <
typename T>
1239 template <
typename T>
1242 template <
typename T>
1245 template <
typename T>
1248 template <
typename R,
typename T>
1253 template <
typename R,
typename T>
1258 template <
typename T>
1261 namespace meta_detail {
1262 template <
typename T,
template <
typename...>
class Templ>
1264 template <
typename... T,
template <
typename...>
class Templ>
1268 template <
typename T,
template <
typename...>
class Templ>
1271 template <
class T,
class...>
1274 template <
class T,
class U,
class... Args>
1275 struct all_same<T, U, Args...> : std::integral_constant<bool, std::is_same<T, U>::value && all_same<T, Args...>::value> {};
1277 template <
class T,
class...>
1280 template <
class T,
class U,
class... Args>
1281 struct any_same<T, U, Args...> : std::integral_constant<bool, std::is_same<T, U>::value || any_same<T, Args...>::value> {};
1284 using boolean = std::integral_constant<bool, B>;
1286 template <
typename T>
1289 template <
typename T>
1292 template <
typename T>
1295 template <
typename Condition,
typename Then,
typename Else>
1296 using condition = std::conditional_t<Condition::value, Then, Else>;
1298 template <
typename... Args>
1301 template <
typename T,
typename... Args>
1304 template <
typename... Args>
1307 template <
typename T,
typename... Args>
1316 template <
bool value,
typename T =
void>
1319 template <
typename... Args>
1322 template <
typename... Args>
1325 template <
typename... Args>
1328 template <
typename... Args>
1331 template <
typename V,
typename... Vs>
1334 template <
typename V,
typename Vs1,
typename... Vs>
1335 struct find_in_pack_v<V, Vs1, Vs...> :
any<boolean<(V::value == Vs1::value)>, find_in_pack_v<V, Vs...>> {};
1337 namespace meta_detail {
1338 template <std::size_t I,
typename T,
typename... Args>
1341 template <std::size_t I,
typename T,
typename T1,
typename... Args>
1342 struct index_in_pack<I, T, T1, Args...> : std::conditional_t<std::is_same<T, T1>::value, std::integral_constant<std::ptrdiff_t, I>, index_in_pack<I + 1, T, Args...>> {};
1345 template <
typename T,
typename... Args>
1348 template <
typename T,
typename List>
1351 template <
typename T,
typename... Args>
1354 template <std::size_t I,
typename... Args>
1357 template <std::size_t I,
typename... Args>
1360 template <std::size_t I,
typename Arg,
typename... Args>
1361 struct at_in_pack<I, Arg, Args...> : std::conditional<I == 0, Arg, at_in_pack_t<I - 1, Args...>> {};
1363 template <
typename Arg,
typename... Args>
1366 namespace meta_detail {
1367 template <std::size_t Limit, std::size_t I,
template <
typename...>
class Pred,
typename... Ts>
1369 template <std::size_t Limit, std::size_t I,
template <
typename...>
class Pred,
typename T,
typename... Ts>
1370 struct count_for_pack<Limit, I, Pred, T, Ts...> : std::conditional_t < sizeof...(Ts)
1373 std::integral_constant<std::size_t, I + static_cast<std::size_t>(Limit != 0 && Pred<T>::value)>,
1374 count_for_pack<Limit - 1, I + static_cast<std::size_t>(Pred<T>::value), Pred, Ts...>> {};
1375 template <std::size_t I, template <typename...> class Pred, typename... Ts>
1376 struct count_2_for_pack : std::integral_constant<std::size_t, 0> {};
1377 template <std::size_t I, template <typename...> class Pred, typename T, typename U, typename... Ts>
1378 struct count_2_for_pack<I, Pred, T, U, Ts...> : std::conditional_t<sizeof...(Ts) == 0,
1379 std::integral_constant<std::size_t, I + static_cast<std::size_t>(Pred<T>::value)>,
1380 count_2_for_pack<I + static_cast<std::size_t>(Pred<T>::value), Pred, Ts...>> {};
1383 template <template <typename...> class Pred, typename... Ts>
1384 struct count_for_pack : meta_detail::count_for_pack<sizeof...(Ts), 0, Pred, Ts...> {};
1386 template <template <typename...> class Pred, typename List>
1389 template <template <typename...> class Pred, typename... Args>
1390 struct count_for<Pred, types<Args...>> : count_for_pack<Pred, Args...> {};
1392 template <std::size_t Limit, template <typename...> class Pred, typename... Ts>
1393 struct count_for_to_pack : meta_detail::count_for_pack<Limit, 0, Pred, Ts...> {};
1395 template <template <typename...> class Pred, typename... Ts>
1396 struct count_2_for_pack : meta_detail::count_2_for_pack<0, Pred, Ts...> {};
1398 template <typename... Args>
1399 struct return_type {
1400 typedef std::tuple<Args...> type;
1403 template <typename T>
1404 struct return_type<T> {
1409 struct return_type<> {
1413 template <typename... Args>
1414 using return_type_t = typename return_type<Args...>::type;
1416 namespace meta_detail {
1418 struct always_true : std::true_type {};
1419 struct is_invokable_tester {
1420 template <typename Fun, typename... Args>
1421 static always_true<decltype(std::declval<Fun>()(std::declval<Args>()...))> test(int);
1422 template <typename...>
1423 static std::false_type test(...);
1427 template <typename T>
1428 struct is_invokable;
1429 template <typename Fun, typename... Args>
1430 struct is_invokable<Fun(Args...)> : decltype(meta_detail::is_invokable_tester::test<Fun, Args...>(0)) {};
1432 namespace meta_detail {
1434 template <typename T, typename = void>
1435 struct is_callable : std::is_function<std::remove_pointer_t<T>> {};
1437 template <typename T>
1438 struct is_callable<T, std::enable_if_t<std::is_final<unqualified_t<T>>::value
1439 && std::is_class<unqualified_t<T>>::value
1440 && std::is_same<decltype(void(&T::operator())), void>::value>> {
1444 template <typename T>
1445 struct is_callable<T, std::enable_if_t<!std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value && std::is_destructible<unqualified_t<T>>::value>> {
1447 using no = struct { char s[2]; };
1452 struct Derived : T, F {};
1453 template <typename U, U>
1456 template <typename V>
1457 static no test(Check<void (F::*)(), &V::operator()>*);
1460 static yes test(...);
1462 static const bool value = sizeof(test<Derived>(0)) == sizeof(yes);
1465 template <typename T>
1466 struct is_callable<T, std::enable_if_t<!std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value && !std::is_destructible<unqualified_t<T>>::value>> {
1468 using no = struct { char s[2]; };
1473 struct Derived : T, F {
1474 ~Derived() = delete;
1476 template <typename U, U>
1479 template <typename V>
1480 static no test(Check<void (F::*)(), &V::operator()>*);
1483 static yes test(...);
1485 static const bool value = sizeof(test<Derived>(0)) == sizeof(yes);
1488 struct has_begin_end_impl {
1489 template <typename T, typename U = unqualified_t<T>,
1490 typename B = decltype(std::declval<U&>().begin()),
1491 typename E = decltype(std::declval<U&>().end())>
1492 static std::true_type test(int);
1494 template <typename...>
1495 static std::false_type test(...);
1498 struct has_key_type_impl {
1499 template <typename T, typename U = unqualified_t<T>,
1500 typename V = typename U::key_type>
1501 static std::true_type test(int);
1503 template <typename...>
1504 static std::false_type test(...);
1507 struct has_mapped_type_impl {
1508 template <typename T, typename U = unqualified_t<T>,
1509 typename V = typename U::mapped_type>
1510 static std::true_type test(int);
1512 template <typename...>
1513 static std::false_type test(...);
1516 struct has_value_type_impl {
1517 template <typename T, typename U = unqualified_t<T>,
1518 typename V = typename U::value_type>
1519 static std::true_type test(int);
1521 template <typename...>
1522 static std::false_type test(...);
1525 struct has_iterator_impl {
1526 template <typename T, typename U = unqualified_t<T>,
1527 typename V = typename U::iterator>
1528 static std::true_type test(int);
1530 template <typename...>
1531 static std::false_type test(...);
1534 struct has_key_value_pair_impl {
1535 template <typename T, typename U = unqualified_t<T>,
1536 typename V = typename U::value_type,
1537 typename F = decltype(std::declval<V&>().first),
1538 typename S = decltype(std::declval<V&>().second)>
1539 static std::true_type test(int);
1541 template <typename...>
1542 static std::false_type test(...);
1545 template <typename T>
1546 struct has_push_back_test {
1548 template <typename C>
1549 static sfinae_yes_t test(decltype(std::declval<C>().push_back(std::declval<std::add_rvalue_reference_t<typename C::value_type>>())) *);
1550 template <typename C>
1551 static sfinae_no_t test(...);
1554 static const bool value = sizeof(test<T>(0)) == sizeof(sfinae_yes_t);
1557 template <typename T>
1558 struct has_insert_test {
1560 template <typename C>
1561 static sfinae_yes_t test(decltype(std::declval<C>().insert(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>(), std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
1562 template <typename C>
1563 static sfinae_no_t test(...);
1566 static const bool value = sizeof(test<T>(0)) == sizeof(sfinae_yes_t);
1569 template <typename T>
1570 struct has_insert_after_test {
1572 template <typename C>
1573 static sfinae_yes_t test(decltype(std::declval<C>().insert_after(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>(), std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
1574 template <typename C>
1575 static sfinae_no_t test(...);
1578 static const bool value = sizeof(test<T>(0)) == sizeof(sfinae_yes_t);
1581 template <typename T>
1582 struct has_size_test {
1584 typedef std::array<char, 1> sfinae_yes_t;
1585 typedef std::array<char, 2> sfinae_no_t;
1587 template <typename C>
1588 static sfinae_yes_t test(decltype(std::declval<C>().size())*);
1589 template <typename C>
1590 static sfinae_no_t test(...);
1593 static const bool value = sizeof(test<T>(0)) == sizeof(sfinae_yes_t);
1596 template <typename T>
1597 struct has_max_size_test {
1599 typedef std::array<char, 1> sfinae_yes_t;
1600 typedef std::array<char, 2> sfinae_no_t;
1602 template <typename C>
1603 static sfinae_yes_t test(decltype(std::declval<C>().max_size())*);
1604 template <typename C>
1605 static sfinae_no_t test(...);
1608 static const bool value = sizeof(test<T>(0)) == sizeof(sfinae_yes_t);
1611 template <typename T>
1612 struct has_to_string_test {
1614 typedef std::array<char, 1> sfinae_yes_t;
1615 typedef std::array<char, 2> sfinae_no_t;
1617 template <typename C>
1618 static sfinae_yes_t test(decltype(std::declval<C>().to_string())*);
1619 template <typename C>
1620 static sfinae_no_t test(...);
1623 static const bool value = sizeof(test<T>(0)) == sizeof(sfinae_yes_t);
1625 #if defined(_MSC_VER) && _MSC_VER <= 1910
1626 template <typename T, typename U, typename = decltype(std::declval<T&>() < std::declval<U&>())>
1627 std::true_type supports_op_less_test(std::reference_wrapper<T>, std::reference_wrapper<U>);
1628 std::false_type supports_op_less_test(...);
1629 template <typename T, typename U, typename = decltype(std::declval<T&>() == std::declval<U&>())>
1630 std::true_type supports_op_equal_test(std::reference_wrapper<T>, std::reference_wrapper<U>);
1631 std::false_type supports_op_equal_test(...);
1632 template <typename T, typename U, typename = decltype(std::declval<T&>() <= std::declval<U&>())>
1633 std::true_type supports_op_less_equal_test(std::reference_wrapper<T>, std::reference_wrapper<U>);
1634 std::false_type supports_op_less_equal_test(...);
1635 template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<T&>())>
1636 std::true_type supports_ostream_op(std::reference_wrapper<T>, std::reference_wrapper<OS>);
1637 std::false_type supports_ostream_op(...);
1638 template <typename T, typename = decltype(to_string(std::declval<T&>()))>
1639 std::true_type supports_adl_to_string(std::reference_wrapper<T>);
1640 std::false_type supports_adl_to_string(...);
1642 template <typename T, typename U, typename = decltype(std::declval<T&>() < std::declval<U&>())>
1643 std::true_type supports_op_less_test(const T&, const U&);
1644 std::false_type supports_op_less_test(...);
1645 template <typename T, typename U, typename = decltype(std::declval<T&>() == std::declval<U&>())>
1646 std::true_type supports_op_equal_test(const T&, const U&);
1647 std::false_type supports_op_equal_test(...);
1648 template <typename T, typename U, typename = decltype(std::declval<T&>() <= std::declval<U&>())>
1649 std::true_type supports_op_less_equal_test(const T&, const U&);
1650 std::false_type supports_op_less_equal_test(...);
1651 template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<T&>())>
1652 std::true_type supports_ostream_op(const T&, const OS&);
1653 std::false_type supports_ostream_op(...);
1654 template <typename T, typename = decltype(to_string(std::declval<T&>()))>
1655 std::true_type supports_adl_to_string(const T&);
1656 std::false_type supports_adl_to_string(...);
1659 template <typename T, bool b>
1660 struct is_matched_lookup_impl : std::false_type {};
1661 template <typename T>
1662 struct is_matched_lookup_impl<T, true> : std::is_same<typename T::key_type, typename T::value_type> {};
1665 #if defined(_MSC_VER) && _MSC_VER <= 1910
1666 template <typename T, typename U = T>
1667 using supports_op_less = decltype(meta_detail::supports_op_less_test(std::ref(std::declval<T&>()), std::ref(std::declval<U&>())));
1668 template <typename T, typename U = T>
1669 using supports_op_equal = decltype(meta_detail::supports_op_equal_test(std::ref(std::declval<T&>()), std::ref(std::declval<U&>())));
1670 template <typename T, typename U = T>
1671 using supports_op_less_equal = decltype(meta_detail::supports_op_less_equal_test(std::ref(std::declval<T&>()), std::ref(std::declval<U&>())));
1672 template <typename T, typename U = std::ostream>
1673 using supports_ostream_op = decltype(meta_detail::supports_ostream_op(std::ref(std::declval<T&>()), std::ref(std::declval<U&>())));
1674 template <typename T>
1675 using supports_adl_to_string = decltype(meta_detail::supports_adl_to_string(std::ref(std::declval<T&>())));
1677 template <typename T, typename U = T>
1678 using supports_op_less = decltype(meta_detail::supports_op_less_test(std::declval<T&>(), std::declval<U&>()));
1679 template <typename T, typename U = T>
1680 using supports_op_equal = decltype(meta_detail::supports_op_equal_test(std::declval<T&>(), std::declval<U&>()));
1681 template <typename T, typename U = T>
1682 using supports_op_less_equal = decltype(meta_detail::supports_op_less_equal_test(std::declval<T&>(), std::declval<U&>()));
1683 template <typename T, typename U = std::ostream>
1684 using supports_ostream_op = decltype(meta_detail::supports_ostream_op(std::declval<T&>(), std::declval<U&>()));
1685 template <typename T>
1686 using supports_adl_to_string = decltype(meta_detail::supports_adl_to_string(std::declval<T&>()));
1688 template <typename T>
1689 using supports_to_string_member = meta::boolean<meta_detail::has_to_string_test<T>::value>;
1691 template <typename T>
1692 struct is_callable : boolean<meta_detail::is_callable<T>::value> {};
1694 template <typename T>
1695 struct has_begin_end : decltype(meta_detail::has_begin_end_impl::test<T>(0)) {};
1697 template <typename T>
1698 struct has_key_value_pair : decltype(meta_detail::has_key_value_pair_impl::test<T>(0)) {};
1700 template <typename T>
1701 struct has_key_type : decltype(meta_detail::has_key_type_impl::test<T>(0)) {};
1703 template <typename T>
1704 struct has_mapped_type : decltype(meta_detail::has_mapped_type_impl::test<T>(0)) {};
1706 template <typename T>
1707 struct has_iterator : decltype(meta_detail::has_iterator_impl::test<T>(0)) {};
1709 template <typename T>
1710 struct has_value_type : decltype(meta_detail::has_value_type_impl::test<T>(0)) {};
1712 template <typename T>
1713 using has_push_back = meta::boolean<meta_detail::has_push_back_test<T>::value>;
1715 template <typename T>
1716 using has_max_size = meta::boolean<meta_detail::has_max_size_test<T>::value>;
1718 template <typename T>
1719 using has_insert = meta::boolean<meta_detail::has_insert_test<T>::value>;
1721 template <typename T>
1722 using has_insert_after = meta::boolean<meta_detail::has_insert_after_test<T>::value>;
1724 template <typename T>
1725 using has_size = meta::boolean<meta_detail::has_size_test<T>::value || meta_detail::has_size_test<const T>::value>;
1727 template <typename T>
1728 struct is_associative : meta::all<has_key_type<T>, has_key_value_pair<T>, has_mapped_type<T>> {};
1730 template <typename T>
1731 struct is_lookup : meta::all<has_key_type<T>, has_value_type<T>> {};
1733 template <typename T>
1734 struct is_matched_lookup : meta_detail::is_matched_lookup_impl<T, is_lookup<T>::value> {};
1736 template <typename T>
1737 using is_string_like = any<
1738 is_specialization_of<meta::unqualified_t<T>, std::basic_string>,
1739 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
1740 is_specialization_of<meta::unqualified_t<T>, std::basic_string_view>,
1742 is_specialization_of<meta::unqualified_t<T>, basic_string_view>,
1744 meta::all<std::is_array<unqualified_t<T>>, meta::any_same<meta::unqualified_t<std::remove_all_extents_t<meta::unqualified_t<T>>>, char, char16_t, char32_t, wchar_t>>
1747 template <typename T>
1748 using is_string_constructible = any<
1749 meta::all<std::is_array<unqualified_t<T>>, std::is_same<meta::unqualified_t<std::remove_all_extents_t<meta::unqualified_t<T>>>, char>>,
1750 std::is_same<unqualified_t<T>, const char*>,
1751 std::is_same<unqualified_t<T>, char>, std::is_same<unqualified_t<T>, std::string>, std::is_same<unqualified_t<T>, std::initializer_list<char>>
1752 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
1753 , std::is_same<unqualified_t<T>, std::string_view>
1757 template <typename T>
1758 struct is_pair : std::false_type {};
1760 template <typename T1, typename T2>
1761 struct is_pair<std::pair<T1, T2>> : std::true_type {};
1763 template <typename T>
1764 using is_c_str = any<
1765 std::is_same<std::decay_t<unqualified_t<T>>, const char*>,
1766 std::is_same<std::decay_t<unqualified_t<T>>, char*>,
1767 std::is_same<unqualified_t<T>, std::string>>;
1769 template <typename T>
1770 struct is_move_only : all<
1771 neg<std::is_reference<T>>,
1772 neg<std::is_copy_constructible<unqualified_t<T>>>,
1773 std::is_move_constructible<unqualified_t<T>>> {};
1775 template <typename T>
1776 using is_not_move_only = neg<is_move_only<T>>;
1778 namespace meta_detail {
1779 template <typename T, meta::disable<meta::is_specialization_of<meta::unqualified_t<T>, std::tuple>> = meta::enabler>
1780 decltype(auto) force_tuple(T&& x) {
1781 return std::tuple<std::decay_t<T>>(std::forward<T>(x));
1784 template <typename T, meta::enable<meta::is_specialization_of<meta::unqualified_t<T>, std::tuple>> = meta::enabler>
1785 decltype(auto) force_tuple(T&& x) {
1786 return std::forward<T>(x);
1790 template <typename... X>
1791 decltype(auto) tuplefy(X&&... x) {
1792 return std::tuple_cat(meta_detail::force_tuple(std::forward<X>(x))...);
1795 template <typename T, typename = void>
1796 struct iterator_tag {
1797 using type = std::input_iterator_tag;
1800 template <typename T>
1801 struct iterator_tag<T, std::conditional_t<false, typename T::iterator_category, void>> {
1802 using type = typename T::iterator_category;
1808 template <typename T>
1809 struct is_pointer_like : std::is_pointer<T> {};
1810 template <typename T, typename D>
1811 struct is_pointer_like<std::unique_ptr<T, D>> : std::true_type {};
1812 template <typename T>
1813 struct is_pointer_like<std::shared_ptr<T>> : std::true_type {};
1815 template <std::size_t I, typename Tuple>
1816 decltype(auto) forward_get(Tuple&& tuple) {
1817 return std::forward<meta::tuple_element_t<I, Tuple>>(std::get<I>(tuple));
1820 template <std::size_t... I, typename Tuple>
1821 auto forward_tuple_impl(std::index_sequence<I...>, Tuple&& tuple) -> decltype(std::tuple<decltype(forward_get<I>(tuple))...>(forward_get<I>(tuple)...)) {
1822 return std::tuple<decltype(forward_get<I>(tuple))...>(std::move(std::get<I>(tuple))...);
1825 template <typename Tuple>
1826 auto forward_tuple(Tuple&& tuple) {
1827 auto x = forward_tuple_impl(std::make_index_sequence<std::tuple_size<meta::unqualified_t<Tuple>>::value>(), std::forward<Tuple>(tuple));
1831 template <typename T>
1832 auto unwrap(T&& item) -> decltype(std::forward<T>(item)) {
1833 return std::forward<T>(item);
1836 template <typename T>
1837 T& unwrap(std::reference_wrapper<T> arg) {
1841 template <typename T, meta::enable<meta::neg<is_pointer_like<meta::unqualified_t<T>>>> = meta::enabler>
1842 auto deref(T&& item) -> decltype(std::forward<T>(item)) {
1843 return std::forward<T>(item);
1846 template <typename T, meta::enable<is_pointer_like<meta::unqualified_t<T>>> = meta::enabler>
1847 inline auto deref(T&& item) -> decltype(*std::forward<T>(item)) {
1848 return *std::forward<T>(item);
1851 template <typename T, meta::disable<is_pointer_like<meta::unqualified_t<T>>, meta::neg<std::is_pointer<meta::unqualified_t<T>>>> = meta::enabler>
1852 auto deref_non_pointer(T&& item) -> decltype(std::forward<T>(item)) {
1853 return std::forward<T>(item);
1856 template <typename T, meta::enable<is_pointer_like<meta::unqualified_t<T>>, meta::neg<std::is_pointer<meta::unqualified_t<T>>>> = meta::enabler>
1857 inline auto deref_non_pointer(T&& item) -> decltype(*std::forward<T>(item)) {
1858 return *std::forward<T>(item);
1861 template <typename T>
1862 inline T* ptr(T& val) {
1863 return std::addressof(val);
1866 template <typename T>
1867 inline T* ptr(std::reference_wrapper<T> val) {
1868 return std::addressof(val.get());
1871 template <typename T>
1872 inline T* ptr(T* val) {
1894 #if defined(SOL_USING_CXX_LUA) && SOL_USING_CXX_LUA
1897 #include <lauxlib.h>
1898 #if defined(SOL_USING_CXX_LUAJIT) && SOL_USING_CXX_LUAJIT
1901 #if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !(SOL_EXCEPTIONS_SAFE_PROPAGATION)) && (!defined(SOL_EXCEPTIONS_ALWAYS_UNSAFE) || !(SOL_EXCEPTIONS_ALWAYS_UNSAFE))
1902 #define SOL_EXCEPTIONS_SAFE_PROPAGATION 1
1908 #ifdef LUAJIT_VERSION
1910 #define SOL_LUAJIT 1
1911 #ifndef SOL_LUAJIT_VERSION
1912 #define SOL_LUAJIT_VERSION LUAJIT_VERSION_NUM
1917 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 502
1918 #define SOL_LUA_VERSION LUA_VERSION_NUM
1919 #elif defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
1920 #define SOL_LUA_VERSION LUA_VERSION_NUM
1921 #elif !defined(LUA_VERSION_NUM) || !(LUA_VERSION_NUM)
1922 #define SOL_LUA_VERSION 500
1924 #define SOL_LUA_VERSION 502
1929 #if !defined(SOL_NO_COMPAT) || !(SOL_NO_COMPAT)
1931 #if defined(SOL_USING_CXX_LUA) && SOL_USING_CXX_LUA
1932 #ifndef COMPAT53_LUA_CPP
1933 #define COMPAT53_LUA_CPP 1
1936 #ifndef COMPAT53_INCLUDE_SOURCE
1937 #define COMPAT53_INCLUDE_SOURCE 1
1941 #ifndef KEPLER_PROJECT_COMPAT53_H_
1942 #define KEPLER_PROJECT_COMPAT53_H_
1947 #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
1950 #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
1954 #ifndef COMPAT53_PREFIX
1959 # define COMPAT53_PREFIX kp_compat53
1962 #ifndef COMPAT53_API
1963 # if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE
1964 # if defined(__GNUC__) || defined(__clang__)
1965 # define COMPAT53_API __attribute__((__unused__)) static
1967 # define COMPAT53_API static
1971 # define COMPAT53_API extern
1975 #define COMPAT53_CONCAT_HELPER(a, b) a##b
1976 #define COMPAT53_CONCAT(a, b) COMPAT53_CONCAT_HELPER(a, b)
1979 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
1993 # define LUA_OPADD 0
1996 # define LUA_OPSUB 1
1999 # define LUA_OPMUL 2
2002 # define LUA_OPDIV 3
2005 # define LUA_OPMOD 4
2008 # define LUA_OPPOW 5
2011 # define LUA_OPUNM 6
2027 #if !defined(LUA_ERRGCMM)
2033 # define LUA_ERRGCMM (LUA_ERRERR + 2)
2036 typedef size_t lua_Unsigned;
2038 typedef struct luaL_Buffer_53 {
2045 #define luaL_Buffer luaL_Buffer_53
2051 typedef struct luaL_Stream {
2055 #define lua_absindex COMPAT53_CONCAT(COMPAT53_PREFIX, _absindex)
2056 COMPAT53_API int lua_absindex(lua_State *L, int i);
2058 #define lua_arith COMPAT53_CONCAT(COMPAT53_PREFIX, _arith)
2059 COMPAT53_API void lua_arith(lua_State *L, int op);
2061 #define lua_compare COMPAT53_CONCAT(COMPAT53_PREFIX, _compare)
2062 COMPAT53_API int lua_compare(lua_State *L, int idx1, int idx2, int op);
2064 #define lua_copy COMPAT53_CONCAT(COMPAT53_PREFIX, _copy)
2065 COMPAT53_API void lua_copy(lua_State *L, int from, int to);
2067 #define lua_getuservalue(L, i) \
2068 (lua_getfenv((L), (i)), lua_type((L), -1))
2069 #define lua_setuservalue(L, i) \
2070 (luaL_checktype((L), -1, LUA_TTABLE), lua_setfenv((L), (i)))
2072 #define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len)
2073 COMPAT53_API void lua_len(lua_State *L, int i);
2075 #define lua_pushstring(L, s) \
2076 (lua_pushstring((L), (s)), lua_tostring((L), -1))
2078 #define lua_pushlstring(L, s, len) \
2079 ((((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))), lua_tostring((L), -1))
2081 #ifndef luaL_newlibtable
2082 # define luaL_newlibtable(L, l) \
2083 (lua_createtable((L), 0, sizeof((l))/sizeof(*(l))-1))
2086 # define luaL_newlib(L, l) \
2087 (luaL_newlibtable((L), (l)), luaL_register((L), NULL, (l)))
2090 #define lua_pushglobaltable(L) \
2091 lua_pushvalue((L), LUA_GLOBALSINDEX)
2093 #define lua_rawgetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawgetp)
2094 COMPAT53_API int lua_rawgetp(lua_State *L, int i, const void *p);
2096 #define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp)
2097 COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p);
2099 #define lua_rawlen(L, i) lua_objlen((L), (i))
2101 #define lua_tointeger(L, i) lua_tointegerx((L), (i), NULL)
2103 #define lua_tonumberx COMPAT53_CONCAT(COMPAT53_PREFIX, _tonumberx)
2104 COMPAT53_API lua_Number lua_tonumberx(lua_State *L, int i, int *isnum);
2106 #define luaL_checkversion COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkversion)
2107 COMPAT53_API void luaL_checkversion(lua_State *L);
2109 #define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53)
2110 COMPAT53_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char* source, const char* mode);
2112 #define luaL_loadfilex COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadfilex)
2113 COMPAT53_API int luaL_loadfilex(lua_State *L, const char *filename, const char *mode);
2115 #define luaL_loadbufferx COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadbufferx)
2116 COMPAT53_API int luaL_loadbufferx(lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);
2118 #define luaL_checkstack COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkstack_53)
2119 COMPAT53_API void luaL_checkstack(lua_State *L, int sp, const char *msg);
2121 #define luaL_getsubtable COMPAT53_CONCAT(COMPAT53_PREFIX, L_getsubtable)
2122 COMPAT53_API int luaL_getsubtable(lua_State* L, int i, const char *name);
2124 #define luaL_len COMPAT53_CONCAT(COMPAT53_PREFIX, L_len)
2125 COMPAT53_API lua_Integer luaL_len(lua_State *L, int i);
2127 #define luaL_setfuncs COMPAT53_CONCAT(COMPAT53_PREFIX, L_setfuncs)
2128 COMPAT53_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup);
2130 #define luaL_setmetatable COMPAT53_CONCAT(COMPAT53_PREFIX, L_setmetatable)
2131 COMPAT53_API void luaL_setmetatable(lua_State *L, const char *tname);
2133 #define luaL_testudata COMPAT53_CONCAT(COMPAT53_PREFIX, L_testudata)
2134 COMPAT53_API void *luaL_testudata(lua_State *L, int i, const char *tname);
2136 #define luaL_traceback COMPAT53_CONCAT(COMPAT53_PREFIX, L_traceback)
2137 COMPAT53_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level);
2139 #define luaL_fileresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_fileresult)
2140 COMPAT53_API int luaL_fileresult(lua_State *L, int stat, const char *fname);
2142 #define luaL_execresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_execresult)
2143 COMPAT53_API int luaL_execresult(lua_State *L, int stat);
2145 #define lua_callk(L, na, nr, ctx, cont) \
2146 ((void)(ctx), (void)(cont), lua_call((L), (na), (nr)))
2147 #define lua_pcallk(L, na, nr, err, ctx, cont) \
2148 ((void)(ctx), (void)(cont), lua_pcall((L), (na), (nr), (err)))
2150 #define lua_resume(L, from, nargs) \
2151 ((void)(from), lua_resume((L), (nargs)))
2153 #define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53)
2154 COMPAT53_API void luaL_buffinit(lua_State *L, luaL_Buffer_53 *B);
2156 #define luaL_prepbuffsize COMPAT53_CONCAT(COMPAT53_PREFIX, _prepbufsize_53)
2157 COMPAT53_API char *luaL_prepbuffsize(luaL_Buffer_53 *B, size_t s);
2159 #define luaL_addlstring COMPAT53_CONCAT(COMPAT53_PREFIX, _addlstring_53)
2160 COMPAT53_API void luaL_addlstring(luaL_Buffer_53 *B, const char *s, size_t l);
2162 #define luaL_addvalue COMPAT53_CONCAT(COMPAT53_PREFIX, _addvalue_53)
2163 COMPAT53_API void luaL_addvalue(luaL_Buffer_53 *B);
2165 #define luaL_pushresult COMPAT53_CONCAT(COMPAT53_PREFIX, _pushresult_53)
2166 COMPAT53_API void luaL_pushresult(luaL_Buffer_53 *B);
2168 #undef luaL_buffinitsize
2169 #define luaL_buffinitsize(L, B, s) \
2170 (luaL_buffinit((L), (B)), luaL_prepbuffsize((B), (s)))
2172 #undef luaL_prepbuffer
2173 #define luaL_prepbuffer(B) \
2174 luaL_prepbuffsize((B), LUAL_BUFFERSIZE)
2177 #define luaL_addchar(B, c) \
2178 ((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize((B), 1)), \
2179 ((B)->ptr[(B)->nelems++] = (c)))
2182 #define luaL_addsize(B, s) \
2183 ((B)->nelems += (s))
2185 #undef luaL_addstring 2186 #define luaL_addstring(B, s) \ 2187 luaL_addlstring((B), (s), strlen((s))) 2189 #undef luaL_pushresultsize 2190 #define luaL_pushresultsize(B, s) \ 2191 (luaL_addsize((B), (s)), luaL_pushresult((B))) 2193 #if defined(LUA_COMPAT_APIINTCASTS) 2194 #define lua_pushunsigned(L, n) \ 2195 lua_pushinteger((L), (lua_Integer)(n)) 2196 #define lua_tounsignedx(L, i, is) \ 2197 ((lua_Unsigned)lua_tointegerx((L), (i), (is))) 2198 #define lua_tounsigned(L, i) \ 2199 lua_tounsignedx((L), (i), NULL) 2200 #define luaL_checkunsigned(L, a) \ 2201 ((lua_Unsigned)luaL_checkinteger((L), (a))) 2202 #define luaL_optunsigned(L, a, d) \ 2203 ((lua_Unsigned)luaL_optinteger((L), (a), (lua_Integer)(d))) 2209 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502 2211 typedef int lua_KContext;
2213 typedef int(*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);
2215 #define lua_dump(L, w, d, s) \ 2216 ((void)(s), lua_dump((L), (w), (d))) 2218 #define lua_getfield(L, i, k) \ 2219 (lua_getfield((L), (i), (k)), lua_type((L), -1)) 2221 #define lua_gettable(L, i) \ 2222 (lua_gettable((L), (i)), lua_type((L), -1)) 2224 #define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti) 2225 COMPAT53_API int lua_geti(lua_State *L, int index, lua_Integer i);
2227 #define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger) 2228 COMPAT53_API int lua_isinteger(lua_State *L, int index);
2230 #define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx_53) 2231 COMPAT53_API lua_Integer lua_tointegerx(lua_State *L, int i, int *isnum);
2233 #define lua_numbertointeger(n, p) \ 2234 ((*(p) = (lua_Integer)(n)), 1) 2236 #define lua_rawget(L, i) \ 2237 (lua_rawget((L), (i)), lua_type((L), -1)) 2239 #define lua_rawgeti(L, i, n) \ 2240 (lua_rawgeti((L), (i), (n)), lua_type((L), -1)) 2242 #define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate) 2243 COMPAT53_API void lua_rotate(lua_State *L, int idx, int n);
2245 #define lua_seti COMPAT53_CONCAT(COMPAT53_PREFIX, _seti) 2246 COMPAT53_API void lua_seti(lua_State *L, int index, lua_Integer i);
2248 #define lua_stringtonumber COMPAT53_CONCAT(COMPAT53_PREFIX, _stringtonumber) 2249 COMPAT53_API size_t lua_stringtonumber(lua_State *L, const char *s);
2251 #define luaL_tolstring COMPAT53_CONCAT(COMPAT53_PREFIX, L_tolstring) 2252 COMPAT53_API const char *luaL_tolstring(lua_State *L, int idx, size_t *len);
2254 #define luaL_getmetafield(L, o, e) \ 2255 (luaL_getmetafield((L), (o), (e)) ? lua_type((L), -1) : LUA_TNIL) 2257 #define luaL_newmetatable(L, tn) \ 2258 (luaL_newmetatable((L), (tn)) ? (lua_pushstring((L), (tn)), lua_setfield((L), -2, "__name"), 1) : 0) 2260 #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53) 2261 COMPAT53_API void luaL_requiref(lua_State *L, const char *modname,
2262 lua_CFunction openf, int glb);
2267 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 502 2276 #define lua_getglobal(L, n) \ 2277 (lua_getglobal((L), (n)), lua_type((L), -1)) 2279 #define lua_getuservalue(L, i) \ 2280 (lua_getuservalue((L), (i)), lua_type((L), -1)) 2282 #define lua_pushlstring(L, s, len) \ 2283 (((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))) 2285 #define lua_rawgetp(L, i, p) \ 2286 (lua_rawgetp((L), (i), (p)), lua_type((L), -1)) 2288 #define LUA_KFUNCTION(_name) \ 2289 static int (_name)(lua_State *L, int status, lua_KContext ctx); \ 2290 static int (_name ## _52)(lua_State *L) { \ 2292 int status = lua_getctx(L, &ctx); \ 2293 return (_name)(L, status, ctx); \ 2295 static int (_name)(lua_State *L, int status, lua_KContext ctx) 2297 #define lua_pcallk(L, na, nr, err, ctx, cont) \ 2298 lua_pcallk((L), (na), (nr), (err), (ctx), cont ## _52) 2300 #define lua_callk(L, na, nr, ctx, cont) \ 2301 lua_callk((L), (na), (nr), (ctx), cont ## _52) 2303 #define lua_yieldk(L, nr, ctx, cont) \ 2304 lua_yieldk((L), (nr), (ctx), cont ## _52) 2308 # define lua_call(L, na, nr) \ 2309 (lua_callk)((L), (na), (nr), 0, NULL) 2314 # define lua_pcall(L, na, nr, err) \ 2315 (lua_pcallk)((L), (na), (nr), (err), 0, NULL) 2320 # define lua_yield(L, nr) \ 2321 (lua_yieldk)((L), (nr), 0, NULL) 2327 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 504 2329 # error "unsupported Lua version (i.e. not Lua 5.1, 5.2, or 5.3)" 2335 #ifndef LUA_KFUNCTION 2336 #define LUA_KFUNCTION(_name) \ 2337 static int (_name)(lua_State *L, int status, lua_KContext ctx) 2340 #if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE == 1 2349 #ifndef KEPLER_PROJECT_COMPAT53_C_ 2350 #define KEPLER_PROJECT_COMPAT53_C_ 2353 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501 2355 #ifndef COMPAT53_FOPEN_NO_LOCK 2356 # if defined(_MSC_VER) 2357 # define COMPAT53_FOPEN_NO_LOCK 1 2359 # define COMPAT53_FOPEN_NO_LOCK 0 2363 #if defined(_MSC_VER) && COMPAT53_FOPEN_NO_LOCK 2367 #ifndef COMPAT53_HAVE_STRERROR_R 2368 # if defined(__GLIBC__) || defined(_POSIX_VERSION) || defined(__APPLE__) || \ 2369 (!defined (__MINGW32__) && defined(__GNUC__) && (__GNUC__ < 6)) 2370 # define COMPAT53_HAVE_STRERROR_R 1 2372 # define COMPAT53_HAVE_STRERROR_R 0 2376 #ifndef COMPAT53_HAVE_STRERROR_S 2377 # if defined(_MSC_VER) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ 2378 (defined(__STDC_LIB_EXT1__) && __STDC_LIB_EXT1__) 2379 # define COMPAT53_HAVE_STRERROR_S 1 2381 # define COMPAT53_HAVE_STRERROR_S 0 2385 #ifndef COMPAT53_LUA_FILE_BUFFER_SIZE 2386 # define COMPAT53_LUA_FILE_BUFFER_SIZE 4096 2389 static char* compat53_strerror(int en, char* buff, size_t sz) {
2390 #if COMPAT53_HAVE_STRERROR_R 2395 if (strerror_r(en, buff, sz)) {
2399 if (buff[0] ==
'\0') {
2403 return strerror(en);
2407 #elif COMPAT53_HAVE_STRERROR_S 2410 strerror_s(buff, sz, en);
2419 return strerror(en);
2424 if (i < 0 && i > LUA_REGISTRYINDEX)
2425 i += lua_gettop(L) + 1;
2429 static void compat53_call_lua(lua_State *L,
char const code[],
size_t len,
2430 int nargs,
int nret) {
2431 lua_rawgetp(L, LUA_REGISTRYINDEX, (
void*)code);
2432 if (lua_type(L, -1) != LUA_TFUNCTION) {
2434 if (luaL_loadbuffer(L, code, len,
"=none"))
2436 lua_pushvalue(L, -1);
2437 lua_rawsetp(L, LUA_REGISTRYINDEX, (
void*)code);
2439 lua_insert(L, -nargs - 1);
2440 lua_call(L, nargs, nret);
2443 static const char compat53_arith_code[] =
2444 "local op,a,b=...\n" 2445 "if op==0 then return a+b\n" 2446 "elseif op==1 then return a-b\n" 2447 "elseif op==2 then return a*b\n" 2448 "elseif op==3 then return a/b\n" 2449 "elseif op==4 then return a%b\n" 2450 "elseif op==5 then return a^b\n" 2451 "elseif op==6 then return -a\n" 2455 if (op < LUA_OPADD || op > LUA_OPUNM)
2456 luaL_error(L,
"invalid 'op' argument for lua_arith");
2457 luaL_checkstack(L, 5,
"not enough stack slots");
2458 if (op == LUA_OPUNM)
2459 lua_pushvalue(L, -1);
2460 lua_pushnumber(L, op);
2462 compat53_call_lua(L, compat53_arith_code,
2463 sizeof(compat53_arith_code) - 1, 3, 1);
2466 static const char compat53_compare_code[] =
2470 COMPAT53_API int lua_compare(lua_State *L,
int idx1,
int idx2,
int op) {
2474 return lua_equal(L, idx1, idx2);
2476 return lua_lessthan(L, idx1, idx2);
2478 luaL_checkstack(L, 5,
"not enough stack slots");
2479 idx1 = lua_absindex(L, idx1);
2480 idx2 = lua_absindex(L, idx2);
2481 lua_pushvalue(L, idx1);
2482 lua_pushvalue(L, idx2);
2483 compat53_call_lua(L, compat53_compare_code,
2484 sizeof(compat53_compare_code) - 1, 2, 1);
2485 result = lua_toboolean(L, -1);
2489 luaL_error(L,
"invalid 'op' argument for lua_compare");
2494 COMPAT53_API void lua_copy(lua_State *L,
int from,
int to) {
2495 int abs_to = lua_absindex(L, to);
2496 luaL_checkstack(L, 1,
"not enough stack slots");
2497 lua_pushvalue(L, from);
2498 lua_replace(L, abs_to);
2502 switch (lua_type(L, i)) {
2504 lua_pushnumber(L, (lua_Number)lua_objlen(L, i));
2507 if (!luaL_callmeta(L, i,
"__len"))
2508 lua_pushnumber(L, (lua_Number)lua_objlen(L, i));
2511 if (luaL_callmeta(L, i,
"__len"))
2515 luaL_error(L,
"attempt to get length of a %s value",
2516 lua_typename(L, lua_type(L, i)));
2520 COMPAT53_API int lua_rawgetp(lua_State *L,
int i,
const void *p) {
2521 int abs_i = lua_absindex(L, i);
2522 lua_pushlightuserdata(L, (
void*)p);
2523 lua_rawget(L, abs_i);
2524 return lua_type(L, -1);
2527 COMPAT53_API void lua_rawsetp(lua_State *L,
int i,
const void *p) {
2528 int abs_i = lua_absindex(L, i);
2529 luaL_checkstack(L, 1,
"not enough stack slots");
2530 lua_pushlightuserdata(L, (
void*)p);
2532 lua_rawset(L, abs_i);
2535 COMPAT53_API lua_Number lua_tonumberx(lua_State *L,
int i,
int *isnum) {
2536 lua_Number n = lua_tonumber(L, i);
2537 if (isnum != NULL) {
2538 *isnum = (n != 0 || lua_isnumber(L, i));
2547 COMPAT53_API void luaL_checkstack(lua_State *L,
int sp,
const char *msg) {
2548 if (!lua_checkstack(L, sp + LUA_MINSTACK)) {
2550 luaL_error(L,
"stack overflow (%s)", msg);
2552 lua_pushliteral(L,
"stack overflow");
2558 COMPAT53_API int luaL_getsubtable(lua_State *L,
int i,
const char *name) {
2559 int abs_i = lua_absindex(L, i);
2560 luaL_checkstack(L, 3,
"not enough stack slots");
2561 lua_pushstring(L, name);
2562 lua_gettable(L, abs_i);
2563 if (lua_istable(L, -1))
2567 lua_pushstring(L, name);
2568 lua_pushvalue(L, -2);
2569 lua_settable(L, abs_i);
2573 COMPAT53_API lua_Integer luaL_len(lua_State *L,
int i) {
2574 lua_Integer res = 0;
2576 luaL_checkstack(L, 1,
"not enough stack slots");
2578 res = lua_tointegerx(L, -1, &isnum);
2581 luaL_error(L,
"object length is not an integer");
2585 COMPAT53_API void luaL_setfuncs(lua_State *L,
const luaL_Reg *l,
int nup) {
2586 luaL_checkstack(L, nup + 1,
"too many upvalues");
2587 for (; l->name != NULL; l++) {
2589 lua_pushstring(L, l->name);
2590 for (i = 0; i < nup; i++)
2591 lua_pushvalue(L, -(nup + 1));
2592 lua_pushcclosure(L, l->func, nup);
2593 lua_settable(L, -(nup + 3));
2598 COMPAT53_API void luaL_setmetatable(lua_State *L,
const char *tname) {
2599 luaL_checkstack(L, 1,
"not enough stack slots");
2600 luaL_getmetatable(L, tname);
2601 lua_setmetatable(L, -2);
2604 COMPAT53_API void *luaL_testudata(lua_State *L,
int i,
const char *tname) {
2605 void *p = lua_touserdata(L, i);
2606 luaL_checkstack(L, 2,
"not enough stack slots");
2607 if (p == NULL || !lua_getmetatable(L, i))
2611 luaL_getmetatable(L, tname);
2612 res = lua_rawequal(L, -1, -2);
2620 static int compat53_countlevels(lua_State *L) {
2624 while (lua_getstack(L, le, &ar)) { li = le; le *= 2; }
2627 int m = (li + le) / 2;
2628 if (lua_getstack(L, m, &ar)) li = m + 1;
2634 static int compat53_findfield(lua_State *L,
int objidx,
int level) {
2635 if (level == 0 || !lua_istable(L, -1))
2638 while (lua_next(L, -2)) {
2639 if (lua_type(L, -2) == LUA_TSTRING) {
2640 if (lua_rawequal(L, objidx, -1)) {
2644 else if (compat53_findfield(L, objidx, level - 1)) {
2646 lua_pushliteral(L,
".");
2657 static int compat53_pushglobalfuncname(lua_State *L, lua_Debug *ar) {
2658 int top = lua_gettop(L);
2659 lua_getinfo(L,
"f", ar);
2660 lua_pushvalue(L, LUA_GLOBALSINDEX);
2661 if (compat53_findfield(L, top + 1, 2)) {
2662 lua_copy(L, -1, top + 1);
2672 static void compat53_pushfuncname(lua_State *L, lua_Debug *ar) {
2673 if (*ar->namewhat !=
'\0')
2674 lua_pushfstring(L,
"function " LUA_QS, ar->name);
2675 else if (*ar->what ==
'm')
2676 lua_pushliteral(L,
"main chunk");
2677 else if (*ar->what ==
'C') {
2678 if (compat53_pushglobalfuncname(L, ar)) {
2679 lua_pushfstring(L,
"function " LUA_QS, lua_tostring(L, -1));
2683 lua_pushliteral(L,
"?");
2686 lua_pushfstring(L,
"function <%s:%d>", ar->short_src, ar->linedefined);
2689 #define COMPAT53_LEVELS1 12 2690 #define COMPAT53_LEVELS2 10 2692 COMPAT53_API void luaL_traceback(lua_State *L, lua_State *L1,
2693 const char *msg,
int level) {
2695 int top = lua_gettop(L);
2696 int numlevels = compat53_countlevels(L1);
2697 int mark = (numlevels > COMPAT53_LEVELS1 + COMPAT53_LEVELS2) ? COMPAT53_LEVELS1 : 0;
2698 if (msg) lua_pushfstring(L,
"%s\n", msg);
2699 lua_pushliteral(L,
"stack traceback:");
2700 while (lua_getstack(L1, level++, &ar)) {
2701 if (level == mark) {
2702 lua_pushliteral(L,
"\n\t...");
2703 level = numlevels - COMPAT53_LEVELS2;
2706 lua_getinfo(L1,
"Slnt", &ar);
2707 lua_pushfstring(L,
"\n\t%s:", ar.short_src);
2708 if (ar.currentline > 0)
2709 lua_pushfstring(L,
"%d:", ar.currentline);
2710 lua_pushliteral(L,
" in ");
2711 compat53_pushfuncname(L, &ar);
2712 lua_concat(L, lua_gettop(L) - top);
2715 lua_concat(L, lua_gettop(L) - top);
2718 COMPAT53_API int luaL_fileresult(lua_State *L,
int stat,
const char *fname) {
2719 const char *serr = NULL;
2721 char buf[512] = { 0 };
2723 lua_pushboolean(L, 1);
2728 serr = compat53_strerror(en, buf,
sizeof(buf));
2730 lua_pushfstring(L,
"%s: %s", fname, serr);
2732 lua_pushstring(L, serr);
2733 lua_pushnumber(L, (lua_Number)en);
2738 static int compat53_checkmode(lua_State *L,
const char *mode,
const char *modename,
int err) {
2739 if (mode && strchr(mode, modename[0]) == NULL) {
2740 lua_pushfstring(L,
"attempt to load a %s chunk (mode is '%s')", modename, mode);
2749 int has_peeked_data;
2750 const char *peeked_data;
2751 size_t peeked_data_size;
2752 } compat53_reader_data;
2754 static const char *compat53_reader(lua_State *L,
void *ud,
size_t *size) {
2755 compat53_reader_data *data = (compat53_reader_data *)ud;
2756 if (data->has_peeked_data) {
2757 data->has_peeked_data = 0;
2758 *size = data->peeked_data_size;
2759 return data->peeked_data;
2762 return data->reader(L, data->ud, size);
2765 COMPAT53_API int lua_load(lua_State *L, lua_Reader reader,
void *data,
const char *source,
const char *mode) {
2766 int status = LUA_OK;
2767 compat53_reader_data compat53_data = { reader, data, 1, 0, 0 };
2768 compat53_data.peeked_data = reader(L, data, &(compat53_data.peeked_data_size));
2769 if (compat53_data.peeked_data && compat53_data.peeked_data_size &&
2770 compat53_data.peeked_data[0] == LUA_SIGNATURE[0])
2771 status = compat53_checkmode(L, mode,
"binary", LUA_ERRSYNTAX);
2773 status = compat53_checkmode(L, mode,
"text", LUA_ERRSYNTAX);
2774 if (status != LUA_OK)
2778 return lua_load(L, compat53_reader, &compat53_data, source);
2779 #define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53) 2785 char buff[COMPAT53_LUA_FILE_BUFFER_SIZE];
2788 static const char *compat53_getF(lua_State *L,
void *ud,
size_t *size) {
2789 compat53_LoadF *lf = (compat53_LoadF *)ud;
2799 if (feof(lf->f))
return NULL;
2800 *size = fread(lf->buff, 1,
sizeof(lf->buff), lf->f);
2805 static int compat53_errfile(lua_State *L,
const char *what,
int fnameindex) {
2806 char buf[512] = { 0 };
2807 const char *serr = compat53_strerror(errno, buf,
sizeof(buf));
2808 const char *filename = lua_tostring(L, fnameindex) + 1;
2809 lua_pushfstring(L,
"cannot %s %s: %s", what, filename, serr);
2810 lua_remove(L, fnameindex);
2814 static int compat53_skipBOM(compat53_LoadF *lf) {
2815 const char *p =
"\xEF\xBB\xBF";
2820 if (c == EOF || c != *(
const unsigned char *)p++)
return c;
2821 lf->buff[lf->n++] = (char)c;
2822 }
while (*p !=
'\0');
2834 static int compat53_skipcomment(compat53_LoadF *lf,
int *cp) {
2835 int c = *cp = compat53_skipBOM(lf);
2839 }
while (c != EOF && c !=
'\n');
2846 COMPAT53_API int luaL_loadfilex(lua_State *L,
const char *filename,
const char *mode) {
2848 int status, readstatus;
2850 int fnameindex = lua_gettop(L) + 1;
2851 if (filename == NULL) {
2852 lua_pushliteral(L,
"=stdin");
2856 lua_pushfstring(L,
"@%s", filename);
2857 #if defined(_MSC_VER) 2868 #if COMPAT53_FOPEN_NO_LOCK 2869 lf.f = _fsopen(filename,
"r", _SH_DENYNO);
2871 return compat53_errfile(L,
"open", fnameindex);
2873 if (fopen_s(&lf.f, filename,
"r") != 0)
2874 return compat53_errfile(L,
"open", fnameindex);
2877 lf.f = fopen(filename,
"r");
2878 if (lf.f == NULL)
return compat53_errfile(L,
"open", fnameindex);
2881 if (compat53_skipcomment(&lf, &c))
2882 lf.buff[lf.n++] =
'\n';
2883 if (c == LUA_SIGNATURE[0] && filename) {
2884 #if defined(_MSC_VER) 2885 if (freopen_s(&lf.f, filename,
"rb", lf.f) != 0)
2886 return compat53_errfile(L,
"reopen", fnameindex);
2888 lf.f = freopen(filename,
"rb", lf.f);
2889 if (lf.f == NULL)
return compat53_errfile(L,
"reopen", fnameindex);
2891 compat53_skipcomment(&lf, &c);
2894 lf.buff[lf.n++] = (char)c;
2895 status = lua_load(L, &compat53_getF, &lf, lua_tostring(L, -1), mode);
2896 readstatus = ferror(lf.f);
2897 if (filename) fclose(lf.f);
2899 lua_settop(L, fnameindex);
2900 return compat53_errfile(L,
"read", fnameindex);
2902 lua_remove(L, fnameindex);
2906 COMPAT53_API int luaL_loadbufferx(lua_State *L,
const char *buff,
size_t sz,
const char *name,
const char *mode) {
2907 int status = LUA_OK;
2908 if (sz > 0 && buff[0] == LUA_SIGNATURE[0]) {
2909 status = compat53_checkmode(L, mode,
"binary", LUA_ERRSYNTAX);
2912 status = compat53_checkmode(L, mode,
"text", LUA_ERRSYNTAX);
2914 if (status != LUA_OK)
2916 return luaL_loadbuffer(L, buff, sz, name);
2919 #if !defined(l_inspectstat) && \ 2920 (defined(unix) || defined(__unix) || defined(__unix__) || \ 2921 defined(__TOS_AIX__) || defined(_SYSTYPE_BSD) || \ 2922 (defined(__APPLE__) && defined(__MACH__))) 2924 # include <unistd.h> 2927 # if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L 2928 # include <sys/wait.h> 2929 # define l_inspectstat(stat,what) \ 2930 if (WIFEXITED(stat)) { stat = WEXITSTATUS(stat); } \ 2931 else if (WIFSIGNALED(stat)) { stat = WTERMSIG(stat); what = "signal"; } 2936 #if !defined(l_inspectstat) 2937 # define l_inspectstat(stat,what) ((void)0) 2940 COMPAT53_API int luaL_execresult(lua_State *L,
int stat) {
2941 const char *what =
"exit";
2943 return luaL_fileresult(L, 0, NULL);
2945 l_inspectstat(stat, what);
2946 if (*what ==
'e' && stat == 0)
2947 lua_pushboolean(L, 1);
2950 lua_pushstring(L, what);
2951 lua_pushinteger(L, stat);
2956 COMPAT53_API void luaL_buffinit(lua_State *L, luaL_Buffer_53 *B) {
2962 B->ptr = B->b.buffer;
2963 B->capacity = LUAL_BUFFERSIZE;
2968 COMPAT53_API char *luaL_prepbuffsize(luaL_Buffer_53 *B,
size_t s) {
2969 if (B->capacity - B->nelems < s) {
2970 char* newptr = NULL;
2971 size_t newcap = B->capacity * 2;
2972 if (newcap - B->nelems < s)
2973 newcap = B->nelems + s;
2974 if (newcap < B->capacity)
2975 luaL_error(B->L2,
"buffer too large");
2976 newptr = (
char*)lua_newuserdata(B->L2, newcap);
2977 memcpy(newptr, B->ptr, B->nelems);
2978 if (B->ptr != B->b.buffer)
2979 lua_replace(B->L2, -2);
2981 B->capacity = newcap;
2983 return B->ptr + B->nelems;
2986 COMPAT53_API void luaL_addlstring(luaL_Buffer_53 *B,
const char *s,
size_t l) {
2987 memcpy(luaL_prepbuffsize(B, l), s, l);
2993 const char *s = lua_tolstring(B->L2, -1, &len);
2995 luaL_error(B->L2,
"cannot convert value to string");
2996 if (B->ptr != B->b.buffer)
2997 lua_insert(B->L2, -2);
2998 luaL_addlstring(B, s, len);
2999 lua_remove(B->L2, B->ptr != B->b.buffer ? -2 : -1);
3002 void luaL_pushresult(luaL_Buffer_53 *B) {
3003 lua_pushlstring(B->L2, B->ptr, B->nelems);
3004 if (B->ptr != B->b.buffer)
3005 lua_replace(B->L2, -2);
3011 #if defined( LUA_VERSION_NUM ) && LUA_VERSION_NUM <= 502 3013 COMPAT53_API int lua_geti(lua_State *L,
int index, lua_Integer i) {
3014 index = lua_absindex(L, index);
3015 lua_pushinteger(L, i);
3016 lua_gettable(L, index);
3017 return lua_type(L, -1);
3020 COMPAT53_API int lua_isinteger(lua_State *L,
int index) {
3021 if (lua_type(L, index) == LUA_TNUMBER) {
3022 lua_Number n = lua_tonumber(L, index);
3023 lua_Integer i = lua_tointeger(L, index);
3030 COMPAT53_API lua_Integer lua_tointegerx(lua_State *L,
int i,
int *isnum) {
3032 lua_Number n = lua_tonumberx(L, i, &ok);
3034 if (n == (lua_Integer)n) {
3037 return (lua_Integer)n;
3045 static void compat53_reverse(lua_State *L,
int a,
int b) {
3046 for (; a < b; ++a, --b) {
3047 lua_pushvalue(L, a);
3048 lua_pushvalue(L, b);
3054 COMPAT53_API void lua_rotate(lua_State *L,
int idx,
int n) {
3056 idx = lua_absindex(L, idx);
3057 n_elems = lua_gettop(L) - idx + 1;
3060 if (n > 0 && n < n_elems) {
3061 luaL_checkstack(L, 2,
"not enough stack slots available");
3063 compat53_reverse(L, idx, idx + n - 1);
3064 compat53_reverse(L, idx + n, idx + n_elems - 1);
3065 compat53_reverse(L, idx, idx + n_elems - 1);
3069 COMPAT53_API void lua_seti(lua_State *L,
int index, lua_Integer i) {
3070 luaL_checkstack(L, 1,
"not enough stack slots available");
3071 index = lua_absindex(L, index);
3072 lua_pushinteger(L, i);
3074 lua_settable(L, index);
3077 #if !defined(lua_str2number) 3078 # define lua_str2number(s, p) strtod((s), (p)) 3081 COMPAT53_API size_t lua_stringtonumber(lua_State *L,
const char *s) {
3083 lua_Number n = lua_str2number(s, &endptr);
3085 while (*endptr !=
'\0' && isspace((
unsigned char)*endptr))
3087 if (*endptr ==
'\0') {
3088 lua_pushnumber(L, n);
3089 return endptr - s + 1;
3095 COMPAT53_API const char *luaL_tolstring(lua_State *L,
int idx,
size_t *len) {
3096 if (!luaL_callmeta(L, idx,
"__tostring")) {
3097 int t = lua_type(L, idx), tt = 0;
3098 char const* name = NULL;
3101 lua_pushliteral(L,
"nil");
3105 lua_pushvalue(L, idx);
3108 if (lua_toboolean(L, idx))
3109 lua_pushliteral(L,
"true");
3111 lua_pushliteral(L,
"false");
3114 tt = luaL_getmetafield(L, idx,
"__name");
3115 name = (tt == LUA_TSTRING) ? lua_tostring(L, -1) : lua_typename(L, t);
3116 lua_pushfstring(L,
"%s: %p", name, lua_topointer(L, idx));
3123 if (!lua_isstring(L, -1))
3124 luaL_error(L,
"'__tostring' must return a string");
3126 return lua_tolstring(L, -1, len);
3129 COMPAT53_API void luaL_requiref(lua_State *L,
const char *modname,
3130 lua_CFunction openf,
int glb) {
3131 luaL_checkstack(L, 3,
"not enough stack slots available");
3132 luaL_getsubtable(L, LUA_REGISTRYINDEX,
"_LOADED");
3133 if (lua_getfield(L, -1, modname) == LUA_TNIL) {
3135 lua_pushcfunction(L, openf);
3136 lua_pushstring(L, modname);
3138 lua_pushvalue(L, -1);
3139 lua_setfield(L, -3, modname);
3142 lua_pushvalue(L, -1);
3143 lua_setglobal(L, modname);
3186 #endif // SOL_NO_COMPAT 3196 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 3201 template <
typename T>
3203 template <
typename T>
3213 template <std::
size_t I>
3215 template <
typename T>
3226 template <
typename T>
3230 template <std::
size_t I>
3238 template <
typename T>
3242 template <std::
size_t I>
3248 template <
typename T>
3250 template <std::
size_t I>
3258 #if defined(SOL_USE_BOOST) && SOL_USE_BOOST 3259 #include <boost/optional.hpp> 3263 #include <initializer_list> 3265 #if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS 3267 #endif // Exceptions 3269 #define TR2_OPTIONAL_REQUIRES(...) typename ::std::enable_if<__VA_ARGS__::value, bool>::type = false 3271 #if defined __GNUC__ // NOTE: GNUC is also defined for Clang 3273 #define TR2_OPTIONAL_GCC_5_0_AND_HIGHER___ 3274 #define TR2_OPTIONAL_GCC_4_8_AND_HIGHER___ 3275 #elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 8) 3276 #define TR2_OPTIONAL_GCC_4_8_AND_HIGHER___ 3277 #elif (__GNUC__ > 4) 3278 #define TR2_OPTIONAL_GCC_4_8_AND_HIGHER___ 3281 #if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 7) 3282 #define TR2_OPTIONAL_GCC_4_7_AND_HIGHER___ 3283 #elif (__GNUC__ > 4) 3284 #define TR2_OPTIONAL_GCC_4_7_AND_HIGHER___ 3287 #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) && (__GNUC_PATCHLEVEL__ >= 1) 3288 #define TR2_OPTIONAL_GCC_4_8_1_AND_HIGHER___ 3289 #elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9) 3290 #define TR2_OPTIONAL_GCC_4_8_1_AND_HIGHER___ 3291 #elif (__GNUC__ > 4) 3292 #define TR2_OPTIONAL_GCC_4_8_1_AND_HIGHER___ 3296 #if defined __clang_major__ 3297 #if (__clang_major__ == 3 && __clang_minor__ >= 5) 3298 #define TR2_OPTIONAL_CLANG_3_5_AND_HIGHTER_ 3299 #elif (__clang_major__ > 3) 3300 #define TR2_OPTIONAL_CLANG_3_5_AND_HIGHTER_ 3302 #if defined TR2_OPTIONAL_CLANG_3_5_AND_HIGHTER_ 3303 #define TR2_OPTIONAL_CLANG_3_4_2_AND_HIGHER_ 3304 #elif (__clang_major__ == 3 && __clang_minor__ == 4 && __clang_patchlevel__ >= 2) 3305 #define TR2_OPTIONAL_CLANG_3_4_2_AND_HIGHER_ 3309 #if defined _MSC_VER 3310 #if (_MSC_VER >= 1900) 3311 #define TR2_OPTIONAL_MSVC_2015_AND_HIGHER___ 3315 #if defined __clang__ 3316 #if (__clang_major__ > 2) || (__clang_major__ == 2) && (__clang_minor__ >= 9) 3317 #define OPTIONAL_HAS_THIS_RVALUE_REFS 1 3319 #define OPTIONAL_HAS_THIS_RVALUE_REFS 0 3321 #elif defined TR2_OPTIONAL_GCC_4_8_1_AND_HIGHER___ 3322 #define OPTIONAL_HAS_THIS_RVALUE_REFS 1 3323 #elif defined TR2_OPTIONAL_MSVC_2015_AND_HIGHER___ 3324 #define OPTIONAL_HAS_THIS_RVALUE_REFS 1 3326 #define OPTIONAL_HAS_THIS_RVALUE_REFS 0 3329 #if defined TR2_OPTIONAL_GCC_4_8_1_AND_HIGHER___ 3330 #define OPTIONAL_HAS_CONSTEXPR_INIT_LIST 1 3331 #define OPTIONAL_CONSTEXPR_INIT_LIST constexpr 3333 #define OPTIONAL_HAS_CONSTEXPR_INIT_LIST 0 3334 #define OPTIONAL_CONSTEXPR_INIT_LIST 3337 #if defined(TR2_OPTIONAL_MSVC_2015_AND_HIGHER___) || (defined TR2_OPTIONAL_CLANG_3_5_AND_HIGHTER_ && (defined __cplusplus) && (__cplusplus != 201103L)) 3338 #define OPTIONAL_HAS_MOVE_ACCESSORS 1 3340 #define OPTIONAL_HAS_MOVE_ACCESSORS 0 3343 #// In C++11 constexpr implies const, so we need to make non-const members also non-constexpr 3344 #if defined(TR2_OPTIONAL_MSVC_2015_AND_HIGHER___) || ((defined __cplusplus) && (__cplusplus == 201103L)) 3345 #define OPTIONAL_MUTABLE_CONSTEXPR 3347 #define OPTIONAL_MUTABLE_CONSTEXPR constexpr 3350 #if defined TR2_OPTIONAL_MSVC_2015_AND_HIGHER___ 3351 #pragma warning(push) 3352 #pragma warning(disable : 4814) 3358 #if defined TR2_OPTIONAL_GCC_4_8_AND_HIGHER___ 3360 #elif defined TR2_OPTIONAL_CLANG_3_4_2_AND_HIGHER_ 3362 #elif defined TR2_OPTIONAL_MSVC_2015_AND_HIGHER___ 3364 #elif defined TR2_OPTIONAL_DISABLE_EMULATION_OF_TYPE_TRAITS 3367 template <
typename T>
3372 #if (defined TR2_OPTIONAL_GCC_4_7_AND_HIGHER___) 3374 #elif defined TR2_OPTIONAL_CLANG_3_4_2_AND_HIGHER_ 3376 #elif defined TR2_OPTIONAL_MSVC_2015_AND_HIGHER___ 3378 #elif defined TR2_OPTIONAL_DISABLE_EMULATION_OF_TYPE_TRAITS 3385 static constexprbool value = ::std::is_nothrow_constructible<T, T&&>::value;
3388 template <
class T,
class U>
3390 template <
class X,
class Y>
3395 template <
class X,
class Y,
size_t S = sizeof((::std::declval<X>() = ::std::declval<Y>(), true))>
3401 static constexprbool value = has_assign<T, U>(
true);
3406 template <
class X,
bool has_any_move_assign>
3408 static constexprbool value =
false;
3413 static constexprbool value = noexcept(::std::declval<X&>() = ::std::declval<X&&>());
3433 return static_cast<T&&
>(t);
3438 static_assert(!::std::is_lvalue_reference<T>::value,
"!!");
3439 return static_cast<T&&
>(t);
3448 #define TR2_OPTIONAL_ASSERTED_EXPRESSION(CHECK, EXPR) (EXPR) 3450 #define TR2_OPTIONAL_ASSERTED_EXPRESSION(CHECK, EXPR) ((CHECK) ? (EXPR) : ([] { assert(!#CHECK); }(), (EXPR))) 3456 template <
typename T>
3463 template <
class X,
size_t S = sizeof(::std::declval<X&>().operator&())>
3468 static constexpr
bool value = has_overload<T>(
true);
3471 template <
typename T, TR2_OPTIONAL_REQUIRES(!has_overloaded_addressof<T>)>
3476 template <
typename T, TR2_OPTIONAL_REQUIRES(has_overloaded_addressof<T>)>
3478 return ::std::addressof(ref);
3504 : ::std::logic_error{what_arg} {
3507 : ::std::logic_error{what_arg} {
3513 char storage_[
sizeof(T)];
3517 : storage_(), init_(false){};
3520 : storage_(), init_(true) {
3521 new (&storage()) T(v);
3525 : storage_(), init_(true) {
3529 template <
class... Args>
3531 : init_(true), storage_() {
3532 new (&storage()) T(constexpr_forward<Args>(args)...);
3535 template <
class U,
class... Args,
TR2_OPTIONAL_REQUIRES(::std::is_constructible<T, ::std::initializer_list<U>>)>
3537 : init_(true), storage_() {
3538 new (&storage()) T(il, constexpr_forward<Args>(args)...);
3540 #if defined __GNUC__ 3541 #pragma GCC diagnostic push 3542 #pragma GCC diagnostic ignored "-Wstrict-aliasing" 3545 return *
reinterpret_cast<T*
>(&storage_[0]);
3549 return *
reinterpret_cast<T const*
>(&storage_[0]);
3551 #if defined __GNUC__ 3552 #pragma GCC diagnostic pop 3562 #if defined __GNUC__ && !defined TR2_OPTIONAL_GCC_5_0_AND_HIGHER___ 3564 template <
typename T>
3569 char storage_[
sizeof(T)];
3572 : storage_(), init_(false) {
3576 : storage_(), init_(true) {
3577 new (&storage()) T(v);
3581 : storage_(), init_(true) {
3585 template <
class... Args>
3587 : init_(true), storage_() {
3588 new (&storage()) T(constexpr_forward<Args>(args)...);
3591 template <
class U,
class... Args,
TR2_OPTIONAL_REQUIRES(::std::is_constructible<T, ::std::initializer_list<U>>)>
3593 : init_(true), storage_() {
3594 new (&storage()) T(il, constexpr_forward<Args>(args)...);
3597 #if defined __GNUC__ 3598 #pragma GCC diagnostic push 3599 #pragma GCC diagnostic ignored "-Wstrict-aliasing" 3602 return (*reinterpret_cast<T*>(&storage_[0]));
3606 return (*reinterpret_cast<T const*>(&storage_[0]));
3608 #if defined __GNUC__ 3609 #pragma GCC diagnostic pop 3618 ::std::is_trivially_destructible<T>::value,
3637 #if OPTIONAL_HAS_THIS_RVALUE_REFS == 1 3638 constexpr
const T& contained_val()
const& {
3641 #if OPTIONAL_HAS_MOVE_ACCESSORS == 1 3649 T& contained_val() & {
3652 T&& contained_val() && {
3671 template <
class... Args>
3672 void initialize(Args&&... args) noexcept(noexcept(T(::std::forward<Args>(args)...))) {
3674 ::new (static_cast<void*>(dataptr())) T(::std::forward<Args>(args)...);
3678 template <
class U,
class... Args>
3679 void initialize(::std::initializer_list<U> il, Args&&... args) noexcept(noexcept(T(il, ::std::forward<Args>(args)...))) {
3681 ::new (static_cast<void*>(dataptr())) T(il, ::std::forward<Args>(args)...);
3697 ::new (static_cast<void*>(dataptr())) T(*rhs);
3705 ::new (static_cast<void*>(dataptr())) T(*rhs);
3712 if (rhs.initialized()) {
3713 ::new (static_cast<void*>(dataptr())) T(::std::move(*rhs));
3726 template <
class... Args>
3731 template <
class U,
class... Args,
TR2_OPTIONAL_REQUIRES(::std::is_constructible<T, ::std::initializer_list<U>>)>
3746 if (initialized() ==
true && rhs.
initialized() ==
false)
3748 else if (initialized() ==
false && rhs.
initialized() ==
true)
3750 else if (initialized() ==
true && rhs.
initialized() ==
true)
3751 contained_val() = *rhs;
3756 if (initialized() ==
true && rhs.initialized() ==
false)
3758 else if (initialized() ==
false && rhs.initialized() ==
true)
3759 initialize(::std::move(*rhs));
3760 else if (initialized() ==
true && rhs.initialized() ==
true)
3761 contained_val() = ::std::move(*rhs);
3767 -> typename ::std::enable_if<
3770 if (initialized()) {
3771 contained_val() = ::std::forward<U>(v);
3774 initialize(::std::forward<U>(v));
3779 template <
class... Args>
3782 initialize(::std::forward<Args>(args)...);
3785 template <
class U,
class... Args>
3786 void emplace(::std::initializer_list<U> il, Args&&... args) {
3788 initialize<U, Args...>(il, ::std::forward<Args>(args)...);
3792 void swap(
optional<T>& rhs) noexcept(::std::is_nothrow_move_constructible<T>::value&& noexcept(
swap(::std::declval<T&>(), ::std::declval<T&>()))) {
3793 if (initialized() ==
true && rhs.initialized() ==
false) {
3794 rhs.initialize(::std::move(**
this));
3797 else if (initialized() ==
false && rhs.initialized() ==
true) {
3798 initialize(::std::move(*rhs));
3801 else if (initialized() ==
true && rhs.initialized() ==
true) {
3809 explicit constexpr
operator bool() const noexcept {
3810 return initialized();
3817 #if OPTIONAL_HAS_MOVE_ACCESSORS == 1 3820 assert(initialized());
3829 assert(initialized());
3830 return contained_val();
3834 assert(initialized());
3838 constexpr T
const& value()
const& {
3839 return initialized() ? contained_val()
3840 #ifdef SOL_NO_EXCEPTIONS 3843 : *
static_cast<T*
>(
nullptr);
3850 return initialized() ? contained_val()
3851 #ifdef SOL_NO_EXCEPTIONS 3852 : *
static_cast<T*
>(
nullptr);
3859 return initialized() ? contained_val()
3860 #ifdef SOL_NO_EXCEPTIONS 3863 : std::move(*static_cast<T*>(
nullptr));
3872 assert(initialized());
3881 assert(initialized());
3882 return contained_val();
3886 return initialized() ? contained_val()
3887 #ifdef SOL_NO_EXCEPTIONS 3890 : *
static_cast<T*
>(
nullptr);
3897 return initialized() ? contained_val()
3898 #ifdef SOL_NO_EXCEPTIONS 3901 : (std::abort(), *
static_cast<T*
>(
nullptr));
3909 #if OPTIONAL_HAS_THIS_RVALUE_REFS == 1 3912 constexpr T value_or(V&& v)
const& {
3913 return *
this ? **
this : detail_::convert<T>(constexpr_forward<V>(v));
3916 #if OPTIONAL_HAS_MOVE_ACCESSORS == 1 3926 T value_or(V&& v) && {
3936 return *
this ? **
this : detail_::convert<T>(constexpr_forward<V>(v));
3944 static_assert(!::std::is_same<T, nullopt_t>::value,
"bad T");
3945 static_assert(!::std::is_same<T, in_place_t>::value,
"bad T");
3992 template <
typename U>
3994 -> typename ::std::enable_if<
3995 ::std::is_same<typename ::std::decay<U>::
type,
optional<T&>>::value,
4001 template <
typename U>
4002 auto operator=(U&& rhs) noexcept
4003 -> typename ::std::enable_if<
4004 !::std::is_same<typename ::std::decay<U>::type,
optional<T&>>::value,
4011 void emplace(T&&) =
delete;
4027 #ifdef SOL_NO_EXCEPTIONS 4032 #endif // Exceptions 4035 explicit constexpr
operator bool() const noexcept {
4036 return ref !=
nullptr;
4039 template <
typename V>
4041 return *
this ? **
this : detail_::convert<T&>(constexpr_forward<V>(v));
4047 static_assert(
sizeof(T) == 0,
"optional rvalue references disallowed");
4053 return bool(x) != bool(y) ?
false : bool(x) ==
false ?
true : *x == *y;
4062 constexpr
bool operator<(const optional<T>& x,
const optional<T>& y) {
4063 return (!y) ?
false : (!x) ?
true : *x < *y;
4072 constexpr
bool operator<=(const optional<T>& x,
const optional<T>& y) {
4103 constexpr
bool operator<(const optional<T>&,
nullopt_t) noexcept {
4108 constexpr
bool operator<(nullopt_t, const optional<T>& x) noexcept {
4113 constexpr
bool operator<=(const optional<T>& x,
nullopt_t) noexcept {
4118 constexpr
bool operator<=(nullopt_t, const optional<T>&) noexcept {
4145 return bool(x) ? *x == v :
false;
4150 return bool(x) ? v == *x :
false;
4155 return bool(x) ? *x != v :
true;
4160 return bool(x) ? v != *x :
true;
4164 constexpr
bool operator<(const optional<T>& x,
const T& v) {
4165 return bool(x) ? *x < v :
true;
4170 return bool(x) ? v > *x :
true;
4175 return bool(x) ? *x > v :
false;
4179 constexpr
bool operator<(const T& v, const optional<T>& x) {
4180 return bool(x) ? v < *x :
false;
4185 return bool(x) ? *x >= v :
false;
4189 constexpr
bool operator<=(const T& v, const optional<T>& x) {
4190 return bool(x) ? v <= *x :
false;
4194 constexpr
bool operator<=(const optional<T>& x,
const T& v) {
4195 return bool(x) ? *x <= v :
true;
4200 return bool(x) ? v >= *x :
true;
4206 return bool(x) ? *x == v :
false;
4211 return bool(x) ? v == *x :
false;
4216 return bool(x) ? *x != v :
true;
4221 return bool(x) ? v != *x :
true;
4225 constexpr
bool operator<(const optional<T&>& x,
const T& v) {
4226 return bool(x) ? *x < v :
true;
4231 return bool(x) ? v > *x :
true;
4236 return bool(x) ? *x > v :
false;
4240 constexpr
bool operator<(const T& v, const optional<T&>& x) {
4241 return bool(x) ? v < *x :
false;
4246 return bool(x) ? *x >= v :
false;
4250 constexpr
bool operator<=(const T& v, const optional<T&>& x) {
4251 return bool(x) ? v <= *x :
false;
4255 constexpr
bool operator<=(const optional<T&>& x,
const T& v) {
4256 return bool(x) ? *x <= v :
true;
4261 return bool(x) ? v >= *x :
true;
4267 return bool(x) ? *x == v :
false;
4272 return bool(x) ? v == *x :
false;
4277 return bool(x) ? *x != v :
true;
4282 return bool(x) ? v != *x :
true;
4286 constexpr
bool operator<(const optional<const T&>& x,
const T& v) {
4287 return bool(x) ? *x < v :
true;
4292 return bool(x) ? v > *x :
true;
4297 return bool(x) ? *x > v :
false;
4301 constexpr
bool operator<(const T& v, const optional<const T&>& x) {
4302 return bool(x) ? v < *x :
false;
4307 return bool(x) ? *x >= v :
false;
4311 constexpr
bool operator<=(const T& v, const optional<const T&>& x) {
4312 return bool(x) ? v <= *x :
false;
4316 constexpr
bool operator<=(const optional<const T&>& x,
const T& v) {
4317 return bool(x) ? *x <= v :
true;
4322 return bool(x) ? v >= *x :
true;
4344 template <
typename T>
4345 struct hash<
sol::optional<T>> {
4349 constexpr result_type
operator()(argument_type
const& arg)
const {
4350 return arg ? ::std::hash<T>{}(*arg) : result_type{};
4354 template <
typename T>
4355 struct hash<
sol::optional<T&>> {
4359 constexpr result_type
operator()(argument_type
const& arg)
const {
4360 return arg ? ::std::hash<T>{}(*arg) : result_type{};
4365 #if defined TR2_OPTIONAL_MSVC_2015_AND_HIGHER___ 4366 #pragma warning(pop) 4369 #undef TR2_OPTIONAL_REQUIRES 4370 #undef TR2_OPTIONAL_ASSERTED_EXPRESSION 4374 #endif // Boost vs. Better optional 4378 #if defined(SOL_USE_BOOST) && SOL_USE_BOOST 4379 template <
typename T>
4380 using optional = boost::optional<T>;
4381 using nullopt_t = boost::none_t;
4383 #endif // Boost vs. Better optional 4386 template <
typename T>
4388 template <
typename T>
4400 #if defined(SOL_SAFE_FUNCTION_CALLS) && SOL_SAFE_FUNCTION_CALLS 4408 namespace meta_detail {
4413 namespace stack_detail {
4414 template <
typename T>
4419 namespace usertype_detail {
4420 template <
typename T,
typename Regs,
typename Fx>
4423 template <
typename T,
typename Regs, meta::enable<meta::neg<std::is_po
inter<T>>, std::is_destructible<T>> = meta::enabler>
4425 template <
typename T,
typename Regs, meta::disable<meta::neg<std::is_po
inter<T>>, std::is_destructible<T>> = meta::enabler>
4437 template <
typename T,
typename... Args>
4440 std::allocator<Tu> alloc{};
4441 std::allocator_traits<std::allocator<Tu>>::construct(alloc, std::forward<T>(obj), std::forward<Args>(args)...);
4444 template <
typename T,
typename... Args>
4446 construct(std::forward<T>(obj), std::forward<Args>(args)...);
4451 template <
typename T>
4453 std::allocator<meta::unqualified_t<T>> alloc{};
4457 template <
typename T>
4459 destroy(std::forward<T>(obj));
4464 template <
typename T>
4476 template <
typename T,
typename Dx,
typename... Args>
4478 return std::unique_ptr<T, Dx>(
new T(std::forward<Args>(args)...));
4481 template <
typename Tag,
typename T>
4486 : value(std::forward<Arg>(arg), std::forward<Args>(args)...) {
4491 template <
typename... Args>
4494 template <
typename... Args>
4505 template <
typename... Functions>
4510 : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {
4514 template <
typename... Functions>
4519 template <
typename... Functions>
4524 : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {
4528 template <
typename... Functions>
4533 template <
typename Function>
4537 : fx(std::move(f)) {
4546 template <
typename Fx>
4562 template <
int Target,
int... In>
4565 template <
int... In>
4574 template <
typename... Args>
4576 : target(stack_target), stack_indices(), len(sizeof...(Args)) {
4578 (void)
detail::swallow{int(), (stack_indices[i++] =
static_cast<int>(std::forward<Args>(args)), int())...};
4582 return stack_indices[i];
4586 return stack_indices[i];
4594 template <
typename F,
typename... Filters>
4596 typedef std::index_sequence_for<Filters...>
indices;
4603 : value(std::forward<Fx>(fx)),
filters(std::forward<Args>(args)...) {
4606 filter_wrapper(
const filter_wrapper&) =
default;
4607 filter_wrapper& operator=(
const filter_wrapper&) =
default;
4608 filter_wrapper(filter_wrapper&&) =
default;
4609 filter_wrapper& operator=(filter_wrapper&&) =
default;
4612 template <
typename F,
typename... Args>
4620 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 4622 #ifdef SOL_STD_VARIANT 4626 #ifdef SOL_USE_BOOST 4627 #include <boost/unordered_map.hpp> 4629 #include <unordered_map> 4630 #endif // Using Boost 4633 namespace usertype_detail {
4634 #if defined(SOL_USE_BOOST) 4635 #if defined(SOL_CXX17_FEATURES) 4636 template <
typename K,
typename V,
typename H = std::hash<K>,
typename E = std::equal_to<>>
4637 using map_t = boost::unordered_map<K, V, H, E>;
4639 template <
typename K,
typename V,
typename H = boost::hash<K>,
typename E = std::equal_to<>>
4640 using map_t = boost::unordered_map<K, V, H, E>;
4641 #endif // C++17 or not, WITH boost 4643 template <
typename K,
typename V,
typename H = std::hash<K>,
typename E = std::equal_to<>>
4644 using map_t = std::unordered_map<K, V, H, E>;
4645 #endif // Boost map target 4649 #ifdef SOL_NOEXCEPT_FUNCTION_TYPE 4653 #endif // noexcept function type for lua_CFunction 4655 template <
typename T>
4658 template <
typename T>
4671 return std::addressof(item);
4691 #if !defined(SOL_NO_NIL) || (SOL_NO_NIL == 0) 4708 template <
typename T>
4717 template <
typename Arg, meta::enable<meta::neg<std::is_same<meta::unqualified_t<Arg>, yielding_t>>, meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<Arg>>>> = meta::enabler>
4719 : func(std::forward<Arg>(arg)) {
4721 template <
typename Arg0,
typename Arg1,
typename... Args>
4723 : func(std::forward<Arg0>(arg0), std::forward<Arg1>(arg1), std::forward<Args>(args)...) {
4727 template <
typename F>
4734 template <
typename T>
4738 template <
typename X>
4741 static const bool value =
false;
4743 template <
typename U>
4748 template <
typename U>
4749 static auto get(U&& value) {
4754 template <
typename T>
4761 template <
typename X>
4764 static const bool value =
true;
4767 return p ==
nullptr;
4770 static type*
get(
const actual_type& p) {
4775 template <
typename T,
typename D>
4779 template <
typename X>
4782 static const bool value =
true;
4785 return p ==
nullptr;
4788 static type*
get(
const actual_type& p) {
4793 template <
typename T>
4796 template <
typename... Args>
4802 : index(lua_upvalueindex(idx)) {
4805 operator int()
const {
4816 operator int()
const {
4824 : index(lua_absindex(L, idx)) {
4827 operator int()
const {
4838 operator int()
const {
4856 operator void*()
const {
4866 operator void*()
const {
4871 template <
typename L>
4876 : value(std::addressof(x)) {
4882 : value(static_cast<L*>(x)) {
4884 operator L*()
const {
4887 operator L&()
const {
4892 template <
typename T>
4898 template <
typename U>
4903 : value(std::forward<U>(x)) {
4905 operator std::add_pointer_t<std::remove_reference_t<U>>() {
4906 return std::addressof(value);
4908 operator std::add_lvalue_reference_t<U>() {
4911 operator std::add_const_t<std::add_lvalue_reference_t<U>>&()
const {
4916 template <
typename T>
4919 return user<U>(std::forward<T>(u));
4922 template <
typename T>
4927 : key(std::forward<T>(key)) {
4931 template <
typename T>
4937 template <
typename... Upvalues>
4941 closure(lua_CFunction f, Upvalues... targetupvalues)
4942 : c_function(f), upvalues(std::forward<Upvalues>(targetupvalues)...) {
4951 : c_function(f), upvalues(upvalue_count) {
4957 template <
typename... Args>
4959 return closure<Args...>(f, std::forward<Args>(args)...);
4962 template <
typename Sig,
typename... Ps>
4967 : arguments(std::forward<Arg>(arg), std::forward<Args>(args)...) {
4971 template <
typename Sig = function_sig<>,
typename... Args>
4976 template <
typename Sig = function_sig<>,
typename... Args>
4981 template <
typename T>
4990 template <
typename Arg, meta::enable<meta::neg<std::is_same<meta::unqualified_t<Arg>, as_table_t>>, meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<Arg>>>> = meta::enabler>
4992 : source(std::forward<Arg>(arg)) {
4994 template <
typename Arg0,
typename Arg1,
typename... Args>
4996 : source(std::forward<Arg0>(arg0), std::forward<Arg1>(arg1), std::forward<Args>(args)...) {
4999 operator std::add_lvalue_reference_t<T>() {
5004 template <
typename T>
5013 template <
typename Arg, meta::enable<meta::neg<std::is_same<meta::unqualified_t<Arg>, nested>>, meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<Arg>>>> = meta::enabler>
5015 : source(std::forward<Arg>(arg)) {
5017 template <
typename Arg0,
typename Arg1,
typename... Args>
5018 nested(Arg0&& arg0, Arg1&& arg1, Args&&... args)
5019 : source(std::forward<Arg0>(arg0), std::forward<Arg1>(arg1), std::forward<Args>(args)...) {
5022 operator std::add_lvalue_reference_t<T>() {
5027 template <
typename T>
5032 template <
typename T>
5037 template <
typename T>
5039 return nested<T>(std::forward<T>(container));
5042 template <
typename T>
5054 operator lua_State*()
const noexcept {
5074 operator lua_State*()
const noexcept {
5088 int sequence_hint = 0;
5098 : sequence_hint(sequence_hint), map_hint(map_hint) {
5176 #if !defined(SOL_NO_NIL) 5178 #endif // Objective C/C++ Keyword that's found in OSX SDK and OBJC -- check for all forms to protect 5179 string = LUA_TSTRING,
5182 boolean = LUA_TBOOLEAN,
5183 function = LUA_TFUNCTION,
5191 static const std::array<std::string, 10> names{ {
"ok",
5199 "CRITICAL_EXCEPTION_FAILURE",
5200 "CRITICAL_INDETERMINATE_STATE_FAILURE" } };
5219 if (static_cast<std::ptrdiff_t>(c) == -1) {
5242 static const std::array<std::string, 7> names{ {
"ok",
5247 "CRITICAL_EXCEPTION_FAILURE",
5248 "CRITICAL_INDETERMINATE_STATE_FAILURE" } };
5261 if (static_cast<int>(c) == -1) {
5269 static const std::array<std::string, 3> names{ {
5274 return names[
static_cast<std::size_t
>(c)];
5317 static const std::array<std::string, 32> names = { {
"new",
5359 return static_cast<type>(lua_type(L, index));
5363 return lua_typename(L, static_cast<int>(t));
5366 template <
typename T>
5368 std::is_base_of<reference, meta::unqualified_t<T>>::value
5369 || std::is_base_of<main_reference, meta::unqualified_t<T>>::value
5370 || std::is_base_of<stack_reference, meta::unqualified_t<T>>::value> {};
5372 template <
typename T>
5374 is_lua_reference<meta::unqualified_t<T>>::value
5375 || meta::is_specialization_of<meta::unqualified_t<T>, proxy>::value> {};
5377 template <
typename T>
5387 template <
typename T>
5391 template <
typename T>
5394 template <
typename T>
5397 template <
typename T,
typename C =
void>
5400 template <
typename T>
5403 template <
typename T>
5404 struct is_container<T, std::enable_if_t<meta::is_string_like<meta::unqualified_t<T>>::value>> : std::false_type {};
5406 template <
typename T>
5407 struct is_container<T, std::enable_if_t<meta::all<std::is_array<meta::unqualified_t<T>>, meta::neg<meta::any_same<std::remove_all_extents_t<meta::unqualified_t<T>>, char, wchar_t, char16_t, char32_t>>>::value>> : std::true_type {};
5409 template <
typename T>
5410 struct is_container<T, std::enable_if_t<meta::all<meta::has_begin_end<meta::unqualified_t<T>>, meta::neg<is_initializer_list<meta::unqualified_t<T>>>, meta::neg<meta::is_string_like<meta::unqualified_t<T>>>>::value>> : std::true_type {};
5413 template <
typename T>
5416 template <
typename T>
5417 struct is_to_stringable :
meta::any<meta::supports_to_string_member<meta::unqualified_t<T>>, meta::supports_adl_to_string<meta::unqualified_t<T>>, meta::supports_ostream_op<meta::unqualified_t<T>>> {};
5420 template <
typename T,
typename =
void>
5423 template <
typename C,
typename T,
typename A>
5424 struct lua_type_of<std::basic_string<C, T, A>> : std::integral_constant<type, type::string> {};
5426 template <
typename C,
typename T>
5429 template <std::
size_t N>
5430 struct lua_type_of<char[N]> : std::integral_constant<type, type::string> {};
5432 template <std::
size_t N>
5433 struct lua_type_of<wchar_t[N]> : std::integral_constant<type, type::string> {};
5435 template <std::
size_t N>
5436 struct lua_type_of<char16_t[N]> : std::integral_constant<type, type::string> {};
5438 template <std::
size_t N>
5439 struct lua_type_of<char32_t[N]> : std::integral_constant<type, type::string> {};
5442 struct lua_type_of<char> : std::integral_constant<type, type::string> {};
5445 struct lua_type_of<wchar_t> : std::integral_constant<type, type::string> {};
5448 struct lua_type_of<char16_t> : std::integral_constant<type, type::string> {};
5451 struct lua_type_of<char32_t> : std::integral_constant<type, type::string> {};
5454 struct lua_type_of<const char*> : std::integral_constant<type, type::string> {};
5457 struct lua_type_of<const char16_t*> : std::integral_constant<type, type::string> {};
5460 struct lua_type_of<const char32_t*> : std::integral_constant<type, type::string> {};
5463 struct lua_type_of<bool> : std::integral_constant<type, type::boolean> {};
5475 struct lua_type_of<std::nullptr_t> : std::integral_constant<type, type::lua_nil> {};
5480 template <
bool b,
typename Base>
5486 template <
typename B>
5495 template <
typename T>
5498 template <
typename T>
5499 struct lua_type_of<std::initializer_list<T>> : std::integral_constant<type, type::table> {};
5507 template <
typename Base>
5510 template <
typename... Args>
5511 struct lua_type_of<std::tuple<Args...>> : std::integral_constant<type, type::poly> {};
5513 template <
typename A,
typename B>
5514 struct lua_type_of<std::pair<A, B>> : std::integral_constant<type, type::poly> {};
5517 struct lua_type_of<void*> : std::integral_constant<type, type::lightuserdata> {};
5520 struct lua_type_of<const void*> : std::integral_constant<type, type::lightuserdata> {};
5528 template <
typename T>
5531 template <
typename T>
5534 template <
typename Base>
5537 template <
typename Base>
5541 struct lua_type_of<lua_CFunction> : std::integral_constant<type, type::function> {};
5544 struct lua_type_of<std::remove_pointer_t<lua_CFunction>> : std::integral_constant<type, type::function> {};
5546 template <
typename Base,
bool aligned>
5549 template <
typename Base,
bool aligned,
typename Handler>
5552 template <
typename Base>
5555 template <
typename Base>
5558 template <
typename Signature>
5561 template <
typename T>
5564 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 5565 template <
typename T>
5567 #endif // std::optional 5570 struct lua_type_of<variadic_args> : std::integral_constant<type, type::poly> {};
5579 struct lua_type_of<this_state> : std::integral_constant<type, type::poly> {};
5582 struct lua_type_of<this_main_state> : std::integral_constant<type, type::poly> {};
5585 struct lua_type_of<this_environment> : std::integral_constant<type, type::poly> {};
5590 template <
typename T>
5591 struct lua_type_of<T*> : std::integral_constant<type, type::userdata> {};
5593 template <
typename T>
5594 struct lua_type_of<T, std::enable_if_t<std::is_arithmetic<T>::value>> : std::integral_constant<type, type::number> {};
5596 template <
typename T>
5597 struct lua_type_of<T, std::enable_if_t<std::is_enum<T>::value>> : std::integral_constant<type, type::number> {};
5602 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 5603 #ifdef SOL_STD_VARIANT 5604 template <
typename... Tn>
5605 struct lua_type_of<std::variant<Tn...>> : std::integral_constant<type, type::poly> {};
5606 #endif // SOL_STD_VARIANT 5607 #endif // SOL_CXX17_FEATURES 5609 template <
typename T>
5610 struct lua_type_of<
nested<T>, std::enable_if_t<::sol::is_container<T>::value>> : std::integral_constant<type, type::table> {};
5612 template <
typename T>
5615 template <
typename C, C v,
template <
typename...>
class V,
typename... Args>
5618 template <
typename C, C v,
template <
typename...>
class V,
typename T,
typename... Args>
5621 template <
typename C, C v,
template <
typename...>
class V,
typename List>
5624 template <
typename C, C v,
template <
typename...>
class V,
typename... Args>
5628 template <
typename T>
5631 template <
typename T>
5636 template <
typename T>
5641 template <
typename A,
typename B>
5642 struct lua_size<std::pair<A, B>> : std::integral_constant<int, lua_size<A>::value + lua_size<B>::value> {};
5644 template <
typename... Args>
5645 struct lua_size<std::tuple<Args...>> : std::integral_constant<int, detail::accumulate<int, 0, lua_size, Args...>::value> {};
5648 template <
typename...>
5650 template <
typename T,
typename =
void>
5652 template <
typename T>
5655 template <
typename T>
5659 template <
typename T>
5661 type::userdata != lua_type_of<meta::unqualified_t<T>>::value
5662 || ((type::userdata == lua_type_of<meta::unqualified_t<T>>::value)
5663 && detail::has_internal_marker<lua_type_of<meta::unqualified_t<T>>>::value
5664 && !detail::has_internal_marker<lua_size<meta::unqualified_t<T>>>::value)
5665 || is_lua_reference<meta::unqualified_t<T>>::value
5666 || meta::is_specialization_of<meta::unqualified_t<T>, std::tuple>::value
5667 || meta::is_specialization_of<meta::unqualified_t<T>, std::pair>::value> {};
5669 template <
typename T>
5672 template <
typename T>
5685 template <
typename T>
5691 template <
typename T>
5693 template <
typename T>
5695 template <
typename T>
5697 template <
typename T>
5699 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 5700 template <
typename T>
5703 template <
typename T>
5705 template <
typename T>
5711 template <
typename T>
5714 template <
typename T>
5717 template <
typename T>
5728 template <
typename Signature>
5734 typedef std::integral_constant<bool, meta::count_for<is_variadic_arguments, typename base_t::args_list>::value != 0>
runtime_variadics_t;
5735 static const std::size_t true_arity = base_t::arity;
5737 static const std::size_t true_free_arity = base_t::free_arity;
5741 template <
typename T>
5743 template <
bool x,
typename T>
5746 template <
typename T>
5748 template <
typename T,
bool aligned>
5750 template <
typename T,
bool aligned,
typename Handler>
5753 template <
typename T>
5755 template <
typename T>
5758 template <
typename T>
5760 template <
typename T>
5763 template <
typename T>
5764 struct is_environment : std::integral_constant<bool, is_userdata<T>::value || is_table<T>::value> {};
5766 template <
typename T>
5769 template <
typename T>
5775 template <
typename T>
5778 template <
typename... Args>
5781 template <
typename... Args>
5787 template <
typename T>
5790 template <
typename... Args>
5793 template <
typename T>
5796 template <
typename F,
typename... Filters>
5799 template <
typename... Args>
5802 template <
typename T>
5805 template <
typename Fx>
5808 template <
typename... Args>
5820 #include <exception> 5823 #if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS 5835 static const char name[11] =
"sol.\xE2\x98\xA2\xE2\x98\xA2";
5841 #if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS 5842 std::cerr <<
"[sol2] An exception occurred: ";
5843 std::cerr.write(what.
data(), what.
size());
5844 std::cerr << std::endl;
5846 lua_pushlstring(L, what.
data(), what.
size());
5852 type t =
static_cast<type>(lua_type(L, -1));
5857 void* vfunc = lua_touserdata(L, -1);
5859 if (vfunc ==
nullptr) {
5863 return exfunc(L, std::move(maybe_ex), std::move(what));
5866 #ifdef SOL_NO_EXCEPTIONS 5867 template <lua_CFunction f>
5872 #ifdef SOL_NOEXCEPT_FUNCTION_TYPE 5873 template <lua_CFunction_noexcept f>
5878 template <lua_CFunction f>
5884 template <
typename Fx,
typename... Args>
5885 int trampoline(lua_State* L, Fx&& f, Args&&... args) noexcept {
5886 return f(L, std::forward<Args>(args)...);
5889 inline int c_trampoline(lua_State* L, lua_CFunction f) noexcept {
5893 template <lua_CFunction f>
5895 #if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT) 5902 catch (
const char* cs) {
5908 catch (
const std::exception& e) {
5911 #if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) 5918 #endif // LuaJIT cannot have the catchall, but we must catch std::exceps for it 5919 return lua_error(L);
5920 #endif // Safe exceptions 5923 #ifdef SOL_NOEXCEPT_FUNCTION_TYPE 5927 template <lua_CFunction_noexcept f>
5932 template <lua_CFunction_noexcept f>
5936 #endif // impossible 5939 template <lua_CFunction f>
5943 #endif // noexcept lua_CFunction type 5945 template <
typename Fx,
typename... Args>
5948 return f(L, std::forward<Args>(args)...);
5950 #if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT) 5951 return f(L, std::forward<Args>(args)...);
5954 return f(L, std::forward<Args>(args)...);
5956 catch (
const char* cs) {
5962 catch (
const std::exception& e) {
5965 #if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) 5973 return lua_error(L);
5980 #endif // Exceptions vs. No Exceptions 5982 template <
typename F, F fx>
5984 return static_trampoline_noexcept<fx>(L);
5987 template <
typename F, F fx>
5989 return static_trampoline<fx>(L);
5992 template <
typename F, F fx>
5994 return typed_static_trampoline_raw<F, fx>(std::integral_constant<bool, meta::bind_traits<F>::is_noexcept>(), L);
5999 static_assert(
sizeof(
void*) >=
sizeof(
exception_handler_function),
"void* storage is too small to transport the exception handler: please file a bug on the issue tracker");
6002 lua_pushlightuserdata(L, storage);
6018 #if defined(__GNUC__) && defined(__MINGW32__) && (__GNUC__ < 6) 6021 #endif // MinGW is on some stuff 6026 #if defined(__GNUC__) || defined(__clang__) 6027 template <
typename T,
class seperator_mark =
int>
6030 using namespace std;
6031 static const std::array<std::string, 2> removals = {{
"{anonymous}",
"(anonymous namespace)"}};
6033 std::size_t start = name.find_first_of(
'[');
6034 start = name.find_first_of(
'=', start);
6035 std::size_t end = name.find_last_of(
']');
6036 if (end == std::string::npos)
6038 if (start == std::string::npos)
6040 if (start < name.size() - 1)
6042 name = name.substr(start, end - start);
6043 start = name.rfind(
"seperator_mark");
6044 if (start != std::string::npos) {
6045 name.erase(start - 2, name.length());
6047 while (!name.empty() && isblank(name.front()))
6048 name.erase(name.begin());
6049 while (!name.empty() && isblank(name.back()))
6052 for (std::size_t r = 0; r < removals.size(); ++r) {
6053 auto found = name.find(removals[r]);
6054 while (found != std::string::npos) {
6055 name.erase(found, removals[r].size());
6056 found = name.find(removals[r]);
6062 #elif defined(_MSC_VER) 6063 template <
typename T>
6065 static const std::array<std::string, 7> removals = {{
"public:",
"private:",
"protected:",
"struct ",
"class ",
"`anonymous-namespace'",
"`anonymous namespace'"}};
6067 std::size_t start = name.find(
"get_type_name");
6068 if (start == std::string::npos)
6072 if (start < name.size() - 1)
6074 std::size_t end = name.find_last_of(
'>');
6075 if (end == std::string::npos)
6077 name = name.substr(start, end - start);
6078 if (name.find(
"struct", 0) == 0)
6079 name.replace(0, 6,
"", 0);
6080 if (name.find(
"class", 0) == 0)
6081 name.replace(0, 5,
"", 0);
6082 while (!name.empty() && isblank(name.front()))
6083 name.erase(name.begin());
6084 while (!name.empty() && isblank(name.back()))
6087 for (std::size_t r = 0; r < removals.size(); ++r) {
6088 auto found = name.find(removals[r]);
6089 while (found != std::string::npos) {
6090 name.erase(found, removals[r].size());
6091 found = name.find(removals[r]);
6098 #error Compiler not supported for demangling 6101 template <
typename T>
6107 template <
typename T>
6111 static const std::array<std::string, 10> ops = {{
"operator<",
"operator<<",
"operator<<=",
"operator<=",
"operator>",
"operator>>",
"operator>>=",
"operator>=",
"operator->",
"operator->*"}};
6113 std::ptrdiff_t idx = 0;
6114 for (idx = static_cast<std::ptrdiff_t>(realname.empty() ? 0 : realname.size() - 1); idx > 0; --idx) {
6115 if (level == 0 && realname[idx] ==
':') {
6118 bool isleft = realname[idx] ==
'<';
6119 bool isright = realname[idx] ==
'>';
6120 if (!isleft && !isright)
6122 bool earlybreak =
false;
6123 for (
const auto& op : ops) {
6124 std::size_t nisop = realname.rfind(op, idx);
6125 if (nisop == std::string::npos)
6127 std::size_t nisopidx = idx - op.size() + 1;
6128 if (nisop == nisopidx) {
6129 idx =
static_cast<std::ptrdiff_t
>(nisopidx);
6137 level += isleft ? -1 : 1;
6140 realname.erase(0, realname.length() <
static_cast<std::size_t
>(idx) ? realname.length() : idx + 1);
6145 template <
typename T>
6151 template <
typename T>
6153 static const std::string d = short_demangle_once<T>();
6163 template <
typename T>
6166 static const std::string& n = detail::short_demangle<T>();
6170 static const std::string& q_n = detail::demangle<T>();
6182 static const std::string u_g_m =
std::string(
"sol.").append(detail::demangle<T>()).append(
".user\xE2\x99\xBB");
6186 static const std::string g_t =
std::string(
"sol.").append(detail::demangle<T>()).append(
".\xE2\x99\xBB");
6196 template <
typename... Args>
6198 template <
typename... Args>
6206 template <
typename T>
6211 template <
typename T>
6215 static const auto& key =
"class_check";
6220 static const auto& key =
"class_cast";
6225 static const auto& key =
u8"\xF0\x9F\x8C\xB2.index";
6230 static const auto& key =
u8"\xF0\x9F\x8C\xB2.new_index";
6234 template <
typename T,
typename... Bases>
6240 template <
typename Base,
typename... Args>
6253 template <
typename Base,
typename... Args>
6260 T* data =
static_cast<T*
>(voiddata);
6264 template <
typename U>
6269 template <
typename U,
typename Base,
typename... Args>
6272 typedef typename uu_traits::template rebind_base<Base> base_ptr;
6274 if (base_ti == ti) {
6275 if (target_data !=
nullptr) {
6276 U* source =
static_cast<U*
>(source_data);
6277 base_ptr* target =
static_cast<base_ptr*
>(target_data);
6283 return type_unique_cast_bases<U, Args...>(source_data, target_data, ti);
6286 template <
typename U>
6289 typedef typename uu_traits::template rebind_base<T> rebind_t;
6291 if (rebind_ti != this_rebind_ti) {
6295 return type_unique_cast_bases<U, Bases...>(source_data, target_data, ti);
6317 if (lua_getmetatable(L, index) == 0) {
6320 lua_pushlstring(L,
"__name", 6);
6323 const char* name = lua_tolstring(L, -1, &sz);
6324 std::string tn(name, static_cast<std::string::size_type>(sz));
6331 return lua_typename(L, static_cast<int>(t));
6335 const char* err = message.empty() ?
"stack index %d, expected %s, received %s" :
"stack index %d, expected %s, received %s: %s";
6337 return luaL_error(L, err, index,
6338 expected ==
type::poly ?
"anything" : lua_typename(L, static_cast<int>(expected)),
6344 const char* err = message ==
nullptr || (std::char_traits<char>::length(message) == 0) ?
"stack index %d, expected %s, received %s" :
"stack index %d, expected %s, received %s: %s";
6346 return luaL_error(L, err, index,
6347 expected ==
type::poly ?
"anything" : lua_typename(L, static_cast<int>(expected)),
6356 int operator()(lua_State* L,
int index,
type expected,
type actual,
const char* message)
const noexcept(
false) {
6368 std::string str =
"(type check failed in constructor)";
6369 return type_panic_string(L, index, expected, actual, message.empty() ? str : message +
" " + str);
6373 template <
typename F =
void>
6376 std::string str =
"(bad argument to variable or function call)";
6377 return type_panic_string(L, index, expected, actual, message.empty() ? str : message +
" " + str );
6381 template <
typename R,
typename... Args>
6385 addendum += detail::demangle<R>();
6388 auto action = [&addendum, &marker](
const std::string& n) {
6395 (void)
detail::swallow{int(), (action(detail::demangle<Args>()), int())...};
6397 return type_panic_string(L, index, expected, actual, message.empty() ? addendum : message +
" " + addendum);
6406 inline void type_error(lua_State* L,
int expected,
int actual) noexcept(
false) {
6407 luaL_error(L,
"expected %s, received %s", lua_typename(L, expected), lua_typename(L, actual));
6411 type_error(L, static_cast<int>(expected), static_cast<int>(actual));
6415 if (expected !=
type::poly && expected != actual) {
6435 inline bool xmovable(lua_State* leftL, lua_State* rightL) {
6436 if (rightL ==
nullptr || leftL ==
nullptr || leftL == rightL) {
6439 const void* leftregistry = lua_topointer(leftL, LUA_REGISTRYINDEX);
6440 const void* rightregistry = lua_topointer(rightL, LUA_REGISTRYINDEX);
6441 return leftregistry == rightregistry;
6447 lua_State* luastate =
nullptr;
6460 : luastate(L), index(0) {
6466 : luastate(L), index(i) {
6469 : luastate(L), index(i) {
6493 return push(lua_state());
6496 int push(lua_State* Ls)
const noexcept {
6497 if (lua_state() ==
nullptr) {
6501 lua_pushvalue(lua_state(), index);
6502 if (Ls != lua_state()) {
6503 lua_xmove(lua_state(), Ls, 1);
6512 void pop(lua_State* Ls,
int n = 1) const noexcept {
6521 const void* vp = lua_topointer(lua_state(), stack_index());
6526 int result = lua_type(lua_state(), index);
6527 return static_cast<type>(result);
6535 type t = get_type();
6549 return !lhs.
valid();
6553 return !rhs.
valid();
6570 static const char name[9] =
"sol.\xF0\x9F\x93\x8C";
6576 inline void remove(lua_State* L,
int rawindex,
int count) {
6579 int top = lua_gettop(L);
6583 if (rawindex == -
count || top == rawindex) {
6585 lua_pop(L, static_cast<int>(
count));
6592 int index = lua_absindex(L, rawindex);
6594 index = lua_gettop(L) + (index + 1);
6596 int last = index +
count;
6597 for (
int i = index; i < last; ++i) {
6598 lua_remove(L, index);
6607 : L(luastate), index(index), count(count) {
6610 remove(L, index, count);
6614 template <
bool top_level>
6619 : L(luastate), t(x) {
6634 template <
bool,
typename T,
typename =
void>
6645 template <
typename T,
typename C>
6652 template <
typename T>
6653 struct push_popper<false, T, std::enable_if_t<std::is_base_of<stack_reference, meta::unqualified_t<T>>::value>> {
6660 template <
bool top_level = false,
typename T>
6664 template <
typename T>
6667 lua_State* L = x.lua_state();
6670 template <
bool top_level = false>
6676 inline lua_State*
main_thread(lua_State* L, lua_State* backup_if_unsupported =
nullptr) {
6677 #if SOL_LUA_VERSION < 502 6679 return backup_if_unsupported;
6683 return lua_tothread(L, -1);
6685 return backup_if_unsupported;
6688 return backup_if_unsupported;
6689 lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_MAINTHREAD);
6690 lua_State* Lmain = lua_tothread(L, -1);
6693 #endif // Lua 5.2+ has the main thread getter 6705 (void)backup_if_unsupported;
6713 template <
bool main_only = false>
6716 template <
bool o_main_only>
6718 lua_State* luastate =
nullptr;
6719 int ref = LUA_NOREF;
6722 if (ref == LUA_NOREF)
6725 return luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6728 template <
bool r_main_only>
6733 if (r.
ref == LUA_REFNIL) {
6734 luastate = detail::pick_main_thread < main_only && !r_main_only > (r.
lua_state(), r.
lua_state());
6738 if (r.
ref == LUA_NOREF) {
6744 r.
push(lua_state());
6745 ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6748 luastate = detail::pick_main_thread < main_only && !r_main_only > (r.
lua_state(), r.
lua_state());
6752 template <
bool r_main_only>
6757 if (r.ref == LUA_REFNIL) {
6758 luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
6762 if (r.ref == LUA_NOREF) {
6763 luastate = r.luastate;
6768 r.push(lua_state());
6769 ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6773 luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
6776 r.luastate =
nullptr;
6782 lua_pushglobaltable(lua_state());
6783 ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6791 luaL_unref(lua_state(), LUA_REGISTRYINDEX, ref);
6805 template <
bool r_main_only>
6807 : luastate(detail::pick_main_thread<main_only>(L, L)) {
6808 if (r.ref == LUA_REFNIL) {
6812 if (r.ref == LUA_NOREF || lua_state() ==
nullptr) {
6817 r.push(lua_state());
6818 ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6824 template <
bool r_main_only>
6827 if (r.ref == LUA_REFNIL) {
6831 if (r.ref == LUA_NOREF || lua_state() ==
nullptr) {
6836 r.push(lua_state());
6837 ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6842 r.luastate =
nullptr;
6846 : luastate(detail::pick_main_thread<main_only>(L, L)) {
6847 if (lua_state() ==
nullptr || r.lua_state() ==
nullptr || r.get_type() ==
type::none) {
6855 if (lua_state() != r.lua_state() && !
detail::xmovable(lua_state(), r.lua_state())) {
6858 r.push(lua_state());
6859 ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6864 lua_pushvalue(L, index);
6865 ref = luaL_ref(L, LUA_REGISTRYINDEX);
6868 : luastate(detail::pick_main_thread<main_only>(L, L)) {
6869 lua_rawgeti(lua_state(), LUA_REGISTRYINDEX, index.index);
6870 ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6877 if (lua_state() ==
nullptr || ref == LUA_NOREF)
6883 : luastate(o.lua_state()), ref(o.copy()) {
6887 : luastate(o.lua_state()), ref(o.ref) {
6888 o.luastate =
nullptr;
6893 : luastate(detail::pick_main_thread < main_only && !main_only > (o.lua_state(), o.lua_state())), ref(o.copy()) {
6897 : luastate(detail::
pick_main_thread < main_only && !main_only > (o.lua_state(), o.lua_state())), ref(o.ref) {
6898 o.luastate =
nullptr;
6903 move_assign(std::move(r));
6913 move_assign(std::move(r));
6931 template <
typename Super>
6934 template <
typename Super>
6938 return push(lua_state());
6941 int push(lua_State* Ls)
const noexcept {
6942 if (lua_state() ==
nullptr) {
6946 lua_rawgeti(lua_state(), LUA_REGISTRYINDEX, ref);
6947 if (Ls != lua_state()) {
6948 lua_xmove(lua_state(), Ls, 1);
6957 void pop(lua_State* Ls,
int n = 1) const noexcept {
6966 return !(ref == LUA_NOREF || ref == LUA_REFNIL);
6971 const void* vp = lua_topointer(lua_state(), -si);
6972 lua_pop(this->lua_state(), si);
6976 explicit operator bool() const noexcept {
6982 int result = lua_type(lua_state(), -1);
6983 return static_cast<type>(result);
6991 template <
bool lb,
bool rb>
6995 return lua_compare(l.
lua_state(), -1, -2, LUA_OPEQ) == 1;
6998 template <
bool lb,
bool rb>
7005 return !lhs.
valid();
7010 return !rhs.
valid();
7031 template <
typename T>
7035 template <
typename T>
7038 template <
typename T>
7039 struct is_tieable : std::integral_constant<bool, (::sol::tie_size<T>::value > 0)> {};
7041 template <
typename... Tn>
7042 struct tie_t :
public std::tuple<std::add_lvalue_reference_t<Tn>...> {
7044 typedef std::tuple<std::add_lvalue_reference_t<Tn>...>
base_t;
7046 template <
typename T>
7047 void set(std::false_type, T&& target) {
7048 std::get<0>(*this) = std::forward<T>(target);
7051 template <
typename T>
7052 void set(std::true_type, T&& target) {
7055 typedef std::conditional_t<(value_size::value < tie_size::value), value_size, tie_size> indices_size;
7056 typedef std::make_index_sequence<indices_size::value> indices;
7060 template <std::size_t... I,
typename T>
7061 void set_extra(std::true_type, std::index_sequence<I...>, T&& target) {
7067 template <std::size_t... I,
typename T>
7068 void set_extra(std::false_type, std::index_sequence<I...>, T&& target) {
7071 (get<I>(
static_cast<base_t&
>(*this)) = get<I>(target), 0)..., 0};
7075 using base_t::base_t;
7077 template <
typename T>
7080 set(tieable(), std::forward<T>(value));
7085 template <
typename... Tn>
7088 namespace adl_barrier_detail {
7089 template <
typename... Tn>
7095 using namespace adl_barrier_detail;
7106 #if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS) 7112 #endif // No Exceptions 7125 : L(L), top(top), on_mismatch(std::move(fx)) {
7128 int bottom = lua_gettop(L) + modification;
7129 if (top == bottom) {
7132 on_mismatch(top, bottom);
7144 #include <forward_list> 7145 #include <algorithm> 7146 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 7152 template <
typename T>
7154 template <
typename T>
7156 template <
typename T>
7166 inline void*
align(std::size_t alignment, std::size_t size,
void*&
ptr, std::size_t& space, std::size_t& required_space) {
7171 std::uintptr_t initial =
reinterpret_cast<std::uintptr_t
>(
ptr);
7172 std::uintptr_t offby =
static_cast<std::uintptr_t
>(initial % alignment);
7173 std::uintptr_t padding = (alignment - offby) % alignment;
7174 required_space += size + padding;
7175 if (space < required_space) {
7178 ptr =
static_cast<void*
>(
static_cast<char*
>(
ptr) + padding);
7183 inline void*
align(std::size_t alignment, std::size_t size,
void*&
ptr, std::size_t& space) {
7184 std::size_t required_space = 0;
7185 return align(alignment, size, ptr, space, required_space);
7188 template <
typename... Args>
7190 char* start =
static_cast<char*
>(alignment);
7191 auto specific_align = [&alignment](std::size_t a, std::size_t s) {
7192 std::size_t space = (std::numeric_limits<std::size_t>::max)();
7193 alignment =
align(a, s, alignment, space);
7194 alignment =
static_cast<void*
>(
static_cast<char*
>(alignment) + s);
7196 (void)
detail::swallow{
int{}, (specific_align(std::alignment_of<Args>::value,
sizeof(Args)),
int{})... };
7197 return static_cast<char*
>(alignment) - start;
7201 typedef std::integral_constant<bool,
7202 #if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT 7205 (std::alignment_of<void*>::value > 1)
7209 if (!use_align::value) {
7212 std::size_t space = (std::numeric_limits<std::size_t>::max)();
7213 return align(std::alignment_of<void*>::value,
sizeof(
void*), ptr, space);
7216 template <
bool pre_aligned = false>
7218 typedef std::integral_constant<bool,
7219 #if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT 7222 (std::alignment_of<unique_destructor>::value > 1)
7228 ptr =
static_cast<void*
>(
static_cast<char*
>(
ptr) +
sizeof(
void*));
7230 if (!use_align::value) {
7231 return static_cast<void*
>(
static_cast<void**
>(
ptr) + 1);
7233 std::size_t space = (std::numeric_limits<std::size_t>::max)();
7237 template <
bool pre_aligned = false>
7239 typedef std::integral_constant<bool,
7240 #if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT 7243 (std::alignment_of<unique_tag>::value > 1)
7251 if (!use_align::value) {
7254 std::size_t space = (std::numeric_limits<std::size_t>::max)();
7255 return align(std::alignment_of<unique_tag>::value,
sizeof(
unique_tag), ptr, space);
7257 template <
typename T,
bool pre_aligned = false>
7259 typedef std::integral_constant<bool,
7260 #if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT 7263 (std::alignment_of<T>::value > 1)
7269 ptr =
static_cast<void*
>(
static_cast<char*
>(
ptr) +
sizeof(
unique_tag));
7271 if (!use_align::value) {
7274 std::size_t space = (std::numeric_limits<std::size_t>::max)();
7275 return align(std::alignment_of<T>::value,
sizeof(T), ptr, space);
7278 template <
typename T>
7280 typedef std::integral_constant<bool,
7281 #if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT 7284 (std::alignment_of<T>::value > 1)
7288 if (!use_align::value) {
7291 std::size_t space = (std::numeric_limits<std::size_t>::max)();
7292 return align(std::alignment_of<T>::value,
sizeof(T), ptr, space);
7295 template <
typename T>
7297 typedef std::integral_constant<bool,
7298 #if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT 7301 (std::alignment_of<T*>::value > 1)
7305 if (!use_align::value) {
7306 T** pointerpointer =
static_cast<T**
>(lua_newuserdata(L,
sizeof(T*)));
7307 return pointerpointer;
7309 static const std::size_t initial_size = aligned_space_for<T*>(
nullptr);
7310 static const std::size_t misaligned_size = aligned_space_for<T*>(
reinterpret_cast<void*
>(0x1));
7312 std::size_t allocated_size = initial_size;
7313 void* unadjusted = lua_newuserdata(L, initial_size);
7314 void* adjusted =
align(std::alignment_of<T*>::value,
sizeof(T*), unadjusted, allocated_size);
7315 if (adjusted ==
nullptr) {
7319 allocated_size = misaligned_size;
7320 unadjusted = lua_newuserdata(L, allocated_size);
7321 adjusted =
align(std::alignment_of<T*>::value,
sizeof(T*), unadjusted, allocated_size);
7322 if (adjusted ==
nullptr) {
7326 luaL_error(L,
"cannot properly align memory for '%s'", detail::demangle<T*>().data());
7329 return static_cast<T**
>(adjusted);
7332 template <
typename T>
7334 typedef std::integral_constant<bool,
7335 #if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT 7338 (std::alignment_of<T*>::value > 1 || std::alignment_of<T>::value > 1)
7342 if (!use_align::value) {
7343 T** pointerpointer =
static_cast<T**
>(lua_newuserdata(L,
sizeof(T*) +
sizeof(T)));
7344 T*& pointerreference = *pointerpointer;
7345 T* allocationtarget =
reinterpret_cast<T*
>(pointerpointer + 1);
7346 pointerreference = allocationtarget;
7347 return allocationtarget;
7365 static const std::size_t initial_size = aligned_space_for<T*, T>(
nullptr);
7366 static const std::size_t misaligned_size = aligned_space_for<T*, T>(
reinterpret_cast<void*
>(0x1));
7368 void* pointer_adjusted;
7369 void* data_adjusted;
7370 auto attempt_alloc = [](lua_State* L, std::size_t allocated_size,
void*& pointer_adjusted,
void*& data_adjusted) ->
bool {
7371 void* adjusted = lua_newuserdata(L, allocated_size);
7372 pointer_adjusted =
align(std::alignment_of<T*>::value,
sizeof(T*), adjusted, allocated_size);
7373 if (pointer_adjusted ==
nullptr) {
7378 allocated_size -=
sizeof(T*);
7379 adjusted =
static_cast<void*
>(
static_cast<char*
>(pointer_adjusted) +
sizeof(T*));
7380 data_adjusted =
align(std::alignment_of<T>::value,
sizeof(T), adjusted, allocated_size);
7381 if (data_adjusted ==
nullptr) {
7387 bool result = attempt_alloc(L, initial_size, pointer_adjusted, data_adjusted);
7391 pointer_adjusted =
nullptr;
7392 data_adjusted =
nullptr;
7393 result = attempt_alloc(L, misaligned_size, pointer_adjusted, data_adjusted);
7395 if (pointer_adjusted ==
nullptr) {
7396 luaL_error(L,
"aligned allocation of userdata block (pointer section) for '%s' failed", detail::demangle<T>().c_str());
7399 luaL_error(L,
"aligned allocation of userdata block (data section) for '%s' failed", detail::demangle<T>().c_str());
7405 T** pointerpointer =
reinterpret_cast<T**
>(pointer_adjusted);
7406 T*& pointerreference = *pointerpointer;
7407 T* allocationtarget =
reinterpret_cast<T*
>(data_adjusted);
7408 pointerreference = allocationtarget;
7409 return allocationtarget;
7412 template <
typename T,
typename Real>
7414 typedef std::integral_constant<bool,
7415 #if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT 7418 (std::alignment_of<T*>::value > 1 || std::alignment_of<unique_tag>::value > 1 || std::alignment_of<unique_destructor>::value > 1 || std::alignment_of<Real>::value > 1)
7422 if (!use_align::value) {
7425 id =
static_cast<unique_tag*
>(
static_cast<void*
>(dx + 1));
7426 Real* mem =
static_cast<Real*
>(
static_cast<void*
>(
id + 1));
7430 static const std::size_t initial_size = aligned_space_for<T*, unique_destructor, unique_tag, Real>(
nullptr);
7431 static const std::size_t misaligned_size = aligned_space_for<T*, unique_destructor, unique_tag, Real>(
reinterpret_cast<void*
>(0x1));
7433 void* pointer_adjusted;
7436 void* data_adjusted;
7437 auto attempt_alloc = [](lua_State* L, std::size_t allocated_size,
void*& pointer_adjusted,
void*& dx_adjusted,
void*& id_adjusted,
void*& data_adjusted) ->
bool {
7438 void* adjusted = lua_newuserdata(L, allocated_size);
7439 pointer_adjusted =
align(std::alignment_of<T*>::value,
sizeof(T*), adjusted, allocated_size);
7440 if (pointer_adjusted ==
nullptr) {
7444 allocated_size -=
sizeof(T*);
7446 adjusted =
static_cast<void*
>(
static_cast<char*
>(pointer_adjusted) +
sizeof(T*));
7447 dx_adjusted =
align(std::alignment_of<unique_destructor>::value,
sizeof(
unique_destructor), adjusted, allocated_size);
7448 if (dx_adjusted ==
nullptr) {
7454 adjusted =
static_cast<void*
>(
static_cast<char*
>(dx_adjusted) +
sizeof(
unique_destructor));
7456 id_adjusted =
align(std::alignment_of<unique_tag>::value,
sizeof(
unique_tag), adjusted, allocated_size);
7457 if (id_adjusted ==
nullptr) {
7463 adjusted =
static_cast<void*
>(
static_cast<char*
>(id_adjusted) +
sizeof(
unique_tag));
7464 data_adjusted =
align(std::alignment_of<Real>::value,
sizeof(Real), adjusted, allocated_size);
7465 if (data_adjusted ==
nullptr) {
7471 bool result = attempt_alloc(L, initial_size, pointer_adjusted, dx_adjusted, id_adjusted, data_adjusted);
7475 pointer_adjusted =
nullptr;
7476 dx_adjusted =
nullptr;
7477 id_adjusted =
nullptr;
7478 data_adjusted =
nullptr;
7479 result = attempt_alloc(L, misaligned_size, pointer_adjusted, dx_adjusted, id_adjusted, data_adjusted);
7481 if (pointer_adjusted ==
nullptr) {
7482 luaL_error(L,
"aligned allocation of userdata block (pointer section) for '%s' failed", detail::demangle<T>().c_str());
7484 else if (dx_adjusted ==
nullptr) {
7485 luaL_error(L,
"aligned allocation of userdata block (deleter section) for '%s' failed", detail::demangle<T>().c_str());
7488 luaL_error(L,
"aligned allocation of userdata block (data section) for '%s' failed", detail::demangle<T>().c_str());
7494 pref =
static_cast<T**
>(pointer_adjusted);
7497 Real* mem =
static_cast<Real*
>(data_adjusted);
7501 template <
typename T>
7503 typedef std::integral_constant<bool,
7504 #if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT 7507 (std::alignment_of<T>::value > 1)
7511 if (!use_align::value) {
7512 T* pointer =
static_cast<T*
>(lua_newuserdata(L,
sizeof(T)));
7516 static const std::size_t initial_size = aligned_space_for<T>(
nullptr);
7517 static const std::size_t misaligned_size = aligned_space_for<T>(
reinterpret_cast<void*
>(0x1));
7519 std::size_t allocated_size = initial_size;
7520 void* unadjusted = lua_newuserdata(L, allocated_size);
7521 void* adjusted =
align(std::alignment_of<T>::value,
sizeof(T), unadjusted, allocated_size);
7522 if (adjusted ==
nullptr) {
7525 allocated_size = misaligned_size;
7526 unadjusted = lua_newuserdata(L, allocated_size);
7527 adjusted =
align(std::alignment_of<T>::value,
sizeof(T), unadjusted, allocated_size);
7528 if (adjusted ==
nullptr) {
7530 luaL_error(L,
"cannot properly align memory for '%s'", detail::demangle<T>().data());
7533 return static_cast<T*
>(adjusted);
7536 template <
typename T>
7538 void*
memory = lua_touserdata(L, 1);
7540 T** pdata =
static_cast<T**
>(memory);
7542 std::allocator<T> alloc{};
7543 std::allocator_traits<std::allocator<T>>::destroy(alloc, data);
7547 template <
typename T>
7549 void*
memory = lua_touserdata(L, 1);
7552 memory =
static_cast<void*
>(
static_cast<char*
>(memory) +
sizeof(
unique_destructor));
7553 memory = align_usertype_unique_tag<true>(memory);
7554 memory =
static_cast<void*
>(
static_cast<char*
>(memory) +
sizeof(
unique_tag));
7559 template <
typename T>
7561 void*
memory = lua_touserdata(L, 1);
7562 memory = align_user<T>(memory);
7563 T* data =
static_cast<T*
>(memory);
7564 std::allocator<T> alloc;
7565 std::allocator_traits<std::allocator<T>>::destroy(alloc, data);
7569 template <
typename T,
typename Real>
7571 memory = align_usertype_unique<Real, true>(memory);
7572 Real* target =
static_cast<Real*
>(memory);
7573 std::allocator<Real> alloc;
7574 std::allocator_traits<std::allocator<Real>>::destroy(alloc, target);
7577 template <
typename T>
7579 return luaL_error(L,
"cannot call the destructor for '%s': it is either hidden (protected/private) or removed with '= delete' and thusly this type is being destroyed without properly destructing, invoking undefined behavior: please bind a usertype and specify a custom destructor to define the behavior properly", detail::demangle<T>().data());
7582 template <
typename T>
7586 template <
typename T,
typename Al>
7587 void reserve(std::vector<T, Al>& arr, std::size_t hint) {
7591 template <
typename T,
typename Tr,
typename Al>
7592 void reserve(std::basic_string<T, Tr, Al>& arr, std::size_t hint) {
7599 template <
typename T>
7602 template <
typename T,
bool global = false,
bool raw = false,
typename =
void>
7604 template <
typename T,
typename P,
bool global = false,
bool raw = false,
typename =
void>
7606 template <
typename T,
bool global = false,
bool raw = false,
typename =
void>
7608 template <
typename T,
typename =
void>
7610 template <
typename T,
typename =
void>
7612 template <
typename T,
typename =
void>
7614 template <
typename T,
typename =
void>
7616 template <
typename T,
typename =
void>
7618 template <typename T, type = lua_type_of<T>::value,
typename =
void>
7620 template <typename T, type = lua_type_of<T>::value,
typename =
void>
7622 template <
typename T,
typename =
void>
7624 template <
typename T,
typename =
void>
7626 template <
typename T,
typename =
void>
7634 : success(s), levels(l) {
7637 operator bool()
const {
7655 namespace stack_detail {
7656 template <
typename T>
7660 template <
typename T>
7661 struct strip<std::reference_wrapper<T>> {
7664 template <
typename T>
7668 template <
typename T>
7672 template <
typename T>
7675 template <
typename T>
7678 template <
typename T>
7681 template <
typename T>
7684 template <
typename C>
7686 return static_cast<int>(c.size());
7689 template <
typename V,
typename Al>
7692 return static_cast<int>(32);
7695 template <
typename T>
7700 return g.
get(L, index, tracking);
7703 template <
typename T>
7707 return g.
get(L, index, tracking);
7710 template <
typename T,
typename Arg,
typename... Args>
7713 std::is_lvalue_reference<T>,
7720 return p.
push(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
7723 template <
typename T,
typename Handler>
7730 template <
typename T,
typename Handler>
7743 inline int top(lua_State* L) {
7744 return lua_gettop(L);
7748 int ismainthread = lua_pushthread(L);
7750 return ismainthread == 1;
7757 int stacksize = lua_gettop(L);
7758 if (stacksize < 1) {
7766 lua_pop(L, stacksize);
7769 template <
typename T,
typename... Args>
7770 inline int push(lua_State* L, T&& t, Args&&... args) {
7775 template <
typename T,
typename Arg,
typename... Args,
typename = std::enable_if_t<!std::is_same<T, Arg>::value>>
7776 inline int push(lua_State* L, Arg&& arg, Args&&... args) {
7780 template <
typename T,
typename... Args>
7782 return stack_detail::push_reference<T>(L, std::forward<T>(t), std::forward<Args>(args)...);
7785 template <
typename T,
typename Arg,
typename... Args>
7787 return stack_detail::push_reference<T>(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
7795 template <
typename T,
typename... Args>
7797 int pushcount =
push(L, std::forward<T>(t));
7807 template <
typename T,
typename... Args>
7814 template <
typename T,
typename Handler>
7815 bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
7819 return c.
check(L, index, std::forward<Handler>(
handler), tracking);
7822 template <
typename T,
typename Handler>
7823 bool check(lua_State* L,
int index, Handler&& handler) {
7825 return check<T>(L, index, std::forward<Handler>(
handler), tracking);
7828 template <
typename T>
7831 return check<T>(L, index,
handler);
7834 template <
typename T,
typename Handler>
7840 return c.
check(L, index, std::forward<Handler>(
handler), tracking);
7843 template <
typename T,
typename Handler>
7846 return unqualified_check<T>(L, index, std::forward<Handler>(
handler), tracking);
7849 template <
typename T>
7852 return unqualified_check<T>(L, index,
handler);
7855 template <
typename T,
typename Handler>
7858 return stack_detail::check_usertype<T>(std::is_pointer<T>(), L, index, indextype, std::forward<Handler>(
handler), tracking);
7861 template <
typename T,
typename Handler>
7864 return check_usertype<T>(L, index, std::forward<Handler>(
handler), tracking);
7867 template <
typename T>
7870 return check_usertype<T>(L, index,
handler);
7873 template <
typename T,
typename Handler>
7878 return cg.
get(L, index, std::forward<Handler>(handler), tracking);
7881 template <
typename T,
typename Handler>
7884 return unqualified_check_get<T>(L, index, handler, tracking);
7887 template <
typename T>
7890 return unqualified_check_get<T>(L, index,
handler);
7893 template <
typename T,
typename Handler>
7894 inline decltype(
auto)
check_get(lua_State* L,
int index, Handler&& handler,
record& tracking) {
7897 return cg.
get(L, index, std::forward<Handler>(handler), tracking);
7900 template <
typename T,
typename Handler>
7901 inline decltype(
auto)
check_get(lua_State* L,
int index, Handler&& handler) {
7903 return check_get<T>(L, index, handler, tracking);
7906 template <
typename T>
7909 return check_get<T>(L, index,
handler);
7912 namespace stack_detail {
7914 #if defined(SOL_SAFE_GETTER) && SOL_SAFE_GETTER 7915 template <
typename T>
7918 return stack_detail::unchecked_unqualified_get<T>(L, index, tracking);
7921 return *std::move(op);
7924 template <
typename T>
7926 return stack_detail::unchecked_unqualified_get<optional<T>>(L, index, tracking);
7929 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 7930 template <
typename T>
7932 return stack_detail::unchecked_unqualified_get<std::optional<T>>(L, index, tracking);
7934 #endif // shitty optional 7936 template <
typename T>
7937 inline auto tagged_get(
types<T>, lua_State* L,
int index,
record& tracking) -> decltype(stack_detail::unchecked_get<T>(L, index, tracking)) {
7939 return stack_detail::unchecked_get<T>(L, index, tracking);
7942 return *std::move(op);
7945 template <
typename T>
7947 return stack_detail::unchecked_get<optional<T>>(L, index, tracking);
7950 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 7951 template <
typename T>
7952 inline decltype(
auto)
tagged_get(
types<std::optional<T>>, lua_State* L,
int index,
record& tracking) {
7953 return stack_detail::unchecked_get<std::optional<T>>(L, index, tracking);
7955 #endif // shitty optional 7958 template <
typename T>
7960 return stack_detail::unchecked_unqualified_get<T>(L, index, tracking);
7963 template <
typename T>
7965 return stack_detail::unchecked_get<T>(L, index, tracking);
7971 template <
typename T,
typename... Args,
typename Handler>
7973 if (!stack::check<T>(L, firstargument + tracking.
used,
handler, tracking))
7978 template <
typename Handler>
7986 template <
typename... Args,
typename Handler>
7994 template <
bool b,
typename... Args,
typename Handler>
7999 template <
bool b,
typename... Args,
typename Handler>
8005 template <
bool b,
typename... Args>
8011 template <
typename... Args,
typename Handler>
8013 return multi_check<
true, Args...>(L, index, std::forward<Handler>(
handler), tracking);
8016 template <
typename... Args,
typename Handler>
8021 template <
typename... Args>
8026 template <
typename T>
8028 #if defined(SOL_SAFE_GETTER) && SOL_SAFE_GETTER 8035 template <
typename T>
8038 return get_usertype<T>(L, index, tracking);
8041 template <
typename T>
8046 template <
typename T>
8049 return unqualified_get<T>(L, index, tracking);
8052 template <
typename T>
8053 inline decltype(
auto)
get(lua_State* L,
int index,
record& tracking) {
8057 template <
typename T>
8060 return get<T>(L, index, tracking);
8063 template <
typename T>
8064 inline decltype(
auto)
pop(lua_State* L) {
8068 template <
bool global = false,
bool raw = false,
typename Key>
8073 template <
bool global = false,
bool raw = false,
typename Key>
8078 template <
bool global = false,
typename Key>
8080 get_field<global, true>(L, std::forward<Key>(key));
8083 template <
bool global = false,
typename Key>
8085 get_field<global, true>(L, std::forward<Key>(key), tableindex);
8088 template <
bool global = false,
bool raw = false,
typename C = detail::non_lua_nil_t,
typename Key>
8093 template <
bool global = false,
bool raw = false,
typename C = detail::non_lua_nil_t,
typename Key>
8098 template <
bool global = false,
typename C = detail::non_lua_nil_t,
typename Key>
8100 return probe_get_field<global, true, C>(L, std::forward<Key>(key));
8103 template <
bool global = false,
typename C = detail::non_lua_nil_t,
typename Key>
8105 return probe_get_field<global, true, C>(L, std::forward<Key>(key), tableindex);
8108 template <
bool global = false,
bool raw = false,
typename Key,
typename Value>
8113 template <
bool global = false,
bool raw = false,
typename Key,
typename Value>
8114 void set_field(lua_State* L, Key&& key, Value&& value,
int tableindex) {
8118 template <
bool global = false,
typename Key,
typename Value>
8120 set_field<global, true>(L, std::forward<Key>(key), std::forward<Value>(value));
8123 template <
bool global = false,
typename Key,
typename Value>
8125 set_field<global, true>(L, std::forward<Key>(key), std::forward<Value>(value), tableindex);
8128 template <
typename T,
typename F>
8133 void* uu_memory = detail::align_usertype_unique<T>(raw);
8134 T& uu = *
static_cast<T*
>(uu_memory);
8136 *
static_cast<void**
>(ptr_memory) = static_cast<void*>(
u_traits::get(uu));
8139 template <
typename F>
8142 typedef typename bt::template arg_at<0> T;
8143 modify_unique_usertype_as<meta::unqualified_t<T>>(obj, std::forward<F>(f));
8155 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 8156 #if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT 8157 #endif // SOL_STD_VARIANT 8158 #endif // SOL_CXX17_FEATURES 8162 namespace stack_detail {
8163 template <
typename T,
bool poptable = true>
8166 luaL_getmetatable(L, &metakey[0]);
8167 const type expectedmetatabletype =
static_cast<type>(lua_type(L, -1));
8169 if (lua_rawequal(L, -1, index) == 1) {
8170 lua_pop(L, 1 + static_cast<int>(poptable));
8178 template <type expected,
int (*check_func)(lua_State*,
int)>
8180 template <
typename Handler>
8181 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8183 bool success = check_func(L, index) == 1;
8193 template <
typename T,
typename>
8195 template <
typename Handler>
8201 template <
typename T, type expected,
typename>
8203 template <
typename Handler>
8204 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8207 bool success = expected == indextype;
8210 handler(L, index, expected, indextype,
"");
8216 template <
typename T, type expected,
typename C>
8219 template <
typename T>
8221 template <
typename Handler>
8222 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8224 #if SOL_LUA_VERSION >= 503 8225 #if defined(SOL_STRINGS_ARE_NUMBERS) && SOL_STRINGS_ARE_NUMBERS 8227 lua_tointegerx(L, index, &isnum);
8228 const bool success = isnum != 0;
8233 #elif (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION) 8235 if (lua_isinteger(L, index) == 1) {
8238 const bool success =
false;
8246 #endif // If numbers are enabled, use the imprecise check 8253 #if !defined(SOL_STRINGS_ARE_NUMBERS) || !SOL_STRINGS_ARE_NUMBERS 8261 #endif // Do not allow strings to be numbers 8262 #if (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION) 8264 const lua_Number v = lua_tonumberx(L, index, &isnum);
8265 const bool success = isnum != 0 &&
static_cast<lua_Number
>(llround(v)) == v;
8267 const bool success =
true;
8268 #endif // Safe numerics and number precision checking 8271 #if defined(SOL_STRINGS_ARE_NUMBERS) && SOL_STRINGS_ARE_NUMBERS 8278 #endif // Lua Version 5.3 versus others 8282 template <
typename T>
8284 template <
typename Handler>
8285 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8287 #if defined(SOL_STRINGS_ARE_NUMBERS) && SOL_STRINGS_ARE_NUMBERS 8288 bool success = lua_isnumber(L, index) == 1;
8302 #endif // Strings are Numbers 8306 template <type expected,
typename C>
8308 template <
typename Handler>
8309 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8310 bool success = lua_isnil(L, index);
8316 success = lua_isnone(L, index);
8325 template <
typename C>
8327 template <
typename Handler>
8328 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8329 return !stack::unqualified_check<lua_nil_t>(L, index, std::forward<Handler>(
handler), tracking);
8333 template <type expected,
typename C>
8336 template <
typename C>
8338 template <
typename Handler>
8345 template <
typename C>
8347 template <
typename Handler>
8354 template <
typename C>
8356 template <
typename Handler>
8363 template <
typename C>
8365 template <
typename Handler>
8372 template <
typename C>
8374 template <
typename Handler>
8381 template <
typename T,
typename C>
8383 template <
typename Handler>
8384 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8395 template <
typename T,
typename C>
8397 template <
typename Handler>
8398 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8410 template <
typename C>
8412 template <
typename Handler>
8413 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8425 template <
typename B,
typename C>
8427 template <
typename Handler>
8428 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8429 return stack::check<userdata_value>(L, index, std::forward<Handler>(
handler), tracking);
8433 template <
typename T,
typename C>
8436 template <
typename T,
typename C>
8439 template <
typename C>
8441 template <
typename C>
8443 template <
typename C>
8446 template <
typename T,
typename C>
8448 template <
typename Handler>
8449 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8462 if (lua_getmetatable(L, index) == 0) {
8464 handler(L, index,
type::function, t,
"value is not a function and does not have overriden metatable");
8467 if (lua_isnoneornil(L, -1)) {
8472 lua_getfield(L, -1, &callkey[0]);
8473 if (lua_isnoneornil(L, -1)) {
8475 handler(L, index,
type::function, t,
"value's metatable does not have __call overridden in metatable, cannot call this type");
8484 template <
typename T,
typename C>
8486 template <
typename Handler>
8487 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8494 handler(L, index,
type::table, t,
"value is not a table or a userdata that can behave like one");
8501 template <type expected,
typename C>
8503 template <
typename Handler>
8504 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8506 if (lua_getmetatable(L, index) == 0) {
8516 handler(L, index, expected, t,
"value does not have a valid metatable");
8523 template <
typename C>
8525 template <
typename Handler>
8526 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8537 template <
typename E,
typename C>
8539 template <
typename Handler>
8540 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8542 if (lua_getmetatable(L, index) == 0) {
8559 template <
typename T,
typename C>
8561 template <
typename Handler>
8562 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8563 const type indextype =
type_of(L, index);
8567 template <
typename U,
typename Handler>
8569 #if defined(SOL_ENABLE_INTEROP) && SOL_ENABLE_INTEROP 8572 if (uc.
check(L, index, indextype,
handler, tracking)) {
8575 #endif // interop extensibility 8581 if (
meta::any<std::is_same<T, lightuserdata_value>, std::is_same<T, userdata_value>, std::is_same<T, userdata>, std::is_same<T, lightuserdata>>::value)
8583 if (lua_getmetatable(L, index) == 0) {
8586 int metatableindex = lua_gettop(L);
8587 if (stack_detail::check_metatable<U>(L, metatableindex))
8589 if (stack_detail::check_metatable<U*>(L, metatableindex))
8595 bool success =
false;
8599 lua_rawget(L, metatableindex);
8601 void* basecastdata = lua_touserdata(L, -1);
8608 handler(L, index,
type::userdata, indextype,
"value at this index does not properly reflect the desired type");
8616 template <
typename T,
typename C>
8618 template <
typename Handler>
8619 static bool check(lua_State* L,
int index, type indextype, Handler&& handler,
record& tracking) {
8624 return stack_detail::check_usertype<T>(std::false_type(), L, index, indextype, std::forward<Handler>(
handler), tracking);
8627 template <
typename Handler>
8628 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8629 const type indextype =
type_of(L, index);
8634 template <
typename T,
typename C>
8636 template <
typename Handler>
8637 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8638 return check_usertype<T>(L, index, std::forward<Handler>(
handler), tracking);
8642 template <
typename T,
typename C>
8644 template <
typename Handler>
8645 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8646 return check_usertype<T*>(L, index, std::forward<Handler>(
handler), tracking);
8650 template <
typename X>
8653 template <
typename Handler>
8654 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8655 const type indextype =
type_of(L, index);
8657 if (indextype != type::userdata) {
8658 handler(L, index, type::userdata, indextype,
"value is not a userdata");
8661 if (lua_getmetatable(L, index) == 0) {
8664 int metatableindex = lua_gettop(L);
8666 void*
memory = lua_touserdata(L, index);
8669 bool success = &detail::usertype_unique_alloc_destroy<T, X> == pdx;
8671 memory = detail::align_usertype_unique_tag<true>(memory);
8675 const char*& name_tag = *
static_cast<const char**
>(memory);
8679 handler(L, index, type::userdata, indextype,
"value is a userdata but is not the correct unique usertype");
8685 handler(L, index, type::userdata, indextype,
"unrecognized userdata (not pushed by sol?)");
8690 template <
typename T,
typename C>
8691 struct checker<std::reference_wrapper<T>, type::userdata, C> {
8692 template <
typename Handler>
8693 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8694 return stack::check<T>(L, index, std::forward<Handler>(
handler), tracking);
8698 template <
typename... Args,
typename C>
8700 template <
typename Handler>
8701 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8706 template <
typename A,
typename B,
typename C>
8708 template <
typename Handler>
8709 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8710 return stack::multi_check<A, B>(L, index, std::forward<Handler>(
handler), tracking);
8714 template <
typename T,
typename C>
8716 template <
typename Handler>
8717 static bool check(lua_State* L,
int index, Handler&&,
record& tracking) {
8727 return stack::check<T>(L, index,
no_panic, tracking);
8731 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 8733 template <
typename T,
typename C>
8735 template <
typename Handler>
8736 static bool check(lua_State* L,
int index, Handler&&,
record& tracking) {
8746 return stack::check<T>(L, index,
no_panic, tracking);
8750 #if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT 8752 template <
typename... Tn,
typename C>
8754 typedef std::variant<Tn...> V;
8755 typedef std::variant_size<V> V_size;
8756 typedef std::integral_constant<bool, V_size::value == 0> V_is_empty;
8758 template <
typename Handler>
8759 static bool is_one(std::integral_constant<std::size_t, 0>, lua_State* L,
int index, Handler&&
handler,
record& tracking) {
8760 if (V_is_empty::value && lua_isnone(L, index)) {
8768 template <std::
size_t I,
typename Handler>
8769 static bool is_one(std::integral_constant<std::size_t, I>, lua_State* L,
int index, Handler&&
handler,
record& tracking) {
8770 typedef std::variant_alternative_t<I - 1, V> T;
8771 record temp_tracking = tracking;
8772 if (stack::check<T>(L, index,
no_panic, temp_tracking)) {
8773 tracking = temp_tracking;
8776 return is_one(std::integral_constant<std::size_t, I - 1>(), L, index, std::forward<Handler>(
handler), tracking);
8779 template <
typename Handler>
8781 return is_one(std::integral_constant<std::size_t, V_size::value>(), L, index, std::forward<Handler>(
handler), tracking);
8785 #endif // SOL_STD_VARIANT 8787 #endif // SOL_CXX17_FEATURES 8799 template <
typename X>
8800 struct qualified_checker<X, type::
userdata, std::enable_if_t<is_unique_usertype<X>::value && !std::is_reference<X>::value>> {
8804 template <
typename Handler>
8805 static bool check(std::false_type, lua_State* L,
int index, Handler&&
handler,
record& tracking) {
8806 return stack::unqualified_check<X>(L, index, std::forward<Handler>(
handler), tracking);
8809 template <
typename Handler>
8810 static bool check(std::true_type, lua_State* L,
int index, Handler&&
handler,
record& tracking) {
8813 const type indextype =
type_of(L, index);
8819 if (lua_getmetatable(L, index) == 0) {
8822 int metatableindex = lua_gettop(L);
8823 void* basecastdata = lua_touserdata(L, index);
8826 if (&detail::usertype_unique_alloc_destroy<T, X> == pdx) {
8830 memory = detail::align_usertype_unique_cast<
true>(memory);
8834 if (ic(
nullptr, basecastdata, ti, rebind_ti)) {
8838 handler(L, index,
type::userdata, indextype,
"value is a userdata but is not the correct unique usertype");
8842 template <
typename Handler>
8844 return check(
meta::neg<std::is_void<typename u_traits::base_id>>(), L, index, std::forward<Handler>(
handler), tracking);
8848 #endif // Not implemented right now... 8850 template <
typename X>
8851 struct qualified_checker<X, type::
userdata, std::enable_if_t<is_container<meta::unqualified_t<X>>::value && !std::is_reference<X>::value>> {
8852 template <
typename Handler>
8853 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
8855 return stack::unqualified_check<X>(L, index, std::forward<Handler>(
handler), tracking);
8858 return stack::unqualified_check<nested<X>>(L, index, std::forward<Handler>(
handler), tracking);
8876 template <
typename... Functions>
8881 : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {
8889 template <
typename... Args>
8916 "invalid code points",
8917 "invalid code unit",
8920 return arr[
static_cast<std::size_t
>(ec)];
8923 template <
typename It>
8930 template <
typename C>
8939 static constexpr char32_t last_code_point = 0x10FFFF;
8941 static constexpr char32_t first_lead_surrogate = 0xD800;
8942 static constexpr char32_t last_lead_surrogate = 0xDBFF;
8944 static constexpr char32_t first_trail_surrogate = 0xDC00;
8945 static constexpr char32_t last_trail_surrogate = 0xDFFF;
8947 static constexpr char32_t first_surrogate = first_lead_surrogate;
8948 static constexpr char32_t last_surrogate = last_trail_surrogate;
8951 return u >= first_lead_surrogate && u <= last_lead_surrogate;
8954 return u >= first_trail_surrogate && u <= last_trail_surrogate;
8957 return u >= first_surrogate && u <= last_surrogate;
8961 static constexpr
auto last_1byte_value = 0x7Fu;
8962 static constexpr
auto last_2byte_value = 0x7FFu;
8963 static constexpr
auto last_3byte_value = 0xFFFFu;
8965 static constexpr
auto start_2byte_mask = 0x80u;
8966 static constexpr
auto start_3byte_mask = 0xE0u;
8967 static constexpr
auto start_4byte_mask = 0xF0u;
8969 static constexpr
auto continuation_mask = 0xC0u;
8970 static constexpr
auto continuation_signature = 0x80u;
8973 return (b & start_2byte_mask) == 0 ? 1
8974 : (b & start_3byte_mask) != start_3byte_mask ? 2
8975 : (b & start_4byte_mask) != start_4byte_mask ? 3
8979 static constexpr char32_t
decode(
unsigned char b0,
unsigned char b1) {
8980 return ((b0 & 0x1F) << 6) | (b1 & 0x3F);
8982 static constexpr char32_t
decode(
unsigned char b0,
unsigned char b1,
unsigned char b2) {
8983 return ((b0 & 0x0F) << 12) | ((b1 & 0x3F) << 6) | (b2 & 0x3F);
8985 static constexpr char32_t
decode(
unsigned char b0,
unsigned char b1,
unsigned char b2,
unsigned char b3) {
8986 return ((b0 & 0x07) << 18) | ((b1 & 0x3F) << 12) | ((b2 & 0x3F) << 6) | (b3 & 0x3F);
8990 static constexpr char32_t last_bmp_value = 0xFFFF;
8991 static constexpr char32_t normalizing_value = 0x10000;
8992 static constexpr
int lead_surrogate_bitmask = 0xFFC00;
8993 static constexpr
int trail_surrogate_bitmask = 0x3FF;
8994 static constexpr
int lead_shifted_bits = 10;
8995 static constexpr char32_t replacement = 0xFFFD;
8998 auto hi = lead - first_lead_surrogate;
8999 auto lo = trail - first_trail_surrogate;
9000 return normalizing_value + ((hi << lead_shifted_bits) | lo);
9007 if (codepoint <= unicode_detail::last_1byte_value) {
9009 er.
code_units = std::array<char, 4>{ {
static_cast<char>(codepoint) } };
9011 else if (codepoint <= unicode_detail::last_2byte_value) {
9014 static_cast<char>(0xC0 | ((codepoint & 0x7C0) >> 6)),
9015 static_cast<char>(0x80 | (codepoint & 0x3F)),
9018 else if (codepoint <= unicode_detail::last_3byte_value) {
9021 static_cast<char>(0xE0 | ((codepoint & 0xF000) >> 12)),
9022 static_cast<char>(0x80 | ((codepoint & 0xFC0) >> 6)),
9023 static_cast<char>(0x80 | (codepoint & 0x3F)),
9029 static_cast<char>(0xF0 | ((codepoint & 0x1C0000) >> 18)),
9030 static_cast<char>(0x80 | ((codepoint & 0x3F000) >> 12)),
9031 static_cast<char>(0x80 | ((codepoint & 0xFC0) >> 6)),
9032 static_cast<char>(0x80 | (codepoint & 0x3F)),
9041 if (codepoint <= unicode_detail::last_bmp_value) {
9043 er.
code_units = std::array<char16_t, 4>{ {
static_cast<char16_t
>(codepoint) } };
9047 auto normal = codepoint - unicode_detail::normalizing_value;
9048 auto lead = unicode_detail::first_lead_surrogate + ((normal & unicode_detail::lead_surrogate_bitmask) >> unicode_detail::lead_shifted_bits);
9049 auto trail = unicode_detail::first_trail_surrogate + (normal & unicode_detail::trail_surrogate_bitmask);
9051 static_cast<char16_t
>(lead),
9052 static_cast<char16_t>(trail)
9068 template <
typename It>
9073 dr.
error = error_code::sequence_too_short;
9077 unsigned char b0 = *it;
9078 std::size_t
length = unicode_detail::sequence_length(b0);
9081 dr.
codepoint =
static_cast<char32_t
>(b0);
9088 auto is_invalid = [](
unsigned char b) {
return b == 0xC0 || b == 0xC1 || b > 0xF4; };
9089 auto is_continuation = [](
unsigned char b) {
9090 return (b & unicode_detail::continuation_mask) == unicode_detail::continuation_signature;
9093 if (is_invalid(b0) || is_continuation(b0)) {
9094 dr.
error = error_code::invalid_code_unit;
9100 std::array<unsigned char, 4> b;
9102 for (std::size_t i = 1; i < length; ++i) {
9104 if (!is_continuation(b[i])) {
9105 dr.
error = error_code::invalid_code_unit;
9115 decoded = unicode_detail::decode(b[0], b[1]);
9118 decoded = unicode_detail::decode(b[0], b[1], b[2]);
9121 decoded = unicode_detail::decode(b[0], b[1], b[2], b[3]);
9125 auto is_overlong = [](char32_t u, std::size_t bytes) {
9126 return u <= unicode_detail::last_1byte_value
9127 || (u <= unicode_detail::last_2byte_value && bytes > 2)
9128 || (u <= unicode_detail::last_3byte_value && bytes > 3);
9130 if (is_overlong(decoded, length)) {
9131 dr.
error = error_code::overlong_sequence;
9134 if (unicode_detail::is_surrogate(decoded) || decoded > unicode_detail::last_code_point) {
9135 dr.
error = error_code::invalid_code_point;
9146 template <
typename It>
9151 dr.
error = error_code::sequence_too_short;
9155 char16_t lead =
static_cast<char16_t
>(*it);
9157 if (!unicode_detail::is_surrogate(lead)) {
9159 dr.
codepoint =
static_cast<char32_t
>(lead);
9164 if (!unicode_detail::is_lead_surrogate(lead)) {
9165 dr.
error = error_code::invalid_leading_surrogate;
9172 if (!unicode_detail::is_trail_surrogate(trail)) {
9173 dr.
error = error_code::invalid_trailing_surrogate;
9178 dr.
codepoint = unicode_detail::combine_surrogates(lead, trail);
9184 template <
typename It>
9189 dr.
error = error_code::sequence_too_short;
9192 dr.
codepoint =
static_cast<char32_t
>(*it);
9201 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 9202 #if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT 9203 #endif // Apple clang screwed up 9209 template <
typename U>
9213 static std::pair<bool, T*>
get(lua_State*, int,
void*,
record&) {
9214 return {
false,
nullptr };
9218 template <
typename T,
typename>
9220 static T&
get(lua_State* L,
int index,
record& tracking) {
9225 template <
typename T,
typename C>
9228 template <
typename T>
9229 struct getter<T, std::enable_if_t<std::is_floating_point<T>::value>> {
9230 static T
get(lua_State* L,
int index,
record& tracking) {
9232 return static_cast<T
>(lua_tonumber(L, index));
9236 template <
typename T>
9237 struct getter<T, std::enable_if_t<std::is_integral<T>::value>> {
9238 static T
get(lua_State* L,
int index,
record& tracking) {
9240 #if SOL_LUA_VERSION >= 503 9241 if (lua_isinteger(L, index) != 0) {
9242 return static_cast<T
>(lua_tointeger(L, index));
9245 return static_cast<T
>(llround(lua_tonumber(L, index)));
9249 template <
typename T>
9250 struct getter<T, std::enable_if_t<std::is_enum<T>::value>> {
9251 static T
get(lua_State* L,
int index,
record& tracking) {
9253 return static_cast<T
>(lua_tointegerx(L, index,
nullptr));
9257 template <
typename T>
9261 template <
typename V>
9266 template <
typename V>
9271 template <
typename V>
9277 template <
typename V>
9287 return idx >= arr.max_size();
9290 static T
get(lua_State* L,
int relindex,
record& tracking) {
9294 static T
get(std::false_type, lua_State* L,
int relindex,
record& tracking) {
9295 typedef typename T::value_type V;
9296 return get(
types<V>(), L, relindex, tracking);
9299 template <
typename V>
9303 int index = lua_absindex(L, relindex);
9305 std::size_t idx = 0;
9306 #if SOL_LUA_VERSION >= 503 9314 for (
int vi = 0; vi < lua_size<V>::value; ++vi) {
9315 #if defined(LUA_NILINTABLE) && LUA_NILINTABLE 9316 lua_pushinteger(L, static_cast<lua_Integer>(i + vi));
9317 if (lua_keyin(L, index) == 0) {
9323 lua_geti(L, index, i + vi);
9326 type vt =
static_cast<type>(lua_geti(L, index, i + vi));
9334 #if defined(LUA_NILINTABLE) && LUA_NILINTABLE 9337 lua_pop(L, (vi + 1));
9343 #if defined(LUA_NILINTABLE) && LUA_NILINTABLE 9356 if (idx >= arr.max_size()) {
9360 for (
int vi = 0; vi < lua_size<V>::value; ++vi) {
9361 lua_pushinteger(L, i);
9362 lua_gettable(L, index);
9369 lua_pop(L, (vi + 1));
9382 static T
get(std::true_type, lua_State* L,
int index,
record& tracking) {
9383 typedef typename T::value_type P;
9384 typedef typename P::first_type K;
9385 typedef typename P::second_type V;
9389 template <
typename K,
typename V>
9394 int index = lua_absindex(L, relindex);
9396 while (lua_next(L, index) != 0) {
9397 decltype(
auto) key = stack::check_get<K>(L, -2);
9402 associative.emplace(std::forward<decltype(*key)>(*key), stack::get<V>(L, -1));
9409 template <
typename T,
typename Al>
9411 typedef std::forward_list<T, Al>
C;
9413 static C
get(lua_State* L,
int relindex,
record& tracking) {
9417 static C
get(std::true_type, lua_State* L,
int index,
record& tracking) {
9418 typedef typename T::value_type P;
9419 typedef typename P::first_type K;
9420 typedef typename P::second_type V;
9424 static C
get(std::false_type, lua_State* L,
int relindex,
record& tracking) {
9425 typedef typename C::value_type V;
9426 return get(
types<V>(), L, relindex, tracking);
9429 template <
typename V>
9433 int index = lua_absindex(L, relindex);
9435 auto at = arr.cbefore_begin();
9436 std::size_t idx = 0;
9437 #if SOL_LUA_VERSION >= 503 9440 if (idx >= arr.max_size()) {
9444 for (
int vi = 0; vi < lua_size<V>::value; ++vi) {
9445 type t =
static_cast<type>(lua_geti(L, index, i + vi));
9451 lua_pop(L, (vi + 1));
9463 if (idx >= arr.max_size()) {
9467 for (
int vi = 0; vi < lua_size<V>::value; ++vi) {
9468 lua_pushinteger(L, i);
9469 lua_gettable(L, index);
9476 lua_pop(L, (vi + 1));
9489 template <
typename K,
typename V>
9494 auto at = associative.cbefore_begin();
9495 int index = lua_absindex(L, relindex);
9497 while (lua_next(L, index) != 0) {
9498 decltype(
auto) key = stack::check_get<K>(L, -2);
9503 at = associative.emplace_after(at, std::forward<decltype(*key)>(*key), stack::get<V>(L, -1));
9510 template <
typename T>
9512 static T
get(lua_State* L,
int index,
record& tracking) {
9516 return g.
get(L, index, tracking);
9520 template <
typename T>
9521 struct getter<
nested<T>, std::enable_if_t<meta::all<is_container<T>, meta::neg<meta::has_key_value_pair<meta::unqualified_t<T>>>>::value>> {
9522 static T
get(lua_State* L,
int index,
record& tracking) {
9523 typedef typename T::value_type V;
9531 template <
typename T>
9532 struct getter<
nested<T>, std::enable_if_t<meta::all<is_container<T>, meta::has_key_value_pair<meta::unqualified_t<T>>>::value>> {
9533 static T
get(lua_State* L,
int index,
record& tracking) {
9534 typedef typename T::value_type P;
9535 typedef typename P::first_type K;
9536 typedef typename P::second_type V;
9544 template <
typename T>
9545 struct getter<T, std::enable_if_t<is_lua_reference<T>::value>> {
9546 static T
get(lua_State* L,
int index,
record& tracking) {
9568 template <
typename T>
9572 void*
memory = lua_touserdata(L, index);
9573 return light<T>(
static_cast<T*
>(memory));
9577 template <
typename T>
9579 static std::add_lvalue_reference_t<T>
get(lua_State* L,
int index,
record& tracking) {
9581 void*
memory = lua_touserdata(L, index);
9582 memory = detail::align_user<T>(memory);
9583 return *
static_cast<std::remove_reference_t<T>*
>(memory);
9587 template <
typename T>
9589 static T*
get(lua_State* L,
int index,
record& tracking) {
9591 void*
memory = lua_touserdata(L, index);
9592 memory = detail::align_user<T*>(memory);
9593 return static_cast<T*
>(memory);
9601 return static_cast<type>(lua_type(L, index));
9607 static bool get(lua_State* L,
int index,
record& tracking) {
9609 return lua_toboolean(L, index) != 0;
9618 auto str = lua_tolstring(L, index, &len);
9625 static const char*
get(lua_State* L,
int index,
record& tracking) {
9628 return lua_tolstring(L, index, &sz);
9634 static char get(lua_State* L,
int index,
record& tracking) {
9637 auto str = lua_tolstring(L, index, &len);
9638 return len > 0 ? str[0] :
'\0';
9642 template <
typename Traits>
9647 const char* str = lua_tolstring(L, index, &sz);
9652 template <
typename Traits,
typename Al>
9653 struct getter<std::basic_string<wchar_t, Traits, Al>> {
9654 typedef std::basic_string<wchar_t, Traits, Al>
S;
9655 static S
get(lua_State* L,
int index,
record& tracking) {
9656 typedef std::conditional_t<sizeof(wchar_t) == 2, char16_t, char32_t> Ch;
9657 typedef typename std::allocator_traits<Al>::template rebind_alloc<Ch> ChAl;
9658 typedef std::char_traits<Ch> ChTraits;
9661 return g.template get_into<S>(L, index, tracking);
9665 template <
typename Traits,
typename Al>
9666 struct getter<std::basic_string<char16_t, Traits, Al>> {
9667 template <
typename F>
9668 static void convert(
const char* strb,
const char* stre, F&& f) {
9670 for (
const char* strtarget = strb; strtarget < stre;) {
9678 strtarget = dr.next;
9685 template <
typename S>
9687 typedef typename S::value_type Ch;
9690 auto utf8p = lua_tolstring(L, index, &len);
9693 std::size_t needed_size = 0;
9694 const char* strb = utf8p;
9695 const char* stre = utf8p + len;
9697 needed_size += er.code_units_size;
9699 convert(strb, stre, count_units);
9700 S r(needed_size, static_cast<Ch>(0));
9701 r.resize(needed_size);
9704 std::memcpy(target, er.code_units.data(), er.code_units_size *
sizeof(Ch));
9705 target += er.code_units_size;
9707 convert(strb, stre, copy_units);
9711 static std::basic_string<char16_t, Traits, Al>
get(lua_State* L,
int index,
record& tracking) {
9712 return get_into<std::basic_string<char16_t, Traits, Al>>(L, index, tracking);
9716 template <
typename Traits,
typename Al>
9717 struct getter<std::basic_string<char32_t, Traits, Al>> {
9718 template <
typename F>
9719 static void convert(
const char* strb,
const char* stre, F&& f) {
9721 for (
const char* strtarget = strb; strtarget < stre;) {
9729 strtarget = dr.next;
9736 template <
typename S>
9738 typedef typename S::value_type Ch;
9741 auto utf8p = lua_tolstring(L, index, &len);
9744 std::size_t needed_size = 0;
9745 const char* strb = utf8p;
9746 const char* stre = utf8p + len;
9748 needed_size += er.code_units_size;
9750 convert(strb, stre, count_units);
9751 S r(needed_size, static_cast<Ch>(0));
9752 r.resize(needed_size);
9755 std::memcpy(target, er.code_units.data(), er.code_units_size *
sizeof(Ch));
9756 target += er.code_units_size;
9758 convert(strb, stre, copy_units);
9762 static std::basic_string<char32_t, Traits, Al>
get(lua_State* L,
int index,
record& tracking) {
9763 return get_into<std::basic_string<char32_t, Traits, Al>>(L, index, tracking);
9769 static char16_t
get(lua_State* L,
int index,
record& tracking) {
9771 const char* strb = utf8.
data();
9772 const char* stre = utf8.
data() + utf8.
size();
9782 return er.code_units[0];
9788 static char32_t
get(lua_State* L,
int index,
record& tracking) {
9790 const char* strb = utf8.
data();
9791 const char* stre = utf8.
data() + utf8.
size();
9801 return er.code_units[0];
9807 static wchar_t get(lua_State* L,
int index,
record& tracking) {
9808 typedef std::conditional_t<sizeof(wchar_t) == 2, char16_t, char32_t> Ch;
9811 auto c = g.
get(L, index, tracking);
9812 return static_cast<wchar_t>(c);
9822 for (std::size_t i = 0; i < mfnames.size(); ++i)
9823 if (mfnames[i] == name)
9839 static std::nullptr_t
get(lua_State*, int,
record& tracking) {
9871 static lua_CFunction
get(lua_State* L,
int index,
record& tracking) {
9873 return lua_tocfunction(L, index);
9881 return c_closure(lua_tocfunction(L, index), -1);
9890 const char* err = lua_tolstring(L, index, &sz);
9891 if (err ==
nullptr) {
9900 static void*
get(lua_State* L,
int index,
record& tracking) {
9902 return lua_touserdata(L, index);
9908 static const void*
get(lua_State* L,
int index,
record& tracking) {
9910 return lua_touserdata(L, index);
9914 template <
typename T>
9917 void*
memory = lua_touserdata(L, index);
9918 #if defined(SOL_ENABLE_INTEROP) && SOL_ENABLE_INTEROP 9921 auto ugr = ug.get(L, index, memory, tracking);
9925 #endif // interop extensibility 9928 void** pudata =
static_cast<void**
>(rawdata);
9929 void* udata = *pudata;
9930 return get_no_lua_nil_from(L, udata, index, tracking);
9935 void* basecastdata = lua_touserdata(L, -1);
9941 T* obj =
static_cast<T*
>(udata);
9945 static T&
get(lua_State* L,
int index,
record& tracking) {
9946 return *get_no_lua_nil(L, index, tracking);
9950 template <
typename T>
9952 static T*
get(lua_State* L,
int index,
record& tracking) {
9961 return g.get_no_lua_nil(L, index, tracking);
9965 template <
typename T>
9967 static T*
get(lua_State* L,
int index,
record& tracking) {
9971 return g.get_no_lua_nil(L, index, tracking);
9975 template <
typename T>
9977 static T&
get(lua_State* L,
int index,
record& tracking) {
9981 return g.
get(L, index, tracking);
9985 template <
typename T>
9987 static T&
get(lua_State* L,
int index,
record& tracking) {
9991 return g.
get(L, index, tracking);
9995 template <
typename T>
9997 static T*
get(lua_State* L,
int index,
record& tracking) {
10001 return g.
get(L, index, tracking);
10005 template <
typename T>
10006 struct getter<T, std::enable_if_t<is_unique_usertype<T>::value>> {
10010 static Real&
get(lua_State* L,
int index,
record& tracking) {
10012 void*
memory = lua_touserdata(L, index);
10013 memory = detail::align_usertype_unique<Real>(memory);
10014 Real* mem =
static_cast<Real*
>(memory);
10019 template <
typename... Tn>
10021 typedef std::tuple<decltype(stack::get<Tn>(
nullptr, 0))...>
R;
10023 template <
typename... Args>
10024 static R apply(std::index_sequence<>, lua_State*,
int,
record&, Args&&... args) {
10026 return R{ std::forward<Args>(args)... };
10029 template <std::size_t I, std::size_t... Ix,
typename... Args>
10030 static R apply(std::index_sequence<I, Ix...>, lua_State* L,
int index,
record& tracking, Args&&... args) {
10033 return apply(std::index_sequence<Ix...>(), L, index, tracking, std::forward<Args>(args)..., stack::get<T>(L, index + tracking.
used, tracking));
10036 static R get(lua_State* L,
int index,
record& tracking) {
10037 return apply(std::make_index_sequence<
sizeof...(Tn)>(), L, index, tracking);
10041 template <
typename A,
typename B>
10043 static decltype(
auto)
get(lua_State* L,
int index,
record& tracking) {
10044 return std::pair<decltype(stack::get<A>(L, index)), decltype(stack::get<B>(L, index))>{ stack::get<A>(L, index, tracking), stack::get<B>(L, index + tracking.used, tracking) };
10048 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 10050 #if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT 10051 template <
typename... Tn>
10052 struct getter<std::variant<Tn...>> {
10053 typedef std::variant<Tn...> V;
10054 typedef std::variant_size<V> V_size;
10055 typedef std::integral_constant<bool, V_size::value == 0> V_is_empty;
10057 static V get_empty(std::true_type, lua_State*,
int,
record&) {
10061 static V get_empty(std::false_type, lua_State* L,
int index,
record& tracking) {
10062 typedef std::variant_alternative_t<0, V> T;
10066 return V(std::in_place_index<0>, stack::get<T>(L, index, tracking));
10069 static V get_one(std::integral_constant<std::size_t, 0>, lua_State* L,
int index,
record& tracking) {
10070 return get_empty(V_is_empty(), L, index, tracking);
10073 template <std::
size_t I>
10074 static V get_one(std::integral_constant<std::size_t, I>, lua_State* L,
int index,
record& tracking) {
10075 typedef std::variant_alternative_t<I - 1, V> T;
10076 record temp_tracking = tracking;
10077 if (stack::check<T>(L, index,
no_panic, temp_tracking)) {
10078 tracking = temp_tracking;
10079 return V(std::in_place_index<I - 1>, stack::get<T>(L, index));
10081 return get_one(std::integral_constant<std::size_t, I - 1>(), L, index, tracking);
10084 static V
get(lua_State* L,
int index,
record& tracking) {
10085 return get_one(std::integral_constant<std::size_t, V_size::value>(), L, index, tracking);
10088 #endif // SOL_STD_VARIANT 10089 #endif // SOL_CXX17_FEATURES 10100 #if 0 // need static reflection / DERIVED_CLASS macros... 10101 template <
typename X>
10103 !std::is_reference<X>::value && is_unique_usertype<meta::unqualified_t<X>>::value
10108 static Real&
get(lua_State* L,
int index,
record& tracking) {
10110 void*
memory = lua_touserdata(L, index);
10112 memory = detail::align_usertype_unique<Real>(memory);
10113 Real* mem =
static_cast<Real*
>(memory);
10117 #endif // need static reflection 10119 template <
typename T>
10121 !std::is_reference<T>::value
10122 && is_container<meta::unqualified_t<T>>::value
10123 && std::is_default_constructible<meta::unqualified_t<T>>::value
10124 && !is_lua_primitive<T>::value
10125 && !is_transparent_argument<T>::value
10127 static T
get(lua_State* L,
int index,
record& tracking) {
10129 return stack_detail::unchecked_unqualified_get<T>(L, index, tracking);
10132 return stack_detail::unchecked_unqualified_get<sol::nested<T>>(L, index, tracking);
10147 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 10152 template <
typename T,
typename>
10154 typedef decltype(stack_detail::unchecked_unqualified_get<T>(
nullptr, 0, std::declval<record&>())) R;
10156 template <typename Handler>
10158 if (!unqualified_check<T>(L, index, std::forward<Handler>(handler))) {
10159 tracking.use(static_cast<int>(!lua_isnone(L, index)));
10162 return stack_detail::unchecked_unqualified_get<T>(L, index, tracking);
10166 template <
typename T>
10168 template <
typename Handler>
10172 bool success = lua_isnoneornil(L, index) == 0 && stack::check<T>(L, index,
no_panic);
10175 tracking.use(static_cast<int>(success));
10179 return stack_detail::unchecked_get<T>(L, index, tracking);
10183 template <
typename T>
10184 struct check_getter<T, std::enable_if_t<std::is_integral<T>::value && lua_type_of<T>::value == type::number>> {
10185 template <
typename Handler>
10187 #if SOL_LUA_VERSION >= 503 10188 if (lua_isinteger(L, index) != 0) {
10190 return static_cast<T
>(lua_tointeger(L, index));
10194 const lua_Number value = lua_tonumberx(L, index, &isnum);
10196 #if (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION) 10197 const auto integer_value = llround(value);
10198 if (static_cast<lua_Number>(integer_value) == value) {
10200 return static_cast<T
>(integer_value);
10204 return static_cast<T
>(value);
10208 tracking.use(static_cast<int>(t !=
type::none));
10214 template <
typename T>
10215 struct check_getter<T, std::enable_if_t<std::is_enum<T>::value && !meta::any_same<T, meta_function, type>::value>> {
10216 template <
typename Handler>
10219 lua_Integer value = lua_tointegerx(L, index, &isnum);
10222 tracking.use(static_cast<int>(t !=
type::none));
10223 handler(L, index,
type::number, t,
"not a valid enumeration value");
10227 return static_cast<T
>(value);
10231 template <
typename T>
10233 template <
typename Handler>
10236 lua_Number value = lua_tonumberx(L, index, &isnum);
10239 tracking.use(static_cast<int>(t !=
type::none));
10240 handler(L, index,
type::number, t,
"not a valid floating point number");
10244 return static_cast<T
>(value);
10248 template <
typename T>
10250 static decltype(
auto)
get(lua_State* L,
int index,
record& tracking) {
10251 return check_get<T>(L, index,
no_panic, tracking);
10255 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 10256 template <
typename T>
10258 static std::optional<T>
get(lua_State* L,
int index,
record& tracking) {
10259 if (!unqualified_check<T>(L, index,
no_panic)) {
10260 tracking.use(static_cast<int>(!lua_isnone(L, index)));
10263 return stack_detail::unchecked_unqualified_get<T>(L, index, tracking);
10267 #if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT 10268 template <
typename... Tn>
10270 typedef std::variant<Tn...> V;
10271 typedef std::variant_size<V> V_size;
10272 typedef std::integral_constant<bool, V_size::value == 0> V_is_empty;
10274 template <
typename Handler>
10275 static optional<V> get_empty(std::true_type, lua_State*,
int, Handler&&,
record&) {
10279 template <
typename Handler>
10284 handler(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");
10288 template <
typename Handler>
10289 static optional<V> get_one(std::integral_constant<std::size_t, 0>, lua_State* L,
int index, Handler&&
handler,
record& tracking) {
10290 return get_empty(V_is_empty(), L, index, std::forward<Handler>(
handler), tracking);
10293 template <std::
size_t I,
typename Handler>
10294 static optional<V> get_one(std::integral_constant<std::size_t, I>, lua_State* L,
int index, Handler&&
handler,
record& tracking) {
10295 typedef std::variant_alternative_t<I - 1, V> T;
10296 if (stack::check<T>(L, index,
no_panic, tracking)) {
10297 return V(std::in_place_index<I - 1>, stack::get<T>(L, index));
10299 return get_one(std::integral_constant<std::size_t, I - 1>(), L, index, std::forward<Handler>(
handler), tracking);
10302 template <
typename Handler>
10304 return get_one(std::integral_constant<std::size_t, V_size::value>(), L, index, std::forward<Handler>(handler), tracking);
10307 #endif // SOL_STD_VARIANT 10308 #endif // SOL_CXX17_FEATURES 10318 template <
typename T,
typename C>
10330 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 10331 #if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT 10332 #endif // Can use variant 10338 #if SOL_LUA_VERSION < 502 10340 lua_getfenv(L, index);
10344 if (lua_getupvalue(L, index, 1) ==
nullptr) {
10352 template <
typename T>
10358 template <
typename T>
10360 template <
typename F,
typename... Args>
10361 static int push_fx(lua_State* L, F&& f, Args&&... args) {
10367 T* obj = detail::usertype_allocate<T>(L);
10368 std::allocator<T> alloc{};
10369 std::allocator_traits<std::allocator<T>>::construct(alloc, obj, std::forward<Args>(args)...);
10374 template <
typename K,
typename... Args>
10377 return push_fx(L, fx, std::forward<Args>(args)...);
10380 template <
typename... Args>
10381 static int push(lua_State* L, Args&&... args) {
10386 template <
typename T>
10390 template <
typename F>
10392 if (obj ==
nullptr)
10394 T** pref = detail::usertype_allocate_pointer<T>(L);
10400 template <
typename K>
10403 return push_fx(L, fx, obj);
10406 static int push(lua_State* L, T* obj) {
10413 template <
typename T>
10414 static int push(lua_State* L, T&& obj) {
10419 template <
typename T,
typename>
10421 template <
typename... Args>
10422 static int push(lua_State* L, Args&&... args) {
10427 template <
typename T>
10429 template <
typename... Args>
10430 static int push(lua_State* L, Args&&... args) {
10435 template <
typename T>
10436 struct pusher<T, std::enable_if_t<is_unique_usertype<T>::value>> {
10440 template <
typename Arg, meta::enable<std::is_base_of<Real, meta::unqualified_t<Arg>>> = meta::enabler>
10441 static int push(lua_State* L, Arg&& arg) {
10445 return push_deep(L, std::forward<Arg>(arg));
10448 template <
typename Arg0,
typename Arg1,
typename... Args>
10449 static int push(lua_State* L, Arg0&& arg0, Arg0&& arg1, Args&&... args) {
10450 return push_deep(L, std::forward<Arg0>(arg0), std::forward<Arg1>(arg1), std::forward<Args>(args)...);
10453 template <
typename... Args>
10455 P** pref =
nullptr;
10458 Real* mem = detail::usertype_unique_allocate<P, Real>(L, pref, fx, id);
10459 *fx = detail::usertype_unique_alloc_destroy<P, Real>;
10471 usertype_detail::insert_default_registrations<P>(l, index, prop_fx);
10472 usertype_detail::make_destructor<T>(l, index);
10473 luaL_setfuncs(L, l, 0);
10475 lua_setmetatable(L, -2);
10480 template <
typename T>
10482 static int push(lua_State* L,
const std::reference_wrapper<T>& t) {
10487 template <
typename T>
10488 struct pusher<T, std::enable_if_t<std::is_floating_point<T>::value>> {
10489 static int push(lua_State* L,
const T& value) {
10490 lua_pushnumber(L, value);
10495 template <
typename T>
10496 struct pusher<T, std::enable_if_t<std::is_integral<T>::value>> {
10497 static int push(lua_State* L,
const T& value) {
10498 #if SOL_LUA_VERSION >= 503 10499 static auto integer_value_fits = [](T
const& value) {
10500 if (
sizeof(T) <
sizeof(lua_Integer) || (std::is_signed<T>::value &&
sizeof(T) ==
sizeof(lua_Integer))) {
10503 auto u_min =
static_cast<std::intmax_t
>((std::numeric_limits<lua_Integer>::min)());
10504 auto u_max =
static_cast<std::uintmax_t
>((std::numeric_limits<lua_Integer>::max)());
10505 auto t_min =
static_cast<std::intmax_t
>((std::numeric_limits<T>::min)());
10506 auto t_max =
static_cast<std::uintmax_t
>((std::numeric_limits<T>::max)());
10507 return (u_min <= t_min || value >= static_cast<T>(u_min)) && (u_max >= t_max || value <= static_cast<T>(u_max));
10509 if (integer_value_fits(value)) {
10510 lua_pushinteger(L, static_cast<lua_Integer>(value));
10513 #endif // Lua 5.3 and above 10514 #if (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION) 10515 if (static_cast<T>(llround(static_cast<lua_Number>(value))) != value) {
10516 #if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS 10518 assert(
false &&
"integer value will be misrepresented in lua");
10519 lua_pushnumber(L, static_cast<lua_Number>(value));
10523 #endif // No Exceptions 10525 #endif // Safe Numerics and Number Precision Check 10526 lua_pushnumber(L, static_cast<lua_Number>(value));
10531 template <
typename T>
10532 struct pusher<T, std::enable_if_t<std::is_enum<T>::value>> {
10533 static int push(lua_State* L,
const T& value) {
10534 if (std::is_same<
char, std::underlying_type_t<T>>::value) {
10537 return stack::push(L,
static_cast<std::underlying_type_t<T>
>(value));
10541 template <
typename T>
10543 static int push(lua_State* L,
const T& tablecont) {
10545 return push(has_kvp(), std::false_type(), L, tablecont);
10548 static int push(std::true_type, lua_State* L,
const T& tablecont) {
10550 return push(has_kvp(), std::true_type(), L, tablecont);
10553 static int push(std::false_type, lua_State* L,
const T& tablecont) {
10555 return push(has_kvp(), std::false_type(), L, tablecont);
10558 template <
bool is_nested>
10559 static int push(std::true_type, std::integral_constant<bool, is_nested>, lua_State* L,
const T& tablecont) {
10561 lua_createtable(L, static_cast<int>(cont.size()), 0);
10562 int tableindex = lua_gettop(L);
10563 for (
const auto& pair : cont) {
10568 set_field(L, pair.first, pair.second, tableindex);
10574 template <
bool is_nested>
10575 static int push(std::false_type, std::integral_constant<bool, is_nested>, lua_State* L,
const T& tablecont) {
10578 int tableindex = lua_gettop(L);
10579 std::size_t index = 1;
10580 for (
const auto& i : cont) {
10581 #if SOL_LUA_VERSION >= 503 10583 for (
int pi = 0; pi < p; ++pi) {
10584 lua_seti(L, tableindex, static_cast<lua_Integer>(index++));
10587 lua_pushinteger(L, static_cast<lua_Integer>(index));
10591 lua_settable(L, tableindex);
10594 int firstindex = tableindex + 1 + 1;
10595 for (
int pi = 0; pi < p; ++pi) {
10597 lua_pushvalue(L, firstindex);
10598 lua_settable(L, tableindex);
10604 #endif // Lua Version 5.3 and others 10612 template <
typename T>
10613 struct pusher<
as_table_t<T>, std::enable_if_t<is_container<std::remove_pointer_t<meta::unwrap_unqualified_t<T>>>::value>> {
10614 static int push(lua_State* L,
const T& tablecont) {
10615 return stack::push<detail::as_table_tag<T>>(L, tablecont);
10619 template <
typename T>
10620 struct pusher<
as_table_t<T>, std::enable_if_t<!is_container<std::remove_pointer_t<meta::unwrap_unqualified_t<T>>>::value>> {
10621 static int push(lua_State* L,
const T& v) {
10626 template <
typename T>
10627 struct pusher<
nested<T>, std::enable_if_t<is_container<std::remove_pointer_t<meta::unwrap_unqualified_t<T>>>::value>> {
10628 static int push(lua_State* L,
const T& tablecont) {
10632 return p.
push(std::true_type(), L, tablecont);
10636 template <
typename T>
10637 struct pusher<
nested<T>, std::enable_if_t<!is_container<std::remove_pointer_t<meta::unwrap_unqualified_t<T>>>::value>> {
10638 static int push(lua_State* L,
const T& tablecont) {
10642 return p.
push(L, tablecont);
10646 template <
typename T>
10648 static int push(lua_State* L,
const std::initializer_list<T>& il) {
10652 return p.
push(L, il);
10656 template <
typename T>
10657 struct pusher<T, std::enable_if_t<is_lua_reference<T>::value>> {
10658 static int push(lua_State* L,
const T& ref) {
10659 return ref.push(L);
10662 static int push(lua_State* L, T&& ref) {
10663 return ref.push(L);
10669 static int push(lua_State* L,
bool b) {
10670 lua_pushboolean(L, b);
10693 lua_pushlstring(L,
"__mt", 4);
10699 struct pusher<std::remove_pointer_t<lua_CFunction>> {
10700 static int push(lua_State* L, lua_CFunction func,
int n = 0) {
10701 lua_pushcclosure(L, func, n);
10708 static int push(lua_State* L, lua_CFunction func,
int n = 0) {
10709 lua_pushcclosure(L, func, n);
10714 #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE 10716 struct pusher<std::remove_pointer_t<detail::lua_CFunction_noexcept>> {
10718 lua_pushcclosure(L, func, n);
10726 lua_pushcclosure(L, func, n);
10730 #endif // noexcept function type 10740 template <
typename Arg,
typename... Args>
10742 template <std::size_t... I,
typename T>
10743 static int push(std::index_sequence<I...>, lua_State* L, T&& c) {
10744 int pushcount =
multi_push(L, detail::forward_get<I>(c.upvalues)...);
10748 template <
typename T>
10750 return push(std::make_index_sequence<1 +
sizeof...(Args)>(), L, std::forward<T>(c));
10757 lua_pushlightuserdata(L, userdata);
10765 lua_pushlightuserdata(L, const_cast<void*>(userdata));
10773 lua_pushlightuserdata(L, userdata);
10778 template <
typename T>
10781 lua_pushlightuserdata(L, static_cast<void*>(l.
value));
10786 template <
typename T>
10788 template <
bool with_meta =
true,
typename Key,
typename... Args>
10789 static int push_with(lua_State* L, Key&& name, Args&&... args) {
10791 T* data = detail::user_allocate<T>(L);
10792 std::allocator<T> alloc{};
10793 std::allocator_traits<std::allocator<T>>::construct(alloc, data, std::forward<Args>(args)...);
10796 if (luaL_newmetatable(L, name) != 0) {
10797 lua_CFunction cdel = detail::user_alloc_destruct<T>;
10798 lua_pushcclosure(L, cdel, 0);
10799 lua_setfield(L, -2,
"__gc");
10801 lua_setmetatable(L, -2);
10807 static int push(lua_State* L, Arg&& arg, Args&&... args) {
10809 return push_with(L, name, std::forward<Arg>(arg), std::forward<Args>(args)...);
10812 template <
typename... Args>
10813 static int push(lua_State* L, no_metatable_t, Args&&... args) {
10815 return push_with<false>(L, name, std::forward<Args>(args)...);
10818 template <
typename Key,
typename... Args>
10819 static int push(lua_State* L, metatable_t, Key&& key, Args&&... args) {
10820 const auto name = &key[0];
10821 return push_with<true>(L, name, std::forward<Args>(args)...);
10826 return push_with(L, name, u.
value);
10831 return push_with(L, name, std::move(u.value));
10836 return push_with<false>(L, name, u.
value);
10841 return push_with<false>(L, name, std::move(u.value));
10848 void** ud = detail::usertype_allocate_pointer<void>(L);
10856 static int push_sized(lua_State* L,
const char* str, std::size_t len) {
10857 lua_pushlstring(L, str, len);
10861 static int push(lua_State* L,
const char* str) {
10862 if (str ==
nullptr)
10864 return push_sized(L, str, std::char_traits<char>::length(str));
10867 static int push(lua_State* L,
const char* strb,
const char* stre) {
10868 return push_sized(L, strb, stre - strb);
10871 static int push(lua_State* L,
const char* str, std::size_t len) {
10872 return push_sized(L, str, len);
10878 static int push_sized(lua_State* L,
const char* str, std::size_t len) {
10884 static int push(lua_State* L,
const char* str) {
10887 return p.
push(L, str);
10890 static int push(lua_State* L,
const char* strb,
const char* stre) {
10893 return p.
push(L, strb, stre);
10896 static int push(lua_State* L,
const char* str, std::size_t len) {
10899 return p.
push(L, str, len);
10903 template <
size_t N>
10905 static int push(lua_State* L,
const char (&str)[N]) {
10906 lua_pushlstring(L, str, std::char_traits<char>::length(str));
10910 static int push(lua_State* L,
const char (&str)[N], std::size_t sz) {
10911 lua_pushlstring(L, str, sz);
10918 static int push(lua_State* L,
char c) {
10919 const char str[2] = { c,
'\0' };
10924 template <
typename Traits,
typename Al>
10925 struct pusher<std::basic_string<char, Traits, Al>> {
10926 static int push(lua_State* L,
const std::basic_string<char, Traits, Al>& str) {
10927 lua_pushlstring(L, str.c_str(), str.size());
10931 static int push(lua_State* L,
const std::basic_string<char, Traits, Al>& str, std::size_t sz) {
10932 lua_pushlstring(L, str.c_str(), sz);
10937 template <
typename Ch,
typename Traits>
10952 lua_pushlstring(L, str.c_str(), str.size());
10960 lua_pushvalue(L, ai);
10968 lua_pushvalue(L, ri);
10976 lua_rawgeti(L, LUA_REGISTRYINDEX, ri);
10983 static int push(lua_State* L,
const wchar_t* wstr) {
10984 return push(L, wstr, std::char_traits<wchar_t>::length(wstr));
10987 static int push(lua_State* L,
const wchar_t* wstr, std::size_t sz) {
10988 return push(L, wstr, wstr + sz);
10991 static int push(lua_State* L,
const wchar_t* strb,
const wchar_t* stre) {
10992 if (
sizeof(
wchar_t) == 2) {
10993 const char16_t* sb =
reinterpret_cast<const char16_t*
>(strb);
10994 const char16_t* se =
reinterpret_cast<const char16_t*
>(stre);
10997 const char32_t* sb =
reinterpret_cast<const char32_t*
>(strb);
10998 const char32_t* se =
reinterpret_cast<const char32_t*
>(stre);
11005 static int push(lua_State* L,
const wchar_t* str) {
11008 return p.
push(L, str);
11011 static int push(lua_State* L,
const wchar_t* strb,
const wchar_t* stre) {
11014 return p.
push(L, strb, stre);
11017 static int push(lua_State* L,
const wchar_t* str, std::size_t len) {
11020 return p.
push(L, str, len);
11026 static int convert_into(lua_State* L,
char* start, std::size_t,
const char16_t* strb,
const char16_t* stre) {
11027 char* target = start;
11029 for (
const char16_t* strtarget = strb; strtarget < stre;) {
11038 const char* utf8data = er.code_units.data();
11039 std::memcpy(target, utf8data, er.code_units_size);
11040 target += er.code_units_size;
11041 strtarget = dr.next;
11047 static int push(lua_State* L,
const char16_t* u16str) {
11048 return push(L, u16str, std::char_traits<char16_t>::length(u16str));
11051 static int push(lua_State* L,
const char16_t* u16str, std::size_t sz) {
11052 return push(L, u16str, u16str + sz);
11055 static int push(lua_State* L,
const char16_t* strb,
const char16_t* stre) {
11061 std::size_t max_possible_code_units = (stre - strb) * 4;
11063 return convert_into(L, sbo, max_possible_code_units, strb, stre);
11066 std::size_t needed_size = 0;
11067 for (
const char16_t* strtarget = strb; strtarget < stre;) {
11070 needed_size += er.code_units_size;
11071 strtarget = dr.next;
11074 return convert_into(L, sbo, needed_size, strb, stre);
11077 u8str.resize(needed_size);
11078 char* target = &u8str[0];
11079 return convert_into(L, target, needed_size, strb, stre);
11085 static int push(lua_State* L,
const char16_t* str) {
11088 return p.
push(L, str);
11091 static int push(lua_State* L,
const char16_t* strb,
const char16_t* stre) {
11094 return p.
push(L, strb, stre);
11097 static int push(lua_State* L,
const char16_t* str, std::size_t len) {
11100 return p.
push(L, str, len);
11106 static int convert_into(lua_State* L,
char* start, std::size_t,
const char32_t* strb,
const char32_t* stre) {
11107 char* target = start;
11109 for (
const char32_t* strtarget = strb; strtarget < stre;) {
11118 const char* data = er.code_units.data();
11119 std::memcpy(target, data, er.code_units_size);
11120 target += er.code_units_size;
11121 strtarget = dr.next;
11126 static int push(lua_State* L,
const char32_t* u32str) {
11127 return push(L, u32str, u32str + std::char_traits<char32_t>::length(u32str));
11130 static int push(lua_State* L,
const char32_t* u32str, std::size_t sz) {
11131 return push(L, u32str, u32str + sz);
11134 static int push(lua_State* L,
const char32_t* strb,
const char32_t* stre) {
11139 std::size_t max_possible_code_units = (stre - strb) * 4;
11141 return convert_into(L, sbo, max_possible_code_units, strb, stre);
11144 std::size_t needed_size = 0;
11145 for (
const char32_t* strtarget = strb; strtarget < stre;) {
11148 needed_size += er.code_units_size;
11149 strtarget = dr.next;
11152 return convert_into(L, sbo, needed_size, strb, stre);
11155 u8str.resize(needed_size);
11156 char* target = &u8str[0];
11157 return convert_into(L, target, needed_size, strb, stre);
11163 static int push(lua_State* L,
const char32_t* str) {
11166 return p.
push(L, str);
11169 static int push(lua_State* L,
const char32_t* strb,
const char32_t* stre) {
11172 return p.
push(L, strb, stre);
11175 static int push(lua_State* L,
const char32_t* str, std::size_t len) {
11178 return p.
push(L, str, len);
11182 template <
size_t N>
11184 static int push(lua_State* L,
const wchar_t (&str)[N]) {
11185 return push(L, str, std::char_traits<wchar_t>::length(str));
11188 static int push(lua_State* L,
const wchar_t (&str)[N], std::size_t sz) {
11189 return stack::push<const wchar_t*>(L, str, str + sz);
11193 template <
size_t N>
11195 static int push(lua_State* L,
const char16_t (&str)[N]) {
11196 return push(L, str, std::char_traits<char16_t>::length(str));
11199 static int push(lua_State* L,
const char16_t (&str)[N], std::size_t sz) {
11200 return stack::push<const char16_t*>(L, str, str + sz);
11204 template <
size_t N>
11206 static int push(lua_State* L,
const char32_t (&str)[N]) {
11207 return push(L, str, std::char_traits<char32_t>::length(str));
11210 static int push(lua_State* L,
const char32_t (&str)[N], std::size_t sz) {
11211 return stack::push<const char32_t*>(L, str, str + sz);
11217 static int push(lua_State* L,
wchar_t c) {
11218 const wchar_t str[2] = { c,
'\0' };
11225 static int push(lua_State* L, char16_t c) {
11226 const char16_t str[2] = { c,
'\0' };
11233 static int push(lua_State* L, char32_t c) {
11234 const char32_t str[2] = { c,
'\0' };
11239 template <
typename Ch,
typename Traits,
typename Al>
11240 struct pusher<std::basic_string<Ch, Traits, Al>, std::enable_if_t<!std::is_same<Ch, char>::value>> {
11241 static int push(lua_State* L,
const std::basic_string<Ch, Traits, Al>& wstr) {
11242 return push(L, wstr, wstr.size());
11245 static int push(lua_State* L,
const std::basic_string<Ch, Traits, Al>& wstr, std::size_t sz) {
11246 return stack::push(L, wstr.data(), wstr.data() + sz);
11250 template <
typename... Args>
11252 template <std::size_t... I,
typename T>
11253 static int push(std::index_sequence<I...>, lua_State* L, T&& t) {
11259 template <
typename T>
11261 return push(std::index_sequence_for<Args...>(), L, std::forward<T>(t));
11265 template <
typename A,
typename B>
11267 template <
typename T>
11269 int pushcount =
stack::push(L, detail::forward_get<0>(t));
11270 pushcount +=
stack::push(L, detail::forward_get<1>(t));
11275 template <
typename O>
11277 template <
typename T>
11282 return stack::push(L,
static_cast<std::conditional_t<std::is_lvalue_reference<T>::value, O&, O&&
>>(t.value()));
11295 static int push(lua_State* L, std::nullptr_t) {
11322 #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES 11323 template <
typename O>
11325 template <
typename T>
11326 static int push(lua_State* L, T&& t) {
11330 return stack::push(L,
static_cast<std::conditional_t<std::is_lvalue_reference<T>::value, O&, O&&
>>(t.value()));
11334 #if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT 11335 namespace stack_detail {
11337 struct push_function {
11340 push_function(lua_State* L)
11344 template <
typename T>
11345 int operator()(T&& value)
const {
11346 return stack::push<T>(L, std::forward<T>(value));
11352 template <
typename... Tn>
11353 struct pusher<std::variant<Tn...>> {
11354 static int push(lua_State* L,
const std::variant<Tn...>& v) {
11355 return std::visit(stack_detail::push_function(L), v);
11358 static int push(lua_State* L, std::variant<Tn...>&& v) {
11359 return std::visit(stack_detail::push_function(L), std::move(v));
11362 #endif // Variant because Clang is terrible 11363 #endif // C++17 Support 11373 template <
typename T,
typename>
11375 inline static decltype(
auto)
pop(lua_State* L) {
11377 #ifdef __INTEL_COMPILER 11380 decltype(
auto) r = get<T>(L, -lua_size<T>::value, tracking);
11382 lua_pop(L, tracking.used);
11387 template <
typename T>
11388 struct popper<T, std::enable_if_t<is_stack_based<meta::unqualified_t<T>>::value>> {
11400 template <
typename T,
bool,
bool,
typename>
11402 template <
typename Key>
11403 void get(lua_State* L, Key&& key,
int tableindex = -2) {
11404 push(L, std::forward<Key>(key));
11405 lua_gettable(L, tableindex);
11409 template <
typename T,
bool global,
typename C>
11411 template <
typename Key>
11412 void get(lua_State* L, Key&& key,
int tableindex = -2) {
11413 push(L, std::forward<Key>(key));
11414 lua_rawget(L, tableindex);
11418 template <
bool b,
bool raw,
typename C>
11421 if (lua_getmetatable(L, tableindex) == 0)
11426 template <
bool b,
bool raw,
typename C>
11428 void get(lua_State* L,
env_t,
int tableindex = -1) {
11429 #if SOL_LUA_VERSION < 502 11431 lua_getfenv(L, tableindex);
11434 if (lua_getupvalue(L, tableindex, 1) ==
nullptr) {
11441 template <
typename T,
bool raw>
11442 struct field_getter<T, true, raw, std::enable_if_t<meta::is_c_str<T>::value>> {
11443 template <
typename Key>
11444 void get(lua_State* L, Key&& key,
int = -1) {
11445 lua_getglobal(L, &key[0]);
11449 template <
typename T>
11450 struct field_getter<T, false, false, std::enable_if_t<meta::is_c_str<T>::value>> {
11451 template <
typename Key>
11452 void get(lua_State* L, Key&& key,
int tableindex = -1) {
11453 lua_getfield(L, tableindex, &key[0]);
11457 #if SOL_LUA_VERSION >= 503 11458 template <
typename T>
11459 struct field_getter<T, false, false, std::enable_if_t<std::is_integral<T>::value && !std::is_same<bool, T>::value>> {
11460 template <
typename Key>
11461 void get(lua_State* L, Key&& key,
int tableindex = -1) {
11462 lua_geti(L, tableindex, static_cast<lua_Integer>(key));
11465 #endif // Lua 5.3.x 11467 #if SOL_LUA_VERSION >= 502 11468 template <
typename C>
11470 void get(lua_State* L,
void* key,
int tableindex = -1) {
11471 lua_rawgetp(L, tableindex, key);
11474 #endif // Lua 5.3.x 11476 template <
typename T>
11477 struct field_getter<T, false, true, std::enable_if_t<std::is_integral<T>::value && !std::is_same<bool, T>::value>> {
11478 template <
typename Key>
11479 void get(lua_State* L, Key&& key,
int tableindex = -1) {
11480 lua_rawgeti(L, tableindex, static_cast<lua_Integer>(key));
11484 template <
typename... Args,
bool b,
bool raw,
typename C>
11486 template <std::size_t... I,
typename Keys>
11487 void apply(std::index_sequence<0, I...>, lua_State* L, Keys&& keys,
int tableindex) {
11488 get_field<b, raw>(L, detail::forward_get<0>(keys), tableindex);
11489 void(
detail::swallow{(get_field<false, raw>(L, detail::forward_get<I>(keys)), 0)...});
11491 lua_pop(L, static_cast<int>(
sizeof...(I)));
11495 template <
typename Keys>
11496 void get(lua_State* L, Keys&& keys) {
11497 apply(std::make_index_sequence<
sizeof...(Args)>(), L, std::forward<Keys>(keys), lua_absindex(L, -1));
11500 template <
typename Keys>
11501 void get(lua_State* L, Keys&& keys,
int tableindex) {
11502 apply(std::make_index_sequence<
sizeof...(Args)>(), L, std::forward<Keys>(keys), tableindex);
11506 template <
typename A,
typename B,
bool b,
bool raw,
typename C>
11508 template <
typename Keys>
11509 void get(lua_State* L, Keys&& keys,
int tableindex) {
11510 get_field<b, raw>(L, detail::forward_get<0>(keys), tableindex);
11511 get_field<false, raw>(L, detail::forward_get<1>(keys));
11513 lua_pop(L, static_cast<int>(2));
11517 template <
typename Keys>
11518 void get(lua_State* L, Keys&& keys) {
11519 get_field<b, raw>(L, detail::forward_get<0>(keys));
11520 get_field<false, raw>(L, detail::forward_get<1>(keys));
11522 lua_pop(L, static_cast<int>(2));
11527 template <
typename T,
bool,
bool,
typename>
11529 template <
typename Key,
typename Value>
11530 void set(lua_State* L, Key&& key, Value&& value,
int tableindex = -3) {
11531 push(L, std::forward<Key>(key));
11532 push(L, std::forward<Value>(value));
11533 lua_settable(L, tableindex);
11537 template <
typename T,
bool b,
typename C>
11539 template <
typename Key,
typename Value>
11540 void set(lua_State* L, Key&& key, Value&& value,
int tableindex = -3) {
11541 push(L, std::forward<Key>(key));
11542 push(L, std::forward<Value>(value));
11543 lua_rawset(L, tableindex);
11547 template <
bool b,
bool raw,
typename C>
11549 template <
typename Value>
11551 push(L, std::forward<Value>(value));
11552 lua_setmetatable(L, tableindex);
11556 template <
typename T,
bool raw>
11557 struct field_setter<T, true, raw, std::enable_if_t<meta::is_c_str<T>::value>> {
11558 template <
typename Key,
typename Value>
11559 void set(lua_State* L, Key&& key, Value&& value,
int = -2) {
11560 push(L, std::forward<Value>(value));
11561 lua_setglobal(L, &key[0]);
11565 template <
typename T>
11566 struct field_setter<T, false, false, std::enable_if_t<meta::is_c_str<T>::value>> {
11567 template <
typename Key,
typename Value>
11568 void set(lua_State* L, Key&& key, Value&& value,
int tableindex = -2) {
11569 push(L, std::forward<Value>(value));
11570 lua_setfield(L, tableindex, &key[0]);
11574 #if SOL_LUA_VERSION >= 503 11575 template <
typename T>
11576 struct field_setter<T, false, false, std::enable_if_t<std::is_integral<T>::value && !std::is_same<bool, T>::value>> {
11577 template <
typename Key,
typename Value>
11578 void set(lua_State* L, Key&& key, Value&& value,
int tableindex = -2) {
11579 push(L, std::forward<Value>(value));
11580 lua_seti(L, tableindex, static_cast<lua_Integer>(key));
11583 #endif // Lua 5.3.x 11585 template <
typename T>
11586 struct field_setter<T, false, true, std::enable_if_t<std::is_integral<T>::value && !std::is_same<bool, T>::value>> {
11587 template <
typename Key,
typename Value>
11588 void set(lua_State* L, Key&& key, Value&& value,
int tableindex = -2) {
11589 push(L, std::forward<Value>(value));
11590 lua_rawseti(L, tableindex, static_cast<lua_Integer>(key));
11594 #if SOL_LUA_VERSION >= 502 11595 template <
typename C>
11597 template <
typename Key,
typename Value>
11598 void set(lua_State* L,
void* key, Value&& value,
int tableindex = -2) {
11599 push(L, std::forward<Value>(value));
11600 lua_rawsetp(L, tableindex, key);
11603 #endif // Lua 5.2.x 11605 template <
typename... Args,
bool b,
bool raw,
typename C>
11607 template <
bool g, std::
size_t I,
typename Key,
typename Value>
11608 void apply(std::index_sequence<I>, lua_State* L, Key&& keys, Value&& value,
int tableindex) {
11609 I < 1 ? set_field<g, raw>(L, detail::forward_get<I>(keys), std::forward<Value>(value), tableindex) : set_field<g, raw>(L, detail::forward_get<I>(keys), std::forward<Value>(value));
11612 template <
bool g, std::size_t I0, std::size_t I1, std::size_t... I,
typename Keys,
typename Value>
11613 void apply(std::index_sequence<I0, I1, I...>, lua_State* L, Keys&& keys, Value&& value,
int tableindex) {
11614 I0 < 1 ? get_field<g, raw>(L, detail::forward_get<I0>(keys), tableindex) : get_field<g, raw>(L, detail::forward_get<I0>(keys), -1);
11615 apply<false>(std::index_sequence<I1, I...>(), L, std::forward<Keys>(keys), std::forward<Value>(value), -1);
11618 template <
bool g, std::size_t I0, std::size_t... I,
typename Keys,
typename Value>
11619 void top_apply(std::index_sequence<I0, I...>, lua_State* L, Keys&& keys, Value&& value,
int tableindex) {
11620 apply<g>(std::index_sequence<I0, I...>(), L, std::forward<Keys>(keys), std::forward<Value>(value), tableindex);
11621 lua_pop(L, static_cast<int>(
sizeof...(I)));
11624 template <
typename Keys,
typename Value>
11625 void set(lua_State* L, Keys&& keys, Value&& value,
int tableindex = -3) {
11626 top_apply<b>(std::make_index_sequence<
sizeof...(Args)>(), L, std::forward<Keys>(keys), std::forward<Value>(value), tableindex);
11630 template <
typename A,
typename B,
bool b,
bool raw,
typename C>
11632 template <
typename Keys,
typename Value>
11633 void set(lua_State* L, Keys&& keys, Value&& value,
int tableindex = -1) {
11634 get_field<b, raw>(L, detail::forward_get<0>(keys), tableindex);
11635 set_field<false, raw>(L, detail::forward_get<1>(keys), std::forward<Value>(value));
11648 template <
typename T,
typename P,
bool b,
bool raw,
typename>
11650 template <
typename Key>
11651 probe get(lua_State* L, Key&& key,
int tableindex = -2) {
11653 return probe(
false, 0);
11655 get_field<b, raw>(L, std::forward<Key>(key), tableindex);
11656 return probe(check<P>(L), 1);
11660 template <
typename A,
typename B,
typename P,
bool b,
bool raw,
typename C>
11662 template <
typename Keys>
11663 probe get(lua_State* L, Keys&& keys,
int tableindex = -2) {
11665 return probe(
false, 0);
11667 get_field<b, raw>(L, std::get<0>(keys), tableindex);
11669 return probe(
false, 1);
11671 get_field<false, raw>(L, std::get<1>(keys), tableindex);
11672 return probe(check<P>(L), 2);
11676 template <
typename... Args,
typename P,
bool b,
bool raw,
typename C>
11678 template <std::
size_t I,
typename Keys>
11679 probe apply(std::index_sequence<I>,
int sofar, lua_State* L, Keys&& keys,
int tableindex) {
11680 get_field < I<1 && b, raw>(L, std::get<I>(keys), tableindex);
11681 return probe(check<P>(L), sofar);
11684 template <std::size_t I, std::size_t I1, std::size_t... In,
typename Keys>
11685 probe apply(std::index_sequence<I, I1, In...>,
int sofar, lua_State* L, Keys&& keys,
int tableindex) {
11686 get_field < I<1 && b, raw>(L, std::get<I>(keys), tableindex);
11688 return probe(
false, sofar);
11690 return apply(std::index_sequence<I1, In...>(), sofar + 1, L, std::forward<Keys>(keys), -1);
11693 template <
typename Keys>
11694 probe get(lua_State* L, Keys&& keys,
int tableindex = -2) {
11696 return probe(
false, 0);
11698 return apply(std::index_sequence_for<Args...>(), 1, L, std::forward<Keys>(keys), tableindex);
11715 template <std::
size_t N>
11717 if (chunkname.empty()) {
11718 auto it = code.
cbegin();
11719 auto e = code.
cend();
11721 static const std::size_t n = N - 4;
11722 for (i = 0; i < n && it != e; ++i, ++it) {
11723 basechunkname[i] = *it;
11726 for (std::size_t c = 0; c < 3; ++i, ++c) {
11727 basechunkname[i] =
'.';
11730 basechunkname[i] =
'\0';
11731 return &basechunkname[0];
11734 return chunkname.c_str();
11740 namespace stack_detail {
11741 template <
typename T>
11743 typedef std::decay_t<T> TValue;
11744 static const std::size_t itemsize =
sizeof(TValue);
11745 static const std::size_t voidsize =
sizeof(
void*);
11746 static const std::size_t voidsizem1 = voidsize - 1;
11747 static const std::size_t data_t_count = (
sizeof(TValue) + voidsizem1) / voidsize;
11748 typedef std::array<void*, data_t_count> data_t;
11751 std::memcpy(&data[0], std::addressof(item), itemsize);
11753 for (
auto&& v : data) {
11759 template <
typename T>
11761 static const std::size_t data_t_count = (
sizeof(T) + (
sizeof(
void*) - 1)) /
sizeof(
void*);
11762 typedef std::array<void*, data_t_count> data_t;
11763 data_t voiddata{ {} };
11764 for (std::size_t i = 0, d = 0; d <
sizeof(T); ++i, d +=
sizeof(
void*)) {
11765 voiddata[i] = get<lightuserdata_value>(L,
upvalue_index(index++));
11767 return std::pair<T, int>(*
reinterpret_cast<T*
>(
static_cast<void*
>(voiddata.data())), index);
11771 template <
typename Fx,
typename... Args>
11772 static decltype(
auto) eval(
types<>, std::index_sequence<>, lua_State*,
int,
record&, Fx&& fx, Args&&... args) {
11773 return std::forward<Fx>(fx)(std::forward<Args>(args)...);
11776 template <
typename Fx,
typename Arg,
typename... Args, std::size_t I, std::size_t... Is,
typename... FxArgs>
11777 static decltype(
auto) eval(
types<Arg, Args...>, std::index_sequence<I, Is...>, lua_State* L,
int start,
record& tracking, Fx&& fx, FxArgs&&... fxargs) {
11778 return eval(
types<Args...>(), std::index_sequence<Is...>(), L, start, tracking, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)..., stack_detail::unchecked_get<Arg>(L, start + tracking.used, tracking));
11782 template <
bool checkargs =
detail::default_safe_function_calls , std::size_t... I,
typename R,
typename... Args,
typename Fx,
typename... FxArgs,
typename = std::enable_if_t<!std::is_void<R>::value >>
11783 inline decltype(
auto) call(
types<R>,
types<Args...> ta, std::index_sequence<I...> tai, lua_State* L,
int start, Fx&& fx, FxArgs&&... args) {
11785 static_assert(
meta::all<
meta::is_not_move_only<Args>...>::value,
"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 a reference and std::move it manually if this was your intention.");
11786 #endif // This compiler make me so sad 11790 return evaluator{}.
eval(ta, tai, L, start, tracking, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
11796 static_assert(
meta::all<
meta::is_not_move_only<Args>...>::value,
"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 a reference and std::move it manually if this was your intention.");
11797 #endif // This compiler make me so fucking sad 11801 evaluator{}.
eval(ta, tai, L, start, tracking, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
11805 template <
typename T>
11806 int set_ref(lua_State* L, T&& arg,
int tableindex = -2) {
11807 push(L, std::forward<T>(arg));
11808 return luaL_ref(L, tableindex);
11811 template <
bool check_args =
detail::default_safe_function_calls,
typename R,
typename... Args,
typename Fx,
typename... FxArgs,
typename = std::enable_if_t<!std::is_void<R>::value>>
11812 inline decltype(
auto) call(
types<R> tr,
types<Args...> ta, lua_State* L,
int start, Fx&& fx, FxArgs&&... args) {
11813 typedef std::make_index_sequence<
sizeof...(Args)> args_indices;
11814 return stack_detail::call<check_args>(tr, ta, args_indices(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
11817 template <
bool check_args =
detail::default_safe_function_calls,
typename R,
typename... Args,
typename Fx,
typename... FxArgs,
typename = std::enable_if_t<!std::is_void<R>::value>>
11818 inline decltype(
auto) call(
types<R> tr,
types<Args...> ta, lua_State* L, Fx&& fx, FxArgs&&... args) {
11819 return call<check_args>(tr, ta, L, 1, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
11824 typedef std::make_index_sequence<
sizeof...(Args)> args_indices;
11825 stack_detail::call<check_args>(tr, ta, args_indices(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
11830 call<check_args>(tr, ta, L, 1, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
11833 template <
bool check_args =
detail::default_safe_function_calls,
typename R,
typename... Args,
typename Fx,
typename... FxArgs,
typename = std::enable_if_t<!std::is_void<R>::value>>
11836 return call<check_args>(tr, ta, L, (std::max)(static_cast<int>(lua_gettop(L) - expected_count::value),
static_cast<int>(0)), std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
11842 call<check_args>(tr, ta, L, (std::max)(static_cast<int>(lua_gettop(L) - expected_count::value),
static_cast<int>(0)), std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
11847 call<check_args>(tr, ta, L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
11854 template <
bool check_args =
detail::default_safe_function_calls,
bool clean_stack =
true,
typename Ret0,
typename... Ret,
typename... Args,
typename Fx,
typename... FxArgs,
typename = std::enable_if_t<meta::neg<std::is_void<Ret0>>::value>>
11856 decltype(
auto) r = call<check_args>(
types<
meta::return_type_t<Ret0, Ret...>>(), ta, L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
11859 std::is_same<R, absolute_index>,
11860 std::is_same<R, ref_index>,
11861 std::is_same<R, raw_index>>
11863 if (clean_stack && !is_stack::value) {
11870 inline int call_lua(lua_State* L,
int start, Fx&& fx, FxArgs&&... fxargs) {
11872 typedef typename traits_type::args_list args_list;
11873 typedef typename traits_type::returns_list returns_list;
11874 return call_into_lua<check_args, clean_stack>(returns_list(), args_list(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
11878 if (lua_gettop(L) == 0) {
11881 luaL_getmetatable(L, key.
data());
11882 auto pn =
pop_n(L, 1);
11883 if (lua_compare(L, -1, index, LUA_OPEQ) != 1) {
11892 if (luaL_loadbufferx(L, code.
data(), code.
size(), chunknametarget,
to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
11898 if (luaL_loadfilex(L, filename.c_str(),
to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
11904 #if defined(SOL_LUAJIT) && !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) 11905 if (L ==
nullptr) {
11908 lua_pushlightuserdata(L, (
void*)
handler);
11909 auto pn =
pop_n(L, 1);
11910 luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_ON);
11918 #if defined(SOL_LUAJIT) 11919 if (L ==
nullptr) {
11922 luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_OFF);
11943 template <
typename Super>
11946 const Super& super = *
static_cast<const Super*
>(
static_cast<const void*
>(
this));
11947 return super.template get<std::string>();
11950 template <
typename T, meta::enable<meta::neg<meta::is_
string_constructible<T>>, is_proxy_primitive<meta::unqualified_t<T>>> = meta::enabler>
11951 operator T()
const {
11952 const Super& super = *
static_cast<const Super*
>(
static_cast<const void*
>(
this));
11953 return super.template get<T>();
11956 template <
typename T, meta::enable<meta::neg<meta::is_
string_constructible<T>>, meta::neg<is_proxy_primitive<meta::unqualified_t<T>>>> = meta::enabler>
11957 operator T&()
const {
11958 const Super& super = *
static_cast<const Super*
>(
static_cast<const void*
>(
this));
11959 return super.template get<T&>();
11963 const Super& super = *
static_cast<const Super*
>(
static_cast<const void*
>(
this));
11964 return super.lua_state();
11974 template <
typename proxy_t,
bool is_const>
11976 typedef std::conditional_t<is_const, const proxy_t, proxy_t>
reference;
11977 typedef std::conditional_t<is_const, const proxy_t*, proxy_t*>
pointer;
11987 : L(nullptr), index((std::numeric_limits<int>::max)()), stacktop((std::numeric_limits<int>::max)()), sp() {
11990 : L(r.L), index(r.index), stacktop(r.stacktop), sp(r.sp) {
11993 : L(luastate), index(idx), stacktop(topidx), sp(luastate, idx) {
11997 return proxy_t(L, index);
12001 return proxy_t(L, index);
12005 sp = proxy_t(L, index);
12010 const_cast<proxy_t&
>(sp) = proxy_t(L, index);
12021 this->operator++();
12032 this->operator--();
12037 index +=
static_cast<int>(idx);
12042 index -=
static_cast<int>(idx);
12047 return index - r.
index;
12057 return proxy_t(L, index + static_cast<int>(idx));
12061 if (stacktop == (std::numeric_limits<int>::max)()) {
12064 else if (r.
stacktop == (std::numeric_limits<int>::max)()) {
12065 return index == stacktop;
12067 return index == r.
index;
12075 return index < r.
index;
12079 return index > r.
index;
12083 return index <= r.
index;
12087 return index >= r.
index;
12091 template <
typename proxy_t,
bool is_const>
12111 : L(nullptr), index(0) {
12114 : L(L), index(index) {
12117 template <
typename T>
12119 return stack::get<T>(L, stack_index());
12122 template <
typename T>
12124 return stack::check<T>(L, stack_index());
12127 template <
typename T>
12128 decltype(
auto) as()
const {
12133 return type_of(lua_state(), stack_index());
12141 lua_pushvalue(Ls, index);
12183 template <
typename... Ret,
typename... Args>
12184 decltype(
auto) call(Args&&... args);
12186 template <
typename... Args>
12187 decltype(
auto) operator()(Args&&... args) {
12188 return call<>(std::forward<Args>(args)...);
12220 template <
typename T>
12223 int target = index + index_offset;
12227 return stack::get<optional<T>>(L, target);
12230 template <
typename T>
12232 int target = index + index_offset;
12233 #if defined(SOL_SAFE_PROXIES) && SOL_SAFE_PROXIES 12238 #endif // Check Argument Safety 12239 return stack::get<T>(L, target);
12243 int target = index + index_offset;
12251 int target = index + index_offset;
12252 #if defined(SOL_SAFE_PROXIES) && SOL_SAFE_PROXIES 12257 #endif // Check Argument Safety 12274 : L(Ls), index(idx), returncount(retnum), popcount(popped), err(pferr) {
12279 : L(o.L), index(o.index), returncount(o.returncount), popcount(o.popcount), err(o.err) {
12288 returncount = o.returncount;
12289 popcount = o.popcount;
12311 template <
typename T>
12312 decltype(
auto)
get(
int index_offset = 0)
const {
12317 return type_of(L, index + static_cast<int>(index_offset));
12321 return stack_proxy(L, index + static_cast<int>(index_offset));
12325 return iterator(L, index, stack_index() + return_count());
12328 return iterator(L, stack_index() + return_count(), stack_index() + return_count());
12331 return const_iterator(L, index, stack_index() + return_count());
12334 return const_iterator(L, stack_index() + return_count(), stack_index() + return_count());
12344 return std::reverse_iterator<iterator>(begin());
12347 return std::reverse_iterator<iterator>(end());
12350 return std::reverse_iterator<const_iterator>(begin());
12353 return std::reverse_iterator<const_iterator>(end());
12356 return std::reverse_iterator<const_iterator>(cbegin());
12359 return std::reverse_iterator<const_iterator>(cend());
12369 return returncount;
12391 for (
int i = 0; i < pfr.
pop_count(); ++i) {
12425 : L(Ls), index(idx), returncount(retnum) {
12430 : L(o.L), index(o.index), returncount(o.returncount) {
12439 returncount = o.returncount;
12452 template <
typename T>
12453 decltype(
auto)
get(difference_type index_offset = 0)
const {
12454 return stack::get<T>(L, index +
static_cast<int>(index_offset));
12458 return type_of(L, index + static_cast<int>(index_offset));
12462 return stack_proxy(L, index + static_cast<int>(index_offset));
12466 return iterator(L, index, stack_index() + return_count());
12469 return iterator(L, stack_index() + return_count(), stack_index() + return_count());
12472 return const_iterator(L, index, stack_index() + return_count());
12475 return const_iterator(L, stack_index() + return_count(), stack_index() + return_count());
12485 return std::reverse_iterator<iterator>(begin());
12488 return std::reverse_iterator<iterator>(end());
12491 return std::reverse_iterator<const_iterator>(begin());
12494 return std::reverse_iterator<const_iterator>(end());
12497 return std::reverse_iterator<const_iterator>(cbegin());
12500 return std::reverse_iterator<const_iterator>(cend());
12518 return returncount;
12526 lua_pop(L, returncount);
12555 template <std::size_t I,
typename... Args,
typename T>
12557 return stack_proxy(fr.lua_state(),
static_cast<int>(fr.stack_index() + I));
12572 template <std::
size_t I>
12574 return stack_proxy(fr.lua_state(),
static_cast<int>(fr.stack_index() + I));
12577 template <std::size_t I,
typename... Args>
12582 template <std::
size_t I>
12584 return stack_proxy(fr.lua_state(),
static_cast<int>(fr.stack_index() + I));
12587 template <std::size_t I,
typename... Args>
12604 template <
typename T>
12605 using array_return_type = std::conditional_t<std::is_array<T>::value, std::add_lvalue_reference_t<T>, T>;
12608 template <
typename F,
typename =
void>
12615 template <
typename... Args>
12616 static decltype(
auto) call(F& f, Args&&... args) {
12617 return f(std::forward<Args>(args)...);
12621 template <
typename... Args>
12622 decltype(
auto) operator()(F& fx, Args&&... args)
const {
12623 return call(fx, std::forward<Args>(args)...);
12628 template <
typename F>
12629 struct wrapper<F, std::enable_if_t<std::is_function<std::remove_pointer_t<meta::unqualified_t<F>>>::value>> {
12635 template <F fx,
typename... Args>
12636 static decltype(
auto) invoke(Args&&... args) {
12637 return fx(std::forward<Args>(args)...);
12640 template <
typename... Args>
12641 static decltype(
auto) call(F& fx, Args&&... args) {
12642 return fx(std::forward<Args>(args)...);
12646 template <
typename... Args>
12647 decltype(
auto) operator()(F& fx, Args&&... args)
const {
12648 return call(fx, std::forward<Args>(args)...);
12654 template <
typename... Args>
12655 decltype(
auto) operator()(Args&&... args)
const {
12656 return invoke<fx>(std::forward<Args>(args)...);
12661 template <
typename F>
12662 struct wrapper<F, std::enable_if_t<std::is_member_object_pointer<meta::unqualified_t<F>>::value>> {
12675 template <F fx,
typename Arg,
typename... Args>
12676 static decltype(
auto) invoke(object_type& mem, Arg&& arg, Args&&...) {
12677 return mem.*fx = std::forward<Arg>(arg);
12680 template <
typename Fx>
12685 template <
typename Fx,
typename Arg,
typename... Args>
12686 static void call(Fx&& fx, object_type& mem, Arg&& arg, Args&&...) {
12687 (mem.*fx) = std::forward<Arg>(arg);
12691 template <
typename Fx,
typename... Args>
12692 decltype(
auto) operator()(Fx&& fx, object_type& mem, Args&&... args)
const {
12693 return call(std::forward<Fx>(fx), mem, std::forward<Args>(args)...);
12699 template <
typename... Args>
12700 decltype(
auto) operator()(Args&&... args)
const {
12701 return invoke<fx>(std::forward<Args>(args)...);
12706 template <
typename F,
typename R,
typename O,
typename... FArgs>
12714 template <F fx,
typename... Args>
12716 return (mem.*fx)(std::forward<Args>(args)...);
12719 template <
typename Fx,
typename... Args>
12720 static R
call(Fx&& fx, O& mem, Args&&... args) {
12721 return (mem.*fx)(std::forward<Args>(args)...);
12725 template <
typename Fx,
typename... Args>
12726 decltype(
auto) operator()(Fx&& fx, O& mem, Args&&... args)
const {
12727 return call(std::forward<Fx>(fx), mem, std::forward<Args>(args)...);
12733 template <
typename... Args>
12734 decltype(
auto) operator()(O& mem, Args&&... args)
const {
12735 return invoke<fx>(mem, std::forward<Args>(args)...);
12740 template <
typename R,
typename O,
typename... Args>
12744 template <
typename R,
typename O,
typename... Args>
12748 template <
typename R,
typename O,
typename... Args>
12752 template <
typename R,
typename O,
typename... Args>
12756 template <
typename R,
typename O,
typename... Args>
12760 template <
typename R,
typename O,
typename... Args>
12764 template <
typename R,
typename O,
typename... Args>
12768 template <
typename R,
typename O,
typename... Args>
12772 template <
typename R,
typename O,
typename... Args>
12776 template <
typename R,
typename O,
typename... Args>
12780 template <
typename R,
typename O,
typename... Args>
12784 template <
typename R,
typename O,
typename... Args>
12788 template <
typename R,
typename O,
typename... Args>
12792 template <
typename R,
typename O,
typename... Args>
12796 template <
typename R,
typename O,
typename... Args>
12800 #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE 12803 template <
typename R,
typename O,
typename... Args>
12807 template <
typename R,
typename O,
typename... Args>
12811 template <
typename R,
typename O,
typename... Args>
12812 struct wrapper<R (O::*)(Args...) const volatile noexcept> :
public member_function_wrapper<R (O::*)(Args...) const volatile noexcept, R, O, Args...> {
12815 template <
typename R,
typename O,
typename... Args>
12819 template <
typename R,
typename O,
typename... Args>
12823 template <
typename R,
typename O,
typename... Args>
12824 struct wrapper<R (O::*)(Args...) const volatile& noexcept> :
public member_function_wrapper<R (O::*)(Args...) const volatile& noexcept, R, O, Args...> {
12827 template <
typename R,
typename O,
typename... Args>
12831 template <
typename R,
typename O,
typename... Args>
12832 struct wrapper<R (O::*)(Args..., ...) const& noexcept> :
public member_function_wrapper<R (O::*)(Args..., ...) const& noexcept, R, O, Args...> {
12835 template <
typename R,
typename O,
typename... Args>
12836 struct wrapper<R (O::*)(Args..., ...) const volatile& noexcept> :
public member_function_wrapper<R (O::*)(Args..., ...) const volatile& noexcept, R, O, Args...> {
12839 template <
typename R,
typename O,
typename... Args>
12843 template <
typename R,
typename O,
typename... Args>
12847 template <
typename R,
typename O,
typename... Args>
12848 struct wrapper<R (O::*)(Args...) const volatile&& noexcept> :
public member_function_wrapper<R (O::*)(Args...) const volatile& noexcept, R, O, Args...> {
12851 template <
typename R,
typename O,
typename... Args>
12855 template <
typename R,
typename O,
typename... Args>
12856 struct wrapper<R (O::*)(Args..., ...) const&& noexcept> :
public member_function_wrapper<R (O::*)(Args..., ...) const& noexcept, R, O, Args...> {
12859 template <
typename R,
typename O,
typename... Args>
12860 struct wrapper<R (O::*)(Args..., ...) const volatile&& noexcept> :
public member_function_wrapper<R (O::*)(Args..., ...) const volatile& noexcept, R, O, Args...> {
12863 #endif // noexcept is part of a function's type 12870 namespace function_detail {
12871 template <
typename Fx,
int start = 1,
bool is_yielding = false>
12872 inline int call(lua_State* L) {
12876 return lua_yield(L, nr);
12895 template <
typename T>
12901 : value(std::forward<Arg>(arg), std::forward<Args>(args)...) {
12910 template <
typename T>
12925 template <
typename R,
typename W>
12927 typedef std::integral_constant<bool, !std::is_void<R>::value>
can_read;
12928 typedef std::integral_constant<bool, !std::is_void<W>::value>
can_write;
12929 typedef std::conditional_t<can_read::value, R, no_prop>
Read;
12930 typedef std::conditional_t<can_write::value, W, no_prop>
Write;
12934 template <
typename Rx,
typename Wx>
12936 : read(std::forward<Rx>(r)), write(std::forward<Wx>(w)) {
12940 namespace property_detail {
12941 template <
typename R,
typename W>
12942 inline decltype(
auto)
property(std::true_type, R&& read, W&& write) {
12945 template <
typename W,
typename R>
12946 inline decltype(
auto)
property(std::false_type, W&& write, R&& read) {
12949 template <
typename R>
12953 template <
typename W>
12954 inline decltype(
auto)
property(std::false_type, W&& write) {
12959 template <
typename F,
typename G>
12966 template <
typename F>
12972 template <
typename F>
12977 template <
typename F>
12982 template <
typename T>
12987 : v(std::move(v)) {
12993 operator const T&()
const {
12999 template <
typename R,
typename T>
13004 template <
typename T>
13007 template <
typename... Args>
13009 : value(std::forward<Args>(args)...) {
13017 template <
typename V>
13024 template <
typename T>
13027 template <
typename T>
13036 namespace usertype_detail {
13040 namespace filter_detail {
13041 template <
int I,
int... In>
13043 if (
sizeof...(In) == 0) {
13050 lua_createtable(L, static_cast<int>(
sizeof...(In)), 0);
13052 auto per_dep = [&L, &deps](
int i) {
13053 lua_pushvalue(L, i);
13058 lua_setuservalue(L, ai);
13061 template <
int... In>
13072 lua_createtable(L, static_cast<int>(sdeps.
size()), 0);
13074 for (std::size_t i = 0; i < sdeps.
size(); ++i) {
13078 lua_setuservalue(L, ai);
13081 template <
typename P, meta::disable<std::is_base_of<detail::filter_base_tag, meta::unqualified_t<P>>> = meta::enabler>
13083 pushed = std::forward<P>(p)(L, pushed);
13087 namespace function_detail {
13089 return luaL_error(L,
"sol: cannot call this constructor (tagged as non-constructible)");
13093 namespace call_detail {
13095 template <
typename R,
typename W>
13100 template <
typename R,
typename W>
13105 template <
typename T,
typename List>
13108 template <
typename T,
typename... Args>
13114 template <
typename T,
bool checked,
bool clean_stack>
13122 template <
typename Fx, std::size_t I,
typename... R,
typename... Args>
13125 return stack::call_into_lua<checked, clean_stack>(r, a, L, start, func, obj);
13129 namespace overload_detail {
13130 template <std::size_t... M,
typename Match,
typename... Args>
13132 return luaL_error(L,
"sol: no matching function call takes this number of arguments and the specified types");
13135 template <
typename Fx,
typename... Fxs, std::size_t I, std::size_t... In, std::size_t... M,
typename Match,
typename... Args>
13139 typedef typename traits::free_args_list args_list;
13142 return overload_match_arity(
types<Fxs...>(), std::index_sequence<In...>(), std::index_sequence<M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
13144 if (!traits::runtime_variadics_t::value && traits::free_arity != fxarity) {
13145 return overload_match_arity(
types<Fxs...>(), std::index_sequence<In...>(), std::index_sequence<traits::free_arity, M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
13149 return overload_match_arity(
types<Fxs...>(), std::index_sequence<In...>(), std::index_sequence<M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
13151 return matchfx(
types<Fx>(),
index_value<I>(), return_types(), args_list(), L, fxarity, start, std::forward<Args>(args)...);
13154 template <std::size_t... M,
typename Match,
typename... Args>
13156 return overload_match_arity(
types<>(), std::index_sequence<>(), std::index_sequence<M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
13159 template <
typename Fx, std::size_t I, std::size_t... M,
typename Match,
typename... Args>
13163 typedef typename traits::free_args_list args_list;
13166 return overload_match_arity(
types<>(), std::index_sequence<>(), std::index_sequence<M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
13168 if (!traits::runtime_variadics_t::value && traits::free_arity != fxarity) {
13169 return overload_match_arity(
types<>(), std::index_sequence<>(), std::index_sequence<traits::free_arity, M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
13171 return matchfx(
types<Fx>(),
index_value<I>(), return_types(), args_list(), L, fxarity, start, std::forward<Args>(args)...);
13174 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,
typename... Args>
13175 inline 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) {
13178 typedef typename traits::free_args_list args_list;
13181 return overload_match_arity(
types<Fx1, Fxs...>(), std::index_sequence<I1, In...>(), std::index_sequence<M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
13183 if (!traits::runtime_variadics_t::value && traits::free_arity != fxarity) {
13184 return overload_match_arity(
types<Fx1, Fxs...>(), std::index_sequence<I1, In...>(), std::index_sequence<traits::free_arity, M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
13188 return overload_match_arity(
types<Fx1, Fxs...>(), std::index_sequence<I1, In...>(), std::index_sequence<M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
13190 return matchfx(
types<Fx>(),
index_value<I>(), return_types(), args_list(), L, fxarity, start, std::forward<Args>(args)...);
13194 template <
typename... Functions,
typename Match,
typename... Args>
13199 template <
typename... Functions,
typename Match,
typename... Args>
13201 int fxarity = lua_gettop(L) - (start - 1);
13202 return overload_match_arity<Functions...>(std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
13205 template <
typename T,
typename... TypeLists,
typename Match,
typename... Args>
13206 inline int construct_match(Match&& matchfx, lua_State* L,
int fxarity,
int start, Args&&... args) {
13211 template <
typename T,
bool checked,
bool clean_stack,
typename... TypeLists>
13214 int argcount = lua_gettop(L);
13216 argcount -=
static_cast<int>(syntax);
13218 T* obj = detail::usertype_allocate<T>(L);
13224 userdataref.push();
13231 template <
typename T,
bool checked,
bool clean_stack,
typename... TypeLists>
13236 template <
typename F,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename =
void>
13240 template <
typename Fx,
typename... Args>
13243 typedef typename traits_type::function_pointer_type fp_t;
13248 template <
typename Fx,
typename... Args>
13253 return stack::call_into_lua<checked, clean_stack>(returns_list(), args_list(), L, boost + 1, caller(), std::forward<Fx>(f), std::forward<Args>(args)...);
13256 template <
typename Fx,
typename... Args>
13257 static int call(lua_State* L, Fx&& f, Args&&... args) {
13259 typedef typename traits_type::function_pointer_type fp_t;
13260 return convertible_call(std::conditional_t<std::is_class<
meta::unqualified_t<F>>::value, std::is_convertible<std::decay_t<Fx>, fp_t>, std::false_type>(), L, std::forward<Fx>(f), std::forward<Args>(args)...);
13264 template <
typename T,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13266 template <
typename F>
13269 if (clean_stack && !is_stack::value) {
13276 template <
typename T,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13278 template <
typename V>
13280 detail::unwrap(f.value) = stack::unqualified_get<meta::unwrapped_t<T>>(L, boost + (is_variable ? 3 : 1));
13287 template <
typename... Args>
13289 return luaL_error(L,
"sol: cannot write to this variable: copy assignment/constructor not available");
13292 template <
typename... Args>
13293 static int call_const(std::false_type, lua_State* L, Args&&... args) {
13295 return call_assign(std::is_assignable<std::add_lvalue_reference_t<
meta::unqualified_t<R>>, R>(), L, std::forward<Args>(args)...);
13298 template <
typename... Args>
13300 return luaL_error(L,
"sol: cannot write to a readonly (const) variable");
13303 template <
typename V>
13309 template <
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13316 template <
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13318 static int call(lua_State* L, lua_CFunction f) {
13323 #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE 13324 template <
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13330 #endif // noexcept function types 13332 template <
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13335 return luaL_error(L, is_index ?
"sol: cannot read from a writeonly property" :
"sol: cannot write to a readonly property");
13339 template <
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13346 template <
typename... Args,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13354 template <
typename T,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13356 static int call(lua_State* L, std::reference_wrapper<T> f) {
13361 template <
typename T,
typename F,
bool is_index,
bool is_variable,
bool checked = detail::default_safe_function_calls,
int boost = 0,
bool clean_stack = true,
typename =
void>
13364 template <
typename T,
typename F,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack>
13365 struct lua_call_wrapper<T, F, is_index, is_variable, checked, boost, clean_stack, std::enable_if_t<std::is_member_function_pointer<F>::value>> {
13369 template <
typename Fx>
13370 static int call(lua_State* L, Fx&& f, object_type& o) {
13374 return stack::call_into_lua<checked, clean_stack>(returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), std::forward<Fx>(f), o);
13377 template <
typename Fx>
13378 static int call(lua_State* L, Fx&& f) {
13379 typedef std::conditional_t<std::is_void<T>::value, object_type, T> Ta;
13380 #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE 13381 auto maybeo = stack::unqualified_check_get<Ta*>(L, 1);
13382 if (!maybeo || maybeo.value() ==
nullptr) {
13383 return luaL_error(L,
"sol: received nil for 'self' argument (use ':' for accessing member functions, make sure member variables are preceeded by the actual object with '.' syntax)");
13385 object_type* o =
static_cast<object_type*
>(maybeo.value());
13386 return call(L, std::forward<Fx>(f), *o);
13388 object_type& o =
static_cast<object_type&
>(*stack::unqualified_get<non_null<Ta*>>(L, 1));
13389 return call(L, std::forward<Fx>(f), o);
13394 template <
typename T,
typename F,
bool is_variable,
bool checked,
int boost,
bool clean_stack>
13395 struct lua_call_wrapper<T, F, false, is_variable, checked, boost, clean_stack, std::enable_if_t<std::is_member_object_pointer<F>::value>> {
13400 template <
typename V>
13401 static int call_assign(std::true_type, lua_State* L, V&& f, object_type& o) {
13404 return stack::call_into_lua<checked, clean_stack>(
types<void>(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), f, o);
13407 template <
typename V>
13409 typedef std::conditional_t<std::is_void<T>::value, object_type, T> Ta;
13410 #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE 13411 auto maybeo = stack::check_get<Ta*>(L, 1);
13412 if (!maybeo || maybeo.value() ==
nullptr) {
13414 return luaL_error(L,
"sol: received nil for 'self' argument (bad '.' access?)");
13416 return luaL_error(L,
"sol: received nil for 'self' argument (pass 'self' as first argument)");
13418 object_type* o =
static_cast<object_type*
>(maybeo.value());
13419 return call_assign(std::true_type(), L, f, *o);
13421 object_type& o =
static_cast<object_type&
>(*stack::get<non_null<Ta*>>(L, 1));
13422 return call_assign(std::true_type(), L, f, o);
13426 template <
typename... Args>
13428 return luaL_error(L,
"sol: cannot write to this variable: copy assignment/constructor not available");
13431 template <
typename... Args>
13432 static int call_const(std::false_type, lua_State* L, Args&&... args) {
13437 template <
typename... Args>
13439 return luaL_error(L,
"sol: cannot write to a readonly (const) variable");
13442 template <
typename V>
13444 return call_const(std::is_const<typename traits_type::return_type>(), L, std::forward<V>(f));
13447 template <
typename V>
13448 static int call(lua_State* L, V&& f, object_type& o) {
13449 return call_const(std::is_const<typename traits_type::return_type>(), L, std::forward<V>(f), o);
13453 template <
typename T,
typename F,
bool is_variable,
bool checked,
int boost,
bool clean_stack>
13454 struct lua_call_wrapper<T, F, true, is_variable, checked, boost, clean_stack, std::enable_if_t<std::is_member_object_pointer<F>::value>> {
13459 template <
typename V>
13460 static int call(lua_State* L, V&& v, object_type& o) {
13463 F f(std::forward<V>(v));
13464 return stack::call_into_lua<checked, clean_stack>(returns_list(),
types<>(), L, boost + (is_variable ? 3 : 2), caller(), f, o);
13467 template <
typename V>
13469 typedef std::conditional_t<std::is_void<T>::value, object_type, T> Ta;
13470 #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE 13471 auto maybeo = stack::check_get<Ta*>(L, 1);
13472 if (!maybeo || maybeo.value() ==
nullptr) {
13474 return luaL_error(L,
"sol: 'self' argument is lua_nil (bad '.' access?)");
13476 return luaL_error(L,
"sol: 'self' argument is lua_nil (pass 'self' as first argument)");
13478 object_type* o =
static_cast<object_type*
>(maybeo.value());
13479 return call(L, f, *o);
13481 object_type& o =
static_cast<object_type&
>(*stack::get<non_null<Ta*>>(L, 1));
13482 return call(L, f, o);
13487 template <
typename T,
typename F,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13493 template <
typename V>
13495 return luaL_error(L,
"sol: cannot write to a sol::readonly variable");
13498 template <
typename V>
13499 static int call(lua_State* L, V&&, object_type&) {
13500 return luaL_error(L,
"sol: cannot write to a sol::readonly variable");
13504 template <
typename T,
typename F,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13505 struct lua_call_wrapper<T,
readonly_wrapper<F>, true, is_variable, checked, boost, clean_stack, C> :
lua_call_wrapper<T, F, true, is_variable, checked, boost, clean_stack, C> {
13508 template <
typename T,
typename... Args,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13514 int argcount = lua_gettop(L);
13516 argcount -=
static_cast<int>(syntax);
13518 T* obj = detail::usertype_allocate<T>(L);
13523 userdataref.push();
13531 template <
typename T,
typename... Cxs,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13536 template <
typename Fx, std::size_t I,
typename... R,
typename... Args>
13539 T* obj = detail::usertype_allocate<T>(L);
13545 userdataref.push();
13555 int syntaxval =
static_cast<int>(syntax);
13556 int argcount = lua_gettop(L) - syntaxval;
13557 return construct_match<T, meta::pop_front_type_t<meta::function_args_t<Cxs>>...>(onmatch(), L, argcount, 1 + syntaxval, f);
13561 template <
typename T,
typename Fx,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack>
13565 static int call(lua_State* L,
const F&) {
13566 return detail::usertype_alloc_destruct<T>(L);
13570 template <
typename T,
typename Fx,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack>
13574 static int call_void(std::true_type, lua_State* L,
const F& f) {
13576 typedef typename bt::template arg_at<0> arg0;
13579 O& obj = stack::get<O>(L);
13584 static int call_void(std::false_type, lua_State* L,
const F& f) {
13585 T& obj = stack::get<T>(L);
13590 static int call(lua_State* L,
const F& f) {
13591 return call_void(std::is_void<T>(), L, f);
13595 template <
typename T,
typename... Fs,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13600 template <
typename Fx, std::size_t I,
typename... R,
typename... Args>
13612 template <
typename T,
typename... Fs,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13617 template <
typename Fx, std::size_t I,
typename... R,
typename... Args>
13629 template <
typename T,
typename R,
typename W,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13631 typedef std::conditional_t<is_index, R, W>
P;
13637 template <
typename F>
13643 return stack::call_into_lua<checked, clean_stack>(returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), f);
13646 template <
typename F>
13650 typedef std::remove_pointer_t<object_type> Oa;
13651 #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE 13652 auto maybeo = stack::check_get<Ta*>(L, 1);
13653 if (!maybeo || maybeo.value() ==
nullptr) {
13655 return luaL_error(L,
"sol: 'self' argument is lua_nil (bad '.' access?)");
13657 return luaL_error(L,
"sol: 'self' argument is lua_nil (pass 'self' as first argument)");
13659 Oa* o =
static_cast<Oa*
>(maybeo.value());
13661 Oa* o =
static_cast<Oa*
>(stack::get<non_null<Ta*>>(L, 1));
13665 return stack::call_into_lua<checked, clean_stack>(returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), f,
detail::implicit_wrapper<Oa>(*o));
13668 template <
typename F,
typename... Args>
13669 static int defer_call(std::false_type, lua_State* L, F&& f, Args&&... args) {
13673 template <
typename F,
typename... Args>
13674 static int defer_call(std::true_type, lua_State* L, F&& f, Args&&... args) {
13679 template <
typename F,
typename... Args>
13680 static int call(lua_State* L, F&& f, Args&&... args) {
13683 std::is_same<U, no_prop>,
13687 std::is_member_pointer<U>>
13689 return defer_call(is_specialized(), L, std::forward<F>(f), std::forward<Args>(args)...);
13693 template <
typename T,
typename V,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13697 template <
typename... Args>
13698 static int call(lua_State* L, F& fx, Args&&... args) {
13703 template <
typename T,
typename F,
typename... Filters,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13707 template <std::size_t... In>
13708 static int call(std::index_sequence<In...>, lua_State* L,
P& fx) {
13716 return call(indices(), L, fx);
13720 template <
typename T,
typename Sig,
typename P,
bool is_index,
bool is_variable,
bool checked,
int boost,
bool clean_stack,
typename C>
13722 template <
typename F>
13728 template <
typename T,
bool is_index,
bool is_variable,
int boost = 0,
bool checked =
detail::default_safe_function_calls,
bool clean_stack =
true,
typename Fx,
typename... Args>
13733 template <
typename T,
bool is_index,
bool is_variable,
typename F,
int start = 1,
bool checked = detail::default_safe_function_calls,
bool clean_stack = true>
13735 auto& fx = stack::unqualified_get<user<F>>(L,
upvalue_index(start));
13736 return call_wrapped<T, is_index, is_variable, 0, checked, clean_stack>(L, fx);
13739 template <
typename T,
typename =
void>
13742 template <
typename T>
13743 struct is_var_bind<T, std::enable_if_t<std::is_member_object_pointer<T>::value>> : std::true_type {};
13748 template <
typename R,
typename W>
13751 template <
typename T>
13754 template <
typename T>
13757 template <
typename F,
typename... Filters>
13761 template <
typename T>
13764 template <
typename T>
13772 namespace function_detail {
13773 template <
typename F, F fx>
13776 typedef typename traits_type::args_list args_list;
13781 template <
typename R,
typename V, V,
typename T>
13783 return luaL_error(L,
"cannot write to this type: copy assignment/constructor not available");
13786 template <
typename R,
typename V, V variable,
typename T>
13788 (mem.*variable) = stack::get<R>(L, 2);
13792 template <
typename R,
typename V, V,
typename T>
13794 return luaL_error(L,
"cannot write to a const variable");
13797 template <
typename R,
typename V, V variable,
typename T>
13799 return call_set_assignable<R, V, variable>(std::is_assignable<std::add_lvalue_reference_t<R>, R>(), L, std::forward<T>(mem));
13802 template <
typename V, V variable>
13805 typedef typename traits_type::object_type T;
13806 typedef typename traits_type::return_type R;
13807 auto& mem = stack::get<T>(L, 1);
13808 switch (lua_gettop(L)) {
13810 decltype(
auto) r = (mem.*variable);
13817 return luaL_error(L,
"incorrect number of arguments to member variable function call");
13821 template <
typename F, F fx>
13823 return call_wrapper_variable<F, fx>(std::is_member_object_pointer<F>(), L);
13826 template <
typename F, F fx>
13828 return call_detail::call_wrapped<void, false, false>(L, fx);
13831 template <
typename F, F fx>
13833 return call_wrapper_function<F, fx>(std::is_member_function_pointer<meta::unqualified_t<F>>(), L);
13836 template <
typename... Fxs>
13838 template <
typename Fx, std::size_t I,
typename R,
typename... Args>
13845 template <
typename F, F fx>
13850 template <
typename F, F fx>
13855 return detail::typed_static_trampoline<decltype(&function_detail::call_wrapper_entry<F, fx>), (&function_detail::call_wrapper_entry<F, fx>)>(L);
13856 #endif // fuck you clang :c 13861 template <
typename F, F fx>
13864 typedef std::integral_constant<bool, std::is_same<Fu, lua_CFunction>::value
13865 #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE 13866 || std::is_same<Fu, detail::lua_CFunction_noexcept>::value
13869 return function_detail::c_call_raw<F, fx>(is_raw(), L);
13872 template <
typename F, F f>
13877 return c_call<type, f>(L);
13881 template <
typename... Fxs>
13883 if (
sizeof...(Fxs) < 2) {
13898 namespace function_detail {
13899 template <
typename Function,
bool is_yielding>
13904 static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) {
13905 auto udata = stack::stack_detail::get_as_upvalues<function_type*>(L);
13906 function_type* fx = udata.first;
13907 return call_detail::call_wrapped<void, true, false>(L, fx);
13911 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
13913 return lua_yield(L, nr);
13925 template <
typename T,
typename Function,
bool is_yielding>
13930 static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) {
13936 auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
13937 auto objdata = stack::stack_detail::get_as_upvalues<T*>(L, memberdata.second);
13938 function_type& memfx = memberdata.first;
13939 auto& item = *objdata.first;
13944 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
13946 return lua_yield(L, nr);
13958 template <
typename T,
typename Function,
bool is_yielding>
13963 static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) {
13969 auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
13970 auto objdata = stack::stack_detail::get_as_upvalues<T*>(L, memberdata.second);
13971 auto& mem = *objdata.first;
13972 function_type&
var = memberdata.first;
13973 switch (lua_gettop(L)) {
13979 return luaL_error(L,
"sol: incorrect number of arguments to member variable function");
13984 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
13986 return lua_yield(L, nr);
13998 template <
typename T,
typename Function,
bool is_yielding>
14003 static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) {
14009 auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
14010 auto objdata = stack::stack_detail::get_as_upvalues<T*>(L, memberdata.second);
14011 auto& mem = *objdata.first;
14012 function_type&
var = memberdata.first;
14013 switch (lua_gettop(L)) {
14017 return luaL_error(L,
"sol: incorrect number of arguments to member variable function");
14022 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
14024 return lua_yield(L, nr);
14036 template <
typename T,
typename Function,
bool is_yielding>
14041 static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) {
14044 auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
14045 function_type& memfx = memberdata.first;
14046 return call_detail::call_wrapped<T, false, false>(L, memfx);
14050 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
14052 return lua_yield(L, nr);
14064 template <
typename T,
typename Function,
bool is_yielding>
14071 auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
14072 function_type&
var = memberdata.first;
14073 switch (lua_gettop(L)) {
14075 return call_detail::call_wrapped<T, true, false>(L,
var);
14077 return call_detail::call_wrapped<T, false, false>(L,
var);
14079 return luaL_error(L,
"sol: incorrect number of arguments to member variable function");
14084 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
14086 return lua_yield(L, nr);
14098 template <
typename T,
typename Function,
bool is_yielding>
14106 auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
14107 function_type&
var = memberdata.first;
14108 switch (lua_gettop(L)) {
14110 return call_detail::call_wrapped<T, true, false>(L,
var);
14112 return luaL_error(L,
"sol: incorrect number of arguments to member variable function");
14117 int nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
14119 return lua_yield(L, nr);
14138 namespace function_detail {
14139 template <
typename Func,
bool is_yielding,
bool no_trampoline>
14144 template <
typename... Args>
14146 : fx(std::move(f), std::forward<Args>(args)...) {
14150 int nr = call_detail::call_wrapped<void, true, false>(L, fx);
14152 return lua_yield(L, nr);
14160 if (!no_trampoline) {
14161 auto f = [&](lua_State*) ->
int {
return this->call(L); };
14170 template <
typename T,
typename Function,
bool is_yielding>
14178 template <
typename... Args>
14180 : invocation(std::move(f)), member(std::forward<Args>(args)...) {
14186 return lua_yield(L, nr);
14194 auto f = [&](lua_State*) ->
int {
return this->call(L); };
14199 template <
typename T,
typename Function,
bool is_yielding>
14206 typedef std::add_lvalue_reference_t<meta::unwrapped_t<std::remove_reference_t<decltype(detail::deref(member))>>>
M;
14208 template <
typename... Args>
14210 : var(std::move(v)), member(std::forward<Args>(args)...) {
14217 switch (lua_gettop(L)) {
14225 nr = luaL_error(L,
"sol: incorrect number of arguments to member variable function");
14230 return lua_yield(L, nr);
14238 auto f = [&](lua_State*) ->
int {
return this->call(L); };
14250 namespace function_detail {
14251 template <
int start_skew = 0,
typename... Functions>
14254 typedef std::make_index_sequence<
sizeof...(Functions)>
indices;
14258 : overloads(std::move(set)) {
14262 : overloads(fxs...) {
14265 template <
typename Fx, std::size_t I,
typename... R,
typename... Args>
14267 auto& func = std::get<I>(overloads);
14268 return call_detail::call_wrapped<void, true, false, start_skew>(L, func);
14272 auto mfx = [&](
auto&&... args) {
return this->call(std::forward<decltype(args)>(args)...); };
14289 template <
typename R,
typename... Args,
typename F,
typename = std::result_of_t<meta::unqualified_t<F>(Args...)>>
14291 using Sig = R(Args...);
14293 return static_cast<Sig Fu::*
>(&Fu::operator());
14296 template <
typename F,
typename U = meta::unqualified_t<F>>
14302 template <
typename F>
14305 "Cannot use no-template-parameter call with an overloaded functor: specify the signature");
14308 template <
typename F,
typename U = meta::unqualified_t<F>>
14313 template <
typename... Args,
typename F,
typename R = std::result_of_t<F&(Args...)>>
14318 template <
typename Sig,
typename C>
14319 inline constexpr Sig C::*
resolve_v(std::false_type, Sig C::*mem_func_ptr) {
14320 return mem_func_ptr;
14323 template <
typename Sig,
typename C>
14324 inline constexpr Sig C::*
resolve_v(std::true_type, Sig C::*mem_variable_ptr) {
14325 return mem_variable_ptr;
14329 template <
typename... Args,
typename R>
14330 inline constexpr
auto resolve(R fun_ptr(Args...)) -> R (*)(Args...) {
14334 template <
typename Sig>
14339 template <
typename... Args,
typename R,
typename C>
14340 inline constexpr
auto resolve(R (C::*mem_ptr)(Args...)) -> R (C::*)(Args...) {
14344 template <
typename Sig,
typename C>
14359 template <
typename R,
typename... Args,
typename F,
typename = std::result_of_t<meta::unqualified_t<F>(Args...)>>
14361 using Sig = R(Args...);
14363 return static_cast<Sig Fu::*
>(&Fu::operator());
14366 template <
typename F,
typename U = meta::unqualified_t<F>>
14367 inline auto resolve_f(std::true_type, F&& f)
14372 template <
typename F>
14373 inline void resolve_f(std::false_type, F&&) {
14375 "Cannot use no-template-parameter call with an overloaded functor: specify the signature");
14378 template <
typename F,
typename U = meta::unqualified_t<F>>
14383 template <
typename... Args,
typename F,
typename R = std::result_of_t<F&(Args...)>>
14388 template <
typename Sig,
typename C>
14389 inline Sig C::*
resolve_v(std::false_type, Sig C::*mem_func_ptr) {
14390 return mem_func_ptr;
14393 template <
typename Sig,
typename C>
14394 inline Sig C::*
resolve_v(std::true_type, Sig C::*mem_variable_ptr) {
14395 return mem_variable_ptr;
14399 template <
typename... Args,
typename R>
14400 inline auto resolve(R fun_ptr(Args...)) -> R (*)(Args...) {
14404 template <
typename Sig>
14405 inline Sig*
resolve(Sig* fun_ptr) {
14409 template <
typename... Args,
typename R,
typename C>
14410 inline auto resolve(R (C::*mem_ptr)(Args...)) -> R (C::*)(Args...) {
14414 template <
typename Sig,
typename C>
14415 inline Sig C::*
resolve(Sig C::*mem_ptr) {
14419 template <
typename... Sig,
typename F>
14431 namespace function_detail {
14432 template <
typename T>
14439 template <
typename... Sigs>
14441 template <
bool is_yielding,
typename... Sig,
typename Fx,
typename... Args>
14443 typedef std::remove_pointer_t<std::decay_t<Fx>> clean_fx;
14445 set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
14448 template <
bool is_yielding,
typename R,
typename... A,
typename Fx,
typename... Args>
14450 using fx_ptr_t = R (*)(A...);
14452 select_function<is_yielding>(std::true_type(), L, fxptr, std::forward<Args>(args)...);
14455 template <
bool is_yielding,
typename R,
typename... A,
typename Fx,
typename... Args>
14457 typedef std::decay_t<meta::unwrap_unqualified_t<Fx>> raw_fx_t;
14458 typedef R (*fx_ptr_t)(A...);
14459 typedef std::is_convertible<raw_fx_t, fx_ptr_t> is_convertible;
14460 select_convertible<is_yielding>(is_convertible(), t, L, std::forward<Fx>(fx), std::forward<Args>(args)...);
14463 template <
bool is_yielding,
typename Fx,
typename... Args>
14466 select_convertible<is_yielding>(
types<Sig>(), L, std::forward<Fx>(fx), std::forward<Args>(args)...);
14469 template <
bool is_yielding,
typename Fx,
typename T,
typename... Args>
14471 typedef std::remove_pointer_t<std::decay_t<Fx>> clean_fx;
14473 set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<T>(obj), std::forward<Args>(args)...);
14476 template <
bool is_yielding,
typename Fx,
typename T,
typename... Args>
14478 typedef std::decay_t<Fx> dFx;
14479 dFx memfxptr(std::forward<Fx>(fx));
14480 auto userptr =
detail::ptr(std::forward<T>(obj), std::forward<Args>(args)...);
14490 template <
bool is_yielding,
typename Fx,
typename... Args>
14492 select_convertible<is_yielding>(
types<Sigs...>(), L, std::forward<Fx>(fx), std::forward<Args>(args)...);
14498 select_reference_member_variable<is_yielding>(is_reference(), L, std::forward<Fx>(fx), std::forward<T>(obj), std::forward<Args>(args)...);
14501 template <
bool is_yielding,
typename Fx,
typename C>
14511 template <
bool is_yielding,
typename Fx>
14522 template <
bool is_yielding,
typename Fx,
typename T,
typename... Args>
14524 typedef std::decay_t<Fx> clean_fx;
14526 set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<T>(obj), std::forward<Args>(args)...);
14529 template <
bool is_yielding,
typename Fx,
typename T,
typename... Args>
14531 typedef std::decay_t<Fx> dFx;
14532 dFx memfxptr(std::forward<Fx>(fx));
14533 auto userptr =
detail::ptr(std::forward<T>(obj), std::forward<Args>(args)...);
14543 template <
bool is_yielding,
typename Fx,
typename... Args>
14548 template <
bool is_yielding,
typename Fx,
typename T,
typename... Args, meta::disable<meta::is_specialization_of<meta::unqualified_t<T>, function_detail::class_indicator>> =
meta::enabler>
14551 select_reference_member_function<is_yielding>(is_reference(), L, std::forward<Fx>(fx), std::forward<T>(obj), std::forward<Args>(args)...);
14554 template <
bool is_yielding,
typename Fx,
typename C>
14564 template <
bool is_yielding,
typename Fx>
14575 template <
bool is_yielding,
typename Fx,
typename... Args>
14577 select_member_function<is_yielding>(std::is_member_function_pointer<meta::unqualified_t<Fx>>(), L, std::forward<Fx>(fx), std::forward<Args>(args)...);
14580 template <
bool is_yielding,
typename Fx,
typename... Args>
14582 std::decay_t<Fx> target(std::forward<Fx>(fx), std::forward<Args>(args)...);
14591 template <
bool is_yielding>
14597 #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE 14598 template <
bool is_yielding>
14603 #endif // noexcept function type 14606 static void select(lua_State* L, Fx&& fx, Args&&... args) {
14607 select_function<is_yielding>(std::is_function<std::remove_pointer_t<meta::unqualified_t<Fx>>>(), L, std::forward<Fx>(fx), std::forward<Args>(args)...);
14610 template <
bool is_yielding,
typename Fx, meta::enable<is_lua_reference<meta::unqualified_t<Fx>>> = meta::enabler>
14616 template <
bool is_yielding,
typename Fx,
typename... Args>
14617 static void set_fx(lua_State* L, Args&&... args) {
14618 lua_CFunction freefunc = detail::static_trampoline<function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>>;
14622 upvalues += stack::push<user<Fx>>(L, std::forward<Args>(args)...);
14627 static int push(lua_State* L, Arg0&& arg0, Args&&... args) {
14629 select<false>(L, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
14633 template <
typename... Args>
14636 select<true>(L, std::forward<Args>(args)...);
14641 template <
typename T>
14643 template <
typename... Args>
14650 template <
typename... Args>
14658 template <
typename T,
typename... Args>
14660 template <std::size_t... I,
typename FP>
14661 static int push_func(std::index_sequence<I...>, lua_State* L, FP&& fp) {
14662 return stack::push<T>(L, detail::forward_get<I>(fp.arguments)...);
14666 return push_func(std::make_index_sequence<
sizeof...(Args)>(), L, fp);
14670 return push_func(std::make_index_sequence<
sizeof...(Args)>(), L, std::move(fp));
14674 template <
typename Signature>
14676 static int push(lua_State* L,
const std::function<Signature>& fx) {
14680 static int push(lua_State* L, std::function<Signature>&& fx) {
14685 template <
typename Signature>
14686 struct pusher<Signature, std::enable_if_t<std::is_member_pointer<Signature>::value>> {
14687 template <
typename F,
typename... Args>
14688 static int push(lua_State* L, F&& f, Args&&... args) {
14691 return p.
push(L, std::forward<F>(f), std::forward<Args>(args)...);
14695 template <
typename Signature>
14696 struct pusher<Signature, std::enable_if_t<meta::all<std::is_function<std::remove_pointer_t<Signature>>, meta::neg<std::is_same<Signature, lua_CFunction>>, meta::neg<std::is_same<Signature, std::remove_pointer_t<lua_CFunction>>>
14697 #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE
14699 meta::neg<std::is_same<Signature, detail::lua_CFunction_noexcept>>, meta::neg<std::is_same<Signature, std::remove_pointer_t<detail::lua_CFunction_noexcept>>>
14702 template <
typename F>
14708 template <
typename... Functions>
14725 template <
typename T>
14728 lua_CFunction cf = call_detail::call_user<void, false, false, protect_t<T>, 2>;
14731 upvalues += stack::push<user<protect_t<T>>>(L, std::move(pw.value));
14736 lua_CFunction cf = call_detail::call_user<void, false, false, protect_t<T>, 2>;
14739 upvalues += stack::push<user<protect_t<T>>>(L, pw.
value);
14744 template <
typename F,
typename G>
14754 template <
typename F>
14764 template <
typename F>
14774 template <
typename T>
14784 template <
typename... Functions>
14823 template <
typename T,
typename... Lists>
14824 struct pusher<detail::tagged<T, constructor_list<Lists...>>> {
14836 template <
typename L0,
typename... Lists>
14841 return stack::push<detail::tagged<T, cl_t>>(L, cl);
14845 template <
typename T,
typename... Fxs>
14846 struct pusher<detail::tagged<T, constructor_wrapper<Fxs...>>> {
14847 template <
typename C>
14857 template <
typename F,
typename... Fxs>
14859 template <
typename C>
14867 template <
typename T>
14868 struct pusher<detail::tagged<T, destructor_wrapper<void>>> {
14870 lua_CFunction cf = detail::usertype_alloc_destruct<T>;
14875 template <
typename T,
typename Fx>
14876 struct pusher<detail::tagged<T, destructor_wrapper<Fx>>> {
14878 lua_CFunction cf = call_detail::call_user<T, false, false, destructor_wrapper<Fx>, 2>;
14881 upvalues += stack::push<user<destructor_wrapper<Fx>>>(L, std::move(c));
14886 lua_CFunction cf = call_detail::call_user<T, false, false, destructor_wrapper<Fx>, 2>;
14889 upvalues += stack::push<user<destructor_wrapper<Fx>>>(L, c);
14894 template <
typename Fx>
14897 lua_CFunction cf = call_detail::call_user<void, false, false, destructor_wrapper<Fx>, 2>;
14900 upvalues += stack::push<user<destructor_wrapper<Fx>>>(L, std::move(c));
14905 lua_CFunction cf = call_detail::call_user<void, false, false, destructor_wrapper<Fx>, 2>;
14908 upvalues += stack::push<user<destructor_wrapper<Fx>>>(L, c);
14913 template <
typename F,
typename... Filters>
14918 lua_CFunction cf = call_detail::call_user<void, false, false, P, 2>;
14921 upvalues += stack::push<user<P>>(L, p);
14926 lua_CFunction cf = call_detail::call_user<void, false, false, P, 2>;
14929 upvalues += stack::push<user<P>>(L, std::move(p));
14939 template <
typename base_t,
bool aligned = false>
14942 void luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount)
const {
14943 lua_call(lua_state(), static_cast<int>(argcount), static_cast<int>(resultcount));
14946 template <std::size_t... I,
typename... Ret>
14948 luacall(n,
lua_size<std::tuple<Ret...>>::value);
14949 return stack::pop<std::tuple<Ret...>>(lua_state());
14952 template <std::
size_t I,
typename Ret>
14955 return stack::pop<Ret>(lua_state());
14958 template <std::
size_t I>
14964 int stacksize = lua_gettop(lua_state());
14965 int firstreturn = (std::max)(1, stacksize - static_cast<int>(n));
14966 luacall(n, LUA_MULTRET);
14967 int poststacksize = lua_gettop(lua_state());
14968 int returncount = poststacksize - (firstreturn - 1);
14973 using base_t::lua_state;
14976 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>
14978 :
base_t(std::forward<T>(r)) {
14979 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 14983 stack::check<basic_function>(lua_state(), -1,
handler);
15000 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
15002 :
base_t(L, std::forward<T>(r)) {
15003 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15006 stack::check<basic_function>(lua_state(), -1,
handler);
15011 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15013 stack::check<basic_function>(L, index,
handler);
15018 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15021 stack::check<basic_function>(lua_state(), -1,
handler);
15025 template <
typename... Args>
15027 return call<>(std::forward<Args>(args)...);
15030 template <
typename... Ret,
typename... Args>
15031 decltype(
auto) operator()(
types<Ret...>, Args&&... args)
const {
15032 return call<Ret...>(std::forward<Args>(args)...);
15035 template <
typename... Ret,
typename... Args>
15036 decltype(
auto) call(Args&&... args)
const {
15041 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), pushcount);
15055 static const char name[9] =
"sol.\xF0\x9F\x94\xA9";
15059 template <
bool b,
typename target_t = reference>
15066 : target(target), stackindex(0) {
15068 stackindex = lua_gettop(target.lua_state()) + 1;
15074 : target(target), stackindex(0) {
15076 stackindex = target.stack_index();
15089 if (!is_stack::value && stackindex != 0) {
15090 lua_remove(target.lua_state(), stackindex);
15095 template <
typename base_t,
typename T>
15100 template <
typename Reference,
bool is_main_ref = false>
15103 return Reference(L,
lua_nil);
15107 return Reference(L, -1);
15110 template <
typename T>
15112 if (L ==
nullptr) {
15115 if (!ref.valid()) {
15130 template <
typename base_t,
bool aligned = false,
typename handler_t = reference>
15136 return detail::get_default_handler<handler_t, is_main_threaded<base_t>::value>(L);
15139 template <
typename T>
15147 return static_cast<call_status>(lua_pcall(lua_state(), static_cast<int>(argcount), static_cast<int>(resultcount), h.
stackindex));
15150 template <std::size_t... I,
bool b,
typename... Ret>
15152 luacall(n,
sizeof...(Ret), h);
15153 return stack::pop<std::tuple<Ret...>>(lua_state());
15156 template <std::
size_t I,
bool b,
typename Ret>
15159 return stack::pop<Ret>(lua_state());
15162 template <std::
size_t I,
bool b>
15169 int stacksize = lua_gettop(lua_state());
15170 int poststacksize = stacksize;
15171 int firstreturn = 1;
15172 int returncount = 0;
15174 #if !defined(SOL_NO_EXCEPTIONS) || !SOL_NO_EXCEPTIONS 15175 auto onexcept = [&](optional<const std::exception&> maybe_ex,
const char*
error) {
15180 lua_call(lua_state(), 1, 1);
15187 #if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !SOL_NO_EXCEPTIONS_SAFE_PROPAGATION) || (defined(SOL_LUAJIT) && SOL_LUAJIT) 15189 #endif // Safe Exception Propagation 15190 #endif // No Exceptions 15191 firstreturn = (std::max)(1, static_cast<int>(stacksize - n - static_cast<int>(h.
valid())));
15192 code = luacall(n, LUA_MULTRET, h);
15193 poststacksize = lua_gettop(lua_state()) -
static_cast<int>(h.
valid());
15194 returncount = poststacksize - (firstreturn - 1);
15195 #ifndef SOL_NO_EXCEPTIONS 15196 #if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !SOL_NO_EXCEPTIONS_SAFE_PROPAGATION) || (defined(SOL_LUAJIT) && SOL_LUAJIT) 15199 catch (
const char*
error) {
15200 onexcept(optional<const std::exception&>(
nullopt), error);
15201 firstreturn = lua_gettop(lua_state());
15205 onexcept(optional<const std::exception&>(
nullopt), error.c_str());
15206 firstreturn = lua_gettop(lua_state());
15209 catch (
const std::exception& error) {
15210 onexcept(optional<const std::exception&>(error), error.what());
15211 firstreturn = lua_gettop(lua_state());
15214 #if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !SOL_NO_EXCEPTIONS_SAFE_PROPAGATION) 15219 onexcept(optional<const std::exception&>(
nullopt),
"caught (...) unknown error during protected_function call");
15220 firstreturn = lua_gettop(lua_state());
15226 #endif // Safe Exception Propagation 15227 #endif // Exceptions vs. No Exceptions 15232 using base_t::lua_state;
15237 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>
15240 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15244 stack::check<basic_protected_function>(lua_state(), -1,
handler);
15259 :
base_t(b), error_handler(std::move(eh)) {
15262 :
base_t(std::move(b)), error_handler(std::move(eh)) {
15277 template <
typename Super>
15281 template <
typename Super>
15285 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>
15290 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
15294 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
15296 :
base_t(L, std::forward<T>(r)), error_handler(std::move(eh)) {
15297 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15300 stack::check<basic_protected_function>(lua_state(), -1,
handler);
15305 :
base_t(n), error_handler(n) {
15312 :
base_t(L, index), error_handler(std::move(eh)) {
15313 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15315 stack::check<basic_protected_function>(L, index,
handler);
15322 :
base_t(L, index), error_handler(std::move(eh)) {
15323 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15325 stack::check<basic_protected_function>(L, index,
handler);
15332 :
base_t(L, index), error_handler(std::move(eh)) {
15333 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15335 stack::check<basic_protected_function>(L, index,
handler);
15342 :
base_t(L, index), error_handler(std::move(eh)) {
15343 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15346 stack::check<basic_protected_function>(lua_state(), -1,
handler);
15350 template <
typename... Args>
15352 return call<>(std::forward<Args>(args)...);
15355 template <
typename... Ret,
typename... Args>
15356 decltype(
auto) operator()(
types<Ret...>, Args&&... args)
const {
15357 return call<Ret...>(std::forward<Args>(args)...);
15360 template <
typename... Ret,
typename... Args>
15361 decltype(
auto) call(Args&&... args)
const {
15364 if (error_handler.valid()) {
15368 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), pushcount, h);
15374 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), pushcount, h);
15379 if (error_handler.valid()) {
15383 if (!is_stack_handler::value) {
15388 if (!is_stack_handler::value) {
15389 lua_replace(lua_state(), -3);
15390 h.
stackindex = lua_absindex(lua_state(), -2);
15393 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), pushcount, h);
15398 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), pushcount, h);
15408 template <
typename... Ret,
typename... Args>
15411 return sf.template call<Ret...>(std::forward<Args>(args)...);
15415 : L(o.lua_state()), index(o.stack_index()), returncount(o.return_count()), popcount(o.return_count()), err(o.status()) {
15424 index = o.stack_index();
15425 returncount = o.return_count();
15426 popcount = o.return_count();
15436 : L(o.lua_state()), index(o.stack_index()), returncount(o.return_count()) {
15444 index = o.stack_index();
15445 returncount = o.return_count();
15454 template <
typename Signature>
15460 template <
typename... Args,
typename... Ret>
15464 return f.call<Ret...>(std::forward<Args>(args)...);
15466 return std::move(fx);
15469 template <
typename... FxArgs>
15472 auto fx = [f = std::move(f)](FxArgs&&... args) ->
void {
15473 f(std::forward<FxArgs>(args)...);
15475 return std::move(fx);
15478 template <
typename... FxArgs>
15483 static std::function<Signature>
get(lua_State* L,
int index,
record& tracking) {
15485 tracking.used += 1;
15490 return get_std_func(return_types(), args_lists(), L, index);
15500 template <
typename Table,
typename Key>
15505 template <
typename T, std::size_t... I>
15506 decltype(
auto) tuple_get(std::index_sequence<I...>)
const {
15507 return tbl.template traverse_get<T>(std::get<I>(key)...);
15510 template <std::size_t... I,
typename T>
15512 tbl.traverse_set(std::get<I>(key)..., std::forward<T>(value));
15516 auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>,
global_table>::value>(lua_state(), key, tbl.stack_index());
15517 lua_pop(lua_state(), p.levels);
15523 auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>,
global_table>::value>(lua_state(), key, lua_gettop(lua_state()));
15524 lua_pop(lua_state(), p.levels);
15532 template <
typename T>
15534 : tbl(table), key(std::forward<T>(k)) {
15537 template <
typename T>
15543 template <
typename... Args>
15549 template <
typename U, meta::enable<meta::neg<is_lua_reference_or_proxy<meta::unwrap_unqualified_t<U>>>, meta::is_callable<meta::unwrap_unqualified_t<U>>> = meta::enabler>
15551 return set_function(std::forward<U>(other));
15554 template <
typename U, meta::disable<meta::neg<is_lua_reference_or_proxy<meta::unwrap_unqualified_t<U>>>, meta::is_callable<meta::unwrap_unqualified_t<U>>> = meta::enabler>
15556 return set(std::forward<U>(other));
15559 template <
typename T>
15561 return set(std::move(other));
15564 template <
typename T>
15566 return tuple_get<T>(std::make_index_sequence<std::tuple_size<meta::unqualified_t<key_type>>::value>());
15569 template <
typename T>
15570 decltype(
auto) get_or(T&& otherwise)
const {
15571 typedef decltype(get<T>()) U;
15574 return static_cast<U
>(option.
value());
15576 return static_cast<U
>(std::forward<T>(otherwise));
15579 template <
typename T,
typename D>
15580 decltype(
auto) get_or(D&& otherwise)
const {
15583 return static_cast<T
>(option.
value());
15585 return static_cast<T
>(std::forward<D>(otherwise));
15588 template <
typename T>
15589 decltype(
auto) get_or_create() {
15593 template <
typename T,
typename Otherwise>
15594 decltype(
auto) get_or_create(Otherwise&& other) {
15595 if (!this->valid()) {
15596 this->
set(std::forward<Otherwise>(other));
15601 template <
typename K>
15602 decltype(
auto) operator[](K&& k)
const {
15607 template <
typename... Ret,
typename... Args>
15608 decltype(
auto) call(Args&&... args) {
15609 #if !defined(__clang__) && defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 191200000 15611 return get<function>().call<Ret...>(std::forward<Args>(args)...);
15613 return get<function>().
template call<Ret...>(std::forward<Args>(args)...);
15617 template <
typename... Args>
15618 decltype(
auto) operator()(Args&&... args) {
15619 return call<>(std::forward<Args>(args)...);
15624 auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>,
global_table>::value>(lua_state(), key, lua_gettop(lua_state()));
15625 lua_pop(lua_state(), p.levels);
15630 return push(this->lua_state());
15633 int push(lua_State* L)
const noexcept {
15634 return get<reference>().
push(L);
15640 auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>,
global_table>::value>(lua_state(), key, lua_gettop(lua_state()));
15642 t =
type_of(lua_state(), -1);
15644 lua_pop(lua_state(), p.levels);
15649 return tbl.lua_state();
15653 if (this->valid()) {
15660 template <
typename Table,
typename Key,
typename T>
15662 typedef decltype(stack::get<T>(
nullptr, 0)) U;
15663 return right.template get<optional<U>>() == left;
15666 template <
typename Table,
typename Key,
typename T>
15668 typedef decltype(stack::get<T>(
nullptr, 0)) U;
15669 return right.template get<optional<U>>() == left;
15672 template <
typename Table,
typename Key,
typename T>
15674 typedef decltype(stack::get<T>(
nullptr, 0)) U;
15675 return right.template get<optional<U>>() != left;
15678 template <
typename Table,
typename Key,
typename T>
15680 typedef decltype(stack::get<T>(
nullptr, 0)) U;
15681 return right.template get<optional<U>>() != left;
15684 template <
typename Table,
typename Key>
15686 return !right.
valid();
15689 template <
typename Table,
typename Key>
15691 return !right.
valid();
15694 template <
typename Table,
typename Key>
15696 return right.
valid();
15699 template <
typename Table,
typename Key>
15701 return right.
valid();
15705 template <
typename Super>
15708 this->operator=(std::move(v));
15713 template <
typename Super>
15716 this->operator=(std::move(v));
15721 template <
typename Table,
typename Key>
15739 #ifndef SOL_DEPRECATED 15741 #define SOL_DEPRECATED __declspec(deprecated) 15743 #define SOL_DEPRECATED __attribute__((deprecated)) 15745 #define SOL_DEPRECATED [[deprecated]] 15746 #endif // compilers 15747 #endif // SOL_DEPRECATED 15751 template <
typename T>
15766 template <
typename base_t>
15769 template <
typename T>
15770 decltype(
auto) as_stack(std::true_type)
const {
15771 return stack::get<T>(base_t::lua_state(), base_t::stack_index());
15774 template <
typename T>
15775 decltype(
auto) as_stack(std::false_type)
const {
15777 return stack::pop<T>(base_t::lua_state());
15780 template <
typename T>
15782 return stack::check<T>(base_t::lua_state(), base_t::stack_index(),
no_panic);
15785 template <
typename T>
15787 int r = base_t::registry_index();
15788 if (r == LUA_REFNIL)
15790 if (r == LUA_NOREF)
15793 return stack::check<T>(base_t::lua_state(), -1,
no_panic);
15804 :
base_t(std::forward<T>(arg), std::forward<Args>(args)...) {
15807 template <
typename T>
15808 decltype(
auto) as()
const {
15812 template <
typename T>
15824 template <
typename base_type>
15829 using base_t::lua_state;
15833 basic_userdata(T&& r) noexcept
15834 : base_t(std::forward<T>(r)) {
15835 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15852 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
15854 : base_t(L, std::forward<T>(r)) {
15855 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15858 stack::check<basic_userdata>(L, -1,
handler);
15862 : base_t(detail::
no_safety, L, index) {
15863 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15865 stack::check<basic_userdata>(L, index,
handler);
15869 : base_t(detail::
no_safety, L, index) {
15870 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15873 stack::check<basic_userdata>(L, -1,
handler);
15878 template <
typename base_type>
15883 using base_t::lua_state;
15887 basic_lightuserdata(T&& r) noexcept
15888 : base_t(std::forward<T>(r)) {
15889 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15906 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
15909 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15912 stack::check<basic_lightuserdata>(lua_state(), -1,
handler);
15916 : base_t(L, index) {
15917 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15919 stack::check<basic_lightuserdata>(L, index,
handler);
15923 : base_t(L, index) {
15924 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 15927 stack::check<basic_lightuserdata>(lua_state(), index,
handler);
15939 template <
typename T>
15944 template <
typename Source>
15950 template <
typename T>
15954 for (
const auto& i : e.
src) {
15987 : L(luastate), index(lua_absindex(luastate, stackindex)), stacktop(lua_gettop(luastate)) {
15990 : L(luastate), index(lua_absindex(luastate, stackindex)), stacktop(lastindex) {
15995 : L(o.L), index(o.index), stacktop(o.stacktop) {
16006 stacktop = o.stacktop;
16017 return iterator(L, index, stacktop + 1);
16020 return iterator(L, stacktop + 1, stacktop + 1);
16023 return const_iterator(L, index, stacktop + 1);
16026 return const_iterator(L, stacktop + 1, stacktop + 1);
16036 return std::reverse_iterator<iterator>(begin());
16039 return std::reverse_iterator<iterator>(end());
16042 return std::reverse_iterator<const_iterator>(begin());
16045 return std::reverse_iterator<const_iterator>(end());
16048 return std::reverse_iterator<const_iterator>(cbegin());
16051 return std::reverse_iterator<const_iterator>(cend());
16060 for (
int i = index; i <= stacktop; ++i) {
16061 lua_pushvalue(L, i);
16065 lua_xmove(L, target, pushcount);
16070 template <
typename T>
16071 decltype(
auto)
get(difference_type index_offset = 0)
const {
16072 return stack::get<T>(L, index +
static_cast<int>(index_offset));
16076 return type_of(L, index + static_cast<int>(index_offset));
16080 return stack_proxy(L, index + static_cast<int>(index_offset));
16090 return stacktop - (index - 1);
16093 return static_cast<std::size_t
>(leftover_count());
16112 return ref.
push(L);
16122 template <typename R = reference, bool should_pop = !is_stack_based<R>::value,
typename T>
16124 int backpedal =
stack::push(L, std::forward<T>(value));
16125 R r = stack::get<R>(L, -backpedal);
16127 lua_pop(L, backpedal);
16132 template <typename T, typename R = reference, bool should_pop = !is_stack_based<R>::value,
typename... Args>
16134 int backpedal = stack::push<T>(L, std::forward<Args>(args)...);
16135 R r = stack::get<R>(L, -backpedal);
16137 lua_pop(L, backpedal);
16142 template <
typename base_type>
16147 template <
bool invert_and_pop = false>
16148 basic_object(std::integral_constant<bool, invert_and_pop>, lua_State* L,
int index = -1) noexcept
16149 : base_t(L, index) {
16150 if (invert_and_pop) {
16151 lua_pop(L, -index);
16157 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>
16159 : base_t(std::forward<T>(r)) {
16161 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
16163 : base_t(L, std::forward<T>(r)) {
16176 template <
typename Super>
16180 template <
typename Super>
16188 : base_t(L, index) {
16191 : base_t(L, index) {
16194 : base_t(L, index) {
16197 : base_t(L, index) {
16199 template <
typename T,
typename... Args>
16203 template <
typename T,
typename... Args>
16210 base_t::operator=(b);
16214 base_t::operator=(std::move(b));
16217 template <
typename Super>
16222 template <
typename Super>
16229 template <
typename T>
16231 return make_reference<object, true>(L, std::forward<T>(value));
16234 template <
typename T,
typename... Args>
16236 return make_reference<T, object, true>(L, std::forward<Args>(args)...);
16248 template <
typename T>
16251 template <
typename T>
16256 : source(std::move(value)) {
16259 operator std::add_rvalue_reference_t<T>() {
16260 return std::move(source);
16263 operator std::add_lvalue_reference_t<std::add_const_t<T>>()
const {
16268 template <
typename T>
16281 template <
typename T>
16286 namespace container_detail {
16288 template <
typename T>
16294 template <
typename C>
16295 static one test(decltype(&C::clear));
16296 template <
typename C>
16297 static two test(...);
16300 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16303 template <
typename T>
16309 template <
typename C>
16310 static one test(decltype(&C::empty));
16311 template <
typename C>
16312 static two test(...);
16315 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16318 template <
typename T>
16324 template <
typename C>
16325 static one test(decltype(std::declval<C>().erase_after(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>()))*);
16326 template <
typename C>
16327 static two test(...);
16330 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16333 template <
typename T,
typename =
void>
16339 template <
typename C>
16340 static one test(decltype(std::declval<C>().find(std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
16341 template <
typename C>
16342 static two test(...);
16345 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16348 template <
typename T>
16354 template <
typename C>
16355 static one test(decltype(std::declval<C>().find(std::declval<std::add_rvalue_reference_t<typename C::key_type>>()))*);
16356 template <
typename C>
16357 static two test(...);
16360 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16363 template <
typename T>
16369 template <
typename C>
16370 static one test(decltype(std::declval<C>().erase(std::declval<typename C::iterator>()))*);
16371 template <
typename C>
16372 static two test(...);
16375 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16378 template <
typename T>
16384 template <
typename C>
16385 static one test(decltype(&C::find));
16386 template <
typename C>
16387 static two test(...);
16390 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16393 template <
typename T>
16399 template <
typename C>
16400 static one test(decltype(&C::insert));
16401 template <
typename C>
16402 static two test(...);
16405 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16408 template <
typename T>
16414 template <
typename C>
16415 static one test(decltype(&C::erase));
16416 template <
typename C>
16417 static two test(...);
16420 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16423 template <
typename T>
16429 template <
typename C>
16430 static one test(decltype(&C::index_set));
16431 template <
typename C>
16432 static two test(...);
16435 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16438 template <
typename T>
16444 template <
typename C>
16445 static one test(decltype(&C::index_get));
16446 template <
typename C>
16447 static two test(...);
16450 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16453 template <
typename T>
16459 template <
typename C>
16460 static one test(decltype(&C::set));
16461 template <
typename C>
16462 static two test(...);
16465 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16468 template <
typename T>
16474 template <
typename C>
16475 static one test(decltype(&
C::get));
16476 template <
typename C>
16477 static two test(...);
16480 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16483 template <
typename T>
16489 template <
typename C>
16490 static one test(decltype(&C::at));
16491 template <
typename C>
16492 static two test(...);
16495 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16498 template <
typename T>
16504 template <
typename C>
16505 static one test(decltype(&
C::pairs));
16506 template <
typename C>
16507 static two test(...);
16510 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16513 template <
typename T>
16519 template <
typename C>
16521 template <
typename C>
16522 static two test(...);
16525 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16528 template <
typename T>
16534 template <
typename C>
16535 static one test(decltype(&
C::next));
16536 template <
typename C>
16537 static two test(...);
16540 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16543 template <
typename T>
16549 template <
typename C>
16550 static one test(decltype(&C::add));
16551 template <
typename C>
16552 static two test(...);
16555 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16558 template <
typename T>
16564 template <
typename C>
16565 static one test(decltype(&C::size));
16566 template <
typename C>
16567 static two test(...);
16570 static const bool value =
sizeof(test<T>(0)) ==
sizeof(char);
16573 template <
typename T>
16576 template <
typename T>
16579 template <
typename T>
16582 template <
typename T>
16585 template <
typename T>
16588 template <
typename T>
16591 template <
typename T>
16594 template <
typename T>
16597 template <
typename T>
16600 template <
typename T>
16603 template <
typename T>
16606 template <
typename T>
16609 template <
typename T>
16612 template <
typename T>
16615 template <
typename T>
16618 template <
typename T>
16621 template <
typename T>
16624 template <
typename T>
16627 template <
typename T>
16630 template <
typename T>
16633 template <
typename T>
16636 template <
typename T>
16639 template <
typename T>
16644 template <
typename T>
16649 template <
typename T>
16652 template <
typename T>
16654 return std::forward<T>(t);
16657 template <
typename T>
16662 template <
typename T>
16664 return std::forward<T>(t);
16667 template <
typename T>
16689 if (er.
fmt_ ==
nullptr) {
16695 template <
typename X,
typename =
void>
16698 typedef std::remove_pointer_t<meta::unwrap_unqualified_t<X>>
T;
16704 static int at(lua_State* L) {
16705 return luaL_error(L,
"sol: cannot call 'at(index)' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16708 static int get(lua_State* L) {
16709 return luaL_error(L,
"sol: cannot call 'get(key)' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16713 return luaL_error(L,
"sol: cannot call 'container[key]' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16716 static int set(lua_State* L) {
16717 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());
16721 return luaL_error(L,
"sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16725 return luaL_error(L,
"sol: cannot call 'add' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16729 return luaL_error(L,
"sol: cannot call 'insert' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16733 return luaL_error(L,
"sol: cannot call 'find' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16737 return luaL_error(L,
"sol: cannot call 'end' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16741 return luaL_error(L,
"sol: cannot call 'clear' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16745 return luaL_error(L,
"sol: cannot call 'empty' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16749 return luaL_error(L,
"sol: cannot call 'erase' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16753 return luaL_error(L,
"sol: cannot call 'next' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16757 return luaL_error(L,
"sol: cannot call '__pairs/pairs' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16761 return luaL_error(L,
"sol: cannot call '__ipairs' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16765 luaL_error(L,
"sol: cannot call 'being' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16769 static iterator
end(lua_State* L, T&) {
16770 luaL_error(L,
"sol: cannot call 'end' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
16775 template <
typename X>
16776 struct container_traits_default<X, std::enable_if_t<meta::all<is_forced_container<meta::unqualified_t<X>>, meta::has_value_type<meta::unqualified_t<container_decay_t<X>>>, meta::has_iterator<meta::unqualified_t<container_decay_t<X>>>>::value>> {
16778 typedef std::remove_pointer_t<meta::unwrap_unqualified_t<container_decay_t<X>>>
T;
16787 typedef std::conditional_t<is_matched_lookup::value,
16788 std::pair<value_type, value_type>,
16789 std::conditional_t<is_associative::value || is_lookup::value,
16791 std::pair<std::ptrdiff_t, value_type>
16794 typedef typename KV::first_type
K;
16795 typedef typename KV::second_type
V;
16796 typedef std::conditional_t<is_matched_lookup::value, std::ptrdiff_t, K>
next_K;
16797 typedef decltype(*std::declval<iterator&>()) iterator_return;
16798 typedef std::conditional_t<is_associative::value || is_matched_lookup::value,
16799 std::add_lvalue_reference_t<V>,
16800 std::conditional_t<is_lookup::value,
16807 typedef std::conditional_t<is_input_iterator::value,
16812 typedef meta::
neg<meta::any<
16813 std::is_const<V>, std::is_const<std::remove_reference_t<iterator_return>>, meta::
neg<is_copyable>
16824 : source(source), it(std::move(it)), i(0) {
16829 #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE 16830 auto p = stack::unqualified_check_get<T*>(L, 1);
16832 luaL_error(L,
"sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle<T>().c_str());
16834 if (p.value() ==
nullptr) {
16835 luaL_error(L,
"sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
16839 return stack::unqualified_get<T>(L, 1);
16840 #endif // Safe getting with error 16844 pos += deferred_traits::index_adjustment(L,
self);
16848 auto it = deferred_traits::begin(L,
self);
16849 auto e = deferred_traits::end(L,
self);
16860 return get_associative(is_associative(), L, it);
16864 std::ptrdiff_t len =
static_cast<std::ptrdiff_t
>(size_start(L,
self));
16865 pos += deferred_traits::index_adjustment(L,
self);
16866 if (pos < 0 || pos >= len) {
16869 auto it =
std::next(deferred_traits::begin(L,
self), pos);
16870 return get_associative(is_associative(), L, it);
16887 key += deferred_traits::index_adjustment(L,
self);
16891 auto it = deferred_traits::begin(L,
self);
16892 auto e = deferred_traits::end(L,
self);
16903 return get_associative(is_associative(), L, it);
16907 std::ptrdiff_t len =
static_cast<std::ptrdiff_t
>(size_start(L,
self));
16908 key += deferred_traits::index_adjustment(L,
self);
16909 if (key < 0 || key >= len) {
16912 auto it =
std::next(deferred_traits::begin(L,
self), key);
16913 return get_associative(is_associative(), L, it);
16921 auto fx = [&](
const value_type& r) ->
bool {
16922 return key ==
get_key(is_associative(), r);
16924 auto e = deferred_traits::end(L,
self);
16925 auto it = std::find_if(deferred_traits::begin(L,
self), e, std::ref(fx));
16929 return get_associative(is_associative(), L, it);
16933 return error_result(
"cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'", detail::demangle<T>().data(), detail::demangle<K>().data());
16942 v.second = value.
as<V>();
16953 return set_associative(is_associative(), it, std::move(value));
16957 return error_result(
"cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
16961 decltype(
auto) key = okey.
as<K>();
16962 key += deferred_traits::index_adjustment(L,
self);
16963 auto e = deferred_traits::end(L,
self);
16964 auto it = deferred_traits::begin(L,
self);
16966 for (; key > 0 && it != e; --key, ++it) {
16973 return error_result(
"out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
16975 return set_writable(
is_writable(), L,
self, it, std::move(value));
16979 decltype(
auto) key = okey.
as<K>();
16981 return error_result(
"sol: out of bounds (too small) for set on '%s'", detail::demangle<T>().c_str());
16983 key += deferred_traits::index_adjustment(L,
self);
16984 std::ptrdiff_t len =
static_cast<std::ptrdiff_t
>(size_start(L,
self));
16986 return add_copyable(
is_copyable(), L,
self, std::move(value));
16988 else if (key > len) {
16989 return error_result(
"sol: out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
16991 auto it =
std::next(deferred_traits::begin(L,
self), key);
16992 return set_writable(
is_writable(), L,
self, it, std::move(value));
16996 decltype(
auto) key = okey.
as<K>();
16997 if (!is_writable::value) {
16998 return error_result(
"cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
17000 auto fx = [&](
const value_type& r) ->
bool {
17001 return key ==
get_key(is_associative(), r);
17003 auto e = deferred_traits::end(L,
self);
17004 auto it = std::find_if(deferred_traits::begin(L,
self), e, std::ref(fx));
17008 return set_writable(
is_writable(), L,
self, it, std::move(value));
17012 return error_result(
"cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key", detail::demangle<T>().data(), detail::demangle<K>().data());
17016 self.insert(it, value_type(key, value.
as<V>()));
17021 self.insert(it, key);
17026 decltype(
auto) key = okey.
as<K>();
17027 auto it =
self.find(key);
17028 if (it == deferred_traits::end(L,
self)) {
17029 return set_associative_insert(is_associative(), L,
self, it, key, std::move(value));
17031 return set_writable(
is_writable(), L,
self, it, std::move(value));
17039 return set_category(
iterator_category(), L,
self, std::move(key), std::move(value));
17047 decltype(
auto) key = stack::unqualified_get<K>(L, 2);
17048 auto it =
self.find(key);
17049 if (it == deferred_traits::end(L,
self)) {
17052 return get_associative(is_associative(), L, it);
17056 decltype(
auto) value = stack::unqualified_get<V>(L, 2);
17057 auto it =
self.find(value);
17058 if (it == deferred_traits::end(L,
self)) {
17061 return get_associative(is_associative(), L, it);
17069 return get_associative(is_associative(), L, it);
17077 return error_result(
"cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable", detail::demangle<T>().c_str());
17081 decltype(
auto) value = stack::unqualified_get<V>(L, 2);
17082 auto it = deferred_traits::begin(L,
self);
17083 auto e = deferred_traits::end(L,
self);
17084 std::size_t index = 1;
17085 for (;; ++it, ++index) {
17089 if (value ==
get_value(is_associative(), *it)) {
17101 return add_insert_after(std::false_type(), L,
self, value);
17105 return error_result(
"cannot call 'add' on type '%s': no suitable insert/push_back C++ functions", detail::demangle<T>().data());
17109 self.insert_after(pos, value.
as<V>());
17114 auto backit =
self.before_begin();
17116 auto e = deferred_traits::end(L,
self);
17117 for (
auto it = deferred_traits::begin(L,
self); it != e; ++backit, ++it) {
17120 return add_insert_after(std::true_type(), L,
self, value, backit);
17124 self.insert(pos, value.
as<V>());
17129 auto pos = deferred_traits::end(L,
self);
17130 return add_insert(std::true_type(), L,
self, value, pos);
17142 self.push_back(value.
as<V>());
17147 self.push_back(value.
as<V>());
17160 self.insert(pos, value_type(key.
as<K>(), stack::unqualified_get<V>(L, 3)));
17165 auto pos = deferred_traits::end(L,
self);
17166 return add_associative(std::true_type(), L,
self, std::move(key), pos);
17178 return add_associative(is_associative(), L,
self, std::move(value), pos);
17182 return add_associative(is_associative(), L,
self, value);
17186 return add_copyable(std::false_type(), L,
self, std::move(value));
17190 return error_result(
"cannot call 'add' on '%s': value_type is non-copyable", detail::demangle<T>().data());
17195 return add_copyable(std::true_type(), L,
self, std::move(value));
17199 auto it = deferred_traits::begin(L,
self);
17200 auto key = where.
as<K>();
17201 key += deferred_traits::index_adjustment(L,
self);
17202 std::advance(it, key);
17203 self.insert(it, value.
as<V>());
17208 auto key = where.
as<K>();
17209 auto backit =
self.before_begin();
17211 key += deferred_traits::index_adjustment(L,
self);
17212 auto e = deferred_traits::end(L,
self);
17213 for (
auto it = deferred_traits::begin(L,
self); key > 0; ++backit, ++it, --key) {
17215 return error_result(
"sol: out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
17219 self.insert_after(backit, value.
as<V>());
17224 return error_result(
"cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle<T>().data());
17240 return error_result(
"cannot call 'insert' on '%s': value_type is non-copyable", detail::demangle<T>().data());
17244 auto it = deferred_traits::begin(L,
self);
17245 key += deferred_traits::index_adjustment(L,
self);
17246 std::advance(it, key);
17253 auto fx = [&](
const value_type& r) ->
bool {
17256 auto e = deferred_traits::end(L,
self);
17257 auto it = std::find_if(deferred_traits::begin(L,
self), e, std::ref(fx));
17272 return erase_integral(std::is_integral<K>(), L,
self, key);
17276 auto backit =
self.before_begin();
17278 key += deferred_traits::index_adjustment(L,
self);
17279 auto e = deferred_traits::end(L,
self);
17280 for (
auto it = deferred_traits::begin(L,
self); key > 0; ++backit, ++it, --key) {
17282 return error_result(
"sol: out of bounds for erase on '%s'", detail::demangle<T>().c_str());
17286 self.erase_after(backit);
17291 return error_result(
"sol: cannot call erase on '%s'", detail::demangle<T>().c_str());
17302 static auto size_has(std::false_type, lua_State* L, T&
self) {
17303 return std::distance(deferred_traits::begin(L,
self), deferred_traits::end(L,
self));
17306 static auto size_has(std::true_type, lua_State*, T&
self) {
17307 return self.size();
17315 luaL_error(L,
"sol: cannot call clear on '%s'", detail::demangle<T>().c_str());
17319 return self.empty();
17323 return deferred_traits::begin(L,
self) == deferred_traits::end(L,
self);
17352 iter& i = stack::unqualified_get<user<iter>>(L, 1);
17353 auto& source = i.source;
17355 if (it == deferred_traits::end(L, source)) {
17367 std::advance(it, 1);
17373 iter& i = stack::unqualified_get<user<iter>>(L, 1);
17374 auto& source = i.source;
17376 next_K k = stack::unqualified_get<next_K>(L, 2);
17377 if (it == deferred_traits::end(L, source)) {
17383 std::advance(it, 1);
17390 return next_associative<ip>(is_assoc(), L);
17395 auto& src = get_src(L);
17397 stack::push<user<iter>>(L, src, deferred_traits::begin(L, src));
17404 auto& src = get_src(L);
17406 stack::push<user<iter>>(L, src, deferred_traits::begin(L, src));
17412 static int at(lua_State* L) {
17413 auto&
self = get_src(L);
17416 std::ptrdiff_t pos = stack::unqualified_get<std::ptrdiff_t>(L);
17417 er = at_start(L,
self, pos);
17422 static int get(lua_State* L) {
17423 auto&
self = get_src(L);
17426 decltype(
auto) key = stack::unqualified_get<K>(L);
17427 er = get_start(L,
self, key);
17436 static int set(lua_State* L) {
17441 auto&
self = get_src(L);
17451 auto&
self = get_src(L);
17457 auto&
self = get_src(L);
17463 auto&
self = get_src(L);
17468 static iterator
begin(lua_State*, T&
self) {
17470 return begin(
self);
17473 static iterator
end(lua_State*, T&
self) {
17479 auto&
self = get_src(L);
17480 std::size_t r = size_start(L,
self);
17485 auto&
self = get_src(L);
17486 clear_start(L,
self);
17491 auto&
self = get_src(L);
17494 decltype(
auto) key = stack::unqualified_get<K>(L, 2);
17495 er = erase_start(L,
self, key);
17501 auto&
self = get_src(L);
17506 #if defined(SOL_CONTAINERS_START_INDEX) 17507 return static_cast<std::ptrdiff_t
>((SOL_CONTAINERS_START) == 0 ? 0 : -(SOL_CONTAINERS_START));
17509 return static_cast<std::ptrdiff_t
>(-1);
17515 return pairs_associative<false>(is_assoc(), L);
17520 return pairs_associative<true>(is_assoc(), L);
17528 template <
typename X>
17531 typedef std::remove_pointer_t<meta::unwrap_unqualified_t<X>>
T;
17544 : source(source), it(std::move(it)) {
17549 auto p = stack::unqualified_check_get<T*>(L, 1);
17550 #if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE 17552 luaL_error(L,
"sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle<T>().c_str());
17554 if (p.value() ==
nullptr) {
17555 luaL_error(L,
"sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
17557 #endif // Safe getting with error 17561 static int find(std::true_type, lua_State* L) {
17562 T&
self = get_src(L);
17563 decltype(
auto) value = stack::unqualified_get<value_type>(L, 2);
17564 std::size_t N = std::extent<T>::value;
17565 for (std::size_t idx = 0; idx < N; ++idx) {
17566 const auto& v =
self[idx];
17574 static int find(std::false_type, lua_State* L) {
17575 return luaL_error(L,
"sol: cannot call 'find' on '%s': no supported comparison operator for the value type", detail::demangle<T>().c_str());
17579 iter& i = stack::unqualified_get<user<iter>>(L, 1);
17580 auto& source = i.source;
17582 std::size_t k = stack::unqualified_get<std::size_t>(L, 2);
17583 if (it == deferred_traits::end(L, source)) {
17589 std::advance(it, 1);
17595 return luaL_error(L,
"sol: cannot call 'clear' on type '%s': cannot remove all items from a fixed array", detail::demangle<T>().c_str());
17599 return luaL_error(L,
"sol: cannot call 'erase' on type '%s': cannot remove an item from fixed arrays", detail::demangle<T>().c_str());
17603 return luaL_error(L,
"sol: cannot call 'add' on type '%s': cannot add to fixed arrays", detail::demangle<T>().c_str());
17607 return luaL_error(L,
"sol: cannot call 'insert' on type '%s': cannot insert new entries into fixed arrays", detail::demangle<T>().c_str());
17610 static int at(lua_State* L) {
17614 static int get(lua_State* L) {
17615 T&
self = get_src(L);
17616 std::ptrdiff_t idx = stack::unqualified_get<std::ptrdiff_t>(L, 2);
17617 idx += deferred_traits::index_adjustment(L,
self);
17618 if (idx >= static_cast<std::ptrdiff_t>(std::extent<T>::value) || idx < 0) {
17628 static int set(lua_State* L) {
17629 T&
self = get_src(L);
17630 std::ptrdiff_t idx = stack::unqualified_get<std::ptrdiff_t>(L, 2);
17631 idx += deferred_traits::index_adjustment(L,
self);
17632 if (idx >= static_cast<std::ptrdiff_t>(std::extent<T>::value)) {
17633 return luaL_error(L,
"sol: index out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
17636 return luaL_error(L,
"sol: index out of bounds (too small) for set on '%s'", detail::demangle<T>().c_str());
17638 self[idx] = stack::unqualified_get<value_type>(L, 3);
17655 return stack::push(L, std::extent<T>::value > 0);
17659 auto& src = get_src(L);
17661 stack::push<user<iter>>(L, src, deferred_traits::begin(L, src));
17675 #if defined(SOL_CONTAINERS_START_INDEX) 17676 return (SOL_CONTAINERS_START) == 0 ? 0 : -(SOL_CONTAINERS_START);
17682 static iterator
begin(lua_State*, T&
self) {
17683 return std::addressof(
self[0]);
17686 static iterator
end(lua_State*, T&
self) {
17687 return std::addressof(
self[0]) + std::extent<T>::value;
17691 template <
typename X>
17695 template <
typename T>
17704 template <
typename X>
17706 typedef std::remove_pointer_t<meta::unqualified_t<X>>
T;
17711 return traits::index_get(L);
17715 return default_traits::index_get(L);
17720 static const call_map calls{
17721 {
"at", &at_call },
17722 {
"get", &real_get_call },
17723 {
"set", &real_set_call },
17724 {
"size", &real_length_call },
17725 {
"add", &real_add_call },
17726 {
"empty", &real_empty_call },
17727 {
"insert", &real_insert_call },
17728 {
"clear", &real_clear_call },
17729 {
"find", &real_find_call },
17730 {
"erase", &real_erase_call },
17731 {
"pairs", &pairs_call },
17732 {
"next", &next_call },
17734 auto maybenameview = stack::unqualified_check_get<string_view>(L, 2);
17735 if (maybenameview) {
17737 #if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH 17738 auto it = calls.find(nameview,
string_view_hash(), std::equal_to<string_view>());
17741 auto it = calls.find(name);
17743 if (it != calls.cend()) {
17751 return traits::at(L);
17755 return default_traits::at(L);
17775 return traits::set(L);
17779 return default_traits::set(L);
17787 return traits::index_set(L);
17791 return default_traits::index_set(L);
17835 return traits::size(L);
17839 return default_traits::size(L);
17847 return traits::add(L);
17851 return default_traits::add(L);
17859 return traits::insert(L);
17863 return default_traits::insert(L);
17871 return traits::clear(L);
17875 return default_traits::clear(L);
17883 return traits::empty(L);
17887 return default_traits::empty(L);
17895 return traits::erase(L);
17899 return default_traits::erase(L);
17907 return traits::find(L);
17911 return default_traits::find(L);
17919 return detail::typed_static_trampoline<decltype(&real_add_call), (&real_add_call)>(L);
17923 return detail::typed_static_trampoline<decltype(&real_erase_call), (&real_erase_call)>(L);
17927 return detail::typed_static_trampoline<decltype(&real_insert_call), (&real_insert_call)>(L);
17931 return detail::typed_static_trampoline<decltype(&real_clear_call), (&real_clear_call)>(L);
17935 return detail::typed_static_trampoline<decltype(&real_empty_call), (&real_empty_call)>(L);
17939 return detail::typed_static_trampoline<decltype(&real_find_call), (&real_find_call)>(L);
17943 return detail::typed_static_trampoline<decltype(&real_length_call), (&real_length_call)>(L);
17947 return detail::typed_static_trampoline<decltype(&real_pairs_call), (&real_pairs_call)>(L);
17951 return detail::typed_static_trampoline<decltype(&real_ipairs_call), (&real_ipairs_call)>(L);
17955 return detail::typed_static_trampoline<decltype(&real_next_call), (&real_next_call)>(L);
17959 return detail::typed_static_trampoline<decltype(&real_at_call), (&real_at_call)>(L);
17963 return detail::typed_static_trampoline<decltype(&real_get_call), (&real_get_call)>(L);
17967 return detail::typed_static_trampoline<decltype(&real_set_call), (&real_set_call)>(L);
17971 return detail::typed_static_trampoline<decltype(&real_index_call), (&real_index_call)>(L);
17975 return detail::typed_static_trampoline<decltype(&real_new_index_call), (&real_new_index_call)>(L);
17980 namespace stack_detail {
17981 template <
typename T,
bool is_shim = false>
17992 std::remove_pointer_t<T>>>
17995 static const std::array<luaL_Reg, 19> reg = { {
17996 {
"__pairs", &meta_cumt::pairs_call },
17997 {
"__ipairs", &meta_cumt::ipairs_call },
17998 {
"__len", &meta_cumt::length_call },
17999 {
"__index", &meta_cumt::index_call },
18000 {
"__newindex", &meta_cumt::new_index_call },
18001 {
"pairs", &meta_cumt::pairs_call },
18002 {
"next", &meta_cumt::next_call },
18003 {
"at", &meta_cumt::at_call },
18004 {
"get", &meta_cumt::get_call },
18005 {
"set", &meta_cumt::set_call },
18006 {
"size", &meta_cumt::length_call },
18007 {
"empty", &meta_cumt::empty_call },
18008 {
"clear", &meta_cumt::clear_call },
18009 {
"insert", &meta_cumt::insert_call },
18010 {
"add", &meta_cumt::add_call },
18011 {
"find", &meta_cumt::find_call },
18012 {
"erase", &meta_cumt::erase_call },
18013 std::is_pointer<T>::value ? luaL_Reg{
nullptr,
nullptr } : luaL_Reg{
"__gc", &detail::usertype_alloc_destruct<T> },
18014 {
nullptr,
nullptr }
18017 if (luaL_newmetatable(L, metakey) == 1) {
18018 luaL_setfuncs(L, reg.data(), 0);
18020 lua_setmetatable(L, -2);
18025 template <
typename T>
18045 return push_lvalue(std::is_lvalue_reference<T>(), L, cont);
18049 return push_lvalue(std::is_lvalue_reference<T>(), L, as_cont.
source);
18053 return push_rvalue(
meta::all<std::is_rvalue_reference<T>,
meta::neg<std::is_lvalue_reference<T>>>(), L, std::forward<T>(as_cont.source));
18057 template <
typename T>
18059 typedef std::add_pointer_t<meta::unqualified_t<std::remove_pointer_t<T>>>
C;
18061 static int push(lua_State* L, T* cont) {
18067 template <
typename T>
18068 struct pusher<T, std::enable_if_t<meta::all<is_container<meta::unqualified_t<T>>, meta::neg<is_lua_reference<meta::unqualified_t<T>>>>::value>> {
18071 static int push(lua_State* L,
const T& cont) {
18076 static int push(lua_State* L, T&& cont) {
18082 template <
typename T>
18084 typedef std::add_pointer_t<meta::unqualified_t<std::remove_pointer_t<T>>>
C;
18086 static int push(lua_State* L, T* cont) {
18092 template <
typename T,
typename C>
18094 template <
typename Handler>
18095 static bool check(lua_State* L,
int index, Handler&& handler,
record& tracking) {
18096 return stack::check<T>(L, index, std::forward<Handler>(
handler), tracking);
18100 template <
typename T>
18102 static decltype(
auto)
get(lua_State* L,
int index,
record& tracking) {
18103 return stack::unqualified_get<T>(L, index, tracking);
18107 template <
typename T>
18109 static decltype(
auto)
get(lua_State* L,
int index,
record& tracking) {
18110 return stack::unqualified_get<T*>(L, index, tracking);
18124 namespace usertype_detail {
18126 template <
typename A,
typename B>
18132 template <
typename T>
18137 template <
typename T>
18139 decltype(
auto) ts = stack::get<T>(L, 1).
to_string();
18140 return stack::push(L, std::forward<decltype(ts)>(ts));
18143 template <
typename T>
18145 return luaL_error(L,
"cannot perform to_string on '%s': no 'to_string' overload in namespace, 'to_string' member function, or operator<<(ostream&, ...) present", detail::demangle<T>().data());
18148 template <
typename T>
18150 using namespace std;
18151 decltype(
auto) ts =
to_string(stack::get<T>(L, 1));
18152 return stack::push(L, std::forward<decltype(ts)>(ts));
18155 template <
typename T>
18160 template <
typename T>
18162 std::ostringstream oss;
18163 oss << stack::unqualified_get<T>(L, 1);
18167 template <
typename T>
18172 template <
typename T>
18177 template <
typename T,
typename Op>
18179 auto maybel = stack::unqualified_check_get<T&>(L, 1);
18181 auto mayber = stack::unqualified_check_get<T&>(L, 2);
18185 if (std::is_same<no_comp, Op>::value) {
18197 template <
typename T,
typename Op,
typename Supports,
typename Regs, meta::enable<Supports> = meta::enabler>
18199 lua_CFunction f = &comparsion_operator_wrap<T, Op>;
18200 l[index] = luaL_Reg{ name, f };
18204 template <
typename T,
typename Op,
typename Supports,
typename Regs, meta::disable<Supports> = meta::enabler>
18205 inline void make_reg_op(Regs&,
int&,
const char*) {
18209 template <
typename T,
typename Supports,
typename Regs, meta::enable<Supports> = meta::enabler>
18212 lua_CFunction f = &detail::static_trampoline<&default_to_string<T>>;
18213 l[index] = luaL_Reg{ name, f };
18217 template <
typename T,
typename Supports,
typename Regs, meta::disable<Supports> = meta::enabler>
18222 template <
typename T,
typename Regs, meta::enable<meta::has_deducible_signature<T>> = meta::enabler>
18225 lua_CFunction f = &c_call<decltype(&T::operator()), &T::operator()>;
18226 l[index] = luaL_Reg{ name, f };
18230 template <
typename T,
typename Regs, meta::disable<meta::has_deducible_signature<T>> = meta::enabler>
18235 template <
typename T,
typename Regs>
18238 #if defined(__clang__) 18239 l[index] = luaL_Reg{ name, &c_call<decltype(&T::size), &T::size> };
18241 typedef decltype(std::declval<T>().size()) R;
18242 using sz_func = R(T::*)()
const;
18243 l[index] = luaL_Reg{ name, &c_call<decltype(static_cast<sz_func>(&T::size)),
static_cast<sz_func
>(&T::size)> };
18248 template <
typename T,
typename Regs>
18251 #if defined(__clang__) 18252 l[index] = luaL_Reg{ name, &c_call<decltype(&T::size), &T::size> };
18254 typedef decltype(std::declval<T>().size()) R;
18255 using sz_func = R(T::*)();
18256 l[index] = luaL_Reg{ name, &c_call<decltype(static_cast<sz_func>(&T::size)),
static_cast<sz_func
>(&T::size)> };
18261 template <
typename T,
typename Regs, meta::enable<meta::has_size<T>, meta::has_size<const T>> = meta::enabler>
18266 template <
typename T,
typename Regs, meta::disable<meta::has_size<T>, meta::has_size<const T>> = meta::enabler>
18271 template <
typename T,
typename Regs, meta::enable<meta::neg<std::is_po
inter<T>>, std::is_destructible<T>>>
18278 template <
typename T,
typename Regs, meta::disable<meta::neg<std::is_po
inter<T>>, std::is_destructible<T>>>
18280 if (!std::is_destructible<T>::value) {
18286 l[index] = luaL_Reg{ name, &detail::cannot_destruct<T> };
18291 template <
typename T,
typename Regs,
typename Fx>
18296 template <
typename T,
typename Regs,
typename Fx>
18308 usertype_detail::make_reg_op<T, std::conditional_t<meta::supports_op_equal<T>::value, std::equal_to<>,
usertype_detail::no_comp>, std::true_type>(l, index, name);
18316 usertype_detail::make_length_op<T>(l, index);
18319 usertype_detail::make_to_string_op<T, is_to_stringable<T>>(l, index);
18322 usertype_detail::make_call_op<T>(l, index);
18326 template <
typename T,
typename Regs,
typename Fx>
18328 insert_default_registrations<T>(
is_automagical<T>(), l, index, std::forward<Fx>(fx));
18332 namespace stack {
namespace stack_detail {
18333 template <
typename T>
18334 struct undefined_metatable {
18336 typedef std::remove_pointer_t<T>
P;
18345 if (luaL_newmetatable(L, key) == 1) {
18349 usertype_detail::insert_default_registrations<P>(l, index, fx);
18350 usertype_detail::make_destructor<T>(l, index);
18351 luaL_setfuncs(L, l, 0);
18354 lua_createtable(L, 0, 2);
18356 lua_pushlstring(L, name.c_str(), name.size());
18357 lua_setfield(L, -2,
"name");
18358 lua_CFunction is_func = &usertype_detail::is_check<T>;
18359 lua_pushcclosure(L, is_func, 0);
18360 lua_setfield(L, -2,
"is");
18363 lua_setmetatable(L, -2);
18379 namespace usertype_detail {
18401 : index(index), new_index(newindex), runtime_target(runtimetarget) {
18408 virtual int index(lua_State* L) = 0;
18409 virtual int new_index(lua_State* L) = 0;
18413 template <
typename T,
typename F>
18417 template <
typename Arg>
18419 : fx(std::forward<Arg>(arg)) {
18423 return call_detail::call_wrapped<T, true, true>(L, fx);
18427 return call_detail::call_wrapped<T, false, true>(L, fx);
18444 : metakey(mkey), variables(std::move(vars)), functions(std::move(funcs)), index(std::move(i)), newindex(std::move(ni)), indexbaseclasspropogation(index), newindexbaseclasspropogation(newindex) {
18457 : mapping(), indexfunc(ifx), newindexfunc(nifx), runtime(), mustindex(false) {
18466 namespace usertype_detail {
18513 template <
typename Arg>
18519 template <
typename N>
18531 virtual int push_um(lua_State* L) = 0;
18538 lua_Integer magic = lua_tointegerx(L,
upvalue_index(index), &isnum);
18544 object& runtimeobj = runtime[runtimetarget];
18548 template <
typename T,
bool is_index>
18551 #if 0 //defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE 18552 auto maybeaccessor = stack::get<optional<string_view>>(L, is_index ? -1 : -2);
18553 string_view accessor = maybeaccessor.value_or(string_detail::string_shim(
"(unknown)"));
18554 return luaL_error(L,
"sol: attempt to index (get) nil value \"%s\" on userdata (bad (misspelled?) key name or does not exist)", accessor.data());
18557 if (lua_getmetatable(L, 1) == 1) {
18558 int metatarget = lua_gettop(L);
18568 auto maybeaccessor = stack::get<optional<string_view>>(L, is_index ? -1 : -2);
18570 return luaL_error(L,
"sol: attempt to index (set) nil value \"%s\" on userdata (bad (misspelled?) key name or does not exist)", accessor.data());
18576 template <
typename T,
bool is_simple>
18579 auto non_indexable = [&L]() {
18584 if (!maybeaccessor) {
18588 #if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH 18589 auto preexistingit = functions.find(accessor_view,
string_view_hash(), std::equal_to<string_view>());
18592 auto preexistingit = functions.find(accessor);
18594 if (preexistingit == functions.cend()) {
18595 #if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH 18598 functions.emplace_hint(preexistingit, std::move(accessor),
object(L, 3));
18601 preexistingit->second =
object(L, 3);
18610 if (!maybeaccessor) {
18616 int target =
static_cast<int>(runtime.size());
18617 #if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH 18618 auto preexistingit = mapping.find(accessor_view,
string_view_hash(), std::equal_to<string_view>());
18621 auto preexistingit = mapping.find(accessor);
18623 if (preexistingit == mapping.cend()) {
18624 #if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH 18627 runtime.emplace_back(L, 3);
18631 target = preexistingit->second.runtime_target;
18632 runtime[target] =
object(L, 3);
18637 for (std::size_t i = 0; i < 4; lua_settop(L, 3), ++i) {
18638 const char* metakey =
nullptr;
18642 luaL_getmetatable(L, metakey);
18646 luaL_getmetatable(L, metakey);
18650 luaL_getmetatable(L, metakey);
18656 luaL_getmetatable(L, metakey);
18657 lua_getmetatable(L, -1);
18661 int tableindex = lua_gettop(L);
18670 return indexing_fail<T, false>(L);
18675 object& runtimeobj = runtime[runtimetarget];
18676 runtimeobj =
object(L, 3);
18680 template <
bool is_index,
typename Base>
18688 luaL_getmetatable(L, metakey);
18699 lua_CFunction basewalkfunc = stack::pop<lua_CFunction>(L);
18702 stack::get_field<true>(L, gcmetakey);
18703 int value = basewalkfunc(L);
18710 template <
bool is_index,
typename... Bases>
18716 (void)
detail::swallow{0, (walk_single_base<is_index, Bases>(L, found, ret, accessor), 0)...};
18720 template <
typename T>
18722 typedef std::conditional_t<std::is_array<meta::unqualified_t<T>>::value, T&, std::decay_t<T>>
type;
18725 template <
typename T>
18728 template <
typename T,
typename IndexSequence,
typename... Tn>
18731 template <
typename T, std::size_t... I,
typename... Tn>
18733 typedef std::make_index_sequence<
sizeof...(I) * 2>
indices;
18735 typedef std::array<luaL_Reg,
sizeof...(Tn) / 2 + 1 + 31>
regs_t;
18737 typedef std::tuple<clean_type_t<Tn>...>
Tuple;
18738 template <std::
size_t Idx>
18752 template <std::
size_t Idx, meta::enable<std::is_same<lua_CFunction, meta::unqualified_tuple_element<Idx + 1, RawTuple>>> = meta::enabler>
18754 return std::get<Idx + 1>(functions);
18757 template <std::
size_t Idx, meta::disable<std::is_same<lua_CFunction, meta::unqualified_tuple_element<Idx + 1, RawTuple>>> = meta::enabler>
18759 const auto& name = std::get<Idx>(functions);
18765 return has_variables::value;
18775 auto prop_fx = [&](
meta_function mf) {
return !properties[
static_cast<int>(mf)]; };
18776 usertype_detail::insert_default_registrations<T>(l, index, prop_fx);
18777 if (destructfunc !=
nullptr) {
18784 template <std::
size_t Idx,
typename F>
18786 callconstructfunc = call<Idx + 1>;
18787 secondarymeta =
true;
18790 template <std::size_t,
typename... Bases>
18793 if (
sizeof...(Bases) < 1) {
18799 static_assert(
sizeof(
void*) <=
sizeof(
detail::inheritance_check_function),
"The size of this data pointer is too small to fit the inheritance checking function: file a bug report.");
18800 static_assert(
sizeof(
void*) <=
sizeof(
detail::inheritance_cast_function),
"The size of this data pointer is too small to fit the inheritance checking function: file a bug report.");
18807 template <std::
size_t Idx,
typename N,
typename F,
typename = std::enable_if_t<!meta::any_same<meta::unqualified_t<N>, base_
classes_tag, call_construction>::value>>
18813 for (std::size_t i = 0; i < properties.size(); ++i) {
18816 if (mfname == reg.name) {
18819 if (properties[i]) {
18820 #if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS) 18821 throw error(
"sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
18823 assert(
false &&
"sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
18828 if (destructfunc !=
nullptr) {
18829 #if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS) 18830 throw error(
"sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
18832 assert(
false &&
"sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
18835 destructfunc = reg.func;
18838 indexfunc = reg.func;
18843 newindexfunc = reg.func;
18858 template <
typename... Args,
typename = std::enable_if_t<
sizeof...(Args) ==
sizeof...(Tn)>>
18860 :
usertype_metatable_core(&usertype_detail::
indexing_fail<T, true>, &usertype_detail::
metatable_new_index<T, false>), usertype_detail::registrar(), functions(std::forward<Args>(args)...), destructfunc(nullptr), callconstructfunc(nullptr), indexbase(&core_indexing_call<true>), newindexbase(&core_indexing_call<false>), indexbaseclasspropogation(usertype_detail::
walk_all_bases<true>), newindexbaseclasspropogation(usertype_detail::
walk_all_bases<false>), baseclasscheck(nullptr), baseclasscast(nullptr), secondarymeta(contains_variable()), properties() {
18861 properties.reset();
18862 std::initializer_list<typename usertype_detail::mapping_t::value_type> ilist{{std::pair<std::string, usertype_detail::call_information>(
usertype_detail::make_string(std::get<I * 2>(functions)),
18864 &usertype_metatable::real_find_call<I * 2, I * 2 + 1, false>))}...};
18865 this->mapping.insert(ilist);
18867 this->mapping.erase(n);
18869 this->mustindex = contains_variable() || contains_index();
18877 template <std::
size_t I0, std::
size_t I1,
bool is_index>
18881 return real_call_with<I1, is_index, true>(L, f);
18888 auto cfunc = &call<I1, is_index>;
18892 template <
bool is_index>
18895 return is_index ? f.indexfunc(L) : f.newindexfunc(L);
18898 template <
bool is_index,
bool toplevel = false,
bool is_meta_bound = false>
18903 static const int keyidx = -2 +
static_cast<int>(is_index);
18904 if (toplevel && stack::get<type>(L, keyidx) !=
type::string) {
18905 return is_index ? f.indexfunc(L) : f.newindexfunc(L);
18907 int runtime_target = 0;
18910 #if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH 18911 string_view name = stack::get<string_view>(L, keyidx);
18912 auto memberit = f.mapping.find(name,
string_view_hash(), std::equal_to<string_view>());
18914 std::string name = stack::get<std::string>(L, keyidx);
18915 auto memberit = f.mapping.find(name);
18917 if (memberit != f.mapping.cend()) {
18923 if (member !=
nullptr) {
18924 return (member)(L,
static_cast<void*
>(&f), static_cast<usertype_metatable_core&>(f), runtime_target);
18926 if (is_meta_bound && toplevel && !is_index) {
18927 return usertype_detail::metatable_new_index<T, false>(L);
18929 string_view accessor = stack::get<string_view>(L, keyidx);
18931 bool found =
false;
18934 f.indexbaseclasspropogation(L, found, ret, accessor);
18936 f.newindexbaseclasspropogation(L, found, ret, accessor);
18940 if (is_meta_bound) {
18941 return is_index ? usertype_detail::indexing_fail<T, is_index>(L) : usertype_detail::metatable_new_index<T, false>(L);
18943 return toplevel ? (is_index ? f.indexfunc(L) : f.newindexfunc(L)) : -1;
18947 return core_indexing_call<true, true>(L);
18951 return core_indexing_call<false, true>(L);
18955 return core_indexing_call<true, true, true>(L);
18959 return core_indexing_call<false, true, true>(L);
18962 template <std::
size_t Idx,
bool is_index = true,
bool is_variable = false>
18965 return real_call_with<Idx, is_index, is_variable>(L, f);
18968 template <std::
size_t Idx,
bool is_index = true,
bool is_variable = false>
18973 && std::is_same<K, call_construction>::value
18976 auto& f = std::get<Idx>(um.functions);
18977 return call_detail::call_wrapped<T, is_index, is_variable, boost>(L, f);
18980 template <std::
size_t Idx,
bool is_index = true,
bool is_variable = false>
18982 return detail::typed_static_trampoline<decltype(&real_call<Idx, is_index, is_variable>), (&real_call<Idx, is_index, is_variable>)>(L);
18985 template <std::
size_t Idx,
bool is_index = true,
bool is_variable = false>
18987 return detail::typed_static_trampoline<decltype(&real_call_with<Idx, is_index, is_variable>), (&real_call_with<Idx, is_index, is_variable>)>(L);
18991 return detail::typed_static_trampoline<decltype(&real_index_call), (&real_index_call)>(L);
18995 return detail::typed_static_trampoline<decltype(&real_new_index_call), (&real_new_index_call)>(L);
18999 return detail::typed_static_trampoline<decltype(&real_meta_index_call), (&real_meta_index_call)>(L);
19003 return detail::typed_static_trampoline<decltype(&real_meta_new_index_call), (&real_meta_new_index_call)>(L);
19016 template <
typename T, std::size_t... I,
typename... Args>
19023 static int uniqueness = 0;
19028 int appended = snprintf(
nullptr, 0,
"%d", uniqueness);
19029 std::size_t insertionpoint = uniquegcmetakey.length() - 1;
19030 uniquegcmetakey.append(appended,
'\0');
19031 char* uniquetarget = &uniquegcmetakey[insertionpoint];
19032 snprintf(uniquetarget, uniquegcmetakey.length(),
"%d", uniqueness);
19038 stack::push<user<umt_t>>(L,
metatable_key, uniquegcmetakey, std::move(umx));
19041 stack::set_field<true>(L, gcmetakey, umt);
19044 stack::get_field<true>(L, gcmetakey);
19045 umt_t& target_umt = stack::pop<user<umt_t>>(L);
19051 umt_t& um = make_cleanup(L, std::move(umx));
19053 regs_t value_table{{}};
19055 (void)
detail::swallow{0, (um.template make_regs<(I * 2)>(value_table, lastreg, std::get<(I * 2)>(um.functions),
std::get<(I * 2 + 1)>(um.functions)), 0)...};
19056 um.finish_regs(value_table, lastreg);
19057 value_table[lastreg] = {
nullptr,
nullptr};
19058 regs_t ref_table = value_table;
19059 regs_t unique_table = value_table;
19061 if (hasdestructor) {
19062 ref_table[lastreg - 1] = {
nullptr,
nullptr};
19064 unique_table[lastreg - 1] = {value_table[lastreg - 1].name, detail::unique_destruct<T>};
19066 lua_createtable(L, 0, 2);
19074 for (std::size_t i = 0; i < 3; ++i) {
19076 const char* metakey =
nullptr;
19077 luaL_Reg* metaregs =
nullptr;
19081 metaregs = ref_table.data();
19085 metaregs = unique_table.data();
19090 metaregs = value_table.data();
19093 luaL_newmetatable(L, metakey);
19099 luaL_setfuncs(L, metaregs, upvalues);
19101 if (um.baseclasscheck !=
nullptr) {
19104 if (um.baseclasscast !=
nullptr) {
19123 lua_createtable(L, 0, 3);
19126 if (um.callconstructfunc !=
nullptr) {
19129 if (um.secondarymeta) {
19149 luaL_setfuncs(L, value_table.data(), upvalues);
19151 lua_createtable(L, 0, 3);
19155 if (um.callconstructfunc !=
nullptr) {
19181 namespace usertype_detail {
19183 int before = lua_gettop(L);
19185 for (
int i = 1; i <= before; ++i) {
19186 lua_pushvalue(L, i);
19188 lua_call(L, before, LUA_MULTRET);
19189 int after = lua_gettop(L);
19190 return after - before;
19193 template <
typename T,
bool is_index,
bool toplevel = false,
bool has_indexing = false>
19200 static const int keyidx = -2 +
static_cast<int>(is_index);
19203 if (has_indexing) {
19204 object& indexingfunc = is_index
19211 ? indexing_fail<T, is_index>(L)
19212 : metatable_new_index<T, true>(L);
19216 string_view accessor = stack::get<string_view>(L, keyidx);
19219 #if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH 19221 auto vit = variables.find(accessorkey,
string_view_hash(), std::equal_to<string_view>());
19224 auto vit = variables.find(accessorkey);
19225 #endif // Compatible Hash 19226 if (vit != variables.cend()) {
19227 varwrap = vit->second.get();
19230 if (varwrap !=
nullptr) {
19231 return is_index ? varwrap->index(L) : varwrap->new_index(L);
19233 bool function_failed =
false;
19235 #if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH 19237 auto fit = functions.find(accessorkey,
string_view_hash(), std::equal_to<string_view>());
19240 auto fit = functions.find(accessorkey);
19241 #endif // Compatible Hash 19242 if (fit != functions.cend()) {
19243 object& func = fit->second;
19248 function_failed =
true;
19252 if (function_failed) {
19254 object& indexingfunc = is_index
19261 ? indexing_fail<T, is_index>(L)
19262 : metatable_new_index<T, true>(L);
19280 bool found =
false;
19293 object& indexingfunc = is_index
19300 ? indexing_fail<T, is_index>(L)
19301 : metatable_new_index<T, true>(L);
19307 template <
typename T,
bool has_indexing = false>
19309 return simple_core_indexing_call<T, true, true, has_indexing>(L);
19312 template <
typename T,
bool has_indexing = false>
19314 return simple_core_indexing_call<T, false, true, has_indexing>(L);
19317 template <
typename T,
bool has_indexing = false>
19319 #if defined(__clang__) 19322 return detail::typed_static_trampoline<decltype(&simple_real_index_call<T, has_indexing>), (&simple_real_index_call<T, has_indexing>)>(L);
19326 template <
typename T,
bool has_indexing = false>
19328 #if defined(__clang__) 19331 return detail::typed_static_trampoline<decltype(&simple_real_new_index_call<T, has_indexing>), (&simple_real_new_index_call<T, has_indexing>)>(L);
19339 template <
typename T>
19357 template <
typename N>
19361 if (is_indexer == 1) {
19365 else if (is_indexer == 2) {
19369 auto hint = registrations.find(key);
19370 if (hint == registrations.cend()) {
19371 registrations.emplace_hint(hint, std::move(key), std::move(o));
19374 hint->second = std::move(o);
19377 template <
typename N,
typename F,
typename... Args>
19380 callconstructfunc = std::move(o);
19383 template <
typename N,
typename F,
typename... Args>
19385 object o = make_object<F>(L, std::forward<F>(f), std::forward<Args>(args)...);
19386 insert(std::forward<N>(n), std::move(o));
19389 template <
typename N,
typename F>
19394 template <
typename N,
typename F>
19399 template <
typename N,
typename F, meta::enable<meta::is_callable<meta::unwrap_unqualified_t<F>>> = meta::enabler>
19403 callconstructfunc = std::move(o);
19406 insert(std::forward<N>(n), std::move(o));
19409 template <
typename N,
typename F, meta::disable<meta::is_callable<meta::unwrap_unqualified_t<F>>> = meta::enabler>
19414 template <
typename N,
typename F, meta::disable<is_variable_binding<meta::unqualified_t<F>>> = meta::enabler>
19415 void add(lua_State* L, N&& n, F&& f) {
19416 add_function(L, std::forward<N>(n), std::forward<F>(f));
19419 template <
typename N,
typename F, meta::enable<is_variable_binding<meta::unqualified_t<F>>> = meta::enabler>
19420 void add(lua_State*, N&& n, F&& f) {
19422 secondarymeta =
true;
19424 auto o = std::make_unique<usertype_detail::callable_binding<T, std::decay_t<F>>>(std::forward<F>(f));
19425 auto hint = varmap.find(key);
19426 if (hint == varmap.cend()) {
19427 varmap.emplace_hint(hint, std::move(key), std::move(o));
19430 hint->second = std::move(o);
19433 template <
typename N,
typename... Fxs>
19437 callconstructfunc = std::move(o);
19440 insert(std::forward<N>(n), std::move(o));
19443 template <
typename N,
typename... Lists>
19447 callconstructfunc = std::move(o);
19450 insert(std::forward<N>(n), std::move(o));
19453 template <
typename N>
19457 callconstructfunc = std::move(o);
19460 insert(std::forward<N>(n), std::move(o));
19463 template <
typename N,
typename Fx>
19467 callconstructfunc = std::move(o);
19470 insert(std::forward<N>(n), std::move(o));
19473 template <
typename... Bases>
19475 static_assert(
sizeof(
usertype_detail::base_walk) <=
sizeof(
void*),
"size of function pointer is greater than sizeof(void*); cannot work on this platform. Please file a bug report.");
19477 if (
sizeof...(Bases) < 1) {
19483 static_assert(
sizeof(
void*) <=
sizeof(
detail::inheritance_check_function),
"The size of this data pointer is too small to fit the inheritance checking function: Please file a bug report.");
19484 static_assert(
sizeof(
void*) <=
sizeof(
detail::inheritance_cast_function),
"The size of this data pointer is too small to fit the inheritance checking function: Please file a bug report.");
19492 template <std::size_t... I,
typename Tuple>
19494 : callconstructfunc(
lua_nil), indexfunc(
lua_nil), newindexfunc(
lua_nil), indexbase(&usertype_detail::
simple_core_indexing_call<T, true>), newindexbase(&usertype_detail::
simple_core_indexing_call<T, false>), indexbaseclasspropogation(usertype_detail::
walk_all_bases<true>), newindexbaseclasspropogation(&usertype_detail::
walk_all_bases<false>), baseclasscheck(nullptr), baseclasscast(nullptr), mustindex(false), secondarymeta(false), properties() {
19495 properties.fill(
false);
19498 (add(L, detail::forward_get<I * 2>(args), detail::forward_get<I * 2 + 1>(args)), 0)...};
19501 template <
typename... Args>
19503 :
simple_usertype_metatable(v, std::make_index_sequence<sizeof...(Args) / 2>(), L, std::forward_as_tuple(std::forward<Args>(args)...)) {
19506 template <
typename... Args>
19511 template <
typename... Args>
19526 template <
typename... Args,
typename... CArgs>
19531 template <
typename... Args,
typename... Fxs>
19547 template <
typename T>
19552 static int uniqueness = 0;
19557 int appended = snprintf(
nullptr, 0,
"%d", uniqueness);
19558 std::size_t insertionpoint = uniquegcmetakey.length() - 1;
19559 uniquegcmetakey.append(appended,
'\0');
19560 char* uniquetarget = &uniquegcmetakey[insertionpoint];
19561 snprintf(uniquetarget, uniquegcmetakey.length(),
"%d", uniqueness);
19570 stack::set_field<true>(L, gcmetakey, stackvarmap);
19573 stack::get_field<true>(L, gcmetakey);
19578 static int push(lua_State* L, umt_t&& umx) {
19579 bool hasindex = umx.indexfunc.valid();
19580 bool hasnewindex = umx.newindexfunc.valid();
19581 auto& varmap = make_cleanup(L, umx);
19582 auto& properties = umx.properties;
19583 auto sic = hasindex ? &usertype_detail::simple_index_call<T, true> : &usertype_detail::simple_index_call<T, false>;
19584 auto snic = hasnewindex ? &usertype_detail::simple_new_index_call<T, true> : &usertype_detail::simple_new_index_call<T, false>;
19586 lua_createtable(L, 0, 2);
19592 auto safety_check = [&](
const std::string& first) {
19593 for (std::size_t j = 0; j < properties.size(); ++j) {
19596 bool& prop = properties[j];
19597 if (mfname != first)
19602 #if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS 19603 assert(
false &&
"sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
19605 throw error(
"sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
19611 #if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS 19612 assert(
false &&
"sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
19614 throw error(
"sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
19626 for (
auto& kvp : varmap.functions) {
19627 auto& first = std::get<0>(kvp);
19628 safety_check(first);
19633 for (std::size_t j = 0; j < properties.size(); ++j) {
19636 bool& prop = properties[j];
19637 if (mfname != first)
19641 umx.indexfunc = second;
19644 umx.newindexfunc = second;
19652 switch (meta_index) {
19670 for (std::size_t i = 0; i < 3; ++i) {
19671 const char* metakey =
nullptr;
19684 luaL_newmetatable(L, metakey);
19688 for (
auto& kvp : varmap.functions) {
19689 auto& first = std::get<0>(kvp);
19690 auto& second = std::get<1>(kvp);
19691 register_kvp(i, t, first, second);
19693 luaL_Reg opregs[34]{};
19694 int opregsindex = 0;
19695 auto prop_fx = [&](
meta_function mf) {
return !properties[
static_cast<int>(mf)]; };
19696 usertype_detail::insert_default_registrations<T>(opregs, opregsindex, prop_fx);
19698 luaL_setfuncs(L, opregs, 0);
19701 if (umx.baseclasscheck !=
nullptr) {
19704 if (umx.baseclasscast !=
nullptr) {
19712 if (umx.mustindex) {
19731 lua_createtable(L, 0, 2 * static_cast<int>(umx.secondarymeta) + static_cast<int>(umx.callconstructfunc.valid()));
19734 if (umx.callconstructfunc.valid()) {
19737 if (umx.secondarymeta) {
19760 for (
auto& kvp : varmap.functions) {
19761 auto& first = std::get<0>(kvp);
19762 auto& second = std::get<1>(kvp);
19763 register_kvp(2, t, first, second);
19766 lua_createtable(L, 0, 2 + static_cast<int>(umx.callconstructfunc.valid()));
19769 if (umx.callconstructfunc.valid()) {
19807 template <
typename T>
19812 template <
typename... Args>
19814 : metatableregister(std::make_unique<
usertype_metatable<T, std::make_index_sequence<sizeof...(Args) / 2>, Args...>>(std::forward<Args>(args)...)) {
19815 static_assert(
detail::has_destructor<Args...>::value,
"this type does not have an explicit destructor declared; please pass a custom destructor function wrapped in sol::destruct, especially if the type does not have an accessible (private) destructor");
19818 template <
typename... Args>
19823 template <
typename... Args>
19825 :
usertype(meta::
condition<meta::all<std::is_destructible<T>, meta::
neg<detail::
has_destructor<Args...>>>, detail::add_destructor_tag, detail::verified_tag>(), std::forward<Args>(args)...) {
19829 template <
typename... Args>
19834 template <
typename... Args,
typename... CArgs>
19836 :
usertype(detail::check_destructor_tag(), std::forward<Args>(args)...,
"new", constructorlist) {
19839 template <
typename... Args,
typename... Fxs>
19841 :
usertype(detail::check_destructor_tag(), std::forward<Args>(args)...,
"new", constructorlist) {
19844 template <
typename... Args>
19850 return metatableregister.get();
19854 int r = metatableregister->push_um(L);
19855 metatableregister =
nullptr;
19860 template <
typename T>
19867 template <
typename... Args>
19869 : base_t(
simple, L, std::forward<Args>(args)...), state(L) {
19872 template <
typename N,
typename F>
19873 void set(N&& n, F&& f) {
19875 meta->
add(state, std::forward<N>(n), std::forward<F>(f));
19880 template <
typename T>
19883 return user.
push(L);
19895 template <
typename reference_type>
19912 std::ptrdiff_t idx = 0;
19916 : keyidx(-1), idx(-1) {
19920 : ref(std::move(x)) {
19922 tableidx = lua_gettop(ref.lua_state());
19924 this->operator++();
19935 if (lua_next(ref.lua_state(), tableidx) == 0) {
19941 kvp.first =
object(ref.lua_state(), -2);
19942 kvp.second =
object(ref.lua_state(), -1);
19943 lua_pop(ref.lua_state(), 1);
19945 keyidx = lua_gettop(ref.lua_state());
19950 auto saved = *
this;
19951 this->operator++();
19964 return idx == right.
idx;
19968 return idx != right.
idx;
19972 if (keyidx != -1) {
19975 if (ref.lua_state() !=
nullptr && ref.valid()) {
19987 template <std::
size_t n>
19994 lua_pop(L, static_cast<int>(n));
20001 : L(luastate), n(n) {
20004 lua_pop(L, static_cast<int>(n));
20008 return luaL_error(L,
"sol: cannot modify the elements of an enumeration table");
20014 template <
bool top_level,
typename base_type>
20020 template <
typename... Args>
20023 template <
typename Fx>
20027 while (lua_next(base_t::lua_state(), -2)) {
20028 object key(base_t::lua_state(), -2);
20029 object value(base_t::lua_state(), -1);
20030 std::pair<object&, object&> keyvalue(key, value);
20036 template <
typename Fx>
20040 while (lua_next(base_t::lua_state(), -2)) {
20041 object key(base_t::lua_state(), -2);
20042 object value(base_t::lua_state(), -1);
20048 template <
bool raw,
typename Ret0,
typename Ret1,
typename... Ret, std::size_t... I,
typename Keys>
20050 -> decltype(stack::
pop<std::tuple<Ret0, Ret1, Ret...>>(
nullptr)) {
20051 typedef decltype(
stack::pop<std::tuple<Ret0, Ret1, Ret...>>(
nullptr)) Tup;
20058 template <
bool raw,
typename Ret, std::
size_t I,
typename Keys>
20059 decltype(
auto) tuple_get(
types<Ret>, std::index_sequence<I>, Keys&& keys)
const {
20063 template <
bool raw,
typename Pairs, std::size_t... I>
20065 auto pp = stack::push_pop < top_level && (is_global<decltype(detail::forward_get<I * 2>(
pairs))...>::value) > (*
this);
20066 void(
detail::swallow{ (stack::set_field<top_level, raw>(base_t::lua_state(),
20067 detail::forward_get<I * 2>(
pairs),
20068 detail::forward_get<I * 2 + 1>(
pairs),
20069 lua_gettop(base_t::lua_state())),
20073 template <
bool global,
bool raw,
typename T,
typename Key>
20074 decltype(
auto) traverse_get_deep(Key&& key)
const {
20075 stack::get_field<global, raw>(base_t::lua_state(), std::forward<Key>(key));
20076 return stack::get<T>(base_t::lua_state());
20079 template <
bool global,
bool raw,
typename T,
typename Key,
typename... Keys>
20080 decltype(
auto) traverse_get_deep(Key&& key, Keys&&... keys)
const {
20081 stack::get_field<global, raw>(base_t::lua_state(), std::forward<Key>(key));
20082 return traverse_get_deep<false, raw, T>(std::forward<Keys>(keys)...);
20085 template <
bool global,
bool raw,
typename T, std::
size_t I,
typename Key>
20086 decltype(
auto) traverse_get_deep_optional(
int& popcount, Key&& key)
const {
20087 typedef decltype(stack::get<T>(base_t::lua_state())) R;
20088 auto p = stack::probe_get_field<global, raw, T>(base_t::lua_state(), std::forward<Key>(key), lua_gettop(base_t::lua_state()));
20089 popcount += p.levels;
20092 return stack::get<T>(base_t::lua_state());
20095 template <
bool global,
bool raw,
typename T, std::size_t I,
typename Key,
typename... Keys>
20096 decltype(
auto) traverse_get_deep_optional(
int& popcount, Key&& key, Keys&&... keys)
const {
20097 auto p = I > 0 ? stack::probe_get_field<global>(base_t::lua_state(), std::forward<Key>(key), -1) : stack::probe_get_field<global>(base_t::lua_state(), std::forward<Key>(key), lua_gettop(base_t::lua_state()));
20098 popcount += p.levels;
20101 return traverse_get_deep_optional<false, raw, T, I + 1>(popcount, std::forward<Keys>(keys)...);
20104 template <
bool global,
bool raw,
typename T,
typename... Keys>
20105 decltype(
auto) traverse_get_optional(std::false_type, Keys&&... keys)
const {
20107 return traverse_get_deep<global, raw, T>(std::forward<Keys>(keys)...);
20110 template <
bool global,
bool raw,
typename T,
typename... Keys>
20111 decltype(
auto) traverse_get_optional(std::true_type, Keys&&... keys)
const {
20114 return traverse_get_deep_optional<global, raw, T, 0>(popcount, std::forward<Keys>(keys)...);
20117 template <
bool global,
bool raw,
typename Key,
typename Value>
20119 stack::set_field<global, raw>(base_t::lua_state(), std::forward<Key>(key), std::forward<Value>(value));
20122 template <
bool global,
bool raw,
typename Key,
typename... Keys>
20124 stack::get_field<global, raw>(base_t::lua_state(), std::forward<Key>(key));
20125 traverse_set_deep<false, raw>(std::forward<Keys>(keys)...);
20137 : base_t(L, index) {
20140 : base_t(L, index) {
20142 template <
typename T, meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_table_core>>, meta::neg<std::is_same<base_type, stack_reference>>, meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
20144 : base_t(std::forward<T>(r)) {
20146 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
20148 : base_t(L, std::forward<T>(r)) {
20155 using base_t::lua_state;
20168 template <
typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
20170 : base_t(L, std::forward<T>(r)) {
20171 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 20174 stack::check<basic_table_core>(lua_state(), -1,
handler);
20178 : base_t(L, -stack::
push(L, nt)) {
20185 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 20187 stack::check<basic_table_core>(L, index,
handler);
20192 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 20195 stack::check<basic_table_core>(lua_state(), -1,
handler);
20198 template <
typename T, meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_table_core>>, meta::neg<std::is_same<base_type, stack_reference>>, meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
20201 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 20205 stack::check<basic_table_core>(base_t::lua_state(), -1,
handler);
20214 return iterator(*
this);
20229 template <
typename... Ret,
typename... Keys>
20230 decltype(
auto)
get(Keys&&... keys)
const {
20231 static_assert(
sizeof...(Keys) ==
sizeof...(Ret),
"number of keys and number of return types do not match");
20233 return tuple_get<false>(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), std::forward_as_tuple(std::forward<Keys>(keys)...));
20236 template <
typename T,
typename Key>
20237 decltype(
auto) get_or(Key&& key, T&& otherwise)
const {
20238 typedef decltype(get<T>(
"")) U;
20239 optional<U> option = get<optional<U>>(std::forward<Key>(key));
20241 return static_cast<U
>(option.
value());
20243 return static_cast<U
>(std::forward<T>(otherwise));
20246 template <
typename T,
typename Key,
typename D>
20247 decltype(
auto) get_or(Key&& key, D&& otherwise)
const {
20248 optional<T> option = get<optional<T>>(std::forward<Key>(key));
20250 return static_cast<T
>(option.
value());
20252 return static_cast<T
>(std::forward<D>(otherwise));
20255 template <
typename T,
typename... Keys>
20256 decltype(
auto) traverse_get(Keys&&... keys)
const {
20261 template <
typename... Keys>
20264 auto pn =
stack::pop_n(base_t::lua_state(), static_cast<int>(
sizeof...(Keys) - 2));
20265 traverse_set_deep<top_level, false>(std::forward<Keys>(keys)...);
20269 template <
typename... Args>
20271 tuple_set<false>(std::make_index_sequence<
sizeof...(Args) / 2>(), std::forward_as_tuple(std::forward<Args>(args)...));
20275 template <
typename... Ret,
typename... Keys>
20276 decltype(
auto) raw_get(Keys&&... keys)
const {
20277 static_assert(
sizeof...(Keys) ==
sizeof...(Ret),
"number of keys and number of return types do not match");
20279 return tuple_get<true>(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), std::forward_as_tuple(std::forward<Keys>(keys)...));
20282 template <
typename T,
typename Key>
20283 decltype(
auto) raw_get_or(Key&& key, T&& otherwise)
const {
20284 typedef decltype(raw_get<T>(
"")) U;
20285 optional<U> option = raw_get<optional<U>>(std::forward<Key>(key));
20287 return static_cast<U
>(option.
value());
20289 return static_cast<U
>(std::forward<T>(otherwise));
20292 template <
typename T,
typename Key,
typename D>
20293 decltype(
auto) raw_get_or(Key&& key, D&& otherwise)
const {
20294 optional<T> option = raw_get<optional<T>>(std::forward<Key>(key));
20296 return static_cast<T
>(option.
value());
20298 return static_cast<T
>(std::forward<D>(otherwise));
20301 template <
typename T,
typename... Keys>
20302 decltype(
auto) traverse_raw_get(Keys&&... keys)
const {
20307 template <
typename... Keys>
20310 auto pn =
stack::pop_n(base_t::lua_state(), static_cast<int>(
sizeof...(Keys) - 2));
20311 traverse_set_deep<top_level, true>(std::forward<Keys>(keys)...);
20315 template <
typename... Args>
20317 tuple_set<true>(std::make_index_sequence<
sizeof...(Args) / 2>(), std::forward_as_tuple(std::forward<Args>(args)...));
20321 template <
typename T>
20326 template <
typename Key,
typename T>
20328 return set(std::forward<Key>(key), user);
20331 template <
typename Class,
typename... Args>
20334 set_usertype(name, utype);
20338 template <
typename Class,
typename CTor0,
typename... CTor,
typename... Args>
20341 return new_usertype<Class>(name, ctor, std::forward<Args>(args)...);
20344 template <
typename Class,
typename... CArgs,
typename... Args>
20347 set_usertype(name, utype);
20351 template <
typename Class,
typename... Args>
20354 set_usertype(name, utype);
20358 template <
typename Class,
typename CTor0,
typename... CTor,
typename... Args>
20361 return new_simple_usertype<Class>(name, ctor, std::forward<Args>(args)...);
20364 template <
typename Class,
typename... CArgs,
typename... Args>
20367 set_usertype(name, utype);
20371 template <
typename Class,
typename... Args>
20377 template <
typename Class,
typename CTor0,
typename... CTor,
typename... Args>
20380 return create_simple_usertype<Class>(ctor, std::forward<Args>(args)...);
20383 template <
typename Class,
typename... CArgs,
typename... Args>
20389 template <
bool read_only =
true,
typename... Args>
20391 table target = create_with(std::forward<Args>(args)...);
20393 table x = create_with(
20405 template <
typename T,
bool read_only = true>
20407 table target =
create(static_cast<int>(items.size()), static_cast<int>(0));
20408 for (
const auto& kvp : items) {
20409 target.
set(kvp.first, kvp.second);
20412 table x = create_with(
20424 template <
typename Fx>
20427 for_each(is_paired(), std::forward<Fx>(fx));
20432 lua_len(base_t::lua_state(), -1);
20433 return stack::pop<size_t>(base_t::lua_state());
20437 return cbegin() == cend();
20440 template <
typename T>
20445 template <
typename T>
20450 template <
typename T>
20455 template <
typename Sig,
typename Key,
typename... Args>
20457 set_fx(
types<Sig>(), std::forward<Key>(key), std::forward<Args>(args)...);
20461 template <
typename Key,
typename... Args>
20463 set_fx(
types<>(), std::forward<Key>(key), std::forward<Args>(args)...);
20467 template <
typename... Args>
20471 (
stack::set_ref(base_t::lua_state(), std::forward<Args>(args)), 0)... };
20476 template <
typename R,
typename... Args,
typename Fx,
typename Key,
typename = std::result_of_t<Fx(Args...)>>
20478 set_resolved_function<R(Args...)>(std::forward<Key>(key), std::forward<Fx>(fx));
20481 template <
typename Fx,
typename Key, meta::enable<meta::is_specialization_of<meta::unqualified_t<Fx>, overload_set>> = meta::enabler>
20483 set(std::forward<Key>(key), std::forward<Fx>(fx));
20488 set(std::forward<Key>(key),
as_function_reference(std::forward<Fx>(fx), std::forward<Args>(args)...));
20491 template <
typename... Sig,
typename... Args,
typename Key>
20498 lua_createtable(L, narr, nrec);
20504 template <
typename Key,
typename Value,
typename... Args>
20505 static inline table create(lua_State* L,
int narr,
int nrec, Key&& key, Value&& value, Args&&... args) {
20506 lua_createtable(L, narr, nrec);
20508 result.
set(std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
20513 template <
typename... Args>
20515 static_assert(
sizeof...(Args) % 2 == 0,
"You must have an even number of arguments for a key, value ... list.");
20517 return create(L, narr, static_cast<int>((
sizeof...(Args) / 2) - narr), std::forward<Args>(args)...);
20521 return create(base_t::lua_state(), narr, nrec);
20524 template <
typename Key,
typename Value,
typename... Args>
20525 table create(
int narr,
int nrec, Key&& key, Value&& value, Args&&... args) {
20526 return create(base_t::lua_state(), narr, nrec, std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
20529 template <
typename Name>
20531 table x =
create(base_t::lua_state(), narr, nrec);
20532 this->
set(std::forward<Name>(name), x);
20536 template <
typename Name,
typename Key,
typename Value,
typename... Args>
20537 table create(Name&& name,
int narr,
int nrec, Key&& key, Value&& value, Args&&... args) {
20538 table x =
create(base_t::lua_state(), narr, nrec, std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
20539 this->
set(std::forward<Name>(name), x);
20543 template <
typename... Args>
20545 return create_with(base_t::lua_state(), std::forward<Args>(args)...);
20548 template <
typename Name,
typename... Args>
20551 return create(std::forward<Name>(name), narr, (
sizeof...(Args) / 2) - narr, std::forward<Args>(args)...);
20564 static table
get(lua_State* L,
int index = -1) {
20565 if (lua_getmetatable(L, index) == 0) {
20566 return table(L,
ref_index(LUA_REFNIL));
20568 return table(L, -1);
20580 template <
typename base_type>
20586 using base_t::lua_state;
20601 : base_t(L, std::move(nt)) {
20614 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 20616 stack::check<env_t>(this->lua_state(), -1,
handler);
20618 lua_pop(this->lua_state(), 2);
20623 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 20625 stack::check<env_t>(this->lua_state(), -1,
handler);
20627 lua_pop(this->lua_state(), 2);
20630 : base_t(detail::
no_safety, L, index) {
20631 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 20633 stack::check<basic_environment>(L, index,
handler);
20637 : base_t(detail::
no_safety, L, index) {
20638 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 20641 stack::check<basic_environment>(L, -1,
handler);
20644 template <
typename T, meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_environment>>, meta::neg<std::is_same<base_type, stack_reference>>, meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
20646 : base_t(detail::
no_safety, std::forward<T>(r)) {
20647 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 20651 stack::check<basic_environment>(lua_state(), -1,
handler);
20659 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
20661 : base_t(detail::
no_safety, L, std::forward<T>(r)) {
20662 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 20666 stack::check<basic_environment>(lua_state(), -1,
handler);
20671 template <
typename T>
20673 lua_State* L = target.lua_state();
20675 #if SOL_LUA_VERSION < 502 20678 lua_setfenv(L, -2);
20682 const char* name = lua_setupvalue(L, -2, 1);
20683 if (name ==
nullptr) {
20690 template <
typename T,
typename E>
20695 template <
typename E = reference,
typename T>
20697 lua_State* L = target.lua_state();
20709 : env(std::move(e)) {
20716 explicit operator bool()
const {
20717 return static_cast<bool>(env);
20729 return env.
value();
20733 return env.
value();
20753 int pre_stack_size = lua_gettop(L);
20754 if (lua_getstack(L, 1, &info) != 1) {
20755 if (lua_getstack(L, 0, &info) != 1) {
20756 lua_settop(L, pre_stack_size);
20760 if (lua_getinfo(L,
"f", &info) == 0) {
20761 lua_settop(L, pre_stack_size);
20767 if (!env.valid()) {
20768 lua_settop(L, pre_stack_size);
20790 template <
typename T>
20795 return stack::get<optional<T>>(L, index);
20798 template <
typename T>
20800 #if defined(SOL_SAFE_PROXIES) && SOL_SAFE_PROXIES != 0 20804 #endif // Check Argument Safety 20805 return stack::get<T>(L, index);
20816 #if defined(SOL_SAFE_PROXIES) && SOL_SAFE_PROXIES != 0 20820 #endif // Check Argument Safety 20827 : L(Ls), index(stackindex), returncount(retnum), popcount(popnum), err(lerr) {
20832 : L(o.L), index(o.index), returncount(o.returncount), popcount(o.popcount), err(o.err) {
20845 returncount = o.returncount;
20846 popcount = o.popcount;
20867 template <
typename T>
20872 template <
typename... Ret,
typename... Args>
20873 decltype(
auto) call(Args&&... args) {
20874 #if !defined(__clang__) && defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 191200000 20876 return get<protected_function>().call<Ret...>(std::forward<Args>(args)...);
20878 return get<protected_function>().
template call<Ret...>(std::forward<Args>(args)...);
20882 template <
typename... Args>
20883 decltype(
auto) operator()(Args&&... args) {
20884 return call<>(std::forward<Args>(args)...);
20904 #if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS 20909 #if SOL_LUA_VERSION < 502 20910 if (L ==
nullptr) {
20923 #if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS 20927 size_t messagesize;
20928 const char* message = lua_tolstring(L, -1, &messagesize);
20932 #if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS 20933 std::cerr <<
"[sol2] An error occurred and panic has been invoked: ";
20935 std::cerr << std::endl;
20940 throw error(
std::string(
"An unexpected error occurred and panic has been invoked"));
20941 #endif // Printing Errors 20945 std::string msg =
"An unknown error has triggered the default error handler";
20949 msg.assign(topmsg.
data(), topmsg.
size());
20951 luaL_traceback(L, L, msg.c_str(), 1);
20953 if (maybetraceback) {
20954 const string_view& traceback = maybetraceback.value();
20955 msg.assign(traceback.
data(), traceback.
size());
20957 #if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS 20966 lua_atpanic(L, panic_function);
20974 std::size_t kb = lua_gc(L, LUA_GCCOUNT, 0);
20976 kb += lua_gc(L, LUA_GCCOUNTB, 0);
20989 #if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS) 20990 std::exception_ptr eptr = std::current_exception();
20994 std::rethrow_exception(eptr);
20996 catch (
const std::exception& ex) {
20997 err +=
"std::exception -- ";
20998 err.append(ex.what());
21001 err +=
"thrown message -- ";
21002 err.append(message);
21004 catch (
const char* message) {
21005 err +=
"thrown message -- ";
21006 err.append(message);
21009 err.append(
"thrown but unknown type, cannot serialize into error message");
21012 #endif // serialize exception information if possible 21016 err.append(serr.
data(), serr.
size());
21018 #if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS 21019 std::cerr <<
"[sol2] An error occurred and has been passed to an error handler: ";
21021 std::cerr << std::endl;
21029 int top = lua_gettop(L);
21030 int towards = top - target;
21031 if (towards != 0) {
21032 lua_rotate(L, top, towards);
21034 #if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS 21039 #endif // If exceptions are allowed 21043 #if defined(SOL_DEFAULT_PASS_ON_ERROR) && SOL_DEFAULT_PASS_ON_ERROR 21063 bool is53mod = loaded && !(loaded->is<
bool>() && !loaded->as<
bool>());
21066 #if SOL_LUA_VERSION <= 501 21068 bool is51mod = loaded51 && !(loaded51->is<
bool>() && !loaded51->as<
bool>());
21075 template <
typename T>
21077 #if SOL_LUA_VERSION <= 501 21078 auto pkg = global[
"package"];
21079 if (!pkg.valid()) {
21080 pkg = create_table_with(
"loaded", create_table_with(key, sr));
21083 auto ld = pkg[
"loaded"];
21085 ld = create_table_with(key, sr);
21092 auto loaded = reg[
"_LOADED"];
21093 if (!loaded.valid()) {
21094 loaded = create_table_with(key, sr);
21101 template <
typename Fx>
21104 if (loaded && loaded->valid())
21105 return std::move(*loaded);
21110 ensure_package(key, sr);
21111 return stack::pop<object>(L);
21119 : L(Ls), reg(Ls, LUA_REGISTRYINDEX), global(Ls, detail::
global_) {
21130 template <
typename... Args>
21133 if (
sizeof...(args) == 0) {
21138 lib libraries[1 +
sizeof...(args)] = {
lib::count, std::forward<Args>(args)...};
21140 for (
auto&& library : libraries) {
21142 #if SOL_LUA_VERSION <= 501 && defined(SOL_LUAJIT) 21144 #endif // luajit opens coroutine base stuff 21146 luaL_requiref(L,
"base", luaopen_base, 1);
21150 luaL_requiref(L,
"package", luaopen_package, 1);
21153 #if !defined(SOL_LUAJIT) 21155 #if SOL_LUA_VERSION > 501 21156 luaL_requiref(L,
"coroutine", luaopen_coroutine, 1);
21158 #endif // Lua 5.2+ only 21160 #endif // Not LuaJIT - comes builtin 21162 luaL_requiref(L,
"string", luaopen_string, 1);
21166 luaL_requiref(L,
"table", luaopen_table, 1);
21170 luaL_requiref(L,
"math", luaopen_math, 1);
21175 luaL_requiref(L,
"bit32", luaopen_bit, 1);
21177 #elif (SOL_LUA_VERSION == 502) || defined(LUA_COMPAT_BITLIB) || defined(LUA_COMPAT_5_2) 21178 luaL_requiref(L,
"bit32", luaopen_bit32, 1);
21181 #endif // Lua 5.2 only (deprecated in 5.3 (503)) (Can be turned on with Compat flags) 21184 luaL_requiref(L,
"io", luaopen_io, 1);
21188 luaL_requiref(L,
"os", luaopen_os, 1);
21192 luaL_requiref(L,
"debug", luaopen_debug, 1);
21196 #if SOL_LUA_VERSION > 502 && !defined(SOL_LUAJIT) 21197 luaL_requiref(L,
"utf8", luaopen_utf8, 1);
21199 #endif // Lua 5.3+ only 21203 luaL_requiref(L,
"ffi", luaopen_ffi, 1);
21205 #endif // LuaJIT only 21209 luaL_requiref(L,
"jit", luaopen_jit, 0);
21211 #endif // LuaJIT Only 21221 luaL_requiref(L, key.c_str(), open_function, create_global ? 1 : 0);
21222 return stack::pop<object>(L);
21226 auto action = [
this, &code, &chunkname, &mode]() {
21229 return require_core(key, action, create_global);
21233 auto action = [
this, &filename, &mode]() {
21236 return require_core(key, action, create_global);
21239 template <
typename E>
21252 template <
typename E>
21283 template <
typename Fx, meta::disable_any<meta::is_
string_constructible<meta::unqualified_t<Fx>>, meta::is_specialization_of<meta::unqualified_t<Fx>, basic_environment>> = meta::enabler>
21286 if (!pfr.
valid()) {
21287 return on_error(L, std::move(pfr));
21292 template <
typename Fx,
typename E>
21295 if (!pfr.
valid()) {
21296 return on_error(L, std::move(pfr));
21301 template <
typename E>
21310 template <
typename Fx, meta::disable_any<meta::is_
string_constructible<meta::unqualified_t<Fx>>, meta::is_specialization_of<meta::unqualified_t<Fx>, basic_environment>> = meta::enabler>
21313 if (!pfr.
valid()) {
21314 return on_error(L, std::move(pfr));
21319 template <
typename Fx,
typename E>
21322 if (!pfr.
valid()) {
21323 return on_error(L, std::move(pfr));
21328 template <
typename E>
21337 template <
typename E>
21341 int index = lua_gettop(L);
21342 if (luaL_loadbufferx(L, code.
data(), code.
size(), chunknametarget,
to_string(mode).c_str())) {
21346 if (lua_pcall(L, 0, LUA_MULTRET, 0)) {
21349 int postindex = lua_gettop(L);
21350 int returns = postindex - index;
21355 int index = lua_gettop(L);
21357 int postindex = lua_gettop(L);
21358 int returns = postindex - index;
21362 template <
typename E>
21364 int index = lua_gettop(L);
21365 if (luaL_loadfilex(L, filename.c_str(),
to_string(mode).c_str())) {
21369 if (lua_pcall(L, 0, LUA_MULTRET, 0)) {
21372 int postindex = lua_gettop(L);
21373 int returns = postindex - index;
21378 int index = lua_gettop(L);
21380 int postindex = lua_gettop(L);
21381 int returns = postindex - index;
21385 template <
typename Fx, meta::disable_any<meta::is_
string_constructible<meta::unqualified_t<Fx>>, meta::is_specialization_of<meta::unqualified_t<Fx>, basic_environment>> = meta::enabler>
21387 return safe_script(code, std::forward<Fx>(on_error), chunkname, mode);
21390 template <
typename Fx, meta::disable_any<meta::is_
string_constructible<meta::unqualified_t<Fx>>, meta::is_specialization_of<meta::unqualified_t<Fx>, basic_environment>> = meta::enabler>
21392 return safe_script_file(filename, std::forward<Fx>(on_error), mode);
21395 template <
typename Fx,
typename E>
21397 return safe_script(code, env, std::forward<Fx>(on_error), chunkname, mode);
21400 template <
typename Fx,
typename E>
21402 return safe_script_file(filename, env, std::forward<Fx>(on_error), mode);
21413 #if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION 21415 return safe_script(code, chunkname, mode);
21419 return safe_script_file(filename, mode);
21423 return unsafe_script(code, chunkname, mode);
21427 return unsafe_script_file(filename, mode);
21438 return load(
string_view(buff, size), chunkname, mode);
21454 return global.
begin();
21458 return global.
end();
21466 return global.
cend();
21486 int s = stack_top();
21492 lua_gc(lua_state(), LUA_GCCOLLECT, 0);
21495 operator lua_State*()
const {
21496 return lua_state();
21500 lua_atpanic(lua_state(), panic);
21507 template <
typename... Args,
typename... Keys>
21508 decltype(
auto)
get(Keys&&... keys)
const {
21509 return global.
get<Args...>(std::forward<Keys>(keys)...);
21512 template <
typename T,
typename Key>
21513 decltype(
auto) get_or(Key&& key, T&& otherwise)
const {
21514 return global.
get_or(std::forward<Key>(key), std::forward<T>(otherwise));
21517 template <
typename T,
typename Key,
typename D>
21518 decltype(
auto) get_or(Key&& key, D&& otherwise)
const {
21519 return global.
get_or<T>(std::forward<Key>(key), std::forward<D>(otherwise));
21522 template <
typename... Args>
21524 global.
set(std::forward<Args>(args)...);
21528 template <
typename T,
typename... Keys>
21529 decltype(
auto) traverse_get(Keys&&... keys)
const {
21530 return global.
traverse_get<T>(std::forward<Keys>(keys)...);
21533 template <
typename... Args>
21539 template <
typename T>
21544 template <
typename Key,
typename T>
21550 template <
typename Class,
typename... Args>
21552 global.
new_usertype<Class>(name, std::forward<Args>(args)...);
21556 template <
typename Class,
typename CTor0,
typename... CTor,
typename... Args>
21558 global.
new_usertype<Class, CTor0, CTor...>(name, std::forward<Args>(args)...);
21562 template <
typename Class,
typename... CArgs,
typename... Args>
21564 global.
new_usertype<Class>(name, ctor, std::forward<Args>(args)...);
21568 template <
typename Class,
typename... Args>
21574 template <
typename Class,
typename CTor0,
typename... CTor,
typename... Args>
21580 template <
typename Class,
typename... CArgs,
typename... Args>
21586 template <
typename Class,
typename... Args>
21591 template <
typename Class,
typename CTor0,
typename... CTor,
typename... Args>
21596 template <
typename Class,
typename... CArgs,
typename... Args>
21601 template <
bool read_only =
true,
typename... Args>
21603 global.
new_enum<read_only>(name, std::forward<Args>(args)...);
21607 template <
typename T,
bool read_only = true>
21609 global.
new_enum<T, read_only>(name, std::move(items));
21613 template <
typename Fx>
21615 global.
for_each(std::forward<Fx>(fx));
21618 template <
typename T>
21620 return global[std::forward<T>(key)];
21623 template <
typename T>
21625 return global[std::forward<T>(key)];
21628 template <
typename Sig,
typename... Args,
typename Key>
21630 global.
set_function<Sig>(std::forward<Key>(key), std::forward<Args>(args)...);
21634 template <
typename... Args,
typename Key>
21636 global.
set_function(std::forward<Key>(key), std::forward<Args>(args)...);
21640 template <
typename Name>
21642 return global.
create(std::forward<Name>(name), narr, nrec);
21645 template <
typename Name,
typename Key,
typename Value,
typename... Args>
21647 return global.
create(std::forward<Name>(name), narr, nrec, std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
21650 template <
typename Name,
typename... Args>
21653 global.
set(std::forward<Name>(name), x);
21658 return create_table(lua_state(), narr, nrec);
21661 template <
typename Key,
typename Value,
typename... Args>
21663 return create_table(lua_state(), narr, nrec, std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
21666 template <
typename... Args>
21668 return create_table_with(lua_state(), std::forward<Args>(args)...);
21675 template <
typename Key,
typename Value,
typename... Args>
21676 static inline table create_table(lua_State* L,
int narr,
int nrec, Key&& key, Value&& value, Args&&... args) {
21677 return global_table::create(L, narr, nrec, std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
21680 template <
typename... Args>
21702 operator lua_State*()
const noexcept {
21703 return lua_state();
21706 return lua_state();
21714 lua_pushthread(lts.
L);
21730 template <
typename Handler>
21743 template <
typename base_t>
21746 using base_t::lua_state;
21751 template <
typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_thread>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
21753 : base_t(std::forward<T>(r)) {
21754 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 21757 stack::check<basic_thread>(lua_state(), -1,
handler);
21766 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
21768 : base_t(L, std::forward<T>(r)) {
21769 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 21772 stack::check<basic_thread>(lua_state(), -1,
handler);
21776 : base_t(L, index) {
21777 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 21779 stack::check<basic_thread>(L, index,
handler);
21783 : base_t(L, index) {
21784 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 21787 stack::check<basic_thread>(lua_state(), -1,
handler);
21797 : base_t(L, -stack::
push(L, actualthread)) {
21798 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 21800 stack::check<basic_thread>(lua_state(), -1,
handler);
21803 lua_pop(lua_state(), 1);
21817 lua_State* lthread = lua_tothread(lua_state(), -1);
21822 lua_State* lthread = thread_state();
21823 auto lstat =
static_cast<thread_status>(lua_status(lthread));
21826 if (lua_getstack(lthread, 0, &ar) > 0)
21828 else if (lua_gettop(lthread) == 0)
21837 return create(lua_state());
21864 : unique_base(luaL_newstate()),
state_view(unique_base::
get()) {
21868 state(lua_CFunction panic, lua_Alloc alfunc,
void* alpointer =
nullptr)
21869 : unique_base(lua_newstate(alfunc, alpointer)),
state_view(unique_base::
get()) {
21877 state_view::operator=(std::move(that));
21878 unique_base::operator=(std::move(that));
21894 template <
typename base_t>
21903 void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) {
21904 #if SOL_LUA_VERSION >= 504 21906 stats =
static_cast<call_status>(lua_resume(lua_state(),
nullptr, static_cast<int>(argcount), &nres));
21908 stats =
static_cast<call_status>(lua_resume(lua_state(),
nullptr, static_cast<int>(argcount)));
21912 template <std::size_t... I,
typename... Ret>
21914 luacall(n,
sizeof...(Ret));
21915 return stack::pop<std::tuple<Ret...>>(lua_state());
21918 template <std::
size_t I,
typename Ret>
21921 return stack::pop<Ret>(lua_state());
21924 template <std::
size_t I>
21930 int firstreturn = 1;
21931 luacall(n, LUA_MULTRET);
21932 int poststacksize = lua_gettop(this->lua_state());
21933 int returncount = poststacksize - (firstreturn - 1);
21935 if (error_handler.
valid()) {
21936 string_view err = stack::get<string_view>(this->lua_state(), poststacksize);
21937 error_handler.
push();
21939 lua_call(lua_state(), 1, 1);
21947 using base_t::lua_state;
21950 template <
typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_coroutine>>, 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>
21953 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 21957 stack::check<basic_coroutine>(lua_state(), -1,
handler);
21972 : base_t(b), error_handler(std::move(eh)) {
21975 : base_t(std::move(b)), error_handler(std::move(eh)) {
21990 template <
typename Super>
21994 template <
typename Super>
21998 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>
22003 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
22007 template <
typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
22009 : base_t(L, std::forward<T>(r)), error_handler(std::move(eh)) {
22010 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 22013 stack::check<basic_coroutine>(lua_state(), -1,
handler);
22018 : base_t(n), error_handler(n) {
22025 : base_t(L, index), error_handler(std::move(eh)) {
22026 #ifdef SOL_SAFE_REFERENCES 22028 stack::check<basic_coroutine>(L, index,
handler);
22035 : base_t(L, index), error_handler(std::move(eh)) {
22036 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 22038 stack::check<basic_coroutine>(L, index,
handler);
22045 : base_t(L, index), error_handler(std::move(eh)) {
22046 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 22048 stack::check<basic_coroutine>(L, index,
handler);
22055 : base_t(L, index), error_handler(std::move(eh)) {
22056 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES 22059 stack::check<basic_coroutine>(lua_state(), -1,
handler);
22073 return base_t::valid()
22077 explicit operator bool() const noexcept {
22081 template <
typename... Args>
22083 return call<>(std::forward<Args>(args)...);
22086 template <
typename... Ret,
typename... Args>
22087 decltype(
auto) operator()(
types<Ret...>, Args&&... args) {
22088 return call<Ret...>(std::forward<Args>(args)...);
22091 template <
typename... Ret,
typename... Args>
22092 decltype(
auto) call(Args&&... args) {
22099 return invoke(
types<Ret...>(), std::make_index_sequence<
sizeof...(Ret)>(), pushcount);
22111 template <
typename T>
22116 template <
typename Source>
22122 template <
typename T>
22127 for (
const auto& i : src) {
22141 using std::vector<object>::vector;
22149 for (
const auto& i : e) {
22161 #if defined(__GNUC__) 22162 #pragma GCC diagnostic pop 22163 #elif defined _MSC_VER 22164 #pragma warning( push ) 22167 #if defined(SOL_INSIDE_UNREAL) && SOL_INSIDE_UNREAL 22168 #if defined(SOL_INSIDE_UNREAL_REMOVED_CHECK) && SOL_INSIDE_UNREAL_REMOVED_CHECK 22169 #if defined(DO_CHECK) && DO_CHECK 22170 #define check(expr) { if(UNLIKELY(!(expr))) { FDebug::LogAssertFailedMessage( #expr, __FILE__, __LINE__ ); _DebugBreakAndPromptForRemote(); FDebug::AssertFailed( #expr, __FILE__, __LINE__ ); CA_ASSUME(false); } } 22172 #define check(expr) { CA_ASSUME(expr); } 22175 #endif // Unreal Engine 4 Bullshit 22180 #endif // SOL_SINGLE_INCLUDE_HPP Definition: sol.hpp:21692
usertype< T > base_t
Definition: sol.hpp:19863
std::size_t code_units_size
Definition: sol.hpp:8933
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)
Definition: sol.hpp:20965
static iterator end(lua_State *, T &self)
Definition: sol.hpp:17473
overload_set< Fs... > F
Definition: sol.hpp:13597
int push() const
Definition: sol.hpp:12136
static bool type_check(const std::string &ti)
Definition: sol.hpp:6245
constexpr constexpr_optional_base(const T &v)
Definition: sol.hpp:3575
basic_userdata(lua_State *L, int index=-1)
Definition: sol.hpp:15861
Definition: sol.hpp:12406
stack_iterator & operator-=(difference_type idx)
Definition: sol.hpp:12041
static int defer_call(std::false_type, lua_State *L, F &&f, Args &&... args)
Definition: sol.hpp:13669
T type
Definition: sol.hpp:7670
std::integral_constant< bool, meta::count_for< is_variadic_arguments, typename base_t::args_list >::value !=0 > runtime_variadics_t
Definition: sol.hpp:5734
closure c_closure
Definition: sol.hpp:4955
usertype(Args &&... args)
Definition: sol.hpp:19830
static error_result set_it(std::true_type, lua_State *L, T &self, stack_object key, stack_object value)
Definition: sol.hpp:17038
bool operator!=(const basic_string_view &r) const
Definition: sol.hpp:1134
reverse_iterator rend()
Definition: sol.hpp:16038
auto deref(T &&item) -> decltype(std::forward< T >(item))
Definition: sol.hpp:1842
stack_proxy_base()
Definition: sol.hpp:12110
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)
Definition: sol.hpp:21293
object require(const std::string &key, lua_CFunction open_function, bool create_global=true)
Definition: sol.hpp:21220
lua_CFunction c_function
Definition: sol.hpp:4948
error(detail::direct_error_tag, const std::string &str)
Definition: sol.hpp:426
static error_result insert_after_has(std::false_type, lua_State *, T &, stack_object, stack_object)
Definition: sol.hpp:17223
bool operator==(const Char *r) const
Definition: sol.hpp:1126
proxy< const basic_table_core &, T > operator[](T &&key) const &
Definition: sol.hpp:20446
static int push(lua_State *L, const T &ref)
Definition: sol.hpp:10658
static auto size_has(std::false_type, lua_State *L, T &self)
Definition: sol.hpp:17302
meta::boolean< has_find_test< T >::value > has_find
Definition: sol.hpp:16580
static int self_call(std::true_type, lua_State *L, F &&f)
Definition: sol.hpp:13638
constructor_wrapper(Arg &&arg, Args &&... args)
Definition: sol.hpp:4509
void for_each(Fx &&fx) const
Definition: sol.hpp:20425
handler_t error_handler
Definition: sol.hpp:21898
bool valid() const noexcept
Definition: sol.hpp:6534
Definition: sol.hpp:18414
T & type
Definition: sol.hpp:7662
state & operator=(state &&that)
Definition: sol.hpp:21876
const Char * cbegin() const
Definition: sol.hpp:1098
lua_State * lua_state() const noexcept
Definition: sol.hpp:21699
static bool type_unique_cast_bases(void *, void *, const string_view &)
Definition: sol.hpp:6265
static int call(lua_State *L, V &&f)
Definition: sol.hpp:13304
Definition: sol.hpp:10855
factory_wrapper(Arg &&arg, Args &&... args)
Definition: sol.hpp:4523
Definition: sol.hpp:12212
stack_iterator(lua_State *luastate, int idx, int topidx)
Definition: sol.hpp:11992
const_reverse_iterator rbegin() const
Definition: sol.hpp:16041
reference operator*()
Definition: sol.hpp:11996
static int push(lua_State *L, const new_table &nt)
Definition: sol.hpp:11316
implicit_wrapper(T &item)
Definition: sol.hpp:4664
nested< T > as_nested_ref(T &&container)
Definition: sol.hpp:5038
bool check_usertype(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:7868
static void select_convertible(std::false_type, types< Sig... >, lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:14442
void traverse_set_deep(Key &&key, Keys &&... keys) const
Definition: sol.hpp:20123
~optional_base()
Definition: sol.hpp:3555
iterator begin()
Definition: sol.hpp:12465
type get_type(difference_type index_offset=0) const noexcept
Definition: sol.hpp:16075
int default_at_panic(lua_State *L)
Definition: sol.hpp:20922
Definition: sol.hpp:12926
meta::tuple_types< typename fx_t::return_type > return_types
Definition: sol.hpp:15458
lua_State * lua_state() const noexcept
Definition: sol.hpp:6530
const auto call_constructor
Definition: sol.hpp:4503
static int empty(lua_State *L)
Definition: sol.hpp:17500
int popcount
Definition: sol.hpp:12217
lua_State * L
Definition: sol.hpp:6603
static int call_assign(std::false_type, lua_State *L, Args &&...)
Definition: sol.hpp:13288
std::conditional_t< is_associative::value||is_matched_lookup::value, std::add_lvalue_reference_t< V >, std::conditional_t< is_lookup::value, V, iterator_return > > captured_type
Definition: sol.hpp:16804
basic_reference(basic_reference &&o) noexcept
Definition: sol.hpp:6886
meta::unqualified_t< T > Tu
Definition: sol.hpp:9259
std::array< char, 2 > two
Definition: sol.hpp:16292
static int push(lua_State *L, const wchar_t(&str)[N], std::size_t sz)
Definition: sol.hpp:11188
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8645
void swap(optional< T > &rhs) noexcept(::std::is_nothrow_move_constructible< T >::value &&noexcept(swap(::std::declval< T &>(), ::std::declval< T &>())))
Definition: sol.hpp:3792
const_iterator end() const
Definition: sol.hpp:12474
T source
Definition: sol.hpp:4983
void move_assign(basic_reference< r_main_only > &&r)
Definition: sol.hpp:6753
static decltype(auto) pop(lua_State *L)
Definition: sol.hpp:11375
basic_coroutine(proxy_base< Super > &&p)
Definition: sol.hpp:21995
static int call(lua_State *L, V &&f)
Definition: sol.hpp:13443
static int next_associative(std::true_type, lua_State *L)
Definition: sol.hpp:17351
stack_proxy * pointer
Definition: sol.hpp:12415
static int push(lua_State *L, const char32_t *str)
Definition: sol.hpp:11163
optional(optional &&rhs) noexcept(::std::is_nothrow_move_constructible< T >::value)
Definition: sol.hpp:3710
basic_object(std::integral_constant< bool, invert_and_pop >, lua_State *L, int index=-1) noexcept
Definition: sol.hpp:16148
void swap(optional< T &> &rhs) noexcept
Definition: sol.hpp:4013
const auto direct_error
Definition: sol.hpp:411
as_container_t(T value)
Definition: sol.hpp:16255
std::hash< string_view > string_view_hash
Definition: sol.hpp:1190
std::array< C, 4 > code_units
Definition: sol.hpp:8934
static error_result at_category(std::input_iterator_tag, lua_State *L, T &self, std::ptrdiff_t pos)
Definition: sol.hpp:16843
static const std::string & gc_table()
Definition: sol.hpp:6185
static decltype(auto) eval(types<>, std::index_sequence<>, lua_State *, int, record &, Fx &&fx, Args &&... args)
Definition: sol.hpp:11772
Definition: sol.hpp:13115
as_container_t(T &value)
Definition: sol.hpp:16272
const_iterator cend() const
Definition: sol.hpp:12339
const_iterator cbegin() const
Definition: sol.hpp:16028
static int push(lua_State *, const this_state &)
Definition: sol.hpp:11302
static int push(lua_State *L, const char16_t *str, std::size_t len)
Definition: sol.hpp:11097
closure< Args... > make_closure(lua_CFunction f, Args &&... args)
Definition: sol.hpp:4958
static int call_assign(std::true_type, lua_State *L, V &&f, object_type &o)
Definition: sol.hpp:13401
static auto call(object_type &mem) -> detail::array_return_type< decltype(mem.*fx)>
Definition: sol.hpp:12671
int call(lua_State *L)
Definition: sol.hpp:12872
KV::first_type K
Definition: sol.hpp:16794
stack_reference(lua_State *L, absolute_index i) noexcept
Definition: sol.hpp:6465
simple_usertype< Class > create_simple_usertype(constructors< CArgs... > ctor, Args &&... args)
Definition: sol.hpp:21597
tie_t< std::remove_reference_t< Tn >... > tie(Tn &&... argn)
Definition: sol.hpp:7090
int & operator[](std::size_t i)
Definition: sol.hpp:4581
static int call(lua_State *L)
Definition: sol.hpp:14021
std::array< char, 1 > one
Definition: sol.hpp:16546
static bool type_unique_cast(void *source_data, void *target_data, const string_view &ti, const string_view &rebind_ti)
Definition: sol.hpp:6287
auto deref_non_pointer(T &&item) -> decltype(std::forward< T >(item))
Definition: sol.hpp:1852
static void select(lua_State *L, Fx &&fx)
Definition: sol.hpp:14611
state(lua_CFunction panic, lua_Alloc alfunc, void *alpointer=nullptr)
Definition: sol.hpp:21868
static int push(lua_State *L, const wchar_t *str)
Definition: sol.hpp:11005
error tagged_get(types< error >) const
Definition: sol.hpp:20815
static error_result get_associative(std::false_type, lua_State *L, iterator &it)
Definition: sol.hpp:16882
int push() const noexcept
Definition: sol.hpp:6492
static void set_fx(lua_State *L, Args &&... args)
Definition: sol.hpp:14617
traits_type::args_list args_list
Definition: sol.hpp:12710
auto make_string_view(string_view s)
Definition: sol.hpp:18497
static int push(lua_State *L, function_arguments< T, Args... > &&fp)
Definition: sol.hpp:14669
static int push(lua_State *L, const char32_t(&str)[N])
Definition: sol.hpp:11206
as_table_t(Arg &&arg)
Definition: sol.hpp:4991
int stackindex
Definition: sol.hpp:15063
meta::unqualified_t< T > U
Definition: sol.hpp:10388
proxy< basic_table_core &, T > operator[](T &&key) &
Definition: sol.hpp:20441
lightuserdata_value(void *data)
Definition: sol.hpp:4853
member_function(function_type f, Args &&... args)
Definition: sol.hpp:14179
static int push(lua_State *, const stack_proxy &ref)
Definition: sol.hpp:12202
Definition: sol.hpp:11975
static error_result set_category(std::input_iterator_tag, lua_State *L, T &self, stack_object okey, stack_object value)
Definition: sol.hpp:16960
Definition: sol.hpp:14435
static bool max_size_check(std::false_type, T &, std::size_t)
Definition: sol.hpp:9282
static S get_into(lua_State *L, int index, record &tracking)
Definition: sol.hpp:9686
const_iterator cbegin() const
Definition: sol.hpp:20221
optional< object > is_loaded_package(const std::string &key)
Definition: sol.hpp:21061
closure(lua_CFunction f, Upvalues... targetupvalues)
Definition: sol.hpp:4941
Definition: sol.hpp:16319
std::conditional_t< is_const, const proxy_t, proxy_t > reference
Definition: sol.hpp:11976
static int call(lua_State *L)
Definition: sol.hpp:14049
static bool check(lua_State *, int, Handler &&, record &tracking)
Definition: sol.hpp:8357
table registry() const
Definition: sol.hpp:21473
static error_result add_associative(std::false_type, lua_State *L, T &self, stack_object value)
Definition: sol.hpp:17173
int ref
Definition: sol.hpp:6719
const void * pointer() const noexcept
Definition: sol.hpp:6520
static auto & get_src(lua_State *L)
Definition: sol.hpp:16828
std::size_t size_type
Definition: sol.hpp:12266
constexpr constexpr_optional_base(T &&v)
Definition: sol.hpp:3580
struct sol::simple_tag simple
basic_coroutine(lua_State *L, int index, handler_t eh)
Definition: sol.hpp:22024
static int call(lua_State *L, F &)
Definition: sol.hpp:13512
int type_panic_string(lua_State *L, int index, type expected, type actual, const std::string &message="") noexcept(false)
Definition: sol.hpp:6334
void luajit_exception_off(lua_State *L)
Definition: sol.hpp:11917
int runtime_object_call(lua_State *L, void *, usertype_metatable_core &umc, int runtimetarget)
Definition: sol.hpp:18542
static int push(lua_State *L, const overload_set< Functions... > &set)
Definition: sol.hpp:14717
Definition: sol.hpp:16544
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)
Definition: sol.hpp:12092
this_main_state(lua_State *Ls)
Definition: sol.hpp:5070
meta::boolean< has_traits_insert_test< T >::value > has_traits_insert
Definition: sol.hpp:16628
load_status status() const noexcept
Definition: sol.hpp:20859
basic_reference(lua_State *L, lua_nil_t) noexcept
Definition: sol.hpp:6872
static int push(lua_State *, stack_count st)
Definition: sol.hpp:10685
basic_function(lua_State *L, ref_index index)
Definition: sol.hpp:15016
static void select_member_function(std::false_type, lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:14544
protected_handler(const target_t &target)
Definition: sol.hpp:15080
T src
Definition: sol.hpp:22113
basic_environment(env_t, const stack_reference &extraction_target)
Definition: sol.hpp:20612
static int push(lua_State *L, const char32_t *str, std::size_t len)
Definition: sol.hpp:11175
static T & get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:9220
const bool default_safe_function_calls
Definition: sol.hpp:4399
push_popper_n(lua_State *, int)
Definition: sol.hpp:6631
bool valid() const noexcept
Definition: sol.hpp:6965
static int call(lua_State *L, P &fx)
Definition: sol.hpp:13714
constexpr T value_or(V &&v) const
Definition: sol.hpp:3935
const int metatable_index
Definition: sol.hpp:18380
static int push(lua_State *L, constructor_list< Lists... >)
Definition: sol.hpp:14830
int call(lua_State *L)
Definition: sol.hpp:14149
Definition: sol.hpp:14433
overloaded_function(Functions... fxs)
Definition: sol.hpp:14261
int count
Definition: sol.hpp:6605
bool operator()(A &&, B &&) const
Definition: sol.hpp:18127
stack_iterator< stack_proxy, true > const_iterator
Definition: sol.hpp:12419
reverse_iterator rbegin()
Definition: sol.hpp:12343
std::is_copy_assignable< V > is_copyable
Definition: sol.hpp:16811
basic_protected_function(basic_function< base_t > &&b, handler_t eh)
Definition: sol.hpp:15261
basic_table_iterator(reference_type x)
Definition: sol.hpp:19919
static constexpr char32_t decode(unsigned char b0, unsigned char b1, unsigned char b2)
Definition: sol.hpp:8982
int member_default_to_string(std::false_type, lua_State *L)
Definition: sol.hpp:18144
static int push(lua_State *L, destructor_wrapper< Fx > &&c)
Definition: sol.hpp:14877
void set_on(const T &target) const
Definition: sol.hpp:20672
basic_object_base(T &&arg, Args &&... args)
Definition: sol.hpp:15803
bool valid() const
Definition: sol.hpp:15622
std::remove_pointer_t< meta::unwrap_unqualified_t< X > > T
Definition: sol.hpp:17531
auto initializers(Functions &&... functions)
Definition: sol.hpp:4515
basic_thread< stack_reference > stack_thread
Definition: sol.hpp:362
lua_State * lua_state() const
Definition: sol.hpp:16083
filter_wrapper< F, Filters... > P
Definition: sol.hpp:14915
overloaded_function(overload_list set)
Definition: sol.hpp:14257
state_view & new_enum(const string_view &name, std::initializer_list< std::pair< string_view, T >> items)
Definition: sol.hpp:21608
T type
Definition: sol.hpp:16641
basic_object(const stack_reference &r) noexcept
Definition: sol.hpp:16170
void * value
Definition: sol.hpp:4862
iterator end()
Definition: sol.hpp:16019
auto as_function(Args &&... args)
Definition: sol.hpp:4972
constexpr in_place_tag in_place_of(detail::in_place_of_tag)
Definition: sol.hpp:3235
std::array< char, 2 > two
Definition: sol.hpp:16547
Definition: sol.hpp:15060
int indexing_fail(lua_State *L)
Definition: sol.hpp:18549
stack_iterator< stack_proxy, false > iterator
Definition: sol.hpp:12267
stack_guard(lua_State *L, int top, std::function< void(int, int)> fx=detail::stack_fail)
Definition: sol.hpp:7124
lua_State * main_thread(lua_State *L, lua_State *backup_if_unsupported=nullptr)
Definition: sol.hpp:6676
types< object_type &, FArgs... > free_args_list
Definition: sol.hpp:12711
std::array< char, 1 > one
Definition: sol.hpp:16291
std::array< char, 1 > one
Definition: sol.hpp:16561
Definition: sol.hpp:16289
static int pairs(lua_State *L)
Definition: sol.hpp:16756
meta::boolean< has_traits_set_test< T >::value > has_traits_set
Definition: sol.hpp:16595
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)
Definition: sol.hpp:21284
meta::function_args_t< function_type > args_lists
Definition: sol.hpp:14174
static int ipairs(lua_State *L)
Definition: sol.hpp:17518
static int push(lua_State *L, P &&p)
Definition: sol.hpp:14925
static int push(lua_State *L, c_closure cc)
Definition: sol.hpp:10734
constexpr const T & storage() const
Definition: sol.hpp:3548
static error_result get_category(std::input_iterator_tag, lua_State *L, T &self, K &key)
Definition: sol.hpp:16886
call_status luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount, detail::protected_handler< b, handler_t > &h) const
Definition: sol.hpp:15146
function_map functions
Definition: sol.hpp:18437
Definition: sol.hpp:19896
static int push(lua_State *, const stack_proxy_base &ref)
Definition: sol.hpp:12163
basic_table< base_type > base_t
Definition: sol.hpp:15826
basic_table_core(detail::no_safety_tag, lua_nil_t n)
Definition: sol.hpp:20133
static error_result set_category(std::random_access_iterator_tag, lua_State *L, T &self, stack_object okey, stack_object value)
Definition: sol.hpp:16978
int operator()(lua_State *L)
Definition: sol.hpp:14271
const int newindex_function_index
Definition: sol.hpp:18387
int simple_real_new_index_call(lua_State *L)
Definition: sol.hpp:19313
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8853
difference_type operator-(const stack_iterator &r) const
Definition: sol.hpp:12046
const lua_nil_t lua_nil
Definition: sol.hpp:4683
protected_function_result script_file(const std::string &filename, const basic_environment< E > &env, Fx &&on_error, load_mode mode=load_mode::any)
Definition: sol.hpp:21401
std::string make_string(Arg &&arg)
Definition: sol.hpp:18514
void abandon() noexcept
Definition: sol.hpp:12374
iter(T &source, iterator it)
Definition: sol.hpp:17543
int push_reference(lua_State *L, T &&t, Args &&... args)
Definition: sol.hpp:7781
lib
Definition: sol.hpp:5102
constexpr result_type operator()(argument_type const &arg) const
Definition: sol.hpp:4349
basic_coroutine(lua_State *L, ref_index index, handler_t eh)
Definition: sol.hpp:22054
typename strip_extensible< T >::type strip_extensible_t
Definition: sol.hpp:7682
static int push(lua_State *L, T &&t)
Definition: sol.hpp:11260
static error_result add_insert(std::false_type, lua_State *L, T &self, stack_object value, iterator &pos)
Definition: sol.hpp:17133
basic_coroutine(const proxy_base< Super > &p)
Definition: sol.hpp:21991
bool is_valid(std::false_type)
Definition: sol.hpp:15521
std::size_t memory_used() const
Definition: sol.hpp:21477
int multi_push_reference(lua_State *L, T &&t, Args &&... args)
Definition: sol.hpp:7808
meta::iterator_tag< iterator >::type iterator_category
Definition: sol.hpp:16805
std::array< char, 2 > two
Definition: sol.hpp:16487
static int push(lua_State *L, userdata_value data)
Definition: sol.hpp:10847
std::initializer_list< int > swallow
Definition: sol.hpp:462
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8428
Definition: sol.hpp:13959
destructor_wrapper< Fx > F
Definition: sol.hpp:13563
Definition: sol.hpp:19336
Definition: sol.hpp:12732
meta::boolean< has_traits_size_test< T >::value > has_traits_size
Definition: sol.hpp:16616
auto as_args(Source &&source)
Definition: sol.hpp:15945
static error_result insert_lookup(std::true_type, lua_State *L, T &self, stack_object, stack_object value)
Definition: sol.hpp:17193
static error_result add_insert_after(std::true_type, lua_State *, T &self, stack_object value, iterator &pos)
Definition: sol.hpp:17108
static int push(lua_State *L, lua_nil_t)
Definition: sol.hpp:10677
stack_safe_function stack_protected_function
Definition: sol.hpp:316
decltype(auto) get_key(std::true_type, T &&t)
Definition: sol.hpp:16658
static int push(lua_State *L, C &&c)
Definition: sol.hpp:14860
int leftover_count() const
Definition: sol.hpp:16089
value_type * pointer
Definition: sol.hpp:19903
meta::boolean< has_traits_index_set_test< T >::value > has_traits_index_set
Definition: sol.hpp:16601
basic_protected_function(const basic_function< base_t > &b, handler_t eh)
Definition: sol.hpp:15258
Definition: sol.hpp:13005
T type
Definition: sol.hpp:7679
static void select_reference_member_variable(std::false_type, lua_State *L, Fx &&fx, T &&obj, Args &&... args)
Definition: sol.hpp:14470
lua_bind_traits< meta::unqualified_t< F > > traits_type
Definition: sol.hpp:12610
static int size(lua_State *L)
Definition: sol.hpp:17478
basic_function(lua_State *L, int index=-1)
Definition: sol.hpp:15009
void set_fx(types< R(Args...)>, Key &&key, Fx &&fx)
Definition: sol.hpp:20477
std::reference_wrapper< T > source
Definition: sol.hpp:16270
void make_length_op_const(std::false_type, Regs &l, int &index)
Definition: sol.hpp:18249
pointer operator->()
Definition: sol.hpp:12004
constexpr ::std::remove_reference< T >::type && constexpr_move(T &&t) noexcept
Definition: sol.hpp:3443
int stack_index() const noexcept
Definition: sol.hpp:20890
basic_table_iterator()
Definition: sol.hpp:19915
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8526
auto as_returns(Source &&source)
Definition: sol.hpp:22117
std::conditional_t< std::is_array< meta::unqualified_t< T > >::value, T &, std::decay_t< T > > type
Definition: sol.hpp:18722
static int next(lua_State *L)
Definition: sol.hpp:17670
char32_t codepoint
Definition: sol.hpp:8926
error(std::string &&str)
Definition: sol.hpp:423
static int push(lua_State *L, Arg0 &&arg0, Args &&... args)
Definition: sol.hpp:14627
static int next(lua_State *L)
Definition: sol.hpp:17523
handler_t error_handler
Definition: sol.hpp:15234
reverse_iterator rend()
Definition: sol.hpp:12487
reference operator*() const
Definition: sol.hpp:12000
state_view & set_usertype(Key &&key, usertype< T > &user)
Definition: sol.hpp:21545
basic_table_core & set(Args &&... args)
Definition: sol.hpp:20270
int operator()(lua_State *L)
Definition: sol.hpp:14093
static error_result add_associative(std::true_type, lua_State *L, T &self, stack_object key)
Definition: sol.hpp:17164
T & contained_val()
Definition: sol.hpp:3660
meta::unqualified_t< T > C
Definition: sol.hpp:18027
T value_type
Definition: sol.hpp:3686
static R invoke(O &mem, Args &&... args)
Definition: sol.hpp:12715
Definition: sol.hpp:16499
stack_proxy get(types< Args... >, index_value< 0 >, index_value< I >, const T &fr)
Definition: sol.hpp:12556
load_status err
Definition: sol.hpp:20788
static error_result add_insert(std::true_type, lua_State *L, T &self, stack_object value)
Definition: sol.hpp:17128
decoded_result< It > utf32_to_code_point(It it, It last)
Definition: sol.hpp:9185
basic_protected_function(lua_State *L, int index, handler_t eh)
Definition: sol.hpp:15311
void deref() const noexcept
Definition: sol.hpp:6790
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:13927
Definition: sol.hpp:16249
void * align_user(void *ptr)
Definition: sol.hpp:7279
static int push(lua_State *L, protect_t< T > &&pw)
Definition: sol.hpp:14727
basic_reference(lua_State *L, detail::global_tag) noexcept
Definition: sol.hpp:6780
void tuple_set(std::index_sequence< I... >, Pairs &&pairs)
Definition: sol.hpp:20064
std::array< char, 2 > two
Definition: sol.hpp:16412
error(detail::direct_error_tag, std::string &&str)
Definition: sol.hpp:429
T & source
Definition: sol.hpp:17540
static int push(lua_State *L, const char32_t *u32str)
Definition: sol.hpp:11126
void initialize(Args &&... args) noexcept(noexcept(T(::std::forward< Args >(args)...)))
Definition: sol.hpp:3672
const int metatable_core_index
Definition: sol.hpp:18381
F type
Definition: sol.hpp:13874
simple_usertype< Class > create_simple_usertype(Args &&... args)
Definition: sol.hpp:20372
void get(lua_State *L, Key &&key, int tableindex=-2)
Definition: sol.hpp:11403
basic_reference(basic_reference<!main_only > &&o) noexcept
Definition: sol.hpp:6896
void call_from_top(types< void > tr, types< Args... > ta, lua_State *L, Fx &&fx, FxArgs &&... args)
Definition: sol.hpp:11840
type
Definition: sol.hpp:5173
Definition: sol.hpp:18434
static const std::string & name()
Definition: sol.hpp:6165
basic_coroutine(lua_nil_t n)
Definition: sol.hpp:22017
static constexpr char32_t decode(unsigned char b0, unsigned char b1, unsigned char b2, unsigned char b3)
Definition: sol.hpp:8985
stack_proxy reference_type
Definition: sol.hpp:12262
static int add(lua_State *L)
Definition: sol.hpp:17602
int upvalues
Definition: sol.hpp:4949
static int push(lua_State *L, const char16_t *str)
Definition: sol.hpp:11085
int push_reference(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:7786
table create(int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:20525
int push(lua_State *target) const
Definition: sol.hpp:16058
int typed_static_trampoline(lua_State *L)
Definition: sol.hpp:5993
static int call(lua_State *L, lua_CFunction_ref f)
Definition: sol.hpp:13311
lua_State * thread_state() const
Definition: sol.hpp:21815
std::conditional_t< is_matched_lookup::value, std::ptrdiff_t, K > next_K
Definition: sol.hpp:16796
basic_string_view< char32_t > u32string_view
Definition: sol.hpp:1189
basic_table_iterator & operator++()
Definition: sol.hpp:19931
static handler_t get_default_handler(lua_State *L)
Definition: sol.hpp:15135
variadic_args(lua_State *luastate, int stackindex=-1)
Definition: sol.hpp:15986
stack_iterator operator++(int)
Definition: sol.hpp:12019
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t)
Definition: sol.hpp:21903
decltype(auto) property(std::true_type, R &&read, W &&write)
Definition: sol.hpp:12942
meta::bind_traits< Signature > base_t
Definition: sol.hpp:5731
T * usertype_allocate(lua_State *L)
Definition: sol.hpp:7333
std::array< char, 2 > two
Definition: sol.hpp:16532
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8328
static int index_set(lua_State *L)
Definition: sol.hpp:16720
basic_coroutine(const stack_reference &r)
Definition: sol.hpp:21977
~push_popper_at()
Definition: sol.hpp:6609
void copy_assign(const basic_reference< r_main_only > &r)
Definition: sol.hpp:6729
static void walk_all_bases(lua_State *L, bool &found, int &ret, string_view &accessor)
Definition: sol.hpp:18711
int push() const
Definition: sol.hpp:16054
static int push(lua_State *L, ref_index ri)
Definition: sol.hpp:10975
Definition: sol.hpp:16672
constexpr auto resolve_i(types< R(Args...)>, F &&) -> R(meta::unqualified_t< F >::*)(Args...)
Definition: sol.hpp:14290
std::input_iterator_tag iterator_category
Definition: sol.hpp:19901
object mapped_type
Definition: sol.hpp:19899
Definition: sol.hpp:13873
static int push(std::index_sequence< I... >, lua_State *L, T &&t)
Definition: sol.hpp:11253
int(* member_search)(lua_State *, void *, usertype_metatable_core &, int)
Definition: sol.hpp:18390
basic_reference & operator=(const basic_reference &r) noexcept
Definition: sol.hpp:6907
bool operator>(const stack_iterator &r) const
Definition: sol.hpp:12078
int push_as_upvalues(lua_State *L, T &item)
Definition: sol.hpp:11742
basic_reference(const stack_reference &r) noexcept
Definition: sol.hpp:6799
static R apply(std::index_sequence<>, lua_State *, int, record &, Args &&... args)
Definition: sol.hpp:10024
meta_function meta_method
Definition: sol.hpp:5314
int operator()(lua_State *L)
Definition: sol.hpp:14193
reference_type ref
Definition: sol.hpp:19909
static int push(lua_State *L, const char16_t *strb, const char16_t *stre)
Definition: sol.hpp:11091
type get_type() const noexcept
Definition: sol.hpp:12132
std::conditional_t< std::is_array< T >::value, std::add_lvalue_reference_t< T >, T > array_return_type
Definition: sol.hpp:12605
void script(lua_State *L, const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:11889
static int push(lua_State *L, lua_CFunction func, int n=0)
Definition: sol.hpp:10708
static error_result add_associative(std::true_type, lua_State *L, T &self, stack_object key, iterator &pos)
Definition: sol.hpp:17159
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8384
bool empty() const
Definition: sol.hpp:20436
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8309
basic_lightuserdata(lua_State *L, int index=-1)
Definition: sol.hpp:15915
basic_reference(lua_State *L, const stack_reference &r) noexcept
Definition: sol.hpp:6845
protected_function_result safe_script_file(const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:21333
has_empty< T > has_traits_empty
Definition: sol.hpp:16622
int no_construction_error(lua_State *L)
Definition: sol.hpp:13088
optional_base(in_place_t, ::std::initializer_list< U > il, Args &&... args)
Definition: sol.hpp:3536
unsafe_function_result & operator=(const unsafe_function_result &)=default
static bool value
Definition: sol.hpp:6208
basic_string_view< Ch, Tr > argument_type
Definition: sol.hpp:1149
stack_proxy()
Definition: sol.hpp:12176
typename ::std::remove_const< T >::type * dataptr()
Definition: sol.hpp:3630
std::unique_ptr< lua_State, detail::state_deleter > unique_base
Definition: sol.hpp:21860
typename ::std::conditional< ::std::is_trivially_destructible< T >::value, constexpr_optional_base< typename ::std::remove_const< T >::type >, optional_base< typename ::std::remove_const< T >::type >>::type OptionalBase
Definition: sol.hpp:3620
static int push(lua_State *L, char c)
Definition: sol.hpp:10918
int call_wrapper_function(std::true_type, lua_State *L)
Definition: sol.hpp:13827
static int push(lua_State *L, detail::yield_tag_t, Args &&... args)
Definition: sol.hpp:14634
basic_table_core & add(Args &&... args)
Definition: sol.hpp:20468
static int ipairs(lua_State *L)
Definition: sol.hpp:16760
basic_object(lua_State *L, absolute_index index) noexcept
Definition: sol.hpp:16190
Vector2< T > operator*(T n, Vector2< T > &vector2)
int index
Definition: sol.hpp:4822
as_table_t< meta::unqualified_t< T > > as_table(T &&container)
Definition: sol.hpp:5033
static int empty(lua_State *L)
Definition: sol.hpp:16744
constexpr in_place_tag in_place_type(detail::in_place_of_t< T >)
Definition: sol.hpp:3239
int operator()(lua_State *L, int index, type expected, type actual, const std::string &message) const noexcept(false)
Definition: sol.hpp:6383
table reg
Definition: sol.hpp:21058
table create(Name &&name, int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:20537
static basic_thread create(lua_State *L)
Definition: sol.hpp:21840
int index
Definition: sol.hpp:4800
static void convert(const char *strb, const char *stre, F &&f)
Definition: sol.hpp:9668
constexpr T const & value() const
Definition: sol.hpp:3885
static int call_const(std::false_type, lua_State *L, Args &&... args)
Definition: sol.hpp:13432
static int call(lua_State *L, V &&v, object_type &o)
Definition: sol.hpp:13460
int simple_new_index_call(lua_State *L)
Definition: sol.hpp:19327
std::add_lvalue_reference_t< meta::unwrapped_t< std::remove_reference_t< decltype(detail::deref(member))> > > M
Definition: sol.hpp:14206
T & storage()
Definition: sol.hpp:3601
static int push(lua_State *, const this_main_state &)
Definition: sol.hpp:11309
in_place_tag(&)(detail::in_place_of_t< T >) in_place_type_t
Definition: sol.hpp:3249
T & storage()
Definition: sol.hpp:3544
static void call(Fx &&fx, object_type &mem, Arg &&arg, Args &&...)
Definition: sol.hpp:12686
static int call(lua_State *L, F &fx)
Definition: sol.hpp:13607
int trampoline(lua_State *L, Fx &&f, Args &&... args)
Definition: sol.hpp:5946
std::tuple< Functions... > functions
Definition: sol.hpp:4507
encoded_result< char16_t > code_point_to_utf16(char32_t codepoint)
Definition: sol.hpp:9038
void collect_garbage()
Definition: sol.hpp:21491
int simple_index_call(lua_State *L)
Definition: sol.hpp:19318
basic_object< reference > object
Definition: sol.hpp:350
constexpr T const * operator->() const
Definition: sol.hpp:3813
Definition: sol.hpp:18721
Definition: sol.hpp:22140
stack_proxy operator[](difference_type index_offset) const
Definition: sol.hpp:12320
Definition: sol.hpp:13362
static int index_get(lua_State *L)
Definition: sol.hpp:17624
static error_result insert_has(std::true_type, lua_State *L, T &self, stack_object key, stack_object value)
Definition: sol.hpp:17227
usertype(detail::verified_tag, Args &&... args)
Definition: sol.hpp:19813
table new_enum(const string_view &name, Args &&... args)
Definition: sol.hpp:20390
static int empty(lua_State *L)
Definition: sol.hpp:17654
usertype_detail::registrar * registrar_data()
Definition: sol.hpp:19849
nested(Arg0 &&arg0, Arg1 &&arg1, Args &&... args)
Definition: sol.hpp:5018
static void insert_at_end(std::false_type, types< V >, lua_State *L, T &arr, std::size_t idx)
Definition: sol.hpp:9278
probe get(lua_State *L, Key &&key, int tableindex=-2)
Definition: sol.hpp:11651
basic_coroutine(lua_State *L, raw_index index, handler_t eh)
Definition: sol.hpp:22044
traits_type::object_type object_type
Definition: sol.hpp:12664
table new_enum(const string_view &name, std::initializer_list< std::pair< string_view, T >> items)
Definition: sol.hpp:20406
static int call(lua_State *L)
Definition: sol.hpp:14116
Definition: sol.hpp:16364
load_result load(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:21430
Definition: sol.hpp:13762
std::size_t s
Definition: sol.hpp:1066
bool check(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:7829
static int insert(lua_State *L)
Definition: sol.hpp:17606
const_iterator end() const
Definition: sol.hpp:16025
meta::condition< meta::is_specialization_of< Key, std::tuple >, Key, std::tuple< meta::condition< std::is_array< meta::unqualified_t< Key > >, Key &, meta::unqualified_t< Key > > > > key_type
Definition: sol.hpp:15503
std::array< char, 1 > one
Definition: sol.hpp:16486
void invoke(types< void >, std::index_sequence< I >, std::ptrdiff_t n)
Definition: sol.hpp:21925
T actual_type
Definition: sol.hpp:4737
stack_proxy value_type
Definition: sol.hpp:15976
basic_protected_function(lua_nil_t n)
Definition: sol.hpp:15304
meta::unqualified_t< P > U
Definition: sol.hpp:13632
Definition: sol.hpp:19997
static void convert(const char *strb, const char *stre, F &&f)
Definition: sol.hpp:9719
T & operator*()
Definition: sol.hpp:3880
static T * get_no_lua_nil(lua_State *L, int index, record &tracking)
Definition: sol.hpp:9916
decoded_result< It > utf16_to_code_point(It it, It last)
Definition: sol.hpp:9147
static int call_const(std::true_type, lua_State *L, Args &&...)
Definition: sol.hpp:13438
static int real_call(lua_State *L) noexcept(false)
Definition: sol.hpp:14103
static int push_rvalue(std::true_type, lua_State *L, C &&cont)
Definition: sol.hpp:18039
int multi_push_reference(lua_State *)
Definition: sol.hpp:7802
~protected_function_result()
Definition: sol.hpp:12381
optional_base(const T &v)
Definition: sol.hpp:3519
std::string associated_type_name(lua_State *L, int index, type t)
Definition: sol.hpp:6311
load_status
Definition: sol.hpp:5165
T v
Definition: sol.hpp:12984
static error_result erase_integral(std::false_type, lua_State *L, T &self, const K &key)
Definition: sol.hpp:17252
basic_coroutine(lua_State *L, T &&r, handler_t eh)
Definition: sol.hpp:22008
stack_iterator< stack_proxy, false > iterator
Definition: sol.hpp:15980
bool is_toplevel(lua_State *L, int index=magic_index)
Definition: sol.hpp:18536
void reserve(T &, std::size_t)
Definition: sol.hpp:7583
static int push(lua_State *L, const T &tablecont)
Definition: sol.hpp:10543
void * align_usertype_pointer(void *ptr)
Definition: sol.hpp:7200
std::string short_demangle_once()
Definition: sol.hpp:6108
variable_map variables
Definition: sol.hpp:18436
meta::any< is_constructor< meta::unqualified_t< Args >>... > has_constructor
Definition: sol.hpp:5800
basic_table_core & new_simple_usertype(const std::string &name, constructors< CArgs... > ctor, Args &&... args)
Definition: sol.hpp:20365
bool error() const noexcept
Definition: sol.hpp:22067
static error_result set_associative(std::true_type, iterator &it, stack_object value)
Definition: sol.hpp:16940
static int push(lua_State *L, const char *strb, const char *stre)
Definition: sol.hpp:10890
int call_lua(lua_State *L, int start, Fx &&fx, FxArgs &&... fxargs)
Definition: sol.hpp:11870
decltype(&inheritance< void >::type_unique_cast< void >) inheritance_unique_cast_function
Definition: sol.hpp:6301
T * obj
Definition: sol.hpp:13116
global_table::iterator iterator
Definition: sol.hpp:21115
T value
Definition: sol.hpp:4483
stack_iterator(const stack_iterator< proxy_t, true > &r)
Definition: sol.hpp:11989
static int push(lua_State *L, lightuserdata_value userdata)
Definition: sol.hpp:10772
unique_usertype_traits< T >::type P
Definition: sol.hpp:10007
basic_thread(lua_State *L, lua_thread_state actualthread)
Definition: sol.hpp:21796
const value_type & const_reference
Definition: sol.hpp:19905
basic_thread(lua_State *L, int index=-1)
Definition: sol.hpp:21775
int pop_count() const noexcept
Definition: sol.hpp:12371
stack_proxy value_type
Definition: sol.hpp:12263
std::conditional_t< can_write::value, W, no_prop > Write
Definition: sol.hpp:12930
basic_reference & operator=(basic_reference<!main_only > &&r) noexcept
Definition: sol.hpp:6912
static void select_function(std::true_type, lua_State *L, lua_CFunction f)
Definition: sol.hpp:14592
value_type & reference
Definition: sol.hpp:19904
basic_lightuserdata(lua_State *L, ref_index index)
Definition: sol.hpp:15922
void modify_unique_usertype(const stack_reference &obj, F &&f)
Definition: sol.hpp:8140
static int push(std::true_type, lua_State *L, const T &tablecont)
Definition: sol.hpp:10548
basic_reference & operator=(const basic_reference<!main_only > &r) noexcept
Definition: sol.hpp:6917
decltype(auto) get_or(Key &&key, T &&otherwise) const
Definition: sol.hpp:20237
key_type key
Definition: sol.hpp:15530
static int push(lua_State *L, const T &tablecont)
Definition: sol.hpp:10628
constexpr bool operator!=(const optional< T > &x, const optional< T > &y)
Definition: sol.hpp:4057
protected_function_result do_string(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:21263
basic_protected_function(const stack_reference &r)
Definition: sol.hpp:15264
void set(lua_State *L, Key &&key, Value &&value, int tableindex=-3)
Definition: sol.hpp:11530
stack_proxy value_type
Definition: sol.hpp:12414
state_view(this_state Ls)
Definition: sol.hpp:21122
static int push(lua_State *L, bool b)
Definition: sol.hpp:10669
lua_nil_t nil_t
Definition: sol.hpp:4690
state_view & new_simple_usertype(const std::string &name, Args &&... args)
Definition: sol.hpp:21569
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8413
int call(lua_State *L)
Definition: sol.hpp:14213
U value
Definition: sol.hpp:4900
static int pairs(lua_State *L)
Definition: sol.hpp:17658
static int push_sized(lua_State *L, const char *str, std::size_t len)
Definition: sol.hpp:10856
const_reverse_iterator crbegin() const
Definition: sol.hpp:12496
std::array< char, 2 > two
Definition: sol.hpp:16382
functor_function(function_type f, Args &&... args)
Definition: sol.hpp:14145
lua_State * lua_state() const noexcept
Definition: sol.hpp:12362
lua_State * lua_state() const
Definition: sol.hpp:15648
static int call(lua_State *L, const no_construction &)
Definition: sol.hpp:13341
const_iterator cbegin() const
Definition: sol.hpp:12336
iterator begin() const
Definition: sol.hpp:20213
int oss_default_to_string(std::false_type, lua_State *L)
Definition: sol.hpp:18168
auto invoke(types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n) const
Definition: sol.hpp:14947
static int push(lua_State *L, C &&c)
Definition: sol.hpp:14848
void insert_default_registrations(std::true_type, Regs &l, int &index, Fx &&fx)
Definition: sol.hpp:18297
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:14038
Definition: sol.hpp:12983
basic_reference(const basic_reference<!main_only > &o) noexcept
Definition: sol.hpp:6892
meta::boolean< has_traits_at_test< T >::value > has_traits_at
Definition: sol.hpp:16592
constexpr optional(const T &v)
Definition: sol.hpp:3718
basic_environment(lua_State *L, int index=-1)
Definition: sol.hpp:20629
static int call_void(std::true_type, lua_State *L, const F &f)
Definition: sol.hpp:13574
int overload_match_arity(Match &&matchfx, lua_State *L, int fxarity, int start, Args &&... args)
Definition: sol.hpp:13195
meta::bind_traits< function_type >::args_list args_lists
Definition: sol.hpp:14203
virtual int index(lua_State *L) override
Definition: sol.hpp:18422
static void select_member_variable(std::true_type, lua_State *L, Fx &&fx)
Definition: sol.hpp:14512
lua_bind_traits< F > traits_type
Definition: sol.hpp:12709
bool valid() const noexcept
Definition: sol.hpp:20863
state_view & new_simple_usertype(const std::string &name, Args &&... args)
Definition: sol.hpp:21575
bool init_
Definition: sol.hpp:3514
int push(lua_State *L, T &&t, Args &&... args)
Definition: sol.hpp:7770
decltype(auto) get_value(std::true_type, T &&t)
Definition: sol.hpp:16668
wrapper< meta::unqualified_t< F > > wrap
Definition: sol.hpp:13366
static int push(lua_State *L, absolute_index ai)
Definition: sol.hpp:10959
static int call(lua_State *L)
Definition: sol.hpp:13910
static constexprbool has_assign(...)
Definition: sol.hpp:3391
std::ptrdiff_t difference_type
Definition: sol.hpp:12416
call_status status() const noexcept
Definition: sol.hpp:22063
static optional< R > get(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:10157
constexpr in_place_tag in_place(detail::in_place_of_tag)
Definition: sol.hpp:3223
static int push_func(std::index_sequence< I... >, lua_State *L, FP &&fp)
Definition: sol.hpp:14661
std::reverse_iterator< iterator > reverse_iterator
Definition: sol.hpp:12420
variadic_args(lua_State *luastate, int stackindex, int lastindex)
Definition: sol.hpp:15989
auto make_string_view(base_classes_tag)
Definition: sol.hpp:18509
void script_file(lua_State *L, const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:11897
table create_with(Args &&... args)
Definition: sol.hpp:20544
basic_userdata(stack_reference &&r)
Definition: sol.hpp:15849
meta::bind_traits< Signature > fx_t
Definition: sol.hpp:15456
T * static_addressof(T &ref)
Definition: sol.hpp:3477
meta::boolean< has_traits_pairs_test< T >::value > has_traits_pairs
Definition: sol.hpp:16604
protected_function_result safe_script_file(const std::string &filename, Fx &&on_error, load_mode mode=load_mode::any)
Definition: sol.hpp:21311
int is_indexer(base_classes_tag)
Definition: sol.hpp:18493
std::array< char, 1 > one
Definition: sol.hpp:16366
const auto base_classes
Definition: sol.hpp:6202
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: sol.hpp:12270
void emplace(T &v) noexcept
Definition: sol.hpp:4007
int returncount
Definition: sol.hpp:12410
error_result(const char *fmt_, const char *msg)
Definition: sol.hpp:16683
static int call(lua_State *L, const no_prop &)
Definition: sol.hpp:13334
lua_State * pick_main_thread(lua_State *L, lua_State *backup_if_unsupported=nullptr)
Definition: sol.hpp:6703
decltype(auto) base_class_new_index_propogation_key()
Definition: sol.hpp:6229
void * align_usertype_unique_destructor(void *ptr)
Definition: sol.hpp:7217
int operator()(lua_State *L)
Definition: sol.hpp:14031
basic_coroutine(stack_reference &&r)
Definition: sol.hpp:21980
static error_result add_insert_after(std::false_type, lua_State *L, T &self, stack_object value, iterator &)
Definition: sol.hpp:17100
static int call(lua_State *L)
Definition: sol.hpp:13876
static int push(lua_State *L, const std::initializer_list< T > &il)
Definition: sol.hpp:10648
lua_State * lua_state() const
Definition: sol.hpp:12145
probe(bool s, int l)
Definition: sol.hpp:7633
stack_table_core< true > stack_global_table
Definition: sol.hpp:296
simple_usertype< Class > create_simple_usertype(Args &&... args)
Definition: sol.hpp:21592
static table create(lua_State *L, int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:20505
static int size(lua_State *L)
Definition: sol.hpp:17650
basic_protected_function< reference, false, reference > safe_function
Definition: sol.hpp:307
static int push(lua_State *L, T *obj)
Definition: sol.hpp:10406
tie_t & operator=(T &&value)
Definition: sol.hpp:7078
table create(Name &&name, int narr=0, int nrec=0)
Definition: sol.hpp:20530
Definition: sol.hpp:16484
iterator begin()
Definition: sol.hpp:12324
sol::optional< T > argument_type
Definition: sol.hpp:4347
basic_object_base< base_type > base_t
Definition: sol.hpp:15880
basic_function(lua_State *L, T &&r)
Definition: sol.hpp:15001
std::ptrdiff_t difference_type
Definition: sol.hpp:12265
stack_proxy(lua_State *L, int index)
Definition: sol.hpp:12179
basic_table_core(lua_State *L, detail::global_tag t) noexcept
Definition: sol.hpp:20128
decltype(auto) tagged_get(types< T >, lua_State *L, int index, record &tracking)
Definition: sol.hpp:7964
function_arguments(Arg &&arg, Args &&... args)
Definition: sol.hpp:4966
static void destroy(T &&obj)
Definition: sol.hpp:4452
basic_environment(lua_State *L, new_table t, const basic_reference< b > &fallback)
Definition: sol.hpp:20604
char[32] typical_chunk_name_t
Definition: sol.hpp:11708
Definition: sol.hpp:14200
static bool check(types< T, Args... >, lua_State *L, int firstargument, Handler &&handler, record &tracking)
Definition: sol.hpp:7972
static error_result erase_integral(std::true_type, lua_State *L, T &self, K &key)
Definition: sol.hpp:17243
static void call(Args...)
Definition: sol.hpp:13110
~clean()
Definition: sol.hpp:19993
static int push(std::false_type, lua_State *L, const T &tablecont)
Definition: sol.hpp:10553
static int push_lvalue(std::true_type, lua_State *L, const C &cont)
Definition: sol.hpp:18029
static int push(lua_State *L, const var_wrapper< T > &vw)
Definition: sol.hpp:14779
const_iterator end() const
Definition: sol.hpp:12333
static constexprbool has_assign(bool)
Definition: sol.hpp:3397
static void select_reference_member_variable(std::true_type, lua_State *L, Fx &&fx, T &&obj, Args &&... args)
Definition: sol.hpp:14477
static error_result get_it(std::true_type, lua_State *L, T &self, K &key)
Definition: sol.hpp:16916
Definition: sol.hpp:12104
static error_result add_push_back(std::true_type, lua_State *, T &self, stack_object value, iterator &)
Definition: sol.hpp:17141
int operator()(lua_State *L)
Definition: sol.hpp:14059
OPTIONAL_CONSTEXPR_INIT_LIST optional(in_place_t, ::std::initializer_list< U > il, Args &&... args)
Definition: sol.hpp:3732
int returncount
Definition: sol.hpp:12216
traits_type::args_list args_list
Definition: sol.hpp:12611
this_state(lua_State *Ls)
Definition: sol.hpp:5050
basic_environment(stack_reference &&r)
Definition: sol.hpp:20596
const_iterator cend() const
Definition: sol.hpp:16031
Definition: sol.hpp:12567
basic_thread(lua_State *L, this_state actualthread)
Definition: sol.hpp:21793
static int push(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:10807
int push() const noexcept
Definition: sol.hpp:15629
lua_bind_traits< U > traits_type
Definition: sol.hpp:13634
decltype(auto) unqualified_get(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:8047
static void select_member_function(std::true_type, lua_State *L, Fx &&fx)
Definition: sol.hpp:14565
protected_function_result script_file(const std::string &filename, const environment &env, load_mode mode=load_mode::any)
Definition: sol.hpp:21409
static int push(lua_State *L, const function_arguments< T, Args... > &fp)
Definition: sol.hpp:14665
static int push(lua_State *L, raw_index ri)
Definition: sol.hpp:10967
std::basic_string< wchar_t, Traits, Al > S
Definition: sol.hpp:9654
int operator()(types< Fx >, index_value< I >, types< R... >, types< Args... >, lua_State *L, int, int, F &fx)
Definition: sol.hpp:13618
static error_result find_associative_lookup(std::false_type, lua_State *L, iterator &, std::size_t index)
Definition: sol.hpp:17072
static int push(lua_State *L, const char *str, std::size_t len)
Definition: sol.hpp:10896
unsafe_function_result(unsafe_function_result &&o)
Definition: sol.hpp:12429
unsafe_function_result()=default
int operator()(types< Fx >, index_value< I >, types< R... >, types< Args... >, lua_State *L, int, int, F &fx)
Definition: sol.hpp:13601
static error_result insert_after_has(std::true_type, lua_State *L, T &self, stack_object where, stack_object value)
Definition: sol.hpp:17207
std::string w
Definition: sol.hpp:417
T & type
Definition: sol.hpp:7666
std::conditional_t< can_read::value, R, no_prop > Read
Definition: sol.hpp:12929
lua_State * L
Definition: sol.hpp:5068
Definition: sol.hpp:12707
iterator it
Definition: sol.hpp:17541
bool check_stack(int modification=0) const
Definition: sol.hpp:7127
const destructor_wrapper< void > default_destructor
Definition: sol.hpp:4544
std::make_index_sequence< sizeof...(Args)> indices
Definition: sol.hpp:467
lua_State * L
Definition: sol.hpp:21057
static int push(lua_State *L, const char *str, std::size_t len)
Definition: sol.hpp:10871
protected_function_result script_default_on_error(lua_State *L, protected_function_result pfr)
Definition: sol.hpp:21042
int stack_index() const
Definition: sol.hpp:12514
lua_State * luastate
Definition: sol.hpp:6718
constexpr nullopt_t(init)
Definition: sol.hpp:3495
static int push(lua_State *L, const T &tablecont)
Definition: sol.hpp:10638
basic_object(lua_State *L, in_place_t, T &&arg, Args &&... args) noexcept
Definition: sol.hpp:16204
meta::unqualified_t< typename traits_type::template arg_at< 0 > > object_type
Definition: sol.hpp:13635
basic_environment(lua_nil_t r) noexcept
Definition: sol.hpp:20655
static int push(lua_State *L, const char16_t(&str)[N])
Definition: sol.hpp:11195
void get_field(lua_State *L, Key &&key)
Definition: sol.hpp:8069
static table create_table(lua_State *L, int narr=0, int nrec=0)
Definition: sol.hpp:21671
static void * type_cast_bases(types<>, T *, const std::string &)
Definition: sol.hpp:6249
traits_type::returns_list returns_list
Definition: sol.hpp:12613
int return_count() const
Definition: sol.hpp:12517
static void select_reference_member_function(std::true_type, lua_State *L, Fx &&fx, T &&obj, Args &&... args)
Definition: sol.hpp:14530
wrap::object_type object_type
Definition: sol.hpp:13367
optional< error > tagged_get(types< optional< error >>) const
Definition: sol.hpp:20808
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:13901
object index
Definition: sol.hpp:18438
lua_State * state
Definition: sol.hpp:19864
bool valid() const noexcept
Definition: sol.hpp:12307
basic_environment(T &&r) noexcept
Definition: sol.hpp:20645
static int push(lua_State *L, usertype< T > &user)
Definition: sol.hpp:19882
lua_State * L
Definition: sol.hpp:19998
load_result & operator=(load_result &&o) noexcept
Definition: sol.hpp:20842
meta::boolean< has_clear_test< T >::value > has_clear
Definition: sol.hpp:16574
basic_function< main_reference, false > main_unsafe_function
Definition: sol.hpp:308
static int call(lua_State *L, const F &)
Definition: sol.hpp:13565
static error_result get_comparative(std::false_type, lua_State *, T &, K &)
Definition: sol.hpp:16932
static iterator begin(lua_State *L, T &)
Definition: sol.hpp:16764
basic_coroutine(T &&r) noexcept
Definition: sol.hpp:21951
std::unordered_map< K, V, H, E > map_t
Definition: sol.hpp:4644
static int push(lua_State *L, const char(&str)[N], std::size_t sz)
Definition: sol.hpp:10910
function_type var
Definition: sol.hpp:14204
void for_each(Fx &&fx)
Definition: sol.hpp:21614
int set_ref(lua_State *L, T &&arg, int tableindex=-2)
Definition: sol.hpp:11806
T type
Definition: sol.hpp:7658
int returncount
Definition: sol.hpp:20786
decltype(auto) call(Args &&... args)
void invoke(types< void >, std::index_sequence< I >, std::ptrdiff_t n) const
Definition: sol.hpp:14959
protected_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n)
Definition: sol.hpp:21929
static int call(lua_State *L, const F &f)
Definition: sol.hpp:13590
static int push(std::index_sequence< I... >, lua_State *L, T &&c)
Definition: sol.hpp:10743
static int push_sized(lua_State *L, const char *str, std::size_t len)
Definition: sol.hpp:10878
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)
Definition: sol.hpp:21225
static int insert(lua_State *L)
Definition: sol.hpp:17456
static void clear_start(lua_State *L, T &self)
Definition: sol.hpp:17338
global_table global
Definition: sol.hpp:21059
basic_object(lua_nil_t r)
Definition: sol.hpp:16165
#define OPTIONAL_CONSTEXPR_INIT_LIST
Definition: sol.hpp:3334
basic_object & operator=(const proxy_base< Super > &r)
Definition: sol.hpp:16218
proxy & operator=(U &&other)
Definition: sol.hpp:15550
T member
Definition: sol.hpp:14176
thread_status status() const
Definition: sol.hpp:21821
bool is() const
Definition: sol.hpp:12123
static error_result set_associative_find(std::true_type, lua_State *L, T &self, stack_object okey, stack_object value)
Definition: sol.hpp:17025
static const std::string & qualified_name()
Definition: sol.hpp:6169
Definition: sol.hpp:18407
T member
Definition: sol.hpp:14205
static int push(lua_State *L, const char32_t *strb, const char32_t *stre)
Definition: sol.hpp:11134
basic_coroutine(Proxy &&p, Handler &&eh)
Definition: sol.hpp:21999
wrapper< meta::unqualified_t< F > > wrap
Definition: sol.hpp:13238
static table create(lua_State *L, int narr=0, int nrec=0)
Definition: sol.hpp:20497
static error_result find_has(std::false_type, lua_State *L, T &self)
Definition: sol.hpp:17096
unique_usertype_traits< T >::actual_type Real
Definition: sol.hpp:10438
const yield_tag_t yield_tag
Definition: sol.hpp:4679
int is_check(lua_State *L)
Definition: sol.hpp:18133
static void select_reference_member_function(std::false_type, lua_State *L, Fx &&fx, T &&obj, Args &&... args)
Definition: sol.hpp:14523
static int find(lua_State *L)
Definition: sol.hpp:17462
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:13963
tagged(Arg &&arg, Args &&... args)
Definition: sol.hpp:4485
std::add_pointer_t< meta::unqualified_t< std::remove_pointer_t< T > > > C
Definition: sol.hpp:18059
static error_result add_push_back(std::false_type, lua_State *L, T &self, stack_object value, iterator &pos)
Definition: sol.hpp:17151
const type_panic_t type_panic
Definition: sol.hpp:6364
hash< T >::result_type result_type
Definition: sol.hpp:4346
basic_reference & operator=(basic_reference &&r) noexcept
Definition: sol.hpp:6902
load_result load(lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:21446
stack_reference(lua_nil_t) noexcept
Definition: sol.hpp:6457
void type_error(lua_State *L, int expected, int actual) noexcept(false)
Definition: sol.hpp:6406
basic_table_core & new_usertype(const std::string &name, Args &&... args)
Definition: sol.hpp:20332
stack_iterator operator--(int)
Definition: sol.hpp:12030
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8181
static int defer_call(std::true_type, lua_State *L, F &&f, Args &&... args)
Definition: sol.hpp:13674
int simple_real_index_call(lua_State *L)
Definition: sol.hpp:19308
const_reverse_iterator crbegin() const
Definition: sol.hpp:16047
static int call(lua_State *L, F &&f, Args &&... args)
Definition: sol.hpp:13680
static bool type_check_bases(types<>, const std::string &)
Definition: sol.hpp:6236
static char32_t combine_surrogates(char16_t lead, char16_t trail)
Definition: sol.hpp:8997
int is_indexer(string_view s)
Definition: sol.hpp:18469
static int push_keyed(lua_State *L, K &&k, T *obj)
Definition: sol.hpp:10401
object require_file(const std::string &key, const std::string &filename, bool create_global=true, load_mode mode=load_mode::any)
Definition: sol.hpp:21232
basic_protected_function(lua_State *L, raw_index index, handler_t eh)
Definition: sol.hpp:15331
static int push(lua_State *L, const protect_t< T > &pw)
Definition: sol.hpp:14735
static int push(lua_State *L, const T &v)
Definition: sol.hpp:10621
const no_metatable_t no_metatable
Definition: sol.hpp:4706
std::shared_ptr< T > actual_type
Definition: sol.hpp:4757
probe apply(std::index_sequence< I, I1, In... >, int sofar, lua_State *L, Keys &&keys, int tableindex)
Definition: sol.hpp:11685
static error_result add_push_back(std::true_type, lua_State *, T &self, stack_object value)
Definition: sol.hpp:17146
basic_environment(lua_State *L, ref_index index)
Definition: sol.hpp:20636
decltype(auto) unchecked_unqualified_get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:7696
static std::function< Signature > get_std_func(types< void >, types< FxArgs... >, lua_State *L, int index)
Definition: sol.hpp:15470
static constexpr bool is_surrogate(char32_t u)
Definition: sol.hpp:8956
usertype(constructor_wrapper< Fxs... > constructorlist, Args &&... args)
Definition: sol.hpp:19840
static int find(lua_State *L)
Definition: sol.hpp:17646
bool xmovable(lua_State *leftL, lua_State *rightL)
Definition: sol.hpp:6435
static int at(lua_State *L)
Definition: sol.hpp:16704
bool maybe_indexable(lua_State *L, int index=-1)
Definition: sol.hpp:7738
basic_table_core & new_simple_usertype(const std::string &name, Args &&... args)
Definition: sol.hpp:20359
decltype(auto) writeonly_property(F &&f)
Definition: sol.hpp:12978
static int push(lua_State *L, const char16_t *u16str)
Definition: sol.hpp:11047
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)
Definition: sol.hpp:13175
basic_table_core(detail::no_safety_tag, T &&r) noexcept
Definition: sol.hpp:20143
stack_detail::strip_extensible_t< U > T
Definition: sol.hpp:9211
int operator()(types< Fx >, index_value< I >, types< R... > r, types< Args... > a, lua_State *L, int, int start, F &f)
Definition: sol.hpp:13537
T ** usertype_allocate_pointer(lua_State *L)
Definition: sol.hpp:7296
ref_index(int idx)
Definition: sol.hpp:4834
lua_State * operator->() const noexcept
Definition: sol.hpp:5058
std::pair< T, int > get_as_upvalues(lua_State *L, int index=2)
Definition: sol.hpp:11760
basic_table_core(detail::no_safety_tag, lua_State *L, T &&r) noexcept
Definition: sol.hpp:20147
static int clear(lua_State *L)
Definition: sol.hpp:16740
stack_iterator operator+(difference_type idx) const
Definition: sol.hpp:12050
Definition: sol.hpp:12724
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:14100
void make_call_op(Regs &l, int &index)
Definition: sol.hpp:18223
auto destructor(Fx &&fx)
Definition: sol.hpp:4547
const std::string & to_string(call_status c)
Definition: sol.hpp:5190
basic_string_view(const Char *ptr, std::size_t sz)
Definition: sol.hpp:1075
Definition: sol.hpp:20702
auto operator=(U &&v) -> typename ::std::enable_if< ::std::is_same< typename ::std::decay< U >::type, T >::value, optional &>::type
Definition: sol.hpp:3766
state_view & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:21635
static bool is_null(const actual_type &p)
Definition: sol.hpp:4766
static bool max_size_check(std::true_type, T &arr, std::size_t idx)
Definition: sol.hpp:9286
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:13960
Function fx
Definition: sol.hpp:4535
decltype(auto) base_class_cast_key()
Definition: sol.hpp:6219
int results
Definition: sol.hpp:16673
basic_reference & operator=(const lua_nil_t &) noexcept
Definition: sol.hpp:6922
closure(lua_CFunction f, int upvalue_count=0)
Definition: sol.hpp:4950
int call_exception_handler(lua_State *L, optional< const std::exception &> maybe_ex, string_view what)
Definition: sol.hpp:5850
optional(const optional< T &> &rhs)
Definition: sol.hpp:3702
usertype(constructors< CArgs... > constructorlist, Args &&... args)
Definition: sol.hpp:19835
probe probe_get_field(lua_State *L, Key &&key, int tableindex)
Definition: sol.hpp:8094
KV::second_type V
Definition: sol.hpp:16795
basic_protected_function(const basic_function< base_t > &b)
Definition: sol.hpp:15252
usertype(simple_tag, lua_State *L, Args &&... args)
Definition: sol.hpp:19845
call_syntax
Definition: sol.hpp:5133
std::random_access_iterator_tag iterator_category
Definition: sol.hpp:11980
int cannot_destruct(lua_State *L)
Definition: sol.hpp:7578
static error_result find_has_associative_lookup(std::true_type, lua_State *L, T &self)
Definition: sol.hpp:17046
basic_protected_function(lua_State *L, int index=-1)
Definition: sol.hpp:15308
static auto get(U &&value)
Definition: sol.hpp:4749
constexpr optional_base() noexcept
Definition: sol.hpp:3516
std::size_t length() const
Definition: sol.hpp:1114
void operator()(T &&obj) const
Definition: sol.hpp:4458
load_result(load_result &&o) noexcept
Definition: sol.hpp:20831
int stack_index() const noexcept
Definition: sol.hpp:6516
const int & operator[](std::size_t i) const
Definition: sol.hpp:4585
static int push(lua_State *L, const std::basic_string< Ch, Traits, Al > &wstr, std::size_t sz)
Definition: sol.hpp:11245
void top_apply(std::index_sequence< I0, I... >, lua_State *L, Keys &&keys, Value &&value, int tableindex)
Definition: sol.hpp:11619
map_t< std::string, call_information > mapping_t
Definition: sol.hpp:18405
static int push_keyed(lua_State *L, K &&k, Args &&... args)
Definition: sol.hpp:10375
decltype(auto) get_usertype(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:8036
static error_result add_associative(std::false_type, lua_State *L, T &self, stack_object value, iterator &pos)
Definition: sol.hpp:17169
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:18095
static void * type_cast_bases(types< Base, Args... >, T *data, const std::string &ti)
Definition: sol.hpp:6254
protected_function_result script_throw_on_error(lua_State *L, protected_function_result result)
Definition: sol.hpp:20984
Definition: sol.hpp:14171
basic_table_core(lua_State *L, T &&r)
Definition: sol.hpp:20169
basic_object(T &&r)
Definition: sol.hpp:16158
variadic_args & operator=(variadic_args &&o)
Definition: sol.hpp:16003
auto invoke(types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n)
Definition: sol.hpp:21913
bool check_metatable(lua_State *L, int index=-2)
Definition: sol.hpp:8164
Definition: sol.hpp:13765
state_view & new_usertype(const std::string &name, Args &&... args)
Definition: sol.hpp:21551
static int pairs_associative(std::false_type, lua_State *L)
Definition: sol.hpp:17403
basic_protected_function(lua_State *L, T &&r)
Definition: sol.hpp:15291
Definition: sol.hpp:13237
table create(int narr=0, int nrec=0)
Definition: sol.hpp:20520
void handle_filter(P &&p, lua_State *L, int &pushed)
Definition: sol.hpp:13082
static bool is_null(const actual_type &p)
Definition: sol.hpp:4784
const_iterator cbegin() const
Definition: sol.hpp:21461
static table create_with(lua_State *L, Args &&... args)
Definition: sol.hpp:20514
decltype(auto) overload(Args &&... args)
Definition: sol.hpp:8890
const Char * end() const
Definition: sol.hpp:1094
protected_handler(std::false_type, const target_t &target)
Definition: sol.hpp:15065
int type_panic_c_str(lua_State *L, int index, type expected, type actual, const char *message=nullptr) noexcept(false)
Definition: sol.hpp:6343
int call_into_lua(types< Ret0, Ret... >, types< Args... > ta, lua_State *L, int start, Fx &&fx, FxArgs &&... fxargs)
Definition: sol.hpp:11855
static error_result insert_copyable(std::true_type, lua_State *L, T &self, stack_object key, stack_object value)
Definition: sol.hpp:17235
const_reverse_iterator rend() const
Definition: sol.hpp:12352
basic_table_core & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:20462
optional & operator=(optional &&rhs) noexcept(::std::is_nothrow_move_assignable< T >::value &&::std::is_nothrow_move_constructible< T >::value)
Definition: sol.hpp:3755
static bool check(lua_State *, int, Handler &&, record &tracking)
Definition: sol.hpp:8339
meta::boolean< has_traits_ipairs_test< T >::value > has_traits_ipairs
Definition: sol.hpp:16607
var_wrapper(Args &&... args)
Definition: sol.hpp:13008
callable_binding(Arg &&arg)
Definition: sol.hpp:18418
int operator()(lua_State *L, int index, type expected, type actual) const noexcept(false)
Definition: sol.hpp:6353
static int add(lua_State *L)
Definition: sol.hpp:16724
std::conditional_t< is_const, const proxy_t *, proxy_t * > pointer
Definition: sol.hpp:11977
static int call(lua_State *L)
Definition: sol.hpp:14083
constexpr T const & operator*() const
Definition: sol.hpp:3876
void set_field(lua_State *L, Key &&key, Value &&value)
Definition: sol.hpp:8109
basic_object(stack_reference &&r) noexcept
Definition: sol.hpp:16173
Definition: sol.hpp:12174
std::shared_ptr< X > rebind_base
Definition: sol.hpp:4762
std::size_t size() const
Definition: sol.hpp:16092
static auto size_has(std::true_type, lua_State *, T &self)
Definition: sol.hpp:17306
auto setup_table(std::true_type)
Definition: sol.hpp:15515
static error_result find_comparative(std::true_type, lua_State *L, T &self)
Definition: sol.hpp:17080
basic_object & operator=(proxy_base< Super > &&r)
Definition: sol.hpp:16223
int call_set_assignable(std::true_type, lua_State *L, T &&mem)
Definition: sol.hpp:13787
lua_bind_traits< F > traits_type
Definition: sol.hpp:13455
push_popper(T)
Definition: sol.hpp:6654
static error_result set_comparative(std::true_type, lua_State *L, T &self, stack_object okey, stack_object value)
Definition: sol.hpp:16995
const_iterator begin() const
Definition: sol.hpp:16022
load_result(lua_State *Ls, int stackindex=-1, int retnum=0, int popnum=0, load_status lerr=load_status::ok) noexcept
Definition: sol.hpp:20826
unsafe_function_result script(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:21422
const_iterator cend() const
Definition: sol.hpp:20225
Definition: sol.hpp:22112
void ensure_package(const std::string &key, T &&sr)
Definition: sol.hpp:21076
static error_result find_associative_lookup(std::true_type, lua_State *L, iterator &it, std::size_t)
Definition: sol.hpp:17068
basic_protected_function< main_reference, false, reference > main_safe_function
Definition: sol.hpp:309
void * align(std::size_t alignment, std::size_t size, void *&ptr, std::size_t &space, std::size_t &required_space)
Definition: sol.hpp:7166
int stack_index() const
Definition: sol.hpp:12148
void make_destructor(Regs &l, int &index)
Definition: sol.hpp:18272
static error_result erase_start(lua_State *L, T &self, K &key)
Definition: sol.hpp:17346
lua_State * L
Definition: sol.hpp:20784
Definition: sol.hpp:16424
static auto & get_src(lua_State *L)
Definition: sol.hpp:17548
#define SOL_DEPRECATED
Definition: sol.hpp:15745
static int push(lua_State *L, const property_wrapper< F, G > &pw)
Definition: sol.hpp:14749
static int convert_into(lua_State *L, char *start, std::size_t, const char16_t *strb, const char16_t *stre)
Definition: sol.hpp:11026
basic_object(lua_State *L, ref_index index) noexcept
Definition: sol.hpp:16196
decltype(auto) property(F &&f, G &&g)
Definition: sol.hpp:12960
encoded_result< char > code_point_to_utf8(char32_t codepoint)
Definition: sol.hpp:9004
stack_proxy reference_type
Definition: sol.hpp:15975
Definition: sol.hpp:13926
static int push(lua_State *L, destructor_wrapper< Fx > &&c)
Definition: sol.hpp:14896
bool operator==(const basic_table_iterator &right) const
Definition: sol.hpp:19963
const_reverse_iterator crend() const
Definition: sol.hpp:12499
const_iterator cbegin() const
Definition: sol.hpp:12477
T func
Definition: sol.hpp:4710
basic_object_base< base_type > base_t
Definition: sol.hpp:20016
static constexpr char32_t decode(unsigned char b0, unsigned char b1)
Definition: sol.hpp:8979
Definition: sol.hpp:11770
basic_object(lua_State *L, lua_nil_t r) noexcept
Definition: sol.hpp:16184
int usertype_alloc_destruct(lua_State *L)
Definition: sol.hpp:7537
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)
Definition: sol.hpp:21396
void(* base_walk)(lua_State *, bool &, int &, string_view &)
Definition: sol.hpp:18389
proxy(Table table, T &&k)
Definition: sol.hpp:15533
static int call(lua_State *L, Fx &&f, object_type &o)
Definition: sol.hpp:13370
int operator()(types< Fx >, index_value< I >, types< R... > r, types< Args... > a, lua_State *L, int, int start) const
Definition: sol.hpp:13123
std::remove_pointer_t< lua_CFunction > lua_CFunction_ref
Definition: sol.hpp:4732
wrap::object_type object_type
Definition: sol.hpp:13457
static int push(lua_State *L, const T &value)
Definition: sol.hpp:10489
std::array< char, 2 > two
Definition: sol.hpp:16307
destructor_wrapper< Fx > F
Definition: sol.hpp:13572
static int index_get(lua_State *L)
Definition: sol.hpp:16712
table create_named(Name &&name, Args &&... args)
Definition: sol.hpp:20549
basic_string_view(const Char *ptr)
Definition: sol.hpp:1072
stack_proxy * pointer
Definition: sol.hpp:12264
static int push(lua_State *L, no_metatable_t, user< T > &&u)
Definition: sol.hpp:10839
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:13930
encoded_result< char32_t > code_point_to_utf32(char32_t codepoint)
Definition: sol.hpp:9060
Definition: sol.hpp:12609
optional & operator=(nullopt_t) noexcept
Definition: sol.hpp:3740
std::unique_ptr< usertype_detail::registrar > metatableregister
Definition: sol.hpp:19810
constructor_list< L0, Lists... > cl_t
Definition: sol.hpp:14838
table create_named_table(Name &&name, Args &&... args)
Definition: sol.hpp:21651
static void clear_has(std::true_type, lua_State *, T &self)
Definition: sol.hpp:17310
basic_reference(lua_State *L, basic_reference< r_main_only > &&r) noexcept
Definition: sol.hpp:6825
int SOL_INTERNAL_UNSPECIALIZED_MARKER_
Definition: sol.hpp:5633
lua_State * lua_state() const
Definition: sol.hpp:21126
decltype(auto) base_class_check_key()
Definition: sol.hpp:6214
wrapper< meta::unqualified_t< F > > wrap
Definition: sol.hpp:13456
auto filters(F &&f, Args &&... args)
Definition: sol.hpp:4613
call_status
Definition: sol.hpp:5144
wrapper< U > wrap
Definition: sol.hpp:13633
virtual ~registrar()
Definition: sol.hpp:18532
void emplace(Args &&... args)
Definition: sol.hpp:3780
lua_thread_state(lua_State *Ls)
Definition: sol.hpp:21695
decltype(auto) base_class_index_propogation_key()
Definition: sol.hpp:6224
stack_proxy operator[](difference_type index_offset) const
Definition: sol.hpp:16079
Definition: sol.hpp:14037
int unique_destruct(lua_State *L)
Definition: sol.hpp:7548
int simple_core_indexing_call(lua_State *L)
Definition: sol.hpp:19194
static bool check(types< U >, lua_State *L, int index, type indextype, Handler &&handler, record &tracking)
Definition: sol.hpp:8568
table create_table(Name &&name, int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:21646
static constexpr bool is_trail_surrogate(char32_t u)
Definition: sol.hpp:8953
auto invoke(types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
Definition: sol.hpp:15151
Ret invoke(types< Ret >, std::index_sequence< I >, std::ptrdiff_t n)
Definition: sol.hpp:21919
auto var(V &&v)
Definition: sol.hpp:13018
basic_object(lua_State *L, T &&r)
Definition: sol.hpp:16162
overload_set(Arg &&arg, Args &&... args)
Definition: sol.hpp:8880
protected_function_result safe_script_file(const std::string &filename, const basic_environment< E > &env, load_mode mode=load_mode::any)
Definition: sol.hpp:21329
int operator()(lua_State *L)
Definition: sol.hpp:14126
virtual int new_index(lua_State *L) override
Definition: sol.hpp:18426
bool init_
Definition: sol.hpp:3570
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8701
Definition: sol.hpp:16394
int return_count() const noexcept
Definition: sol.hpp:12368
static int call(lua_State *L)
Definition: sol.hpp:13983
optional(const optional &rhs)
Definition: sol.hpp:3694
unsafe_function_result script_file(const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:21426
basic_object(proxy_base< Super > &&r) noexcept
Definition: sol.hpp:16181
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)
Definition: sol.hpp:21386
meta::unqualified_t< decltype(get_key(is_associative(), std::declval< std::add_lvalue_reference_t< value_type >>()))> key_type
Definition: sol.hpp:16815
T value
Definition: sol.hpp:12897
static int push(lua_State *L, const wchar_t *strb, const wchar_t *stre)
Definition: sol.hpp:10991
lua_State * operator->() const noexcept
Definition: sol.hpp:5078
void operator()(lua_State *L) const
Definition: sol.hpp:4471
static int index_set(lua_State *L)
Definition: sol.hpp:17642
const env_t env_key
Definition: sol.hpp:4703
traits_type::returns_list returns_list
Definition: sol.hpp:12668
#define COMPAT53_API
Definition: sol.hpp:1967
basic_object(const proxy_base< Super > &r) noexcept
Definition: sol.hpp:16177
static int push(lua_State *L, const property_wrapper< void, F > &pw)
Definition: sol.hpp:14769
static error_result add_insert(std::false_type, lua_State *L, T &self, stack_object value)
Definition: sol.hpp:17137
Definition: sol.hpp:11025
basic_protected_function< stack_reference, false, reference > stack_safe_function
Definition: sol.hpp:311
protected_handler(std::true_type, const target_t &target)
Definition: sol.hpp:15073
stack_iterator< stack_proxy, true > const_iterator
Definition: sol.hpp:12268
static int push(lua_State *L, const property_wrapper< F, void > &pw)
Definition: sol.hpp:14759
const nil_t nil
Definition: sol.hpp:4692
Definition: sol.hpp:14252
protected_function_result operator()(Args &&... args)
Definition: sol.hpp:22082
std::integral_constant< std::size_t, I > index_value
Definition: sol.hpp:1205
constexpr optional(T &v) noexcept
Definition: sol.hpp:3958
main_safe_function main_protected_function
Definition: sol.hpp:315
stack_iterator< stack_proxy, true > const_iterator
Definition: sol.hpp:15981
basic_lightuserdata(lua_State *L, T &&r)
Definition: sol.hpp:15907
Definition: sol.hpp:19988
lua_State * L
Definition: sol.hpp:19989
T type
Definition: sol.hpp:4777
static int push(lua_State *L, const std::basic_string< char, Traits, Al > &str)
Definition: sol.hpp:10926
T type
Definition: sol.hpp:4756
constexpr T * operator->() const
Definition: sol.hpp:4018
as_table_t(Arg0 &&arg0, Arg1 &&arg1, Args &&... args)
Definition: sol.hpp:4995
hash< T >::result_type result_type
Definition: sol.hpp:4356
state_view state() const
Definition: sol.hpp:21807
const_reverse_iterator crbegin() const
Definition: sol.hpp:12355
T value
Definition: sol.hpp:13006
int operator()(types< Fx >, index_value< I >, types< R >, types< Args... >, lua_State *L, int, int) const
Definition: sol.hpp:13839
static T & get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:9977
constexpr U convert(U v)
Definition: sol.hpp:3483
static int push(std::false_type, std::integral_constant< bool, is_nested >, lua_State *L, const T &tablecont)
Definition: sol.hpp:10575
std::array< int, 64 > stack_indices
Definition: sol.hpp:4571
static error_result find_comparative(std::false_type, lua_State *, T &)
Definition: sol.hpp:17076
bool is_indeterminate_call_failure(call_status c)
Definition: sol.hpp:5226
static int push(lua_State *L, const char *str)
Definition: sol.hpp:10861
int(*)(lua_State *, optional< const std::exception & >, string_view) exception_handler_function
Definition: sol.hpp:5831
std::array< char, 1 > one
Definition: sol.hpp:16336
static int push(lua_State *L, const T &value)
Definition: sol.hpp:10497
iterator const_iterator
Definition: sol.hpp:20153
static int push(lua_State *L, T &&t)
Definition: sol.hpp:11268
Definition: sol.hpp:16409
static int push(lua_State *L, std::function< Signature > &&fx)
Definition: sol.hpp:14680
state_view & traverse_set(Args &&... args)
Definition: sol.hpp:21534
basic_table_iterator< base_type > iterator
Definition: sol.hpp:20152
int push(lua_State *L, const variadic_results &e)
Definition: sol.hpp:22147
constexpr T & value_or(V &&v) const
Definition: sol.hpp:4040
int push() const noexcept
Definition: sol.hpp:6937
~protected_handler()
Definition: sol.hpp:15088
int & n
Definition: sol.hpp:19999
Definition: sol.hpp:14140
stack_reference(lua_State *L, const stack_reference &r) noexcept
Definition: sol.hpp:6473
static bool is_null(U &&)
Definition: sol.hpp:4744
reference handler_t
Definition: sol.hpp:21897
~push_popper()
Definition: sol.hpp:6649
static int push(lua_State *L, no_metatable_t, Args &&... args)
Definition: sol.hpp:10813
Definition: sol.hpp:16439
static std::function< Signature > get_std_func(types< Ret... >, types< Args... >, lua_State *L, int index)
Definition: sol.hpp:15461
main_table_core< true > main_global_table
Definition: sol.hpp:294
static const std::string & metatable()
Definition: sol.hpp:6173
bool valid() const noexcept
Definition: sol.hpp:12507
constexpr bool initialized() const noexcept
Definition: sol.hpp:3627
basic_table_core & new_usertype(const std::string &name, constructors< CArgs... > ctor, Args &&... args)
Definition: sol.hpp:20345
probe apply(std::index_sequence< I >, int sofar, lua_State *L, Keys &&keys, int tableindex)
Definition: sol.hpp:11679
static int call_void(std::false_type, lua_State *L, const F &f)
Definition: sol.hpp:13584
const void * pointer() const noexcept
Definition: sol.hpp:6969
void swap(optional< T > &x, optional< T > &y) noexcept(noexcept(x.swap(y)))
Definition: sol.hpp:4327
const_reverse_iterator rend() const
Definition: sol.hpp:12493
static int push(lua_State *L, lua_CFunction func, int n=0)
Definition: sol.hpp:10700
static int push(lua_State *L, T &&c)
Definition: sol.hpp:10749
static int pairs_associative(std::true_type, lua_State *L)
Definition: sol.hpp:17394
static std::function< Signature > get_std_func(types<>, types< FxArgs... > t, lua_State *L, int index)
Definition: sol.hpp:15479
constexpr struct sol::trivial_init_t trivial_init
traits_type::args_list args_list
Definition: sol.hpp:12666
T src
Definition: sol.hpp:15941
void tuple_set(std::index_sequence< I... >, T &&value)
Definition: sol.hpp:15511
error_code
Definition: sol.hpp:8903
traits_type::returns_list returns_list
Definition: sol.hpp:12633
basic_thread(stack_reference &&r)
Definition: sol.hpp:21762
int index
Definition: sol.hpp:12215
variadic_args(variadic_args &&o)
Definition: sol.hpp:15994
Ret invoke(types< Ret >, std::index_sequence< I >, std::ptrdiff_t n) const
Definition: sol.hpp:14953
int operator()(lua_State *L)
Definition: sol.hpp:14237
static int push(lua_State *L, const variadic_args &ref)
Definition: sol.hpp:16111
std::size_t size() const
Definition: sol.hpp:1110
const_iterator cend() const
Definition: sol.hpp:21465
basic_protected_function(lua_State *L, T &&r, handler_t eh)
Definition: sol.hpp:15295
traits_type::return_type return_type
Definition: sol.hpp:12665
basic_coroutine(basic_function< base_t > &&b, handler_t eh)
Definition: sol.hpp:21974
basic_protected_function(lua_State *L, ref_index index)
Definition: sol.hpp:15338
basic_coroutine(const basic_function< base_t > &b)
Definition: sol.hpp:21965
int call_indexing_object(lua_State *L, object &f)
Definition: sol.hpp:19182
bool is_main_thread() const
Definition: sol.hpp:21811
constexpr const T & contained_val() const
Definition: sol.hpp:3657
static int push(std::true_type, std::integral_constant< bool, is_nested >, lua_State *L, const T &tablecont)
Definition: sol.hpp:10559
basic_object_base< base_type > base_t
Definition: sol.hpp:16145
std::tuple< std::add_lvalue_reference_t< Tn >... > base_t
Definition: sol.hpp:7044
int call_wrapper_variable(std::true_type, lua_State *L)
Definition: sol.hpp:13803
stack_iterator()
Definition: sol.hpp:11986
void apply(std::index_sequence< 0, I... >, lua_State *L, Keys &&keys, int tableindex)
Definition: sol.hpp:11487
simple_usertype< Class > create_simple_usertype(Args &&... args)
Definition: sol.hpp:20378
static int push_deep(lua_State *L, Args &&... args)
Definition: sol.hpp:10454
meta::boolean< has_erase_after_test< T >::value > has_erase_after
Definition: sol.hpp:16586
basic_table_core & traverse_set(Keys &&... keys)
Definition: sol.hpp:20262
static auto call(Fx &&fx, object_type &mem) -> detail::array_return_type< decltype(mem.*fx)>
Definition: sol.hpp:12681
basic_function< reference, false > unsafe_function
Definition: sol.hpp:306
table_core< false > table
Definition: sol.hpp:291
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8637
meta::is_matched_lookup< T > is_matched_lookup
Definition: sol.hpp:16784
static int push(lua_State *L, factory_wrapper< Functions... > &&set, function_detail::call_indicator)
Definition: sol.hpp:14804
auto tuple_get(types< Ret0, Ret1, Ret... >, std::index_sequence< 0, 1, I... >, Keys &&keys) const -> decltype(stack::pop< std::tuple< Ret0, Ret1, Ret... >>(nullptr))
Definition: sol.hpp:20049
call_status err
Definition: sol.hpp:12218
basic_function(stack_reference &&r)
Definition: sol.hpp:14994
void raw_set_field(lua_State *L, Key &&key, Value &&value, int tableindex)
Definition: sol.hpp:8124
type get_type() const
Definition: sol.hpp:15637
const_reverse_iterator rend() const
Definition: sol.hpp:16044
std::tuple< Functions... > functions
Definition: sol.hpp:4521
basic_table_core & new_usertype(const std::string &name, Args &&... args)
Definition: sol.hpp:20339
static int push(lua_State *L, void *userdata)
Definition: sol.hpp:10756
struct sol::detail::verified_tag verified
static int push(lua_State *L, as_container_t< T > &&as_cont)
Definition: sol.hpp:18052
static int push(lua_State *L, const unsafe_function_result &fr)
Definition: sol.hpp:12533
push_popper_n(lua_State *luastate, int x)
Definition: sol.hpp:6618
iterator end()
Definition: sol.hpp:12468
static int next_iter(lua_State *L)
Definition: sol.hpp:17578
const char * fmt_
Definition: sol.hpp:16674
int push(lua_State *Ls) const
Definition: sol.hpp:12140
static int push(lua_State *L, const char32_t *u32str, std::size_t sz)
Definition: sol.hpp:11130
int push(lua_State *Ls) const noexcept
Definition: sol.hpp:6941
as_table_t< T > as_table_ref(T &&container)
Definition: sol.hpp:5028
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8562
upvalue_index(int idx)
Definition: sol.hpp:4801
std::string type_name(lua_State *L, type t)
Definition: sol.hpp:5362
basic_object(lua_State *L, raw_index index) noexcept
Definition: sol.hpp:16193
const std::string & default_chunk_name()
Definition: sol.hpp:11710
std::size_t i
Definition: sol.hpp:16821
const std::array< std::string, 32 > & meta_function_names()
Definition: sol.hpp:5316
load_result load_file(const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:21441
basic_reference(const basic_reference &o) noexcept
Definition: sol.hpp:6882
basic_object< stack_reference > stack_object
Definition: sol.hpp:359
Read read
Definition: sol.hpp:12931
Definition: sol.hpp:16634
auto make_light(T &l)
Definition: sol.hpp:4893
constexpr const T & storage() const
Definition: sol.hpp:3605
const lua_Integer toplevel_magic
Definition: sol.hpp:18467
proxy< const global_table &, T > operator[](T &&key) const
Definition: sol.hpp:21624
std::size_t size() const
Definition: sol.hpp:4589
static error_result add_copyable(std::true_type, lua_State *L, T &self, stack_object value)
Definition: sol.hpp:17181
absolute_index(lua_State *L, int idx)
Definition: sol.hpp:4823
static int push(lua_State *L, var_wrapper< T > &&vw)
Definition: sol.hpp:14776
optional & operator=(const optional &rhs)
Definition: sol.hpp:3745
const_reverse_iterator crend() const
Definition: sol.hpp:12358
decltype(auto) get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:8053
void set_default_exception_handler(lua_State *L, exception_handler_function exf=&detail::default_exception_handler)
Definition: sol.hpp:5998
const_reverse_iterator rbegin() const
Definition: sol.hpp:12349
int stack_top() const
Definition: sol.hpp:21481
static error_result erase_after_has(std::true_type, lua_State *L, T &self, K &key)
Definition: sol.hpp:17275
std::array< char, 1 > one
Definition: sol.hpp:16381
static error_result at_start(lua_State *L, T &self, std::ptrdiff_t pos)
Definition: sol.hpp:16873
std::array< char, 1 > one
Definition: sol.hpp:16396
static error_result find_has_associative_lookup(std::false_type, lua_State *L, T &self)
Definition: sol.hpp:17055
std::array< char, 1 > one
Definition: sol.hpp:16306
static int push(lua_State *L, const yielding_t< T > &f, Args &&... args)
Definition: sol.hpp:14644
bad_optional_access(const ::std::string &what_arg)
Definition: sol.hpp:3503
const_reverse_iterator crend() const
Definition: sol.hpp:16050
basic_lightuserdata(stack_reference &&r)
Definition: sol.hpp:15903
static int convert_into(lua_State *L, char *start, std::size_t, const char32_t *strb, const char32_t *stre)
Definition: sol.hpp:11106
stack_proxy get(types< Args... > t, const protected_function_result &fr)
Definition: sol.hpp:12588
static int push(lua_State *L, const basic_string_view< Ch, Traits > &sv)
Definition: sol.hpp:10939
constexpr T & value() const
Definition: sol.hpp:4026
wrap::object_type object_type
Definition: sol.hpp:13398
std::tuple< Ps... > arguments
Definition: sol.hpp:4964
traits_type::args_list args_list
Definition: sol.hpp:12631
static error_result erase_has(std::true_type, lua_State *L, T &self, K &key)
Definition: sol.hpp:17294
Definition: sol.hpp:10982
static int push(lua_State *L, const char *str)
Definition: sol.hpp:10884
static int push(lua_State *L, const wchar_t *str, std::size_t len)
Definition: sol.hpp:11017
std::array< char, 1 > one
Definition: sol.hpp:16426
static int push(lua_State *L, const char16_t *strb, const char16_t *stre)
Definition: sol.hpp:11055
static int push(lua_State *L, std::nullptr_t)
Definition: sol.hpp:11295
virtual ~variable_wrapper()
Definition: sol.hpp:18410
simple_map(const char *mkey, base_walk index, base_walk newindex, object i, object ni, variable_map &&vars, function_map &&funcs)
Definition: sol.hpp:18443
static int find(lua_State *L)
Definition: sol.hpp:16732
static const char * get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:9625
static S get_into(lua_State *L, int index, record &tracking)
Definition: sol.hpp:9737
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8285
static error_result insert_copyable(std::false_type, lua_State *, T &, stack_object, stack_object)
Definition: sol.hpp:17239
void rebind_base
Definition: sol.hpp:4739
meta::boolean< has_traits_erase_test< T >::value > has_traits_erase
Definition: sol.hpp:16631
static const std::string & user_metatable()
Definition: sol.hpp:6177
static int push(lua_State *L, F &&f, Args &&... args)
Definition: sol.hpp:14688
void set_fx(types<>, Key &&key, Fx &&fx, Args &&... args)
Definition: sol.hpp:20487
static int push(lua_State *L, Arg0 &&arg0, Arg0 &&arg1, Args &&... args)
Definition: sol.hpp:10449
std::size_t total_memory_used(lua_State *L)
Definition: sol.hpp:20973
void apply(std::index_sequence< I >, lua_State *L, Key &&keys, Value &&value, int tableindex)
Definition: sol.hpp:11608
usertype(detail::add_destructor_tag, Args &&... args)
Definition: sol.hpp:19819
void set_fx(types<>, Key &&key, Fx &&fx)
Definition: sol.hpp:20482
O object_type
Definition: sol.hpp:12708
std::ptrdiff_t difference_type
Definition: sol.hpp:19902
int index
Definition: sol.hpp:4833
std::size_t size_type
Definition: sol.hpp:15979
static int push(lua_State *L, const std::function< Signature > &fx)
Definition: sol.hpp:14676
function_type invocation
Definition: sol.hpp:14175
std::size_t size_type
Definition: sol.hpp:12417
int default_to_string(lua_State *L)
Definition: sol.hpp:18173
std::array< char, 1 > one
Definition: sol.hpp:16321
basic_environment(lua_State *L, T &&r) noexcept
Definition: sol.hpp:20660
std::integral_constant< bool, !std::is_void< W >::value > can_write
Definition: sol.hpp:12928
basic_table_core(detail::no_safety_tag, lua_State *L, int index)
Definition: sol.hpp:20136
static constexpr bool has_overload(...)
Definition: sol.hpp:3459
static void select_convertible(std::true_type, types< R(A...)>, lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:14449
stack_proxy reference_type
Definition: sol.hpp:12413
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)
Definition: sol.hpp:21405
safe_function protected_function
Definition: sol.hpp:314
typename clean_type< T >::type clean_type_t
Definition: sol.hpp:18726
bool multi_check(lua_State *L, int index)
Definition: sol.hpp:8022
lua_State * L
Definition: sol.hpp:6616
unique_usertype_traits< T >::actual_type Real
Definition: sol.hpp:10008
simple_usertype< Class > create_simple_usertype(Args &&... args)
Definition: sol.hpp:21587
T & item
Definition: sol.hpp:4660
proxy< basic_table_core, T > operator[](T &&key) &&
Definition: sol.hpp:20451
global_table globals() const
Definition: sol.hpp:21469
void use(int count)
Definition: sol.hpp:7649
void set_exception_handler(exception_handler_function handler)
Definition: sol.hpp:21503
const_iterator begin() const
Definition: sol.hpp:12471
std::reverse_iterator< iterator > reverse_iterator
Definition: sol.hpp:12269
int registry_index() const noexcept
Definition: sol.hpp:6961
error_result(int results)
Definition: sol.hpp:16680
decltype(auto) readonly_property(F &&f)
Definition: sol.hpp:12973
state_view & new_usertype(const std::string &name, Args &&... args)
Definition: sol.hpp:21557
#define TR2_OPTIONAL_REQUIRES(...)
Definition: sol.hpp:3269
basic_environment< E > get_environment(const T &target)
Definition: sol.hpp:20696
#define TR2_OPTIONAL_ASSERTED_EXPRESSION(CHECK, EXPR)
Definition: sol.hpp:3450
static int convertible_call(std::true_type, lua_State *L, Fx &&f, Args &&... args)
Definition: sol.hpp:13241
basic_protected_function(proxy_base< Super > &&p)
Definition: sol.hpp:15282
std::array< char, 2 > two
Definition: sol.hpp:16502
usertype(detail::check_destructor_tag, Args &&... args)
Definition: sol.hpp:19824
T * ref
Definition: sol.hpp:3944
static error_result erase_associative_lookup(std::false_type, lua_State *L, T &self, K &key)
Definition: sol.hpp:17271
basic_coroutine(lua_State *L, absolute_index index)
Definition: sol.hpp:22031
int operator()(lua_State *L)
Definition: sol.hpp:13953
static int push(lua_State *L, const basic_string_view< Ch, Traits > &sv, std::size_t n)
Definition: sol.hpp:10943
basic_object(lua_State *L, in_place_type_t< T >, Args &&... args) noexcept
Definition: sol.hpp:16200
static error_result add_copyable(std::true_type, lua_State *L, T &self, stack_object value, iterator &pos)
Definition: sol.hpp:17177
meta::tuple_types< R > returns_list
Definition: sol.hpp:12712
std::array< char, 2 > two
Definition: sol.hpp:16367
basic_thread(lua_State *L, lua_State *actualthread)
Definition: sol.hpp:21790
light(L &x)
Definition: sol.hpp:4875
static int call(lua_State *L, V &&)
Definition: sol.hpp:13494
std::string demangle_once()
Definition: sol.hpp:6102
stack_proxy_base(lua_State *L, int index)
Definition: sol.hpp:12113
int handle_errors(lua_State *L, const error_result &er)
Definition: sol.hpp:16688
basic_coroutine(lua_State *L, absolute_index index, handler_t eh)
Definition: sol.hpp:22034
bool operator!=(const stack_iterator &r) const
Definition: sol.hpp:12070
int static_trampoline_noexcept(lua_State *L) noexcept
Definition: sol.hpp:5940
static error_result erase_has(std::false_type, lua_State *L, T &self, K &key)
Definition: sol.hpp:17298
std::array< char, 1 > one
Definition: sol.hpp:16516
stack_iterator & operator++()
Definition: sol.hpp:12014
Definition: sol.hpp:21055
struct sol::detail::global_tag global_
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8487
protected_function_result(lua_State *Ls, int idx=-1, int retnum=0, int popped=0, call_status pferr=call_status::ok) noexcept
Definition: sol.hpp:12273
push_popper_at push_pop_at(T &&x)
Definition: sol.hpp:6665
T * ptr(T &val)
Definition: sol.hpp:1862
auto factories(Functions &&... functions)
Definition: sol.hpp:4529
std::array< char, 2 > two
Definition: sol.hpp:16397
decltype(auto) as() const
Definition: sol.hpp:15808
meta::bind_traits< function_type >::return_type return_type
Definition: sol.hpp:14202
reference operator*()
Definition: sol.hpp:19955
const int simple_metatable_index
Definition: sol.hpp:18385
bool is_main_thread(lua_State *L)
Definition: sol.hpp:7747
int used
Definition: sol.hpp:7644
basic_table< base_type > base_t
Definition: sol.hpp:20583
decoded_result< It > utf8_to_code_point(It it, It last)
Definition: sol.hpp:9069
static constexpr bool has_overload(bool)
Definition: sol.hpp:3464
basic_userdata(lua_State *L, ref_index index)
Definition: sol.hpp:15868
types< object_type &, return_type > free_args_list
Definition: sol.hpp:12667
static bool check(lua_State *L, int index, Handler &&, record &tracking)
Definition: sol.hpp:8717
protected_function_result do_file(const std::string &filename, const basic_environment< E > &env, load_mode mode=load_mode::any)
Definition: sol.hpp:21253
table create_table(int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:21662
protected_function_result script_file(const std::string &filename, Fx &&on_error, load_mode mode=load_mode::any)
Definition: sol.hpp:21391
stack_reference(lua_State *L, int i) noexcept
Definition: sol.hpp:6462
int index
Definition: sol.hpp:6604
bool operator==(const basic_string_view &r) const
Definition: sol.hpp:1122
static int call(lua_State *L, V &&, object_type &)
Definition: sol.hpp:13499
decltype(&inheritance< void >::type_check) inheritance_check_function
Definition: sol.hpp:6299
stack_iterator< stack_proxy, false > iterator
Definition: sol.hpp:12418
decltype(auto) unqualified_check_get(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:7888
std::tuple< decltype(stack::get< Tn >nullptr, 0))... > R
Definition: sol.hpp:10021
basic_table_core & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:20456
bool multi_check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:7995
static int push_fx(lua_State *L, F &&f, Args &&... args)
Definition: sol.hpp:10361
static int at(lua_State *L)
Definition: sol.hpp:17412
optional< environment > env
Definition: sol.hpp:20703
Definition: sol.hpp:16640
protected_function_result(protected_function_result &&o) noexcept
Definition: sol.hpp:12278
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)
Definition: sol.hpp:21240
optional_base(T &&v)
Definition: sol.hpp:3524
static int push(lua_State *L, char32_t c)
Definition: sol.hpp:11233
lua_bind_traits< meta::unqualified_t< F > > traits_type
Definition: sol.hpp:12663
static int push(lua_State *L, const wchar_t *strb, const wchar_t *stre)
Definition: sol.hpp:11011
lua_State * lua_state() const
Definition: sol.hpp:12511
static int call_assign(std::false_type, lua_State *L, Args &&...)
Definition: sol.hpp:13427
basic_reference(lua_State *L, const basic_reference< r_main_only > &r) noexcept
Definition: sol.hpp:6806
int operator()(lua_State *L, int index, type expected, type actual, const std::string &message) const noexcept(false)
Definition: sol.hpp:6367
basic_table_core(T &&r) noexcept
Definition: sol.hpp:20199
void set_environment(const basic_environment< E > &env, const T &target)
Definition: sol.hpp:20691
base_walk newindexbaseclasspropogation
Definition: sol.hpp:18441
proxy & operator=(std::initializer_list< T > other)
Definition: sol.hpp:15560
static int clear(lua_State *L)
Definition: sol.hpp:17594
basic_reference(lua_nil_t) noexcept
Definition: sol.hpp:6796
static error_result get_it(std::false_type, lua_State *L, T &self, K &key)
Definition: sol.hpp:16936
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: sol.hpp:12421
static error_result set_associative_insert(std::false_type, lua_State *, T &self, iterator &it, K &key, stack_object)
Definition: sol.hpp:17020
static int push(lua_State *L, T &&ref)
Definition: sol.hpp:10662
stack_iterator & operator--()
Definition: sol.hpp:12025
lua_State * L
Definition: sol.hpp:5048
static error_result find_has(std::true_type, lua_State *L, T &self)
Definition: sol.hpp:17064
basic_protected_function(Proxy &&p, Handler &&eh)
Definition: sol.hpp:15286
static int call_assign(std::true_type, lua_State *L, V &&f)
Definition: sol.hpp:13279
static bool check(lua_State *, int, Handler &&, record &tracking)
Definition: sol.hpp:8375
int stack_index() const
Definition: sol.hpp:16086
result_type operator()(const argument_type &r) const
Definition: sol.hpp:1157
std::array< char, 2 > two
Definition: sol.hpp:16517
ref_clean(lua_State *luastate, int &n)
Definition: sol.hpp:20000
in_place_tag(&)(detail::in_place_of_i< I >) in_place_index_t
Definition: sol.hpp:3251
static int call(lua_State *L, lua_CFunction f)
Definition: sol.hpp:13318
int index
Definition: sol.hpp:15971
constexpr optional() noexcept
Definition: sol.hpp:3950
static int push(lua_State *L, const char16_t(&str)[N], std::size_t sz)
Definition: sol.hpp:11199
std::array< char, 2 > two
Definition: sol.hpp:16457
yielding_t< std::decay_t< F > > yielding(F &&f)
Definition: sol.hpp:4728
F value
Definition: sol.hpp:4598
void coroutine_create_guard(lua_State *L)
Definition: sol.hpp:7753
constexpr bool operator==(const optional< T > &x, const optional< T > &y)
Definition: sol.hpp:4052
optional & operator=(nullopt_t) noexcept
Definition: sol.hpp:3977
static table create_table(lua_State *L, int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:21676
std::size_t result_type
Definition: sol.hpp:1150
void handle_filter(static_stack_dependencies< I, In... >, lua_State *L, int &)
Definition: sol.hpp:13042
stack_count(int cnt)
Definition: sol.hpp:4846
constructor_match(T *o)
Definition: sol.hpp:13118
const unchecked_t unchecked
Definition: sol.hpp:4676
static int push(lua_State *L, const destructor_wrapper< Fx > &c)
Definition: sol.hpp:14885
reverse_iterator rbegin()
Definition: sol.hpp:12484
static int push(lua_State *L, const std::basic_string< char, Traits, Al > &str, std::size_t sz)
Definition: sol.hpp:10931
static bool check(lua_State *L, int index, type indextype, Handler &&handler, record &tracking)
Definition: sol.hpp:8619
static bool empty_start(lua_State *L, T &self)
Definition: sol.hpp:17342
static int push(lua_State *L, const wchar_t *wstr)
Definition: sol.hpp:10983
basic_table_core & traverse_raw_set(Keys &&... keys)
Definition: sol.hpp:20308
T type
Definition: sol.hpp:7676
bool valid() const noexcept
Definition: sol.hpp:15084
traits_type::args_list free_args_list
Definition: sol.hpp:12612
filter_wrapper(Fx &&fx, Args &&... args)
Definition: sol.hpp:4602
OPTIONAL_CONSTEXPR_INIT_LIST constexpr_optional_base(in_place_t, ::std::initializer_list< U > il, Args &&... args)
Definition: sol.hpp:3592
static int push(lua_State *L, yielding_t< T > &&f, Args &&... args)
Definition: sol.hpp:14651
object make_object(lua_State *L, T &&value)
Definition: sol.hpp:16230
push_popper_n< top_level > pop_n(lua_State *L, int x)
Definition: sol.hpp:6671
iterator end()
Definition: sol.hpp:12327
state(lua_CFunction panic=default_at_panic)
Definition: sol.hpp:21863
static int size(lua_State *L)
Definition: sol.hpp:16736
int operator()(lua_State *L)
Definition: sol.hpp:13920
static error_result add_copyable(std::false_type, lua_State *, T &, stack_object)
Definition: sol.hpp:17189
constexpr T * static_addressof(T &ref)
Definition: sol.hpp:3472
lua_bind_traits< F > traits_type
Definition: sol.hpp:13489
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:14041
static int clear(lua_State *L)
Definition: sol.hpp:17484
light(void *x)
Definition: sol.hpp:4881
static error_result insert_has(std::false_type, lua_State *L, T &self, stack_object where, stack_object value)
Definition: sol.hpp:17231
static int compare(const Char *lhs_p, std::size_t lhs_sz, const Char *rhs_p, std::size_t rhs_sz)
Definition: sol.hpp:1079
int top
Definition: sol.hpp:7118
lua_State * lua_state() const
Definition: sol.hpp:11962
meta::neg< meta::any< std::is_const< V >, std::is_const< std::remove_reference_t< iterator_return > >, meta::neg< is_copyable > > > is_writable
Definition: sol.hpp:16814
static int push(lua_State *L, const user< T > &u)
Definition: sol.hpp:10824
basic_object(lua_State *L, int index=-1) noexcept
Definition: sol.hpp:16187
this_environment()
Definition: sol.hpp:20705
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:13904
iterator begin()
Definition: sol.hpp:16016
bool is_stack(std::true_type) const
Definition: sol.hpp:15781
decltype(auto) pop(lua_State *L)
Definition: sol.hpp:8064
int comparsion_operator_wrap(lua_State *L)
Definition: sol.hpp:18178
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8628
static int push(lua_State *L, T *cont)
Definition: sol.hpp:18061
implicit_wrapper(T *item)
Definition: sol.hpp:4661
std::tuple< Functions... > functions
Definition: sol.hpp:8878
auto meta_registry_key(T &&key)
Definition: sol.hpp:4932
static void select_member_variable(std::true_type, lua_State *L, Fx &&fx, T &&obj, Args &&... args)
Definition: sol.hpp:14496
error_result()
Definition: sol.hpp:16677
static int push(lua_State *L, no_construction)
Definition: sol.hpp:14813
const char(& default_handler_name())[9]
Definition: sol.hpp:15054
static error_result add_insert(std::true_type, lua_State *, T &self, stack_object value, iterator &pos)
Definition: sol.hpp:17123
int no_panic(lua_State *, int, type, type, const char *=nullptr) noexcept
Definition: sol.hpp:6402
static int push(lua_State *L, const proxy< Table, Key > &p)
Definition: sol.hpp:15723
constexpr constexpr_optional_base() noexcept
Definition: sol.hpp:3571
basic_string_view< wchar_t > wstring_view
Definition: sol.hpp:1187
protected_function_result()=default
static int push(lua_State *L, property_wrapper< F, void > &&pw)
Definition: sol.hpp:14756
bool operator!=(const char *r) const
Definition: sol.hpp:1138
basic_protected_function(lua_State *L, absolute_index index)
Definition: sol.hpp:15318
basic_coroutine(const basic_function< base_t > &b, handler_t eh)
Definition: sol.hpp:21971
meta::any< is_destructor< meta::unqualified_t< Args >>... > has_destructor
Definition: sol.hpp:5809
optional_base(in_place_t, Args &&... args)
Definition: sol.hpp:3530
static void select_convertible(types< R(A...)> t, lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:14456
static R call(Fx &&fx, O &mem, Args &&... args)
Definition: sol.hpp:12720
static int push(lua_State *L, const T &value)
Definition: sol.hpp:10533
Definition: sol.hpp:11941
basic_table_core(detail::no_safety_tag, lua_State *L, ref_index index)
Definition: sol.hpp:20139
protected_function_result operator()(Args &&... args) const
Definition: sol.hpp:15351
std::array< char, 2 > two
Definition: sol.hpp:16322
proxy_t sp
Definition: sol.hpp:11984
basic_table_core(stack_reference &&r)
Definition: sol.hpp:20165
meta::boolean< has_traits_index_get_test< T >::value > has_traits_index_get
Definition: sol.hpp:16598
std::array< char, 1 > one
Definition: sol.hpp:16501
Definition: sol.hpp:16529
bad_optional_access(const char *what_arg)
Definition: sol.hpp:3506
Table tbl
Definition: sol.hpp:15529
T source
Definition: sol.hpp:5006
int push(lua_State *Ls) const noexcept
Definition: sol.hpp:6496
lua_bind_traits< function_type > traits_type
Definition: sol.hpp:14039
basic_protected_function(lua_State *L, absolute_index index, handler_t eh)
Definition: sol.hpp:15321
static int push(lua_State *L, factory_wrapper< Functions... > &&fw)
Definition: sol.hpp:14792
static int push(lua_State *L, user< T > &&u)
Definition: sol.hpp:10829
lua_State * lua_state() const noexcept
Definition: sol.hpp:5082
Definition: sol.hpp:12923
basic_function< base_t > force_cast(T &p)
Definition: sol.hpp:15096
constexpr optional(nullopt_t) noexcept
Definition: sol.hpp:3954
int push(lua_State *L) const noexcept
Definition: sol.hpp:15633
static void select_member_variable(std::true_type, lua_State *L, Fx &&fx, function_detail::class_indicator< C >)
Definition: sol.hpp:14502
static bool empty_has(std::true_type, lua_State *, T &self)
Definition: sol.hpp:17318
basic_table_core & new_simple_usertype(const std::string &name, Args &&... args)
Definition: sol.hpp:20352
meta::boolean< has_traits_next_test< T >::value > has_traits_next
Definition: sol.hpp:16610
basic_reference(lua_State *L, ref_index index) noexcept
Definition: sol.hpp:6867
::std::has_trivial_destructor< T > is_trivially_destructible
Definition: sol.hpp:3368
typename strip< T >::type strip_t
Definition: sol.hpp:7673
static bool check(types< Args... >, lua_State *, int, Handler &&, record &)
Definition: sol.hpp:7987
void for_each(std::false_type, Fx &&fx) const
Definition: sol.hpp:20037
static int call(lua_State *L, F &f)
Definition: sol.hpp:13553
R make_reference(lua_State *L, T &&value)
Definition: sol.hpp:16123
void * align_usertype_unique_tag(void *ptr)
Definition: sol.hpp:7238
basic_protected_function< stack_reference, true, reference > stack_aligned_safe_function
Definition: sol.hpp:313
Definition: sol.hpp:15968
void set_extra(std::false_type, std::index_sequence< I... >, T &&target)
Definition: sol.hpp:7068
static error_result at_category(std::random_access_iterator_tag, lua_State *L, T &self, std::ptrdiff_t pos)
Definition: sol.hpp:16863
int index
Definition: sol.hpp:12107
int top(lua_State *L)
Definition: sol.hpp:7743
readonly_wrapper(T v)
Definition: sol.hpp:12986
#define SOL_STACK_STRING_OPTIMIZATION_SIZE
Definition: sol.hpp:252
lua_bind_traits< function_type > traits_type
Definition: sol.hpp:14001
~push_popper_n()
Definition: sol.hpp:6625
static int push(lua_State *L, metatable_t, Key &&key, Args &&... args)
Definition: sol.hpp:10819
std::unique_ptr< T, D > actual_type
Definition: sol.hpp:4778
static int push(lua_State *L, Args &&... args)
Definition: sol.hpp:10381
basic_table_core(lua_State *L, ref_index index)
Definition: sol.hpp:20190
~stack_guard()
Definition: sol.hpp:7135
void set_panic(lua_CFunction panic)
Definition: sol.hpp:21499
error_code error
Definition: sol.hpp:8932
void set_extra(std::true_type, std::index_sequence< I... >, T &&target)
Definition: sol.hpp:7061
static int push(lua_State *L, const char16_t *u16str, std::size_t sz)
Definition: sol.hpp:11051
static int call(lua_State *L, F &fx, Args &&... args)
Definition: sol.hpp:13698
static error_result get_associative(std::true_type, lua_State *L, iterator &it)
Definition: sol.hpp:16877
static int push(lua_State *L, const char(&str)[N])
Definition: sol.hpp:10905
void stack_fail(int, int)
Definition: sol.hpp:7105
constexpr optional< typename ::std::decay< T >::type > make_optional(T &&v)
Definition: sol.hpp:4332
unsafe_function_result unsafe_script_file(const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:21377
meta::boolean< has_empty_test< T >::value > has_empty
Definition: sol.hpp:16577
static int push(lua_State *L, property_wrapper< F, G > &&pw)
Definition: sol.hpp:14746
protected_function_result safe_script(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:21306
Definition: sol.hpp:16454
auto operator=(U &&rhs) noexcept -> typename ::std::enable_if< ::std::is_same< typename ::std::decay< U >::type, optional< T &>>::value, optional &>::type
Definition: sol.hpp:3993
void usertype_unique_alloc_destroy(void *memory)
Definition: sol.hpp:7570
int default_exception_handler(lua_State *L, optional< const std::exception &>, string_view what)
Definition: sol.hpp:5840
static int call(std::index_sequence< In... >, lua_State *L, P &fx)
Definition: sol.hpp:13708
global_table::const_iterator const_iterator
Definition: sol.hpp:21116
const char(& default_exception_handler_name())[11]
Definition: sol.hpp:5834
lua_State * L
Definition: sol.hpp:12214
void initialize(::std::initializer_list< U > il, Args &&... args) noexcept(noexcept(T(il, ::std::forward< Args >(args)...)))
Definition: sol.hpp:3679
basic_coroutine(lua_State *L, ref_index index)
Definition: sol.hpp:22051
int index
Definition: sol.hpp:20785
static int call(lua_State *L, F &&f)
Definition: sol.hpp:13267
void * align_usertype_unique(void *ptr)
Definition: sol.hpp:7258
nested(Arg &&arg)
Definition: sol.hpp:5014
is_stack_based< target_t > is_stack
Definition: sol.hpp:15061
static int push(lua_State *L, const std::basic_string< Ch, Traits, Al > &wstr)
Definition: sol.hpp:11241
Definition: sol.hpp:16514
void make_length_op(Regs &l, int &index)
Definition: sol.hpp:18262
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:14201
protected_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
Definition: sol.hpp:15168
auto & pick(std::false_type, property_wrapper< R, W > &f)
Definition: sol.hpp:13101
std::ptrdiff_t difference_type
Definition: sol.hpp:11979
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8693
simple_usertype(lua_State *L, Args &&... args)
Definition: sol.hpp:19868
basic_protected_function(lua_State *L, raw_index index)
Definition: sol.hpp:15328
std::ptrdiff_t difference_type
Definition: sol.hpp:15978
Definition: sol.hpp:16696
factory_wrapper< Fs... > F
Definition: sol.hpp:13614
int static_trampoline(lua_State *L)
Definition: sol.hpp:5894
static iterator end(lua_State *, T &self)
Definition: sol.hpp:17686
in_place_tag(&)(detail::in_place_of_tag) in_place_t
Definition: sol.hpp:3247
container_traits< X > deferred_traits
Definition: sol.hpp:16781
error tagged_get(types< error >, int index_offset) const
Definition: sol.hpp:12250
T t
Definition: sol.hpp:6636
std::remove_pointer_t< meta::unwrap_unqualified_t< X > > T
Definition: sol.hpp:16698
std::pair< object, object > value_type
Definition: sol.hpp:19900
static int push(lua_State *L, destructor_wrapper< void >)
Definition: sol.hpp:14869
basic_lightuserdata(const stack_reference &r)
Definition: sol.hpp:15900
basic_table_core(lua_State *L, int index=-1)
Definition: sol.hpp:20183
static bool check(types<>, lua_State *, int, Handler &&, record &)
Definition: sol.hpp:7979
std::reverse_iterator< iterator > reverse_iterator
Definition: sol.hpp:15982
bool operator<(const stack_iterator &r) const
Definition: sol.hpp:12074
static error_result set_associative(std::false_type, iterator &it, stack_object value)
Definition: sol.hpp:16946
unsafe_function_result & operator=(unsafe_function_result &&o)
Definition: sol.hpp:12436
static error_result set_comparative(std::false_type, lua_State *, T &, stack_object, stack_object)
Definition: sol.hpp:17011
int top() const
Definition: sol.hpp:16095
~push_popper()
Definition: sol.hpp:6656
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8449
static void select(lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:14606
F fx
Definition: sol.hpp:18415
int stacktop
Definition: sol.hpp:15972
const auto no_constructor
Definition: sol.hpp:4500
std::function< void(int, int)> on_mismatch
Definition: sol.hpp:7119
std::remove_pointer_t< meta::unwrap_unqualified_t< container_decay_t< X > > > T
Definition: sol.hpp:16778
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8709
simple_usertype< Class > create_simple_usertype(constructors< CArgs... > ctor, Args &&... args)
Definition: sol.hpp:20384
bool operator!=(const basic_table_iterator &right) const
Definition: sol.hpp:19967
protected_function_result & operator=(const protected_function_result &)=default
basic_function(T &&r) noexcept
Definition: sol.hpp:14977
~load_result()
Definition: sol.hpp:20894
int multi_push(lua_State *L, T &&t, Args &&... args)
Definition: sol.hpp:7796
void type_assert(lua_State *L, int index, type expected, type actual) noexcept(false)
Definition: sol.hpp:6414
Definition: sol.hpp:21858
int stack_index() const noexcept
Definition: sol.hpp:6786
iter(T &source, iterator it)
Definition: sol.hpp:16823
property_wrapper(Rx &&r, Wx &&w)
Definition: sol.hpp:12935
protect_t< V > F
Definition: sol.hpp:13695
~unsafe_function_result()
Definition: sol.hpp:12525
unsafe_function_result(lua_State *Ls, int idx=-1, int retnum=0)
Definition: sol.hpp:12424
int push(lua_State *, lua_thread_state lts)
Definition: sol.hpp:21713
stack_reference(lua_State *L, raw_index i) noexcept
Definition: sol.hpp:6468
static_stack_dependencies<-1, 1 > self_dependency
Definition: sol.hpp:4564
int push(lua_State *L, const as_args_t< T > &e)
Definition: sol.hpp:15952
type get_type(difference_type index_offset=0) const noexcept
Definition: sol.hpp:12457
static int push_rvalue(std::false_type, lua_State *L, const C &cont)
Definition: sol.hpp:18044
void clear() noexcept
Definition: sol.hpp:3665
Definition: ItemStack.hpp:19
int index
Definition: sol.hpp:11982
clean(lua_State *luastate)
Definition: sol.hpp:19990
lua_State * lua_state() const noexcept
Definition: sol.hpp:5062
static bool empty_has(std::false_type, lua_State *L, T &self)
Definition: sol.hpp:17322
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986
lua_bind_traits< F > traits_type
Definition: sol.hpp:13396
T & value()
Definition: sol.hpp:3896
basic_function< stack_reference, false > stack_unsafe_function
Definition: sol.hpp:310
T::iterator iterator
Definition: sol.hpp:16785
static int push(lua_State *L, detail::tagged< T, constructor_list< Lists... >>)
Definition: sol.hpp:14825
int metatable_new_index(lua_State *L)
Definition: sol.hpp:18577
decltype(auto) get(Keys &&... keys) const
Definition: sol.hpp:20230
static constexpr bool is_lead_surrogate(char32_t u)
Definition: sol.hpp:8950
static error_result insert_lookup(std::false_type, lua_State *L, T &self, stack_object where, stack_object value)
Definition: sol.hpp:17198
destructor_wrapper(Function f)
Definition: sol.hpp:4536
static error_result set_writable(std::true_type, lua_State *, T &, iterator &it, stack_object value)
Definition: sol.hpp:16952
basic_environment(lua_State *L, new_table nt)
Definition: sol.hpp:20600
int c_trampoline(lua_State *L, lua_CFunction f)
Definition: sol.hpp:5977
static std::size_t size_start(lua_State *L, T &self)
Definition: sol.hpp:17334
int call_set_variable(std::true_type, lua_State *L, T &&mem)
Definition: sol.hpp:13798
lua_bind_traits< function_type > traits_type
Definition: sol.hpp:13961
constexpr optional(in_place_t, Args &&... args)
Definition: sol.hpp:3727
static int push(lua_State *L, cl_t cl)
Definition: sol.hpp:14839
static bool check(lua_State *, int, Handler &&, record &tracking)
Definition: sol.hpp:8366
protected_function_result safe_function_result
Definition: sol.hpp:332
bool operator!=(const std::basic_string< Char, Traits > &r) const
Definition: sol.hpp:1142
userdata_value(void *data)
Definition: sol.hpp:4863
auto unwrap(T &&item) -> decltype(std::forward< T >(item))
Definition: sol.hpp:1832
const int magic_index
Definition: sol.hpp:18383
basic_object & operator=(base_type &&b)
Definition: sol.hpp:16213
basic_protected_function(stack_reference &&r, handler_t eh)
Definition: sol.hpp:15273
static int index_set(lua_State *L)
Definition: sol.hpp:17446
static int real_call(lua_State *L) noexcept(false)
Definition: sol.hpp:14068
const char * unique_tag
Definition: sol.hpp:7163
static T * get_no_lua_nil_from(lua_State *L, void *udata, int index, record &)
Definition: sol.hpp:9933
~ref_clean()
Definition: sol.hpp:20003
basic_protected_function(const stack_reference &r, handler_t eh)
Definition: sol.hpp:15270
Definition: sol.hpp:13837
table create_table(int narr=0, int nrec=0)
Definition: sol.hpp:21657
static int call(lua_State *L, V &&f)
Definition: sol.hpp:13468
std::size_t len
Definition: sol.hpp:4572
bases base_classes_tag
Definition: sol.hpp:6201
static error_result get_start(lua_State *L, T &self, K &key)
Definition: sol.hpp:17326
static error_result get_comparative(std::true_type, lua_State *L, T &self, K &key)
Definition: sol.hpp:16920
nested< meta::unqualified_t< T > > as_nested(T &&container)
Definition: sol.hpp:5043
state_view & new_enum(const string_view &name, Args &&... args)
Definition: sol.hpp:21602
static error_result set_writable(std::false_type, lua_State *, T &, iterator &, stack_object)
Definition: sol.hpp:16956
int operator()(lua_State *L, int index, type expected, type actual, const std::string &message) const noexcept(false)
Definition: sol.hpp:6375
int overload_match(Match &&matchfx, lua_State *L, int start, Args &&... args)
Definition: sol.hpp:13200
T * user_allocate(lua_State *L)
Definition: sol.hpp:7502
returns_self_with returns_self
Definition: sol.hpp:4567
int construct_trampolined(lua_State *L)
Definition: sol.hpp:13212
basic_protected_function(stack_reference &&r)
Definition: sol.hpp:15267
iterator it
Definition: sol.hpp:16820
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101
decltype(auto) call(types< R >, types< Args... > ta, std::index_sequence< I... > tai, lua_State *L, int start, Fx &&fx, FxArgs &&... args)
Definition: sol.hpp:11783
L * value
Definition: sol.hpp:4873
int typed_static_trampoline_raw(std::true_type, lua_State *L)
Definition: sol.hpp:5983
int(* lua_CFunction_noexcept)(lua_State *L)
Definition: sol.hpp:4652
~push_popper()
Definition: sol.hpp:6641
stack_proxy * pointer
Definition: sol.hpp:15977
static int push(lua_State *L, T &&t)
Definition: sol.hpp:11278
static int call(lua_State *L, std::reference_wrapper< T > f)
Definition: sol.hpp:13356
static int get_size_hint(const std::forward_list< V, Al > &)
Definition: sol.hpp:7690
void type
Definition: sol.hpp:5649
static error_result add_copyable(std::false_type, lua_State *L, T &self, stack_object value, iterator &)
Definition: sol.hpp:17185
static int push(lua_State *L, const std::reference_wrapper< T > &t)
Definition: sol.hpp:10482
static int convertible_call(std::false_type, lua_State *L, Fx &&f, Args &&... args)
Definition: sol.hpp:13249
void abandon() noexcept
Definition: sol.hpp:12520
std::forward_list< T, Al > C
Definition: sol.hpp:9411
static int ipairs(lua_State *L)
Definition: sol.hpp:17666
probe probe_raw_get_field(lua_State *L, Key &&key, int tableindex)
Definition: sol.hpp:8104
call_status status() const noexcept
Definition: sol.hpp:12503
std::conditional_t< is_input_iterator::value, V, decltype(detail::deref_non_pointer(std::declval< captured_type >))) > push_type
Definition: sol.hpp:16810
static error_result erase_associative_lookup(std::true_type, lua_State *, T &self, const K &key)
Definition: sol.hpp:17266
Write write
Definition: sol.hpp:12932
state_view(lua_State *Ls)
Definition: sol.hpp:21118
Definition: sol.hpp:18525
Definition: sol.hpp:16469
int adl_default_to_string(std::false_type, lua_State *L)
Definition: sol.hpp:18156
const char * metakey
Definition: sol.hpp:18435
bool is_stack(std::false_type) const
Definition: sol.hpp:15786
const_iterator cend() const
Definition: sol.hpp:12480
auto as_function_reference(Args &&... args)
Definition: sol.hpp:4977
static int push(lua_State *L, const as_container_t< T > &as_cont)
Definition: sol.hpp:18048
unsafe_function_result operator()(Args &&... args) const
Definition: sol.hpp:15026
static int push(lua_State *L, no_metatable_t, const user< T > &u)
Definition: sol.hpp:10834
const Char * begin() const
Definition: sol.hpp:1090
basic_coroutine(stack_reference &&r, handler_t eh)
Definition: sol.hpp:21986
static void select_member_function(std::true_type, lua_State *L, Fx &&fx, T &&obj, Args &&... args)
Definition: sol.hpp:14549
Definition: sol.hpp:18125
constexpr optional() noexcept
Definition: sol.hpp:3689
basic_coroutine(lua_State *L, raw_index index)
Definition: sol.hpp:22041
constexpr nullopt_t nullopt
Definition: sol.hpp:3498
iterator end() const
Definition: sol.hpp:20217
int c_call(lua_State *L)
Definition: sol.hpp:13862
auto readonly(R T::*v)
Definition: sol.hpp:13000
map_t< std::string, object > function_map
Definition: sol.hpp:18432
error_code error
Definition: sol.hpp:8925
static void insert_at_end(std::true_type, types< V >, lua_State *L, T &arr, std::size_t)
Definition: sol.hpp:9272
static int push(lua_State *L, property_wrapper< void, F > &&pw)
Definition: sol.hpp:14766
int operator()(lua_State *L)
Definition: sol.hpp:13993
record()
Definition: sol.hpp:7646
void apply(std::index_sequence< I0, I1, I... >, lua_State *L, Keys &&keys, Value &&value, int tableindex)
Definition: sol.hpp:11613
unique_usertype_traits< T >::type P
Definition: sol.hpp:10437
load_result load_buffer(const char *buff, size_t size, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:21437
std::index_sequence_for< Filters... > indices
Definition: sol.hpp:4596
void(*)(void *) unique_destructor
Definition: sol.hpp:7159
static int push(lua_State *L, const char32_t *strb, const char32_t *stre)
Definition: sol.hpp:11169
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8654
struct sol::detail::no_safety_tag no_safety
basic_protected_function(T &&r) noexcept
Definition: sol.hpp:15238
push_popper(T x)
Definition: sol.hpp:6637
basic_coroutine(lua_State *L, int index=-1)
Definition: sol.hpp:22021
std::array< char, 2 > two
Definition: sol.hpp:16472
static int erase(lua_State *L)
Definition: sol.hpp:17598
traits_type::args_list free_args_list
Definition: sol.hpp:12632
constexpr optional(const optional &rhs) noexcept
Definition: sol.hpp:3964
basic_thread create()
Definition: sol.hpp:21836
sol::optional< T & > argument_type
Definition: sol.hpp:4357
void make_to_string_op(Regs &l, int &index)
Definition: sol.hpp:18210
bool operator>=(const stack_iterator &r) const
Definition: sol.hpp:12086
static iterator begin(lua_State *, T &self)
Definition: sol.hpp:17468
std::tuple< Functions... > overload_list
Definition: sol.hpp:14253
type get_type() const noexcept
Definition: sol.hpp:6980
user(U &&x)
Definition: sol.hpp:4902
int construct(lua_State *L)
Definition: sol.hpp:13232
auto make_user(T &&u)
Definition: sol.hpp:4917
const new_table create
Definition: sol.hpp:20012
int call_into_lua(types< void > tr, types< Args... > ta, lua_State *L, int start, Fx &&fx, FxArgs &&... fxargs)
Definition: sol.hpp:11846
static void construct(T &&obj, Args &&... args)
Definition: sol.hpp:4438
filter_wrapper< F, Filters... > P
Definition: sol.hpp:13705
static int push(lua_State *L, const char *strb, const char *stre)
Definition: sol.hpp:10867
void raw_get_field(lua_State *L, Key &&key, int tableindex)
Definition: sol.hpp:8084
static int call_assign(std::true_type, lua_State *L, V &&f)
Definition: sol.hpp:13408
int call_wrapped(lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:13729
has_clear< T > has_traits_clear
Definition: sol.hpp:16619
basic_function(const stack_reference &r)
Definition: sol.hpp:14991
int stack_index() const noexcept
Definition: sol.hpp:12365
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount) const
Definition: sol.hpp:14942
const_reverse_iterator rbegin() const
Definition: sol.hpp:12490
const target_t & target
Definition: sol.hpp:15062
static bool check(lua_State *, int, type, Handler &&, record &)
Definition: sol.hpp:8196
basic_environment(env_t, const basic_reference< b > &extraction_target)
Definition: sol.hpp:20621
std::decay_t< meta::unwrap_unqualified_t< Func > > function_type
Definition: sol.hpp:14141
Definition: sol.hpp:12620
constexpr bool operator>(const optional< T > &x, const optional< T > &y)
Definition: sol.hpp:4067
decltype(&inheritance< void >::type_cast) inheritance_cast_function
Definition: sol.hpp:6300
int push(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:7776
static int push_fx(lua_State *L, F &&f, T *obj)
Definition: sol.hpp:10391
static int push(lua_State *L, const protected_function_result &pfr)
Definition: sol.hpp:12389
constructor_list< Args... > F
Definition: sol.hpp:13510
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8204
int call_user(lua_State *L)
Definition: sol.hpp:13734
void rebind_base
Definition: sol.hpp:4780
void * value
Definition: sol.hpp:4852
static error_result set_start(lua_State *L, T &self, stack_object key, stack_object value)
Definition: sol.hpp:17330
static int next_iter(lua_State *L)
Definition: sol.hpp:17388
const char(& default_main_thread_name())[9]
Definition: sol.hpp:6569
static int call(lua_State *L, V &&f, object_type &o)
Definition: sol.hpp:13448
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:14000
static int insert(lua_State *L)
Definition: sol.hpp:16728
reverse_iterator rend()
Definition: sol.hpp:12346
object newindex
Definition: sol.hpp:18439
static int push_with(lua_State *L, Key &&name, Args &&... args)
Definition: sol.hpp:10789
static int push(lua_State *L, overload_set< Functions... > &&set)
Definition: sol.hpp:14710
protected_function_result do_file(const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:21274
constexpr optional(nullopt_t) noexcept
Definition: sol.hpp:3691
void invoke(types< void >, std::index_sequence< I >, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
Definition: sol.hpp:15163
lua_bind_traits< function_type > traits_type
Definition: sol.hpp:13928
meta_function
Definition: sol.hpp:5277
basic_thread(lua_State *L, ref_index index)
Definition: sol.hpp:21782
Ret invoke(types< Ret >, std::index_sequence< I >, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
Definition: sol.hpp:15157
type type_of(lua_State *L, int index)
Definition: sol.hpp:5358
static int call(lua_State *L)
Definition: sol.hpp:13943
void register_main_thread(lua_State *L)
Definition: sol.hpp:20908
static iterator end(lua_State *L, T &)
Definition: sol.hpp:16769
basic_string_view< char > string_view
Definition: sol.hpp:1186
state_view & new_simple_usertype(const std::string &name, constructors< CArgs... > ctor, Args &&... args)
Definition: sol.hpp:21581
int registry_index() const noexcept
Definition: sol.hpp:6451
std::array< char, 2 > two
Definition: sol.hpp:16562
Definition: sol.hpp:16304
call_syntax get_call_syntax(lua_State *L, const string_view &key, int index)
Definition: sol.hpp:11877
stack_reference(lua_State *L, lua_nil_t) noexcept
Definition: sol.hpp:6459
void operator()(T *p) const
Definition: sol.hpp:4465
int default_traceback_error_handler(lua_State *L)
Definition: sol.hpp:20944
static int erase(lua_State *L)
Definition: sol.hpp:17490
basic_table_core(lua_State *L, const new_table &nt)
Definition: sol.hpp:20177
static void set_default_handler(lua_State *L, const T &ref)
Definition: sol.hpp:15111
int map_hint
Definition: sol.hpp:5089
int sequence_hint
Definition: sol.hpp:5088
static void * type_cast(void *voiddata, const std::string &ti)
Definition: sol.hpp:6259
static int push(lua_State *L, nullopt_t)
Definition: sol.hpp:11288
static constexpr char32_t replacement
Definition: sol.hpp:8995
std::array< char, 1 > one
Definition: sol.hpp:16456
int operator()(lua_State *L)
Definition: sol.hpp:14159
~state()
Definition: sol.hpp:21884
static int erase(lua_State *L)
Definition: sol.hpp:16748
object key_type
Definition: sol.hpp:19898
basic_reference(stack_reference &&r) noexcept
Definition: sol.hpp:6802
reverse_iterator rbegin()
Definition: sol.hpp:16035
basic_string_view< char16_t > u16string_view
Definition: sol.hpp:1188
static int add(lua_State *L)
Definition: sol.hpp:17450
static int call_const(std::false_type, lua_State *L, Args &&... args)
Definition: sol.hpp:13293
lua_State * L
Definition: sol.hpp:12106
T source
Definition: sol.hpp:16253
lua_State * L
Definition: sol.hpp:7117
void set_field(lua_State *L, Key &&key, Value &&value, int tableindex)
Definition: sol.hpp:8114
proxy< global_table &, T > operator[](T &&key)
Definition: sol.hpp:21619
lua_State * L
Definition: sol.hpp:12408
constexpr bool operator>=(const optional< T > &x, const optional< T > &y)
Definition: sol.hpp:4077
int popcount
Definition: sol.hpp:20787
meta::function_return_t< function_type > return_type
Definition: sol.hpp:14173
virtual const char * what() const noexcept override
Definition: sol.hpp:438
static constexpr int sequence_length(unsigned char b)
Definition: sol.hpp:8972
table_core< true > global_table
Definition: sol.hpp:292
const Char * p
Definition: sol.hpp:1067
int push_environment_of(lua_State *L, int index=-1)
Definition: sol.hpp:10337
map_t< std::string, std::unique_ptr< variable_wrapper > > variable_map
Definition: sol.hpp:18431
constexpr optional(in_place_t, T &v) noexcept
Definition: sol.hpp:3968
decltype(auto) unchecked_get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:7704
lua_State * operator->() const noexcept
Definition: sol.hpp:21705
static int push(lua_State *L, no_construction c, function_detail::call_indicator)
Definition: sol.hpp:14818
static void select_member_function(std::true_type, lua_State *L, Fx &&fx, function_detail::class_indicator< C >)
Definition: sol.hpp:14555
typename container_decay< meta::unqualified_t< T >>::type container_decay_t
Definition: sol.hpp:16650
luaL_Reg make_reg(N &&n, lua_CFunction f)
Definition: sol.hpp:18520
Definition: sol.hpp:13106
decltype(auto) get(Keys &&... keys) const
Definition: sol.hpp:21508
static int push(lua_State *L, T &&obj)
Definition: sol.hpp:10414
function_type fx
Definition: sol.hpp:14142
basic_coroutine(lua_State *L, T &&r)
Definition: sol.hpp:22004
void get_field(lua_State *L, Key &&key, int tableindex)
Definition: sol.hpp:8074
member_variable(function_type v, Args &&... args)
Definition: sol.hpp:14209
int t
Definition: sol.hpp:6617
meta::boolean< has_traits_add_test< T >::value > has_traits_add
Definition: sol.hpp:16613
load_mode
Definition: sol.hpp:5138
basic_coroutine(basic_function< base_t > &&b)
Definition: sol.hpp:21968
void luajit_exception_handler(lua_State *L, int(*handler)(lua_State *, lua_CFunction)=detail::c_trampoline)
Definition: sol.hpp:11903
static void select_function(std::true_type, lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:14581
static int find(std::false_type, lua_State *L)
Definition: sol.hpp:17574
raw_index(int i)
Definition: sol.hpp:4812
constexpr auto resolve_f(std::true_type, F &&f) -> decltype(resolve_i(types< meta::function_signature_t< decltype(&U::operator())>>(), std::forward< F >(f)))
Definition: sol.hpp:14297
void remove(lua_State *L, int rawindex, int count)
Definition: sol.hpp:6576
static error_result add_insert_after(std::false_type, lua_State *, T &, stack_object)
Definition: sol.hpp:17104
constexpr in_place_tag in_place_index(detail::in_place_of_i< I >)
Definition: sol.hpp:3243
stack_guard(lua_State *L)
Definition: sol.hpp:7121
value_type * iterator
Definition: sol.hpp:17536
bool operator==(const stack_iterator &r) const
Definition: sol.hpp:12060
constexpr T && constexpr_forward(typename ::std::remove_reference< T >::type &t) noexcept
Definition: sol.hpp:3432
int user_alloc_destruct(lua_State *L)
Definition: sol.hpp:7560
iterator begin() const
Definition: sol.hpp:21453
static error_result add_insert_after(std::true_type, lua_State *L, T &self, stack_object value)
Definition: sol.hpp:17113
result_type operator()(const std::basic_string< Ch, Tr, Al > &r) const
Definition: sol.hpp:1153
meta::bind_traits< function_type > traits_type
Definition: sol.hpp:13902
Definition: sol.hpp:13740
Definition: sol.hpp:16559
static iterator begin(lua_State *, T &self)
Definition: sol.hpp:17682
constructor_wrapper< Cxs... > F
Definition: sol.hpp:13533
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:14066
unsafe_function_result unsafe_script_file(const std::string &filename, const basic_environment< E > &env, load_mode mode=load_mode::any)
Definition: sol.hpp:21363
lua_State * L
Definition: sol.hpp:15970
basic_coroutine(const stack_reference &r, handler_t eh)
Definition: sol.hpp:21983
Definition: sol.hpp:15767
void operator()(T &&obj, Args &&... args) const
Definition: sol.hpp:4445
stack_proxy operator[](difference_type index_offset) const
Definition: sol.hpp:12461
constexpr T & operator*() const
Definition: sol.hpp:4022
unsafe_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n) const
Definition: sol.hpp:14963
int construct_match(Match &&matchfx, lua_State *L, int fxarity, int start, Args &&... args)
Definition: sol.hpp:13206
T * operator->()
Definition: sol.hpp:3871
std::tuple< Upvalues... > upvalues
Definition: sol.hpp:4940
unique_usertype_traits< X >::type T
Definition: sol.hpp:8652
std::conditional_t< is_matched_lookup::value, std::pair< value_type, value_type >, std::conditional_t< is_associative::value||is_lookup::value, value_type, std::pair< std::ptrdiff_t, value_type > > > KV
Definition: sol.hpp:16793
base_walk indexbaseclasspropogation
Definition: sol.hpp:18440
std::array< char, 2 > two
Definition: sol.hpp:16442
static int find(std::true_type, lua_State *L)
Definition: sol.hpp:17561
bool operator<=(const stack_iterator &r) const
Definition: sol.hpp:12082
state_view & new_usertype(const std::string &name, constructors< CArgs... > ctor, Args &&... args)
Definition: sol.hpp:21563
meta::boolean< has_traits_get_test< T >::value > has_traits_get
Definition: sol.hpp:16589
static int push(lua_State *L, Args &&... args)
Definition: sol.hpp:10422
int push(lua_State *L, const as_returns_t< T > &e)
Definition: sol.hpp:22124
basic_table_core & set_usertype(Key &&key, usertype< T > &user)
Definition: sol.hpp:20327
const auto default_constructor
Definition: sol.hpp:4497
int call_wrapper_entry(lua_State *L) noexcept(meta::bind_traits< F >::is_noexcept)
Definition: sol.hpp:13832
stack_iterator & operator+=(difference_type idx)
Definition: sol.hpp:12036
light(L *x)
Definition: sol.hpp:4878
void pop(lua_State *Ls, int n=1) const noexcept
Definition: sol.hpp:6512
pointer operator->() const
Definition: sol.hpp:12009
static int push(lua_State *L, char16_t c)
Definition: sol.hpp:11225
bool operator==(const std::basic_string< Char, Traits > &r) const
Definition: sol.hpp:1130
void set_resolved_function(Key &&key, Args &&... args)
Definition: sol.hpp:20492
static std::ptrdiff_t index_adjustment(lua_State *, T &)
Definition: sol.hpp:17505
static void push_back_at_end(std::true_type, types< V >, lua_State *L, T &arr, std::size_t)
Definition: sol.hpp:9262
~basic_reference() noexcept
Definition: sol.hpp:6876
int copy() const noexcept
Definition: sol.hpp:6721
T::value_type value_type
Definition: sol.hpp:16786
decltype(auto) traverse_get(Keys &&... keys) const
Definition: sol.hpp:20256
yielding_t(Arg &&arg)
Definition: sol.hpp:4718
static error_result set_associative_find(std::false_type, lua_State *L, T &self, stack_object key, stack_object value)
Definition: sol.hpp:17034
constexpr result_type operator()(argument_type const &arg) const
Definition: sol.hpp:4359
constexpr Sig C::* resolve_v(std::false_type, Sig C::*mem_func_ptr)
Definition: sol.hpp:14319
static int self_call(std::false_type, lua_State *L, F &&f)
Definition: sol.hpp:13647
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)
Definition: sol.hpp:21302
state_view & set_usertype(usertype< T > &user)
Definition: sol.hpp:21540
int count
Definition: sol.hpp:4844
static int push(lua_State *L, light< T > l)
Definition: sol.hpp:10780
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: sol.hpp:15983
std::integral_constant< bool, !std::is_void< R >::value > can_read
Definition: sol.hpp:12927
state_view & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:21629
int runtime_new_index(lua_State *L, void *, usertype_metatable_core &, int runtimetarget)
Definition: sol.hpp:18673
basic_table_core & raw_set(Args &&... args)
Definition: sol.hpp:20316
int target
Definition: sol.hpp:4570
constexpr constexpr_optional_base(in_place_t, Args &&... args)
Definition: sol.hpp:3586
basic_reference(lua_State *L, int index=-1) noexcept
Definition: sol.hpp:6861
unsafe_function_result unsafe_script(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:21354
decltype(auto) tagged_unqualified_get(types< T >, lua_State *L, int index, record &tracking)
Definition: sol.hpp:7959
std::remove_extent_t< T > value_type
Definition: sol.hpp:17535
constexpr auto resolve(R fun_ptr(Args...)) -> R(*)(Args...)
Definition: sol.hpp:14330
proxy & set_function(Args &&... args)
Definition: sol.hpp:15544
static int push(lua_State *L, Arg &&arg)
Definition: sol.hpp:10441
std::array< char, 2 > two
Definition: sol.hpp:16337
Definition: sol.hpp:15752
std::size_t aligned_space_for(void *alignment=nullptr)
Definition: sol.hpp:7189
main_table_core< false > main_table
Definition: sol.hpp:293
void pop() const noexcept
Definition: sol.hpp:6953
wrap::object_type object_type
Definition: sol.hpp:13491
static table create_table_with(lua_State *L, Args &&... args)
Definition: sol.hpp:21681
protected_function_result script_pass_on_error(lua_State *, protected_function_result result)
Definition: sol.hpp:20980
static int push(lua_State *L, const factory_wrapper< Functions... > &set, function_detail::call_indicator)
Definition: sol.hpp:14798
int call(lua_State *L)
Definition: sol.hpp:14183
lua_State * L
Definition: sol.hpp:21693
basic_string_view(const std::string &r)
Definition: sol.hpp:1069
static error_result add_push_back(std::false_type, lua_State *L, T &self, stack_object value)
Definition: sol.hpp:17155
meta::boolean< has_erase_test< T >::value > has_erase
Definition: sol.hpp:16583
lua_CFunction c_function
Definition: sol.hpp:4939
this_environment(environment e)
Definition: sol.hpp:20708
static int at(lua_State *L)
Definition: sol.hpp:17610
const std::string & short_demangle()
Definition: sol.hpp:6152
#define OPTIONAL_MUTABLE_CONSTEXPR
Definition: sol.hpp:3347
static int call(lua_State *, const bases< Args... > &)
Definition: sol.hpp:13348
std::array< const char *, 4 > args
Definition: sol.hpp:16675
const int filler_index
Definition: sol.hpp:18382
type get_type(difference_type index_offset=0) const noexcept
Definition: sol.hpp:12316
static int push(lua_State *L, const P &p)
Definition: sol.hpp:14917
static int push(lua_State *L, const char32_t(&str)[N], std::size_t sz)
Definition: sol.hpp:11210
void for_each(std::true_type, Fx &&fx) const
Definition: sol.hpp:20024
static bool type_unique_cast_bases(void *source_data, void *target_data, const string_view &ti)
Definition: sol.hpp:6270
T type
Definition: sol.hpp:4736
T & source
Definition: sol.hpp:16819
Definition: sol.hpp:11105
static void select_function(std::false_type, lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:14576
static int call_const(std::true_type, lua_State *L, Args &&...)
Definition: sol.hpp:13299
static int push(lua_State *L, wchar_t c)
Definition: sol.hpp:11217
std::array< char, 1 > one
Definition: sol.hpp:16471
const Char * cend() const
Definition: sol.hpp:1102
proxy_t value_type
Definition: sol.hpp:11978
T type
Definition: sol.hpp:16646
Definition: sol.hpp:12570
static int push(lua_State *L, const wchar_t(&str)[N])
Definition: sol.hpp:11184
static void walk_single_base(lua_State *L, bool &found, int &ret, string_view &)
Definition: sol.hpp:18681
protected_function_result safe_script_file(const std::string &filename, const basic_environment< E > &env, Fx &&on_error, load_mode mode=load_mode::any)
Definition: sol.hpp:21320
push_popper(T)
Definition: sol.hpp:6647
void open_libraries(Args &&... args)
Definition: sol.hpp:21131
Definition: sol.hpp:14065
basic_thread(T &&r)
Definition: sol.hpp:21752
void pop(lua_State *Ls, int n=1) const noexcept
Definition: sol.hpp:6957
proxy & force()
Definition: sol.hpp:15652
meta::is_lookup< T > is_lookup
Definition: sol.hpp:16783
static error_result erase_after_has(std::false_type, lua_State *, T &, const K &)
Definition: sol.hpp:17290
static void select_member_variable(std::false_type, lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:14491
basic_thread(const stack_reference &r)
Definition: sol.hpp:21760
static bool check(lua_State *, int, Handler &&, record &tracking)
Definition: sol.hpp:8348
static int push(lua_State *L, const wchar_t *wstr, std::size_t sz)
Definition: sol.hpp:10987
int push(lua_State *L)
Definition: sol.hpp:19853
Real * usertype_unique_allocate(lua_State *L, T **&pref, unique_destructor *&dx, unique_tag *&id)
Definition: sol.hpp:7413
lua_State * L
Definition: sol.hpp:11981
~basic_table_iterator()
Definition: sol.hpp:19971
basic_protected_function(basic_function< base_t > &&b)
Definition: sol.hpp:15255
int stacktop
Definition: sol.hpp:11983
const metatable_t metatable_key
Definition: sol.hpp:4700
int call(types< Fx >, index_value< I >, types< R... >, types< Args... >, lua_State *L, int, int)
Definition: sol.hpp:14266
bool is() const
Definition: sol.hpp:15813
thread_status
Definition: sol.hpp:5155
const Char * data() const
Definition: sol.hpp:1106
const_iterator begin() const
Definition: sol.hpp:12330
basic_table_core(lua_nil_t r) noexcept
Definition: sol.hpp:20209
int SOL_INTERNAL_UNSPECIALIZED_MARKER_
Definition: sol.hpp:5638
const_reference operator*() const
Definition: sol.hpp:19959
std::pair< object, object > kvp
Definition: sol.hpp:19908
static int next_associative(std::false_type, lua_State *L)
Definition: sol.hpp:17372
basic_protected_function(lua_State *L, ref_index index, handler_t eh)
Definition: sol.hpp:15341
static int push(lua_State *L, const factory_wrapper< Functions... > &fw)
Definition: sol.hpp:14786
Definition: sol.hpp:13900
lua_bind_traits< function_type > traits_type
Definition: sol.hpp:14101
call_status status() const noexcept
Definition: sol.hpp:12303
meta::is_associative< T > is_associative
Definition: sol.hpp:16782
int index
Definition: sol.hpp:4811
int push_environment_of(const T &target)
Definition: sol.hpp:10353
lua_State * lua_state() const noexcept
Definition: sol.hpp:20887
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)
Definition: sol.hpp:21338
lua_nil_t value_type
Definition: sol.hpp:16702
static int pairs(lua_State *L)
Definition: sol.hpp:17513
static void clear_has(std::false_type, lua_State *L, T &)
Definition: sol.hpp:17314
static int push(lua_State *L, const T &tablecont)
Definition: sol.hpp:10614
std::array< char, 1 > one
Definition: sol.hpp:16411
void pop() const noexcept
Definition: sol.hpp:6508
Definition: sol.hpp:16379
wrapper< meta::unqualified_t< F > > wrap
Definition: sol.hpp:13397
static error_result set_associative_insert(std::true_type, lua_State *, T &self, iterator &it, K &key, stack_object value)
Definition: sol.hpp:17015
int index
Definition: sol.hpp:12409
bool success
Definition: sol.hpp:7630
basic_table_iterator operator++(int)
Definition: sol.hpp:19949
is_stack_based< handler_t > is_stack_handler
Definition: sol.hpp:15133
reference operator[](difference_type idx) const
Definition: sol.hpp:12056
meta::boolean< has_traits_find_test< T >::value > has_traits_find
Definition: sol.hpp:16625
iterator end() const
Definition: sol.hpp:21457
static error_result set_it(std::false_type, lua_State *L, T &self, stack_object key, stack_object value)
Definition: sol.hpp:17042
static constexpr std::size_t size()
Definition: sol.hpp:468
basic_function< stack_reference, true > stack_aligned_unsafe_function
Definition: sol.hpp:312
std::array< char, 1 > one
Definition: sol.hpp:16531
static R apply(std::index_sequence< I, Ix... >, lua_State *L, int index, record &tracking, Args &&... args)
Definition: sol.hpp:10030
static int index_get(lua_State *L)
Definition: sol.hpp:17432
int operator()(lua_State *L, int index, type expected, type actual, const char *message) const noexcept(false)
Definition: sol.hpp:6356
void traverse_set_deep(Key &&key, Value &&value) const
Definition: sol.hpp:20118
void modify_unique_usertype_as(const stack_reference &obj, F &&f)
Definition: sol.hpp:8129
overload_list overloads
Definition: sol.hpp:14255
std::unique_ptr< T, Dx > make_unique_deleter(Args &&... args)
Definition: sol.hpp:4477
protected_function_result & operator=(protected_function_result &&o) noexcept
Definition: sol.hpp:12285
std::array< char, 1 > one
Definition: sol.hpp:16441
static int push_lvalue(std::false_type, lua_State *L, const C &cont)
Definition: sol.hpp:18034
static std::ptrdiff_t index_adjustment(lua_State *, T &)
Definition: sol.hpp:17674
void make_reg_op(Regs &l, int &index, const char *name)
Definition: sol.hpp:18198
basic_table_core & set_usertype(usertype< T > &user)
Definition: sol.hpp:20322
std::is_same< iterator_category, std::input_iterator_tag > is_input_iterator
Definition: sol.hpp:16806
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8540
table create_table(Name &&name, int narr=0, int nrec=0)
Definition: sol.hpp:21641
push_popper< top_level, T > push_pop(T &&x)
Definition: sol.hpp:6661
fx_t::args_list args_lists
Definition: sol.hpp:15457
int c_call_raw(std::false_type, lua_State *L)
Definition: sol.hpp:13851
object require_core(const std::string &key, Fx &&action, bool create_global=true)
Definition: sol.hpp:21102
lua_nil_t iterator
Definition: sol.hpp:16701
const char * make_chunk_name(const string_view &code, const std::string &chunkname, char(&basechunkname)[N])
Definition: sol.hpp:11716
constexpr optional(T &&v)
Definition: sol.hpp:3722
It next
Definition: sol.hpp:8927
Definition: sol.hpp:16334
static int push(lua_State *L, const void *userdata)
Definition: sol.hpp:10764
static const std::string & user_gc_metatable()
Definition: sol.hpp:6181
std::array< char, 2 > two
Definition: sol.hpp:16427
int last
Definition: sol.hpp:7643
static void push_back_at_end(std::false_type, types< V > t, lua_State *L, T &arr, std::size_t idx)
Definition: sol.hpp:9267
int stack_clear()
Definition: sol.hpp:21485
constexpr const T * dataptr() const
Definition: sol.hpp:3633
const std::string & demangle()
Definition: sol.hpp:6146
const int index_function_index
Definition: sol.hpp:18386
basic_function(lua_nil_t n)
Definition: sol.hpp:14997
basic_object & operator=(const base_type &b)
Definition: sol.hpp:16209
basic_protected_function(const proxy_base< Super > &p)
Definition: sol.hpp:15278
type get_type() const noexcept
Definition: sol.hpp:6525
auto protect(T &&value)
Definition: sol.hpp:12911
stack_table_core< false > stack_table
Definition: sol.hpp:295
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8398
int fail_on_newindex(lua_State *L)
Definition: sol.hpp:20007
void emplace(::std::initializer_list< U > il, Args &&... args)
Definition: sol.hpp:3786
int operator()(lua_State *L, int index, type expected, type actual, const std::string &message) const noexcept(false)
Definition: sol.hpp:6359
std::make_index_sequence< sizeof...(Functions)> indices
Definition: sol.hpp:14254
size_t size() const
Definition: sol.hpp:20430
protect_t(Arg &&arg, Args &&... args)
Definition: sol.hpp:12900
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:14003
static int push(lua_State *L, const destructor_wrapper< Fx > &c)
Definition: sol.hpp:14904
basic_userdata(lua_State *L, T &&r)
Definition: sol.hpp:15853
static int call(lua_State *L, Fx &&f, Args &&... args)
Definition: sol.hpp:13257
std::conditional_t< is_index, R, W > P
Definition: sol.hpp:13631
table create_table_with(Args &&... args)
Definition: sol.hpp:21667
Definition: sol.hpp:20782
error(const std::string &str)
Definition: sol.hpp:420
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:14172
push_popper_at(lua_State *luastate, int index=-1, int count=1)
Definition: sol.hpp:6606
wrapper< meta::unqualified_t< F > > wrap
Definition: sol.hpp:13490
static int next(lua_State *L)
Definition: sol.hpp:16752
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:8222
static bool type_check_bases(types< Base, Args... >, const std::string &ti)
Definition: sol.hpp:6241
std::ptrdiff_t idx
Definition: sol.hpp:19912
static int call(lua_State *L, F &&f)
Definition: sol.hpp:13723
static void set_default_handler(const T &ref)
Definition: sol.hpp:15140
static void select_convertible(types<>, lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:14464
yielding_t(Arg0 &&arg0, Arg1 &&arg1, Args &&... args)
Definition: sol.hpp:4722
decltype(auto) check_get(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:7907
lua_bind_traits< std::remove_pointer_t< meta::unqualified_t< F > > > traits_type
Definition: sol.hpp:12630
bool runnable() const noexcept
Definition: sol.hpp:22072
static error_result get_category(std::random_access_iterator_tag, lua_State *L, T &self, K &key)
Definition: sol.hpp:16906
int levels
Definition: sol.hpp:7631
static int call(lua_State *L, F &fx)
Definition: sol.hpp:13624
container_traits< X > deferred_traits
Definition: sol.hpp:17532
stack_dependencies(int stack_target, Args &&... args)
Definition: sol.hpp:4575
optional< error > tagged_get(types< optional< error >>, int index_offset) const
Definition: sol.hpp:12242
unsafe_function function
Definition: sol.hpp:323
auto as_container(T &&value)
Definition: sol.hpp:16282
new_table(int sequence_hint, int map_hint=0)
Definition: sol.hpp:5097
basic_userdata(const stack_reference &r)
Definition: sol.hpp:15846
std::tuple< Filters... > filters
Definition: sol.hpp:4599
basic_thread(lua_State *L, T &&r)
Definition: sol.hpp:21767
static int call(lua_State *L, Fx &&f)
Definition: sol.hpp:13378
bool unqualified_check(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:7850