// sol2 // The MIT License (MIT) // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // the Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SOL_TYPES_HPP #define SOL_TYPES_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if SOL_IS_ON(SOL_STD_VARIANT) #include #endif // variant shenanigans (thanks, Mac OSX) namespace sol { namespace d { // shortest possible hidden detail namespace // when types are transcribed, this saves // quite a bit of space, actually. // it's a little unfortunate, but here we are? template struct u { }; } // namespace d namespace detail { #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE) typedef int (*lua_CFunction_noexcept)(lua_State* L) noexcept; #else typedef int (*lua_CFunction_noexcept)(lua_State* L); #endif // noexcept function type for lua_CFunction template struct implicit_wrapper { T& value; implicit_wrapper(T* value_) : value(*value_) { } implicit_wrapper(T& value_) : value(value_) { } operator T&() { return value; } operator T*() { return std::addressof(value); } }; struct yield_tag_t { }; inline constexpr yield_tag_t yield_tag {}; } // namespace detail struct lua_nil_t { }; inline constexpr lua_nil_t lua_nil {}; inline bool operator==(lua_nil_t, lua_nil_t) { return true; } inline bool operator!=(lua_nil_t, lua_nil_t) { return false; } #if SOL_IS_ON(SOL_NIL) using nil_t = lua_nil_t; inline constexpr const nil_t& nil = lua_nil; #endif namespace detail { struct non_lua_nil_t { }; } // namespace detail struct metatable_key_t { }; inline constexpr metatable_key_t metatable_key {}; struct global_tag_t { } inline constexpr global_tag {}; struct env_key_t { }; inline constexpr env_key_t env_key {}; struct no_metatable_t { }; inline constexpr no_metatable_t no_metatable {}; template struct yielding_t { T func; yielding_t() = default; yielding_t(const yielding_t&) = default; yielding_t(yielding_t&&) = default; yielding_t& operator=(const yielding_t&) = default; yielding_t& operator=(yielding_t&&) = default; template , yielding_t>>, meta::neg>>> = meta::enabler> yielding_t(Arg&& arg) : func(std::forward(arg)) { } template yielding_t(Arg0&& arg0, Arg1&& arg1, Args&&... args) : func(std::forward(arg0), std::forward(arg1), std::forward(args)...) { } }; template inline yielding_t> yielding(F&& f) { return yielding_t>(std::forward(f)); } typedef std::remove_pointer_t lua_CFunction_ref; template struct non_null { }; template struct function_sig { }; struct upvalue_index { int index; upvalue_index(int idx) : index(lua_upvalueindex(idx)) { } operator int() const { return index; } }; struct raw_index { int index; raw_index(int i) : index(i) { } operator int() const { return index; } }; struct absolute_index { int index; absolute_index(lua_State* L, int idx) : index(lua_absindex(L, idx)) { } operator int() const { return index; } }; struct ref_index { int index; ref_index(int idx) : index(idx) { } operator int() const { return index; } }; struct stack_count { int count; stack_count(int cnt) : count(cnt) { } }; struct lightuserdata_value { void* value; lightuserdata_value(void* data) : value(data) { } operator void*() const { return value; } }; struct userdata_value { private: void* m_value; public: userdata_value(void* data) : m_value(data) { } void* value() const { return m_value; } operator void*() const { return value(); } }; template struct light { private: static_assert(!std::is_void_v, "the type for light will never be void"); T* m_value; public: light(T& x) : m_value(std::addressof(x)) { } light(T* x) : m_value(x) { } explicit light(void* x) : m_value(static_cast(x)) { } T* value() const { return m_value; } operator T*() const { return m_value; } operator T&() const { return *m_value; } void* void_value() const { return m_value; } }; template auto make_light(T& l) { typedef meta::unwrapped_t>> L; return light(l); } template struct user : private detail::ebco { private: using base_t = detail::ebco; public: using base_t::base_t; using base_t::value; operator std::add_pointer_t>() { return std::addressof(this->base_t::value()); } operator std::add_pointer_t>>() const { return std::addressof(this->base_t::value()); } operator std::add_lvalue_reference_t() { return this->base_t::value(); } operator std::add_const_t>&() const { return this->base_t::value(); } }; template auto make_user(T&& u) { typedef meta::unwrapped_t> U; return user(std::forward(u)); } template struct metatable_registry_key : private detail::ebco { private: using base_t = detail::ebco; public: using base_t::base_t; using base_t::value; }; template auto meta_registry_key(T&& key) { typedef meta::unqualified_t K; return metatable_registry_key(std::forward(key)); } template struct closure { lua_CFunction c_function; std::tuple upvalues; closure(lua_CFunction f, Upvalues... targetupvalues) : c_function(f), upvalues(std::forward(targetupvalues)...) { } }; template <> struct closure<> { lua_CFunction c_function; int upvalues; closure(lua_CFunction f, int upvalue_count = 0) : c_function(f), upvalues(upvalue_count) { } }; typedef closure<> c_closure; template closure make_closure(lua_CFunction f, Args&&... args) { return closure(f, std::forward(args)...); } template struct function_arguments { std::tuple arguments; template , function_arguments>> = meta::enabler> function_arguments(Arg&& arg, Args&&... args) : arguments(std::forward(arg), std::forward(args)...) { } }; template , typename... Args> auto as_function(Args&&... args) { return function_arguments...>(std::forward(args)...); } template , typename... Args> auto as_function_reference(Args&&... args) { return function_arguments(std::forward(args)...); } template struct as_table_t : private detail::ebco { private: using base_t = detail::ebco; public: as_table_t() = default; as_table_t(const as_table_t&) = default; as_table_t(as_table_t&&) = default; as_table_t& operator=(const as_table_t&) = default; as_table_t& operator=(as_table_t&&) = default; as_table_t(const meta::unqualified_t& obj) noexcept(std::is_nothrow_constructible_v&>) : base_t(obj) { } as_table_t(meta::unqualified_t&& obj) noexcept(std::is_nothrow_constructible_v&&>) : base_t(std::move(obj)) { } template > && !std::is_same_v, meta::unqualified_t>>* = nullptr> as_table_t(Arg&& arg, Args&&... args) noexcept(std::is_nothrow_constructible_v) : base_t(std::forward(arg), std::forward(args)...) { } using base_t::value; operator std::add_lvalue_reference_t() { return this->base_t::value(); } operator std::add_const_t>() const { return this->base_t::value(); } }; template struct nested : private detail::ebco { private: using base_t = detail::ebco; public: using nested_type = T; nested() = default; nested(const nested&) = default; nested(nested&&) = default; nested& operator=(const nested&) = default; nested& operator=(nested&&) = default; nested(const meta::unqualified_t& obj) noexcept(std::is_nothrow_constructible_v&>) : base_t(obj) { } nested(meta::unqualified_t&& obj) noexcept(std::is_nothrow_constructible_v&&>) : base_t(std::move(obj)) { } template > && !std::is_same_v, meta::unqualified_t>>* = nullptr> nested(Arg&& arg, Args&&... args) noexcept(std::is_nothrow_constructible_v) : base_t(std::forward(arg), std::forward(args)...) { } using base_t::value; operator std::add_lvalue_reference_t() { return this->base_t::value(); } operator std::add_const_t>() const { return this->base_t::value(); } }; struct nested_tag_t { }; constexpr inline nested_tag_t nested_tag {}; template as_table_t as_table_ref(T&& container) { return as_table_t(std::forward(container)); } template as_table_t> as_table(T&& container) { return as_table_t>(std::forward(container)); } template nested as_nested_ref(T&& container) { return nested(std::forward(container)); } template nested> as_nested(T&& container) { return nested>(std::forward(container)); } template struct as_container_t : private detail::ebco { private: using base_t = detail::ebco; public: using type = T; as_container_t() = default; as_container_t(const as_container_t&) = default; as_container_t(as_container_t&&) = default; as_container_t& operator=(const as_container_t&) = default; as_container_t& operator=(as_container_t&&) = default; using base_t::base_t; using base_t::value; operator std::add_lvalue_reference_t() { return value(); } }; template auto as_container(T&& value) { return as_container_t(std::forward(value)); } template struct exhaustive_until : private detail::ebco { private: using base_t = detail::ebco; public: using base_t::base_t; using base_t::value; operator std::add_pointer_t>() { return std::addressof(this->base_t::value()); } operator std::add_pointer_t>>() const { return std::addressof(this->base_t::value()); } operator std::add_lvalue_reference_t() { return this->base_t::value(); } operator std::add_const_t>&() const { return this->base_t::value(); } }; template using exhaustive = exhaustive_until::max)()>; template struct non_exhaustive : private detail::ebco { private: using base_t = detail::ebco; public: using base_t::base_t; using base_t::value; operator std::add_pointer_t>() { return std::addressof(this->base_t::value()); } operator std::add_pointer_t>>() const { return std::addressof(this->base_t::value()); } operator std::add_lvalue_reference_t() { return this->base_t::value(); } operator std::add_const_t>&() const { return this->base_t::value(); } }; template struct push_invoke_t : private detail::ebco { private: using base_t = detail::ebco; public: push_invoke_t() = default; push_invoke_t(const push_invoke_t&) = default; push_invoke_t(push_invoke_t&&) = default; push_invoke_t& operator=(const push_invoke_t&) = default; push_invoke_t& operator=(push_invoke_t&&) = default; using base_t::base_t; using base_t::value; }; template auto push_invoke(Fx&& fx) { return push_invoke_t(std::forward(fx)); } template struct forward_as_value_t : private detail::ebco { private: using base_t = detail::ebco; public: forward_as_value_t() = default; forward_as_value_t(const forward_as_value_t&) = default; forward_as_value_t(forward_as_value_t&&) = default; forward_as_value_t& operator=(const forward_as_value_t&) = default; forward_as_value_t& operator=(forward_as_value_t&&) = default; using base_t::base_t; using base_t::value; }; template auto pass_as_value(T& value_ref_) { return forward_as_value_t(value_ref_); } struct override_value_t { }; constexpr inline override_value_t override_value = override_value_t(); struct update_if_empty_t { }; constexpr inline update_if_empty_t update_if_empty = update_if_empty_t(); struct create_if_nil_t { }; constexpr inline create_if_nil_t create_if_nil = create_if_nil_t(); namespace detail { enum insert_mode { none = 0x0, update_if_empty = 0x01, override_value = 0x02, create_if_nil = 0x04 }; template using is_insert_mode = std::integral_constant || std::is_same_v || std::is_same_v>; template using is_not_insert_mode = meta::neg>; } // namespace detail struct this_state { lua_State* L; this_state(lua_State* Ls) : L(Ls) { } operator lua_State*() const noexcept { return lua_state(); } lua_State* operator->() const noexcept { return lua_state(); } lua_State* lua_state() const noexcept { return L; } }; struct this_main_state { lua_State* L; this_main_state(lua_State* Ls) : L(Ls) { } operator lua_State*() const noexcept { return lua_state(); } lua_State* operator->() const noexcept { return lua_state(); } lua_State* lua_state() const noexcept { return L; } }; struct new_table { int sequence_hint = 0; int map_hint = 0; new_table() = default; new_table(const new_table&) = default; new_table(new_table&&) = default; new_table& operator=(const new_table&) = default; new_table& operator=(new_table&&) = default; new_table(int sequence_hint_, int map_hint_ = 0) noexcept : sequence_hint(sequence_hint_), map_hint(map_hint_) { } }; const new_table create = {}; enum class lib : unsigned char { // print, assert, and other base functions base, // require and other package functions package, // coroutine functions and utilities coroutine, // string library string, // functionality from the OS os, // all things math math, // the table manipulator and observer functions table, // the debug library debug, // the bit library: different based on which you're using bit32, // input/output library io, // LuaJIT only ffi, // LuaJIT only jit, // library for handling utf8: new to Lua utf8, // do not use count }; enum class call_syntax { dot = 0, colon = 1 }; enum class load_mode { any = 0, text = 1, binary = 2, }; enum class call_status : int { ok = LUA_OK, yielded = LUA_YIELD, runtime = LUA_ERRRUN, memory = LUA_ERRMEM, handler = LUA_ERRERR, gc = LUA_ERRGCMM, syntax = LUA_ERRSYNTAX, file = LUA_ERRFILE, }; enum class thread_status : int { ok = LUA_OK, yielded = LUA_YIELD, runtime = LUA_ERRRUN, memory = LUA_ERRMEM, gc = LUA_ERRGCMM, handler = LUA_ERRERR, dead = -1, }; enum class load_status : int { ok = LUA_OK, syntax = LUA_ERRSYNTAX, memory = LUA_ERRMEM, gc = LUA_ERRGCMM, file = LUA_ERRFILE, }; enum class gc_mode : int { incremental = 0, generational = 1, default_value = incremental, }; enum class type : int { none = LUA_TNONE, lua_nil = LUA_TNIL, #if SOL_IS_ON(SOL_NIL) nil = lua_nil, #endif // Objective C/C++ Keyword that's found in OSX SDK and OBJC -- check for all forms to protect string = LUA_TSTRING, number = LUA_TNUMBER, thread = LUA_TTHREAD, boolean = LUA_TBOOLEAN, function = LUA_TFUNCTION, userdata = LUA_TUSERDATA, lightuserdata = LUA_TLIGHTUSERDATA, table = LUA_TTABLE, poly = -0xFFFF }; inline const std::string& to_string(call_status c) { static const std::array names { { "ok", "yielded", "runtime", "memory", "handler", "gc", "syntax", "file", "CRITICAL_EXCEPTION_FAILURE", "CRITICAL_INDETERMINATE_STATE_FAILURE" } }; switch (c) { case call_status::ok: return names[0]; case call_status::yielded: return names[1]; case call_status::runtime: return names[2]; case call_status::memory: return names[3]; case call_status::handler: return names[4]; case call_status::gc: return names[5]; case call_status::syntax: return names[6]; case call_status::file: return names[7]; } if (static_cast(c) == -1) { // One of the many cases where a critical exception error has occurred return names[8]; } return names[9]; } inline bool is_indeterminate_call_failure(call_status c) { switch (c) { case call_status::ok: case call_status::yielded: case call_status::runtime: case call_status::memory: case call_status::handler: case call_status::gc: case call_status::syntax: case call_status::file: return false; } return true; } inline const std::string& to_string(load_status c) { static const std::array names { { "ok", "memory", "gc", "syntax", "file", "CRITICAL_EXCEPTION_FAILURE", "CRITICAL_INDETERMINATE_STATE_FAILURE" } }; switch (c) { case load_status::ok: return names[0]; case load_status::memory: return names[1]; case load_status::gc: return names[2]; case load_status::syntax: return names[3]; case load_status::file: return names[4]; } if (static_cast(c) == -1) { // One of the many cases where a critical exception error has occurred return names[5]; } return names[6]; } inline const std::string& to_string(load_mode c) { static const std::array names { { "bt", "t", "b", } }; return names[static_cast(c)]; } enum class meta_function : unsigned { construct, index, new_index, mode, call, call_function = call, metatable, to_string, length, unary_minus, addition, subtraction, multiplication, division, modulus, power_of, involution = power_of, concatenation, equal_to, less_than, less_than_or_equal_to, garbage_collect, floor_division, bitwise_left_shift, bitwise_right_shift, bitwise_not, bitwise_and, bitwise_or, bitwise_xor, pairs, ipairs, next, type, type_info, call_construct, storage, gc_names, static_index, static_new_index, }; typedef meta_function meta_method; inline const std::array& meta_function_names() { static const std::array names = { { "new", "__index", "__newindex", "__mode", "__call", "__metatable", "__tostring", "__len", "__unm", "__add", "__sub", "__mul", "__div", "__mod", "__pow", "__concat", "__eq", "__lt", "__le", "__gc", "__idiv", "__shl", "__shr", "__bnot", "__band", "__bor", "__bxor", "__pairs", "__ipairs", "next", "__type", "__typeinfo", "__sol.call_new", "__sol.storage", "__sol.gc_names", "__sol.static_index", "__sol.static_new_index" } }; return names; } inline const std::string& to_string(meta_function mf) { return meta_function_names()[static_cast(mf)]; } inline type type_of(lua_State* L, int index) { return static_cast(lua_type(L, index)); } inline std::string type_name(lua_State* L, type t) { return lua_typename(L, static_cast(t)); } template struct is_stateless_lua_reference : std::integral_constant || std::is_base_of_v)&&( !std::is_base_of_v && !std::is_base_of_v && !std::is_base_of_v)> { }; template inline constexpr bool is_stateless_lua_reference_v = is_stateless_lua_reference::value; template struct is_lua_reference : std::integral_constant || std::is_base_of_v || std::is_base_of_v || std::is_base_of_v || std::is_base_of_v> { }; template inline constexpr bool is_lua_reference_v = is_lua_reference::value; template struct is_lua_reference_or_proxy : std::integral_constant || meta::is_specialization_of_v> { }; template inline constexpr bool is_lua_reference_or_proxy_v = is_lua_reference_or_proxy::value; template struct is_transparent_argument : std::integral_constant, this_state> || std::is_same_v, this_main_state> || std::is_same_v, this_environment> || std::is_same_v, variadic_args>> { }; template constexpr inline bool is_transparent_argument_v = is_transparent_argument::value; template struct is_variadic_arguments : meta::any, meta::is_optional> { }; template struct is_container : std::integral_constant && !std::is_same_v && !meta::is_initializer_list_v && !meta::is_string_like_v && !meta::is_string_literal_array_v && !is_transparent_argument_v && !is_lua_reference_v && (meta::has_begin_end_v || std::is_array_v)> { }; template constexpr inline bool is_container_v = is_container::value; template struct is_to_stringable : meta::any>, meta::supports_adl_to_string>, meta::supports_op_left_shift>> { }; template inline constexpr bool is_to_stringable_v = is_to_stringable::value; template struct is_callable : std::true_type { }; template inline constexpr bool is_callable_v = is_callable::value; namespace detail { template struct lua_type_of : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of : std::integral_constant { }; template struct lua_type_of : std::integral_constant { }; #if SOL_IS_ON(SOL_CHAR8_T) template struct lua_type_of : std::integral_constant { }; #endif template struct lua_type_of : std::integral_constant { }; template struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; #if SOL_IS_ON(SOL_CHAR8_T) template <> struct lua_type_of : std::integral_constant { }; #endif template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; #if SOL_IS_ON(SOL_CHAR8_T) template <> struct lua_type_of : std::integral_constant { }; #endif template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template struct lua_type_of> : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE) template struct lua_type_of : std::integral_constant ? type::function : type::userdata> { }; #else template struct lua_type_of : std::integral_constant { }; #endif template struct lua_type_of || std::is_same_v || std::is_same_v>> : std::integral_constant { }; template struct lua_type_of>> : std::integral_constant { }; template struct lua_type_of>> : std::integral_constant { }; template <> struct lua_type_of : std::integral_constant { }; #if SOL_IS_ON(SOL_STD_VARIANT) template struct lua_type_of> : std::integral_constant { }; #endif // std::variant deployment sucks on Clang template struct lua_type_of> : meta::conditional_t<::sol::is_container_v, std::integral_constant, lua_type_of> { }; template class V, typename... Args> struct accumulate : std::integral_constant { }; template class V, typename T, typename... Args> struct accumulate : accumulate::value, V, Args...> { }; template class V, typename List> struct accumulate_list; template class V, typename... Args> struct accumulate_list> : accumulate { }; } // namespace detail template struct lua_type_of : detail::lua_type_of { typedef int SOL_INTERNAL_UNSPECIALIZED_MARKER_; }; template inline constexpr type lua_type_of_v = lua_type_of::value; template struct lua_size : std::integral_constant { typedef int SOL_INTERNAL_UNSPECIALIZED_MARKER_; }; template struct lua_size> : std::integral_constant::value + lua_size::value> { }; template struct lua_size> : std::integral_constant::value> { }; template inline constexpr int lua_size_v = lua_size::value; namespace detail { // MSVC's decltype detection is broken, which breaks other // parts of the code. So we add more workarounds. The moment it's fixed, // we take it away and break everyone that doesn't upgrade. template using is_msvc_callable_rigged = meta::any, meta::is_specialization_of, meta::is_specialization_of, meta::is_specialization_of, meta::is_specialization_of, meta::is_specialization_of>; template inline constexpr bool is_msvc_callable_rigged_v = is_msvc_callable_rigged::value; } // namespace detail template struct is_lua_primitive : std::integral_constant // cf || ((type::userdata == lua_type_of_v) // cf &&meta::meta_detail::has_internal_marker_v> // cf && !meta::meta_detail::has_internal_marker_v>) // cf || is_lua_reference_or_proxy_v // cf || meta::is_specialization_of_v // cf || meta::is_specialization_of_v> { }; template constexpr inline bool is_lua_primitive_v = is_lua_primitive::value; template struct is_value_semantic_for_function #if SOL_IS_ON(SOL_FUNCTION_CALL_VALUE_SEMANTICS) : std::true_type { }; #else : std::false_type { }; #endif template constexpr inline bool is_value_semantic_for_function_v = is_value_semantic_for_function::value; template struct is_main_threaded : std::is_base_of { }; template inline constexpr bool is_main_threaded_v = is_main_threaded::value; template struct is_stack_based : std::is_base_of { }; template <> struct is_stack_based : std::true_type { }; template <> struct is_stack_based : std::true_type { }; template <> struct is_stack_based : std::true_type { }; template <> struct is_stack_based : std::true_type { }; template <> struct is_stack_based : std::true_type { }; template <> struct is_stack_based : std::true_type { }; template constexpr inline bool is_stack_based_v = is_stack_based::value; template struct is_lua_primitive : std::true_type { }; template <> struct is_lua_primitive : std::true_type { }; template <> struct is_lua_primitive : std::true_type { }; template struct is_lua_primitive> : std::true_type { }; template struct is_lua_primitive> : std::true_type { }; template struct is_lua_primitive> : is_lua_primitive { }; template struct is_lua_primitive> : std::true_type { }; template struct is_lua_primitive> : std::true_type { }; template struct is_lua_primitive> : std::true_type { }; template struct is_lua_primitive> : std::true_type { }; template <> struct is_lua_primitive : std::true_type { }; template <> struct is_lua_primitive : std::true_type { }; template <> struct is_lua_primitive : std::true_type { }; template <> struct is_lua_primitive : std::true_type { }; template struct is_lua_primitive> : is_lua_primitive { }; template struct is_lua_index : std::is_integral { }; template <> struct is_lua_index : std::true_type { }; template <> struct is_lua_index : std::true_type { }; template <> struct is_lua_index : std::true_type { }; template <> struct is_lua_index : std::true_type { }; template struct lua_bind_traits : meta::bind_traits { private: typedef meta::bind_traits base_t; public: typedef std::integral_constant::value != 0> runtime_variadics_t; static const std::size_t true_arity = base_t::arity; static const std::size_t arity = detail::accumulate_list::value - meta::count_for::value; static const std::size_t true_free_arity = base_t::free_arity; static const std::size_t free_arity = detail::accumulate_list::value - meta::count_for::value; }; template struct is_table : std::false_type { }; template struct is_table> : std::true_type { }; template struct is_table> : std::true_type { }; template inline constexpr bool is_table_v = is_table::value; template struct is_global_table : std::false_type { }; template struct is_global_table> : std::true_type { }; template inline constexpr bool is_global_table_v = is_global_table::value; template struct is_stack_table : std::false_type { }; template struct is_stack_table> : std::integral_constant> { }; template struct is_stack_table> : std::integral_constant> { }; template inline constexpr bool is_stack_table_v = is_stack_table::value; template struct is_function : std::false_type { }; template struct is_function> : std::true_type { }; template struct is_function> : std::true_type { }; template using is_lightuserdata = meta::is_specialization_of; template inline constexpr bool is_lightuserdata_v = is_lightuserdata::value; template using is_userdata = meta::is_specialization_of; template inline constexpr bool is_userdata_v = is_userdata::value; template using is_environment = std::integral_constant || is_table_v || meta::is_specialization_of_v>; template inline constexpr bool is_environment_v = is_environment::value; template using is_table_like = std::integral_constant || is_environment_v || is_userdata_v>; template inline constexpr bool is_table_like_v = is_table_like::value; template struct is_automagical : std::integral_constant> || (!std::is_same_v, state> && !std::is_same_v, state_view>))> { }; template inline type type_of() { return lua_type_of>::value; } namespace detail { template struct is_non_factory_constructor : std::false_type { }; template struct is_non_factory_constructor> : std::true_type { }; template struct is_non_factory_constructor> : std::true_type { }; template <> struct is_non_factory_constructor : std::true_type { }; template inline constexpr bool is_non_factory_constructor_v = is_non_factory_constructor::value; template struct is_constructor : is_non_factory_constructor { }; template struct is_constructor> : std::true_type { }; template struct is_constructor> : is_constructor> { }; template struct is_constructor> : is_constructor> { }; template inline constexpr bool is_constructor_v = is_constructor::value; template using any_is_constructor = meta::any>...>; template inline constexpr bool any_is_constructor_v = any_is_constructor::value; template struct is_destructor : std::false_type { }; template struct is_destructor> : std::true_type { }; template using any_is_destructor = meta::any>...>; template inline constexpr bool any_is_destructor_v = any_is_destructor::value; } // namespace detail template using is_lua_c_function = meta::any, std::is_same, std::is_same>; template inline constexpr bool is_lua_c_function_v = is_lua_c_function::value; enum class automagic_flags : unsigned { none = 0x000u, default_constructor = 0x001, destructor = 0x002u, pairs_operator = 0x004u, to_string_operator = 0x008u, call_operator = 0x010u, less_than_operator = 0x020u, less_than_or_equal_to_operator = 0x040u, length_operator = 0x080u, equal_to_operator = 0x100u, all = default_constructor | destructor | pairs_operator | to_string_operator | call_operator | less_than_operator | less_than_or_equal_to_operator | length_operator | equal_to_operator }; inline constexpr automagic_flags operator|(automagic_flags left, automagic_flags right) noexcept { return static_cast( static_cast>(left) | static_cast>(right)); } inline constexpr automagic_flags operator&(automagic_flags left, automagic_flags right) noexcept { return static_cast( static_cast>(left) & static_cast>(right)); } inline constexpr automagic_flags& operator|=(automagic_flags& left, automagic_flags right) noexcept { left = left | right; return left; } inline constexpr automagic_flags& operator&=(automagic_flags& left, automagic_flags right) noexcept { left = left & right; return left; } template constexpr bool has_flag(Left left, Right right) noexcept { return (left & right) == right; } template constexpr bool has_any_flag(Left left, Right right) noexcept { return (left & right) != static_cast(static_cast>(0)); } template constexpr auto clear_flags(Left left, Right right) noexcept { return static_cast(static_cast>(left) & ~static_cast>(right)); } struct automagic_enrollments { bool default_constructor = true; bool destructor = true; bool pairs_operator = true; bool to_string_operator = true; bool call_operator = true; bool less_than_operator = true; bool less_than_or_equal_to_operator = true; bool length_operator = true; bool equal_to_operator = true; }; template struct constant_automagic_enrollments : public automagic_enrollments { }; } // namespace sol #endif // SOL_TYPES_HPP