mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Slight refactoring of implementation. Also, stray #endif due to not being recognized by include guard regex -- the formula must be kept...!
(TODO: transition sol2 to include guards...?)
This commit is contained in:
parent
6cc8676bc7
commit
0faacb5d2c
|
@ -239,4 +239,4 @@ namespace sol {
|
|||
} // meta
|
||||
} // sol
|
||||
|
||||
#endif // SOL_BIND_TRAITS
|
||||
#endif // SOL_BIND_TRAITS_HPP
|
||||
|
|
|
@ -105,9 +105,6 @@ namespace sol {
|
|||
|
||||
template<typename... Args, typename... Ret>
|
||||
static std::function<Signature> get_std_func(types<Ret...>, types<Args...>, lua_State* L, int index = -1) {
|
||||
if (lua_isnil(L, index) || lua_isnone(L, index)) {
|
||||
return nullptr;
|
||||
}
|
||||
sol::function f(L, index);
|
||||
auto fx = [f, L, index](Args&&... args) -> meta::return_type_t<Ret...> {
|
||||
return f.call<Ret...>(std::forward<Args>(args)...);
|
||||
|
@ -117,9 +114,6 @@ namespace sol {
|
|||
|
||||
template<typename... FxArgs>
|
||||
static std::function<Signature> get_std_func(types<void>, types<FxArgs...>, lua_State* L, int index = -1) {
|
||||
if (lua_isnil(L, index) || lua_isnone(L, index)) {
|
||||
return nullptr;
|
||||
}
|
||||
sol::function f(L, index);
|
||||
auto fx = [f, L, index](FxArgs&&... args) -> void {
|
||||
f(std::forward<FxArgs>(args)...);
|
||||
|
@ -133,6 +127,10 @@ namespace sol {
|
|||
}
|
||||
|
||||
static std::function<Signature> get(lua_State* L, int index) {
|
||||
type t = type_of(L, index);
|
||||
if (t == type::none || t == type::nil) {
|
||||
return nullptr;
|
||||
}
|
||||
return get_std_func(return_types(), args_lists(), L, index);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -196,7 +196,8 @@ namespace sol {
|
|||
template <typename Handler>
|
||||
static bool check(lua_State* L, int index, Handler&& handler) {
|
||||
type t = type_of(L, index);
|
||||
if (t == type::function) {
|
||||
if (t == type::nil || t == type::none || t == type::function) {
|
||||
// allow for nil to be returned
|
||||
return true;
|
||||
}
|
||||
if (t != type::userdata && t != type::table) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user