2017-12-20 17:58:32 +08:00
|
|
|
// sol2
|
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
// The MIT License (MIT)
|
2016-12-16 18:31:32 +08:00
|
|
|
|
2018-02-20 10:15:26 +08:00
|
|
|
// Copyright (c) 2013-2018 Rapptz, ThePhD and contributors
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
// this software and associated documentation files (the "Software"), to deal in
|
|
|
|
// the Software without restriction, including without limitation the rights to
|
|
|
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
// subject to the following conditions:
|
|
|
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
|
|
// copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
#ifndef SOL_TYPES_HPP
|
|
|
|
#define SOL_TYPES_HPP
|
|
|
|
|
2017-07-10 00:00:57 +08:00
|
|
|
#include "error.hpp"
|
2016-12-16 18:31:32 +08:00
|
|
|
#include "optional.hpp"
|
|
|
|
#include "compatibility.hpp"
|
2017-07-10 00:00:57 +08:00
|
|
|
#include "forward.hpp"
|
2017-08-22 03:25:43 +08:00
|
|
|
#include "forward_detail.hpp"
|
2016-12-16 18:31:32 +08:00
|
|
|
#include "traits.hpp"
|
2017-09-06 08:29:21 +08:00
|
|
|
#include "string_view.hpp"
|
2017-08-22 03:25:43 +08:00
|
|
|
#include "raii.hpp"
|
|
|
|
#include "filters.hpp"
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
#include <array>
|
2017-09-23 06:54:33 +08:00
|
|
|
#include <initializer_list>
|
2016-12-16 18:31:32 +08:00
|
|
|
#include <string>
|
2017-07-10 00:00:57 +08:00
|
|
|
#ifdef SOL_CXX17_FEATURES
|
|
|
|
#include <string_view>
|
|
|
|
#include <variant>
|
|
|
|
#endif // C++17
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
namespace sol {
|
|
|
|
namespace detail {
|
2017-06-17 06:43:40 +08:00
|
|
|
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef int (*lua_CFunction_noexcept)(lua_State* L) noexcept;
|
2017-12-12 01:31:30 +08:00
|
|
|
#else
|
|
|
|
typedef int(*lua_CFunction_noexcept)(lua_State* L);
|
2017-06-17 06:43:40 +08:00
|
|
|
#endif // noexcept function type for lua_CFunction
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
#ifdef SOL_NO_EXCEPTIONS
|
|
|
|
template <lua_CFunction f>
|
2017-06-17 06:43:40 +08:00
|
|
|
int static_trampoline(lua_State* L) noexcept {
|
2016-12-16 18:31:32 +08:00
|
|
|
return f(L);
|
|
|
|
}
|
|
|
|
|
2017-06-17 12:43:26 +08:00
|
|
|
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
|
|
|
template <lua_CFunction_noexcept f>
|
|
|
|
int static_trampoline_noexcept(lua_State* L) noexcept {
|
|
|
|
return f(L);
|
|
|
|
}
|
2017-12-11 04:56:49 +08:00
|
|
|
#else
|
|
|
|
template <lua_CFunction f>
|
|
|
|
int static_trampoline_noexcept(lua_State* L) noexcept {
|
|
|
|
return f(L);
|
|
|
|
}
|
2017-06-17 12:43:26 +08:00
|
|
|
#endif
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
template <typename Fx, typename... Args>
|
2017-06-17 06:43:40 +08:00
|
|
|
int trampoline(lua_State* L, Fx&& f, Args&&... args) noexcept {
|
2016-12-16 18:31:32 +08:00
|
|
|
return f(L, std::forward<Args>(args)...);
|
|
|
|
}
|
|
|
|
|
2017-06-17 06:43:40 +08:00
|
|
|
inline int c_trampoline(lua_State* L, lua_CFunction f) noexcept {
|
2016-12-16 18:31:32 +08:00
|
|
|
return trampoline(L, f);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
template <lua_CFunction f>
|
|
|
|
int static_trampoline(lua_State* L) {
|
2017-11-10 06:41:46 +08:00
|
|
|
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
|
|
|
return f(L);
|
|
|
|
|
|
|
|
#else
|
2016-12-16 18:31:32 +08:00
|
|
|
try {
|
|
|
|
return f(L);
|
2017-10-27 01:15:02 +08:00
|
|
|
}
|
2017-11-11 20:42:14 +08:00
|
|
|
catch (const char* cs) {
|
|
|
|
lua_pushstring(L, cs);
|
|
|
|
}
|
|
|
|
catch (const std::string& s) {
|
|
|
|
lua_pushlstring(L, s.c_str(), s.size());
|
2016-12-16 18:31:32 +08:00
|
|
|
}
|
|
|
|
catch (const std::exception& e) {
|
|
|
|
lua_pushstring(L, e.what());
|
|
|
|
}
|
2017-11-11 20:42:14 +08:00
|
|
|
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
2017-11-10 06:41:46 +08:00
|
|
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
|
|
|
// but LuaJIT will swallow all C++ errors
|
|
|
|
// if we don't at least catch std::exception ones
|
2016-12-16 18:31:32 +08:00
|
|
|
catch (...) {
|
|
|
|
lua_pushstring(L, "caught (...) exception");
|
|
|
|
}
|
2017-11-10 06:41:46 +08:00
|
|
|
#endif // LuaJIT cannot have the catchall, but we must catch std::exceps for it
|
2016-12-16 18:31:32 +08:00
|
|
|
return lua_error(L);
|
2017-11-11 20:42:14 +08:00
|
|
|
#endif // Safe exceptions
|
2016-12-16 18:31:32 +08:00
|
|
|
}
|
|
|
|
|
2017-06-17 06:43:40 +08:00
|
|
|
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
|
|
|
|
#if 0
|
2017-09-13 14:46:56 +08:00
|
|
|
// 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
|
2017-06-17 06:43:40 +08:00
|
|
|
template <lua_CFunction_noexcept f>
|
|
|
|
int static_trampoline(lua_State* L) noexcept {
|
2017-09-13 14:46:56 +08:00
|
|
|
return f(L);
|
|
|
|
}
|
2017-06-17 06:43:40 +08:00
|
|
|
#else
|
|
|
|
template <lua_CFunction_noexcept f>
|
|
|
|
int static_trampoline_noexcept(lua_State* L) noexcept {
|
2017-06-17 12:43:26 +08:00
|
|
|
return f(L);
|
|
|
|
}
|
2017-09-13 14:46:56 +08:00
|
|
|
#endif // impossible
|
2017-06-17 12:43:26 +08:00
|
|
|
|
|
|
|
#else
|
|
|
|
template <lua_CFunction f>
|
|
|
|
int static_trampoline_noexcept(lua_State* L) noexcept {
|
2017-06-17 06:43:40 +08:00
|
|
|
return f(L);
|
|
|
|
}
|
|
|
|
#endif // noexcept lua_CFunction type
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
template <typename Fx, typename... Args>
|
|
|
|
int trampoline(lua_State* L, Fx&& f, Args&&... args) {
|
2017-06-17 06:43:40 +08:00
|
|
|
if (meta::bind_traits<meta::unqualified_t<Fx>>::is_noexcept) {
|
|
|
|
return f(L, std::forward<Args>(args)...);
|
|
|
|
}
|
2017-11-10 06:41:46 +08:00
|
|
|
#if defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_LUAJIT)
|
|
|
|
return f(L, std::forward<Args>(args)...);
|
|
|
|
#else
|
2016-12-16 18:31:32 +08:00
|
|
|
try {
|
|
|
|
return f(L, std::forward<Args>(args)...);
|
2017-10-27 01:15:02 +08:00
|
|
|
}
|
2017-09-13 14:46:56 +08:00
|
|
|
catch (const char* s) {
|
2016-12-16 18:31:32 +08:00
|
|
|
lua_pushstring(L, s);
|
|
|
|
}
|
|
|
|
catch (const std::exception& e) {
|
|
|
|
lua_pushstring(L, e.what());
|
|
|
|
}
|
2017-11-11 20:42:14 +08:00
|
|
|
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
|
2017-11-10 06:41:46 +08:00
|
|
|
// LuaJIT cannot have the catchall when the safe propagation is on
|
|
|
|
// but LuaJIT will swallow all C++ errors
|
|
|
|
// if we don't at least catch std::exception ones
|
2016-12-16 18:31:32 +08:00
|
|
|
catch (...) {
|
|
|
|
lua_pushstring(L, "caught (...) exception");
|
|
|
|
}
|
2017-11-10 06:41:46 +08:00
|
|
|
#endif
|
2016-12-16 18:31:32 +08:00
|
|
|
return lua_error(L);
|
2017-10-27 01:15:02 +08:00
|
|
|
#endif
|
2016-12-16 18:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int c_trampoline(lua_State* L, lua_CFunction f) {
|
|
|
|
return trampoline(L, f);
|
|
|
|
}
|
|
|
|
#endif // Exceptions vs. No Exceptions
|
|
|
|
|
2017-06-17 12:43:26 +08:00
|
|
|
template <typename F, F fx>
|
|
|
|
inline int typed_static_trampoline_raw(std::true_type, lua_State* L) {
|
|
|
|
return static_trampoline_noexcept<fx>(L);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename F, F fx>
|
|
|
|
inline int typed_static_trampoline_raw(std::false_type, lua_State* 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);
|
|
|
|
}
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
template <typename T>
|
|
|
|
struct unique_usertype {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct implicit_wrapper {
|
|
|
|
T& item;
|
2017-09-13 14:46:56 +08:00
|
|
|
implicit_wrapper(T* item)
|
|
|
|
: item(*item) {
|
|
|
|
}
|
|
|
|
implicit_wrapper(T& item)
|
|
|
|
: item(item) {
|
|
|
|
}
|
|
|
|
operator T&() {
|
2016-12-16 18:31:32 +08:00
|
|
|
return item;
|
|
|
|
}
|
2017-09-13 14:46:56 +08:00
|
|
|
operator T*() {
|
2016-12-16 18:31:32 +08:00
|
|
|
return std::addressof(item);
|
|
|
|
}
|
|
|
|
};
|
2017-04-03 04:10:00 +08:00
|
|
|
|
|
|
|
struct unchecked_t {};
|
|
|
|
const unchecked_t unchecked = unchecked_t{};
|
2018-02-17 13:18:26 +08:00
|
|
|
|
|
|
|
struct yield_tag_t {};
|
|
|
|
const yield_tag_t yield_tag = yield_tag_t{};
|
2017-09-13 14:46:56 +08:00
|
|
|
} // namespace detail
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
struct lua_nil_t {};
|
|
|
|
const lua_nil_t lua_nil{};
|
2017-09-13 14:46:56 +08:00
|
|
|
inline bool operator==(lua_nil_t, lua_nil_t) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
inline bool operator!=(lua_nil_t, lua_nil_t) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
typedef lua_nil_t nil_t;
|
2017-09-22 23:04:46 +08:00
|
|
|
#if !defined(SOL_NO_NIL)
|
2016-12-16 18:31:32 +08:00
|
|
|
const nil_t nil{};
|
|
|
|
#endif
|
|
|
|
|
2017-04-19 08:23:20 +08:00
|
|
|
struct metatable_t {};
|
|
|
|
const metatable_t metatable_key = {};
|
|
|
|
|
|
|
|
struct env_t {};
|
|
|
|
const env_t env_key = {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
struct no_metatable_t {};
|
|
|
|
const no_metatable_t no_metatable = {};
|
|
|
|
|
2018-02-17 13:18:26 +08:00
|
|
|
template <typename T>
|
|
|
|
struct yielding_t {
|
|
|
|
T func;
|
|
|
|
|
|
|
|
yielding_t() = default;
|
|
|
|
yielding_t(const yielding_t&) = default;
|
|
|
|
yielding_t(yielding_t&&) = default;
|
|
|
|
yielding_t& operator=(const yielding_t&) = default;
|
|
|
|
yielding_t& operator=(yielding_t&&) = default;
|
|
|
|
template <typename Arg, meta::enable<meta::neg<std::is_same<meta::unqualified_t<Arg>, yielding_t>>, meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<Arg>>>> = meta::enabler>
|
|
|
|
yielding_t(Arg&& arg)
|
|
|
|
: func(std::forward<Arg>(arg)) {
|
|
|
|
}
|
|
|
|
template <typename Arg0, typename Arg1, typename... Args>
|
|
|
|
yielding_t(Arg0&& arg0, Arg1&& arg1, Args&&... args)
|
|
|
|
: func(std::forward<Arg0>(arg0), std::forward<Arg1>(arg1), std::forward<Args>(args)...) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename F>
|
|
|
|
inline yielding_t<std::decay_t<F>> yielding(F&& f) {
|
|
|
|
return yielding_t<std::decay_t<F>>(std::forward<F>(f));
|
|
|
|
}
|
|
|
|
|
2017-09-06 01:58:17 +08:00
|
|
|
typedef std::remove_pointer_t<lua_CFunction> lua_CFunction_ref;
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct unique_usertype_traits {
|
|
|
|
typedef T type;
|
|
|
|
typedef T actual_type;
|
|
|
|
static const bool value = false;
|
|
|
|
|
|
|
|
template <typename U>
|
|
|
|
static bool is_null(U&&) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U>
|
|
|
|
static auto get(U&& value) {
|
|
|
|
return std::addressof(detail::deref(value));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct unique_usertype_traits<std::shared_ptr<T>> {
|
|
|
|
typedef T type;
|
|
|
|
typedef std::shared_ptr<T> actual_type;
|
|
|
|
static const bool value = true;
|
|
|
|
|
|
|
|
static bool is_null(const actual_type& p) {
|
|
|
|
return p == nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static type* get(const actual_type& p) {
|
|
|
|
return p.get();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename D>
|
|
|
|
struct unique_usertype_traits<std::unique_ptr<T, D>> {
|
|
|
|
typedef T type;
|
|
|
|
typedef std::unique_ptr<T, D> actual_type;
|
|
|
|
static const bool value = true;
|
|
|
|
|
|
|
|
static bool is_null(const actual_type& p) {
|
|
|
|
return p == nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static type* get(const actual_type& p) {
|
|
|
|
return p.get();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct non_null {};
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
struct function_sig {};
|
|
|
|
|
|
|
|
struct upvalue_index {
|
|
|
|
int index;
|
2017-09-13 14:46:56 +08:00
|
|
|
upvalue_index(int idx)
|
|
|
|
: index(lua_upvalueindex(idx)) {
|
2017-05-29 07:14:18 +08:00
|
|
|
}
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
operator int() const {
|
|
|
|
return index;
|
2017-05-29 07:14:18 +08:00
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct raw_index {
|
|
|
|
int index;
|
2017-09-13 14:46:56 +08:00
|
|
|
raw_index(int i)
|
|
|
|
: index(i) {
|
2017-05-29 07:14:18 +08:00
|
|
|
}
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
operator int() const {
|
|
|
|
return index;
|
2017-05-29 07:14:18 +08:00
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct absolute_index {
|
|
|
|
int index;
|
2017-09-13 14:46:56 +08:00
|
|
|
absolute_index(lua_State* L, int idx)
|
|
|
|
: index(lua_absindex(L, idx)) {
|
2017-05-29 07:14:18 +08:00
|
|
|
}
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
operator int() const {
|
|
|
|
return index;
|
2017-05-29 07:14:18 +08:00
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ref_index {
|
|
|
|
int index;
|
2017-09-13 14:46:56 +08:00
|
|
|
ref_index(int idx)
|
|
|
|
: index(idx) {
|
2017-05-29 07:14:18 +08:00
|
|
|
}
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
operator int() const {
|
|
|
|
return index;
|
2017-05-29 07:14:18 +08:00
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
2017-08-06 07:20:28 +08:00
|
|
|
struct stack_count {
|
|
|
|
int count;
|
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
stack_count(int cnt)
|
|
|
|
: count(cnt) {
|
|
|
|
}
|
2017-08-06 07:20:28 +08:00
|
|
|
};
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
struct lightuserdata_value {
|
|
|
|
void* value;
|
2017-09-13 14:46:56 +08:00
|
|
|
lightuserdata_value(void* data)
|
|
|
|
: value(data) {
|
|
|
|
}
|
|
|
|
operator void*() const {
|
|
|
|
return value;
|
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct userdata_value {
|
|
|
|
void* value;
|
2017-09-13 14:46:56 +08:00
|
|
|
userdata_value(void* data)
|
|
|
|
: value(data) {
|
|
|
|
}
|
|
|
|
operator void*() const {
|
|
|
|
return value;
|
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename L>
|
|
|
|
struct light {
|
|
|
|
L* value;
|
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
light(L& x)
|
|
|
|
: value(std::addressof(x)) {
|
|
|
|
}
|
|
|
|
light(L* x)
|
|
|
|
: value(x) {
|
|
|
|
}
|
|
|
|
light(void* x)
|
|
|
|
: value(static_cast<L*>(x)) {
|
|
|
|
}
|
|
|
|
operator L*() const {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
operator L&() const {
|
|
|
|
return *value;
|
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
auto make_light(T& l) {
|
|
|
|
typedef meta::unwrapped_t<std::remove_pointer_t<std::remove_pointer_t<T>>> L;
|
|
|
|
return light<L>(l);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U>
|
|
|
|
struct user {
|
|
|
|
U value;
|
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
user(U x)
|
|
|
|
: value(std::forward<U>(x)) {
|
|
|
|
}
|
|
|
|
operator std::add_pointer_t<std::remove_reference_t<U>>() {
|
|
|
|
return std::addressof(value);
|
|
|
|
}
|
|
|
|
operator std::add_lvalue_reference_t<U>() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
operator std::add_const_t<std::add_lvalue_reference_t<U>>&() const {
|
|
|
|
return value;
|
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
auto make_user(T&& u) {
|
|
|
|
typedef meta::unwrapped_t<meta::unqualified_t<T>> U;
|
|
|
|
return user<U>(std::forward<T>(u));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct metatable_registry_key {
|
|
|
|
T key;
|
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
metatable_registry_key(T key)
|
|
|
|
: key(std::forward<T>(key)) {
|
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
auto meta_registry_key(T&& key) {
|
|
|
|
typedef meta::unqualified_t<T> K;
|
|
|
|
return metatable_registry_key<K>(std::forward<T>(key));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Upvalues>
|
|
|
|
struct closure {
|
|
|
|
lua_CFunction c_function;
|
|
|
|
std::tuple<Upvalues...> upvalues;
|
2017-09-13 14:46:56 +08:00
|
|
|
closure(lua_CFunction f, Upvalues... targetupvalues)
|
|
|
|
: c_function(f), upvalues(std::forward<Upvalues>(targetupvalues)...) {
|
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct closure<> {
|
|
|
|
lua_CFunction c_function;
|
|
|
|
int upvalues;
|
2017-09-13 14:46:56 +08:00
|
|
|
closure(lua_CFunction f, int upvalue_count = 0)
|
|
|
|
: c_function(f), upvalues(upvalue_count) {
|
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef closure<> c_closure;
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
closure<Args...> make_closure(lua_CFunction f, Args&&... args) {
|
|
|
|
return closure<Args...>(f, std::forward<Args>(args)...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Sig, typename... Ps>
|
|
|
|
struct function_arguments {
|
|
|
|
std::tuple<Ps...> arguments;
|
|
|
|
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, function_arguments>> = meta::enabler>
|
2017-09-13 14:46:56 +08:00
|
|
|
function_arguments(Arg&& arg, Args&&... args)
|
|
|
|
: arguments(std::forward<Arg>(arg), std::forward<Args>(args)...) {
|
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Sig = function_sig<>, typename... Args>
|
|
|
|
auto as_function(Args&&... args) {
|
|
|
|
return function_arguments<Sig, std::decay_t<Args>...>(std::forward<Args>(args)...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Sig = function_sig<>, typename... Args>
|
|
|
|
auto as_function_reference(Args&&... args) {
|
|
|
|
return function_arguments<Sig, Args...>(std::forward<Args>(args)...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct as_table_t {
|
|
|
|
T source;
|
2017-09-13 14:46:56 +08:00
|
|
|
|
2017-08-06 07:20:28 +08:00
|
|
|
as_table_t() = default;
|
|
|
|
as_table_t(const as_table_t&) = default;
|
|
|
|
as_table_t(as_table_t&&) = default;
|
|
|
|
as_table_t& operator=(const as_table_t&) = default;
|
|
|
|
as_table_t& operator=(as_table_t&&) = default;
|
2017-09-13 14:46:56 +08:00
|
|
|
template <typename Arg, meta::enable<meta::neg<std::is_same<meta::unqualified_t<Arg>, as_table_t>>, meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<Arg>>>> = meta::enabler>
|
|
|
|
as_table_t(Arg&& arg)
|
|
|
|
: source(std::forward<Arg>(arg)) {
|
|
|
|
}
|
2017-08-06 07:20:28 +08:00
|
|
|
template <typename Arg0, typename Arg1, typename... Args>
|
2017-09-13 14:46:56 +08:00
|
|
|
as_table_t(Arg0&& arg0, Arg1&& arg1, Args&&... args)
|
|
|
|
: source(std::forward<Arg0>(arg0), std::forward<Arg1>(arg1), std::forward<Args>(args)...) {
|
|
|
|
}
|
2016-12-16 18:31:32 +08:00
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
operator std::add_lvalue_reference_t<T>() {
|
2016-12-16 18:31:32 +08:00
|
|
|
return source;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-31 02:11:43 +08:00
|
|
|
template <typename T>
|
|
|
|
struct nested {
|
|
|
|
T source;
|
2017-09-13 14:46:56 +08:00
|
|
|
|
2017-08-06 07:20:28 +08:00
|
|
|
nested() = default;
|
|
|
|
nested(const nested&) = default;
|
|
|
|
nested(nested&&) = default;
|
|
|
|
nested& operator=(const nested&) = default;
|
|
|
|
nested& operator=(nested&&) = default;
|
2017-09-13 14:46:56 +08:00
|
|
|
template <typename Arg, meta::enable<meta::neg<std::is_same<meta::unqualified_t<Arg>, nested>>, meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<Arg>>>> = meta::enabler>
|
|
|
|
nested(Arg&& arg)
|
|
|
|
: source(std::forward<Arg>(arg)) {
|
|
|
|
}
|
2017-08-06 07:20:28 +08:00
|
|
|
template <typename Arg0, typename Arg1, typename... Args>
|
2017-09-13 14:46:56 +08:00
|
|
|
nested(Arg0&& arg0, Arg1&& arg1, Args&&... args)
|
|
|
|
: source(std::forward<Arg0>(arg0), std::forward<Arg1>(arg1), std::forward<Args>(args)...) {
|
|
|
|
}
|
2017-03-31 02:11:43 +08:00
|
|
|
|
|
|
|
operator std::add_lvalue_reference_t<T>() {
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
template <typename T>
|
2017-12-29 01:11:12 +08:00
|
|
|
as_table_t<T> as_table_ref(T&& container) {
|
2016-12-16 18:31:32 +08:00
|
|
|
return as_table_t<T>(std::forward<T>(container));
|
2017-06-24 06:07:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2017-12-29 01:11:12 +08:00
|
|
|
as_table_t<meta::unqualified_t<T>> as_table(T&& container) {
|
|
|
|
return as_table_t<meta::unqualified_t<T>>(std::forward<T>(container));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
nested<T> as_nested_ref(T&& container) {
|
2017-08-06 07:20:28 +08:00
|
|
|
return nested<T>(std::forward<T>(container));
|
2016-12-16 18:31:32 +08:00
|
|
|
}
|
|
|
|
|
2017-12-29 01:11:12 +08:00
|
|
|
template <typename T>
|
|
|
|
nested<meta::unqualified_t<T>> as_nested(T&& container) {
|
|
|
|
return nested<meta::unqualified_t<T>>(std::forward<T>(container));
|
|
|
|
}
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
struct this_state {
|
|
|
|
lua_State* L;
|
2017-09-14 12:35:40 +08:00
|
|
|
|
|
|
|
this_state(lua_State* Ls)
|
|
|
|
: L(Ls) {
|
|
|
|
}
|
|
|
|
|
|
|
|
operator lua_State*() const noexcept {
|
|
|
|
return lua_state();
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_State* operator->() const noexcept {
|
|
|
|
return lua_state();
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_State* lua_state() const noexcept {
|
|
|
|
return L;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct this_main_state {
|
|
|
|
lua_State* L;
|
|
|
|
|
|
|
|
this_main_state(lua_State* Ls)
|
|
|
|
: L(Ls) {
|
|
|
|
}
|
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
operator lua_State*() const noexcept {
|
2017-09-12 04:12:23 +08:00
|
|
|
return lua_state();
|
|
|
|
}
|
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
lua_State* operator->() const noexcept {
|
2017-09-12 04:12:23 +08:00
|
|
|
return lua_state();
|
2016-12-16 18:31:32 +08:00
|
|
|
}
|
2017-09-12 04:12:23 +08:00
|
|
|
|
|
|
|
lua_State* lua_state() const noexcept {
|
2016-12-16 18:31:32 +08:00
|
|
|
return L;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-04-03 10:37:01 +08:00
|
|
|
struct new_table {
|
|
|
|
int sequence_hint = 0;
|
|
|
|
int map_hint = 0;
|
|
|
|
|
|
|
|
new_table() = default;
|
|
|
|
new_table(const new_table&) = default;
|
|
|
|
new_table(new_table&&) = default;
|
|
|
|
new_table& operator=(const new_table&) = default;
|
|
|
|
new_table& operator=(new_table&&) = default;
|
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
new_table(int sequence_hint, int map_hint = 0)
|
|
|
|
: sequence_hint(sequence_hint), map_hint(map_hint) {
|
|
|
|
}
|
2017-04-03 10:37:01 +08:00
|
|
|
};
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
enum class call_syntax {
|
|
|
|
dot = 0,
|
|
|
|
colon = 1
|
|
|
|
};
|
|
|
|
|
2017-08-06 07:20:28 +08:00
|
|
|
enum class load_mode {
|
|
|
|
any = 0,
|
|
|
|
text = 1,
|
|
|
|
binary = 2,
|
|
|
|
};
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
enum class call_status : int {
|
|
|
|
ok = LUA_OK,
|
|
|
|
yielded = LUA_YIELD,
|
|
|
|
runtime = LUA_ERRRUN,
|
|
|
|
memory = LUA_ERRMEM,
|
|
|
|
handler = LUA_ERRERR,
|
2017-04-01 05:38:04 +08:00
|
|
|
gc = LUA_ERRGCMM,
|
|
|
|
syntax = LUA_ERRSYNTAX,
|
|
|
|
file = LUA_ERRFILE,
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class thread_status : int {
|
|
|
|
ok = LUA_OK,
|
|
|
|
yielded = LUA_YIELD,
|
|
|
|
runtime = LUA_ERRRUN,
|
|
|
|
memory = LUA_ERRMEM,
|
|
|
|
gc = LUA_ERRGCMM,
|
|
|
|
handler = LUA_ERRERR,
|
|
|
|
dead = -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class load_status : int {
|
|
|
|
ok = LUA_OK,
|
|
|
|
syntax = LUA_ERRSYNTAX,
|
|
|
|
memory = LUA_ERRMEM,
|
|
|
|
gc = LUA_ERRGCMM,
|
|
|
|
file = LUA_ERRFILE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class type : int {
|
|
|
|
none = LUA_TNONE,
|
|
|
|
lua_nil = LUA_TNIL,
|
2017-09-22 19:30:41 +08:00
|
|
|
#if !defined(SOL_NO_NIL)
|
2016-12-16 18:31:32 +08:00
|
|
|
nil = lua_nil,
|
2017-09-22 09:32:52 +08:00
|
|
|
#endif // Objective C/C++ Keyword that's found in OSX SDK and OBJC -- check for all forms to protect
|
2016-12-16 18:31:32 +08:00
|
|
|
string = LUA_TSTRING,
|
|
|
|
number = LUA_TNUMBER,
|
|
|
|
thread = LUA_TTHREAD,
|
|
|
|
boolean = LUA_TBOOLEAN,
|
|
|
|
function = LUA_TFUNCTION,
|
|
|
|
userdata = LUA_TUSERDATA,
|
|
|
|
lightuserdata = LUA_TLIGHTUSERDATA,
|
|
|
|
table = LUA_TTABLE,
|
2017-11-18 05:54:42 +08:00
|
|
|
poly = -0xFFFF
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
2017-04-01 05:38:04 +08:00
|
|
|
inline const std::string& to_string(call_status c) {
|
2018-02-09 12:19:45 +08:00
|
|
|
static const std::array<std::string, 10> names{ {
|
2017-04-01 05:38:04 +08:00
|
|
|
"ok",
|
|
|
|
"yielded",
|
|
|
|
"runtime",
|
|
|
|
"memory",
|
|
|
|
"handler",
|
|
|
|
"gc",
|
|
|
|
"syntax",
|
|
|
|
"file",
|
2018-02-09 12:19:45 +08:00
|
|
|
"CRITICAL_EXCEPTION_FAILURE",
|
|
|
|
"CRITICAL_INDETERMINATE_STATE_FAILURE"
|
2017-09-14 12:35:40 +08:00
|
|
|
} };
|
2017-04-01 05:38:04 +08:00
|
|
|
switch (c) {
|
|
|
|
case call_status::ok:
|
|
|
|
return names[0];
|
|
|
|
case call_status::yielded:
|
|
|
|
return names[1];
|
|
|
|
case call_status::runtime:
|
|
|
|
return names[2];
|
|
|
|
case call_status::memory:
|
|
|
|
return names[3];
|
|
|
|
case call_status::handler:
|
|
|
|
return names[4];
|
|
|
|
case call_status::gc:
|
|
|
|
return names[5];
|
|
|
|
case call_status::syntax:
|
|
|
|
return names[6];
|
|
|
|
case call_status::file:
|
|
|
|
return names[7];
|
|
|
|
}
|
2018-02-09 12:19:45 +08:00
|
|
|
if (static_cast<std::ptrdiff_t>(c) == -1) {
|
|
|
|
// One of the many cases where a critical exception error has occurred
|
|
|
|
return names[8];
|
|
|
|
}
|
|
|
|
return names[9];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool is_indeterminate_call_failure(call_status c) {
|
|
|
|
switch (c) {
|
|
|
|
case call_status::ok:
|
|
|
|
case call_status::yielded:
|
|
|
|
case call_status::runtime:
|
|
|
|
case call_status::memory:
|
|
|
|
case call_status::handler:
|
|
|
|
case call_status::gc:
|
|
|
|
case call_status::syntax:
|
|
|
|
case call_status::file:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2017-04-01 05:38:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline const std::string& to_string(load_status c) {
|
2018-02-09 12:19:45 +08:00
|
|
|
static const std::array<std::string, 7> names{ {
|
2017-08-06 07:20:28 +08:00
|
|
|
"ok",
|
|
|
|
"memory",
|
|
|
|
"gc",
|
|
|
|
"syntax",
|
|
|
|
"file",
|
2018-02-09 12:19:45 +08:00
|
|
|
"CRITICAL_EXCEPTION_FAILURE",
|
|
|
|
"CRITICAL_INDETERMINATE_STATE_FAILURE"
|
2017-09-14 12:35:40 +08:00
|
|
|
} };
|
2017-04-01 05:38:04 +08:00
|
|
|
switch (c) {
|
|
|
|
case load_status::ok:
|
|
|
|
return names[0];
|
|
|
|
case load_status::memory:
|
|
|
|
return names[1];
|
|
|
|
case load_status::gc:
|
|
|
|
return names[2];
|
|
|
|
case load_status::syntax:
|
|
|
|
return names[3];
|
|
|
|
case load_status::file:
|
|
|
|
return names[4];
|
|
|
|
}
|
2018-02-09 12:19:45 +08:00
|
|
|
if (static_cast<int>(c) == -1) {
|
|
|
|
// One of the many cases where a critical exception error has occurred
|
|
|
|
return names[5];
|
|
|
|
}
|
|
|
|
return names[6];
|
2017-04-01 05:38:04 +08:00
|
|
|
}
|
|
|
|
|
2017-08-06 07:20:28 +08:00
|
|
|
inline const std::string& to_string(load_mode c) {
|
2017-09-14 12:35:40 +08:00
|
|
|
static const std::array<std::string, 3> names{ {
|
2017-08-06 07:20:28 +08:00
|
|
|
"bt",
|
|
|
|
"t",
|
|
|
|
"b",
|
2017-09-14 12:35:40 +08:00
|
|
|
} };
|
2017-08-06 07:20:28 +08:00
|
|
|
return names[static_cast<std::size_t>(c)];
|
|
|
|
}
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
enum class meta_function {
|
|
|
|
construct,
|
|
|
|
index,
|
|
|
|
new_index,
|
|
|
|
mode,
|
|
|
|
call,
|
|
|
|
call_function = call,
|
|
|
|
metatable,
|
|
|
|
to_string,
|
|
|
|
length,
|
|
|
|
unary_minus,
|
|
|
|
addition,
|
|
|
|
subtraction,
|
|
|
|
multiplication,
|
|
|
|
division,
|
|
|
|
modulus,
|
|
|
|
power_of,
|
|
|
|
involution = power_of,
|
|
|
|
concatenation,
|
|
|
|
equal_to,
|
|
|
|
less_than,
|
|
|
|
less_than_or_equal_to,
|
|
|
|
garbage_collect,
|
|
|
|
floor_division,
|
|
|
|
bitwise_left_shift,
|
|
|
|
bitwise_right_shift,
|
|
|
|
bitwise_not,
|
|
|
|
bitwise_and,
|
|
|
|
bitwise_or,
|
|
|
|
bitwise_xor,
|
2017-02-01 19:29:45 +08:00
|
|
|
pairs,
|
2017-09-07 03:09:51 +08:00
|
|
|
ipairs,
|
2017-09-06 01:58:17 +08:00
|
|
|
next,
|
|
|
|
type,
|
|
|
|
type_info,
|
2016-12-16 18:31:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef meta_function meta_method;
|
|
|
|
|
2017-09-07 03:09:51 +08:00
|
|
|
inline const std::array<std::string, 32>& meta_function_names() {
|
2017-09-14 12:35:40 +08:00
|
|
|
static const std::array<std::string, 32> names = { { "new",
|
2017-09-13 14:46:56 +08:00
|
|
|
"__index",
|
|
|
|
"__newindex",
|
|
|
|
"__mode",
|
|
|
|
"__call",
|
|
|
|
"__mt",
|
|
|
|
"__tostring",
|
|
|
|
"__len",
|
|
|
|
"__unm",
|
|
|
|
"__add",
|
|
|
|
"__sub",
|
|
|
|
"__mul",
|
|
|
|
"__div",
|
|
|
|
"__mod",
|
|
|
|
"__pow",
|
|
|
|
"__concat",
|
|
|
|
"__eq",
|
|
|
|
"__lt",
|
|
|
|
"__le",
|
|
|
|
"__gc",
|
|
|
|
|
|
|
|
"__idiv",
|
|
|
|
"__shl",
|
|
|
|
"__shr",
|
|
|
|
"__bnot",
|
|
|
|
"__band",
|
|
|
|
"__bor",
|
|
|
|
"__bxor",
|
|
|
|
|
|
|
|
"__pairs",
|
|
|
|
"__ipairs",
|
|
|
|
"__next",
|
|
|
|
"__type",
|
2017-09-14 12:35:40 +08:00
|
|
|
"__typeinfo" } };
|
2017-04-05 04:16:22 +08:00
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const std::string& to_string(meta_function mf) {
|
|
|
|
return meta_function_names()[static_cast<int>(mf)];
|
2016-12-16 18:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline type type_of(lua_State* L, int index) {
|
|
|
|
return static_cast<type>(lua_type(L, index));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::string type_name(lua_State* L, type t) {
|
|
|
|
return lua_typename(L, static_cast<int>(t));
|
|
|
|
}
|
|
|
|
|
2017-08-06 07:20:28 +08:00
|
|
|
namespace detail {
|
2017-09-23 06:54:33 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_initializer_list : std::false_type {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_initializer_list<std::initializer_list<T>> : std::true_type {};
|
|
|
|
|
2017-08-06 07:20:28 +08:00
|
|
|
template <typename T, typename C = void>
|
|
|
|
struct is_container : std::false_type {};
|
|
|
|
|
2017-09-23 06:54:33 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_container<std::initializer_list<T>> : std::false_type {};
|
|
|
|
|
2018-03-01 08:20:20 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_container<T, std::enable_if_t<meta::is_string_like<meta::unqualified_t<T>>::value>> : std::false_type {};
|
2017-08-06 07:20:28 +08:00
|
|
|
|
|
|
|
template <typename T>
|
2018-03-01 08:20:20 +08:00
|
|
|
struct is_container<T, std::enable_if_t<meta::all<
|
|
|
|
std::is_array<meta::unqualified_t<T>>
|
|
|
|
, meta::neg<meta::any_same<std::remove_all_extents_t<meta::unqualified_t<T>>, char, wchar_t, char16_t, char32_t>>
|
|
|
|
>::value
|
2018-02-03 14:29:06 +08:00
|
|
|
>> : std::true_type {};
|
2017-08-06 07:20:28 +08:00
|
|
|
|
|
|
|
template <typename T>
|
2018-03-01 08:20:20 +08:00
|
|
|
struct is_container<T, std::enable_if_t<meta::all<
|
|
|
|
meta::has_begin_end<meta::unqualified_t<T>>
|
|
|
|
, meta::neg<is_initializer_list<meta::unqualified_t<T>>>
|
|
|
|
, meta::neg<meta::is_string_like<meta::unqualified_t<T>>>
|
|
|
|
>::value
|
|
|
|
>> : std::true_type {};
|
2017-09-13 14:46:56 +08:00
|
|
|
} // namespace detail
|
2017-08-06 07:20:28 +08:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_container : detail::is_container<T> {};
|
|
|
|
|
2017-09-29 07:07:33 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_to_stringable : meta::any<meta::supports_to_string_member<meta::unqualified_t<T>>, meta::supports_adl_to_string<meta::unqualified_t<T>>, meta::supports_ostream_op<meta::unqualified_t<T>>> {};
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
namespace detail {
|
|
|
|
template <typename T, typename = void>
|
|
|
|
struct lua_type_of : std::integral_constant<type, type::userdata> {};
|
|
|
|
|
2018-02-03 14:29:06 +08:00
|
|
|
template <typename C, typename T, typename A>
|
|
|
|
struct lua_type_of<std::basic_string<C, T, A>> : std::integral_constant<type, type::string> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
2018-02-03 14:29:06 +08:00
|
|
|
template <typename C, typename T>
|
|
|
|
struct lua_type_of<basic_string_view<C, T>> : std::integral_constant<type, type::string> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <std::size_t N>
|
|
|
|
struct lua_type_of<char[N]> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <std::size_t N>
|
|
|
|
struct lua_type_of<wchar_t[N]> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <std::size_t N>
|
|
|
|
struct lua_type_of<char16_t[N]> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <std::size_t N>
|
|
|
|
struct lua_type_of<char32_t[N]> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<char> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<wchar_t> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<char16_t> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<char32_t> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<const char*> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<const char16_t*> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<const char32_t*> : std::integral_constant<type, type::string> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<bool> : std::integral_constant<type, type::boolean> {};
|
|
|
|
|
|
|
|
template <>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct lua_type_of<lua_nil_t> : std::integral_constant<type, type::lua_nil> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct lua_type_of<nullopt_t> : std::integral_constant<type, type::lua_nil> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct lua_type_of<std::nullptr_t> : std::integral_constant<type, type::lua_nil> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <>
|
2017-09-14 12:35:40 +08:00
|
|
|
struct lua_type_of<error> : std::integral_constant<type, type::string> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <bool b, typename Base>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct lua_type_of<basic_table_core<b, Base>> : std::integral_constant<type, type::table> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
2017-04-19 08:23:20 +08:00
|
|
|
template <>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct lua_type_of<metatable_t> : std::integral_constant<type, type::table> {};
|
2017-04-19 08:23:20 +08:00
|
|
|
|
2017-04-20 01:00:47 +08:00
|
|
|
template <typename B>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct lua_type_of<basic_environment<B>> : std::integral_constant<type, type::poly> {};
|
2017-04-20 01:00:47 +08:00
|
|
|
|
2017-04-19 08:23:20 +08:00
|
|
|
template <>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct lua_type_of<env_t> : std::integral_constant<type, type::poly> {};
|
2017-04-19 08:23:20 +08:00
|
|
|
|
2017-04-03 10:37:01 +08:00
|
|
|
template <>
|
2017-08-06 07:20:28 +08:00
|
|
|
struct lua_type_of<new_table> : std::integral_constant<type, type::table> {};
|
2017-04-03 10:37:01 +08:00
|
|
|
|
2017-03-30 13:31:55 +08:00
|
|
|
template <typename T>
|
|
|
|
struct lua_type_of<as_table_t<T>> : std::integral_constant<type, type::table> {};
|
|
|
|
|
2017-09-23 06:54:33 +08:00
|
|
|
template <typename T>
|
|
|
|
struct lua_type_of<std::initializer_list<T>> : std::integral_constant<type, type::table> {};
|
|
|
|
|
2017-09-14 12:35:40 +08:00
|
|
|
template <bool b>
|
|
|
|
struct lua_type_of<basic_reference<b>> : std::integral_constant<type, type::poly> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<stack_reference> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
|
|
|
template <typename Base>
|
|
|
|
struct lua_type_of<basic_object<Base>> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
struct lua_type_of<std::tuple<Args...>> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
|
|
|
template <typename A, typename B>
|
|
|
|
struct lua_type_of<std::pair<A, B>> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<void*> : std::integral_constant<type, type::lightuserdata> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<lightuserdata_value> : std::integral_constant<type, type::lightuserdata> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<userdata_value> : std::integral_constant<type, type::userdata> {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct lua_type_of<light<T>> : std::integral_constant<type, type::lightuserdata> {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct lua_type_of<user<T>> : std::integral_constant<type, type::userdata> {};
|
|
|
|
|
|
|
|
template <typename Base>
|
|
|
|
struct lua_type_of<basic_lightuserdata<Base>> : std::integral_constant<type, type::lightuserdata> {};
|
|
|
|
|
|
|
|
template <typename Base>
|
|
|
|
struct lua_type_of<basic_userdata<Base>> : std::integral_constant<type, type::userdata> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<lua_CFunction> : std::integral_constant<type, type::function> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<std::remove_pointer_t<lua_CFunction>> : std::integral_constant<type, type::function> {};
|
|
|
|
|
2017-08-06 07:20:28 +08:00
|
|
|
template <typename Base, bool aligned>
|
|
|
|
struct lua_type_of<basic_function<Base, aligned>> : std::integral_constant<type, type::function> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
2017-08-07 00:20:32 +08:00
|
|
|
template <typename Base, bool aligned, typename Handler>
|
|
|
|
struct lua_type_of<basic_protected_function<Base, aligned, Handler>> : std::integral_constant<type, type::function> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
2017-09-14 20:45:44 +08:00
|
|
|
template <typename Base>
|
|
|
|
struct lua_type_of<basic_coroutine<Base>> : std::integral_constant<type, type::function> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
2017-09-14 20:45:44 +08:00
|
|
|
template <typename Base>
|
|
|
|
struct lua_type_of<basic_thread<Base>> : std::integral_constant<type, type::thread> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename Signature>
|
|
|
|
struct lua_type_of<std::function<Signature>> : std::integral_constant<type, type::function> {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct lua_type_of<optional<T>> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<variadic_args> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
2017-08-06 07:20:28 +08:00
|
|
|
template <>
|
|
|
|
struct lua_type_of<variadic_results> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct lua_type_of<stack_count> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
template <>
|
|
|
|
struct lua_type_of<this_state> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
2017-09-14 12:35:40 +08:00
|
|
|
template <>
|
|
|
|
struct lua_type_of<this_main_state> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
2017-05-10 01:24:56 +08:00
|
|
|
template <>
|
|
|
|
struct lua_type_of<this_environment> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
template <>
|
|
|
|
struct lua_type_of<type> : std::integral_constant<type, type::poly> {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct lua_type_of<T*> : std::integral_constant<type, type::userdata> {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct lua_type_of<T, std::enable_if_t<std::is_arithmetic<T>::value>> : std::integral_constant<type, type::number> {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct lua_type_of<T, std::enable_if_t<std::is_enum<T>::value>> : std::integral_constant<type, type::number> {};
|
|
|
|
|
2017-07-10 00:00:57 +08:00
|
|
|
template <>
|
|
|
|
struct lua_type_of<meta_function> : std::integral_constant<type, type::string> {};
|
|
|
|
|
2017-09-06 08:29:21 +08:00
|
|
|
#ifdef SOL_CXX17_FEATURES
|
2017-07-10 00:00:57 +08:00
|
|
|
template <typename... Tn>
|
|
|
|
struct lua_type_of<std::variant<Tn...>> : std::integral_constant<type, type::poly> {};
|
|
|
|
#endif // C++ 17 (or not) features
|
2017-09-13 14:46:56 +08:00
|
|
|
|
2017-08-06 07:20:28 +08:00
|
|
|
template <typename T>
|
|
|
|
struct lua_type_of<nested<T>, std::enable_if_t<::sol::is_container<T>::value>> : std::integral_constant<type, type::table> {};
|
2017-07-10 00:00:57 +08:00
|
|
|
|
|
|
|
template <typename T>
|
2017-08-06 07:20:28 +08:00
|
|
|
struct lua_type_of<nested<T>, std::enable_if_t<!::sol::is_container<T>::value>> : lua_type_of<T> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename C, C v, template <typename...> class V, typename... Args>
|
|
|
|
struct accumulate : std::integral_constant<C, v> {};
|
|
|
|
|
|
|
|
template <typename C, C v, template <typename...> class V, typename T, typename... Args>
|
|
|
|
struct accumulate<C, v, V, T, Args...> : accumulate<C, v + V<T>::value, V, Args...> {};
|
2017-09-13 14:46:56 +08:00
|
|
|
} // namespace detail
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_unique_usertype : std::integral_constant<bool, unique_usertype_traits<T>::value> {};
|
|
|
|
|
|
|
|
template <typename T>
|
2017-02-21 07:07:02 +08:00
|
|
|
struct lua_type_of : detail::lua_type_of<T> {
|
|
|
|
typedef int SOL_INTERNAL_UNSPECIALIZED_MARKER_;
|
|
|
|
};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename T>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct lua_size : std::integral_constant<int, 1> {
|
|
|
|
typedef int SOL_INTERNAL_UNSPECIALIZED_MARKER_;
|
2017-02-21 07:07:02 +08:00
|
|
|
};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename A, typename B>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct lua_size<std::pair<A, B>> : std::integral_constant<int, lua_size<A>::value + lua_size<B>::value> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename... Args>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct lua_size<std::tuple<Args...>> : std::integral_constant<int, detail::accumulate<int, 0, lua_size, Args...>::value> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
2017-02-21 07:07:02 +08:00
|
|
|
namespace detail {
|
|
|
|
template <typename...>
|
|
|
|
struct void_ { typedef void type; };
|
|
|
|
template <typename T, typename = void>
|
|
|
|
struct has_internal_marker_impl : std::false_type {};
|
|
|
|
template <typename T>
|
|
|
|
struct has_internal_marker_impl<T, typename void_<typename T::SOL_INTERNAL_UNSPECIALIZED_MARKER_>::type> : std::true_type {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct has_internal_marker : has_internal_marker_impl<T> {};
|
2017-09-13 14:46:56 +08:00
|
|
|
} // namespace detail
|
2017-02-21 07:07:02 +08:00
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_lua_primitive : std::integral_constant<bool,
|
2017-09-13 14:46:56 +08:00
|
|
|
type::userdata != lua_type_of<meta::unqualified_t<T>>::value
|
|
|
|
|| ((type::userdata == lua_type_of<meta::unqualified_t<T>>::value)
|
|
|
|
&& detail::has_internal_marker<lua_type_of<meta::unqualified_t<T>>>::value
|
|
|
|
&& !detail::has_internal_marker<lua_size<meta::unqualified_t<T>>>::value)
|
|
|
|
|| std::is_base_of<reference, meta::unqualified_t<T>>::value
|
2017-09-14 12:35:40 +08:00
|
|
|
|| std::is_base_of<main_reference, meta::unqualified_t<T>>::value
|
2017-09-13 14:46:56 +08:00
|
|
|
|| std::is_base_of<stack_reference, meta::unqualified_t<T>>::value
|
|
|
|
|| meta::is_specialization_of<std::tuple, meta::unqualified_t<T>>::value
|
|
|
|
|| meta::is_specialization_of<std::pair, meta::unqualified_t<T>>::value> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_lua_reference : std::integral_constant<bool,
|
2017-09-13 14:46:56 +08:00
|
|
|
std::is_base_of<reference, meta::unqualified_t<T>>::value
|
2017-09-14 12:35:40 +08:00
|
|
|
|| std::is_base_of<main_reference, meta::unqualified_t<T>>::value
|
|
|
|
|| std::is_base_of<stack_reference, meta::unqualified_t<T>>::value> {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_lua_reference_or_proxy : std::integral_constant<bool,
|
|
|
|
is_lua_reference<meta::unqualified_t<T>>::value
|
|
|
|
|| meta::is_specialization_of<proxy, meta::unqualified_t<T>>::value> {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_main_threaded : std::is_base_of<main_reference, T> {};
|
2017-09-22 19:30:41 +08:00
|
|
|
|
2017-09-14 12:35:40 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_stack_based : std::is_base_of<stack_reference, T> {};
|
2017-11-10 06:41:46 +08:00
|
|
|
template <>
|
|
|
|
struct is_stack_based<variadic_args> : std::true_type {};
|
|
|
|
template <>
|
|
|
|
struct is_stack_based<unsafe_function_result> : std::true_type {};
|
|
|
|
template <>
|
|
|
|
struct is_stack_based<protected_function_result> : std::true_type {};
|
|
|
|
template <>
|
|
|
|
struct is_stack_based<stack_proxy> : std::true_type {};
|
|
|
|
template <>
|
|
|
|
struct is_stack_based<stack_proxy_base> : std::true_type {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_lua_primitive<T*> : std::true_type {};
|
2017-08-27 13:59:37 +08:00
|
|
|
template <>
|
2017-11-08 09:19:36 +08:00
|
|
|
struct is_lua_primitive<unsafe_function_result> : std::true_type {};
|
2017-08-27 13:59:37 +08:00
|
|
|
template <>
|
|
|
|
struct is_lua_primitive<protected_function_result> : std::true_type {};
|
2016-12-16 18:31:32 +08:00
|
|
|
template <typename T>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct is_lua_primitive<std::reference_wrapper<T>> : std::true_type {};
|
2016-12-16 18:31:32 +08:00
|
|
|
template <typename T>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct is_lua_primitive<user<T>> : std::true_type {};
|
2016-12-16 18:31:32 +08:00
|
|
|
template <typename T>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct is_lua_primitive<light<T>> : is_lua_primitive<T*> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_lua_primitive<optional<T>> : std::true_type {};
|
2017-08-06 07:20:28 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_lua_primitive<as_table_t<T>> : std::true_type {};
|
|
|
|
template <typename T>
|
|
|
|
struct is_lua_primitive<nested<T>> : std::true_type {};
|
2016-12-16 18:31:32 +08:00
|
|
|
template <>
|
|
|
|
struct is_lua_primitive<userdata_value> : std::true_type {};
|
|
|
|
template <>
|
|
|
|
struct is_lua_primitive<lightuserdata_value> : std::true_type {};
|
|
|
|
template <typename T>
|
|
|
|
struct is_lua_primitive<non_null<T>> : is_lua_primitive<T*> {};
|
|
|
|
|
|
|
|
template <typename T>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct is_proxy_primitive : is_lua_primitive<T> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_transparent_argument : std::false_type {};
|
|
|
|
template <>
|
|
|
|
struct is_transparent_argument<this_state> : std::true_type {};
|
2017-05-10 01:24:56 +08:00
|
|
|
template <>
|
2017-09-14 12:35:40 +08:00
|
|
|
struct is_transparent_argument<this_main_state> : std::true_type {};
|
|
|
|
template <>
|
2017-05-10 01:24:56 +08:00
|
|
|
struct is_transparent_argument<this_environment> : std::true_type {};
|
2016-12-16 18:31:32 +08:00
|
|
|
template <>
|
|
|
|
struct is_transparent_argument<variadic_args> : std::true_type {};
|
2017-08-06 07:20:28 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_variadic_arguments : std::is_same<meta::unqualified_t<T>, variadic_args> {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
2017-01-10 05:38:23 +08:00
|
|
|
template <typename T>
|
2017-08-07 14:07:21 +08:00
|
|
|
struct is_lua_index : std::is_integral<T> {};
|
2017-08-06 07:20:28 +08:00
|
|
|
template <>
|
|
|
|
struct is_lua_index<raw_index> : std::true_type {};
|
|
|
|
template <>
|
|
|
|
struct is_lua_index<absolute_index> : std::true_type {};
|
|
|
|
template <>
|
|
|
|
struct is_lua_index<ref_index> : std::true_type {};
|
|
|
|
template <>
|
|
|
|
struct is_lua_index<upvalue_index> : std::true_type {};
|
2017-01-10 05:38:23 +08:00
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
template <typename Signature>
|
|
|
|
struct lua_bind_traits : meta::bind_traits<Signature> {
|
|
|
|
private:
|
|
|
|
typedef meta::bind_traits<Signature> base_t;
|
2017-09-13 14:46:56 +08:00
|
|
|
|
2016-12-16 18:31:32 +08:00
|
|
|
public:
|
2017-08-06 07:20:28 +08:00
|
|
|
typedef std::integral_constant<bool, meta::count_for<is_variadic_arguments, typename base_t::args_list>::value != 0> runtime_variadics_t;
|
2016-12-16 18:31:32 +08:00
|
|
|
static const std::size_t true_arity = base_t::arity;
|
|
|
|
static const std::size_t arity = base_t::arity - meta::count_for<is_transparent_argument, typename base_t::args_list>::value;
|
|
|
|
static const std::size_t true_free_arity = base_t::free_arity;
|
|
|
|
static const std::size_t free_arity = base_t::free_arity - meta::count_for<is_transparent_argument, typename base_t::args_list>::value;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_table : std::false_type {};
|
|
|
|
template <bool x, typename T>
|
|
|
|
struct is_table<basic_table_core<x, T>> : std::true_type {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_function : std::false_type {};
|
2017-08-06 07:20:28 +08:00
|
|
|
template <typename T, bool aligned>
|
|
|
|
struct is_function<basic_function<T, aligned>> : std::true_type {};
|
2017-08-07 00:20:32 +08:00
|
|
|
template <typename T, bool aligned, typename Handler>
|
2017-09-13 14:46:56 +08:00
|
|
|
struct is_function<basic_protected_function<T, aligned, Handler>> : std::true_type {};
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_lightuserdata : std::false_type {};
|
|
|
|
template <typename T>
|
|
|
|
struct is_lightuserdata<basic_lightuserdata<T>> : std::true_type {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_userdata : std::false_type {};
|
|
|
|
template <typename T>
|
|
|
|
struct is_userdata<basic_userdata<T>> : std::true_type {};
|
|
|
|
|
2017-04-20 01:00:47 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_environment : std::integral_constant<bool, is_userdata<T>::value || is_table<T>::value> {};
|
2017-09-13 14:46:56 +08:00
|
|
|
|
2018-02-23 01:26:46 +08:00
|
|
|
template <typename T>
|
|
|
|
struct is_automagical : std::true_type {};
|
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
template <typename T>
|
2016-12-16 18:31:32 +08:00
|
|
|
inline type type_of() {
|
|
|
|
return lua_type_of<meta::unqualified_t<T>>::value;
|
|
|
|
}
|
2017-08-22 03:25:43 +08:00
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
template <typename T>
|
|
|
|
struct is_non_factory_constructor : std::false_type {};
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
struct is_non_factory_constructor<constructors<Args...>> : std::true_type {};
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
struct is_non_factory_constructor<constructor_wrapper<Args...>> : std::true_type {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct is_non_factory_constructor<no_construction> : std::true_type {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_constructor : is_non_factory_constructor<T> {};
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
struct is_constructor<factory_wrapper<Args...>> : std::true_type {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_constructor<protect_t<T>> : is_constructor<meta::unqualified_t<T>> {};
|
|
|
|
|
|
|
|
template <typename F, typename... Filters>
|
|
|
|
struct is_constructor<filter_wrapper<F, Filters...>> : is_constructor<meta::unqualified_t<F>> {};
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
using has_constructor = meta::any<is_constructor<meta::unqualified_t<Args>>...>;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_destructor : std::false_type {};
|
|
|
|
|
|
|
|
template <typename Fx>
|
|
|
|
struct is_destructor<destructor_wrapper<Fx>> : std::true_type {};
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
|
|
using has_destructor = meta::any<is_destructor<meta::unqualified_t<Args>>...>;
|
|
|
|
|
|
|
|
struct add_destructor_tag {};
|
|
|
|
struct check_destructor_tag {};
|
2017-09-13 14:46:56 +08:00
|
|
|
struct verified_tag {
|
|
|
|
} const verified{};
|
|
|
|
} // namespace detail
|
|
|
|
} // namespace sol
|
2016-12-16 18:31:32 +08:00
|
|
|
|
|
|
|
#endif // SOL_TYPES_HPP
|