mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
nil checks. Nil checks as far as the eye can see.
This commit is contained in:
parent
e1241c110a
commit
72fcc1e6a5
|
@ -134,7 +134,7 @@ namespace call_detail {
|
|||
|
||||
userdataref.push();
|
||||
luaL_getmetatable(L, &meta[0]);
|
||||
if (stack::get<type>(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<type>(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<T>::metatable[0]);
|
||||
if (stack::get<type>(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<T>::name;
|
||||
|
|
|
@ -274,14 +274,14 @@ struct checker<T, type::userdata, C> {
|
|||
bool success = true;
|
||||
#ifndef SOL_NO_EXCEPTIONS
|
||||
lua_getfield(L, -1, &detail::base_class_check_key()[0]);
|
||||
if (stack::get<type>(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<T>(basecast);
|
||||
}
|
||||
#elif !defined(SOL_NO_RTTI)
|
||||
lua_getfield(L, -1, &detail::base_class_check_key()[0]);
|
||||
if (stack::get<type>(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<T, type::userdata, C> {
|
|||
#else
|
||||
// Topkek
|
||||
lua_getfield(L, -1, &detail::base_class_check_key()[0]);
|
||||
if (stack::get<type>(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<T>::value);
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace sol {
|
|||
template <std::size_t... I>
|
||||
bool contains_index(std::index_sequence<I...>) const {
|
||||
bool idx = false;
|
||||
detail::swallow{ 0, ((idx &= usertype_detail::is_indexer(std::get<I * 2>(functions))), 0) ... };
|
||||
(void)detail::swallow{ 0, ((idx &= usertype_detail::is_indexer(std::get<I * 2>(functions))), 0) ... };
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user