From 72fcc1e6a5150095cc8808c4b6ec1abcf6e6a66d Mon Sep 17 00:00:00 2001 From: ThePhD Date: Fri, 10 Jun 2016 21:14:43 -0400 Subject: [PATCH] nil checks. Nil checks as far as the eye can see. --- sol/call.hpp | 6 +++--- sol/stack_check.hpp | 6 +++--- sol/usertype_metatable.hpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sol/call.hpp b/sol/call.hpp index 34bcd153..94201548 100644 --- a/sol/call.hpp +++ b/sol/call.hpp @@ -134,7 +134,7 @@ namespace call_detail { userdataref.push(); luaL_getmetatable(L, &meta[0]); - if (stack::get(L) == type::nil) { + if (type_of(L, -1) == type::nil) { lua_pop(L, 1); return luaL_error(L, "sol: unable to get usertype metatable"); } @@ -314,7 +314,7 @@ namespace call_detail { userdataref.push(); luaL_getmetatable(L, &metakey[0]); - if (stack::get(L) == type::nil) { + if (type_of(L, -1) == type::nil) { lua_pop(L, 1); return luaL_error(L, "sol: unable to get usertype metatable"); } @@ -342,7 +342,7 @@ namespace call_detail { userdataref.push(); luaL_getmetatable(L, &usertype_traits::metatable[0]); - if (stack::get(L) == type::nil) { + if (type_of(L, -1) == type::nil) { lua_pop(L, 1); std::string err = "sol: unable to get usertype metatable for "; err += usertype_traits::name; diff --git a/sol/stack_check.hpp b/sol/stack_check.hpp index 7c1a7669..84404e1a 100644 --- a/sol/stack_check.hpp +++ b/sol/stack_check.hpp @@ -274,14 +274,14 @@ struct checker { bool success = true; #ifndef SOL_NO_EXCEPTIONS lua_getfield(L, -1, &detail::base_class_check_key()[0]); - if (stack::get(L) != type::nil) { + if (type_of(L, -1) != type::nil) { void* basecastdata = lua_touserdata(L, -1); detail::throw_cast basecast = (detail::throw_cast)basecastdata; success = detail::catch_check(basecast); } #elif !defined(SOL_NO_RTTI) lua_getfield(L, -1, &detail::base_class_check_key()[0]); - if (stack::get(L) != type::nil) { + if (type_of(L, -1) != type::nil) { void* basecastdata = lua_touserdata(L, -1); detail::inheritance_check_function ic = (detail::inheritance_check_function)basecastdata; success = ic(typeid(T)); @@ -289,7 +289,7 @@ struct checker { #else // Topkek lua_getfield(L, -1, &detail::base_class_check_key()[0]); - if (stack::get(L) != type::nil) { + if (type_of(L, -1) != type::nil) { void* basecastdata = lua_touserdata(L, -1); detail::inheritance_check_function ic = (detail::inheritance_check_function)basecastdata; success = ic(detail::id_for::value); diff --git a/sol/usertype_metatable.hpp b/sol/usertype_metatable.hpp index 33ca10b8..f0b1f1ec 100644 --- a/sol/usertype_metatable.hpp +++ b/sol/usertype_metatable.hpp @@ -115,7 +115,7 @@ namespace sol { template bool contains_index(std::index_sequence) const { bool idx = false; - detail::swallow{ 0, ((idx &= usertype_detail::is_indexer(std::get(functions))), 0) ... }; + (void)detail::swallow{ 0, ((idx &= usertype_detail::is_indexer(std::get(functions))), 0) ... }; return idx; }