mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Heavily improve usage of Preprocessor checks
- Weed out bugs in the numeric checking implementation - Solve the problem with load_result/protected_function_result/unsafe_function_result being copyable and thus amenable to explosions. Fixes #995. - Resolve the warning in sol::readonly. Fixes #1000. - Looke into #1014. Not sure I can help there, honestly; looks like a mix up of multiply-loaded libraries and mixing the two.
This commit is contained in:
parent
0e1aafe4df
commit
000fa31809
|
@ -34,7 +34,7 @@ two_things sol_lua_get(sol::types<two_things>, lua_State* L, int index, sol::sta
|
||||||
return two_things { a, b };
|
return two_things { a, b };
|
||||||
}
|
}
|
||||||
|
|
||||||
int sol_lua_push(sol::types<two_things>, lua_State* L, const two_things& things) {
|
int sol_lua_push(lua_State* L, const two_things& things) {
|
||||||
int amount = sol::stack::push(L, things.a);
|
int amount = sol::stack::push(L, things.a);
|
||||||
// amount will be 1: int pushes 1 item
|
// amount will be 1: int pushes 1 item
|
||||||
amount += sol::stack::push(L, things.b);
|
amount += sol::stack::push(L, things.b);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <sol/version.hpp>
|
#include <sol/version.hpp>
|
||||||
#include <sol/compatibility/lua_version.hpp>
|
#include <sol/compatibility/lua_version.hpp>
|
||||||
|
|
||||||
#if !defined(SOL_NO_COMPAT) || !(SOL_NO_COMPAT)
|
#if SOL_IS_ON(SOL_USE_COMPATIBILITY_LAYER_I_)
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_CXX_LUA_I_) || SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_)
|
#if SOL_IS_ON(SOL_USE_CXX_LUA_I_) || SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_)
|
||||||
#ifndef COMPAT53_LUA_CPP
|
#ifndef COMPAT53_LUA_CPP
|
||||||
|
@ -46,6 +46,6 @@
|
||||||
#include <sol/compatibility/compat-5.3.h>
|
#include <sol/compatibility/compat-5.3.h>
|
||||||
#include <sol/compatibility/compat-5.4.h>
|
#include <sol/compatibility/compat-5.4.h>
|
||||||
|
|
||||||
#endif // SOL_NO_COMPAT
|
#endif
|
||||||
|
|
||||||
#endif // SOL_COMPATIBILITY_HPP
|
#endif // SOL_COMPATIBILITY_HPP
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
#elif defined(LUAJIT_VERSION)
|
#elif defined(LUAJIT_VERSION)
|
||||||
#define SOL_USE_LUAJIT_I_ SOL_OFF
|
#define SOL_USE_LUAJIT_I_ SOL_OFF
|
||||||
#else
|
#else
|
||||||
#define SOL_USE_LUAJIT_I_ SOL_OFF
|
#define SOL_USE_LUAJIT_I_ SOL_DEFAULT_OFF
|
||||||
#endif // luajit
|
#endif // luajit
|
||||||
|
|
||||||
#if SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_)
|
#if SOL_IS_ON(SOL_USE_CXX_LUAJIT_I_)
|
||||||
|
@ -71,9 +71,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MOONJIT_VERSION)
|
#if defined(MOONJIT_VERSION)
|
||||||
#define SOL_MOONJIT_I_ SOL_ON
|
#define SOL_USE_MOONJIT_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_MOONJIT_I_ SOL_OFF
|
#define SOL_USE_MOONJIT_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(SOL_LUA_VERSION)
|
#if !defined(SOL_LUA_VERSION)
|
||||||
|
@ -98,10 +98,18 @@
|
||||||
|
|
||||||
// Exception safety / propagation, according to Lua information
|
// Exception safety / propagation, according to Lua information
|
||||||
// and user defines. Note this can sometimes change based on version information...
|
// and user defines. Note this can sometimes change based on version information...
|
||||||
#if defined(SOL_EXCEPTIONS_ALWAYS_UNSAFE) && (SOL_EXCEPTIONS_ALWAYS_UNSAFE != 0)
|
#if defined(SOL_EXCEPTIONS_ALWAYS_UNSAFE)
|
||||||
|
#if (SOL_EXCEPTIONS_ALWAYS_UNSAFE != 0)
|
||||||
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
|
||||||
#elif defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && (SOL_EXCEPTIONS_SAFE_PROPAGATION != 0)
|
#else
|
||||||
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_ON
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_ON
|
||||||
|
#endif
|
||||||
|
#elif defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
||||||
|
#if (SOL_EXCEPTIONS_SAFE_PROPAGATION != 0)
|
||||||
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
|
||||||
|
#endif
|
||||||
#elif SOL_LUAJIT_VERSION_I_ >= 20100
|
#elif SOL_LUAJIT_VERSION_I_ >= 20100
|
||||||
// LuaJIT 2.1.0-beta3 and better have exception support locked in for all platforms (mostly)
|
// LuaJIT 2.1.0-beta3 and better have exception support locked in for all platforms (mostly)
|
||||||
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON
|
||||||
|
@ -116,9 +124,37 @@
|
||||||
// otherwise, there is no exception safety for
|
// otherwise, there is no exception safety for
|
||||||
// shoving exceptions through Lua and errors should
|
// shoving exceptions through Lua and errors should
|
||||||
// always be serialized
|
// always be serialized
|
||||||
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
|
#define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_OFF
|
||||||
#endif // LuaJIT beta 02.01.00 have better exception handling on all platforms since beta3
|
#endif // LuaJIT beta 02.01.00 have better exception handling on all platforms since beta3
|
||||||
|
|
||||||
|
#if defined(SOL_LUAJIT_USE_EXCEPTION_TRAMPOLINE)
|
||||||
|
#if (SOL_LUAJIT_USE_EXCEPTION_TRAMPOLINE != 0)
|
||||||
|
#define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_OFF
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS_I_) && SOL_IS_ON(SOL_USE_LUAJIT_I_)
|
||||||
|
#define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_DEFAULT_OFF
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SOL_LUAL_STREAM_HAS_CLOSE_FUNCTION)
|
||||||
|
#if (SOL_LUAL_STREAM_HAS_CLOSE_FUNCTION != 0)
|
||||||
|
#define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_OFF
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#if SOL_IS_OFF(SOL_USE_LUAJIT_I_) && (SOL_LUA_VERSION > 501)
|
||||||
|
#define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_DEFAULT_OFF
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#endif // SOL_COMPATIBILITY_VERSION_HPP
|
#endif // SOL_COMPATIBILITY_VERSION_HPP
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace sol {
|
||||||
call_status stats = call_status::yielded;
|
call_status stats = call_status::yielded;
|
||||||
|
|
||||||
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) {
|
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) {
|
||||||
#if SOL_LUA_VERSION >= 504
|
#if SOL_LUA_VESION_I_ >= 504
|
||||||
int nresults;
|
int nresults;
|
||||||
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount), &nresults));
|
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount), &nresults));
|
||||||
#else
|
#else
|
||||||
|
@ -91,7 +91,10 @@ namespace sol {
|
||||||
using base_t::lua_state;
|
using base_t::lua_state;
|
||||||
|
|
||||||
basic_coroutine() = default;
|
basic_coroutine() = default;
|
||||||
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>
|
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>
|
||||||
basic_coroutine(T&& r) noexcept
|
basic_coroutine(T&& r) noexcept
|
||||||
: base_t(std::forward<T>(r)), error_handler(detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
: base_t(std::forward<T>(r)), error_handler(detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
||||||
|
@ -112,11 +115,9 @@ namespace sol {
|
||||||
basic_coroutine(basic_function<base_t>&& b)
|
basic_coroutine(basic_function<base_t>&& b)
|
||||||
: basic_coroutine(std::move(b), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(b.lua_state())) {
|
: basic_coroutine(std::move(b), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(b.lua_state())) {
|
||||||
}
|
}
|
||||||
basic_coroutine(const basic_function<base_t>& b, handler_t eh)
|
basic_coroutine(const basic_function<base_t>& b, handler_t eh) : base_t(b), error_handler(std::move(eh)) {
|
||||||
: base_t(b), error_handler(std::move(eh)) {
|
|
||||||
}
|
}
|
||||||
basic_coroutine(basic_function<base_t>&& b, handler_t eh)
|
basic_coroutine(basic_function<base_t>&& b, handler_t eh) : base_t(std::move(b)), error_handler(std::move(eh)) {
|
||||||
: base_t(std::move(b)), error_handler(std::move(eh)) {
|
|
||||||
}
|
}
|
||||||
basic_coroutine(const stack_reference& r)
|
basic_coroutine(const stack_reference& r)
|
||||||
: basic_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
: basic_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
||||||
|
@ -124,11 +125,9 @@ namespace sol {
|
||||||
basic_coroutine(stack_reference&& r)
|
basic_coroutine(stack_reference&& r)
|
||||||
: basic_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
: basic_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
|
||||||
}
|
}
|
||||||
basic_coroutine(const stack_reference& r, handler_t eh)
|
basic_coroutine(const stack_reference& r, handler_t eh) : basic_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
|
||||||
: basic_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
|
|
||||||
}
|
}
|
||||||
basic_coroutine(stack_reference&& r, handler_t eh)
|
basic_coroutine(stack_reference&& r, handler_t eh) : basic_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
|
||||||
: basic_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Super>
|
template <typename Super>
|
||||||
|
@ -139,9 +138,9 @@ namespace sol {
|
||||||
basic_coroutine(proxy_base<Super>&& p)
|
basic_coroutine(proxy_base<Super>&& p)
|
||||||
: basic_coroutine(std::move(p), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(p.lua_state())) {
|
: basic_coroutine(std::move(p), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(p.lua_state())) {
|
||||||
}
|
}
|
||||||
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>
|
template <typename Proxy, typename Handler,
|
||||||
basic_coroutine(Proxy&& p, Handler&& eh)
|
meta::enable<std::is_base_of<proxy_base_tag, meta::unqualified_t<Proxy>>, meta::neg<is_lua_index<meta::unqualified_t<Handler>>>> = meta::enabler>
|
||||||
: basic_coroutine(detail::force_cast<base_t>(p), std::forward<Handler>(eh)) {
|
basic_coroutine(Proxy&& p, Handler&& eh) : basic_coroutine(detail::force_cast<base_t>(p), std::forward<Handler>(eh)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
|
@ -149,8 +148,7 @@ namespace sol {
|
||||||
: basic_coroutine(L, std::forward<T>(r), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_coroutine(L, std::forward<T>(r), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_coroutine(lua_State* L, T&& r, handler_t eh)
|
basic_coroutine(lua_State* L, T&& r, handler_t eh) : base_t(L, std::forward<T>(r)), error_handler(std::move(eh)) {
|
||||||
: base_t(L, std::forward<T>(r)), error_handler(std::move(eh)) {
|
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
|
@ -158,15 +156,13 @@ namespace sol {
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_coroutine(lua_nil_t n)
|
basic_coroutine(lua_nil_t n) : base_t(n), error_handler(n) {
|
||||||
: base_t(n), error_handler(n) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_coroutine(lua_State* L, int index = -1)
|
basic_coroutine(lua_State* L, int index = -1)
|
||||||
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_coroutine(lua_State* L, int index, handler_t eh)
|
basic_coroutine(lua_State* L, int index, handler_t eh) : base_t(L, index), error_handler(std::move(eh)) {
|
||||||
: base_t(L, index), error_handler(std::move(eh)) {
|
|
||||||
#ifdef SOL_SAFE_REFERENCES
|
#ifdef SOL_SAFE_REFERENCES
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_coroutine>(L, index, handler);
|
stack::check<basic_coroutine>(L, index, handler);
|
||||||
|
@ -175,8 +171,7 @@ namespace sol {
|
||||||
basic_coroutine(lua_State* L, absolute_index index)
|
basic_coroutine(lua_State* L, absolute_index index)
|
||||||
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_coroutine(lua_State* L, absolute_index index, handler_t eh)
|
basic_coroutine(lua_State* L, absolute_index index, handler_t eh) : base_t(L, index), error_handler(std::move(eh)) {
|
||||||
: base_t(L, index), error_handler(std::move(eh)) {
|
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_coroutine>(L, index, handler);
|
stack::check<basic_coroutine>(L, index, handler);
|
||||||
|
@ -185,8 +180,7 @@ namespace sol {
|
||||||
basic_coroutine(lua_State* L, raw_index index)
|
basic_coroutine(lua_State* L, raw_index index)
|
||||||
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_coroutine(lua_State* L, raw_index index, handler_t eh)
|
basic_coroutine(lua_State* L, raw_index index, handler_t eh) : base_t(L, index), error_handler(std::move(eh)) {
|
||||||
: base_t(L, index), error_handler(std::move(eh)) {
|
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_coroutine>(L, index, handler);
|
stack::check<basic_coroutine>(L, index, handler);
|
||||||
|
@ -195,8 +189,7 @@ namespace sol {
|
||||||
basic_coroutine(lua_State* L, ref_index index)
|
basic_coroutine(lua_State* L, ref_index index)
|
||||||
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
: basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
|
||||||
}
|
}
|
||||||
basic_coroutine(lua_State* L, ref_index index, handler_t eh)
|
basic_coroutine(lua_State* L, ref_index index, handler_t eh) : base_t(L, index), error_handler(std::move(eh)) {
|
||||||
: base_t(L, index), error_handler(std::move(eh)) {
|
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
|
@ -214,8 +207,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool runnable() const noexcept {
|
bool runnable() const noexcept {
|
||||||
return base_t::valid()
|
return base_t::valid() && (status() == call_status::yielded);
|
||||||
&& (status() == call_status::yielded);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator bool() const noexcept {
|
explicit operator bool() const noexcept {
|
||||||
|
|
|
@ -28,15 +28,14 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#if defined(__GNUC__) && defined(__MINGW32__) && (__GNUC__ < 6)
|
#if SOL_IS_ON(SOL_MINGW_CCTYPE_IS_POISONED_I_)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
}
|
}
|
||||||
#endif // MinGW is on some stuff
|
#endif // MinGW is on some stuff
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
|
||||||
namespace sol {
|
namespace sol { namespace detail {
|
||||||
namespace detail {
|
|
||||||
inline constexpr std::array<string_view, 9> removals { { "{anonymous}",
|
inline constexpr std::array<string_view, 9> removals { { "{anonymous}",
|
||||||
"(anonymous namespace)",
|
"(anonymous namespace)",
|
||||||
"public:",
|
"public:",
|
||||||
|
@ -48,7 +47,7 @@ namespace detail {
|
||||||
"`anonymous namespace'" } };
|
"`anonymous namespace'" } };
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
#if SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
|
||||||
inline std::string ctti_get_type_name_from_sig(std::string name) {
|
inline std::string ctti_get_type_name_from_sig(std::string name) {
|
||||||
// cardinal sins from MINGW
|
// cardinal sins from MINGW
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -86,7 +85,7 @@ namespace detail {
|
||||||
inline std::string ctti_get_type_name() {
|
inline std::string ctti_get_type_name() {
|
||||||
return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__);
|
return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__);
|
||||||
}
|
}
|
||||||
#elif defined(_MSC_VER)
|
#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
||||||
inline std::string ctti_get_type_name_from_sig(std::string name) {
|
inline std::string ctti_get_type_name_from_sig(std::string name) {
|
||||||
std::size_t start = name.find("get_type_name");
|
std::size_t start = name.find("get_type_name");
|
||||||
if (start == std::string::npos)
|
if (start == std::string::npos)
|
||||||
|
@ -135,7 +134,9 @@ namespace detail {
|
||||||
|
|
||||||
inline std::string short_demangle_from_type_name(std::string realname) {
|
inline std::string short_demangle_from_type_name(std::string realname) {
|
||||||
// This isn't the most complete but it'll do for now...?
|
// This isn't the most complete but it'll do for now...?
|
||||||
static const std::array<std::string, 10> ops = {{"operator<", "operator<<", "operator<<=", "operator<=", "operator>", "operator>>", "operator>>=", "operator>=", "operator->", "operator->*"}};
|
static const std::array<std::string, 10> ops = {
|
||||||
|
{ "operator<", "operator<<", "operator<<=", "operator<=", "operator>", "operator>>", "operator>>=", "operator>=", "operator->", "operator->*" }
|
||||||
|
};
|
||||||
int level = 0;
|
int level = 0;
|
||||||
std::ptrdiff_t idx = 0;
|
std::ptrdiff_t idx = 0;
|
||||||
for (idx = static_cast<std::ptrdiff_t>(realname.empty() ? 0 : realname.size() - 1); idx > 0; --idx) {
|
for (idx = static_cast<std::ptrdiff_t>(realname.empty() ? 0 : realname.size() - 1); idx > 0; --idx) {
|
||||||
|
@ -186,7 +187,6 @@ namespace detail {
|
||||||
static const std::string d = short_demangle_once<T>();
|
static const std::string d = short_demangle_once<T>();
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
}
|
}} // namespace sol::detail
|
||||||
} // namespace sol::detail
|
|
||||||
|
|
||||||
#endif // SOL_DEMANGLE_HPP
|
#endif // SOL_DEMANGLE_HPP
|
||||||
|
|
|
@ -41,19 +41,15 @@ namespace sol {
|
||||||
basic_environment(basic_environment&&) = default;
|
basic_environment(basic_environment&&) = default;
|
||||||
basic_environment& operator=(const basic_environment&) = default;
|
basic_environment& operator=(const basic_environment&) = default;
|
||||||
basic_environment& operator=(basic_environment&&) = default;
|
basic_environment& operator=(basic_environment&&) = default;
|
||||||
basic_environment(const stack_reference& r)
|
basic_environment(const stack_reference& r) : basic_environment(r.lua_state(), r.stack_index()) {
|
||||||
: basic_environment(r.lua_state(), r.stack_index()) {
|
|
||||||
}
|
}
|
||||||
basic_environment(stack_reference&& r)
|
basic_environment(stack_reference&& r) : basic_environment(r.lua_state(), r.stack_index()) {
|
||||||
: basic_environment(r.lua_state(), r.stack_index()) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_environment(lua_State* L, new_table nt)
|
basic_environment(lua_State* L, new_table nt) : base_t(L, std::move(nt)) {
|
||||||
: base_t(L, std::move(nt)) {
|
|
||||||
}
|
}
|
||||||
template <bool b>
|
template <bool b>
|
||||||
basic_environment(lua_State* L, new_table t, const basic_reference<b>& fallback)
|
basic_environment(lua_State* L, new_table t, const basic_reference<b>& fallback) : basic_environment(L, std::move(t)) {
|
||||||
: basic_environment(L, std::move(t)) {
|
|
||||||
stack_table mt(L, new_table(0, 1));
|
stack_table mt(L, new_table(0, 1));
|
||||||
mt.set(meta_function::index, fallback);
|
mt.set(meta_function::index, fallback);
|
||||||
this->set(metatable_key, mt);
|
this->set(metatable_key, mt);
|
||||||
|
@ -77,24 +73,23 @@ namespace sol {
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
lua_pop(this->lua_state(), 2);
|
lua_pop(this->lua_state(), 2);
|
||||||
}
|
}
|
||||||
basic_environment(lua_State* L, int index = -1)
|
basic_environment(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) {
|
||||||
: base_t(detail::no_safety, L, index) {
|
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_environment>(L, index, handler);
|
stack::check<basic_environment>(L, index, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_environment(lua_State* L, ref_index index)
|
basic_environment(lua_State* L, ref_index index) : base_t(detail::no_safety, L, index) {
|
||||||
: base_t(detail::no_safety, L, index) {
|
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
constructor_handler handler {};
|
constructor_handler handler {};
|
||||||
stack::check<basic_environment>(L, -1, handler);
|
stack::check<basic_environment>(L, -1, handler);
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
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>
|
template <typename T,
|
||||||
basic_environment(T&& r) noexcept
|
meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_environment>>, meta::neg<std::is_same<base_type, stack_reference>>,
|
||||||
: base_t(detail::no_safety, std::forward<T>(r)) {
|
meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
|
basic_environment(T&& r) noexcept : base_t(detail::no_safety, std::forward<T>(r)) {
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
||||||
if (!is_environment<meta::unqualified_t<T>>::value) {
|
if (!is_environment<meta::unqualified_t<T>>::value) {
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
|
@ -103,13 +98,11 @@ namespace sol {
|
||||||
}
|
}
|
||||||
#endif // Safety
|
#endif // Safety
|
||||||
}
|
}
|
||||||
basic_environment(lua_nil_t r) noexcept
|
basic_environment(lua_nil_t r) noexcept : base_t(detail::no_safety, r) {
|
||||||
: base_t(detail::no_safety, r) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
|
||||||
basic_environment(lua_State* L, T&& r) noexcept
|
basic_environment(lua_State* L, T&& r) noexcept : base_t(detail::no_safety, L, std::forward<T>(r)) {
|
||||||
: base_t(detail::no_safety, L, std::forward<T>(r)) {
|
|
||||||
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
#if SOL_IS_ON(SOL_SAFE_REFERENCES_I_)
|
||||||
if (!is_environment<meta::unqualified_t<T>>::value) {
|
if (!is_environment<meta::unqualified_t<T>>::value) {
|
||||||
auto pp = stack::push_pop(*this);
|
auto pp = stack::push_pop(*this);
|
||||||
|
@ -123,7 +116,7 @@ namespace sol {
|
||||||
void set_on(const T& target) const {
|
void set_on(const T& target) const {
|
||||||
lua_State* L = target.lua_state();
|
lua_State* L = target.lua_state();
|
||||||
auto pp = stack::push_pop(target);
|
auto pp = stack::push_pop(target);
|
||||||
#if SOL_LUA_VERSION < 502
|
#if SOL_LUA_VESION_I_ < 502
|
||||||
// Use lua_setfenv
|
// Use lua_setfenv
|
||||||
this->push();
|
this->push();
|
||||||
lua_setfenv(L, -2);
|
lua_setfenv(L, -2);
|
||||||
|
@ -153,11 +146,9 @@ namespace sol {
|
||||||
struct this_environment {
|
struct this_environment {
|
||||||
optional<environment> env;
|
optional<environment> env;
|
||||||
|
|
||||||
this_environment()
|
this_environment() : env(nullopt) {
|
||||||
: env(nullopt) {
|
|
||||||
}
|
}
|
||||||
this_environment(environment e)
|
this_environment(environment e) : env(std::move(e)) {
|
||||||
: env(std::move(e)) {
|
|
||||||
}
|
}
|
||||||
this_environment(const this_environment&) = default;
|
this_environment(const this_environment&) = default;
|
||||||
this_environment(this_environment&&) = default;
|
this_environment(this_environment&&) = default;
|
||||||
|
|
|
@ -39,12 +39,18 @@ namespace sol {
|
||||||
load_status err;
|
load_status err;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
load_result() = default;
|
load_result() noexcept = default;
|
||||||
load_result(lua_State* Ls, int stackindex = -1, int retnum = 0, int popnum = 0, load_status lerr = load_status::ok) noexcept
|
load_result(lua_State* Ls, int stackindex = -1, int retnum = 0, int popnum = 0, load_status lerr = load_status::ok) noexcept
|
||||||
: L(Ls), index(stackindex), returncount(retnum), popcount(popnum), err(lerr) {
|
: L(Ls), index(stackindex), returncount(retnum), popcount(popnum), err(lerr) {
|
||||||
}
|
}
|
||||||
load_result(const load_result&) = default;
|
|
||||||
load_result& operator=(const load_result&) = default;
|
// We do not want anyone to copy these around willy-nilly
|
||||||
|
// Will likely break people, but also will probably get rid of quiet bugs that have
|
||||||
|
// been lurking. (E.g., Vanilla Lua will just quietly discard over-pops and under-pops:
|
||||||
|
// LuaJIT and other Lua engines will implode and segfault at random later times.)
|
||||||
|
load_result(const load_result&) = delete;
|
||||||
|
load_result& operator=(const load_result&) = delete;
|
||||||
|
|
||||||
load_result(load_result&& o) noexcept : L(o.L), index(o.index), returncount(o.returncount), popcount(o.popcount), err(o.err) {
|
load_result(load_result&& o) noexcept : L(o.L), index(o.index), returncount(o.returncount), popcount(o.popcount), err(o.err) {
|
||||||
// Must be manual, otherwise destructor will screw us
|
// Must be manual, otherwise destructor will screw us
|
||||||
// return count being 0 is enough to keep things clean
|
// return count being 0 is enough to keep things clean
|
||||||
|
|
|
@ -54,12 +54,18 @@ namespace sol {
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
|
||||||
protected_function_result() = default;
|
protected_function_result() noexcept = default;
|
||||||
protected_function_result(lua_State* Ls, int idx = -1, int retnum = 0, int popped = 0, call_status pferr = call_status::ok) noexcept
|
protected_function_result(lua_State* Ls, int idx = -1, int retnum = 0, int popped = 0, call_status pferr = call_status::ok) noexcept
|
||||||
: L(Ls), index(idx), returncount(retnum), popcount(popped), err(pferr) {
|
: L(Ls), index(idx), returncount(retnum), popcount(popped), err(pferr) {
|
||||||
}
|
}
|
||||||
protected_function_result(const protected_function_result&) = default;
|
|
||||||
protected_function_result& operator=(const protected_function_result&) = default;
|
// We do not want anyone to copy these around willy-nilly
|
||||||
|
// Will likely break people, but also will probably get rid of quiet bugs that have
|
||||||
|
// been lurking. (E.g., Vanilla Lua will just quietly discard over-pops and under-pops:
|
||||||
|
// LuaJIT and other Lua engines will implode and segfault at random later times.)
|
||||||
|
protected_function_result(const protected_function_result&) = delete;
|
||||||
|
protected_function_result& operator=(const protected_function_result&) = delete;
|
||||||
|
|
||||||
protected_function_result(protected_function_result&& o) noexcept
|
protected_function_result(protected_function_result&& o) noexcept
|
||||||
: L(o.L), index(o.index), returncount(o.returncount), popcount(o.popcount), err(o.err) {
|
: L(o.L), index(o.index), returncount(o.returncount), popcount(o.popcount), err(o.err) {
|
||||||
// Must be manual, otherwise destructor will screw us
|
// Must be manual, otherwise destructor will screw us
|
||||||
|
|
|
@ -68,8 +68,7 @@ namespace sol {
|
||||||
lua_State* L;
|
lua_State* L;
|
||||||
int index;
|
int index;
|
||||||
int count;
|
int count;
|
||||||
push_popper_at(lua_State* luastate, int index = -1, int count = 1)
|
push_popper_at(lua_State* luastate, int index = -1, int count = 1) : L(luastate), index(index), count(count) {
|
||||||
: L(luastate), index(index), count(count) {
|
|
||||||
}
|
}
|
||||||
~push_popper_at() {
|
~push_popper_at() {
|
||||||
remove(L, index, count);
|
remove(L, index, count);
|
||||||
|
@ -80,8 +79,7 @@ namespace sol {
|
||||||
struct push_popper_n {
|
struct push_popper_n {
|
||||||
lua_State* L;
|
lua_State* L;
|
||||||
int t;
|
int t;
|
||||||
push_popper_n(lua_State* luastate, int x)
|
push_popper_n(lua_State* luastate, int x) : L(luastate), t(x) {
|
||||||
: L(luastate), t(x) {
|
|
||||||
}
|
}
|
||||||
push_popper_n(const push_popper_n&) = delete;
|
push_popper_n(const push_popper_n&) = delete;
|
||||||
push_popper_n(push_popper_n&&) = default;
|
push_popper_n(push_popper_n&&) = default;
|
||||||
|
@ -104,9 +102,7 @@ namespace sol {
|
||||||
T t;
|
T t;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
push_popper(T x)
|
push_popper(T x) : t(x), idx(lua_absindex(t.lua_state(), -t.push())) {
|
||||||
: t(x), idx(lua_absindex(t.lua_state(), -t.push())) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int index_of(const Tu&) {
|
int index_of(const Tu&) {
|
||||||
|
@ -167,7 +163,7 @@ namespace sol {
|
||||||
} // namespace stack
|
} // namespace stack
|
||||||
|
|
||||||
inline lua_State* main_thread(lua_State* L, lua_State* backup_if_unsupported = nullptr) {
|
inline lua_State* main_thread(lua_State* L, lua_State* backup_if_unsupported = nullptr) {
|
||||||
#if SOL_LUA_VERSION < 502
|
#if SOL_LUA_VESION_I_ < 502
|
||||||
if (L == nullptr)
|
if (L == nullptr)
|
||||||
return backup_if_unsupported;
|
return backup_if_unsupported;
|
||||||
lua_getglobal(L, detail::default_main_thread_name());
|
lua_getglobal(L, detail::default_main_thread_name());
|
||||||
|
@ -319,8 +315,7 @@ namespace sol {
|
||||||
stateless_reference(const stateless_reference& o) noexcept = delete;
|
stateless_reference(const stateless_reference& o) noexcept = delete;
|
||||||
stateless_reference& operator=(const stateless_reference& r) noexcept = delete;
|
stateless_reference& operator=(const stateless_reference& r) noexcept = delete;
|
||||||
|
|
||||||
stateless_reference(stateless_reference&& o) noexcept
|
stateless_reference(stateless_reference&& o) noexcept : ref(o.ref) {
|
||||||
: ref(o.ref) {
|
|
||||||
o.ref = LUA_NOREF;
|
o.ref = LUA_NOREF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,8 +432,7 @@ namespace sol {
|
||||||
: basic_reference(detail::pick_main_thread<main_only>(L, L), detail::global_, detail::global_) {
|
: basic_reference(detail::pick_main_thread<main_only>(L, L), detail::global_, detail::global_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_reference(lua_State* L, detail::global_tag, detail::global_tag) noexcept
|
basic_reference(lua_State* L, detail::global_tag, detail::global_tag) noexcept : stateless_reference(L, detail::global_), luastate(L) {
|
||||||
: stateless_reference(L, detail::global_), luastate(L) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_reference(lua_State* oL, const basic_reference<!main_only>& o) noexcept : stateless_reference(oL, o), luastate(oL) {
|
basic_reference(lua_State* oL, const basic_reference<!main_only>& o) noexcept : stateless_reference(oL, o), luastate(oL) {
|
||||||
|
@ -458,18 +452,14 @@ namespace sol {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
basic_reference() noexcept = default;
|
basic_reference() noexcept = default;
|
||||||
basic_reference(lua_nil_t) noexcept
|
basic_reference(lua_nil_t) noexcept : basic_reference() {
|
||||||
: basic_reference() {
|
|
||||||
}
|
}
|
||||||
basic_reference(const stack_reference& r) noexcept
|
basic_reference(const stack_reference& r) noexcept : basic_reference(r.lua_state(), r.stack_index()) {
|
||||||
: basic_reference(r.lua_state(), r.stack_index()) {
|
|
||||||
}
|
}
|
||||||
basic_reference(stack_reference&& r) noexcept
|
basic_reference(stack_reference&& r) noexcept : basic_reference(r.lua_state(), r.stack_index()) {
|
||||||
: basic_reference(r.lua_state(), r.stack_index()) {
|
|
||||||
}
|
}
|
||||||
template <bool r_main_only>
|
template <bool r_main_only>
|
||||||
basic_reference(lua_State* L, const basic_reference<r_main_only>& r) noexcept
|
basic_reference(lua_State* L, const basic_reference<r_main_only>& r) noexcept : luastate(detail::pick_main_thread<main_only>(L, L)) {
|
||||||
: luastate(detail::pick_main_thread<main_only>(L, L)) {
|
|
||||||
if (r.ref == LUA_REFNIL) {
|
if (r.ref == LUA_REFNIL) {
|
||||||
ref = LUA_REFNIL;
|
ref = LUA_REFNIL;
|
||||||
return;
|
return;
|
||||||
|
@ -487,8 +477,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool r_main_only>
|
template <bool r_main_only>
|
||||||
basic_reference(lua_State* L, basic_reference<r_main_only>&& r) noexcept
|
basic_reference(lua_State* L, basic_reference<r_main_only>&& r) noexcept : luastate(detail::pick_main_thread<main_only>(L, L)) {
|
||||||
: luastate(detail::pick_main_thread<main_only>(L, L)) {
|
|
||||||
if (r.ref == LUA_REFNIL) {
|
if (r.ref == LUA_REFNIL) {
|
||||||
ref = LUA_REFNIL;
|
ref = LUA_REFNIL;
|
||||||
return;
|
return;
|
||||||
|
@ -507,8 +496,7 @@ namespace sol {
|
||||||
r.luastate = nullptr;
|
r.luastate = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_reference(lua_State* L, const stack_reference& r) noexcept
|
basic_reference(lua_State* L, const stack_reference& r) noexcept : luastate(detail::pick_main_thread<main_only>(L, L)) {
|
||||||
: luastate(detail::pick_main_thread<main_only>(L, L)) {
|
|
||||||
if (lua_state() == nullptr || r.lua_state() == nullptr || r.get_type() == type::none) {
|
if (lua_state() == nullptr || r.lua_state() == nullptr || r.get_type() == type::none) {
|
||||||
ref = LUA_NOREF;
|
ref = LUA_NOREF;
|
||||||
return;
|
return;
|
||||||
|
@ -523,8 +511,7 @@ namespace sol {
|
||||||
r.push(lua_state());
|
r.push(lua_state());
|
||||||
ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
|
ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
|
||||||
}
|
}
|
||||||
basic_reference(lua_State* L, int index = -1) noexcept
|
basic_reference(lua_State* L, int index = -1) noexcept : luastate(detail::pick_main_thread<main_only>(L, L)) {
|
||||||
: luastate(detail::pick_main_thread<main_only>(L, L)) {
|
|
||||||
// use L to stick with that state's execution stack
|
// use L to stick with that state's execution stack
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
||||||
luaL_checkstack(L, 1, "not enough Lua stack space to push this reference value");
|
luaL_checkstack(L, 1, "not enough Lua stack space to push this reference value");
|
||||||
|
@ -532,13 +519,11 @@ namespace sol {
|
||||||
lua_pushvalue(L, index);
|
lua_pushvalue(L, index);
|
||||||
ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
}
|
}
|
||||||
basic_reference(lua_State* L, ref_index index) noexcept
|
basic_reference(lua_State* L, ref_index index) noexcept : luastate(detail::pick_main_thread<main_only>(L, L)) {
|
||||||
: luastate(detail::pick_main_thread<main_only>(L, L)) {
|
|
||||||
lua_rawgeti(lua_state(), LUA_REGISTRYINDEX, index.index);
|
lua_rawgeti(lua_state(), LUA_REGISTRYINDEX, index.index);
|
||||||
ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
|
ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
|
||||||
}
|
}
|
||||||
basic_reference(lua_State* L, lua_nil_t) noexcept
|
basic_reference(lua_State* L, lua_nil_t) noexcept : luastate(detail::pick_main_thread<main_only>(L, L)) {
|
||||||
: luastate(detail::pick_main_thread<main_only>(L, L)) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~basic_reference() noexcept {
|
~basic_reference() noexcept {
|
||||||
|
@ -547,12 +532,10 @@ namespace sol {
|
||||||
deref();
|
deref();
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_reference(const basic_reference& o) noexcept
|
basic_reference(const basic_reference& o) noexcept : stateless_reference(o.copy()), luastate(o.lua_state()) {
|
||||||
: stateless_reference(o.copy()), luastate(o.lua_state()) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_reference(basic_reference&& o) noexcept
|
basic_reference(basic_reference&& o) noexcept : stateless_reference(std::move(o)), luastate(o.lua_state()) {
|
||||||
: stateless_reference(std::move(o)), luastate(o.lua_state()) {
|
|
||||||
o.luastate = nullptr;
|
o.luastate = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,24 +22,25 @@
|
||||||
#ifndef SOL_HPP
|
#ifndef SOL_HPP
|
||||||
#define SOL_HPP
|
#define SOL_HPP
|
||||||
|
|
||||||
#if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER)
|
#include <sol/version.hpp>
|
||||||
#define SOL_INSIDE_UNREAL
|
|
||||||
|
#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE_I_)
|
||||||
#ifdef check
|
#ifdef check
|
||||||
#pragma push_macro("check")
|
#pragma push_macro("check")
|
||||||
#undef check
|
#undef check
|
||||||
#endif
|
#endif
|
||||||
#endif // Unreal Engine 4 Bullshit
|
#endif // Unreal Engine 4 Bullshit
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if SOL_IS_ON(SOL_COMPILER_GCC_I_)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wshadow"
|
#pragma GCC diagnostic ignored "-Wshadow"
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
#pragma GCC diagnostic ignored "-Wconversion"
|
||||||
#if __GNUC__ > 6
|
#if __GNUC__ > 6
|
||||||
#pragma GCC diagnostic ignored "-Wnoexcept-type"
|
#pragma GCC diagnostic ignored "-Wnoexcept-type"
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__clang__)
|
#elif SOL_IS_ON(SOL_COMPILER_CLANG_I_)
|
||||||
// we'll just let this alone for now
|
// we'll just let this alone for now
|
||||||
#elif defined _MSC_VER
|
#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4505) // unreferenced local function has been removed GEE THANKS
|
#pragma warning(disable : 4505) // unreferenced local function has been removed GEE THANKS
|
||||||
#endif // clang++ vs. g++ vs. VC++
|
#endif // clang++ vs. g++ vs. VC++
|
||||||
|
@ -63,13 +64,13 @@
|
||||||
#include <sol/variadic_results.hpp>
|
#include <sol/variadic_results.hpp>
|
||||||
#include <sol/lua_value.hpp>
|
#include <sol/lua_value.hpp>
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if SOL_IS_ON(SOL_COMPILER_GCC_I_)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#elif defined _MSC_VER
|
#elif SOL_IS_ON(SOL_COMPILER_VCXX_I_)
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif // g++
|
#endif // g++
|
||||||
|
|
||||||
#if defined(SOL_INSIDE_UNREAL)
|
#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE_I_)
|
||||||
#undef check
|
#undef check
|
||||||
#pragma pop_macro("check")
|
#pragma pop_macro("check")
|
||||||
#endif // Unreal Engine 4 Bullshit
|
#endif // Unreal Engine 4 Bullshit
|
||||||
|
|
|
@ -272,7 +272,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void luajit_exception_handler(lua_State* L, int (*handler)(lua_State*, lua_CFunction) = detail::c_trampoline) {
|
inline void luajit_exception_handler(lua_State* L, int (*handler)(lua_State*, lua_CFunction) = detail::c_trampoline) {
|
||||||
#if defined(SOL_LUAJIT) && (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !(SOL_EXCEPTIONS_SAFE_PROPAGATION))
|
#if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_)
|
||||||
if (L == nullptr) {
|
if (L == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void luajit_exception_off(lua_State* L) {
|
inline void luajit_exception_off(lua_State* L) {
|
||||||
#if defined(SOL_LUAJIT)
|
#if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_)
|
||||||
if (L == nullptr) {
|
if (L == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace sol { namespace stack {
|
||||||
return stack_detail::unchecked_get<T>(L, index, tracking);
|
return stack_detail::unchecked_get<T>(L, index, tracking);
|
||||||
}
|
}
|
||||||
else if constexpr ((std::is_integral_v<T> || std::is_same_v<T, lua_Integer>)&&!std::is_same_v<T, bool>) {
|
else if constexpr ((std::is_integral_v<T> || std::is_same_v<T, lua_Integer>)&&!std::is_same_v<T, bool>) {
|
||||||
#if SOL_LUA_VERSION >= 503
|
#if SOL_LUA_VESION_I_ >= 503
|
||||||
if (lua_isinteger(L, index) != 0) {
|
if (lua_isinteger(L, index) != 0) {
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
return static_cast<T>(lua_tointeger(L, index));
|
return static_cast<T>(lua_tointeger(L, index));
|
||||||
|
@ -67,7 +67,7 @@ namespace sol { namespace stack {
|
||||||
int isnum = 0;
|
int isnum = 0;
|
||||||
const lua_Number value = lua_tonumberx(L, index, &isnum);
|
const lua_Number value = lua_tonumberx(L, index, &isnum);
|
||||||
if (isnum != 0) {
|
if (isnum != 0) {
|
||||||
#if (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION)
|
#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_)
|
||||||
const auto integer_value = llround(value);
|
const auto integer_value = llround(value);
|
||||||
if (static_cast<lua_Number>(integer_value) == value) {
|
if (static_cast<lua_Number>(integer_value) == value) {
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
|
|
|
@ -105,8 +105,10 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_integral_v<T> || std::is_same_v<T, lua_Integer>) {
|
else if constexpr (std::is_integral_v<T> || std::is_same_v<T, lua_Integer>) {
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
#if SOL_LUA_VERSION >= 503
|
#if SOL_LUA_VESION_I_ >= 503
|
||||||
|
// Lua 5.3 and greater checks for numeric precision
|
||||||
#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_)
|
#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_)
|
||||||
|
// imprecise, sloppy conversions
|
||||||
int isnum = 0;
|
int isnum = 0;
|
||||||
lua_tointegerx(L, index, &isnum);
|
lua_tointegerx(L, index, &isnum);
|
||||||
const bool success = isnum != 0;
|
const bool success = isnum != 0;
|
||||||
|
@ -114,8 +116,8 @@ namespace sol { namespace stack {
|
||||||
// expected type, actual type
|
// expected type, actual type
|
||||||
handler(L, index, type::number, type_of(L, index), detail::not_a_number_or_number_string_integral);
|
handler(L, index, type::number, type_of(L, index), detail::not_a_number_or_number_string_integral);
|
||||||
}
|
}
|
||||||
#elif (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION)
|
#elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_)
|
||||||
// this check is precise, does not convert
|
// this check is precise, do not convert
|
||||||
if (lua_isinteger(L, index) == 1) {
|
if (lua_isinteger(L, index) == 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -125,16 +127,18 @@ namespace sol { namespace stack {
|
||||||
handler(L, index, type::number, type_of(L, index), detail::not_a_number_integral);
|
handler(L, index, type::number, type_of(L, index), detail::not_a_number_integral);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
// Numerics are neither safe nor string-convertible
|
||||||
type t = type_of(L, index);
|
type t = type_of(L, index);
|
||||||
const bool success = t == type::number;
|
const bool success = t == type::number;
|
||||||
#endif // If numbers are enabled, use the imprecise check
|
#endif
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// expected type, actual type
|
// expected type, actual type
|
||||||
handler(L, index, type::number, type_of(L, index), detail::not_a_number);
|
handler(L, index, type::number, type_of(L, index), detail::not_a_number);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
#else
|
#else
|
||||||
#if !defined(SOL_STRINGS_ARE_NUMBERS) || !SOL_STRINGS_ARE_NUMBERS
|
// Lua 5.2 and below checks
|
||||||
|
#if SOL_IS_OFF(SOL_STRINGS_ARE_NUMBERS_I_)
|
||||||
// must pre-check, because it will convert
|
// must pre-check, because it will convert
|
||||||
type t = type_of(L, index);
|
type t = type_of(L, index);
|
||||||
if (t != type::number) {
|
if (t != type::number) {
|
||||||
|
@ -143,7 +147,8 @@ namespace sol { namespace stack {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif // Do not allow strings to be numbers
|
#endif // Do not allow strings to be numbers
|
||||||
#if (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION)
|
|
||||||
|
#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_)
|
||||||
int isnum = 0;
|
int isnum = 0;
|
||||||
const lua_Number v = lua_tonumberx(L, index, &isnum);
|
const lua_Number v = lua_tonumberx(L, index, &isnum);
|
||||||
const bool success = isnum != 0 && static_cast<lua_Number>(llround(v)) == v;
|
const bool success = isnum != 0 && static_cast<lua_Number>(llround(v)) == v;
|
||||||
|
@ -151,17 +156,17 @@ namespace sol { namespace stack {
|
||||||
const bool success = true;
|
const bool success = true;
|
||||||
#endif // Safe numerics and number precision checking
|
#endif // Safe numerics and number precision checking
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// expected type, actual type
|
// Use defines to provide a better error message!
|
||||||
#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_)
|
#if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS_I_)
|
||||||
handler(L, index, type::number, type_of(L, index), detail::not_a_number_or_number_string);
|
handler(L, index, type::number, type_of(L, index), detail::not_a_number_or_number_string);
|
||||||
#elif (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS)
|
#elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_)
|
||||||
handler(L, index, type::number, t, detail::not_a_number_or_number_string);
|
handler(L, index, type::number, t, detail::not_a_number_or_number_string);
|
||||||
#else
|
#else
|
||||||
handler(L, index, type::number, t, detail::not_a_number);
|
handler(L, index, type::number, t, detail::not_a_number);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
#endif // Lua Version 5.3 versus others
|
#endif
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_floating_point_v<T> || std::is_same_v<T, lua_Number>) {
|
else if constexpr (std::is_floating_point_v<T> || std::is_same_v<T, lua_Number>) {
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace sol { namespace stack {
|
||||||
template <typename T, bool global, bool raw, typename>
|
template <typename T, bool global, bool raw, typename>
|
||||||
struct field_getter {
|
struct field_getter {
|
||||||
static constexpr int default_table_index = meta::conditional_t < meta::is_c_str_v<T>
|
static constexpr int default_table_index = meta::conditional_t < meta::is_c_str_v<T>
|
||||||
#if SOL_LUA_VERSION >= 503
|
#if SOL_LUA_VESION_I_ >= 503
|
||||||
|| (std::is_integral_v<T> && !std::is_same_v<T, bool>)
|
|| (std::is_integral_v<T> && !std::is_same_v<T, bool>)
|
||||||
#endif // integer global keys 5.3 or better
|
#endif // integer global keys 5.3 or better
|
||||||
|| (raw && std::is_void_v<std::remove_pointer_t<T>>),
|
|| (raw && std::is_void_v<std::remove_pointer_t<T>>),
|
||||||
|
@ -48,7 +48,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_same_v<T, env_key_t>) {
|
else if constexpr (std::is_same_v<T, env_key_t>) {
|
||||||
(void)key;
|
(void)key;
|
||||||
#if SOL_LUA_VERSION < 502
|
#if SOL_LUA_VESION_I_ < 502
|
||||||
// Use lua_setfenv
|
// Use lua_setfenv
|
||||||
lua_getfenv(L, tableindex);
|
lua_getfenv(L, tableindex);
|
||||||
#else
|
#else
|
||||||
|
@ -67,7 +67,7 @@ namespace sol { namespace stack {
|
||||||
if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
|
if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
|
||||||
lua_rawgeti(L, tableindex, static_cast<lua_Integer>(key));
|
lua_rawgeti(L, tableindex, static_cast<lua_Integer>(key));
|
||||||
}
|
}
|
||||||
#if SOL_LUA_VERSION >= 502
|
#if SOL_LUA_VESION_I_ >= 502
|
||||||
else if constexpr (std::is_void_v<std::remove_pointer_t<T>>) {
|
else if constexpr (std::is_void_v<std::remove_pointer_t<T>>) {
|
||||||
lua_rawgetp(L, tableindex, key);
|
lua_rawgetp(L, tableindex, key);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ namespace sol { namespace stack {
|
||||||
lua_getfield(L, tableindex, &key[0]);
|
lua_getfield(L, tableindex, &key[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if SOL_LUA_VERSION >= 503
|
#if SOL_LUA_VESION_I_ >= 503
|
||||||
else if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
|
else if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
|
||||||
lua_geti(L, tableindex, static_cast<lua_Integer>(key));
|
lua_geti(L, tableindex, static_cast<lua_Integer>(key));
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ namespace sol { namespace stack {
|
||||||
push(L, std::forward<Value>(value));
|
push(L, std::forward<Value>(value));
|
||||||
lua_rawseti(L, tableindex, static_cast<lua_Integer>(key));
|
lua_rawseti(L, tableindex, static_cast<lua_Integer>(key));
|
||||||
}
|
}
|
||||||
#if SOL_LUA_VERSION >= 502
|
#if SOL_LUA_VESION_I_ >= 502
|
||||||
else if constexpr (std::is_void_v<std::remove_pointer_t<T>>) {
|
else if constexpr (std::is_void_v<std::remove_pointer_t<T>>) {
|
||||||
push(L, std::forward<Value>(value));
|
push(L, std::forward<Value>(value));
|
||||||
lua_rawsetp(L, tableindex, std::forward<Key>(key));
|
lua_rawsetp(L, tableindex, std::forward<Key>(key));
|
||||||
|
@ -192,7 +192,7 @@ namespace sol { namespace stack {
|
||||||
lua_setfield(L, tableindex, &key[0]);
|
lua_setfield(L, tableindex, &key[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if SOL_LUA_VERSION >= 503
|
#if SOL_LUA_VESION_I_ >= 503
|
||||||
else if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
|
else if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
|
||||||
push(L, std::forward<Value>(value));
|
push(L, std::forward<Value>(value));
|
||||||
lua_seti(L, tableindex, static_cast<lua_Integer>(key));
|
lua_seti(L, tableindex, static_cast<lua_Integer>(key));
|
||||||
|
|
|
@ -127,7 +127,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_integral_v<T> || std::is_same_v<T, lua_Integer>) {
|
else if constexpr (std::is_integral_v<T> || std::is_same_v<T, lua_Integer>) {
|
||||||
tracking.use(1);
|
tracking.use(1);
|
||||||
#if SOL_LUA_VERSION >= 503
|
#if SOL_LUA_VESION_I_ >= 503
|
||||||
if (lua_isinteger(L, index) != 0) {
|
if (lua_isinteger(L, index) != 0) {
|
||||||
return static_cast<T>(lua_tointeger(L, index));
|
return static_cast<T>(lua_tointeger(L, index));
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ namespace sol { namespace stack {
|
||||||
int index = lua_absindex(L, relindex);
|
int index = lua_absindex(L, relindex);
|
||||||
T cont;
|
T cont;
|
||||||
std::size_t idx = 0;
|
std::size_t idx = 0;
|
||||||
#if SOL_LUA_VERSION >= 503
|
#if SOL_LUA_VESION_I_ >= 503
|
||||||
// This method is HIGHLY performant over regular table iteration
|
// This method is HIGHLY performant over regular table iteration
|
||||||
// thanks to the Lua API changes in 5.3
|
// thanks to the Lua API changes in 5.3
|
||||||
// Questionable in 5.4
|
// Questionable in 5.4
|
||||||
|
@ -337,7 +337,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
bool isnil = false;
|
bool isnil = false;
|
||||||
for (int vi = 0; vi < lua_size<V>::value; ++vi) {
|
for (int vi = 0; vi < lua_size<V>::value; ++vi) {
|
||||||
#if defined(LUA_NILINTABLE) && LUA_NILINTABLE && SOL_LUA_VERSION >= 600
|
#if defined(LUA_NILINTABLE) && LUA_NILINTABLE && SOL_LUA_VESION_I_ >= 600
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
||||||
luaL_checkstack(L, 1, detail::not_enough_stack_space_generic);
|
luaL_checkstack(L, 1, detail::not_enough_stack_space_generic);
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
|
@ -358,7 +358,7 @@ namespace sol { namespace stack {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if defined(LUA_NILINTABLE) && LUA_NILINTABLE && SOL_LUA_VERSION >= 600
|
#if defined(LUA_NILINTABLE) && LUA_NILINTABLE && SOL_LUA_VESION_I_ >= 600
|
||||||
lua_pop(L, vi);
|
lua_pop(L, vi);
|
||||||
#else
|
#else
|
||||||
lua_pop(L, (vi + 1));
|
lua_pop(L, (vi + 1));
|
||||||
|
@ -368,7 +368,7 @@ namespace sol { namespace stack {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isnil) {
|
if (isnil) {
|
||||||
#if defined(LUA_NILINTABLE) && LUA_NILINTABLE && SOL_LUA_VERSION >= 600
|
#if defined(LUA_NILINTABLE) && LUA_NILINTABLE && SOL_LUA_VESION_I_ >= 600
|
||||||
#else
|
#else
|
||||||
lua_pop(L, lua_size<V>::value);
|
lua_pop(L, lua_size<V>::value);
|
||||||
#endif
|
#endif
|
||||||
|
@ -476,7 +476,7 @@ namespace sol { namespace stack {
|
||||||
C cont;
|
C cont;
|
||||||
auto at = cont.cbefore_begin();
|
auto at = cont.cbefore_begin();
|
||||||
std::size_t idx = 0;
|
std::size_t idx = 0;
|
||||||
#if SOL_LUA_VERSION >= 503
|
#if SOL_LUA_VESION_I_ >= 503
|
||||||
// This method is HIGHLY performant over regular table iteration thanks to the Lua API changes in 5.3
|
// This method is HIGHLY performant over regular table iteration thanks to the Lua API changes in 5.3
|
||||||
for (lua_Integer i = 0;; i += lua_size<V>::value, lua_pop(L, lua_size<V>::value)) {
|
for (lua_Integer i = 0;; i += lua_size<V>::value, lua_pop(L, lua_size<V>::value)) {
|
||||||
if (idx >= cont.max_size()) {
|
if (idx >= cont.max_size()) {
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace sol { namespace stack {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
||||||
luaL_checkstack(L, 1, detail::not_enough_stack_space_environment);
|
luaL_checkstack(L, 1, detail::not_enough_stack_space_environment);
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
#if SOL_LUA_VERSION < 502
|
#if SOL_LUA_VESION_I_ < 502
|
||||||
// Use lua_getfenv
|
// Use lua_getfenv
|
||||||
lua_getfenv(L, index);
|
lua_getfenv(L, index);
|
||||||
#else
|
#else
|
||||||
|
@ -265,13 +265,13 @@ namespace sol { namespace stack {
|
||||||
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
#if SOL_IS_ON(SOL_SAFE_STACK_CHECK_I_)
|
||||||
luaL_checkstack(L, 1, detail::not_enough_stack_space_integral);
|
luaL_checkstack(L, 1, detail::not_enough_stack_space_integral);
|
||||||
#endif // make sure stack doesn't overflow
|
#endif // make sure stack doesn't overflow
|
||||||
#if SOL_LUA_VERSION >= 503
|
#if SOL_LUA_VESION_I_ >= 503
|
||||||
if (stack_detail::integer_value_fits<Tu>(value)) {
|
if (stack_detail::integer_value_fits<Tu>(value)) {
|
||||||
lua_pushinteger(L, static_cast<lua_Integer>(value));
|
lua_pushinteger(L, static_cast<lua_Integer>(value));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif // Lua 5.3 and above
|
#endif // Lua 5.3 and above
|
||||||
#if (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION)
|
#if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS_I_)
|
||||||
if (static_cast<T>(llround(static_cast<lua_Number>(value))) != value) {
|
if (static_cast<T>(llround(static_cast<lua_Number>(value))) != value) {
|
||||||
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
||||||
// Is this really worth it?
|
// Is this really worth it?
|
||||||
|
@ -297,7 +297,7 @@ namespace sol { namespace stack {
|
||||||
luaL_Stream* source { std::forward<Args>(args)... };
|
luaL_Stream* source { std::forward<Args>(args)... };
|
||||||
luaL_Stream* stream = static_cast<luaL_Stream*>(lua_newuserdata(L, sizeof(luaL_Stream)));
|
luaL_Stream* stream = static_cast<luaL_Stream*>(lua_newuserdata(L, sizeof(luaL_Stream)));
|
||||||
stream->f = source->f;
|
stream->f = source->f;
|
||||||
#if !defined(SOL_LUAJIT) && (SOL_LUA_VERSION > 501)
|
#if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_)
|
||||||
stream->closef = source->closef;
|
stream->closef = source->closef;
|
||||||
#endif // LuaJIT and Lua 5.1 and below do not have
|
#endif // LuaJIT and Lua 5.1 and below do not have
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -306,7 +306,7 @@ namespace sol { namespace stack {
|
||||||
luaL_Stream& source(std::forward<Args>(args)...);
|
luaL_Stream& source(std::forward<Args>(args)...);
|
||||||
luaL_Stream* stream = static_cast<luaL_Stream*>(lua_newuserdata(L, sizeof(luaL_Stream)));
|
luaL_Stream* stream = static_cast<luaL_Stream*>(lua_newuserdata(L, sizeof(luaL_Stream)));
|
||||||
stream->f = source.f;
|
stream->f = source.f;
|
||||||
#if !defined(SOL_LUAJIT) && (SOL_LUA_VERSION > 501)
|
#if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_)
|
||||||
stream->closef = source.closef;
|
stream->closef = source.closef;
|
||||||
#endif // LuaJIT and Lua 5.1 and below do not have
|
#endif // LuaJIT and Lua 5.1 and below do not have
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -376,7 +376,7 @@ namespace sol { namespace stack {
|
||||||
int tableindex = lua_gettop(L);
|
int tableindex = lua_gettop(L);
|
||||||
std::size_t index = 1;
|
std::size_t index = 1;
|
||||||
for (const auto& i : cont) {
|
for (const auto& i : cont) {
|
||||||
#if SOL_LUA_VERSION >= 503
|
#if SOL_LUA_VESION_I_ >= 503
|
||||||
int p = is_nested ? stack::push(L, as_nested_ref(i)) : stack::push(L, i);
|
int p = is_nested ? stack::push(L, as_nested_ref(i)) : stack::push(L, i);
|
||||||
for (int pi = 0; pi < p; ++pi) {
|
for (int pi = 0; pi < p; ++pi) {
|
||||||
lua_seti(L, tableindex, static_cast<lua_Integer>(index++));
|
lua_seti(L, tableindex, static_cast<lua_Integer>(index++));
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
inline void register_main_thread(lua_State* L) {
|
inline void register_main_thread(lua_State* L) {
|
||||||
#if SOL_LUA_VERSION < 502
|
#if SOL_LUA_VESION_I_ < 502
|
||||||
if (L == nullptr) {
|
if (L == nullptr) {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
lua_setglobal(L, detail::default_main_thread_name());
|
lua_setglobal(L, detail::default_main_thread_name());
|
||||||
|
@ -120,7 +120,7 @@ namespace sol {
|
||||||
std::string err = "sol: ";
|
std::string err = "sol: ";
|
||||||
err += to_string(result.status());
|
err += to_string(result.status());
|
||||||
err += " error";
|
err += " error";
|
||||||
#if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS)
|
#if SOL_IS_ON(SOL_EXCEPTIONS_I_)
|
||||||
std::exception_ptr eptr = std::current_exception();
|
std::exception_ptr eptr = std::current_exception();
|
||||||
if (eptr) {
|
if (eptr) {
|
||||||
err += " with a ";
|
err += " with a ";
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace sol {
|
||||||
bool is53mod = loaded && !(loaded->is<bool>() && !loaded->as<bool>());
|
bool is53mod = loaded && !(loaded->is<bool>() && !loaded->as<bool>());
|
||||||
if (is53mod)
|
if (is53mod)
|
||||||
return loaded;
|
return loaded;
|
||||||
#if SOL_LUA_VERSION <= 501
|
#if SOL_LUA_VESION_I_ <= 501
|
||||||
auto loaded51 = global.traverse_get<optional<object>>("package", "loaded", key);
|
auto loaded51 = global.traverse_get<optional<object>>("package", "loaded", key);
|
||||||
bool is51mod = loaded51 && !(loaded51->is<bool>() && !loaded51->as<bool>());
|
bool is51mod = loaded51 && !(loaded51->is<bool>() && !loaded51->as<bool>());
|
||||||
if (is51mod)
|
if (is51mod)
|
||||||
|
@ -57,7 +57,7 @@ namespace sol {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void ensure_package(const std::string& key, T&& sr) {
|
void ensure_package(const std::string& key, T&& sr) {
|
||||||
#if SOL_LUA_VERSION <= 501
|
#if SOL_LUA_VESION_I_ <= 501
|
||||||
auto pkg = global["package"];
|
auto pkg = global["package"];
|
||||||
if (!pkg.valid()) {
|
if (!pkg.valid()) {
|
||||||
pkg = create_table_with("loaded", create_table_with(key, sr));
|
pkg = create_table_with("loaded", create_table_with(key, sr));
|
||||||
|
@ -120,7 +120,7 @@ namespace sol {
|
||||||
|
|
||||||
for (auto&& library : libraries) {
|
for (auto&& library : libraries) {
|
||||||
switch (library) {
|
switch (library) {
|
||||||
#if SOL_LUA_VERSION <= 501 && defined(SOL_LUAJIT)
|
#if SOL_LUA_VESION_I_ <= 501 && defined(SOL_LUAJIT)
|
||||||
case lib::coroutine:
|
case lib::coroutine:
|
||||||
#endif // luajit opens coroutine base stuff
|
#endif // luajit opens coroutine base stuff
|
||||||
case lib::base:
|
case lib::base:
|
||||||
|
@ -133,7 +133,7 @@ namespace sol {
|
||||||
break;
|
break;
|
||||||
#if !defined(SOL_LUAJIT)
|
#if !defined(SOL_LUAJIT)
|
||||||
case lib::coroutine:
|
case lib::coroutine:
|
||||||
#if SOL_LUA_VERSION > 501
|
#if SOL_LUA_VESION_I_ > 501
|
||||||
luaL_requiref(L, "coroutine", luaopen_coroutine, 1);
|
luaL_requiref(L, "coroutine", luaopen_coroutine, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
#endif // Lua 5.2+ only
|
#endif // Lua 5.2+ only
|
||||||
|
@ -155,7 +155,7 @@ namespace sol {
|
||||||
#ifdef SOL_LUAJIT
|
#ifdef SOL_LUAJIT
|
||||||
luaL_requiref(L, "bit32", luaopen_bit, 1);
|
luaL_requiref(L, "bit32", luaopen_bit, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
#elif (SOL_LUA_VERSION == 502) || defined(LUA_COMPAT_BITLIB) || defined(LUA_COMPAT_5_2)
|
#elif (SOL_LUA_VESION_I_ == 502) || defined(LUA_COMPAT_BITLIB) || defined(LUA_COMPAT_5_2)
|
||||||
luaL_requiref(L, "bit32", luaopen_bit32, 1);
|
luaL_requiref(L, "bit32", luaopen_bit32, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
#else
|
#else
|
||||||
|
@ -174,7 +174,7 @@ namespace sol {
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
break;
|
break;
|
||||||
case lib::utf8:
|
case lib::utf8:
|
||||||
#if SOL_LUA_VERSION > 502 && !defined(SOL_LUAJIT)
|
#if SOL_LUA_VESION_I_ > 502 && !defined(SOL_LUAJIT)
|
||||||
luaL_requiref(L, "utf8", luaopen_utf8, 1);
|
luaL_requiref(L, "utf8", luaopen_utf8, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
#endif // Lua 5.3+ only
|
#endif // Lua 5.3+ only
|
||||||
|
@ -227,7 +227,7 @@ namespace sol {
|
||||||
// one day Lua 5.1 will die a peaceful death
|
// one day Lua 5.1 will die a peaceful death
|
||||||
// and its old bones will find blissful rest
|
// and its old bones will find blissful rest
|
||||||
auto loaders_proxy = package
|
auto loaders_proxy = package
|
||||||
#if SOL_LUA_VERSION < 502
|
#if SOL_LUA_VESION_I_ < 502
|
||||||
["loaders"]
|
["loaders"]
|
||||||
#else
|
#else
|
||||||
["searchers"]
|
["searchers"]
|
||||||
|
@ -255,7 +255,7 @@ namespace sol {
|
||||||
// one day Lua 5.1 will die a peaceful death
|
// one day Lua 5.1 will die a peaceful death
|
||||||
// and its old bones will find blissful rest
|
// and its old bones will find blissful rest
|
||||||
auto loaders_proxy = package
|
auto loaders_proxy = package
|
||||||
#if SOL_LUA_VERSION < 502
|
#if SOL_LUA_VESION_I_ < 502
|
||||||
["loaders"]
|
["loaders"]
|
||||||
#else
|
#else
|
||||||
["searchers"]
|
["searchers"]
|
||||||
|
@ -638,7 +638,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool supports_gc_mode(gc_mode mode) const noexcept {
|
bool supports_gc_mode(gc_mode mode) const noexcept {
|
||||||
#if SOL_LUA_VERSION >= 504
|
#if SOL_LUA_VESION_I_ >= 504
|
||||||
// supports all modes
|
// supports all modes
|
||||||
(void)mode;
|
(void)mode;
|
||||||
return true;
|
return true;
|
||||||
|
@ -647,7 +647,12 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_gc_on() const {
|
bool is_gc_on() const {
|
||||||
|
#if SOL_LUA_VESION_I_ >= 502
|
||||||
return lua_gc(lua_state(), LUA_GCISRUNNING, 0) == 1;
|
return lua_gc(lua_state(), LUA_GCISRUNNING, 0) == 1;
|
||||||
|
#else
|
||||||
|
// You cannot turn it off in Lua 5.1
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void collect_garbage() {
|
void collect_garbage() {
|
||||||
|
@ -662,7 +667,7 @@ namespace sol {
|
||||||
// THOUGHT: std::chrono-alikes to map "kilobyte size" here...?
|
// THOUGHT: std::chrono-alikes to map "kilobyte size" here...?
|
||||||
// Make it harder to give MB or KB to a B parameter...?
|
// Make it harder to give MB or KB to a B parameter...?
|
||||||
// Probably overkill for now.
|
// Probably overkill for now.
|
||||||
#if SOL_LUA_VERSION >= 504
|
#if SOL_LUA_VESION_I_ >= 504
|
||||||
// The manual implies that this function is almost always successful...
|
// The manual implies that this function is almost always successful...
|
||||||
// is it?? It could depend on the GC mode...
|
// is it?? It could depend on the GC mode...
|
||||||
return lua_gc(lua_state(), LUA_GCSTEP, step_size_kilobytes) != 0;
|
return lua_gc(lua_state(), LUA_GCSTEP, step_size_kilobytes) != 0;
|
||||||
|
@ -687,7 +692,7 @@ namespace sol {
|
||||||
// THOUGHT: std::chrono-alikes to map "byte size" here...?
|
// THOUGHT: std::chrono-alikes to map "byte size" here...?
|
||||||
// Make it harder to give MB or KB to a B parameter...?
|
// Make it harder to give MB or KB to a B parameter...?
|
||||||
// Probably overkill for now.
|
// Probably overkill for now.
|
||||||
#if SOL_LUA_VERSION >= 504
|
#if SOL_LUA_VESION_I_ >= 504
|
||||||
int old_mode = lua_gc(lua_state(), LUA_GCINC, pause, step_multiplier, step_byte_size);
|
int old_mode = lua_gc(lua_state(), LUA_GCINC, pause, step_multiplier, step_byte_size);
|
||||||
if (old_mode == LUA_GCGEN) {
|
if (old_mode == LUA_GCGEN) {
|
||||||
return gc_mode::generational;
|
return gc_mode::generational;
|
||||||
|
@ -705,7 +710,7 @@ namespace sol {
|
||||||
|
|
||||||
// Returns the old GC mode. Check support using the supports_gc_mode function.
|
// 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) {
|
gc_mode change_gc_mode_generational(int minor_multiplier, int major_multiplier) {
|
||||||
#if SOL_LUA_VERSION >= 504
|
#if SOL_LUA_VESION_I_ >= 504
|
||||||
// "What does this shit mean?"
|
// "What does this shit mean?"
|
||||||
// http://www.lua.org/manual/5.4/manual.html#2.5.2
|
// 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);
|
int old_mode = lua_gc(lua_state(), LUA_GCGEN, minor_multiplier, major_multiplier);
|
||||||
|
|
|
@ -72,13 +72,13 @@ namespace sol {
|
||||||
return exfunc(L, std::move(maybe_ex), std::move(what));
|
return exfunc(L, std::move(maybe_ex), std::move(what));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SOL_NO_EXCEPTIONS
|
#if SOL_IS_OFF(SOL_EXCEPTIONS_I_)
|
||||||
template <lua_CFunction f>
|
template <lua_CFunction f>
|
||||||
int static_trampoline(lua_State* L) noexcept {
|
int static_trampoline(lua_State* L) noexcept {
|
||||||
return f(L);
|
return f(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
||||||
template <lua_CFunction_noexcept f>
|
template <lua_CFunction_noexcept f>
|
||||||
int static_trampoline_noexcept(lua_State* L) noexcept {
|
int static_trampoline_noexcept(lua_State* L) noexcept {
|
||||||
return f(L);
|
return f(L);
|
||||||
|
@ -100,8 +100,8 @@ namespace sol {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
inline int impl_static_trampoline(lua_State* L, lua_CFunction f) {
|
inline int lua_cfunction_trampoline(lua_State* L, lua_CFunction f) {
|
||||||
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
#if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS_I_)
|
||||||
return f(L);
|
return f(L);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -117,7 +117,7 @@ namespace sol {
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
call_exception_handler(L, optional<const std::exception&>(e), e.what());
|
call_exception_handler(L, optional<const std::exception&>(e), e.what());
|
||||||
}
|
}
|
||||||
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
#if SOL_IS_OFF(SOL_USE_LUAJIT_I_)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
|
@ -131,37 +131,28 @@ namespace sol {
|
||||||
|
|
||||||
template <lua_CFunction f>
|
template <lua_CFunction f>
|
||||||
int static_trampoline(lua_State* L) {
|
int static_trampoline(lua_State* L) {
|
||||||
return impl_static_trampoline(L, f);
|
return lua_cfunction_trampoline(L, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
||||||
#if 0
|
|
||||||
// impossible: g++/clang++ choke as they think this function is ambiguous:
|
|
||||||
// to fix, wait for template <auto X> and then switch on no-exceptness of the function
|
|
||||||
template <lua_CFunction_noexcept f>
|
|
||||||
int static_trampoline(lua_State* L) noexcept {
|
|
||||||
return f(L);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
template <lua_CFunction_noexcept f>
|
template <lua_CFunction_noexcept f>
|
||||||
int static_trampoline_noexcept(lua_State* L) noexcept {
|
int static_trampoline_noexcept(lua_State* L) noexcept {
|
||||||
return f(L);
|
return f(L);
|
||||||
}
|
}
|
||||||
#endif // impossible
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
template <lua_CFunction f>
|
template <lua_CFunction f>
|
||||||
int static_trampoline_noexcept(lua_State* L) noexcept {
|
int static_trampoline_noexcept(lua_State* L) noexcept {
|
||||||
return f(L);
|
return f(L);
|
||||||
}
|
}
|
||||||
#endif // noexcept lua_CFunction type
|
#endif
|
||||||
|
|
||||||
template <typename Fx, typename... Args>
|
template <typename Fx, typename... Args>
|
||||||
int trampoline(lua_State* L, Fx&& f, Args&&... args) {
|
int trampoline(lua_State* L, Fx&& f, Args&&... args) {
|
||||||
if (meta::bind_traits<meta::unqualified_t<Fx>>::is_noexcept) {
|
if constexpr (meta::bind_traits<meta::unqualified_t<Fx>>::is_noexcept) {
|
||||||
return f(L, std::forward<Args>(args)...);
|
return f(L, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
else {
|
||||||
|
#if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS_I_)
|
||||||
return f(L, std::forward<Args>(args)...);
|
return f(L, std::forward<Args>(args)...);
|
||||||
#else
|
#else
|
||||||
try {
|
try {
|
||||||
|
@ -176,7 +167,7 @@ namespace sol {
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
call_exception_handler(L, optional<const std::exception&>(e), e.what());
|
call_exception_handler(L, optional<const std::exception&>(e), e.what());
|
||||||
}
|
}
|
||||||
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
#if SOL_IS_OFF(SOL_USE_LUAJIT_I_)
|
||||||
// LuaJIT cannot have the catchall when the safe propagation is on
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
||||||
// but LuaJIT will swallow all C++ errors
|
// but LuaJIT will swallow all C++ errors
|
||||||
// if we don't at least catch std::exception ones
|
// if we don't at least catch std::exception ones
|
||||||
|
@ -187,6 +178,7 @@ namespace sol {
|
||||||
return lua_error(L);
|
return lua_error(L);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline int c_trampoline(lua_State* L, lua_CFunction f) {
|
inline int c_trampoline(lua_State* L, lua_CFunction f) {
|
||||||
return trampoline(L, f);
|
return trampoline(L, f);
|
||||||
|
@ -194,28 +186,24 @@ namespace sol {
|
||||||
#endif // Exceptions vs. No Exceptions
|
#endif // Exceptions vs. No Exceptions
|
||||||
|
|
||||||
template <typename F, F fx>
|
template <typename F, F fx>
|
||||||
inline int typed_static_trampoline_raw(std::true_type, lua_State* L) {
|
inline int typed_static_trampoline(lua_State* L) {
|
||||||
|
if constexpr (meta::bind_traits<F>::is_noexcept) {
|
||||||
return static_trampoline_noexcept<fx>(L);
|
return static_trampoline_noexcept<fx>(L);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
template <typename F, F fx>
|
|
||||||
inline int typed_static_trampoline_raw(std::false_type, lua_State* L) {
|
|
||||||
return static_trampoline<fx>(L);
|
return static_trampoline<fx>(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename F, F fx>
|
|
||||||
inline int typed_static_trampoline(lua_State* L) {
|
|
||||||
return typed_static_trampoline_raw<F, fx>(std::integral_constant<bool, meta::bind_traits<F>::is_noexcept>(), L);
|
|
||||||
}
|
}
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
inline void set_default_exception_handler(lua_State* L, exception_handler_function exf = &detail::default_exception_handler) {
|
inline void set_default_exception_handler(lua_State* L, exception_handler_function exf = &detail::default_exception_handler) {
|
||||||
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");
|
static_assert(sizeof(void*) >= sizeof(exception_handler_function),
|
||||||
|
"void* storage is too small to transport the exception handler: please file a bug on the sol2 issue tracker to get this looked at!");
|
||||||
void* storage;
|
void* storage;
|
||||||
std::memcpy(&storage, &exf, sizeof(exception_handler_function));
|
std::memcpy(&storage, &exf, sizeof(exception_handler_function));
|
||||||
lua_pushlightuserdata(L, storage);
|
lua_pushlightuserdata(L, storage);
|
||||||
lua_setglobal(L, detail::default_exception_handler_name());
|
lua_setglobal(L, detail::default_exception_handler_name());
|
||||||
}
|
}
|
||||||
} // sol
|
} // namespace sol
|
||||||
|
|
||||||
#endif // SOL_TRAMPOLINE_HPP
|
#endif // SOL_TRAMPOLINE_HPP
|
||||||
|
|
|
@ -50,20 +50,25 @@ namespace sol {
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
|
||||||
unsafe_function_result() = default;
|
unsafe_function_result() noexcept = default;
|
||||||
unsafe_function_result(lua_State* Ls, int idx = -1, int retnum = 0)
|
unsafe_function_result(lua_State* Ls, int idx = -1, int retnum = 0) noexcept : L(Ls), index(idx), returncount(retnum) {
|
||||||
: L(Ls), index(idx), returncount(retnum) {
|
|
||||||
}
|
}
|
||||||
unsafe_function_result(const unsafe_function_result&) = default;
|
|
||||||
unsafe_function_result& operator=(const unsafe_function_result&) = default;
|
|
||||||
unsafe_function_result(unsafe_function_result&& o)
|
// We do not want anyone to copy these around willy-nilly
|
||||||
: L(o.L), index(o.index), returncount(o.returncount) {
|
// Will likely break people, but also will probably get rid of quiet bugs that have
|
||||||
|
// been lurking. (E.g., Vanilla Lua will just quietly discard over-pops and under-pops:
|
||||||
|
// LuaJIT and other Lua engines will implode and segfault at random later times.)
|
||||||
|
unsafe_function_result(const unsafe_function_result&) = delete;
|
||||||
|
unsafe_function_result& operator=(const unsafe_function_result&) = delete;
|
||||||
|
|
||||||
|
unsafe_function_result(unsafe_function_result&& o) noexcept : L(o.L), index(o.index), returncount(o.returncount) {
|
||||||
// Must be manual, otherwise destructor will screw us
|
// Must be manual, otherwise destructor will screw us
|
||||||
// return count being 0 is enough to keep things clean
|
// return count being 0 is enough to keep things clean
|
||||||
// but will be thorough
|
// but will be thorough
|
||||||
o.abandon();
|
o.abandon();
|
||||||
}
|
}
|
||||||
unsafe_function_result& operator=(unsafe_function_result&& o) {
|
unsafe_function_result& operator=(unsafe_function_result&& o) noexcept {
|
||||||
L = o.L;
|
L = o.L;
|
||||||
index = o.index;
|
index = o.index;
|
||||||
returncount = o.returncount;
|
returncount = o.returncount;
|
||||||
|
|
|
@ -68,6 +68,12 @@
|
||||||
#define SOL_COMPILER_VCXX_I_ SOL_OFF
|
#define SOL_COMPILER_VCXX_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__MINGW32__)
|
||||||
|
#define SOL_COMPILER_FRONTEND_MINGW_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_COMPILER_FRONTEND_MINGW_I_ SOL_OFF
|
||||||
|
#endif
|
||||||
|
|
||||||
#if SIZE_MAX <= 0xFFFFULL
|
#if SIZE_MAX <= 0xFFFFULL
|
||||||
#define SOL_PLATFORM_X16_I_ SOL_ON
|
#define SOL_PLATFORM_X16_I_ SOL_ON
|
||||||
#define SOL_PLATFORM_X86_I_ SOL_OFF
|
#define SOL_PLATFORM_X86_I_ SOL_OFF
|
||||||
|
@ -125,7 +131,7 @@
|
||||||
#define SOL_DEBUG_BUILD_I_ SOL_OFF
|
#define SOL_DEBUG_BUILD_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SOL_DEBUG_BUILD_I_ SOL_OFF
|
#define SOL_DEBUG_BUILD_I_ SOL_DEFAULT_OFF
|
||||||
#endif // We are in a debug mode of some sort
|
#endif // We are in a debug mode of some sort
|
||||||
|
|
||||||
#if defined(SOL_NO_EXCEPTIONS)
|
#if defined(SOL_NO_EXCEPTIONS)
|
||||||
|
@ -147,7 +153,7 @@
|
||||||
#define SOL_EXCEPTIONS_I_ SOL_ON
|
#define SOL_EXCEPTIONS_I_ SOL_ON
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SOL_EXCEPTIONS_I_ SOL_ON
|
#define SOL_EXCEPTIONS_I_ SOL_DEFAULT_ON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,7 +176,7 @@
|
||||||
#define SOL_RTTI_I_ SOL_ON
|
#define SOL_RTTI_I_ SOL_ON
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SOL_EXCEPTIONS_I_ SOL_ON
|
#define SOL_RTTI_I_ SOL_DEFAULT_ON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_NO_THREAD_LOCAL) && (SOL_NO_THREAD_LOCAL != 0)
|
#if defined(SOL_NO_THREAD_LOCAL) && (SOL_NO_THREAD_LOCAL != 0)
|
||||||
|
@ -182,7 +188,7 @@
|
||||||
#if defined(SOL_ALL_SAFETIES_ON) && (SOL_ALL_SAFETIES_ON != 0)
|
#if defined(SOL_ALL_SAFETIES_ON) && (SOL_ALL_SAFETIES_ON != 0)
|
||||||
#define SOL_ALL_SAFETIES_ON_I_ SOL_ON
|
#define SOL_ALL_SAFETIES_ON_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_ALL_SAFETIES_ON_I_ SOL_OFF
|
#define SOL_ALL_SAFETIES_ON_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_SAFE_GETTER) && (SOL_SAFE_GETTER != 0)
|
#if defined(SOL_SAFE_GETTER) && (SOL_SAFE_GETTER != 0)
|
||||||
|
@ -193,7 +199,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_GETTER_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_GETTER_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_GETTER_I_ SOL_OFF
|
#define SOL_SAFE_GETTER_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -205,7 +211,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_USERTYPE_I_ SOL_OFF
|
#define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -217,7 +223,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_REFERENCES_I_ SOL_OFF
|
#define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -230,7 +236,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_OFF
|
#define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -242,7 +248,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_FUNCTION_CALLS_I_ SOL_OFF
|
#define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -254,7 +260,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_PROXIES_I_ SOL_OFF
|
#define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -266,7 +272,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_NUMERICS_I_ SOL_OFF
|
#define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -278,7 +284,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_STACK_CHECK_I_ SOL_OFF
|
#define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -288,10 +294,12 @@
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_)
|
#if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_)
|
||||||
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON
|
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON
|
||||||
|
#elif SOL_IS_ON(SOL_SAFE_NUMERICS_I_)
|
||||||
|
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_ON
|
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_OFF
|
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -302,14 +310,14 @@
|
||||||
#define SOL_STRINGS_ARE_NUMBERS_I_ SOL_OFF
|
#define SOL_STRINGS_ARE_NUMBERS_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SOL_STRINGS_ARE_NUMBERS_I_ SOL_OFF
|
#define SOL_STRINGS_ARE_NUMBERS_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_ENABLE_INTEROP) && (SOL_ENABLE_INTEROP != 0) \
|
#if defined(SOL_ENABLE_INTEROP) && (SOL_ENABLE_INTEROP != 0) \
|
||||||
|| defined(SOL_USE_INTEROP) && (SOL_USE_INTEROP != 0)
|
|| defined(SOL_USE_INTEROP) && (SOL_USE_INTEROP != 0)
|
||||||
#define SOL_USE_INTEROP_I_ SOL_ON
|
#define SOL_USE_INTEROP_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_USE_INTEROP_I_ SOL_OFF
|
#define SOL_USE_INTEROP_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_NO_NIL)
|
#if defined(SOL_NO_NIL)
|
||||||
|
@ -319,7 +327,7 @@
|
||||||
#define SOL_NIL_I_ SOL_ON
|
#define SOL_NIL_I_ SOL_ON
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil)
|
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil)
|
||||||
#define SOL_NIL_I_ SOL_OFF
|
#define SOL_NIL_I_ SOL_DEFAULT_OFF
|
||||||
#else
|
#else
|
||||||
#define SOL_NIL_I_ SOL_DEFAULT_ON
|
#define SOL_NIL_I_ SOL_DEFAULT_ON
|
||||||
#endif
|
#endif
|
||||||
|
@ -413,8 +421,12 @@
|
||||||
#define SOL_FILE_ID_SIZE_I_ 2048
|
#define SOL_FILE_ID_SIZE_I_ 2048
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_PRINT_ERRORS) && (SOL_PRINT_ERRORS != 0)
|
#if defined(SOL_PRINT_ERRORS)
|
||||||
|
#if (SOL_PRINT_ERRORS != 0)
|
||||||
#define SOL_PRINT_ERRORS_I_ SOL_ON
|
#define SOL_PRINT_ERRORS_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_PRINT_ERRORS_I_ SOL_OFF
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_)
|
#if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_)
|
||||||
#define SOL_PRINT_ERRORS_I_ SOL_ON
|
#define SOL_PRINT_ERRORS_I_ SOL_ON
|
||||||
|
@ -526,6 +538,37 @@
|
||||||
#else
|
#else
|
||||||
#define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_OFF
|
#define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(SOL_INSIDE_UNREAL)
|
||||||
|
#if (SOL_INSIDE_UNREAL != 0)
|
||||||
|
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_OFF
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER)
|
||||||
|
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_DEFAULT_OFF
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SOL_NO_COMPAT)
|
||||||
|
#if (SOL_NO_COMPAT != 0)
|
||||||
|
#define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_OFF
|
||||||
|
#else
|
||||||
|
#define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_ON
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_DEFAULT_ON
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SOL_IS_ON(SOL_COMPILER_FRONTEND_MINGW_I_) && defined(__GNUC__) && (__GNUC__ < 6)
|
||||||
|
// MinGW is off its rocker in some places...
|
||||||
|
#define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_OFF
|
||||||
|
#endif
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#endif // SOL_VERSION_HPP
|
#endif // SOL_VERSION_HPP
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// This file was generated with a script.
|
// This file was generated with a script.
|
||||||
// Generated 2020-09-09 00:46:22.609996 UTC
|
// Generated 2020-09-26 10:44:02.641191 UTC
|
||||||
// This header was generated with sol v3.2.1 (revision e4f588d)
|
// This header was generated with sol v3.2.1 (revision e89b6ac)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_CONFIG_HPP
|
#ifndef SOL_SINGLE_CONFIG_HPP
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// This file was generated with a script.
|
// This file was generated with a script.
|
||||||
// Generated 2020-09-09 00:46:22.606997 UTC
|
// Generated 2020-09-26 10:44:02.626193 UTC
|
||||||
// This header was generated with sol v3.2.1 (revision e4f588d)
|
// This header was generated with sol v3.2.1 (revision e89b6ac)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
||||||
|
@ -76,6 +76,12 @@
|
||||||
#define SOL_COMPILER_VCXX_I_ SOL_OFF
|
#define SOL_COMPILER_VCXX_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__MINGW32__)
|
||||||
|
#define SOL_COMPILER_FRONTEND_MINGW_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_COMPILER_FRONTEND_MINGW_I_ SOL_OFF
|
||||||
|
#endif
|
||||||
|
|
||||||
#if SIZE_MAX <= 0xFFFFULL
|
#if SIZE_MAX <= 0xFFFFULL
|
||||||
#define SOL_PLATFORM_X16_I_ SOL_ON
|
#define SOL_PLATFORM_X16_I_ SOL_ON
|
||||||
#define SOL_PLATFORM_X86_I_ SOL_OFF
|
#define SOL_PLATFORM_X86_I_ SOL_OFF
|
||||||
|
@ -132,7 +138,7 @@
|
||||||
#define SOL_DEBUG_BUILD_I_ SOL_OFF
|
#define SOL_DEBUG_BUILD_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SOL_DEBUG_BUILD_I_ SOL_OFF
|
#define SOL_DEBUG_BUILD_I_ SOL_DEFAULT_OFF
|
||||||
#endif // We are in a debug mode of some sort
|
#endif // We are in a debug mode of some sort
|
||||||
|
|
||||||
#if defined(SOL_NO_EXCEPTIONS)
|
#if defined(SOL_NO_EXCEPTIONS)
|
||||||
|
@ -154,7 +160,7 @@
|
||||||
#define SOL_EXCEPTIONS_I_ SOL_ON
|
#define SOL_EXCEPTIONS_I_ SOL_ON
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SOL_EXCEPTIONS_I_ SOL_ON
|
#define SOL_EXCEPTIONS_I_ SOL_DEFAULT_ON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_NO_RTTI)
|
#if defined(SOL_NO_RTTI)
|
||||||
|
@ -176,7 +182,7 @@
|
||||||
#define SOL_RTTI_I_ SOL_ON
|
#define SOL_RTTI_I_ SOL_ON
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SOL_EXCEPTIONS_I_ SOL_ON
|
#define SOL_RTTI_I_ SOL_DEFAULT_ON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_NO_THREAD_LOCAL) && (SOL_NO_THREAD_LOCAL != 0)
|
#if defined(SOL_NO_THREAD_LOCAL) && (SOL_NO_THREAD_LOCAL != 0)
|
||||||
|
@ -188,7 +194,7 @@
|
||||||
#if defined(SOL_ALL_SAFETIES_ON) && (SOL_ALL_SAFETIES_ON != 0)
|
#if defined(SOL_ALL_SAFETIES_ON) && (SOL_ALL_SAFETIES_ON != 0)
|
||||||
#define SOL_ALL_SAFETIES_ON_I_ SOL_ON
|
#define SOL_ALL_SAFETIES_ON_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_ALL_SAFETIES_ON_I_ SOL_OFF
|
#define SOL_ALL_SAFETIES_ON_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_SAFE_GETTER) && (SOL_SAFE_GETTER != 0)
|
#if defined(SOL_SAFE_GETTER) && (SOL_SAFE_GETTER != 0)
|
||||||
|
@ -199,7 +205,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_GETTER_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_GETTER_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_GETTER_I_ SOL_OFF
|
#define SOL_SAFE_GETTER_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -211,7 +217,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_USERTYPE_I_ SOL_OFF
|
#define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -223,7 +229,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_REFERENCES_I_ SOL_OFF
|
#define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -236,7 +242,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_OFF
|
#define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -248,7 +254,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_FUNCTION_CALLS_I_ SOL_OFF
|
#define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -260,7 +266,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_PROXIES_I_ SOL_OFF
|
#define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -272,7 +278,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_NUMERICS_I_ SOL_OFF
|
#define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -284,7 +290,7 @@
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_ON
|
#define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_SAFE_STACK_CHECK_I_ SOL_OFF
|
#define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -294,10 +300,12 @@
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_)
|
#if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_)
|
||||||
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON
|
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON
|
||||||
|
#elif SOL_IS_ON(SOL_SAFE_NUMERICS_I_)
|
||||||
|
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON
|
||||||
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
#elif SOL_IS_ON(SOL_DEBUG_BUILD_I_)
|
||||||
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_ON
|
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_OFF
|
#define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -308,14 +316,14 @@
|
||||||
#define SOL_STRINGS_ARE_NUMBERS_I_ SOL_OFF
|
#define SOL_STRINGS_ARE_NUMBERS_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define SOL_STRINGS_ARE_NUMBERS_I_ SOL_OFF
|
#define SOL_STRINGS_ARE_NUMBERS_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_ENABLE_INTEROP) && (SOL_ENABLE_INTEROP != 0) \
|
#if defined(SOL_ENABLE_INTEROP) && (SOL_ENABLE_INTEROP != 0) \
|
||||||
|| defined(SOL_USE_INTEROP) && (SOL_USE_INTEROP != 0)
|
|| defined(SOL_USE_INTEROP) && (SOL_USE_INTEROP != 0)
|
||||||
#define SOL_USE_INTEROP_I_ SOL_ON
|
#define SOL_USE_INTEROP_I_ SOL_ON
|
||||||
#else
|
#else
|
||||||
#define SOL_USE_INTEROP_I_ SOL_OFF
|
#define SOL_USE_INTEROP_I_ SOL_DEFAULT_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_NO_NIL)
|
#if defined(SOL_NO_NIL)
|
||||||
|
@ -325,7 +333,7 @@
|
||||||
#define SOL_NIL_I_ SOL_ON
|
#define SOL_NIL_I_ SOL_ON
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil)
|
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil)
|
||||||
#define SOL_NIL_I_ SOL_OFF
|
#define SOL_NIL_I_ SOL_DEFAULT_OFF
|
||||||
#else
|
#else
|
||||||
#define SOL_NIL_I_ SOL_DEFAULT_ON
|
#define SOL_NIL_I_ SOL_DEFAULT_ON
|
||||||
#endif
|
#endif
|
||||||
|
@ -419,8 +427,12 @@
|
||||||
#define SOL_FILE_ID_SIZE_I_ 2048
|
#define SOL_FILE_ID_SIZE_I_ 2048
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SOL_PRINT_ERRORS) && (SOL_PRINT_ERRORS != 0)
|
#if defined(SOL_PRINT_ERRORS)
|
||||||
|
#if (SOL_PRINT_ERRORS != 0)
|
||||||
#define SOL_PRINT_ERRORS_I_ SOL_ON
|
#define SOL_PRINT_ERRORS_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_PRINT_ERRORS_I_ SOL_OFF
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_)
|
#if SOL_IS_ON(SOL_ALL_SAFETIES_ON_I_)
|
||||||
#define SOL_PRINT_ERRORS_I_ SOL_ON
|
#define SOL_PRINT_ERRORS_I_ SOL_ON
|
||||||
|
@ -533,6 +545,37 @@
|
||||||
#define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_OFF
|
#define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_OFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(SOL_INSIDE_UNREAL)
|
||||||
|
#if (SOL_INSIDE_UNREAL != 0)
|
||||||
|
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_OFF
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER)
|
||||||
|
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_DEFAULT_OFF
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SOL_NO_COMPAT)
|
||||||
|
#if (SOL_NO_COMPAT != 0)
|
||||||
|
#define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_OFF
|
||||||
|
#else
|
||||||
|
#define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_ON
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_DEFAULT_ON
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SOL_IS_ON(SOL_COMPILER_FRONTEND_MINGW_I_) && defined(__GNUC__) && (__GNUC__ < 6)
|
||||||
|
// MinGW is off its rocker in some places...
|
||||||
|
#define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_ON
|
||||||
|
#else
|
||||||
|
#define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_OFF
|
||||||
|
#endif
|
||||||
|
|
||||||
// end of sol/version.hpp
|
// end of sol/version.hpp
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,20 @@
|
||||||
|
#define SOL_ALL_SAFETIES_ON 1
|
||||||
|
|
||||||
|
#include <sol/sol.hpp>
|
||||||
|
|
||||||
|
struct foo1000 {
|
||||||
|
static void register_into(sol::table& table) {
|
||||||
|
table.new_usertype<foo1000>("foo1000", "id", sol::readonly(&foo1000::foo));
|
||||||
|
}
|
||||||
|
int foo;
|
||||||
|
};
|
||||||
|
|
||||||
|
int regression_1000() {
|
||||||
|
sol::state lua;
|
||||||
|
lua.create_named_table("t");
|
||||||
|
|
||||||
|
sol::table t = lua["t"];
|
||||||
|
foo1000::register_into(t);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,10 +1,11 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
extern int regression_1008();
|
extern int regression_1008();
|
||||||
|
extern int regression_1000();
|
||||||
|
|
||||||
int main(int, char*[]) {
|
int main(int, char*[]) {
|
||||||
using f_ptr = int (*)();
|
using f_ptr = int (*)();
|
||||||
const f_ptr regressions[] = { ®ression_1008 };
|
const f_ptr regressions[] = { ®ression_1008, ®ression_1000 };
|
||||||
const int sizeof_regressions = sizeof(regressions) / sizeof(regressions[0]);
|
const int sizeof_regressions = sizeof(regressions) / sizeof(regressions[0]);
|
||||||
int r = 0;
|
int r = 0;
|
||||||
for (std::size_t i = 0; i < sizeof_regressions; ++i) {
|
for (std::size_t i = 0; i < sizeof_regressions; ++i) {
|
||||||
|
|
|
@ -30,13 +30,12 @@
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T va_func(sol::variadic_args va, T first) {
|
T va_func(sol::variadic_args va, T first) {
|
||||||
|
(void)first;
|
||||||
T s = 0;
|
T s = 0;
|
||||||
for (auto arg : va) {
|
for (auto arg : va) {
|
||||||
T v = arg;
|
T v = arg;
|
||||||
s += v;
|
s += v;
|
||||||
}
|
}
|
||||||
std::cout << first << std::endl;
|
|
||||||
std::cout << s << std::endl;
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,12 +74,12 @@ TEST_CASE("operators/default", "test that generic equality operators and all sor
|
||||||
SECTION("plain") {
|
SECTION("plain") {
|
||||||
// Can only compare identity here
|
// Can only compare identity here
|
||||||
{
|
{
|
||||||
auto result1 = lua.safe_script(
|
sol::optional<sol::error> result1 = lua.safe_script(
|
||||||
"assert(t1 == t1)"
|
"assert(t1 == t1)"
|
||||||
"assert(t2 == t2)"
|
"assert(t2 == t2)"
|
||||||
"assert(t3 == t3)",
|
"assert(t3 == t3)",
|
||||||
sol::script_pass_on_error);
|
sol::script_pass_on_error);
|
||||||
REQUIRE(result1.valid());
|
REQUIRE_FALSE(result1.has_value());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto result1 = lua.safe_script(
|
auto result1 = lua.safe_script(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user