diff --git a/include/sol/function_types_stateless.hpp b/include/sol/function_types_stateless.hpp index d9d38fb1..75dbcf27 100644 --- a/include/sol/function_types_stateless.hpp +++ b/include/sol/function_types_stateless.hpp @@ -1,4 +1,4 @@ -// sol3 +// sol3 // The MIT License (MIT) @@ -28,14 +28,19 @@ #include #include -namespace sol { -namespace function_detail { +namespace sol { namespace function_detail { template struct upvalue_free_function { using function_type = std::remove_pointer_t>; using traits_type = meta::bind_traits; - static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int real_call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { auto udata = stack::stack_detail::get_as_upvalues(L); function_type* fx = udata.first; return call_detail::call_wrapped(L, fx); @@ -61,7 +66,13 @@ namespace function_detail { typedef std::remove_pointer_t> function_type; typedef lua_bind_traits traits_type; - static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int real_call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { // Layout: // idx 1...n: verbatim data of member function pointer // idx n + 1: is the object's void pointer @@ -72,7 +83,13 @@ namespace function_detail { return call_detail::call_wrapped(L, memfx, item); } - static int call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { int nr = detail::typed_static_trampoline(L); if (is_yielding) { return lua_yield(L, nr); @@ -92,7 +109,13 @@ namespace function_detail { typedef std::remove_pointer_t> function_type; typedef lua_bind_traits traits_type; - static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int real_call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { // Layout: // idx 1...n: verbatim data of member variable pointer // idx n + 1: is the object's void pointer @@ -112,7 +135,13 @@ namespace function_detail { } } - static int call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { int nr = detail::typed_static_trampoline(L); if (is_yielding) { return lua_yield(L, nr); @@ -132,7 +161,13 @@ namespace function_detail { typedef std::remove_pointer_t> function_type; typedef lua_bind_traits traits_type; - static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int real_call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { // Layout: // idx 1...n: verbatim data of member variable pointer // idx n + 1: is the object's void pointer @@ -150,7 +185,13 @@ namespace function_detail { } } - static int call(lua_State* L) { + static int call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { int nr = detail::typed_static_trampoline(L); if (is_yielding) { return lua_yield(L, nr); @@ -170,14 +211,26 @@ namespace function_detail { typedef std::remove_pointer_t> function_type; typedef lua_bind_traits traits_type; - static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int real_call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { // Layout: // idx 1...n: verbatim data of member variable pointer function_type& memfx = stack::get>(L, upvalue_index(2)); return call_detail::call_wrapped(L, memfx); } - static int call(lua_State* L) { + static int call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { int nr = detail::typed_static_trampoline(L); if (is_yielding) { return lua_yield(L, nr); @@ -258,7 +311,6 @@ namespace function_detail { return call(L); } }; -} -} // namespace sol::function_detail +}} // namespace sol::function_detail #endif // SOL_FUNCTION_TYPES_STATELESS_HPP diff --git a/include/sol/stack_core.hpp b/include/sol/stack_core.hpp index 7298483b..a6f900b1 100644 --- a/include/sol/stack_core.hpp +++ b/include/sol/stack_core.hpp @@ -46,16 +46,16 @@ namespace sol { namespace detail { - struct with_function_tag {}; - struct as_reference_tag {}; + struct with_function_tag { }; + struct as_reference_tag { }; template - struct as_pointer_tag {}; + struct as_pointer_tag { }; template - struct as_value_tag {}; + struct as_value_tag { }; template - struct as_unique_tag {}; + struct as_unique_tag { }; template - struct as_table_tag {}; + struct as_table_tag { }; using lua_reg_table = luaL_Reg[64]; @@ -92,7 +92,9 @@ namespace sol { template std::size_t aligned_space_for(void* alignment = nullptr) { - char* start = static_cast(alignment); + // use temporary storage to prevent strict UB shenanigans + char alignment_shim[(std::max)({ sizeof(Args)... }) + (std::max)({ alignof(Args)... })] {}; + char* start = alignment == nullptr ? static_cast(alignment) : alignment_shim; (void)detail::swallow { int {}, (align_one(std::alignment_of_v, sizeof(Args), alignment), int {})... }; return static_cast(alignment) - start; } @@ -1423,24 +1425,24 @@ namespace sol { void insert_default_registrations(IFx&& ifx, Fx&& fx); template - struct get_is_primitive : is_lua_primitive {}; + struct get_is_primitive : is_lua_primitive { }; template struct get_is_primitive - : meta::neg(), nullptr, -1, std::declval()))>> {}; + : meta::neg(), nullptr, -1, std::declval()))>> { }; template struct get_is_primitive - : meta::neg>(), nullptr, -1, std::declval()))>> {}; + : meta::neg>(), nullptr, -1, std::declval()))>> { }; template - struct get_is_primitive : get_is_primitive {}; + struct get_is_primitive : get_is_primitive { }; } // namespace detail template struct is_proxy_primitive - : detail::get_is_primitive, meta::meta_detail::is_adl_sol_lua_get_v>> {}; + : detail::get_is_primitive, meta::meta_detail::is_adl_sol_lua_get_v>> { }; } // namespace sol diff --git a/include/sol/state_view.hpp b/include/sol/state_view.hpp index 223accb9..e110ec83 100644 --- a/include/sol/state_view.hpp +++ b/include/sol/state_view.hpp @@ -637,10 +637,88 @@ namespace sol { return s; } + bool supports_gc_mode(gc_mode mode) const noexcept { +#if SOL_LUA_VERSION >= 504 + // supports all modes + (void)mode; + return true; +#endif + return mode == gc_mode::default; + } + + bool is_gc_on() const { + return lua_gc(lua_state(), LUA_GCISRUNNING, 0) == 1; + } + void collect_garbage() { lua_gc(lua_state(), LUA_GCCOLLECT, 0); } + void collect_gc() { + collect_garbage(); + } + + bool step_gc(int step_size_kilobytes) { + // THOUGHT: std::chrono-alikes to map "kilobyte size" here...? + // Make it harder to give MB or KB to a B parameter...? + // Probably overkill for now. +#if SOL_LUA_VERSION >= 504 + // The manual implies that this function is almost always successful... + // is it?? It could depend on the GC mode... + return lua_gc(lua_state(), LUA_GCSTEP, step_size_kilobytes) != 0; +#else + return lua_gc(lua_state(), LUA_GCSTEP, step_size_kilobytes) == 1; +#endif + } + + void restart_gc() { + lua_gc(lua_state(), LUA_GCRESTART, 0); + } + + void stop_gc() { + lua_gc(lua_state(), LUA_GCSTOP, 0); + } + + // Returns the old GC mode. Check support using the supports_gc_mode function. + gc_mode change_gc_mode_incremental(int pause, int step_multiplier, int step_byte_size) { + // "What the fuck does any of this mean??" + // http://www.lua.org/manual/5.4/manual.html#2.5.1 + + // THOUGHT: std::chrono-alikes to map "byte size" here...? + // Make it harder to give MB or KB to a B parameter...? + // Probably overkill for now. +#if SOL_LUA_VERSION >= 504 + int old_mode = lua_gc(lua_state(), LUA_GCINC, pause, step_multiplier, step_byte_size); + if (old_mode == LUA_GCGEN) { + return gc_mode::generational; + } + else if (old_mode == LUA_GCINC) { + return gc_mode::incremental; + } +#else + lua_gc(lua_state(), LUA_GCSETPAUSE, pause); + lua_gc(lua_state(), LUA_GCSETSTEPMUL, step_multiplier); + (void)step_byte_size; // means nothing in older versions +#endif + return gc_mode::default; + } + + // Returns the old GC mode. Check support using the supports_gc_mode function. + gc_mode change_gc_mode_generational(int minor_multiplier, int major_multiplier) { +#if SOL_LUA_VERSION >= 504 + // "What does this shit mean?" + // http://www.lua.org/manual/5.4/manual.html#2.5.2 + int old_mode = lua_gc(lua_state(), LUA_GCGEN, minor_multiplier, major_multiplier); + if (old_mode == LUA_GCGEN) { + return gc_mode::generational; + } + else if (old_mode == LUA_GCINC) { + return gc_mode::incremental; + } +#endif + return gc_mode::default; + } + operator lua_State*() const { return lua_state(); } diff --git a/include/sol/types.hpp b/include/sol/types.hpp index 58c20e32..253197c6 100644 --- a/include/sol/types.hpp +++ b/include/sol/types.hpp @@ -53,7 +53,7 @@ namespace sol { #endif // noexcept function type for lua_CFunction template - struct unique_usertype {}; + struct unique_usertype { }; template struct implicit_wrapper { @@ -70,11 +70,11 @@ namespace sol { } }; - struct yield_tag_t {}; + struct yield_tag_t { }; const yield_tag_t yield_tag = yield_tag_t {}; } // namespace detail - struct lua_nil_t {}; + struct lua_nil_t { }; inline constexpr lua_nil_t lua_nil {}; inline bool operator==(lua_nil_t, lua_nil_t) { return true; @@ -88,16 +88,16 @@ namespace sol { #endif namespace detail { - struct non_lua_nil_t {}; + struct non_lua_nil_t { }; } // namespace detail - struct metatable_key_t {}; + struct metatable_key_t { }; const metatable_key_t metatable_key = {}; - struct env_key_t {}; + struct env_key_t { }; const env_key_t env_key = {}; - struct no_metatable_t {}; + struct no_metatable_t { }; const no_metatable_t no_metatable = {}; template @@ -127,10 +127,10 @@ namespace sol { typedef std::remove_pointer_t lua_CFunction_ref; template - struct non_null {}; + struct non_null { }; template - struct function_sig {}; + struct function_sig { }; struct upvalue_index { int index; @@ -233,7 +233,7 @@ namespace sol { operator std::add_lvalue_reference_t() { return value; } - operator std::add_const_t>&() const { + operator std::add_const_t> &() const { return value; } }; @@ -375,7 +375,7 @@ namespace sol { } }; - struct nested_tag_t {}; + struct nested_tag_t { }; constexpr inline nested_tag_t nested_tag {}; template @@ -506,11 +506,11 @@ namespace sol { return push_invoke_t(std::forward(fx)); } - struct override_value_t {}; + struct override_value_t { }; constexpr inline override_value_t override_value = override_value_t(); - struct update_if_empty_t {}; + struct update_if_empty_t { }; constexpr inline update_if_empty_t update_if_empty = update_if_empty_t(); - struct create_if_nil_t {}; + struct create_if_nil_t { }; constexpr inline create_if_nil_t create_if_nil = create_if_nil_t(); namespace detail { @@ -646,6 +646,12 @@ namespace sol { file = LUA_ERRFILE, }; + enum class gc_mode : int { + incremental = 0, + generational = 1, + default = incremental, + }; + enum class type : int { none = LUA_TNONE, lua_nil = LUA_TNIL, @@ -848,33 +854,33 @@ namespace sol { template struct is_lua_reference - : std::integral_constant || std::is_base_of_v || std::is_base_of_v> {}; + : std::integral_constant || 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> {}; + 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::false_type {}; + struct is_transparent_argument : std::false_type { }; template constexpr inline bool is_transparent_argument_v = is_transparent_argument::value; template <> - struct is_transparent_argument : std::true_type {}; + struct is_transparent_argument : std::true_type { }; template <> - struct is_transparent_argument : std::true_type {}; + struct is_transparent_argument : std::true_type { }; template <> - struct is_transparent_argument : std::true_type {}; + struct is_transparent_argument : std::true_type { }; template <> - struct is_transparent_argument : std::true_type {}; + struct is_transparent_argument : std::true_type { }; template - struct is_variadic_arguments : std::is_same {}; + struct is_variadic_arguments : std::is_same { }; template struct is_container @@ -888,221 +894,221 @@ namespace sol { template struct is_to_stringable : meta::any>, meta::supports_adl_to_string>, - meta::supports_op_left_shift>> {}; + meta::supports_op_left_shift>> { }; namespace detail { template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template struct lua_type_of || std::is_same_v || std::is_same_v>> - : std::integral_constant {}; + : std::integral_constant { }; template - struct lua_type_of>> : std::integral_constant {}; + struct lua_type_of>> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; #if SOL_IS_ON(SOL_STD_VARIANT_I_) template - struct lua_type_of> : std::integral_constant {}; + 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> {}; + 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 {}; + struct accumulate : std::integral_constant { }; template class V, typename T, typename... Args> - struct accumulate : accumulate::value, V, Args...> {}; + struct accumulate : accumulate::value, V, Args...> { }; template class V, typename List> struct accumulate_list; template class V, typename... Args> - struct accumulate_list> : accumulate {}; + struct accumulate_list> : accumulate { }; } // namespace detail template @@ -1119,10 +1125,10 @@ namespace sol { }; template - struct lua_size> : std::integral_constant::value + lua_size::value> {}; + struct lua_size> : std::integral_constant::value + lua_size::value> { }; template - struct lua_size> : std::integral_constant::value> {}; + struct lua_size> : std::integral_constant::value> { }; template inline constexpr int lua_size_v = lua_size::value; @@ -1133,9 +1139,9 @@ namespace sol { typedef void type; }; template - struct has_internal_marker_impl : std::false_type {}; + struct has_internal_marker_impl : std::false_type { }; template - struct has_internal_marker_impl::type> : std::true_type {}; + struct has_internal_marker_impl::type> : std::true_type { }; template using has_internal_marker = has_internal_marker_impl; @@ -1150,73 +1156,73 @@ namespace sol { type::userdata != lua_type_of_v< T> || ((type::userdata == lua_type_of_v)&&detail::has_internal_marker_v> && !detail::has_internal_marker_v>) - || is_lua_reference_or_proxy_v || meta::is_specialization_of_v || meta::is_specialization_of_v> {}; + || is_lua_reference_or_proxy_v || meta::is_specialization_of_v || meta::is_specialization_of_v> { }; template constexpr inline bool is_lua_primitive_v = is_lua_primitive::value; template - struct is_main_threaded : std::is_base_of {}; + struct is_main_threaded : std::is_base_of { }; template - struct is_stack_based : std::is_base_of {}; + struct is_stack_based : std::is_base_of { }; template <> - struct is_stack_based : std::true_type {}; + struct is_stack_based : std::true_type { }; template <> - struct is_stack_based : std::true_type {}; + struct is_stack_based : std::true_type { }; template <> - struct is_stack_based : std::true_type {}; + struct is_stack_based : std::true_type { }; template <> - struct is_stack_based : std::true_type {}; + struct is_stack_based : std::true_type { }; template <> - struct is_stack_based : std::true_type {}; + struct is_stack_based : std::true_type { }; template <> - struct is_stack_based : std::true_type {}; + 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 {}; + struct is_lua_primitive : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template - struct is_lua_primitive> : is_lua_primitive {}; + struct is_lua_primitive> : is_lua_primitive { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template - struct is_lua_primitive> : is_lua_primitive {}; + struct is_lua_primitive> : is_lua_primitive { }; template - struct is_lua_index : std::is_integral {}; + struct is_lua_index : std::is_integral { }; template <> - struct is_lua_index : std::true_type {}; + struct is_lua_index : std::true_type { }; template <> - struct is_lua_index : std::true_type {}; + struct is_lua_index : std::true_type { }; template <> - struct is_lua_index : std::true_type {}; + struct is_lua_index : std::true_type { }; template <> - struct is_lua_index : std::true_type {}; + struct is_lua_index : std::true_type { }; template struct lua_bind_traits : meta::bind_traits { @@ -1234,31 +1240,31 @@ namespace sol { }; template - struct is_table : std::false_type {}; + struct is_table : std::false_type { }; template - struct is_table> : std::true_type {}; + struct is_table> : std::true_type { }; template - struct is_table> : std::true_type {}; + struct is_table> : std::true_type { }; template inline constexpr bool is_table_v = is_table::value; template - struct is_stack_table : std::false_type {}; + struct is_stack_table : std::false_type { }; template - struct is_stack_table> : std::integral_constant> {}; + struct is_stack_table> : std::integral_constant> { }; template - struct is_stack_table> : std::integral_constant> {}; + 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 {}; + struct is_function : std::false_type { }; template - struct is_function> : std::true_type {}; + struct is_function> : std::true_type { }; template - struct is_function> : std::true_type {}; + struct is_function> : std::true_type { }; template @@ -1300,31 +1306,31 @@ namespace sol { namespace detail { template - struct is_non_factory_constructor : std::false_type {}; + struct is_non_factory_constructor : std::false_type { }; template - struct is_non_factory_constructor> : std::true_type {}; + struct is_non_factory_constructor> : std::true_type { }; template - struct is_non_factory_constructor> : std::true_type {}; + struct is_non_factory_constructor> : std::true_type { }; template <> - struct is_non_factory_constructor : std::true_type {}; + 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 {}; + struct is_constructor : is_non_factory_constructor { }; template - struct is_constructor> : std::true_type {}; + struct is_constructor> : std::true_type { }; template - struct is_constructor> : is_constructor> {}; + struct is_constructor> : is_constructor> { }; template - struct is_constructor> : is_constructor> {}; + struct is_constructor> : is_constructor> { }; template inline constexpr bool is_constructor_v = is_constructor::value; @@ -1336,10 +1342,10 @@ namespace sol { inline constexpr bool any_is_constructor_v = any_is_constructor::value; template - struct is_destructor : std::false_type {}; + struct is_destructor : std::false_type { }; template - struct is_destructor> : std::true_type {}; + struct is_destructor> : std::true_type { }; template using any_is_destructor = meta::any>...>; diff --git a/single/include/sol/config.hpp b/single/include/sol/config.hpp index 64833d53..c5197928 100644 --- a/single/include/sol/config.hpp +++ b/single/include/sol/config.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2020-08-12 23:04:25.864654 UTC -// This header was generated with sol v3.2.1 (revision 5bbc095) +// Generated 2020-09-05 21:23:26.771012 UTC +// This header was generated with sol v3.2.1 (revision de87bec) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_CONFIG_HPP diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index 5e76b26d..34330910 100644 --- a/single/include/sol/forward.hpp +++ b/single/include/sol/forward.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2020-08-12 23:04:25.839654 UTC -// This header was generated with sol v3.2.1 (revision 5bbc095) +// Generated 2020-09-05 21:23:26.767014 UTC +// This header was generated with sol v3.2.1 (revision de87bec) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/single/include/sol/sol.hpp b/single/include/sol/sol.hpp index df4deddd..e3cc67c2 100644 --- a/single/include/sol/sol.hpp +++ b/single/include/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2020-08-12 23:04:25.317593 UTC -// This header was generated with sol v3.2.1 (revision 5bbc095) +// Generated 2020-09-05 21:23:26.587015 UTC +// This header was generated with sol v3.2.1 (revision de87bec) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -6486,7 +6486,7 @@ namespace sol { #endif // noexcept function type for lua_CFunction template - struct unique_usertype {}; + struct unique_usertype { }; template struct implicit_wrapper { @@ -6503,11 +6503,11 @@ namespace sol { } }; - struct yield_tag_t {}; + struct yield_tag_t { }; const yield_tag_t yield_tag = yield_tag_t {}; } // namespace detail - struct lua_nil_t {}; + struct lua_nil_t { }; inline constexpr lua_nil_t lua_nil {}; inline bool operator==(lua_nil_t, lua_nil_t) { return true; @@ -6521,16 +6521,16 @@ namespace sol { #endif namespace detail { - struct non_lua_nil_t {}; + struct non_lua_nil_t { }; } // namespace detail - struct metatable_key_t {}; + struct metatable_key_t { }; const metatable_key_t metatable_key = {}; - struct env_key_t {}; + struct env_key_t { }; const env_key_t env_key = {}; - struct no_metatable_t {}; + struct no_metatable_t { }; const no_metatable_t no_metatable = {}; template @@ -6560,10 +6560,10 @@ namespace sol { typedef std::remove_pointer_t lua_CFunction_ref; template - struct non_null {}; + struct non_null { }; template - struct function_sig {}; + struct function_sig { }; struct upvalue_index { int index; @@ -6666,7 +6666,7 @@ namespace sol { operator std::add_lvalue_reference_t() { return value; } - operator std::add_const_t>&() const { + operator std::add_const_t> &() const { return value; } }; @@ -6808,7 +6808,7 @@ namespace sol { } }; - struct nested_tag_t {}; + struct nested_tag_t { }; constexpr inline nested_tag_t nested_tag {}; template @@ -6939,11 +6939,11 @@ namespace sol { return push_invoke_t(std::forward(fx)); } - struct override_value_t {}; + struct override_value_t { }; constexpr inline override_value_t override_value = override_value_t(); - struct update_if_empty_t {}; + struct update_if_empty_t { }; constexpr inline update_if_empty_t update_if_empty = update_if_empty_t(); - struct create_if_nil_t {}; + struct create_if_nil_t { }; constexpr inline create_if_nil_t create_if_nil = create_if_nil_t(); namespace detail { @@ -7079,6 +7079,12 @@ namespace sol { file = LUA_ERRFILE, }; + enum class gc_mode : int { + incremental = 0, + generational = 1, + default = incremental, + }; + enum class type : int { none = LUA_TNONE, lua_nil = LUA_TNIL, @@ -7281,33 +7287,33 @@ namespace sol { template struct is_lua_reference - : std::integral_constant || std::is_base_of_v || std::is_base_of_v> {}; + : std::integral_constant || 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> {}; + 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::false_type {}; + struct is_transparent_argument : std::false_type { }; template constexpr inline bool is_transparent_argument_v = is_transparent_argument::value; template <> - struct is_transparent_argument : std::true_type {}; + struct is_transparent_argument : std::true_type { }; template <> - struct is_transparent_argument : std::true_type {}; + struct is_transparent_argument : std::true_type { }; template <> - struct is_transparent_argument : std::true_type {}; + struct is_transparent_argument : std::true_type { }; template <> - struct is_transparent_argument : std::true_type {}; + struct is_transparent_argument : std::true_type { }; template - struct is_variadic_arguments : std::is_same {}; + struct is_variadic_arguments : std::is_same { }; template struct is_container @@ -7321,221 +7327,221 @@ namespace sol { template struct is_to_stringable : meta::any>, meta::supports_adl_to_string>, - meta::supports_op_left_shift>> {}; + meta::supports_op_left_shift>> { }; namespace detail { template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template - struct lua_type_of> : std::integral_constant {}; + struct lua_type_of> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; template struct lua_type_of || std::is_same_v || std::is_same_v>> - : std::integral_constant {}; + : std::integral_constant { }; template - struct lua_type_of>> : std::integral_constant {}; + struct lua_type_of>> : std::integral_constant { }; template <> - struct lua_type_of : std::integral_constant {}; + struct lua_type_of : std::integral_constant { }; #if SOL_IS_ON(SOL_STD_VARIANT_I_) template - struct lua_type_of> : std::integral_constant {}; + 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> {}; + 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 {}; + struct accumulate : std::integral_constant { }; template class V, typename T, typename... Args> - struct accumulate : accumulate::value, V, Args...> {}; + struct accumulate : accumulate::value, V, Args...> { }; template class V, typename List> struct accumulate_list; template class V, typename... Args> - struct accumulate_list> : accumulate {}; + struct accumulate_list> : accumulate { }; } // namespace detail template @@ -7552,10 +7558,10 @@ namespace sol { }; template - struct lua_size> : std::integral_constant::value + lua_size::value> {}; + struct lua_size> : std::integral_constant::value + lua_size::value> { }; template - struct lua_size> : std::integral_constant::value> {}; + struct lua_size> : std::integral_constant::value> { }; template inline constexpr int lua_size_v = lua_size::value; @@ -7566,9 +7572,9 @@ namespace sol { typedef void type; }; template - struct has_internal_marker_impl : std::false_type {}; + struct has_internal_marker_impl : std::false_type { }; template - struct has_internal_marker_impl::type> : std::true_type {}; + struct has_internal_marker_impl::type> : std::true_type { }; template using has_internal_marker = has_internal_marker_impl; @@ -7583,73 +7589,73 @@ namespace sol { type::userdata != lua_type_of_v< T> || ((type::userdata == lua_type_of_v)&&detail::has_internal_marker_v> && !detail::has_internal_marker_v>) - || is_lua_reference_or_proxy_v || meta::is_specialization_of_v || meta::is_specialization_of_v> {}; + || is_lua_reference_or_proxy_v || meta::is_specialization_of_v || meta::is_specialization_of_v> { }; template constexpr inline bool is_lua_primitive_v = is_lua_primitive::value; template - struct is_main_threaded : std::is_base_of {}; + struct is_main_threaded : std::is_base_of { }; template - struct is_stack_based : std::is_base_of {}; + struct is_stack_based : std::is_base_of { }; template <> - struct is_stack_based : std::true_type {}; + struct is_stack_based : std::true_type { }; template <> - struct is_stack_based : std::true_type {}; + struct is_stack_based : std::true_type { }; template <> - struct is_stack_based : std::true_type {}; + struct is_stack_based : std::true_type { }; template <> - struct is_stack_based : std::true_type {}; + struct is_stack_based : std::true_type { }; template <> - struct is_stack_based : std::true_type {}; + struct is_stack_based : std::true_type { }; template <> - struct is_stack_based : std::true_type {}; + 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 {}; + struct is_lua_primitive : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template - struct is_lua_primitive> : is_lua_primitive {}; + struct is_lua_primitive> : is_lua_primitive { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template - struct is_lua_primitive> : std::true_type {}; + struct is_lua_primitive> : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template <> - struct is_lua_primitive : std::true_type {}; + struct is_lua_primitive : std::true_type { }; template - struct is_lua_primitive> : is_lua_primitive {}; + struct is_lua_primitive> : is_lua_primitive { }; template - struct is_lua_index : std::is_integral {}; + struct is_lua_index : std::is_integral { }; template <> - struct is_lua_index : std::true_type {}; + struct is_lua_index : std::true_type { }; template <> - struct is_lua_index : std::true_type {}; + struct is_lua_index : std::true_type { }; template <> - struct is_lua_index : std::true_type {}; + struct is_lua_index : std::true_type { }; template <> - struct is_lua_index : std::true_type {}; + struct is_lua_index : std::true_type { }; template struct lua_bind_traits : meta::bind_traits { @@ -7667,31 +7673,31 @@ namespace sol { }; template - struct is_table : std::false_type {}; + struct is_table : std::false_type { }; template - struct is_table> : std::true_type {}; + struct is_table> : std::true_type { }; template - struct is_table> : std::true_type {}; + struct is_table> : std::true_type { }; template inline constexpr bool is_table_v = is_table::value; template - struct is_stack_table : std::false_type {}; + struct is_stack_table : std::false_type { }; template - struct is_stack_table> : std::integral_constant> {}; + struct is_stack_table> : std::integral_constant> { }; template - struct is_stack_table> : std::integral_constant> {}; + 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 {}; + struct is_function : std::false_type { }; template - struct is_function> : std::true_type {}; + struct is_function> : std::true_type { }; template - struct is_function> : std::true_type {}; + struct is_function> : std::true_type { }; template using is_lightuserdata = meta::is_specialization_of; @@ -7732,31 +7738,31 @@ namespace sol { namespace detail { template - struct is_non_factory_constructor : std::false_type {}; + struct is_non_factory_constructor : std::false_type { }; template - struct is_non_factory_constructor> : std::true_type {}; + struct is_non_factory_constructor> : std::true_type { }; template - struct is_non_factory_constructor> : std::true_type {}; + struct is_non_factory_constructor> : std::true_type { }; template <> - struct is_non_factory_constructor : std::true_type {}; + 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 {}; + struct is_constructor : is_non_factory_constructor { }; template - struct is_constructor> : std::true_type {}; + struct is_constructor> : std::true_type { }; template - struct is_constructor> : is_constructor> {}; + struct is_constructor> : is_constructor> { }; template - struct is_constructor> : is_constructor> {}; + struct is_constructor> : is_constructor> { }; template inline constexpr bool is_constructor_v = is_constructor::value; @@ -7768,10 +7774,10 @@ namespace sol { inline constexpr bool any_is_constructor_v = any_is_constructor::value; template - struct is_destructor : std::false_type {}; + struct is_destructor : std::false_type { }; template - struct is_destructor> : std::true_type {}; + struct is_destructor> : std::true_type { }; template using any_is_destructor = meta::any>...>; @@ -9676,16 +9682,16 @@ namespace sol { namespace sol { namespace detail { - struct with_function_tag {}; - struct as_reference_tag {}; + struct with_function_tag { }; + struct as_reference_tag { }; template - struct as_pointer_tag {}; + struct as_pointer_tag { }; template - struct as_value_tag {}; + struct as_value_tag { }; template - struct as_unique_tag {}; + struct as_unique_tag { }; template - struct as_table_tag {}; + struct as_table_tag { }; using lua_reg_table = luaL_Reg[64]; @@ -9722,7 +9728,11 @@ namespace sol { template std::size_t aligned_space_for(void* alignment = nullptr) { - char* start = static_cast(alignment); + // use temporary storage to prevent strict UB shenanigans + using union_type = std::aligned_union<1, Args...>; + using union_type_t = typename union_type::type; + char alignment_shim[(std::max)({ sizeof(Args)... }) + (std::max)({ alignof(Args)... })] {}; + char* start = alignment == nullptr ? static_cast(alignment) : alignment_shim; (void)detail::swallow { int {}, (align_one(std::alignment_of_v, sizeof(Args), alignment), int {})... }; return static_cast(alignment) - start; } @@ -11052,24 +11062,24 @@ namespace sol { void insert_default_registrations(IFx&& ifx, Fx&& fx); template - struct get_is_primitive : is_lua_primitive {}; + struct get_is_primitive : is_lua_primitive { }; template struct get_is_primitive - : meta::neg(), nullptr, -1, std::declval()))>> {}; + : meta::neg(), nullptr, -1, std::declval()))>> { }; template struct get_is_primitive - : meta::neg>(), nullptr, -1, std::declval()))>> {}; + : meta::neg>(), nullptr, -1, std::declval()))>> { }; template - struct get_is_primitive : get_is_primitive {}; + struct get_is_primitive : get_is_primitive { }; } // namespace detail template struct is_proxy_primitive - : detail::get_is_primitive, meta::meta_detail::is_adl_sol_lua_get_v>> {}; + : detail::get_is_primitive, meta::meta_detail::is_adl_sol_lua_get_v>> { }; } // namespace sol @@ -17455,14 +17465,19 @@ namespace sol { // beginning of sol/function_types_stateless.hpp -namespace sol { -namespace function_detail { +namespace sol { namespace function_detail { template struct upvalue_free_function { using function_type = std::remove_pointer_t>; using traits_type = meta::bind_traits; - static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int real_call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { auto udata = stack::stack_detail::get_as_upvalues(L); function_type* fx = udata.first; return call_detail::call_wrapped(L, fx); @@ -17488,7 +17503,13 @@ namespace function_detail { typedef std::remove_pointer_t> function_type; typedef lua_bind_traits traits_type; - static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int real_call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { // Layout: // idx 1...n: verbatim data of member function pointer // idx n + 1: is the object's void pointer @@ -17499,7 +17520,13 @@ namespace function_detail { return call_detail::call_wrapped(L, memfx, item); } - static int call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { int nr = detail::typed_static_trampoline(L); if (is_yielding) { return lua_yield(L, nr); @@ -17519,7 +17546,13 @@ namespace function_detail { typedef std::remove_pointer_t> function_type; typedef lua_bind_traits traits_type; - static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int real_call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { // Layout: // idx 1...n: verbatim data of member variable pointer // idx n + 1: is the object's void pointer @@ -17539,7 +17572,13 @@ namespace function_detail { } } - static int call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { int nr = detail::typed_static_trampoline(L); if (is_yielding) { return lua_yield(L, nr); @@ -17559,7 +17598,13 @@ namespace function_detail { typedef std::remove_pointer_t> function_type; typedef lua_bind_traits traits_type; - static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int real_call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { // Layout: // idx 1...n: verbatim data of member variable pointer // idx n + 1: is the object's void pointer @@ -17577,7 +17622,13 @@ namespace function_detail { } } - static int call(lua_State* L) { + static int call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { int nr = detail::typed_static_trampoline(L); if (is_yielding) { return lua_yield(L, nr); @@ -17597,14 +17648,26 @@ namespace function_detail { typedef std::remove_pointer_t> function_type; typedef lua_bind_traits traits_type; - static int real_call(lua_State* L) noexcept(traits_type::is_noexcept) { + static int real_call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { // Layout: // idx 1...n: verbatim data of member variable pointer function_type& memfx = stack::get>(L, upvalue_index(2)); return call_detail::call_wrapped(L, memfx); } - static int call(lua_State* L) { + static int call(lua_State* L) +#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) + // MSVC is broken, what a surprise... +#else + noexcept(traits_type::is_noexcept) +#endif + { int nr = detail::typed_static_trampoline(L); if (is_yielding) { return lua_yield(L, nr); @@ -17685,8 +17748,7 @@ namespace function_detail { return call(L); } }; -} -} // namespace sol::function_detail +}} // namespace sol::function_detail // end of sol/function_types_stateless.hpp @@ -25366,10 +25428,88 @@ namespace sol { return s; } + bool supports_gc_mode(gc_mode mode) const noexcept { +#if SOL_LUA_VERSION >= 504 + // supports all modes + (void)mode; + return true; +#endif + return mode == gc_mode::default; + } + + bool is_gc_on() const { + return lua_gc(lua_state(), LUA_GCISRUNNING, 0) == 1; + } + void collect_garbage() { lua_gc(lua_state(), LUA_GCCOLLECT, 0); } + void collect_gc() { + collect_garbage(); + } + + bool step_gc(int step_size_kilobytes) { + // THOUGHT: std::chrono-alikes to map "kilobyte size" here...? + // Make it harder to give MB or KB to a B parameter...? + // Probably overkill for now. +#if SOL_LUA_VERSION >= 504 + // The manual implies that this function is almost always successful... + // is it?? It could depend on the GC mode... + return lua_gc(lua_state(), LUA_GCSTEP, step_size_kilobytes) != 0; +#else + return lua_gc(lua_state(), LUA_GCSTEP, step_size_kilobytes) == 1; +#endif + } + + void restart_gc() { + lua_gc(lua_state(), LUA_GCRESTART, 0); + } + + void stop_gc() { + lua_gc(lua_state(), LUA_GCSTOP, 0); + } + + // Returns the old GC mode. Check support using the supports_gc_mode function. + gc_mode change_gc_mode_incremental(int pause, int step_multiplier, int step_byte_size) { + // "What the fuck does any of this mean??" + // http://www.lua.org/manual/5.4/manual.html#2.5.1 + + // THOUGHT: std::chrono-alikes to map "byte size" here...? + // Make it harder to give MB or KB to a B parameter...? + // Probably overkill for now. +#if SOL_LUA_VERSION >= 504 + int old_mode = lua_gc(lua_state(), LUA_GCINC, pause, step_multiplier, step_byte_size); + if (old_mode == LUA_GCGEN) { + return gc_mode::generational; + } + else if (old_mode == LUA_GCINC) { + return gc_mode::incremental; + } +#else + lua_gc(lua_state(), LUA_GCSETPAUSE, pause); + lua_gc(lua_state(), LUA_GCSETSTEPMUL, step_multiplier); + (void)step_byte_size; // means nothing in older versions +#endif + return gc_mode::default; + } + + // Returns the old GC mode. Check support using the supports_gc_mode function. + gc_mode change_gc_mode_generational(int minor_multiplier, int major_multiplier) { +#if SOL_LUA_VERSION >= 504 + // "What does this shit mean?" + // http://www.lua.org/manual/5.4/manual.html#2.5.2 + int old_mode = lua_gc(lua_state(), LUA_GCGEN, minor_multiplier, major_multiplier); + if (old_mode == LUA_GCGEN) { + return gc_mode::generational; + } + else if (old_mode == LUA_GCINC) { + return gc_mode::incremental; + } +#endif + return gc_mode::default; + } + operator lua_State*() const { return lua_state(); } @@ -26275,7 +26415,8 @@ namespace sol { using base_t = std::vector; public: - basic_variadic_results() : base_t() {} + basic_variadic_results() : base_t() { + } basic_variadic_results(unsafe_function_result fr) : base_t() { this->reserve(fr.return_count()); @@ -26306,10 +26447,10 @@ namespace sol { }; template - struct is_container> : std::false_type {}; + struct is_container> : std::false_type { }; template <> - struct is_container : std::false_type {}; + struct is_container : std::false_type { }; namespace stack { template