mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
single header file, head forward
This commit is contained in:
parent
6a3b0adf0d
commit
f2667827ca
|
@ -20,8 +20,8 @@
|
|||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2016-08-30 22:16:25.077226 UTC
|
||||
// This header was generated with sol v2.12.2 (revision 5093f61)
|
||||
// Generated 2016-09-01 12:50:16.642849 UTC
|
||||
// This header was generated with sol v2.12.2 (revision 6a3b0ad)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -41,7 +41,7 @@ namespace sol {
|
|||
struct direct_error_tag {};
|
||||
const auto direct_error = direct_error_tag{};
|
||||
} // detail
|
||||
|
||||
|
||||
class error : public std::runtime_error {
|
||||
private:
|
||||
// Because VC++ is a fuccboi
|
||||
|
@ -975,7 +975,7 @@ struct has_overloaded_addressof
|
|||
{
|
||||
template <class X>
|
||||
constexpr static bool has_overload(...) { return false; }
|
||||
|
||||
|
||||
template <class X, size_t S = sizeof(::std::declval<X&>().operator&()) >
|
||||
constexpr static bool has_overload(bool) { return true; }
|
||||
|
||||
|
@ -1098,11 +1098,11 @@ class optional : private OptionalBase<T>
|
|||
{
|
||||
static_assert( !::std::is_same<typename ::std::decay<T>::type, nullopt_t>::value, "bad T" );
|
||||
static_assert( !::std::is_same<typename ::std::decay<T>::type, in_place_t>::value, "bad T" );
|
||||
|
||||
|
||||
constexpr bool initialized() const noexcept { return OptionalBase<T>::init_; }
|
||||
typename ::std::remove_const<T>::type* dataptr() { return ::std::addressof(OptionalBase<T>::storage_.value_); }
|
||||
constexpr const T* dataptr() const { return detail_::static_addressof(OptionalBase<T>::storage_.value_); }
|
||||
|
||||
|
||||
# if OPTIONAL_HAS_THIS_RVALUE_REFS == 1
|
||||
constexpr const T& contained_val() const& { return OptionalBase<T>::storage_.value_; }
|
||||
# if OPTIONAL_HAS_MOVE_ACCESSORS == 1
|
||||
|
@ -1121,7 +1121,7 @@ class optional : private OptionalBase<T>
|
|||
if (initialized()) dataptr()->T::~T();
|
||||
OptionalBase<T>::init_ = false;
|
||||
}
|
||||
|
||||
|
||||
template <class... Args>
|
||||
void initialize(Args&&... args) noexcept(noexcept(T(::std::forward<Args>(args)...)))
|
||||
{
|
||||
|
@ -1154,7 +1154,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
optional(const optional<T&>& rhs) : optional()
|
||||
optional(const optional<T&>& rhs) : optional()
|
||||
{
|
||||
if (rhs) {
|
||||
::new (static_cast<void*>(dataptr())) T(*rhs);
|
||||
|
@ -1192,7 +1192,7 @@ public:
|
|||
clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
optional& operator=(const optional& rhs)
|
||||
{
|
||||
if (initialized() == true && rhs.initialized() == false) clear();
|
||||
|
@ -1200,7 +1200,7 @@ public:
|
|||
else if (initialized() == true && rhs.initialized() == true) contained_val() = *rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
optional& operator=(optional&& rhs)
|
||||
noexcept(::std::is_nothrow_move_assignable<T>::value && ::std::is_nothrow_move_constructible<T>::value)
|
||||
{
|
||||
|
@ -1222,21 +1222,21 @@ public:
|
|||
else { initialize(::std::forward<U>(v)); }
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template <class... Args>
|
||||
void emplace(Args&&... args)
|
||||
{
|
||||
clear();
|
||||
initialize(::std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
template <class U, class... Args>
|
||||
void emplace(::std::initializer_list<U> il, Args&&... args)
|
||||
{
|
||||
clear();
|
||||
initialize<U, Args...>(il, ::std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
// 20.5.4.4, Swap
|
||||
void swap(optional<T>& rhs) noexcept(::std::is_nothrow_move_constructible<T>::value && noexcept(swap(::std::declval<T&>(), ::std::declval<T&>())))
|
||||
{
|
||||
|
@ -1246,29 +1246,29 @@ public:
|
|||
}
|
||||
|
||||
// 20.5.4.5, Observers
|
||||
|
||||
|
||||
explicit constexpr operator bool() const noexcept { return initialized(); }
|
||||
|
||||
|
||||
constexpr T const* operator ->() const {
|
||||
return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), dataptr());
|
||||
}
|
||||
|
||||
|
||||
# if OPTIONAL_HAS_MOVE_ACCESSORS == 1
|
||||
|
||||
OPTIONAL_MUTABLE_CONSTEXPR T* operator ->() {
|
||||
assert (initialized());
|
||||
return dataptr();
|
||||
}
|
||||
|
||||
|
||||
constexpr T const& operator *() const& {
|
||||
return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), contained_val());
|
||||
}
|
||||
|
||||
|
||||
OPTIONAL_MUTABLE_CONSTEXPR T& operator *() & {
|
||||
assert (initialized());
|
||||
return contained_val();
|
||||
}
|
||||
|
||||
|
||||
OPTIONAL_MUTABLE_CONSTEXPR T&& operator *() && {
|
||||
assert (initialized());
|
||||
return constexpr_move(contained_val());
|
||||
|
@ -1277,42 +1277,42 @@ public:
|
|||
constexpr T const& value() const& {
|
||||
return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val());
|
||||
}
|
||||
|
||||
|
||||
OPTIONAL_MUTABLE_CONSTEXPR T& value() & {
|
||||
return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val());
|
||||
}
|
||||
|
||||
|
||||
OPTIONAL_MUTABLE_CONSTEXPR T&& value() && {
|
||||
if (!initialized()) throw bad_optional_access("bad optional access");
|
||||
return ::std::move(contained_val());
|
||||
}
|
||||
|
||||
|
||||
# else
|
||||
|
||||
T* operator ->() {
|
||||
assert (initialized());
|
||||
return dataptr();
|
||||
}
|
||||
|
||||
|
||||
constexpr T const& operator *() const {
|
||||
return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), contained_val());
|
||||
}
|
||||
|
||||
|
||||
T& operator *() {
|
||||
assert (initialized());
|
||||
return contained_val();
|
||||
}
|
||||
|
||||
|
||||
constexpr T const& value() const {
|
||||
return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val());
|
||||
}
|
||||
|
||||
|
||||
T& value() {
|
||||
return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val());
|
||||
}
|
||||
|
||||
|
||||
# endif
|
||||
|
||||
|
||||
# if OPTIONAL_HAS_THIS_RVALUE_REFS == 1
|
||||
|
||||
template <class V>
|
||||
|
@ -1320,7 +1320,7 @@ public:
|
|||
{
|
||||
return *this ? **this : detail_::convert<T>(constexpr_forward<V>(v));
|
||||
}
|
||||
|
||||
|
||||
# if OPTIONAL_HAS_MOVE_ACCESSORS == 1
|
||||
|
||||
template <class V>
|
||||
|
@ -1330,17 +1330,17 @@ public:
|
|||
}
|
||||
|
||||
# else
|
||||
|
||||
|
||||
template <class V>
|
||||
T value_or(V&& v) &&
|
||||
{
|
||||
return *this ? constexpr_move(const_cast<optional<T>&>(*this).contained_val()) : detail_::convert<T>(constexpr_forward<V>(v));
|
||||
}
|
||||
|
||||
|
||||
# endif
|
||||
|
||||
|
||||
# else
|
||||
|
||||
|
||||
template <class V>
|
||||
constexpr T value_or(V&& v) const
|
||||
{
|
||||
|
@ -1357,42 +1357,42 @@ class optional<T&>
|
|||
static_assert( !::std::is_same<T, nullopt_t>::value, "bad T" );
|
||||
static_assert( !::std::is_same<T, in_place_t>::value, "bad T" );
|
||||
T* ref;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// 20.5.5.1, construction/destruction
|
||||
constexpr optional() noexcept : ref(nullptr) {}
|
||||
|
||||
|
||||
constexpr optional(nullopt_t) noexcept : ref(nullptr) {}
|
||||
|
||||
|
||||
constexpr optional(T& v) noexcept : ref(detail_::static_addressof(v)) {}
|
||||
|
||||
|
||||
optional(T&&) = delete;
|
||||
|
||||
|
||||
constexpr optional(const optional& rhs) noexcept : ref(rhs.ref) {}
|
||||
|
||||
|
||||
explicit constexpr optional(in_place_t, T& v) noexcept : ref(detail_::static_addressof(v)) {}
|
||||
|
||||
|
||||
explicit optional(in_place_t, T&&) = delete;
|
||||
|
||||
|
||||
~optional() = default;
|
||||
|
||||
|
||||
// 20.5.5.2, mutation
|
||||
optional& operator=(nullopt_t) noexcept {
|
||||
ref = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// optional& operator=(const optional& rhs) noexcept {
|
||||
// ref = rhs.ref;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
|
||||
// optional& operator=(optional&& rhs) noexcept {
|
||||
// ref = rhs.ref;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
|
||||
template <typename U>
|
||||
auto operator=(U&& rhs) noexcept
|
||||
-> typename ::std::enable_if
|
||||
|
@ -1404,7 +1404,7 @@ public:
|
|||
ref = rhs.ref;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template <typename U>
|
||||
auto operator=(U&& rhs) noexcept
|
||||
-> typename ::std::enable_if
|
||||
|
@ -1413,35 +1413,35 @@ public:
|
|||
optional&
|
||||
>::type
|
||||
= delete;
|
||||
|
||||
|
||||
void emplace(T& v) noexcept {
|
||||
ref = detail_::static_addressof(v);
|
||||
}
|
||||
|
||||
|
||||
void emplace(T&&) = delete;
|
||||
|
||||
|
||||
void swap(optional<T&>& rhs) noexcept
|
||||
{
|
||||
::std::swap(ref, rhs.ref);
|
||||
}
|
||||
|
||||
|
||||
// 20.5.5.3, observers
|
||||
constexpr T* operator->() const {
|
||||
return TR2_OPTIONAL_ASSERTED_EXPRESSION(ref, ref);
|
||||
}
|
||||
|
||||
|
||||
constexpr T& operator*() const {
|
||||
return TR2_OPTIONAL_ASSERTED_EXPRESSION(ref, *ref);
|
||||
}
|
||||
|
||||
|
||||
constexpr T& value() const {
|
||||
return ref ? *ref : (throw bad_optional_access("bad optional access"), *ref);
|
||||
}
|
||||
|
||||
|
||||
explicit constexpr operator bool() const noexcept {
|
||||
return ref != nullptr;
|
||||
}
|
||||
|
||||
|
||||
template <class V>
|
||||
constexpr typename ::std::decay<T>::type value_or(V&& v) const
|
||||
{
|
||||
|
@ -1743,7 +1743,7 @@ constexpr optional<X&> make_optional(::std::reference_wrapper<X> v)
|
|||
return optional<X&>(v.get());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
@ -1752,18 +1752,18 @@ namespace std
|
|||
{
|
||||
typedef typename hash<T>::result_type result_type;
|
||||
typedef sol::optional<T> argument_type;
|
||||
|
||||
|
||||
constexpr result_type operator()(argument_type const& arg) const {
|
||||
return arg ? ::std::hash<T>{}(*arg) : result_type{};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct hash<sol::optional<T&>>
|
||||
{
|
||||
typedef typename hash<T>::result_type result_type;
|
||||
typedef sol::optional<T&> argument_type;
|
||||
|
||||
|
||||
constexpr result_type operator()(argument_type const& arg) const {
|
||||
return arg ? ::std::hash<T>{}(*arg) : result_type{};
|
||||
}
|
||||
|
@ -1828,7 +1828,7 @@ namespace sol {
|
|||
#define SOL_LUA_VERSION 500
|
||||
#else
|
||||
#define SOL_LUA_VERSION 502
|
||||
#endif // Lua Version 502, 501 || luajit, 500
|
||||
#endif // Lua Version 502, 501 || luajit, 500
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _DEBUG
|
||||
|
@ -5083,7 +5083,7 @@ namespace sol {
|
|||
return lua_tostring(L, index);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct getter<char> {
|
||||
static char get(lua_State* L, int index, record& tracking) {
|
||||
|
@ -5114,7 +5114,7 @@ namespace sol {
|
|||
uint8_t* b = reinterpret_cast<uint8_t*>(&c);
|
||||
std::swap(b[0], b[1]);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
|
||||
|
@ -5569,7 +5569,7 @@ namespace sol {
|
|||
// Basically, we store all user-data like this:
|
||||
// If it's a movable/copyable value (no std::ref(x)), then we store the pointer to the new
|
||||
// data in the first sizeof(T*) bytes, and then however many bytes it takes to
|
||||
// do the actual object. Things that are std::ref or plain T* are stored as
|
||||
// do the actual object. Things that are std::ref or plain T* are stored as
|
||||
// just the sizeof(T*), and nothing else.
|
||||
T** pointerpointer = static_cast<T**>(lua_newuserdata(L, sizeof(T*) + sizeof(T)));
|
||||
T*& referencereference = *pointerpointer;
|
||||
|
@ -5635,7 +5635,7 @@ namespace sol {
|
|||
return pusher<detail::as_value_tag<T>>{}.push(L, std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct pusher<T*, meta::disable_if_t<meta::all<meta::has_begin_end<meta::unqualified_t<T>>, meta::neg<meta::any<std::is_base_of<reference, meta::unqualified_t<T>>, std::is_base_of<stack_reference, meta::unqualified_t<T>>>>>::value>> {
|
||||
template <typename... Args>
|
||||
|
@ -6139,7 +6139,7 @@ namespace sol {
|
|||
static int push(lua_State* L, const std::u16string& u16str) {
|
||||
return push(L, u16str, u16str.size());
|
||||
}
|
||||
|
||||
|
||||
static int push(lua_State* L, const std::u16string& u16str, std::size_t sz) {
|
||||
return stack::push(L, u16str.data(), u16str.data() + sz);
|
||||
}
|
||||
|
@ -6563,7 +6563,7 @@ namespace sol {
|
|||
static decltype(auto) eval(types<>, std::index_sequence<>, lua_State*, int, record&, Fx&& fx, Args&&... args) {
|
||||
return std::forward<Fx>(fx)(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
template <typename Fx, typename Arg, typename... Args, std::size_t I, std::size_t... Is, typename... FxArgs>
|
||||
static decltype(auto) eval(types<Arg, Args...>, std::index_sequence<I, Is...>, lua_State* L, int start, record& tracking, Fx&& fx, FxArgs&&... fxargs) {
|
||||
return eval(types<Args...>(), std::index_sequence<Is...>(), L, start, tracking, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)..., stack_detail::unchecked_get<Arg>(L, start + tracking.used, tracking));
|
||||
|
@ -7045,7 +7045,7 @@ namespace sol {
|
|||
// beginning of sol/protect.hpp
|
||||
|
||||
namespace sol {
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct protect_t {
|
||||
T value;
|
||||
|
@ -8672,8 +8672,8 @@ namespace sol {
|
|||
}
|
||||
};
|
||||
|
||||
int luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount, handler& h) const {
|
||||
return lua_pcallk(base_t::lua_state(), static_cast<int>(argcount), static_cast<int>(resultcount), h.stackindex, 0, nullptr);
|
||||
call_status luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount, handler& h) const {
|
||||
return static_cast<call_status>(lua_pcallk(base_t::lua_state(), static_cast<int>(argcount), static_cast<int>(resultcount), h.stackindex, 0, nullptr));
|
||||
}
|
||||
|
||||
template<std::size_t... I, typename... Ret>
|
||||
|
@ -8712,9 +8712,12 @@ namespace sol {
|
|||
};
|
||||
try {
|
||||
#endif // No Exceptions
|
||||
code = static_cast<call_status>(luacall(n, LUA_MULTRET, h));
|
||||
code = luacall(n, LUA_MULTRET, h);
|
||||
int poststacksize = lua_gettop(base_t::lua_state());
|
||||
returncount = poststacksize - (stacksize - 1);
|
||||
if (code != call_status::yielded && != call_status::ok) {
|
||||
return protected_function_result(base_t::lua_state(), lua_absindex(base_t::lua_state(), -1), returncount, returncount, code);
|
||||
}
|
||||
#ifndef SOL_NO_EXCEPTIONS
|
||||
}
|
||||
// Handle C++ errors thrown from C++ functions bound inside of lua
|
||||
|
@ -9352,7 +9355,7 @@ namespace sol {
|
|||
#ifdef _MSC_VER
|
||||
#define SOL_DEPRECATED __declspec(deprecated)
|
||||
#elif __GNUC__
|
||||
#define SOL_DEPRECATED __attribute__((deprecated))
|
||||
#define SOL_DEPRECATED __attribute__((deprecated))
|
||||
#else
|
||||
#define SOL_DEPRECATED [[deprecated]]
|
||||
#endif // compilers
|
||||
|
@ -9923,7 +9926,7 @@ namespace sol {
|
|||
struct simple_usertype_metatable : usertype_detail::registrar {
|
||||
std::vector<std::pair<object, object>> registrations;
|
||||
object callconstructfunc;
|
||||
|
||||
|
||||
template <typename N, typename F, meta::enable<meta::is_callable<meta::unwrap_unqualified_t<F>>> = meta::enabler>
|
||||
void add(lua_State* L, N&& n, F&& f) {
|
||||
registrations.emplace_back(make_object(L, std::forward<N>(n)), make_object(L, as_function(std::forward<F>(f))));
|
||||
|
@ -9971,8 +9974,8 @@ namespace sol {
|
|||
simple_usertype_metatable(lua_State* L) : simple_usertype_metatable(meta::condition<meta::all<std::is_default_constructible<T>>, decltype(default_constructor), usertype_detail::check_destructor_tag>(), L) {}
|
||||
|
||||
template<typename Arg, typename... Args, meta::disable_any<
|
||||
meta::any_same<meta::unqualified_t<Arg>,
|
||||
usertype_detail::verified_tag,
|
||||
meta::any_same<meta::unqualified_t<Arg>,
|
||||
usertype_detail::verified_tag,
|
||||
usertype_detail::add_destructor_tag,
|
||||
usertype_detail::check_destructor_tag
|
||||
>,
|
||||
|
@ -9996,7 +9999,7 @@ namespace sol {
|
|||
template <typename T>
|
||||
struct pusher<simple_usertype_metatable<T>> {
|
||||
typedef simple_usertype_metatable<T> umt_t;
|
||||
|
||||
|
||||
static int push(lua_State* L, umt_t&& umx) {
|
||||
bool hasequals = false;
|
||||
bool hasless = false;
|
||||
|
@ -10093,7 +10096,7 @@ namespace sol {
|
|||
// beginning of sol/container_usertype_metatable.hpp
|
||||
|
||||
namespace sol {
|
||||
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
|
@ -10950,7 +10953,7 @@ namespace sol {
|
|||
template <typename... Args>
|
||||
basic_table_core& add(Args&&... args) {
|
||||
auto pp = stack::push_pop(*this);
|
||||
(void)detail::swallow{0,
|
||||
(void)detail::swallow{0,
|
||||
(stack::set_ref(base_t::lua_state(), std::forward<Args>(args)), 0)...
|
||||
};
|
||||
return *this;
|
||||
|
@ -11699,6 +11702,9 @@ namespace sol {
|
|||
luacall(n, LUA_MULTRET);
|
||||
int poststacksize = lua_gettop(lua_state());
|
||||
int returncount = poststacksize - (firstreturn - 1);
|
||||
if (error()) {
|
||||
return protected_function_result(lua_state(), lua_absindex(lua_state(), -1), 1, returncount, status());
|
||||
}
|
||||
return protected_function_result(lua_state(), firstreturn, returncount, returncount, status());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user