2020-08-10 05:17:06 +08:00
|
|
|
// sol3
|
2017-12-20 17:58:32 +08:00
|
|
|
|
2016-06-20 07:02:40 +08:00
|
|
|
// The MIT License (MIT)
|
|
|
|
|
2021-03-06 14:03:23 +08:00
|
|
|
// Copyright (c) 2013-2021 Rapptz, ThePhD and contributors
|
2016-06-20 07:02:40 +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_BIND_TRAITS_HPP
|
|
|
|
#define SOL_BIND_TRAITS_HPP
|
2016-06-04 09:40:23 +08:00
|
|
|
|
2020-08-10 05:17:06 +08:00
|
|
|
#include <sol/forward.hpp>
|
|
|
|
#include <sol/base_traits.hpp>
|
|
|
|
#include <sol/tuple.hpp>
|
2016-06-04 09:40:23 +08:00
|
|
|
|
2020-08-10 05:17:06 +08:00
|
|
|
namespace sol { namespace meta {
|
2017-09-13 14:46:56 +08:00
|
|
|
namespace meta_detail {
|
2020-11-20 04:12:56 +08:00
|
|
|
template <typename F>
|
|
|
|
using detect_deducible_signature = decltype(&F::operator(), void());
|
2017-09-13 14:46:56 +08:00
|
|
|
} // namespace meta_detail
|
|
|
|
|
2020-11-20 04:12:56 +08:00
|
|
|
template <typename F>
|
|
|
|
using call_operator_deducible = typename is_detected<meta_detail::detect_deducible_signature, F>::type;
|
|
|
|
|
|
|
|
template <typename F>
|
|
|
|
constexpr inline bool call_operator_deducible_v = call_operator_deducible<F>::value;
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
namespace meta_detail {
|
|
|
|
|
|
|
|
template <std::size_t I, typename T>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct void_tuple_element : meta::tuple_element<I, T> { };
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <std::size_t I>
|
2020-08-10 05:17:06 +08:00
|
|
|
struct void_tuple_element<I, std::tuple<>> {
|
|
|
|
typedef void type;
|
|
|
|
};
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <std::size_t I, typename T>
|
|
|
|
using void_tuple_element_t = typename void_tuple_element<I, T>::type;
|
|
|
|
|
|
|
|
template <bool it_is_noexcept, bool has_c_variadic, typename T, typename R, typename... Args>
|
|
|
|
struct basic_traits {
|
|
|
|
private:
|
2019-03-15 04:15:43 +08:00
|
|
|
using first_type = meta::conditional_t<std::is_void<T>::value, int, T>&;
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
public:
|
2020-05-22 21:38:53 +08:00
|
|
|
inline static constexpr const bool is_noexcept = it_is_noexcept;
|
|
|
|
inline static constexpr bool is_member_function = std::is_void<T>::value;
|
|
|
|
inline static constexpr bool has_c_var_arg = has_c_variadic;
|
|
|
|
inline static constexpr std::size_t arity = sizeof...(Args);
|
|
|
|
inline static constexpr std::size_t free_arity = sizeof...(Args) + static_cast<std::size_t>(!std::is_void<T>::value);
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef types<Args...> args_list;
|
|
|
|
typedef std::tuple<Args...> args_tuple;
|
|
|
|
typedef T object_type;
|
|
|
|
typedef R return_type;
|
|
|
|
typedef tuple_types<R> returns_list;
|
|
|
|
typedef R(function_type)(Args...);
|
2019-03-15 04:15:43 +08:00
|
|
|
typedef meta::conditional_t<std::is_void<T>::value, args_list, types<first_type, Args...>> free_args_list;
|
|
|
|
typedef meta::conditional_t<std::is_void<T>::value, R(Args...), R(first_type, Args...)> free_function_type;
|
|
|
|
typedef meta::conditional_t<std::is_void<T>::value, R (*)(Args...), R (*)(first_type, Args...)> free_function_pointer_type;
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef std::remove_pointer_t<free_function_pointer_type> signature_type;
|
|
|
|
template <std::size_t i>
|
|
|
|
using arg_at = void_tuple_element_t<i, args_tuple>;
|
|
|
|
};
|
|
|
|
|
2020-11-20 04:12:56 +08:00
|
|
|
template <typename Signature, bool b = call_operator_deducible<Signature>::value>
|
|
|
|
struct fx_traits : public basic_traits<false, false, void, void> { };
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
// Free Functions
|
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R(Args...), false> : public basic_traits<false, false, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (*function_pointer_type)(Args...);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (*)(Args...), false> : public basic_traits<false, false, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (*function_pointer_type)(Args...);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R(Args..., ...), false> : public basic_traits<false, true, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (*function_pointer_type)(Args..., ...);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (*)(Args..., ...), false> : public basic_traits<false, true, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (*function_pointer_type)(Args..., ...);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Member Functions
|
|
|
|
/* C-Style Variadics */
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...), false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...), false> : public basic_traits<false, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Const Volatile */
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const, false> : public basic_traits<false, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const volatile, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const volatile;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const volatile, false> : public basic_traits<false, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const volatile;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Member Function Qualifiers */
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...)&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) &;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...)&, false> : public basic_traits<false, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) &;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const&, false> : public basic_traits<false, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const volatile&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const volatile&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const volatile&, false> : public basic_traits<false, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const volatile&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...)&&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) &&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...)&&, false> : public basic_traits<false, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) &&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const&&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const&&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const&&, false> : public basic_traits<false, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const&&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const volatile&&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const volatile&&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const volatile&&, false> : public basic_traits<false, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const volatile&&;
|
|
|
|
};
|
2016-06-20 07:02:40 +08:00
|
|
|
|
2020-08-10 05:17:06 +08:00
|
|
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
2017-06-17 06:43:40 +08:00
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (*function_pointer_type)(Args...) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (*)(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (*function_pointer_type)(Args...) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R(Args..., ...) noexcept, false> : public basic_traits<true, true, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (*function_pointer_type)(Args..., ...) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (*)(Args..., ...) noexcept, false> : public basic_traits<true, true, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (*function_pointer_type)(Args..., ...) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Const Volatile */
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const volatile noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const volatile noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const volatile noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const volatile noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...)& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) & noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...)& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) & noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const& noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const& noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const volatile& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const volatile& noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const volatile& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const volatile& noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...)&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) && noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...)&& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) && noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const&& noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const&& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const&& noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args...) const volatile&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args...) const volatile&& noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (T::*)(Args..., ...) const volatile&& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (T::*function_pointer_type)(Args..., ...) const volatile&& noexcept;
|
|
|
|
};
|
2017-06-15 01:28:12 +08:00
|
|
|
|
2017-06-17 06:43:40 +08:00
|
|
|
#endif // noexcept is part of a function's type
|
2017-06-15 01:28:12 +08:00
|
|
|
|
2020-08-10 05:17:06 +08:00
|
|
|
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) && SOL_IS_ON(SOL_PLATFORM_X86_I_)
|
2017-09-13 14:46:56 +08:00
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R __stdcall(Args...), false> : public basic_traits<false, false, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R(__stdcall* function_pointer_type)(Args...);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R(__stdcall*)(Args...), false> : public basic_traits<false, false, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R(__stdcall* function_pointer_type)(Args...);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...), false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Const Volatile */
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const volatile, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Member Function Qualifiers */
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...)&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) &;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const volatile&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...)&&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) &&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const&&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const&&;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const volatile&&, false> : public basic_traits<false, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&&;
|
|
|
|
};
|
2017-08-11 15:24:17 +08:00
|
|
|
|
2020-08-10 05:17:06 +08:00
|
|
|
#if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_)
|
2017-08-11 15:24:17 +08:00
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R __stdcall(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R(__stdcall* function_pointer_type)(Args...) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R(__stdcall*)(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R(__stdcall* function_pointer_type)(Args...) noexcept;
|
|
|
|
};
|
|
|
|
|
2018-01-31 00:02:46 +08:00
|
|
|
/* __stdcall cannot be applied to functions with varargs*/
|
|
|
|
/*template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<__stdcall R(Args..., ...) noexcept, false> : public basic_traits<true, true, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R(__stdcall* function_pointer_type)(Args..., ...) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall *)(Args..., ...) noexcept, false> : public basic_traits<true, true, void, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R(__stdcall* function_pointer_type)(Args..., ...) noexcept;
|
2018-01-31 00:02:46 +08:00
|
|
|
};*/
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) noexcept;
|
|
|
|
};
|
|
|
|
|
2018-01-31 00:02:46 +08:00
|
|
|
/* __stdcall does not work with varargs */
|
|
|
|
/*template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args..., ...) noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args..., ...) noexcept;
|
2018-01-31 00:02:46 +08:00
|
|
|
};*/
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
/* Const Volatile */
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const noexcept;
|
|
|
|
};
|
|
|
|
|
2018-01-31 00:02:46 +08:00
|
|
|
/* __stdcall does not work with varargs */
|
|
|
|
/*template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args..., ...) const noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const noexcept;
|
2018-01-31 00:02:46 +08:00
|
|
|
};*/
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const volatile noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile noexcept;
|
|
|
|
};
|
|
|
|
|
2018-01-31 00:02:46 +08:00
|
|
|
/* __stdcall does not work with varargs */
|
|
|
|
/*template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args..., ...) const volatile noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const volatile noexcept;
|
2018-01-31 00:02:46 +08:00
|
|
|
};*/
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...)& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) & noexcept;
|
|
|
|
};
|
|
|
|
|
2018-01-31 00:02:46 +08:00
|
|
|
/* __stdcall does not work with varargs */
|
|
|
|
/*template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args..., ...) & noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args..., ...) & noexcept;
|
2018-01-31 00:02:46 +08:00
|
|
|
};*/
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const& noexcept;
|
|
|
|
};
|
|
|
|
|
2018-01-31 00:02:46 +08:00
|
|
|
/* __stdcall does not work with varargs */
|
|
|
|
/*template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args..., ...) const& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const& noexcept;
|
2018-01-31 00:02:46 +08:00
|
|
|
};*/
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const volatile& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile& noexcept;
|
|
|
|
};
|
|
|
|
|
2018-01-31 00:02:46 +08:00
|
|
|
/* __stdcall does not work with varargs */
|
|
|
|
/*template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args..., ...) const volatile& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const volatile& noexcept;
|
2018-01-31 00:02:46 +08:00
|
|
|
};*/
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...)&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) && noexcept;
|
|
|
|
};
|
|
|
|
|
2018-01-31 00:02:46 +08:00
|
|
|
/* __stdcall does not work with varargs */
|
|
|
|
/*template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args..., ...) && noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args..., ...) && noexcept;
|
2018-01-31 00:02:46 +08:00
|
|
|
};*/
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const&& noexcept;
|
|
|
|
};
|
|
|
|
|
2018-01-31 00:02:46 +08:00
|
|
|
/* __stdcall does not work with varargs */
|
|
|
|
/*template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args..., ...) const&& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const&& noexcept;
|
2018-01-31 00:02:46 +08:00
|
|
|
};*/
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args...) const volatile&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&& noexcept;
|
|
|
|
};
|
|
|
|
|
2018-01-31 00:02:46 +08:00
|
|
|
/* __stdcall does not work with varargs */
|
|
|
|
/*template <typename T, typename R, typename... Args>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<R (__stdcall T::*)(Args..., ...) const volatile&& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const volatile&& noexcept;
|
2018-01-31 00:02:46 +08:00
|
|
|
};*/
|
2017-08-11 15:24:17 +08:00
|
|
|
#endif // noexcept is part of a function's type
|
|
|
|
#endif // __stdcall x86 VC++ bug
|
|
|
|
|
2017-09-13 14:46:56 +08:00
|
|
|
template <typename Signature>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct fx_traits<Signature, true> : public fx_traits<typename fx_traits<decltype(&Signature::operator())>::function_type, false> { };
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename Signature, bool b = std::is_member_object_pointer<Signature>::value>
|
2020-11-20 04:12:56 +08:00
|
|
|
struct callable_traits : public fx_traits<std::decay_t<Signature>> { };
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename R, typename T>
|
|
|
|
struct callable_traits<R(T::*), true> {
|
2019-03-15 04:15:43 +08:00
|
|
|
typedef meta::conditional_t<std::is_array_v<R>, std::add_lvalue_reference_t<R>, R> return_type;
|
2018-03-19 11:41:03 +08:00
|
|
|
typedef return_type Arg;
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef T object_type;
|
|
|
|
using signature_type = R(T::*);
|
2020-05-22 21:38:53 +08:00
|
|
|
inline static constexpr bool is_noexcept = false;
|
|
|
|
inline static constexpr bool is_member_function = false;
|
|
|
|
inline static constexpr std::size_t arity = 1;
|
|
|
|
inline static constexpr std::size_t free_arity = 2;
|
2017-09-13 14:46:56 +08:00
|
|
|
typedef std::tuple<Arg> args_tuple;
|
|
|
|
typedef types<Arg> args_list;
|
|
|
|
typedef types<T, Arg> free_args_list;
|
2018-03-19 11:41:03 +08:00
|
|
|
typedef meta::tuple_types<return_type> returns_list;
|
|
|
|
typedef return_type(function_type)(T&, return_type);
|
2020-08-10 05:17:06 +08:00
|
|
|
typedef return_type (*function_pointer_type)(T&, Arg);
|
|
|
|
typedef return_type (*free_function_pointer_type)(T&, Arg);
|
2017-09-13 14:46:56 +08:00
|
|
|
template <std::size_t i>
|
|
|
|
using arg_at = void_tuple_element_t<i, args_tuple>;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace meta_detail
|
|
|
|
|
|
|
|
template <typename Signature>
|
2020-11-20 04:12:56 +08:00
|
|
|
using bind_traits = meta_detail::callable_traits<Signature>;
|
|
|
|
|
|
|
|
namespace meta_detail {
|
|
|
|
template <typename, bool>
|
|
|
|
struct is_probably_stateless_lambda : std::false_type { };
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct is_probably_stateless_lambda<T, true> : std::is_convertible<T, typename bind_traits<T>::function_type*>::type { };
|
|
|
|
} // namespace meta_detail
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
using is_probably_stateless_lambda = typename meta_detail::is_probably_stateless_lambda<T, std::is_empty_v<T> && call_operator_deducible_v<T>>::type;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
inline constexpr bool is_probably_stateless_lambda_v = is_probably_stateless_lambda<T>::value;
|
2017-09-13 14:46:56 +08:00
|
|
|
|
|
|
|
template <typename Signature>
|
|
|
|
using function_args_t = typename bind_traits<Signature>::args_list;
|
|
|
|
|
|
|
|
template <typename Signature>
|
|
|
|
using function_signature_t = typename bind_traits<Signature>::signature_type;
|
|
|
|
|
|
|
|
template <typename Signature>
|
|
|
|
using function_return_t = typename bind_traits<Signature>::return_type;
|
2020-08-10 05:17:06 +08:00
|
|
|
}} // namespace sol::meta
|
2016-06-20 07:02:40 +08:00
|
|
|
|
2016-06-20 19:03:44 +08:00
|
|
|
#endif // SOL_BIND_TRAITS_HPP
|