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:
ThePhD 2016-06-20 07:03:44 -04:00
parent 6cc8676bc7
commit 0faacb5d2c
3 changed files with 7 additions and 8 deletions

View File

@ -239,4 +239,4 @@ namespace sol {
} // meta
} // sol
#endif // SOL_BIND_TRAITS
#endif // SOL_BIND_TRAITS_HPP

View File

@ -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);
}
};

View File

@ -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) {